Tone.Clock
↳ EXTENDS Tone.EmitterA sample accurate clock which provides a callback at the given rate. While the callback is not sample-accurate (it is still susceptible to loose JS timing), the time passed in as the argument to the callback is precise. For most applications, it is better to use Tone.Transport instead of the Clock by itself since you can synchronize multiple callbacks.
CONSTRUCTOR
new Tone.Clock (The callback to be invoked with the time of the audio event
The rate of the callback
DEFAULTS
EXAMPLE
Members
.state
↝ Tone.State READONLY #Returns the playback state of the source, either “started”, “stopped” or “paused”.
.ticks
↝ Ticks READONLY #The number of times the callback was invoked. Starts counting at 0 and increments after the callback was invoked.
Methods
.pause ( )
#The time when the clock should stop.
this
Pause the clock. Pausing does not reset the tick counter.
.start ( )
#The time the clock should start
Where the tick counter starts counting from.
this
Start the clock at the given time. Optionally pass in an offset of where to start the tick counter from.
.stop ( )
#The time when the clock should stop.
this
Stop the clock. Stopping the clock resets the tick counter to 0.
EXAMPLE
.emit ( )
#The name of the event.
The arguments to pass to the functions listening.
this
Invoke all of the callbacks bound to the event with any arguments passed in.
.on ( )
#The name of the event to listen for.
The callback to invoke when the event is emitted
this
Bind a callback to a specific event.
.off ( )
#The event to stop listening to.
The callback which was bound to the event with Tone.Emitter.on. If no callback is given, all callbacks events are removed.
this
Remove the event listener.