The callback function to invoke at the scheduled tick.
Readonly
contextThe context belonging to the node.
Set this debug flag to log all events that happen in this class.
Rest
...args: any[]The rate the callback function should be invoked.
Readonly
nameOptional
callback: ((...args) => void)Rest
...args: any[]Rest
...args: any[]Rest
...args: any[]Static
versionThe version number semver
The number of seconds of 1 processing block (128 samples)
console.log(Tone.Destination.blockTime);
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 duration in seconds of one sample.
The time since ticks=0 that the Clock has been running. Accounts for tempo curves
Returns the playback state of the source, either "started", "stopped" or "paused".
The number of times the callback was invoked. Starts counting at 0 and increments after the callback was invoked.
Returns the scheduled state at the given time.
The name of the state input in setStateAtTime.
const clock = new Tone.Clock();
clock.start("+0.1");
clock.getStateAtTime("+0.1"); // returns "started"
Get the time of the given tick. The second argument is when to test before. Since ticks can be set (with setTicksAtTime) there may be multiple times for a given tick value.
The tick number.
When to measure the tick value from.
The time of the tick
Set multiple properties at once with an object.
const filter = new Tone.Filter().toDestination();
// set values using an object
filter.set({
frequency: "C6",
type: "highpass"
});
const player = new Tone.Player("https://tonejs.github.io/audio/berklee/Analogsynth_octaves_highmid.mp3").connect(filter);
player.autostart = true;
Convert the incoming time to seconds. This is calculated against the current TransportClass bpm
const gain = new Tone.Gain();
setInterval(() => console.log(gain.toSeconds("4n")), 100);
// ramp the tempo to 60 bpm over 30 seconds
Tone.getTransport().bpm.rampTo(60, 30);
Static
get
A 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.
Example