Skip to content

ClippedAudioSource

Wraps an underlying AudioSource to restrict sample reads and visualization to a bounded time window.

new ClippedAudioSource(underlyingSource: AudioSource, bounds?: ClipBounds): ClippedAudioSource;
ParameterType
underlyingSourceAudioSource
boundsClipBounds

ClippedAudioSource

PropertyModifierTypeDescription
channelCountreadonlynumberNumber of audio channels.
sampleRatereadonlynumberSample rate in Hz.
underlyingSourcereadonlyAudioSource-
get clipDuration(): number;

number


get clipEnd(): number;

number


get clipStart(): number;

number


get duration(): number;

Total duration in seconds.

number

Total duration in seconds.

AudioSource.duration


get id(): string;

Stable identifier for caching computed STFT frames.

string

Stable identifier for caching computed STFT frames.

AudioSource.id

destroy(): void;

void


getClipBounds(): object;

object

clipEnd: number;
clipStart: number;

on<K>(event: K, handler: (e: ClippedSourceEvents[K]) => void): () => void;
Type Parameter
K extends keyof ClippedSourceEvents
ParameterType
eventK
handler(e: ClippedSourceEvents[K]) => void

() => void


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


setClipBounds(bounds: ClipBounds): void;
ParameterType
boundsClipBounds

void