A collection of functions to import and manipulate a midi file
Methods
# (static) chordify(parsed_midi, ticksopt, uniqueopt, as_PCopt, orderedopt) → {Array.<Array.<Number>>}
Gets a midi file and chunks all notes to partitions of a certain timeframe
Remark: "pitch classes" conform to the current tuning system used. E.g., 0-11 in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
parsed_midi |
JSON | The returned JSON from EDO.midi.import() |
||
ticks |
Number |
<optional> |
480 | The number of ticks for each partition (the "harmonic rhythm") |
unique |
Boolean |
<optional> |
true | When true, even if a note is repeated within a given timeframe it will appear once. |
as_PC |
Boolean |
<optional> |
false | When true, instead of returning the midi note number, the pitches will be returned as pitch classes |
ordered |
Boolean |
<optional> |
false | When true, each chord will be sorted by pitch height (rather than the order in which it appeared in the midi file) |
- See:
The midi file returns as array of chords corresponding the to the given timeframe
- Type
- Array.<Array.<Number>>
let edo = new EDO(12) // define a tuning system
let bach = edo.midi.import('midi/Bach - Prelude1.mid') //parsing Bach prelude in C major midi file
bach = edo.midi.chordify(bach,960,true,false,true) //chordifying
edo.convert.midi_to_name(bach) //replacing the midi values with note names
//returns
[
[ 'C4', 'E4', 'G4', 'C5', 'E5' ],
[ 'C4', 'D4', 'A4', 'D5', 'F5' ],
[ 'B3', 'D4', 'G4', 'D5', 'F5' ],
[ 'C4', 'E4', 'G4', 'C5', 'E5' ],
[ 'C4', 'E4', 'A4', 'E5', 'A5' ],
[ 'C4', 'D4', 'F#4', 'A4', 'D5' ],
[ 'B3', 'D4', 'G4', 'D5', 'G5' ],
[ 'B3', 'C4', 'E4', 'G4', 'C5' ],
[ 'A3', 'C4', 'E4', 'G4', 'C5' ],
[ 'D3', 'A3', 'D4', 'F#4', 'C5' ],
[ 'G3', 'B3', 'D4', 'G4', 'B4' ],
[ 'G3', 'Bb3', 'E4', 'G4', 'C#5' ],
[ 'F3', 'A3', 'D4', 'A4', 'D5' ],
[ 'F3', 'Ab3', 'D4', 'F4', 'B4' ],
[ 'E3', 'G3', 'C4', 'G4', 'C5' ],
[ 'E3', 'F3', 'A3', 'C4', 'F4' ],
[ 'D3', 'F3', 'A3', 'C4', 'F4' ],
[ 'G2', 'D3', 'G3', 'B3', 'F4' ],
[ 'C3', 'E3', 'G3', 'C4', 'E4' ],
[ 'C3', 'G3', 'Bb3', 'C4', 'E4' ],
[ 'F2', 'F3', 'A3', 'C4', 'E4' ],
[ 'F#2', 'C3', 'A3', 'C4', 'Eb4' ],
[ 'Ab2', 'F3', 'B3', 'C4', 'D4' ],
[ 'G2', 'F3', 'G3', 'B3', 'D4' ],
[ 'G2', 'E3', 'G3', 'C4', 'E4' ],
[ 'G2', 'D3', 'G3', 'C4', 'F4' ],
[ 'G2', 'D3', 'G3', 'B3', 'F4' ],
[ 'G2', 'Eb3', 'A3', 'C4', 'F#4' ],
[ 'G2', 'E3', 'G3', 'C4', 'G4' ],
[ 'G2', 'D3', 'G3', 'C4', 'F4' ],
[ 'G2', 'D3', 'G3', 'B3', 'F4' ],
[ 'C2', 'C3', 'G3', 'Bb3', 'E4' ],
['C2', 'C3', 'D3', 'F3', 'A3', 'C4', 'F4'],
['C2', 'B2', 'D4', 'E4', 'F4', 'G4', 'B4', 'D5', 'F5'],
[ 'C2', 'C3', 'E4', 'G4', 'C5' ]
]
# (static) import(file_path) → {JSON}
Imports a midi file
Name | Type | Description |
---|---|---|
file_path |
String | The path of the file |
the midi file as JSON
- Type
- JSON
# (static) strip(parsed_midi) → {Array.<(Number|Array.<Number>)>}
Gets a midi file and returns only the note on events from all tracks in correct order as one big array
Name | Type | Description |
---|---|---|
parsed_midi |
JSON | The returned JSON from EDO.midi.import() |
- See:
Returns an array of pitches (or arrays of pitches if there's more than one note played simultaneously)
- Type
- Array.<(Number|Array.<Number>)>
let edo = new EDO(12) // define a tuning system
let bach = edo.midi.import('midi/Bach - Prelude1.mid') //parsing Bach prelude in C major midi file which has multiple tracks
edo.midi.strip(bach) //returns all tracks as one array of pitches
[
60, 64, 67, 72, 76, 67, 72, 76, 60, 64, 67, 72,
76, 67, 72, 76, 60, 62, 69, 74, 77, 69, 74, 77,
60, 62, 69, 74, 77, 69, 74, 77, 59, 62, 67, 74,
77, 67, 74, 77, 59, 62, 67, 74, 77, 67, 74, 77,
60, 64, 67, 72, 76, 67, 72, 76, 60, 64, 67, 72,
76, 67, 72, 76, 60, 64, 69, 76, 81, 69, 76, 81,
60, 64, 69, 76, 81, 69, 76, 81, 60, 62, 66, 69,
74, 66, 69, 74, 60, 62, 66, 69, 74, 66, 69, 74,
59, 62, 67, 74,
... 441 more items
]