Time (original) (raw)

All methods which take time as an argument accept a String or Number. Time encoded as a Number is assumed to be seconds and returned. Time encoded as a String can take various forms in order to synchronize it to the Tone.Transport.

Examples:

Numbers

A number will be evaluated as the time (in seconds).

Notation

Describes time in BPM and time signature relative values.

Transport Time

Tempo and time signature relative time in the form BARS:QUARTERS:SIXTEENTHS.

Frequency

Seconds can also be described in Hz.

Ticks

A time relative to the Transport's PPQ (Pulse Per Quarter). The number before the 'i' needs to be an integer.

Now-Relative

Prefix any of the above with "+" and it will be interpreted as "the current time plus whatever expression follows"

No Argument

Methods which accept time, no argument (undefined) will be interpreted as "now" (i.e. the audioContext.currentTime).

For example, Tone.MonoSynth's triggerAttack method will accept a time as the second argument, or if a value is ommitted, the it will default to "now".

synth.triggerAttack();//context.currentTime synth.triggerRelease("+4n"); //a quarter-note from now

Quantization

Using the @ symbol, a Time can be quantized relative to the the Transport's grid.

Conversion

To convert between seconds and BPM relative values, use Tone.Time

Tone.Time("4n").toSeconds();