Tone.Time

↳ EXTENDS Tone.TimeBase

Tone.Time is a primitive type for encoding Time values. Eventually all time values are evaluated to seconds using the eval method. Tone.Time can be constructed with or without the new keyword. Tone.Time can be passed into the parameter of any method which takes time as an argument.

CONSTRUCTOR

new Tone.Time (
val
, [
units
] )
val

The time value.

type: String or Number
units

The units of the value.

type: String
optional

EXAMPLE

var t = Tone.Time("4n");//encodes a quarter note
t.mult(4); // multiply that value by 4
t.toNotation(); //returns "1m"

Methods

.toBarsBeatsSixteenths ( )

#

Return the time encoded as Bars:Beats:Sixteenths.

</>

.toMilliseconds ( )

#
↪ returns Milliseconds

Return the time in milliseconds.

</>

.toNotation ( )

#
↪ returns Notation

Convert a Time to Notation. Values will be thresholded to the nearest 128th note.

EXAMPLE

//if the Transport is at 120bpm:
Tone.Time(2).toNotation();//returns "1m"
</>

.toSamples ( )

#
↪ returns Samples

Return the time in samples

</>

.toSeconds ( )

#
↪ returns Seconds

Return the time in seconds.

</>

.toTicks ( )

#
↪ returns Ticks

Return the time in ticks.

</>

.valueOf ( )

#
↪ returns Seconds

Return the time in seconds.

</>

.quantize ( )

#
val

The subdivision to quantize to

percent

Move the time value towards the quantized value by a percentage.

default: 1
↪ returns Tone.Time

this

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.

EXAMPLE

Tone.Time(21).quantize(2) //returns 22
Tone.Time(0.6).quantize("4n", 0.5) //returns 0.55
</>

.copy ( )

#
time
type: Tone.Time
↪ returns Time

Copies the value of time to this Time

</>

.addNow ( )

#
↪ returns Tone.Time

this

Adds the clock time to the time expression at the moment of evaluation.

</>

.toFrequency ( )

#
↪ returns Frequency

Return the time as a frequency value

EXAMPLE

Tone.Time(2).toFrequency(); //0.5
</>
inherited from Tone.TimeBase

.sub ( )

#
val

The value to subtract

type: Time
units

Optional units to use with the value.

type: String
optional
↪ returns Tone.TimeBase

this

Subtract the value from the current time.

EXAMPLE

Tone.TimeBase("2m").sub("1m"); //"1m"
</>
inherited from Tone.TimeBase

.clone ( )

#
↪ returns Tone.TimeBase

The new cloned Tone.TimeBase

Return a clone of the TimeBase object.

</>
inherited from Tone.TimeBase

.dispose ( )

#
↪ returns Tone.TimeBase

this

Clean up

</>
inherited from Tone.TimeBase

.div ( )

#
val

The value to divide by

type: Time
units

Optional units to use with the value.

type: String
optional
↪ returns Tone.TimeBase

this

Divide the current value by the given time.

EXAMPLE

Tone.TimeBase("2m").div(2); //"1m"
</>
inherited from Tone.TimeBase

.mult ( )

#
val

The value to multiply

type: Time
units

Optional units to use with the value.

type: String
optional
↪ returns Tone.TimeBase

this

Multiply the current value by the given time.

EXAMPLE

Tone.TimeBase("2m").mult("2"); //"4m"
</>
inherited from Tone.TimeBase

.set ( )

#
exprString
type: String
↪ returns Tone.TimeBase

this

Repalce the current time value with the value given by the expression string.

</>
inherited from Tone.TimeBase

.add ( )

#
val

The value to add

type: Time
units

Optional units to use with the value.

type: String
optional
↪ returns Tone.TimeBase

this

Add to the current value.

EXAMPLE

Tone.TimeBase("2m").add("1m"); //"3m"
</>
docs generated Sep 15 2019