Skip to content

Instantly share code, notes, and snippets.

@runemadsen
Created April 7, 2017 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runemadsen/e047c65e60f9b05143abcc735ce76818 to your computer and use it in GitHub Desktop.
Save runemadsen/e047c65e60f9b05143abcc735ce76818 to your computer and use it in GitHub Desktop.
midi file download
var midi = MidiConvert.create()
midi.track()
.patch(32)
.note(60, 0, 2)
.note(63, 1, 2)
.note(60, 2, 2);
var data = 'data:audio/midi;base64,' + btoa(midi.encode())
var element = document.createElement('a');
element.setAttribute('href', data);
element.setAttribute('download', 'miditest.midi');
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment