Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Cross platform MIDI related utilities.

class MidiIn
Can read from a MIDI input port, typically provided by a keyboard

class MidiOut
Outputs to a MIDI port, typically consumed by a synthesizer

class MidiSoftSynth : public MidiOutBase
A software synthesizer that can be used as a MIDI output. Currently
only implemented for OSX (and presumably it would work for iOS as well).

class MidiSong
A song is a collection of tracks, which are a list of MIDI events. A song can
be parsed from a Standard MIDI file, or from a base64 encoded Standard MIDI file
with an appropriate header. MML (Music Macro Language) data may also be parsed,
passed in as either an MML string, or a file path. The version parsed is a restricted
form of Modern MML, and not nearly as sophisticated as what mml2mid can currently

class MidiSongPlayer
Can play a single MidiSong. The class is initialized with a pointer
to a MidiSong. The data in the MidiSong is not retained in any way,
so after a MidiSongPlayer is instantiated it is fine to discard the
MidiSong object.

Contains various routines to convert between note names, note numbers,
and frequency, as well as routines to fetch standard General MIDI names
for instruments.

Like ofxMidi, I'm thinking of using PGMidi to implement the MidiIn and MidiOUt classes on iOS.


CMake 3.10 or greater is required for building. Building in the usual way should work out of the box, as LabMidi has no external dependencies.


See the MidiApp source for examples of usage. Note that MidiApp.cpp currently has hard coded paths to the midi sample files. You'll need to make sure you've set your working directory to the folder containing the resources folder. In XCode, under the Product menu, select Edit Schemes..., then the Options tab, then the target you want to run, and click the Use Custom Working Directory box. Fill in the path appropriately.


MidiPlayerApp -o 0 -f path/to/file.midi

Will play file.midi on the 0th port.


BSD 3-clause.

Note that the sample midi files in the assets directory were obtained from the jasmid distribution on github, and they contain their own internal copyright notices.


Thanks to ofxMidi for inspiration, and jasmid for a clean implementation of a standard midi file reader, which I used as a jumping off point for the LabMidi midi file parser. Thanks to RtMidi for providing a robust platform abstraction. LabMidi is quite different from jasmid and ofxMidi because the focus is playing midi files, and providing basic routing functionality.

Thanks to qiao for posting lots of base64 encoded MIDI tracks at

Thanks to for posting a very cool web utility that calculates scales and chords. It's dual licensed GPL and CC-0. I used the tables in that utility, choosing the CC-0 license for this usage.

There's 9,310 piano MIDI files here:

Thanks to arle for publishing mml2mid, and to g200kg for an MML player.

Thanks to Andre Mazzone and Josh Fillstrup for helping get LabMidi up and running on Linux.


Midi IN and OUT. Standard midi file parser and player. Midi Softsynth implementation.





No releases published
You can’t perform that action at this time.