tonal-midi

Conversion between midi numbers and note names

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
tonal-midi
0.69.77 years ago8 years agoMinified + gzip package size for tonal-midi in KB

Readme

tonal-midi npm version
tonal
tonal-midi is a collection of functions to convert between midi numbers and note names.
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-midi

API Reference

isMidiNum(num)Boolean

Test if the given number is a valid midi note number

toMidi(pitch)Integer

Get midi number for a pitch

fromMidi(midi)String

Given a midi number, returns a note name. The altered notes will have flats.

fromMidiS(midi)String

Given a midi number, returns a note name. The altered notes will have sharps.


isMidiNum(num) ⇒ Boolean

Test if the given number is a valid midi note number
Kind: global function
Returns: Boolean - true if it's a valid midi note number
| Param | Type | Description | | --- | --- | --- | | num | Object | the thing to be tested |

toMidi(pitch) ⇒ Integer

Get midi number for a pitch
Kind: global function
Returns: Integer - the midi number or null if not valid pitch
| Param | Type | Description | | --- | --- | --- | | pitch | Array | String | the pitch |
Example
midi('C4') // => 60

fromMidi(midi) ⇒ String

Given a midi number, returns a note name. The altered notes will have flats.
Kind: global function
Returns: String - the note name
| Param | Type | Description | | --- | --- | --- | | midi | Integer | the midi note number |
Example
tonal.fromMidi(61) // => 'Db4'

fromMidiS(midi) ⇒ String

Given a midi number, returns a note name. The altered notes will have sharps.
Kind: global function
Returns: String - the note name
| Param | Type | Description | | --- | --- | --- | | midi | Integer | the midi note number |
Example
tonal.fromMidiS(61) // => 'C#4'