midi-file-io
v3.1.3
Published
Reads, parses and writes MIDI files. Fork of NHQ's midi-file-parser.
Downloads
24
Maintainers
Readme
midi-file-parser
npm install https://github.com/celsasser/midi-file-io
Forked from midi-file-parser. Special thanks to the authors.
Added write functionality, tests and made small additions/revisions to the read functionity. Probably not as portable as it was. File IO has dependencies on NodeJS's fs
. Feel free to fork it and pull it out if this gets in your way.
usage
Functionality is broken up into read and write. Each of these are broken up into a file operation and a buffer operation:
parseMidiBuffer
- parses the binary MIDI buffer into a MidiIoSongparseMidiFile
- parses the MIDI file at the specified path into a MidiIoSongwriteMidiToBuffer
- writes the specified MidiIoSong object to a returnedBuffer
.writeMidiToFile
- writes the specified MidiIoSong object to the specified path.
parseMidiBuffer
const midiFileIO = require('midi-file-parser');
const buffer = require('fs').readFileSync('rachnananov.mid', 'binary')
const parsed = parseMidiBuffer(buffer);
parseMidiFile
const midiFileIO = require('midi-file-parser');
const parsed = parseMidiFile('rachnananov.mid');
writeMidiToBuffer
const midiFileIO = require('midi-file-parser');
const parsed = parseMidiFile('rachnananov.mid');
const buffer = writeMidiToBuffer(parsed);
writeMidiToFile
const midiFileIO = require('midi-file-parser');
const parsed = parseMidiFile('rachnananov.mid');
const buffer = writeMidiToFile(parsed, 'rachnananov-copy.mid');