Loop creates a looped callback at the specified interval. The callback can be started, stopped and scheduled along the Transport's timeline.
import { Loop, Transport } from "tone";
const loop = new Loop((time) => {
// triggered every eighth note.
console.log(time);
}, "8n").start(0);
Transport.start();
The number of seconds of 1 processing block (128 samples)
The callback to invoke with the next event in the pattern
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.
Random variation +/-0.01s to the scheduled time. Or give it a time value which it will randomize by.
The time between successive callbacks.
import { Loop, Transport } from "tone";
const loop = new Loop();
loop.interval = "8n"; // loop every 8n
The number of iterations of the loop. The default value is Infinity
(loop forever).
The playback rate of the loop. The normal playback rate is 1 (no change).
A playbackRate
of 2 would be twice as fast.
The progress of the loop as a value between 0-1. 0, when the loop is stopped or done iterating.
The duration in seconds of one sample.
The state of the Loop, either started or stopped.
The version number semver
Cancel all scheduled events greater than or equal to the given time
Get the object's attributes.
import { Oscillator } from "tone";
const osc = new Oscillator();
console.log(osc.get());
// returns {"type" : "sine", "frequency" : 440, ...etc}
Returns all of the default options belonging to the class.
Return the current time of the Context clock without any lookAhead.
Return the current time of the Context clock plus the lookAhead.
Set multiple properties at once with an object.
import { Filter } from "tone";
const filter = new Filter();
// set values using an object
filter.set({
frequency: 300,
type: "highpass"
});
Start the loop at the specified time along the Transport's timeline.
Convert the input to a frequency number
Convert the incoming time to seconds
Convert the class to a string
import { Oscillator } from "tone";
const osc = new Oscillator();
console.log(osc.toString());
Convert the input time into ticks