See the music embedding portion of this blog post by John Resig. (For some reason, the Mario game that Resig links to plays sound for me in Firefox but not Chrome or Safari; it'd be worth investigating why).
The idea is that you use a data URI to embed a base64 encoded version of your data within the HTML file itself. So you could write Javascript to continuously generate data in the MIDI format, then encode it in base64, and then inject it into an HTML5 <audio>
element