I'd like to generate a sequence of MIDI notes in javascript and then play it. Many plugins support MIDI, but I'm not aware of any supporting "data:" URL. Generating MIDI content is not a big deal - but feeding this content into player is. Anyone knows how this can be done - if not in general, then at least for specific plugin like QuickTime?
Very neat problem. I've been working a lot lately with base64-encoded images and have regularly been using http://www.greywyvern.com/code/php/binary2base64 for image encoding. I just tried converting a MIDI file and putting the base64 text stream into an HTML and it played just fine in Firefox (which astonished me). Here's the code (with the Base64 stream removed for brevity):
<embed
autostart="true"
loop="false"
volume="100"
hidden="false"
src="data:audio/x-midi;base64,abc...."
></embed>
I'm not sure it's possible to go from a binary image to base64 in JS, but I suspect that going from MIDI might be. It's a start.
You might want to take a look at the following blog post of mine. It is about a library that does exactly what you are trying to do, client-side. Be aware that cross browser MIDI reproducibility in browsers is not really consistent, though.
http://sergimansilla.com/blog/dinamically-generating-midi-in-javascript/
Sounds like the easiest way would be passing the MIDI data to e.g. a PHP script which then returns the input. Then you can use "yourscript.php?your-midi-data" instead of "data:your-mini-data".
In addition to using Javascript (see Sergi's post), you can use Java as a fallback method with my Javascript to Java bridge that exposes portions of the MIDI framework: http://mudcube7.blogspot.com/2010/08/dynamic-midi-generation-in-browser.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With