1 |
- if("undefined"==typeof MIDI&&(MIDI={}),function(e){"use strict";var n={},t=0,r=function(e){t++;var r=document.body,o=new Audio,i=e.split(";")[0];o.id="audio",o.setAttribute("preload","auto"),o.setAttribute("audiobuffer",!0),o.addEventListener("error",function(){r.removeChild(o),n[i]=!1,t--},!1),o.addEventListener("canplaythrough",function(){r.removeChild(o),n[i]=!0,t--},!1),o.src="data:"+e,r.appendChild(o)};e.audioDetect=function(e){if(navigator.requestMIDIAccess){var o=Function.prototype.toString.call(navigator.requestMIDIAccess).indexOf("[native code]");if(o)n.webmidi=!0;else for(var i=0;navigator.plugins.length>i;i++){var a=navigator.plugins[i];a.name.indexOf("Jazz-Plugin")>=0&&(n.webmidi=!0)}}if("undefined"==typeof Audio)return e({});n.audiotag=!0,(window.AudioContext||window.webkitAudioContext)&&(n.webaudio=!0);var u=new Audio;if(u.canPlayType===void 0)return e(n);var s=u.canPlayType('audio/ogg; codecs="vorbis"');s="probably"===s||"maybe"===s;var c=u.canPlayType("audio/mpeg");if(c="probably"===c||"maybe"===c,!s&&!c)return e(n),void 0;s&&r("audio/ogg;base64,T2dnUwACAAAAAAAAAADqnjMlAAAAAOyyzPIBHgF2b3JiaXMAAAAAAUAfAABAHwAAQB8AAEAfAACZAU9nZ1MAAAAAAAAAAAAA6p4zJQEAAAANJGeqCj3//////////5ADdm9yYmlzLQAAAFhpcGguT3JnIGxpYlZvcmJpcyBJIDIwMTAxMTAxIChTY2hhdWZlbnVnZ2V0KQAAAAABBXZvcmJpcw9CQ1YBAAABAAxSFCElGVNKYwiVUlIpBR1jUFtHHWPUOUYhZBBTiEkZpXtPKpVYSsgRUlgpRR1TTFNJlVKWKUUdYxRTSCFT1jFloXMUS4ZJCSVsTa50FkvomWOWMUYdY85aSp1j1jFFHWNSUkmhcxg6ZiVkFDpGxehifDA6laJCKL7H3lLpLYWKW4q91xpT6y2EGEtpwQhhc+211dxKasUYY4wxxsXiUyiC0JBVAAABAABABAFCQ1YBAAoAAMJQDEVRgNCQVQBABgCAABRFcRTHcRxHkiTLAkJDVgEAQAAAAgAAKI7hKJIjSZJkWZZlWZameZaouaov+64u667t6roOhIasBACAAAAYRqF1TCqDEEPKQ4QUY9AzoxBDDEzGHGNONKQMMogzxZAyiFssLqgQBKEhKwKAKAAAwBjEGGIMOeekZFIi55iUTkoDnaPUUcoolRRLjBmlEluJMYLOUeooZZRCjKXFjFKJscRUAABAgAMAQICFUGjIigAgCgCAMAYphZRCjCnmFHOIMeUcgwwxxiBkzinoGJNOSuWck85JiRhjzjEHlXNOSuekctBJyaQTAAAQ4AAAEGAhFBqyIgCIEwAwSJKmWZomipamiaJniqrqiaKqWp5nmp5pqqpnmqpqqqrrmqrqypbnmaZnmqrqmaaqiqbquqaquq6nqrZsuqoum65q267s+rZru77uqapsm6or66bqyrrqyrbuurbtS56nqqKquq5nqq6ruq5uq65r25pqyq6purJtuq4tu7Js664s67pmqq5suqotm64s667s2rYqy7ovuq5uq7Ks+6os+75s67ru2rrwi65r66os674qy74x27bwy7ouHJMnqqqnqq7rmarrqq5r26rr2rqmmq5suq4tm6or26os67Yry7aumaosm64r26bryrIqy77vyrJui67r66Ys67oqy8Lu6roxzLat+6Lr6roqy7qvyrKuu7ru+7JuC7umqrpuyrKvm7Ks+7auC8us27oxuq7vq7It/KosC7+u+8Iy6z5jdF1fV21ZGFbZ9n3d95Vj1nVhWW1b+V1bZ7y+bgy7bvzKrQvLstq2scy6rSyvrxvDLux8W/iVmqratum6um7Ksq/Lui60dd1XRtf1fdW2fV+VZd+3hV9pG8OwjK6r+6os68Jry8ov67qw7MIvLKttK7+r68ow27qw3L6wLL/uC8uq277v6rrStXVluX2fsSu38QsAABhwAAAIMKEMFBqyIgCIEwBAEHIOKQahYgpCCKGkEEIqFWNSMuakZM5JKaWUFEpJrWJMSuaclMwxKaGUlkopqYRSWiqlxBRKaS2l1mJKqcVQSmulpNZKSa2llGJMrcUYMSYlc05K5pyUklJrJZXWMucoZQ5K6iCklEoqraTUYuacpA46Kx2E1EoqMZWUYgupxFZKaq2kFGMrMdXUWo4hpRhLSrGVlFptMdXWWqs1YkxK5pyUzDkqJaXWSiqtZc5J6iC01DkoqaTUYiopxco5SR2ElDLIqJSUWiupxBJSia20FGMpqcXUYq4pxRZDSS2WlFosqcTWYoy1tVRTJ6XFklKMJZUYW6y5ttZqDKXEVkqLsaSUW2sx1xZjjqGkFksrsZWUWmy15dhayzW1VGNKrdYWY40x5ZRrrT2n1mJNMdXaWqy51ZZbzLXnTkprpZQWS0oxttZijTHmHEppraQUWykpxtZara3FXEMpsZXSWiypxNhirLXFVmNqrcYWW62ltVprrb3GVlsurdXcYqw9tZRrrLXmWFNtBQAADDgAAASYUAYKDVkJAEQBAADGMMYYhEYpx5yT0ijlnHNSKucghJBS5hyEEFLKnINQSkuZcxBKSSmUklJqrYVSUmqttQIAAAocAAACbNCUWByg0JCVAEAqAIDBcTRNFFXVdX1fsSxRVFXXlW3jVyxNFFVVdm1b+DVRVFXXtW3bFn5NFFVVdmXZtoWiqrqybduybgvDqKqua9uybeuorqvbuq3bui9UXVmWbVu3dR3XtnXd9nVd+Bmzbeu2buu+8CMMR9/4IeTj+3RCCAAAT3AAACqwYXWEk6KxwEJDVgIAGQAAgDFKGYUYM0gxphhjTDHGmAAAgAEHAIAAE8pAoSErAoAoAADAOeecc84555xzzjnnnHPOOeecc44xxhhjjDHGGGOMMcYYY4wxxhhjjDHGGGOMMcYYY0wAwE6EA8BOhIVQaMhKACAcAABACCEpKaWUUkoRU85BSSmllFKqFIOMSkoppZRSpBR1lFJKKaWUIqWgpJJSSimllElJKaWUUkoppYw6SimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaVUSimllFJKKaWUUkoppRQAYPLgAACVYOMMK0lnhaPBhYasBAByAwAAhRiDEEJpraRUUkolVc5BKCWUlEpKKZWUUqqYgxBKKqmlklJKKbXSQSihlFBKKSWUUkooJYQQSgmhlFRCK6mEUkoHoYQSQimhhFRKKSWUzkEoIYUOQkmllNRCSB10VFIpIZVSSiklpZQ6CKGUklJLLZVSWkqpdBJSKamV1FJqqbWSUgmhpFZKSSWl0lpJJbUSSkklpZRSSymFVFJJJYSSUioltZZaSqm11lJIqZWUUkqppdRSSiWlkEpKqZSSUmollZRSaiGVlEpJKaTUSimlpFRCSamlUlpKLbWUSkmptFRSSaWUlEpJKaVSSksppRJKSqmllFpJKYWSUkoplZJSSyW1VEoKJaWUUkmptJRSSymVklIBAEAHDgAAAUZUWoidZlx5BI4oZJiAAgAAQABAgAkgMEBQMApBgDACAQAAAADAAAAfAABHARAR0ZzBAUKCwgJDg8MDAAAAAAAAAAAAAACAT2dnUwAEAAAAAAAAAADqnjMlAgAAADzQPmcBAQA="),c&&r("audio/mpeg;base64,/+MYxAAAAANIAUAAAASEEB/jwOFM/0MM/90b/+RhST//w4NFwOjf///PZu////9lns5GFDv//l9GlUIEEIAAAgIg8Ir/JGq3/+MYxDsLIj5QMYcoAP0dv9HIjUcH//yYSg+CIbkGP//8w0bLVjUP///3Z0x5QCAv/yLjwtGKTEFNRTMuOTeqqqqqqqqqqqqq/+MYxEkNmdJkUYc4AKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");var l=(new Date).getTime(),d=window.setInterval(function(){var r=(new Date).getTime(),o=r-l>5e3;(!t||o)&&(window.clearInterval(d),e(n))},1)}}(MIDI),function(e){"use strict";e.GM=function(e){var n=function(e){return e.replace(/[^a-z0-9 ]/gi,"").replace(/[ ]/g,"_").toLowerCase()},t={byName:{},byId:{},byCategory:{}};for(var r in e)for(var o=e[r],i=0,a=o.length;a>i;i++){var u=o[i];if(u){var s=parseInt(u.substr(0,u.indexOf(" ")),10);u=u.replace(s+" ",""),t.byId[--s]=t.byName[n(u)]=t.byCategory[n(r)]={id:n(u),instrument:u,number:s,category:r}}}return t}({Piano:["1 Acoustic Grand Piano","2 Bright Acoustic Piano","3 Electric Grand Piano","4 Honky-tonk Piano","5 Electric Piano 1","6 Electric Piano 2","7 Harpsichord","8 Clavinet"],"Chromatic Percussion":["9 Celesta","10 Glockenspiel","11 Music Box","12 Vibraphone","13 Marimba","14 Xylophone","15 Tubular Bells","16 Dulcimer"],Organ:["17 Drawbar Organ","18 Percussive Organ","19 Rock Organ","20 Church Organ","21 Reed Organ","22 Accordion","23 Harmonica","24 Tango Accordion"],Guitar:["25 Acoustic Guitar (nylon)","26 Acoustic Guitar (steel)","27 Electric Guitar (jazz)","28 Electric Guitar (clean)","29 Electric Guitar (muted)","30 Overdriven Guitar","31 Distortion Guitar","32 Guitar Harmonics"],Bass:["33 Acoustic Bass","34 Electric Bass (finger)","35 Electric Bass (pick)","36 Fretless Bass","37 Slap Bass 1","38 Slap Bass 2","39 Synth Bass 1","40 Synth Bass 2"],Strings:["41 Violin","42 Viola","43 Cello","44 Contrabass","45 Tremolo Strings","46 Pizzicato Strings","47 Orchestral Harp","48 Timpani"],Ensemble:["49 String Ensemble 1","50 String Ensemble 2","51 Synth Strings 1","52 Synth Strings 2","53 Choir Aahs","54 Voice Oohs","55 Synth Choir","56 Orchestra Hit"],Brass:["57 Trumpet","58 Trombone","59 Tuba","60 Muted Trumpet","61 French Horn","62 Brass Section","63 Synth Brass 1","64 Synth Brass 2"],Reed:["65 Soprano Sax","66 Alto Sax","67 Tenor Sax","68 Baritone Sax","69 Oboe","70 English Horn","71 Bassoon","72 Clarinet"],Pipe:["73 Piccolo","74 Flute","75 Recorder","76 Pan Flute","77 Blown Bottle","78 Shakuhachi","79 Whistle","80 Ocarina"],"Synth Lead":["81 Lead 1 (square)","82 Lead 2 (sawtooth)","83 Lead 3 (calliope)","84 Lead 4 (chiff)","85 Lead 5 (charang)","86 Lead 6 (voice)","87 Lead 7 (fifths)","88 Lead 8 (bass + lead)"],"Synth Pad":["89 Pad 1 (new age)","90 Pad 2 (warm)","91 Pad 3 (polysynth)","92 Pad 4 (choir)","93 Pad 5 (bowed)","94 Pad 6 (metallic)","95 Pad 7 (halo)","96 Pad 8 (sweep)"],"Synth Effects":["97 FX 1 (rain)","98 FX 2 (soundtrack)","99 FX 3 (crystal)","100 FX 4 (atmosphere)","101 FX 5 (brightness)","102 FX 6 (goblins)","103 FX 7 (echoes)","104 FX 8 (sci-fi)"],Ethnic:["105 Sitar","106 Banjo","107 Shamisen","108 Koto","109 Kalimba","110 Bagpipe","111 Fiddle","112 Shanai"],Percussive:["113 Tinkle Bell","114 Agogo","115 Steel Drums","116 Woodblock","117 Taiko Drum","118 Melodic Tom","119 Synth Drum"],"Sound effects":["120 Reverse Cymbal","121 Guitar Fret Noise","122 Breath Noise","123 Seashore","124 Bird Tweet","125 Telephone Ring","126 Helicopter","127 Applause","128 Gunshot"]}),e.getInstrument=function(n){var t=e.channels[n];return t&&t.instrument},e.setInstrument=function(n,t,r){var o=e.channels[n];return r?setTimeout(function(){o.instrument=t},r):(o.instrument=t,void 0)},e.getMono=function(n){var t=e.channels[n];return t&&t.mono},e.setMono=function(n,t,r){var o=e.channels[n];return r?setTimeout(function(){o.mono=t},r):(o.mono=t,void 0)},e.getOmni=function(n){var t=e.channels[n];return t&&t.omni},e.setOmni=function(n,t){var r=e.channels[n];return delay?setTimeout(function(){r.omni=t},delay):(r.omni=t,void 0)},e.getSolo=function(n){var t=e.channels[n];return t&&t.solo},e.setSolo=function(n,t){var r=e.channels[n];return delay?setTimeout(function(){r.solo=t},delay):(r.solo=t,void 0)},e.channels=function(){for(var e={},n=0;16>n;n++)e[n]={instrument:n,pitchBend:0,mute:!1,mono:!1,omni:!1,solo:!1};return e}(),e.keyToNote={},e.noteToKey={},function(){for(var n=21,t=108,r=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],o=n;t>=o;o++){var i=(o-12)/12>>0,a=r[o%12]+i;e.keyToNote[a]=o,e.noteToKey[o]=a}}()}(MIDI),"undefined"==typeof MIDI&&(MIDI={}),MIDI.Soundfont=MIDI.Soundfont||{},MIDI.Player=MIDI.Player||{},function(e){"use strict";e.DEBUG=!0,e.USE_XHR=!0,e.soundfontUrl="./soundfont/",e.loadPlugin=function(t){"function"==typeof t&&(t={onsuccess:t}),e.soundfontUrl=t.soundfontUrl||e.soundfontUrl,e.audioDetect(function(r){var o=window.location.hash,i="";if(r[t.api]?i=t.api:r[o.substr(1)]?i=o.substr(1):r.webmidi?i="webmidi":window.AudioContext?i="webaudio":window.Audio&&(i="audiotag"),n[i]){if(t.targetFormat)var a=t.targetFormat;else var a=r["audio/ogg"]?"ogg":"mp3";e.__api=i,e.__audioFormat=a,e.supports=r,e.loadResource(t)}})},e.loadResource=function(t){var r=t.instruments||t.instrument||"acoustic_grand_piano";"object"!=typeof r&&(r=r||0===r?[r]:[]);for(var o=0;r.length>o;o++){var i=r[o];i===+i&&e.GM.byId[i]&&(r[o]=e.GM.byId[i].id)}t.format=e.__audioFormat,t.instruments=r,n[e.__api](t)};var n={webmidi:function(n){e.WebMIDI.connect(n)},audiotag:function(e){t(e,"AudioTag")},webaudio:function(e){t(e,"WebAudio")}},t=function(n,t){for(var o=n.format,i=n.instruments,a=n.onprogress,u=n.onerror,s=i.length,c=s,l=function(){--c||(a&&a("load",1),e[t].connect(n))},d=0;s>d;d++){var f=i[d];MIDI.Soundfont[f]?l():r(i[d],o,function(e,n){var t=n/s,r=(s-c)/s;a&&a("load",t+r,f)},function(){l()},u)}},r=function(n,t,r,o,i){var a=e.soundfontUrl+n+"-"+t+".js";e.USE_XHR?e.util.request({url:a,format:"text",onerror:i,onprogress:r,onsuccess:function(e,n){var t=document.createElement("script");t.language="javascript",t.type="text/javascript",t.text=n,document.body.appendChild(t),o()}}):dom.loadScript.add({url:a,verify:'MIDI.Soundfont["'+n+'"]',onerror:i,onsuccess:function(){o()}})};e.setDefaultPlugin=function(n){for(var t in n)e[t]=n[t]}}(MIDI),"undefined"==typeof MIDI&&(MIDI={}),MIDI.Player===void 0&&(MIDI.Player={}),function(){"use strict";var e=MIDI.Player;e.currentTime=0,e.endTime=0,e.restart=0,e.playing=!1,e.timeWarp=1,e.startDelay=0,e.BPM=120,e.start=e.resume=function(n){-1>e.currentTime&&(e.currentTime=-1),d(e.currentTime,null,n)},e.pause=function(){var n=e.restart;f(),e.restart=n},e.stop=function(){f(),e.restart=0,e.currentTime=0},e.addListener=function(e){a=e},e.removeListener=function(){a=void 0},e.clearAnimation=function(){e.animationFrameId&&cancelAnimationFrame(e.animationFrameId)},e.setAnimation=function(n){var t=0,r=0,o=0;e.clearAnimation();var a=function(){if(e.animationFrameId=requestAnimationFrame(a),0!==e.endTime){e.playing?(t=o===e.currentTime?r-Date.now():0,t=0===e.currentTime?0:e.currentTime-t,o!==e.currentTime&&(r=Date.now(),o=e.currentTime)):t=e.currentTime;var u=e.endTime,s=t/1e3,c=s/60,l=s-60*c,d=60*c+l,f=u/1e3;-1>f-d||n({now:d,end:f,events:i})}};requestAnimationFrame(a)},e.loadMidiFile=function(n,t,r){try{e.replayer=new Replayer(MidiFile(e.currentData),e.timeWarp,null,e.BPM),e.data=e.replayer.getData(),e.endTime=c(),MIDI.loadPlugin({onsuccess:n,onprogress:t,onerror:r})}catch(o){r&&r(o)}},e.loadFile=function(n,t,r,o){if(e.stop(),-1!==n.indexOf("base64,")){var i=window.atob(n.split(",")[1]);e.currentData=i,e.loadMidiFile(t,r,o)}else{var a=new XMLHttpRequest;a.open("GET",n),a.overrideMimeType("text/plain; charset=x-user-defined"),a.onreadystatechange=function(){if(4===this.readyState)if(200===this.status){for(var n=this.responseText||"",i=[],a=n.length,u=String.fromCharCode,s=0;a>s;s++)i[s]=u(255&n.charCodeAt(s));var c=i.join("");e.currentData=c,e.loadMidiFile(t,r,o)}else o&&o("Unable to load MIDI file")},a.send()}},e.getFileInstruments=function(){for(var n={},t={},r=0;e.data.length>r;r++){var o=e.data[r][0].event;if("channel"===o.type){var i=o.channel;switch(o.subtype){case"controller":break;case"programChange":t[i]=o.programNumber;break;case"noteOn":var a=t[i],u=MIDI.GM.byId[isFinite(a)?a:i];n[u.id]=!0}}}var s=[];for(var c in n)s.push(c);return s};var n,t,r=[],o=0,i={},a=void 0,u=function(t,o,u,s,c,l){return setTimeout(function(){var s={channel:t,note:o,now:u,end:e.endTime,message:c,velocity:l};128===c?delete i[o]:i[o]=s,a&&a(s),e.currentTime=u,r.shift(),1e3>r.length?d(n,!0):e.currentTime===n&&e.endTime>n&&d(n,!0)},u-s)},s=function(){return"webaudio"===MIDI.api?MIDI.WebAudio.getContext():(e.ctx={currentTime:0},e.ctx)},c=function(){for(var n=e.data,t=n.length,r=.5,o=0;t>o;o++)r+=n[o][1];return r},l=function(){return window.performance&&window.performance.now?window.performance.now():Date.now()},d=function(i,a,d){if(e.replayer){a||(i===void 0&&(i=e.restart),e.playing&&f(),e.playing=!0,e.data=e.replayer.getData(),e.endTime=c());var p,A=0,m=0,v=e.data,q=s(),g=v.length;n=.5,r[0]&&r[0].interval||0;var h=i-e.currentTime;if("webaudio"!==MIDI.api){var y=l();t=t||y,q.currentTime=(y-t)/1e3}o=q.currentTime;for(var S=0;g>S&&100>m;S++){var I=v[S];if(i>=(n+=I[1]))A=n;else{i=n-A;var b=I[0].event;if("channel"===b.type){var T=b.channel,w=MIDI.channels[T],M=q.currentTime+(i+h+e.startDelay)/1e3,D=n-A+e.startDelay;switch(b.subtype){case"controller":MIDI.setController(T,b.controllerType,b.value,M);break;case"programChange":MIDI.programChange(T,b.programNumber,M);break;case"pitchBend":MIDI.pitchBend(T,b.value,M);break;case"noteOn":if(w.mute)break;p=b.noteNumber-(e.MIDIOffset||0),r.push({event:b,time:D,source:MIDI.noteOn(T,b.noteNumber,b.velocity,M),interval:u(T,p,n+e.startDelay,A-h,144,b.velocity)}),m++;break;case"noteOff":if(w.mute)break;p=b.noteNumber-(e.MIDIOffset||0),r.push({event:b,time:D,source:MIDI.noteOff(T,b.noteNumber,M),interval:u(T,p,n,A-h,128,0)});break;default:}}}}d&&d(r)}},f=function(){var n=s();for(e.playing=!1,e.restart+=1e3*(n.currentTime-o);r.length;){var t=r.pop();window.clearInterval(t.interval),t.source&&("number"==typeof t.source?window.clearTimeout(t.source):t.source.disconnect(0))}for(var u in i){var t=i[u];144===i[u].message&&a&&a({channel:t.channel,note:t.note,now:t.now,end:t.end,message:128,velocity:t.velocity})}i={}}}(),function(e){"use strict";window.Audio&&function(){for(var n=e.AudioTag={api:"audiotag"},t={},r=127,o=-1,i=[],a=[],u={},s=0;12>s;s++)i[s]=new Audio;var c=function(n,t){if(e.channels[n]){var s=e.channels[n].instrument,c=e.GM.byId[s].id,t=u[t];if(t){var l=c+""+t.id,d=(o+1)%i.length,f=i[d];if(a[d]=l,!e.Soundfont[c])return e.DEBUG&&console.log("404",c),void 0;f.src=e.Soundfont[c][t.id],f.volume=r/127,f.play(),o=d}}},l=function(n,t){if(e.channels[n]){var r=e.channels[n].instrument,s=e.GM.byId[r].id,t=u[t];if(t)for(var c=s+""+t.id,l=0,d=i.length;d>l;l++){var f=(l+o+1)%d,p=a[f];if(p&&p==c)return i[f].pause(),a[f]=null,void 0}}};n.audioBuffers=i,n.send=function(){},n.setController=function(){},n.setVolume=function(e,n){r=n},n.programChange=function(n,t){e.channels[n].instrument=t},n.pitchBend=function(){},n.noteOn=function(e,n,r,o){var i=t[n];if(u[i])return o?setTimeout(function(){c(e,i)},1e3*o):(c(e,i),void 0)},n.noteOff=function(){},n.chordOn=function(e,n,r,o){for(var i=0;n.length>i;i++){var a=n[i],s=t[a];if(u[s]){if(o)return setTimeout(function(){c(e,s)},1e3*o);c(e,s)}}},n.chordOff=function(e,n,r){for(var o=0;n.length>o;o++){var i=n[o],a=t[i];if(u[a]){if(r)return setTimeout(function(){l(e,a)},1e3*r);l(e,a)}}},n.stopAllNotes=function(){for(var e=0,n=i.length;n>e;e++)i[e].pause()},n.connect=function(r){e.setDefaultPlugin(n);for(var o in e.keyToNote)t[e.keyToNote[o]]=o,u[o]={id:o};r.onsuccess&&r.onsuccess()}}()}(MIDI),function(e){"use strict";window.AudioContext&&function(){function n(e,n,t){if(o){var i=new Audio;i.src=e,i.controls=!1,i.autoplay=!1,i.preload=!1,i.addEventListener("canplay",function(){n&&n(i)}),i.addEventListener("error",function(e){t&&t(e)}),document.body.appendChild(i)}else if(0===e.indexOf("data:audio")){var a=e.split(",")[1],u=Base64Binary.decodeArrayBuffer(a);r.decodeAudioData(u,n,t)}else{var s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="arraybuffer",s.onload=function(){r.decodeAudioData(s.response,n,t)},s.send()}}function t(){return new(window.AudioContext||window.webkitAudioContext)}var r,o=!1,i=e.WebAudio={api:"webaudio"},a={},u={},s=127,c={};i.audioBuffers=c,i.send=function(){},i.setController=function(){},i.setVolume=function(e,n,t){t?setTimeout(function(){s=n},1e3*t):s=n},i.programChange=function(n,t){var r=e.channels[n];r.instrument=t},i.pitchBend=function(n,t){var r=e.channels[n];r.pitchBend=t},i.noteOn=function(n,t,i,l){l=l||0;var d=e.channels[n],f=d.instrument,p=f+""+t,A=c[p];if(A){if(r.currentTime>l&&(l+=r.currentTime),o)var m=r.createMediaElementSource(A);else{var m=r.createBufferSource();m.buffer=A}if(u){var v=m;for(var q in u)v.connect(u[q].input),v=u[q]}var g=2*i/127*(s/127)-1;if(m.connect(r.destination),m.playbackRate.value=1,m.gainNode=r.createGain(),m.gainNode.connect(r.destination),m.gainNode.gain.value=Math.min(1,Math.max(-1,g)),m.connect(m.gainNode),o){if(l)return setTimeout(function(){A.currentTime=0,A.play()},1e3*l);A.currentTime=0,A.play()}else m.start(l||0);return a[n+""+t]=m,m}},i.noteOff=function(n,t,i){i=i||0;var u=e.channels[n],s=u.instrument,l=s+""+t,d=c[l];if(d){r.currentTime>i&&(i+=r.currentTime);var f=a[n+""+t];if(f){if(f.gainNode){var p=f.gainNode.gain;p.linearRampToValueAtTime(p.value,i),p.linearRampToValueAtTime(-1,i+.3)}return o?i?setTimeout(function(){d.pause()},1e3*i):d.pause():f.noteOff?f.noteOff(i+.5):f.stop(i+.5),delete a[n+""+t],f}}},i.chordOn=function(e,n,t,r){for(var o,a={},u=0,s=n.length;s>u;u++)a[o=n[u]]=i.noteOn(e,o,t,r);return a},i.chordOff=function(e,n,t){for(var r,o={},a=0,u=n.length;u>a;a++)o[r=n[a]]=i.noteOff(e,r,t);return o},i.stopAllNotes=function(){for(var e in a){var n=0;r.currentTime>n&&(n+=r.currentTime);var t=a[e];t.gain.linearRampToValueAtTime(1,n),t.gain.linearRampToValueAtTime(0,n+.3),t.noteOff?t.noteOff(n+.3):t.stop(n+.3),delete a[e]}},i.setEffects=function(e){if(!r.tunajs)return console.log("Effects module not installed.");for(var n=0;e.length>n;n++){var t=e[n],o=new r.tunajs[t.type](t);o.connect(r.destination),u[t.type]=o}},i.connect=function(n){e.setDefaultPlugin(i),i.setContext(r||t(),n.onsuccess)},i.getContext=function(){return r},i.setContext=function(t,o){r=t,"undefined"==typeof Tuna||r.tunajs||(r.tunajs=new Tuna(r));var i=[],a=e.keyToNote;for(var u in a)i.push(u);var s=function(){for(var e in d)if(d[e])return;o&&(o(),o=null)},l=function(t,r,o,i){var a=t[i];a&&(d[r]++,n(a,function(n){n.id=i;var o=e.keyToNote[i];c[r+""+o]=n,0===--d[r]&&(t.isLoaded=!0,s(f))},function(){}))},d={};for(var f in e.Soundfont){var p=e.Soundfont[f];if(!p.isLoaded){var A=e.GM.byName[f],m=A.number;d[m]=0;for(var v=0;i.length>v;v++){var u=i[v];l(p,m,v,u)}}}setTimeout(s,1)}}()}(MIDI),function(e){"use strict";var n=null,t=null,r=e.WebMIDI={api:"webmidi"};r.send=function(e,n){t.send(e,1e3*n)},r.setController=function(e,n,r,o){t.send([e,n,r],1e3*o)},r.setVolume=function(e,n,r){t.send([176+e,7,n],1e3*r)},r.programChange=function(e,n,r){t.send([192+e,n],1e3*r)},r.pitchBend=function(e,n,r){t.send([224+e,n],1e3*r)},r.noteOn=function(e,n,r,o){t.send([144+e,n,r],1e3*o)},r.noteOff=function(e,n,r){t.send([128+e,n,0],1e3*r)},r.chordOn=function(e,n,r,o){for(var i=0;n.length>i;i++){var a=n[i];t.send([144+e,a,r],1e3*o)}},r.chordOff=function(e,n,r){for(var o=0;n.length>o;o++){var i=n[o];t.send([128+e,i,0],1e3*r)}},r.stopAllNotes=function(){t.cancel();for(var e=0;16>e;e++)t.send([176+e,123,0])},r.connect=function(o){e.setDefaultPlugin(r);var i=function(){if(window.AudioContext)o.api="webaudio";else{if(!window.Audio)return;o.api="audiotag"}e.loadPlugin(o)};navigator.requestMIDIAccess().then(function(e){n=e;var r=n.outputs;t="function"==typeof r?r()[0]:r[0],void 0===t?i():o.onsuccess&&o.onsuccess()},i)}}(MIDI),"undefined"==typeof MIDI&&(MIDI={}),function(e){var n=e.util||(e.util={});if(n.request=function(n,r,o,i){"use strict";"string"==typeof n&&(n={url:n});var a=n.data,u=n.url,s=n.method||(n.data?"POST":"GET"),c=n.format,l=n.headers,d=n.responseType,f=n.withCredentials||!1,r=r||n.onsuccess,o=o||n.onerror,i=i||n.onprogress;if(t!==void 0&&e.loc.isLocalUrl(u))return t.readFile(u,"utf8",function(e,n){e?o&&o(e):r&&r({responseText:n})}),void 0;var p=new XMLHttpRequest;if(p.open(s,u,!0),l)for(var A in l)p.setRequestHeader(A,l[A]);else a&&p.setRequestHeader("Content-type","application/x-www-form-urlencoded");return"binary"===c&&p.overrideMimeType&&p.overrideMimeType("text/plain; charset=x-user-defined"),d&&(p.responseType=d),f&&(p.withCredentials="true"),o&&"onerror"in p&&(p.onerror=o),i&&p.upload&&"onprogress"in p.upload&&(a?p.upload.onprogress=function(e){i.call(p,e,event.loaded/event.total)}:p.addEventListener("progress",function(e){var n=0;if(e.lengthComputable)n=e.total;else if(p.totalBytes)n=p.totalBytes;else{var t=parseInt(p.getResponseHeader("Content-Length-Raw"));if(!isFinite(t))return;p.totalBytes=n=t}i.call(p,e,e.loaded/n)})),p.onreadystatechange=function(n){if(4===p.readyState)if(200===p.status||304===p.status||308===p.status||0===p.status&&e.client.cordova){if(r){var t;if("xml"===c)t=n.target.responseXML;else if("text"===c)t=n.target.responseText;else if("json"===c)try{t=JSON.parse(n.target.response)}catch(i){o&&o.call(p,n)}r.call(p,n,t)}}else o&&o.call(p,n)},p.send(a),p},"undefined"!=typeof module&&module.exports){var t=require("fs");XMLHttpRequest=require("xmlhttprequest").XMLHttpRequest,module.exports=e.util.request}}(MIDI),dom===void 0)var dom={};(function(){"use strict";dom.loadScript=function(){return this.loaded={},this.loading={},this},dom.loadScript.prototype.add=function(n){var t=this;"string"==typeof n&&(n={url:n});var r=n.urls;r===void 0&&(r=[{url:n.url,verify:n.verify}]);var o=document.getElementsByTagName("head")[0],i=function(n,r){t.loaded[n.url]||r&&e(r)===!1||(t.loaded[n.url]=!0,t.loading[n.url]&&t.loading[n.url](),delete t.loading[n.url],n.onsuccess&&n.onsuccess(),f!==void 0&&f())},a=!1,u=[],s=function(e){if("string"==typeof e&&(e={url:e,verify:n.verify}),/([\w\d.\[\]\'\"])$/.test(e.verify)){var r=e.test=e.verify;if("object"==typeof r)for(var s=0;r.length>s;s++)u.push(r[s]);else u.push(r)}if(!t.loaded[e.url]){var l=document.createElement("script");l.onreadystatechange=function(){("loaded"===this.readyState||"complete"===this.readyState)&&i(e)},l.onload=function(){i(e)},l.onerror=function(){if(a=!0,delete t.loading[e.url],"object"==typeof e.test)for(var n in e.test)c(e.test[n]);else c(e.test)},l.setAttribute("type","text/javascript"),l.setAttribute("src",e.url),o.appendChild(l),t.loading[e.url]=function(){}}},c=function(e){for(var n=[],t=0;u.length>t;t++)u[t]!==e&&n.push(u[t]);u=n},l=function(t){if(t)i(t,t.test);else for(var o=0;r.length>o;o++)i(r[o],r[o].test);for(var s=!0,o=0;u.length>o;o++)e(u[o])===!1&&(s=!1);!n.strictOrder&&s?a?n.error&&n.error():n.onsuccess&&n.onsuccess():setTimeout(function(){l(t)},10)};if(n.strictOrder){var d=-1,f=function(){if(d++,r[d]){var e=r[d],o=e.url;t.loading[o]?t.loading[o]=function(){e.onsuccess&&e.onsuccess(),f()}:t.loaded[o]?f():(s(e),l(e))}else a?n.error&&n.error():n.onsuccess&&n.onsuccess()};f()}else for(var d=0;r.length>d;d++)s(r[d]),l(r[d])},dom.loadScript=new dom.loadScript;var e=function(e,n){try{e=e.split('"').join("").split("'").join("").split("]").join("").split("[").join(".");for(var t=e.split("."),r=t.length,o=n||window,i=0;r>i;i++){var a=t[i];if(null==o[a])return!1;o=o[a]}return!0}catch(u){return!1}}})(),"undefined"!=typeof module&&module.exports&&(module.exports=dom.loadScript);
|