Tone.Frequency
↳ EXTENDS Tone.TimeBaseTone.Frequency is a primitive type for encoding Frequency values. Eventually all time values are evaluated to hertz using the eval
method.
CONSTRUCTOR
new Tone.Frequency (The time value.
The units of the value.
EXAMPLE
Tone.Frequency("C3") // 261
Tone.Frequency(38, "midi") //
Tone.Frequency("C3").transpose(4);
Methods
.frequencyToMidi ( )
#Convert a frequency value to a MIDI note.
EXAMPLE
tone.midiToFrequency(440); // returns 69
.midiToFrequency ( )
#Convert a MIDI note to frequency value.
EXAMPLE
tone.midiToFrequency(69); // returns 440
.toMidi ( )
#Return the value of the frequency as a MIDI note
EXAMPLE
Tone.Frequency("C4").toMidi(); //60
.toNote ( )
#Return the value of the frequency in Scientific Pitch Notation
EXAMPLE
Tone.Frequency(69, "midi").toNote(); //"A4"
.transpose ( )
#this
Transposes the frequency by the given number of semitones.
EXAMPLE
Tone.Frequency("A4").transpose(3); //"C5"
.harmonize ( )
#this
Takes an array of semitone intervals and returns an array of frequencies transposed by those intervals.
EXAMPLE
Tone.Frequency("A4").harmonize([0, 3, 7]); //["A4", "C5", "E5"]
.valueOf ( )
#Evaluate the time value. Returns the time in seconds.
.clone ( )
#The new cloned Tone.TimeBase
Return a clone of the TimeBase object.
.copy ( )
#Copies the value of time to this Time
.div ( )
#The value to divide by
Optional units to use with the value.
this
Divide the current value by the given time.
EXAMPLE
Tone.TimeBase("2m").div(2); //"1m"
.mult ( )
#The value to multiply
Optional units to use with the value.
this
Multiply the current value by the given time.
EXAMPLE
Tone.TimeBase("2m").mult("2"); //"4m"
.set ( )
#this
Repalce the current time value with the value given by the expression string.
.sub ( )
#The value to subtract
Optional units to use with the value.
this
Subtract the value from the current time.
EXAMPLE
Tone.TimeBase("2m").sub("1m"); //"1m"
.add ( )
#The value to add
Optional units to use with the value.
this
Add to the current value.
EXAMPLE
Tone.TimeBase("2m").add("1m"); //"3m"