I’ve had a relatively cheap Korg synthesizer sitting in my room for about a year now. Regularly I’ve thought about using it and its MIDI capabilities to explore various musical ideas by recording what I do to a MIDI file for later perusal or transcription. All I wanted to do was something simple: save the MIDI data that enter my iBook through my MIDI-USB cable to a MIDI file. No routing, no use of software synths, nothing like that: just save the data that I’m playing. This shouldn’t be too difficult, especially given that MIDI is a twenty-year old technology.
Wednesday night I went about trying to find a piece of software to let me do this…
… and by Thursday night I had written midiRecord.
Basically I discovered, through hours and hours of Google searching and discussions with friends of mine who also work in music technology, that what I wanted to do was not possible without the use of expensive sequencer software such as Logic, Digital Performer, or Garage Band. A Pure Data extension called “seq” suggests that this is possible, but the MIDI files it created were malformed; similarly, version 5 of csound purports to have this feature, but there is no documentation as to how to use it. All of the freeware tools I found involved complicated abilities to route and pipe data from one object to another, but none of them allowed me to save the data to a MIDI file. I found a few tools on Linux, but none that worked with Core MIDI. And while I discovered that I had Garage Band on my laptop, I also discovered that it won’t export MIDI.
In the end I came across the cross-platform RtMidi library that gave me access to the underlying MIDI-In bytestream. All that remained was the “simple” task of writing the stream to disk; I say “simple” because the MIDI format was designed when byte space was at a premium and uses a number of bit-twidling hacks to squeeze the most amount of information in the least amount of space. Elegant, perhaps, but it makes the application developer’s job much more difficult.
What I ended up with is midiRecord, a command-line tool to do exactly what I wanted, and nothing else:
I’ve included the source and a Makefile, along with a compiled version that runs at least on OS X.4.7.
Run the command with “—help” to get an idea of usage. Read the README file to get an idea of current hacks and issues. As well, let me know if you have suggestions for improvement, patches, complaints, et cetera.