FrequencyClass < Type >

  • Type: number

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


import { Frequency } from "tone";
Frequency("C3"); // 261
Frequency(38, "midi");
Frequency("C3").transpose(4);

Hierarchy

Constructor

new FrequencyClass (
context:BaseContext ,

The context associated with the time value. Used to computeTransport and context-relative timing.

value?:TimeValue ,

The time value as a number, string or object

units?:Unit

Unit values

) => FrequencyClass

Properties

static A4 #

Hertz

The concert tuning pitch which is used to generate all the other pitch values from notes. A4's values in Hertz.

debug #

boolean

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

disposed #

readonly 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.

name #

string

static version #

string

The version number semver

Methods

dispose #

disconnect and dispose.

dispose ( ) => this

fromType #

Coerce a time type into this units type.

fromType (
type:TimeBaseClass<any , any >

Any time type units

) => this

static ftom #

Convert a frequency value to a MIDI note.

ftom (
frequency:Hertz

The value to frequency value to convert.

) => MidiNote

static getDefaults #

Returns all of the default options belonging to the class.

getDefaults ( ) => BaseToneOptions

harmonize #

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


import { Frequency } from "tone";
Frequency("A4").harmonize([0, 3, 7]); // ["A4", "C5", "E5"]
harmonize (
intervals:Interval []
) => FrequencyClass []
Returns an array of Frequencies

static mtof #

Convert a MIDI note to frequency value.

mtof (
midi:MidiNote

The midi number to convert.

) => Hertz
The corresponding frequency value

quantize #

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.


import { Time } from "tone";
Time(21).quantize(2); // returns 22
Time(0.6).quantize("4n", 0.5); // returns 0.55
quantize (
subdiv:Time ,

The subdivision to quantize to

percent= 1:number

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

) => Type

toBarsBeatsSixteenths #

Return the time encoded as Bars:Beats:Sixteenths.

toBarsBeatsSixteenths ( ) => BarsBeatsSixteenths

toFrequency #

Return the value in hertz

toFrequency ( ) => Hertz

toMidi #

Return the value of the frequency as a MIDI note


import { Frequency } from "tone";
Frequency("C4").toMidi(); // 60
toMidi ( ) => MidiNote

toMilliseconds #

Return the time in milliseconds.

toMilliseconds ( ) => Milliseconds

toNotation #

Convert a Time to Notation. The notation values are will be the closest representation between 1m to 128th note.


import { Time } from "tone";
// if the Transport is at 120bpm:
Time(2).toNotation(); // returns "1m"
toNotation ( ) => Subdivision

toNote #

Return the value of the frequency in Scientific Pitch Notation


import { Frequency } from "tone";
Frequency(69, "midi").toNote(); // "A4"
toNote ( ) => Note

toSamples #

Return the time in samples

toSamples ( ) => Samples

toSeconds #

Return the duration of one cycle in seconds.

toSeconds ( ) => Seconds

toString #

Convert the class to a string


import { Oscillator } from "tone";
const osc = new Oscillator();
console.log(osc.toString());
toString ( ) => string

toTicks #

Return the duration of one cycle in ticks

toTicks ( ) => Ticks

transpose #

Transposes the frequency by the given number of semitones.


import { Frequency } from "tone";
Frequency("A4").transpose(3); // "C5"
transpose (
interval:Interval
) => FrequencyClass
A new transposed frequency

valueOf #

Evaluate the time value. Returns the time in seconds.

valueOf ( ) => Type