Exporting MIDI Files using Data URIs

I made a post on Reddit about my Melodique melodic phrase generation tool. Three people told me that they'd like for the tool to have the ability to export MIDI files, as this would allow loading the generated content into music editing software. It turns out there's a file writer W3C API in the works that would make implementing this fairly easy, but unfortunately, no browsers seem to support it at this time, not even dear Chrome.

The solution I found was to use data URIs to encode the files. They're simply URIs containing uncompressed base64 encoded file data. These are easily generated from JavaScript code. This should work nicely in most browsers out there. There's often a limit of 30-60KB, but this isn't an issue for my short MIDI files, which are often under 400 bytes.

Implementing basic support for exporting MIDI files took me about 4-5 hours in total. Fortunately, there's great resources out there documenting the format, which, although peculiar, isn't that hard to implement.

On another note, I started reading Virtual Music, a book about computer-generated music which I'd bought a couple months ago. It's been an interesting read so far. I particularly liked the humorous prose about the nature of music and composition:

Is music a craft Or is it an art? Does it come from mere training or spring form the heart?

Did the études of Chopin reveal his soul's mood? Or was Frédéric Chopin Just some slick "pattern dude"?

An interesting read for those interested in this topic :)