TK.Notes

TK.Notes converts between frequencies, MIDI notes and note names.

Source:

Methods

freq2cents(frequency, baseopt) → {number}

Returns the percents a frequency misses a real note by.

Parameters:
Name Type Attributes Description
frequency number

The frequency to translate.

base number <optional>

The frequency of A440.

Source:
Returns:

cents - The percent of the difference to the next full note.

Type
number

freq2midi(frequency, baseopt) → {int}

Returns a MIDI note number for a frequency.

Parameters:
Name Type Attributes Description
frequency number

The frequency to translate.

base number <optional>

The frequency of A440.

Source:
Returns:

number - The MIDI number of the frequency.

Type
int

freq2note(frequency, baseopt) → {string}

Returns a note name for a frequency.

Parameters:
Name Type Attributes Description
frequency number

The frequency to translate.

base number <optional>

The frequency of A440.

Source:
Returns:

note - The name of the note.

Type
string

midi2freq(note) → {number}

Returns a frequency of a MIDI note number.

Parameters:
Name Type Description
note int

The MIDI note to translate.

Source:
Returns:

frequency - The frequency of the MIDI number.

Type
number

midi2note(note) → {string}

Returns a note name for a MIDI note number.

Parameters:
Name Type Description
note int

The MIDI note to translate.

Source:
Returns:

note - The name of the note.

Type
string