Tone.Frequency

↳ EXTENDS Tone.TimeBase

Tone.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 (
val
, [
units
] )
val

The time value.

type: String or Number
units

The units of the value.

type: String
optional

EXAMPLE

Tone.Frequency("C3") // 261
Tone.Frequency(38, "midi") //
Tone.Frequency("C3").transpose(4);

Methods

.frequencyToMidi ( )

#
frequency

The value to frequency value to convert.

↪ returns MIDI

Convert a frequency value to a MIDI note.

EXAMPLE

tone.midiToFrequency(440); // returns 69
</>

.midiToFrequency ( )

#
midi

The midi number to convert.

type: MIDI
↪ returns Frequency

the corresponding frequency value

Convert a MIDI note to frequency value.

EXAMPLE

tone.midiToFrequency(69); // returns 440
</>

.toFrequency ( )

#
↪ returns Frequency

Return the value in Hertz

</>

.toMidi ( )

#
↪ returns MIDI

Return the value of the frequency as a MIDI note

EXAMPLE

Tone.Frequency("C4").toMidi(); //60
</>

.toNote ( )

#
↪ returns Note

Return the value of the frequency in Scientific Pitch Notation

EXAMPLE

Tone.Frequency(69, "midi").toNote(); //"A4"
</>

.toSeconds ( )

#
↪ returns Seconds

Return the duration of one cycle in seconds.

</>

.toTicks ( )

#
↪ returns Ticks

Return the duration of one cycle in ticks

</>

.transpose ( )

#
interval
↪ returns Tone.Frequency

this

Transposes the frequency by the given number of semitones.

EXAMPLE

Tone.Frequency("A4").transpose(3); //"C5"
</>

.harmonize ( )

#
intervals
type: Array
↪ returns Tone.Frequency

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"]
</>
inherited from Tone.TimeBase

.valueOf ( )

#
↪ returns Seconds

Evaluate the time value. Returns the time in seconds.

</>
inherited from Tone.TimeBase

.clone ( )

#
↪ returns Tone.TimeBase

The new cloned Tone.TimeBase

Return a clone of the TimeBase object.

</>
inherited from Tone.TimeBase

.copy ( )

#
time
↪ returns TimeBase

Copies the value of time to this Time

</>
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

.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

.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