Uses TickSignal to track elapsed ticks with complex automation curves.
The initial frequency that the signal ticks at
The number of seconds of 1 processing block (128 samples)
console.log(Tone.Destination.blockTime);
The context belonging to the node.
Set this debug flag to log all events that happen in this class.
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 frequency the callback function should be invoked.
The duration in seconds of one sample.
console.log(Tone.Transport.sampleTime);
The time since ticks=0 that the TickSource 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 -1 when stopped.
The version number semver
Cancel start/stop/pause and setTickAtTime events scheduled after the given time.
Invoke the callback event at all scheduled ticks between the start time and the end time
The beginning of the search range
The end of the search range
The callback to invoke with each tick
Get the object's attributes.
const osc = new Tone.Oscillator();
console.log(osc.get());
Returns all of the default options belonging to the class.
Return the elapsed seconds at the given time.
Returns the scheduled state at the given time.
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.
When to measure the tick value from.
Return the current time of the Context clock without any lookAhead.
setInterval(() => {
console.log(Tone.immediate());
}, 100);
Return the current time of the Context clock plus the lookAhead.
setInterval(() => {
console.log(Tone.now());
}, 100);
Pause the clock. Pausing does not reset the tick counter.
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;
Start the clock at the given time. Optionally pass in an offset of where to start the tick counter from.
Stop the clock. Stopping the clock resets the tick counter to 0.
Convert the input to a frequency number
const gain = new Tone.Gain();
console.log(gain.toFrequency("4n"));
Convert the incoming time to seconds. This is calculated against the current Tone.Transport 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);
Convert the class to a string
const osc = new Tone.Oscillator();
console.log(osc.toString());
Convert the input time into ticks
const gain = new Tone.Gain();
console.log(gain.toTicks("4n"));