Skip to content

Reads, parses and writes MIDI (.mid) files and buffers

License

Notifications You must be signed in to change notification settings

celsasser/midi-file-io

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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');

About

Reads, parses and writes MIDI (.mid) files and buffers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.5%
  • JavaScript 1.5%