The OfflineAudioContext interface is an AudioContext interface representing an audio-processing graph built from linked together AudioNodes. In contrast with a standard AudioContext, an OfflineAudioContext doesn't render the audio to the device hardware; instead, it generates it, as fast as it can, and outputs the result to an AudioBuffer.

Documentation OfflineAudioContext by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See also:

Constructor

new(numberOfChannels:Int, length:Int, sampleRate:Float)

new(contextOptions:OfflineAudioContextOptions)

Throws:

null

DOMError

Variables

read onlylength:Int

An integer representing the size of the buffer in sample-frames.

oncomplete:Function

Is an EventHandler called when processing is terminated, that is when the complete event (of type OfflineAudioCompletionEvent) is raised, after the event-based version of OfflineAudioContext.startRendering() is used.

Methods

startRendering():Promise<AudioBuffer>

Starts rendering the audio, taking into account the current connections and the current scheduled changes. This page covers both the event-based version and the promise-based version.

Throws:

null

DOMError

Inherited Variables

Defined by BaseAudioContext

read onlycurrentTime:Float

Returns a double representing an ever-increasing hardware time in seconds used for scheduling. It starts at 0.

read onlydestination:AudioDestinationNode

Returns an AudioDestinationNode representing the final destination of all audio in the context. It can be thought of as the audio-rendering device.

read onlylistener:AudioListener

Returns the AudioListener object, used for 3D spatialization.

onstatechange:Function

An event handler that runs when an event of type statechange has fired. This occurs when the AudioContext's state changes, due to the calling of one of the state change methods (AudioContext.suspend, AudioContext.resume, or AudioContext.close).

read onlysampleRate:Float

Returns a float representing the sample rate (in samples per second) used by all nodes in this context. The sample-rate of an AudioContext cannot be changed.

read onlystate:AudioContextState

Returns the current state of the AudioContext.

Inherited Methods

Defined by BaseAudioContext

createAnalyser():AnalyserNode

Creates an AnalyserNode, which can be used to expose audio time and frequency data and for example to create data visualisations.

Throws:

null

DOMError

createBiquadFilter():BiquadFilterNode

Creates a BiquadFilterNode, which represents a second order filter configurable as several different common filter types: high-pass, low-pass, band-pass, etc

Throws:

null

DOMError

createBuffer(numberOfChannels:Int, length:Int, sampleRate:Float):AudioBuffer

Creates a new, empty AudioBuffer object, which can then be populated by data and played via an AudioBufferSourceNode.

Throws:

null

DOMError

createBufferSource():AudioBufferSourceNode

Creates an AudioBufferSourceNode, which can be used to play and manipulate audio data contained within an AudioBuffer object. AudioBuffers are created using AudioContext.createBuffer or returned by AudioContext.decodeAudioData when it successfully decodes an audio track.

Throws:

null

DOMError

@:value({ numberOfInputs : 6 })createChannelMerger(numberOfInputs:Int = 6):ChannelMergerNode

Creates a ChannelMergerNode, which is used to combine channels from multiple audio streams into a single audio stream.

Throws:

null

DOMError

@:value({ numberOfOutputs : 6 })createChannelSplitter(numberOfOutputs:Int = 6):ChannelSplitterNode

Creates a ChannelSplitterNode, which is used to access the individual channels of an audio stream and process them separately.

Throws:

null

DOMError

createConstantSource():ConstantSourceNode

Creates a ConstantSourceNode object, which is an audio source that continuously outputs a monaural (one-channel) sound signal whose samples all have the same value.

Throws:

null

DOMError

createConvolver():ConvolverNode

Creates a ConvolverNode, which can be used to apply convolution effects to your audio graph, for example a reverberation effect.

Throws:

null

DOMError

@:value({ maxDelayTime : 1.0 })createDelay(maxDelayTime:Float = 1.0):DelayNode

Creates a DelayNode, which is used to delay the incoming audio signal by a certain amount. This node is also useful to create feedback loops in a Web Audio API graph.

Throws:

null

DOMError

createDynamicsCompressor():DynamicsCompressorNode

Creates a DynamicsCompressorNode, which can be used to apply acoustic compression to an audio signal.

Throws:

null

DOMError

createGain():GainNode

Creates a GainNode, which can be used to control the overall volume of the audio graph.

Throws:

null

DOMError

createIIRFilter(feedforward:Array<Float>, feedback:Array<Float>):IIRFilterNode

Creates an IIRFilterNode, which represents a second order filter configurable as several different common filter types.

Throws:

null

DOMError

createOscillator():OscillatorNode

Creates an OscillatorNode, a source representing a periodic waveform. It basically generates a tone.

Throws:

null

DOMError

createPanner():PannerNode

Creates a PannerNode, which is used to spatialise an incoming audio stream in 3D space.

Throws:

null

DOMError

createPeriodicWave(real:Float32Array, imag:Float32Array, ?constraints:Null<PeriodicWaveConstraints>):PeriodicWave

Creates a PeriodicWave, used to define a periodic waveform that can be used to determine the output of an OscillatorNode.

Throws:

null

DOMError

@:value({ numberOfOutputChannels : 2, numberOfInputChannels : 2, bufferSize : 0 })createScriptProcessor(bufferSize:Int = 0, numberOfInputChannels:Int = 2, numberOfOutputChannels:Int = 2):ScriptProcessorNode

Creates a ScriptProcessorNode, which can be used for direct audio processing via JavaScript.

Throws:

null

DOMError

createStereoPanner():StereoPannerNode

Creates a StereoPannerNode, which can be used to apply stereo panning to an audio source.

Throws:

null

DOMError

createWaveShaper():WaveShaperNode

Creates a WaveShaperNode, which is used to implement non-linear distortion effects.

Throws:

null

DOMError

decodeAudioData(audioData:ArrayBuffer, ?successCallback:AudioBuffer ‑> Void, ?errorCallback:DOMException ‑> Void):Promise<AudioBuffer>

decodeAudioData(audioData:ArrayBuffer, ?successCallback:AudioBuffer ‑> Void, ?errorCallback:() ‑> Void):Promise<AudioBuffer>

Asynchronously decodes audio file data contained in an ArrayBuffer. In this case, the ArrayBuffer is usually loaded from an XMLHttpRequest's response attribute after setting the responseType to arraybuffer. This method only works on complete files, not fragments of audio files.

Throws:

null

DOMError

resume():Promise<Void>

Resumes the progression of time in an audio context that has previously been suspended/paused.

Throws:

null

DOMError

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

Register an event handler of a specific event type on the EventTarget.

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Dispatch an event to this EventTarget.

Throws:

null

DOMError

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes an event listener from the EventTarget.

Throws:

null

DOMError