Class FrequencyClass<Type>

Frequency is a primitive type for encoding Frequency values. Eventually all time values are evaluated to hertz using the valueOf method.

Example

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

Type Parameters

  • Type extends number = Hertz

Hierarchy (view full)

Constructors

Properties

context: BaseContext
debug: boolean = false

Set this debug flag to log all events that happen in this class.

defaultUnits: FrequencyUnit = "hz"

The default units

name: string = "Frequency"
version: string = version

The version number semver

Accessors

  • get disposed(): boolean
  • 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.

    Returns boolean

Methods

  • Takes an array of semitone intervals and returns an array of frequencies transposed by those intervals.

    Parameters

    • intervals: number[]

    Returns FrequencyClass<number>[]

    Returns an array of Frequencies

    Example

    Tone.Frequency("A4").harmonize([0, 3, 7]); // ["A4", "C5", "E5"]
    
  • 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.

    Parameters

    • subdiv: Unit.Time

      The subdivision to quantize to

    • percent: number = 1

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

    Returns Type

    Example

    Tone.Time(21).quantize(2); // returns 22
    Tone.Time(0.6).quantize("4n", 0.5); // returns 0.55
  • Convert the class to a string

    Returns string

    Example

    const osc = new Tone.Oscillator();
    console.log(osc.toString());
  • Convert a MIDI note to frequency value.

    Parameters

    • midi: MidiNote

      The midi number to convert.

    Returns number

    The corresponding frequency value