Methods
(static) fromScientificPitch(pitch) → {number}
Converts from scientific pitch back to a MIDI note number
Parameters:
| Name | Type | Description |
|---|---|---|
pitch |
string | A music note in scientific pitch notation |
- Source:
Returns:
the pitch as a MIDI note number
- Type
- number
(static) makeUnique(nums) → {Array.<number>}
Removes any notes which are an octave multiple of a lower note.
Parameters:
| Name | Type | Description |
|---|---|---|
nums |
Array.<number> | An array of MIDI note numbers |
- Source:
Returns:
An array of MIDI note numbers
- Type
- Array.<number>
Example
// returns [60, 64, 67, 74]
MIDINumber.makeUnique([60, 64, 67, 72, 74, 76, 79])
(static) toChord(nums, sharpopt, verboseopt) → {string}
Calculates the name of a chord from an array of MIDI note numbers.
If a name can't be found, lists all held notes, separated by long dashes.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
nums |
Array.<number> | An array of MIDI note numbers. | ||
sharp |
boolean |
<optional> |
true | Format accidentals as sharp or flat |
verbose |
boolean |
<optional> |
false | Format as short or verbose form of chord names |
- Source:
Returns:
The chord name of the held notes.
- Type
- string
(static) toFrequency(num) → {number}
Converts a MIDI number to its frequency in equal temperament.
Parameters:
| Name | Type | Description |
|---|---|---|
num |
number | A MIDI note number. Floating point numbers are interpolated logarithmically. |
- Source:
Returns:
The note's frequency in Hertz
- Type
- number
(static) toInterval(nums) → {string}
Calculates the interval between a pair of MIDI numbers.
Parameters:
| Name | Type | Description |
|---|---|---|
nums |
Array.<number> | The MIDI numbers to find the interval between. |
- Source:
Returns:
The interval between the notes.
- Type
- string
(static) toLetter(num, sharpopt) → {string}
Converts a MIDI number to its note name.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
num |
number | A MIDI number. | ||
sharp |
boolean |
<optional> |
true | Format accidentals as sharp or flat. |
- Source:
Returns:
The note name
- Type
- string
(static) toPentaChord(nums, sharpopt, verboseopt, slashOkayopt) → {string}
Calculates the chord represented by five MIDI numbers.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
nums |
Array.<number> | The MIDI numbers to find the chord of. | ||
sharp |
boolean |
<optional> |
true | Format accidentals as sharp or flat. |
verbose |
boolean |
<optional> |
false | Format as short or verbose form of chord names |
slashOkay |
boolean |
<optional> |
true | Return a slash chord if no pentachord is found. |
- Source:
Returns:
The calculated chord, or an empty string if no chord is found.
- Type
- string
(static) toScientificPitch(num, sharpopt) → {string}
Converts a MIDI number to scientific pitch notation.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
num |
number | A MIDI number. | ||
sharp |
boolean |
<optional> |
true | Format accidentals as sharp or flat. |
- Source:
Returns:
The note name and octave number
- Type
- string
Example
//returns 'C5'
MIDINumber.toScientificPitch(60)
(static) toTetrachord(nums, sharpopt, verboseopt, slashOkayopt) → {string}
Calculates the chord represented by four MIDI numbers.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
nums |
Array.<number> | The MIDI numbers to find the chord of. | ||
sharp |
boolean |
<optional> |
true | Format accidentals as sharp or flat. |
verbose |
boolean |
<optional> |
false | Format as short or verbose form of chord names |
slashOkay |
boolean |
<optional> |
true | Return a slash chord if no tetrachord is found. |
- Source:
Returns:
The calculated chord, or an empty string if no chord is found.
- Type
- string
(static) toTriad(nums, sharpopt, verboseopt) → {string}
Calculates the chord represented by three MIDI numbers.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
nums |
Array.<number> | The MIDI numbers to find the chord of. | ||
sharp |
boolean |
<optional> |
true | Format accidentals as sharp or flat. |
verbose |
boolean |
<optional> |
false | Format as short or verbose form of chord names |
- Source:
Returns:
The calculated chord, or an empty string if no chord is found.
- Type
- string