Skip to content

OfflineAudioContext

Values

addEventListener

Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. Read more on MDN

let addEventListener: (
WebAudioTypes.offlineAudioContext,
EventTypes.eventType,
EventTypes.eventListener<'event>,
~options: EventTypes.addEventListenerOptions=?,
) => unit

Parameters

WebAudioTypes.offlineAudioContext EventTypes.eventType EventTypes.eventListener option< EventTypes.addEventListenerOptions >

Return type

unit

addEventListenerWithCapture

Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. Read more on MDN

let addEventListenerWithCapture: (
WebAudioTypes.offlineAudioContext,
EventTypes.eventType,
EventTypes.eventListener<'event>,
) => unit

Parameters

WebAudioTypes.offlineAudioContext EventTypes.eventType EventTypes.eventListener

Return type

unit

asBaseAudioContext

let asBaseAudioContext: WebAudioTypes.offlineAudioContext => WebAudioTypes.baseAudioContext

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.baseAudioContext

asEventTarget

let asEventTarget: WebAudioTypes.offlineAudioContext => EventTypes.eventTarget

Parameters

WebAudioTypes.offlineAudioContext

Return type

EventTypes.eventTarget

createAnalyser

let createAnalyser: WebAudioTypes.offlineAudioContext => WebAudioTypes.analyserNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.analyserNode

createBiquadFilter

let createBiquadFilter: WebAudioTypes.offlineAudioContext => WebAudioTypes.biquadFilterNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.biquadFilterNode

createBuffer

let createBuffer: (
WebAudioTypes.offlineAudioContext,
~numberOfChannels: int,
~length: int,
~sampleRate: float,
) => WebAudioTypes.audioBuffer

Parameters

WebAudioTypes.offlineAudioContext int int float

Return type

WebAudioTypes.audioBuffer

createBufferSource

let createBufferSource: WebAudioTypes.offlineAudioContext => WebAudioTypes.audioBufferSourceNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.audioBufferSourceNode

createChannelMerger

let createChannelMerger: (
WebAudioTypes.offlineAudioContext,
~numberOfInputs: int=?,
) => WebAudioTypes.channelMergerNode

Parameters

WebAudioTypes.offlineAudioContext option< int >

Return type

WebAudioTypes.channelMergerNode

createChannelSplitter

let createChannelSplitter: (
WebAudioTypes.offlineAudioContext,
~numberOfOutputs: int=?,
) => WebAudioTypes.channelSplitterNode

Parameters

WebAudioTypes.offlineAudioContext option< int >

Return type

WebAudioTypes.channelSplitterNode

createConstantSource

let createConstantSource: WebAudioTypes.offlineAudioContext => WebAudioTypes.constantSourceNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.constantSourceNode

createConvolver

let createConvolver: WebAudioTypes.offlineAudioContext => WebAudioTypes.convolverNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.convolverNode

createDelay

let createDelay: (
WebAudioTypes.offlineAudioContext,
~maxDelayTime: float=?,
) => WebAudioTypes.delayNode

Parameters

WebAudioTypes.offlineAudioContext option< float >

Return type

WebAudioTypes.delayNode

createDynamicsCompressor

let createDynamicsCompressor: WebAudioTypes.offlineAudioContext => WebAudioTypes.dynamicsCompressorNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.dynamicsCompressorNode

createGain

let createGain: WebAudioTypes.offlineAudioContext => WebAudioTypes.gainNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.gainNode

createIIRFilter

let createIIRFilter: (
WebAudioTypes.offlineAudioContext,
~feedforward: array<float>,
~feedback: array<float>,
) => WebAudioTypes.iirFilterNode

Parameters

WebAudioTypes.offlineAudioContext array< float > array< float >

Return type

WebAudioTypes.iirFilterNode

createOscillator

let createOscillator: WebAudioTypes.offlineAudioContext => WebAudioTypes.oscillatorNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.oscillatorNode

createPanner

let createPanner: WebAudioTypes.offlineAudioContext => WebAudioTypes.pannerNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.pannerNode

createPeriodicWave

let createPeriodicWave: (
WebAudioTypes.offlineAudioContext,
~real: array<float>,
~imag: array<float>,
~constraints: WebAudioTypes.periodicWaveConstraints=?,
) => WebAudioTypes.periodicWave

Parameters

WebAudioTypes.offlineAudioContext array< float > array< float > option< WebAudioTypes.periodicWaveConstraints >

Return type

WebAudioTypes.periodicWave

createStereoPanner

let createStereoPanner: WebAudioTypes.offlineAudioContext => WebAudioTypes.stereoPannerNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.stereoPannerNode

createWaveShaper

let createWaveShaper: WebAudioTypes.offlineAudioContext => WebAudioTypes.waveShaperNode

Parameters

WebAudioTypes.offlineAudioContext

Return type

WebAudioTypes.waveShaperNode

decodeAudioData

let decodeAudioData: (
WebAudioTypes.offlineAudioContext,
~audioData: ArrayBuffer.t,
~successCallback: WebAudioTypes.decodeSuccessCallback=?,
~errorCallback: WebAudioTypes.decodeErrorCallback=?,
) => promise<WebAudioTypes.audioBuffer>

Parameters

WebAudioTypes.offlineAudioContext Stdlib.ArrayBuffer.t option< WebAudioTypes.decodeSuccessCallback > option< WebAudioTypes.decodeErrorCallback >

Return type

promise< WebAudioTypes.audioBuffer >

dispatchEvent

Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. Read more on MDN

let dispatchEvent: (
WebAudioTypes.offlineAudioContext,
EventTypes.event,
) => bool

Parameters

WebAudioTypes.offlineAudioContext EventTypes.event

Return type

bool

fromChannelCountLengthAndSampleRate

fromChannelCountLengthAndSampleRate(~numberOfChannels: int, ~length: int, ~sampleRate: float)

Creates a new OfflineAudioContext from explicit channel, length, and sample-rate values.

let context =
  OfflineAudioContext.fromChannelCountLengthAndSampleRate(
    ~numberOfChannels=2,
    ~length=44_100,
    ~sampleRate=44_100.,
  )

Read more on MDN

let fromChannelCountLengthAndSampleRate: (
~numberOfChannels: int,
~length: int,
~sampleRate: float,
) => WebAudioTypes.offlineAudioContext

Parameters

int int float

Return type

WebAudioTypes.offlineAudioContext

fromOptions

fromOptions(offlineAudioContextOptions)

Creates a new OfflineAudioContext from offlineAudioContextOptions.

let context = OfflineAudioContext.fromOptions(myOfflineAudioContextOptions)

Read more on MDN

let fromOptions: WebAudioTypes.offlineAudioContextOptions => WebAudioTypes.offlineAudioContext

Parameters

WebAudioTypes.offlineAudioContextOptions

Return type

WebAudioTypes.offlineAudioContext

removeEventListener

Removes the event listener in target's event listener list with the same type, callback, and options. Read more on MDN

let removeEventListener: (
WebAudioTypes.offlineAudioContext,
EventTypes.eventType,
EventTypes.eventListener<'event>,
~options: EventTypes.eventListenerOptions=?,
) => unit

Parameters

WebAudioTypes.offlineAudioContext EventTypes.eventType EventTypes.eventListener option< EventTypes.eventListenerOptions >

Return type

unit

removeEventListenerUseCapture

Removes the event listener in target's event listener list with the same type, callback, and options. Read more on MDN

let removeEventListenerUseCapture: (
WebAudioTypes.offlineAudioContext,
EventTypes.eventType,
EventTypes.eventListener<'event>,
) => unit

Parameters

WebAudioTypes.offlineAudioContext EventTypes.eventType EventTypes.eventListener

Return type

unit

resume

let resume: WebAudioTypes.offlineAudioContext => promise<unit>

Parameters

WebAudioTypes.offlineAudioContext

Return type

promise< unit >

startRendering

let startRendering: WebAudioTypes.offlineAudioContext => promise<
WebAudioTypes.audioBuffer,
>

Parameters

WebAudioTypes.offlineAudioContext

Return type

promise< WebAudioTypes.audioBuffer >

suspend

let suspend: (WebAudioTypes.offlineAudioContext, float) => promise<unit>

Parameters

WebAudioTypes.offlineAudioContext float

Return type

promise< unit >