The number of channels to render
The duration to render in seconds
the sample rate to render at
Set this debug flag to log all events that happen in this class.
ReadonlyisIndicates if the context is an OfflineAudioContext or an AudioContext
ReadonlynameThe name of the class
StaticversionThe version number semver
What the source of the clock is, either "worker" (default), "timeout", or "offline" (none).
Same as this.now()
A reference to the Context's destination node.
Indicates if the instance was disposed. 'Disposing' an instance means that all of the Web Audio nodes that were created for the instance are disconnected and freed for garbage collection.
This is the Draw object for the context which is useful for synchronizing the draw frame with the Tone.js clock.
The type of playback, which affects tradeoffs between audio output latency and responsiveness. In addition to setting the value in seconds, the latencyHint also accepts the strings "interactive" (prioritizes low latency), "playback" (prioritizes sustained playback), "balanced" (balances latency and performance).
The listener
The amount of time into the future events are scheduled. Giving Web Audio a short amount of time into the future to schedule events can reduce clicks and improve performance. This value can be set to 0 to get the lowest latency. Adjusting this value also affects the updateInterval.
The unwrapped AudioContext or OfflineAudioContext
The current time in seconds of the AudioContext.
The current time in seconds of the AudioContext.
There is only one Transport per Context. It is created on initialization.
How often the interval callback is invoked. This number corresponds to how responsive the scheduling can be. Setting to 0 will result in the lowest practical interval based on context properties. context.updateInterval + context.lookAhead gives you the total latency between scheduling an event and hearing it.
Add an AudioWorkletProcessor module
The url of the module
Clear the function scheduled by setInterval.
The ID returned from setInterval.
Clears a previously scheduled timeout with setTimeout.
The ID returned from setTimeout.
Close the context
Create an audio worklet node from a name and options. The module must first be loaded using addAudioWorkletModule.
Optionaloptions: Partial<AudioWorkletNodeOptions>Clean up. Also closes the audio context.
Invoke all of the callbacks bound to the event with any arguments passed in.
The name of the event.
The arguments to pass to the functions listening.
The current audio context time without the lookAhead.
In most cases it is better to use now instead of immediate since
with now the lookAhead is applied equally to all components including internal components,
to making sure that everything is scheduled in sync. Mixing now and immediate
can cause some timing issues. If no lookAhead is desired, you can set the lookAhead to 0.
Override the now method to point to the internal clock time
Remove the event listener.
The event to stop listening to.
Optionalcallback: (...args: any[]) => voidThe callback which was bound to the event with Emitter.on. If no callback is given, all callbacks events are removed.
Bind a callback to a specific event.
The name of the event to listen for.
The callback to invoke when the event is emitted
Bind a callback which is only invoked once
The name of the event to listen for.
The callback to invoke when the event is emitted
Render the output of the OfflineContext
If the clock should be rendered asynchronously, which will not block the main thread, but be slightly slower.
Adds a repeating event to the context's callback clock.
The callback to invoke.
The timeout in seconds.
ID to use when invoking clearInterval.
A setTimeout which is guaranteed by the clock source.
Also runs in the offline context.
The callback to invoke.
The timeout in seconds.
ID to use when invoking clearTimeout.
StaticgetReturns all of the default options belonging to the class.
StaticmixinAdd Emitter functions (on/off/emit) to the object
Wrapper around the OfflineAudioContext
Example