Ticks is a primitive type for encoding Time values.
Ticks can be constructed with or without the new
keyword. Ticks can be passed
into the parameter of any method which takes time as an argument.
import { Ticks } from "tone";
const t = Ticks("4n"); // a quarter note as ticks
The context associated with the time value. Used to computeTransport and context-relative timing.
Unit values
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 version number semver
disconnect and dispose.
Coerce a time type into this units type.
Returns all of the default options belonging to the class.
Quantize the time by the given subdivision. Optionally add a percentage which will move the time value towards the ideal quantized value by that percentage.
import { Time } from "tone";
Time(21).quantize(2); // returns 22
Time(0.6).quantize("4n", 0.5); // returns 0.55
Move the time value towards the quantized value by a percentage.
Return the time encoded as Bars:Beats:Sixteenths.
Return the value in hertz
Return the value as a midi note.
Return the time in milliseconds.
Convert a Time to Notation. The notation values are will be the closest representation between 1m to 128th note.
import { Time } from "tone";
// if the Transport is at 120bpm:
Time(2).toNotation(); // returns "1m"
Return the time in samples
Convert the class to a string
import { Oscillator } from "tone";
const osc = new Oscillator();
console.log(osc.toString());
Evaluate the time value. Returns the time in seconds.