Pulled in some code from v2 to add basic MIDI support.

Not really going to be able to continue going with this so I figured
it would be worth trying out MIDI support now that it's possible.
Removed things that never got finished..