Tone.Draw

↳ EXTENDS Tone
SINGLETON

Tone.Draw is useful for synchronizing visuals and audio events. Callbacks from Tone.Transport or any of the Tone.Event classes always happen before the scheduled time and are not synchronized to the animation frame so they are not good for triggering tightly synchronized visuals and sound. Tone.Draw makes it easy to schedule callbacks using the AudioContext time and uses requestAnimationFrame.

CONSTRUCTOR

new Tone.Draw ( )

EXAMPLE

Tone.Transport.schedule(function(time){
	//use the time argument to schedule a callback with Tone.Draw
	Tone.Draw.schedule(function(){
		//do drawing or DOM manipulation here
	}, time)
}, "+0.5")

Members

.anticipation

Number #

The amount of time before the scheduled time that the callback can be invoked. Default is half the time of an animation frame (0.008 seconds).

</>

.expiration

Number #

The duration after which events are not invoked.

</>

Methods

.cancel ( )

#
after

Time after which scheduled events will be removed from the scheduling timeline.

type: Time
optional
↪ returns Tone.Draw

this

Cancel events scheduled after the given time

</>

.schedule ( )

#
callback

Callback is invoked at the given time.

time

The time relative to the AudioContext time to invoke the callback.

type: Time
↪ returns Tone.Draw

this

Schedule a function at the given time to be invoked on the nearest animation frame.

</>
docs generated Sep 15 2019