Skip to content

StreamingMp3Source

Audio source that supplies PCM samples on demand.

PropertyModifierTypeDescription
channelCountreadonlynumberNumber of audio channels.
durationpublicnumberTotal duration in seconds.
idreadonlystringStable identifier for caching computed STFT frames.
sampleRatereadonlynumberSample rate in Hz.
onRangeAvailable(handler: (range: AudioRange) => void): () => void;

Subscribes to progressive loading updates as new byte ranges arrive.

ParameterTypeDescription
handler(range: AudioRange) => voidCallback receiving the newly available time range in seconds.

Unsubscribe function.

() => void

AudioSource.onRangeAvailable


read(options: object):
| Float32Array<ArrayBufferLike>
| Promise<Float32Array<ArrayBufferLike>>;

Reads PCM samples for a specific channel and time range.

ParameterTypeDescription
options{ channel: number; endTime: number; startTime: number; }Channel index and time span in seconds.
options.channelnumber-
options.endTimenumber-
options.startTimenumber-

| Float32Array<ArrayBufferLike> | Promise<Float32Array<ArrayBufferLike>>

Float32Array of normalized audio samples.

AudioSource.read


static fromByteSource(byteSource: ByteStreamSource, options?: object): Promise<StreamingMp3Source>;
ParameterType
byteSourceByteStreamSource
options?{ decoderFactory?: Mp3DecoderFactory; id?: string; }
options.decoderFactory?Mp3DecoderFactory
options.id?string

Promise<StreamingMp3Source>


static fromReader(
reader: ReadableStreamDefaultReader<Uint8Array<ArrayBufferLike>>,
initialChunks?: Uint8Array<ArrayBufferLike>[],
totalBytes?: number,
options?: object): Promise<StreamingMp3Source>;
ParameterTypeDefault value
readerReadableStreamDefaultReader<Uint8Array<ArrayBufferLike>>undefined
initialChunksUint8Array<ArrayBufferLike>[][]
totalBytes?numberundefined
options?{ decoderFactory?: Mp3DecoderFactory; id?: string; }undefined
options.decoderFactory?Mp3DecoderFactoryundefined
options.id?stringundefined

Promise<StreamingMp3Source>


static isSupported(): Promise<boolean>;

Promise<boolean>