My MIDI file processing code, as lifted from foo_midi and modified to use STL classes instead. Still kind of a mess.