Created
August 1, 2016 19:57
-
-
Save airportyh/16180099d2bfee019ff1682433581142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html xmlns = "http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
| <!-- polyfill --> | |
| <script src="../inc/shim/Base64.js" type="text/javascript"></script> | |
| <script src="../inc/shim/Base64binary.js" type="text/javascript"></script> | |
| <script src="../inc/shim/WebAudioAPI.js" type="text/javascript"></script> | |
| <!-- midi.js package --> | |
| <script src="../js/midi/audioDetect.js" type="text/javascript"></script> | |
| <script src="../js/midi/gm.js" type="text/javascript"></script> | |
| <script src="../js/midi/loader.js" type="text/javascript"></script> | |
| <script src="../js/midi/plugin.audiotag.js" type="text/javascript"></script> | |
| <script src="../js/midi/plugin.webaudio.js" type="text/javascript"></script> | |
| <script src="../js/midi/plugin.webmidi.js" type="text/javascript"></script> | |
| <!-- utils --> | |
| <script src="../js/util/dom_request_xhr.js" type="text/javascript"></script> | |
| <script src="../js/util/dom_request_script.js" type="text/javascript"></script> | |
| </head> | |
| <body> | |
| <script type="text/javascript"> | |
| window.onload = function () { | |
| MIDI.loadPlugin({ | |
| soundfontUrl: "./soundfont/", | |
| instrument: "acoustic_grand_piano", | |
| onprogress: function(state, progress) { | |
| console.log(state, progress); | |
| }, | |
| onsuccess: function() { | |
| var delay = 0; // play one note every quarter second | |
| var stopNote = 200; | |
| var note = 0; | |
| nextNote(); | |
| function nextNote() { | |
| if (note === stopNote) { | |
| return; | |
| } | |
| console.log('Playing note', note); | |
| var velocity = 127; | |
| MIDI.setVolume(0, 127); | |
| MIDI.noteOn(0, note, velocity, delay); | |
| MIDI.noteOff(0, note, delay + 0.75); | |
| note++; | |
| setTimeout(function() { | |
| nextNote(); | |
| }, 200); | |
| } | |
| } | |
| }); | |
| }; | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment