Wrapper around the native AudioContext.
What the source of the clock is, either "worker" (default), "timeout", or "offline" (none).
The current time in seconds of the AudioContext.
Set this debug flag to log all events that happen in this class.
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.
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), and "fastest" (lowest latency, might glitch more often).
//set the lookAhead to 0.3 seconds
Tone.context.latencyHint = 0.3;
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.
The unwrapped AudioContext.
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. context.updateInterval + context.lookAhead gives you the total latency between scheduling an event and hearing it.
The version number semver
Add an AudioWorkletProcessor module
The url of the module
The name of the module
Clear the function scheduled by setInterval
Clears a previously scheduled timeout with Tone.context.setTimeout
The ID returned from setTimeout
Promise which is invoked when the context is running. Tries to resume the context if it's not started.
Create an audio worklet node from a name and options. The module must first be loaded using addAudioWorkletModule.
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.
Generate a looped buffer at some constant value.
Returns all of the default options belonging to the class.
Finish setting up the context. You usually do not need to do this manually.
Add Emitter functions (on/off/emit) to the object
The current audio context time plus a short {@link lookAhead}.
Remove the event listener.
The event to stop listening to.
The 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
Starts the audio context from a suspended state. This is required to initially start the AudioContext.
Adds a repeating event to the context's callback clock
A setTimeout which is guaranteed by the clock source. Also runs in the offline context.
The callback to invoke
Convert the class to a string
const osc = new Oscillator()
osc.toString() // "Oscillator"