If you're handling it all yourself, I think you'd be better off coming up with your own format... MIDI is an old, gross binary format with lots of baggage. The main usage for this, I would imagine, would be to get a MIDI file out for use with some other application (despite being ugly, it is a standard format and has wide support).