Skip to main content

OfflineAudioContext

The OfflineAudioContext interface inherits from BaseAudioContext. In contrast with a standard AudioContext, it doesn't render audio to the device hardware. Instead, it processes the audio as quickly as possible and outputs the result to an AudioBuffer.

Constructor

OfflineAudioContext(options: OfflineAudioContextOptions)

interface OfflineAudioContextOptions {
numberOfChannels: number;
length: number; // The length of the rendered AudioBuffer, in sample-frames
sampleRate: number;
}

Properties

OfflineAudioContext does not define any additional properties. It inherits all properties from BaseAudioContext.

Methods

It inherits all methods from BaseAudioContext.

suspend

Schedules a suspension of the time progression in audio context at the specified time.

ParametersTypeDescription
suspendTimenumberA floating-point number specifying the suspend time, in seconds.

Returns Promise<undefined>.

resume

Resume time progression in audio context when it has been suspended.

Returns Promise<undefined>

startRendering

Starts rendering the audio, taking into account the current connections and the current scheduled changes.

Returns Promise<AudioBuffer>.