Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.58 KB

README.md

File metadata and controls

46 lines (35 loc) · 1.58 KB

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 MidiIoSong
  • parseMidiFile - parses the MIDI file at the specified path into a MidiIoSong
  • writeMidiToBuffer - writes the specified MidiIoSong object to a returned Buffer.
  • 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');