Skip to content


libmidi is a very simple library created for reading and writing MIDI files. It is designed to be quick to use and quick to learn.

All interaction should be done through the MIDI::File class, which parses a MIDI file. The data inside the MIDI::File class is then organized as if it were a normal MIDI file. That is, MIDI::File has a header (MIDI::Header) and a list of tracks (MIDI::Track). Each track then has a list of MIDI events.

See the MIDI file specification for more information.

The following sites also describe the MIDI file, but are easier to read.



  • API Reference
  • See examples in the examples/ directory of libmidi for usage demonstration.


libmidi is being developed mainly as a personal project, designed to do what I want it to do. I do not have any plans for any large scale, organized, development. That being said, I do not have any problems with people reporting bugs, expressing wishes, submitting patches or asking questions. So feel free to contact me, leave a comment or post a message on GitHUB.

I have also setup a GitHUB repository that contains the latest development code:

git clone git://


There are a few more features that I plan to add to libmidi, but I am not sure when. To increase the speed at which I implement them, pressure me through email.

  • More methods for modifying a MIDI file
  • Write a define for all meta events
  • Better error handling
  • Port/test no Windows and Mac OS X. There is no reason why it shouldn’t work on either right now.
  • Include tutorials in the API reference
Leave a comment