!function(t){try{t.MIDIjs=new Object,t.MIDIjs.initError="initializing ...";var n,s,l,u,r,d,c=6,m=null,p=0,o=32768,f=8192,g=0,a=0,I=0,b=!1,M="",w=-1,j="",y=!1,v=0,h=!1,_=100,D=null,A=null,k="libtimidity-for-worklet.js?v="+c,x=null,O=new Array,C=440,E=new Int32Array(128),T=Math.pow(2,1/12);function R(e){var t=0;return void 0!==e&&(!0===e?t=-1:!isNaN(e)&&0',document.body&&document.body.appendChild(e)),d=setInterval(z,_),w=-1,p=e,Y("Playing "+url+" ...")}function J(){p&&(p.lastChild.setAttribute("src",G(M)+"../midi/silence.mid"),clearInterval(d),p=0),Y(j)}function K(){var e;p&&((e=p).parentNode.removeChild(e),clearInterval(d),p=0),Y(j)}function Q(e,t,n){var r=Module._malloc(t.length);Module.writeArrayToMemory(t,r);Module.ccall("mid_init","number",[],[]);var o=Module.ccall("mid_istream_open_mem","number",["number","number","number"],[r,t.length,!1]),t=Module.ccall("mid_create_options","number",["number","number","number","number"],[44100,32784,1,2*f]),t=Module.ccall("mid_song_load","number",["number","number"],[o,t]),o=(Module.ccall("mid_istream_close","number",["number"],[o]),Module.ccall("mid_song_get_total_time","number",["number"],[t])/1e3);Module.ccall("mid_song_free","void",["number"],[t]),Module._free(r),n&&n(o)}function Y(){if(h){for(var e=new Array("[midijs] "),t=0;t>4?V(M+"../midi/init.midi?v="+c,function(e,t,n){Y("Got MIDI data from URL: "+e),t[43]=a;var r=new Object;r.type="prepare-player",r.url=e,r.midiDataArray=t,r.sampleRate=m.sampleRate,r.isEndless=!0,r.looping=!1,A.port.postMessage(r),(r=new Object).type="midi-message",r.status=o,r.a=a,r.b=i,A.port.postMessage(r)},function(){}):((e=new Object).type="midi-message",e.status=o,e.a=a,e.b=i,A.port.postMessage(e))}function te(e,t,n){A||ne(),"suspended"===m.state?m.resume().then(function(){x.then(function(){ee(e,t,n)})}):x.then(function(){ee(e,t,n)})}function ne(e){var a;A||(m||(window.AudioContext=window.AudioContext||window.webkitAudioContext,m=new AudioContext),a=null,x=new Promise(function(e){a=e}),m.audioWorklet.addModule(M+k).then(function(){A=new AudioWorkletNode(m,"midijs-audio-worklet");var e=new Object;e.type="set-logging",e.logging=h,A.port.postMessage(e),A.connect(m.destination),A.port.onmessage=function(e){var t=e.data;if(Y("Request from worklet: ",t),"get-patches"==t.type){var n=t.patches;if(0==(g=n.length)){e=new Object;e.type="start-player",e.url=M+"../midi/init-expander.midi?v="+c,A.port.postMessage(e)}else for(var r=0;r',document.body&&document.body.appendChild(t)),d=setInterval(z,_),w=-1,p=t,Y("Playing "+e+" ...")},t.MIDIjs.stop=K,"audioMethod: <object>"):(t.MIDIjs.play=function(e){},t.MIDIjs.stop=function(e){},"audioMethod: No method found"),"Microsoft Internet Explorer"==me.browserName&&"https:"==location.protocol.toLowerCase()&&setTimeout(function(){X(G(M)+"../midi/silence.mid"),clearInterval(d)},1),-1==location.href.indexOf("scorio.com")&&-1==location.href.indexOf("weblily.net")&&-1==location.href.indexOf("local")||"WebAudioWorklet"==n&&ne(),t.MIDIjs.initError=null}catch(ve){t.MIDIjs=new Object,t.MIDIjs.initError=ve}var fe,ge,Ie,be,Me,we}(this);
//# sourceMappingURL=https://midijs.intern.scorio.com/lib/midi.js.map