Tone.OfflineContext

↳ EXTENDS Tone.Context

Wrapper around the OfflineAudioContext

CONSTRUCTOR

new Tone.OfflineContext (
channels
,
duration
,
sampleRate
)
channels

The number of channels to render

type: Number
duration

The duration to render in samples

type: Number
sampleRate

the sample rate to render at

type: Number

Members

inherited from Tone.Context

.clockSource

String #

What the source of the clock is, either “worker” (Web Worker [default]), “timeout” (setTimeout), or “offline” (none).

</>
inherited from Tone.Context

.isContext

Boolean #

Is an instanceof Tone.Context

</>
inherited from Tone.Context

.latencyHint

String or Seconds #

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).

EXAMPLE

//set the lookAhead to 0.3 seconds
Tone.context.latencyHint = 0.3;
</>
inherited from Tone.Context

.lookAhead

Number #

The amount of time events are scheduled into the future

</>
inherited from Tone.Context

.rawContext

AudioContext READONLY #

The unwrapped AudioContext.

</>
inherited from Tone.Context

.updateInterval

Number #

How often the Web Worker 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.

</>

Methods

.createBufferSource ( )

#
</>

.now ( )

#
↪ returns Number

Override the now method to point to the internal clock time

</>

.render ( )

#
↪ returns Promise

Render the output of the OfflineContext

</>

.close ( )

#
↪ returns Promise

Close the context

</>

.resume ( )

#
↪ returns Promise

Overwrite resume, should not do anything in the OfflineAudioContext.

</>
inherited from Tone.Context

.setTimeout ( )

#
fn

The callback to invoke

timeout

The timeout in seconds

type: Seconds
↪ returns Number

ID to use when invoking Tone.Context.clearTimeout

A setTimeout which is gaurenteed by the clock source. Also runs in the offline context.

</>
inherited from Tone.Context

.dispose ( )

#
↪ returns Promise

this

Unlike other dispose methods, this returns a Promise which executes when the context is closed and disposed

</>
inherited from Tone.Context

.getConstant ( )

#
val
type: Number
↪ returns BufferSourceNode

Generate a looped buffer at some constant value.

</>
inherited from Tone.Context

.clearTimeout ( )

#
id

The ID returned from setTimeout

type: Number
↪ returns Tone.Context

this

Clears a previously scheduled timeout with Tone.context.setTimeout

</>
inherited from Tone.Emitter

.once ( )

#
event

The name of the event to listen for.

type: String
callback

The callback to invoke when the event is emitted

↪ returns Tone.Emitter

this

Bind a callback which is only invoked once

</>
inherited from Tone.Emitter

.off ( )

#
event

The event to stop listening to.

type: String
callback

The callback which was bound to the event with Tone.Emitter.on. If no callback is given, all callbacks events are removed.

optional
↪ returns Tone.Emitter

this

Remove the event listener.

</>
inherited from Tone.Emitter

.emit ( )

#
event

The name of the event.

type: String
args...

The arguments to pass to the functions listening.

type: *
↪ returns Tone.Emitter

this

Invoke all of the callbacks bound to the event with any arguments passed in.

</>
inherited from Tone.Emitter

.on ( )

#
event

The name of the event to listen for.

type: String
callback

The callback to invoke when the event is emitted

↪ returns Tone.Emitter

this

Bind a callback to a specific event.

</>
docs generated Sep 15 2019