
tonal-pitch is a low level module to encode and manipulate music pitch and intervals.
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-pitch
PitchCreate a pitch
BooleanTest if an object is a pitch
Encode a pitch
ArrayDecode a pitch
StringGet pitch type
BooleanTest if is a pitch note (with or without octave)
BooleanTest if is an interval
BooleanTest if is a pitch class (a pitch note without octave)
IntegerGet direction of a pitch (even for notes)
IntegerGet encoded fifths from pitch.
IntegerGet encoded octaves from pitch.
IntegerGet height of a pitch.
IntegerGet chroma of a pitch. The chroma is a number between 0 and 11 to represent
the position of a pitch inside an octave. Is the numeric equivlent of a
pitch class.
PitchParse a note
PitchParse an interval
PitchParse a note or an interval
PitchEnsure the given object is a note pitch. If is a string, it will be
parsed. If not a note pitch or valid note string, it returns null.
PitchEnsure the given object is a interval pitch. If is a string, it will be
parsed. If not a interval pitch or valid interval string, it returns null.
PitchEnsure the given object is a pitch. If is a string, it will be
parsed. If not a pitch or valid pitch string, it returns null.
StringConvert a note pitch to string representation
StringConvert a interval pitch to string representation
StringConvert a pitch to string representation (either notes or intervals)
functionDecorate a function to work internally with note pitches, even if the
parameters are provided as strings. Also it converts back the result
to string if a note pitch is returned.
functionDecorate a function to work internally with interval pitches, even if the
parameters are provided as strings. Also it converts back the result
to string if a interval pitch is returned.
functionDecorate a function to work internally with pitches, even if the
parameters are provided as strings. Also it converts back the result
to string if a pitch is returned.
Pitch| Param | Type | Description |
| --- | --- | --- |
| fifths | Integer | the number of fifths from C or from P1 |
| focts | Integer | the number of encoded octaves |
| dir | Integer | (Optional) Only required for intervals. Can be 1 or -1 |
Boolean| Param | Type |
| --- | --- |
| p | Pitch |
| Param | Type | Description |
| --- | --- | --- |
| step | Integer | |
| alt | Integer | |
| oct | Integer | |
| dir | Integer | (Optional) |
Array
Returns: Array - An array with [step, alt, oct]
| Param | Type | Description |
| --- | --- | --- |
| the | Pitch | pitch |
String
Returns: String - 'ivl' or 'note' or null if not a pitch
| Param | Type |
| --- | --- |
| p | Pitch |
Boolean| Param | Type |
| --- | --- |
| p | Pitch |
Boolean| Param | Type |
| --- | --- |
| p | Pitch |
Boolean| Param | Type |
| --- | --- |
| p | Pitch |
Integer
Returns: Integer - 1 or -1
| Param | Type |
| --- | --- |
| p | Pitch |
Integer| Param | Type |
| --- | --- |
| p | Pitch |
Integer| Param | Type |
| --- | --- |
| p | Pitch |
Integer| Param | Type |
| --- | --- |
| p | Pitch |
Integer| Param | Type |
| --- | --- |
| p | Pitch |
Pitch
Returns: Pitch - the pitch or null if not valid note string
| Param | Type |
| --- | --- |
| str | String |
Pitch
Returns: Pitch - the pitch or null if not valid interval string
| Param | Type |
| --- | --- |
| str | String |
Pitch
Returns: Pitch - the pitch or null if not valid pitch string
| Param | Type |
| --- | --- |
| str | String |
Pitch| Param | Type |
| --- | --- |
| p | Pitch | String |
Pitch| Param | Type |
| --- | --- |
| p | Pitch | String |
Pitch| Param | Type |
| --- | --- |
| p | Pitch | String |
String| Param | Type |
| --- | --- |
| p | Pitch |
String| Param | Type |
| --- | --- |
| p | Pitch |
String| Param | Type |
| --- | --- |
| p | Pitch |
function
Returns: function - the decorated function
| Param | Type |
| --- | --- |
| fn | function |
function
Returns: function - the decorated function
| Param | Type |
| --- | --- |
| fn | function |
function
Returns: function - the decorated function
| Param | Type |
| --- | --- |
| fn | function |