Skip to content

Commit c287d5a

Browse files
authored
Revert "init (#492)" (#493)
1 parent ca51387 commit c287d5a

2 files changed

Lines changed: 1 addition & 35 deletions

File tree

packages/livekit-rtc/rust-sdks

Submodule rust-sdks updated 79 files

packages/livekit-rtc/src/audio_frame.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,24 @@ import { FfiClient, FfiHandle } from './ffi_client.js';
55
import type { OwnedAudioFrameBuffer } from './proto/audio_frame_pb.js';
66
import { AudioFrameBufferInfo } from './proto/audio_frame_pb.js';
77

8-
/**
9-
* A class that represents a frame of audio data with specific properties such as sample rate,
10-
* number of channels, and samples per channel.
11-
*/
128
export class AudioFrame {
139
data: Int16Array;
1410
sampleRate: number;
1511
channels: number;
1612
samplesPerChannel: number;
17-
duration: number;
1813

1914
// note: if converting from Uint8Array to Int16Array, *do not* use buffer.slice!
2015
// it is marked unstable by Node and can cause undefined behaviour, such as massive chunks of
2116
// noise being added to the end.
2217
// it is recommended to use buffer.subarray instead.
2318
// XXX(nbsp): add this when writing proper docs
24-
25-
/**
26-
* Initialize an AudioFrame instance.
27-
*
28-
* @param data - The raw audio data as Int16Array, which must be at least
29-
* `channels * samplesPerChannel` elements long.
30-
* @param sampleRate - The sample rate of the audio in Hz.
31-
* @param channels - The number of audio channels (e.g., 1 for mono, 2 for stereo).
32-
* @param samplesPerChannel - The number of samples per channel.
33-
*
34-
* @throws Error - If the length of `data` is smaller than the required size.
35-
*/
3619
constructor(data: Int16Array, sampleRate: number, channels: number, samplesPerChannel: number) {
37-
if (data.length < channels * samplesPerChannel) {
38-
throw new Error(
39-
`data length ${data.length} is smaller than required ${channels * samplesPerChannel}`,
40-
);
41-
}
42-
4320
this.data = data;
4421
this.sampleRate = sampleRate;
4522
this.channels = channels;
4623
this.samplesPerChannel = samplesPerChannel;
47-
this.duration = samplesPerChannel / sampleRate;
4824
}
4925

50-
/**
51-
* Create a new empty AudioFrame instance with specified sample rate, number of channels,
52-
* and samples per channel.
53-
*
54-
* @param sampleRate - The sample rate of the audio in Hz.
55-
* @param channels - The number of audio channels (e.g., 1 for mono, 2 for stereo).
56-
* @param samplesPerChannel - The number of samples per channel.
57-
*
58-
* @returns A new AudioFrame instance with uninitialized (zeroed) data.
59-
*/
6026
static create(sampleRate: number, channels: number, samplesPerChannel: number): AudioFrame {
6127
const data = new Int16Array(channels * samplesPerChannel);
6228
return new AudioFrame(data, sampleRate, channels, samplesPerChannel);

0 commit comments

Comments
 (0)