Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

picoaudio

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

picoaudio - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

dist/browser/PicoAudio.min.js

@@ -1,2 +0,2 @@

var PicoAudio=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var a=0;a<t.length;a++){var i=t[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function i(e,t,i){return t&&a(e.prototype,t),i&&a(e,i),e}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function r(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function o(e,t,a){return(o=r()?Reflect.construct:function(e,t,a){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return a&&s(n,a.prototype),n}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(a=e,-1===Function.toString.call(a).indexOf("[native code]")))return e;var a;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return o(e,arguments,n(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),s(i,e)})(e)}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function l(e){for(var t in this.debug=!1,this.isStarted=!1,this.isPlayed=!1,this.settings={masterVolume:1,generateVolume:.15,tempo:120,basePitch:440,resolution:480,isWebMIDI:!1,WebMIDIPortOutputs:null,WebMIDIPortOutput:null,WebMIDIPort:-1,WebMIDIPortSysEx:!0,isReverb:!0,reverbVolume:1.5,initReverb:10,isChorus:!0,chorusVolume:.5,isCC111:!0,loop:!1,isSkipBeginning:!1,isSkipEnding:!0,holdOnValue:64,maxPoly:-1,maxPercPoly:-1,isOfflineRendering:!1,isSameDrumSoundOverlap:!1,baseLatency:-1},m(this,e,"debug"),this.settings)m(this.settings,e,t);this.events=[],this.trigger={isNoteTrigger:!0,play:function(){},stop:function(){},noteOn:function(){},noteOff:function(){},songEnd:function(){}},this.states={isPlaying:!1,startTime:0,stopTime:0,stopFuncs:[],webMIDIWaitState:null,webMIDIStopTime:0,playIndices:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],updateBufTime:100,updateBufMaxTime:350,updateIntervalTime:0,latencyLimitTime:0},this.hashedDataList=[],this.hashedMessageList=[],this.playData=null,this.channels=[],this.tempoTrack=[{timing:0,value:120},{timing:0,value:120}],this.cc111Time=-1,this.onSongEndListener=null,this.baseLatency=.01;for(var a=0;a<17;a++)this.channels.push([0,0,1]);e&&e.audioContext&&this.init(e)}function m(e,t,a){t&&null!=t[a]&&e&&null!=e[a]&&(e[a]=t[a])}var h=function(){function e(){t(this,e)}return i(e,null,[{key:"resetSeed",value:function(){this.init=!0,this.x=123456789,this.y=362436069,this.z=521288629,this.w=8867512}},{key:"random",value:function(){this.init||this.resetSeed();var e=this.x^this.x<<11;this.x=this.y,this.y=this.z,this.z=this.w;var t=this.w=this.w^this.w>>>19^e^e>>>8;return t=Math.abs(t)/2147483648%2}}]),e}(),p=function(){function e(){t(this,e)}return i(e,null,[{key:"lerpWave",value:function(e,t){var a=e.getChannelData(0).length,i=t[0].length;if(a==i)for(var n=0;n<2;n++)for(var s=e.getChannelData(n),r=t[n],o=0;o<a;o++)s[o]=r[o];else for(var u=i/a,c=0;c<2;c++)for(var l=e.getChannelData(c),m=t[c],h=0;h<a;h++){var p=h*u,T=Math.trunc(p),f=(T+1)%i,g=p-T,v=m[T]*(1-g)+m[f]*g;l[h]=v}}}]),e}();function T(e){if(!this.isStarted){this.isStarted=!0;var t=e&&e.audioContext,a=e&&e.picoAudio,i=window.AudioContext||window.webkitAudioContext;this.context=t||new i,this.masterGainNode=this.context.createGain(),this.masterGainNode.gain.value=this.settings.masterVolume;var n=this.context.sampleRate,s=n>=48e3?48e3:n;if(a&&a.whitenoise)this.whitenoise=a.whitenoise;else{h.resetSeed();for(var r=1*n,o=1*s,u=[],c=0;c<2;c++){u.push(new Float32Array(o));for(var l=u[c],m=0;m<o;m++){var T=h.random();l[m]=2*T-1}}this.whitenoise=this.context.createBuffer(2,r,n),p.lerpWave(this.whitenoise,u)}if(a&&a.impulseResponse)this.impulseResponse=a.impulseResponse;else{h.resetSeed();for(var f=3.5*n,g=3.5*s,v=[],d=0;d<2;d++){v.push(new Float32Array(g));for(var y=v[d],b=0;b<g;b++){var A=(g-b)/g,V=b/s,k=(V<.03?0:A)*(V>=.03&&V<.031?2*A:A)*(V>=.04&&V<.042?1.5*A:A)*(V>=.05&&V<.054?1.25*A:A)*h.random()*.2*Math.pow(A-.03,4);y[b]=k}}this.impulseResponse=this.context.createBuffer(2,f,this.context.sampleRate),p.lerpWave(this.impulseResponse,v)}this.convolver=this.context.createConvolver(),this.convolver.buffer=this.impulseResponse,this.convolver.normalize=!0,this.convolverGainNode=this.context.createGain(),this.convolverGainNode.gain.value=this.settings.reverbVolume,this.convolver.connect(this.convolverGainNode),this.convolverGainNode.connect(this.masterGainNode),this.masterGainNode.connect(this.context.destination),this.chorusDelayNode=this.context.createDelay(),this.chorusGainNode=this.context.createGain(),this.chorusOscillator=this.context.createOscillator(),this.chorusLfoGainNode=this.context.createGain(),this.chorusDelayNode.delayTime.value=.025,this.chorusLfoGainNode.gain.value=.01,this.chorusOscillator.frequency.value=.05,this.chorusGainNode.gain.value=this.settings.chorusVolume,this.chorusOscillator.connect(this.chorusLfoGainNode),this.chorusLfoGainNode.connect(this.chorusDelayNode.delayTime),this.chorusDelayNode.connect(this.chorusGainNode),this.chorusGainNode.connect(this.masterGainNode),this.masterGainNode.connect(this.context.destination),this.chorusOscillator.start(0),this.baseLatency=this.context.baseLatency||this.baseLatency,-1!=this.settings.baseLatency&&(this.baseLatency=this.settings.baseLatency)}}var f=function(){function e(){t(this,e)}return i(e,null,[{key:"now",value:function(){return null==this._now&&(void 0===window.performance?this._now=function(){return window.Date.now()}:this._now=function(){return window.performance.now()}),this._now()}}]),e}();function g(e){if(this.debug)var t=f.now();if(this.states.isPlaying&&this.stop(),this.playData=e,this.settings.resolution=e.header.resolution,this.settings.tempo=e.tempo||120,this.tempoTrack=e.tempoTrack,this.cc111Time=e.cc111Time,this.firstNoteOnTiming=e.firstNoteOnTiming,this.lastNoteOffTiming=e.lastNoteOffTiming,this.firstNoteOnTime=e.firstNoteOnTime,this.lastNoteOffTime=e.lastNoteOffTime,this.initStatus(),this.debug){var a=f.now();console.log("setData time",a-t)}return this}function v(e,t){if((!this.settings.isWebMIDI||null==this.states.webMIDIWaitState)&&(this.stop(e),this.states={isPlaying:!1,startTime:0,stopTime:0,stopFuncs:[],webMIDIWaitState:null,webMIDIStopTime:this.states.webMIDIStopTime,playIndices:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],updateBufTime:this.states.updateBufTime,updateBufMaxTime:this.states.updateBufMaxTime,updateIntervalTime:this.states.updateIntervalTime,latencyLimitTime:this.states.latencyLimitTime,noteOnAry:[],noteOffAry:[]},this.settings.isWebMIDI&&!t)){if(e)return;if(null==this.settings.WebMIDIPortOutput)return void this.startWebMIDI();if(this.settings.WebMIDIPortSysEx)this.settings.WebMIDIPortOutput.send([240,126,127,9,1,247]);else for(var a=0;a<16;a++)this.settings.WebMIDIPortOutput.send([192+a,0]),this.settings.WebMIDIPortOutput.send([224+a,0,64]),this.settings.WebMIDIPortOutput.send([176+a,100,0]),this.settings.WebMIDIPortOutput.send([176+a,101,0]),this.settings.WebMIDIPortOutput.send([176+a,6,2]),this.settings.WebMIDIPortOutput.send([176+a,100,1]),this.settings.WebMIDIPortOutput.send([176+a,96,0]),this.settings.WebMIDIPortOutput.send([176+a,97,64]),this.settings.WebMIDIPortOutput.send([176+a,7,100]),this.settings.WebMIDIPortOutput.send([176+a,10,64]),this.settings.WebMIDIPortOutput.send([176+a,11,127]),this.settings.WebMIDIPortOutput.send([176+a,98,0]),this.settings.WebMIDIPortOutput.send([176+a,99,0]),this.settings.WebMIDIPortOutput.send([176+a,122,0])}}var d=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(l,e);var a,o,u=(a=l,o=r(),function(){var e,t=n(a);if(o){var i=n(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return c(this,e)});function l(){return t(this,l),u.apply(this,arguments)}return i(l,null,[{key:"delete",value:function(e,t){t==e.length-1?e.pop():0==t?e.shift():e.splice(t,1)}}]),l}(u(Array)),y=function(){function e(){t(this,e)}return i(e,null,[{key:"getInt",value:function(e,t,a){for(var i=0,n=t;n<a;n++)i=(i<<8)+e[n];return i}},{key:"variableLengthToInt",value:function(e,t,a){for(var i=t,n=0;i<a-1&&e[i]>=128;)i<t+4&&(n=(n<<7)+(e[i]-128)),i++;return[n=(n<<7)+e[i],++i-t]}},{key:"chIndicesInsert",value:function(e,t,a,i,n){var s=t.indices;if(t.indicesLength>=4&&a<s[t.indicesFoot])for(;-1!=t.indicesCur;){if(a<s[t.indicesCur]){t.indicesCur==t.indicesHead?t.indicesHead=t.indicesLength:s[t.indicesPre+3]=t.indicesLength,s[t.indicesLength]=a,s[t.indicesLength+1]=n,s[t.indicesLength+2]=i,s[t.indicesLength+3]=t.indicesCur,t.indicesPre=t.indicesLength,t.indicesLength+=4;break}t.indicesPre=t.indicesCur,t.indicesCur=s[t.indicesCur+3]}else t.indicesLength>=4?s[t.indicesFoot+3]=t.indicesLength:t.indicesHead=0,t.indicesFoot=t.indicesLength,s[t.indicesLength]=a,s[t.indicesLength+1]=n,s[t.indicesLength+2]=i,s[t.indicesLength+3]=-1,t.indicesLength+=4}}]),e}(),b=function(){function e(){t(this,e)}return i(e,null,[{key:"init",value:function(e,t){this.updatePreTime=f.now(),this.pPreTime=f.now(),this.cPreTime=1e3*e.context.currentTime,this.pTimeSum=0,this.cTimeSum=0,this.cnt=0,this.initCurrentTime=t}},{key:"update",value:function(e){var t=this,a=e.context,i=e.settings,n=e.states,s=e.baseLatency,r=f.now(),o=this.updatePreTime,u=this.pPreTime,c=this.cPreTime,l=this.pTimeSum,m=this.cTimeSum,h=this.cnt,p=r-o,T=r,g=1e3*a.currentTime;l+=T-u,m+=g-c,u=T,c=g;var v=l-m;if(n.latencyTime=v,v>=100?(n.latencyLimitTime+=v,m+=100):v<=-100?m=l:n.latencyLimitTime>0&&(n.latencyLimitTime-=.003*p,n.latencyLimitTime<0&&(n.latencyLimitTime=0)),n.updateIntervalTime=p,n.updateBufTime<p?n.updateBufTime=p:(n.updateBufMaxTime>350&&(n.updateBufMaxTime-=.002*n.updateBufMaxTime),n.updateBufTime<20&&(n.updateBufTime+=5e-4*n.updateBufTime),n.updateBufMaxTime>=10&&n.updateBufMaxTime<340&&(n.updateBufMaxTime+=.002*n.updateBufMaxTime)),n.updateBufTime>n.updateBufMaxTime){if(p>=900&&n.latencyLimitTime<=150)n.updateBufMaxTime+=p;else{var d=p-n.updateBufMaxTime;n.updateBufTime=n.updateBufMaxTime,n.updateBufMaxTime<10?(n.updateBufTime=n.updateBufMaxTime,n.updateBufMaxTime*=1.25):n.updateBufMaxTime+=d/2}n.updateBufMaxTime>1100&&(n.updateBufMaxTime=1100)}n.latencyLimitTime>150&&(m=l,n.latencyLimitTime-=5,n.latencyLimitTime>1e3&&(n.latencyLimitTime=1e3),n.updateBufMaxTime=1,n.updateBufTime=1,p=1);for(var b=0;b<16;b++){for(var A=e.playData.channels[b].notes,V=n.playIndices[b],k=function(){var r=A[V],o=0==h?t.initCurrentTime-n.startTime:a.currentTime-n.startTime;if(o>=r.stopTime)return"continue";if(0==h&&o>r.startTime+s)return"continue";if(o<r.startTime-n.updateBufTime/1e3)return"break";if(!i.isWebMIDI){if(n.stopFuncs.length>=350&&n.updateBufTime<1e3&&(n.updateBufTime=12,n.updateBufMaxTime=n.updateBufTime),-1!=i.maxPoly||-1!=i.maxPercPoly){var u=0,c=0;if(n.stopFuncs.forEach((function(e){e.note&&(9!=e.note.channel?r.start>=e.note.start&&r.start<e.note.stop&&u++:r.start==e.note.start&&c++)})),9!=r.channel&&u>=i.maxPoly||9==r.channel&&c>=i.maxPercPoly)return"continue"}var l=9!=r.channel?e.createNote(r):e.createPercussionNote(r);if(!l)return"continue";e.pushFunc({note:r,stopFunc:l})}n.noteOnAry.push(r)};V<A.length;V++){var I=k();if("continue"!==I&&"break"===I)break}n.playIndices[b]=V}if(this.checkNoteOn(e),this.checkNoteOff(e),i.isWebMIDI&&null!=i.WebMIDIPortOutput){for(var R=e.playData.messages,M=e.playData.smfData,N=n.playIndices[16];N<R.length;N++){var w=R[N],O=a.currentTime-n.startTime;if(!(O>w.time+1)){if(O<w.time-1)break;var x=w.smfPtrLen,P=w.smfPtr,D=w.time,S=M[P];if(255!=S)try{if(240==S||247==S){if(i.WebMIDIPortSysEx){var L=y.variableLengthToInt(M,P+1,P+1+4),W=P+1+L[1],q=W+L[0],B=new Uint8Array(1+L[0]);B[0]=S;for(var E=q-W,C=0;C<E;C++)B[C+1]=M[W+C];i.WebMIDIPortOutput.send(B,1e3*(D-a.currentTime+f.now()/1e3+n.startTime))}}else{for(var G=[],F=0;F<x;F++)G.push(M[P+F]);i.WebMIDIPortOutput.send(G,1e3*(D-a.currentTime+f.now()/1e3+n.startTime))}}catch(e){console.log(e,P,x,D,S)}}}n.playIndices[16]=N}h++,this.updatePreTime=r,this.pPreTime=u,this.cPreTime=c,this.pTimeSum=l,this.cTimeSum=m,this.cnt=h}},{key:"checkNoteOn",value:function(e){for(var t=e.context,a=e.trigger,i=e.states,n=e.states.noteOnAry,s=e.states.noteOffAry,r=0;r<n.length;r++){var o=n[r],u=t.currentTime-i.startTime;o.startTime-u<=0&&(d.delete(n,r),s.push(o),a.isNoteTrigger&&a.noteOn(o),e.fireEvent("noteOn",o),r--)}}},{key:"checkNoteOff",value:function(e){for(var t=e.context,a=e.trigger,i=e.states,n=e.states.noteOffAry,s=0;s<n.length;s++){var r=n[s],o=t.currentTime-i.startTime;(9!=r.channel&&r.stopTime-o<=0||9==r.channel&&r.drumStopTime-o<=0)&&(d.delete(n,s),e.clearFunc("note",r),a.isNoteTrigger&&a.noteOff(r),e.fireEvent("noteOff",r),s--)}}}]),e}();function A(e){var t=this,a=this.context,i=this.settings,n=this.trigger,s=this.states;if(a.resume&&a.resume(),!s.isPlaying){if(i.isWebMIDI&&!e){if("completed"!=s.webMIDIWaitState){if("waiting"!=s.webMIDIWaitState){s.webMIDIWaitState="waiting";var r=1e3-1e3*(a.currentTime-s.webMIDIStopTime);0==s.webMIDIStopTime&&(r=1e3),setTimeout((function(){s.webMIDIWaitState="completed",s.isPlaying=!1,t.play()}),r)}return}s.webMIDIWaitState=null}var o,u=a.currentTime;if(this.isPlayed=!0,s.isPlaying=!0,s.startTime=s.startTime||s.stopTime?s.startTime+u-s.stopTime:u,s.stopFuncs=[],i.isSkipBeginning){var c=this.firstNoteOnTime;-s.startTime+u<c&&this.setStartTime(c+s.startTime-u)}var l=1e3*((i.isCC111&&-1!=this.cc111Time?this.lastNoteOffTime:this.getTime(9007199254740991))-a.currentTime+s.startTime);o=setTimeout((function e(){t.clearFunc("rootTimeout",o),(i.isCC111&&-1!=t.cc111Time?t.lastNoteOffTime:t.getTime(9007199254740991))-a.currentTime+s.startTime<=0?(n.songEnd(),t.onSongEnd(),t.fireEvent("songEnd")):(o=setTimeout(e,1),t.pushFunc({rootTimeout:o,stopFunc:function(){clearTimeout(o)}}))}),l),this.pushFunc({rootTimeout:o,stopFunc:function(){clearTimeout(o)}}),n.play(),this.fireEvent("play"),b.init(this,u);var m=setInterval((function(){b.update(t)}),1);this.pushFunc({rootTimeout:m,stopFunc:function(){clearInterval(m)}})}}function V(e){var t=this,a=this.states;if(0!=a.isPlaying){if(a.isPlaying=!1,a.stopTime=this.context.currentTime,a.stopFuncs.forEach((function(e){e.stopFunc()})),a.stopFuncs=[],a.playIndices.forEach((function(e,t,a){a[t]=0})),a.noteOnAry=[],a.noteOffAry=[],this.settings.isWebMIDI){if(e)return;if(null==this.settings.WebMIDIPortOutput)return;a.webMIDIStopTime=this.context.currentTime,setTimeout((function(){for(var e=0;e<16;e++)t.settings.WebMIDIPortOutput.send([176+e,120,0])}),1e3)}this.trigger.stop(),this.fireEvent("pause"),this.fireEvent("stop")}}function k(e,t,a,i,n){var s=this,r=this.settings,o=this.context,u=this.states.startTime,c=this.baseLatency,l=i?0:e.channel||0,m=e.velocity*Number(i?1:null!=this.channels[l][2]?this.channels[l][2]:1)*r.generateVolume,h=!0;if(m<=0)return{isGainValueZero:!0};var p=m*((e.expression?e.expression[0].value:100)/127),T=o.createGain();if(T.gain.value=p,a?e.expression&&e.expression.forEach((function(e){var t=m*(e.value/127);t>0&&(h=!1);var a=Math.max(0,e.time+u+c);T.gain.setValueAtTime(t,a)})):p>0&&(h=!1),h)return{isGainValueZero:!0};var f=e.startTime+u+c,g=e.stopTime+u+c,v=r.basePitch*Math.pow(Math.pow(2,1/12),(e.pitch||69)-69),d=t?o.createBufferSource():o.createOscillator(),y=o.createStereoPanner?o.createStereoPanner():o.createPanner?o.createPanner():{pan:{setValueAtTime:function(){}}},b=o.createGain(),A=o.createGain();t?(d.loop=!0,d.buffer=this.whitenoise):(d.type=e.type||"sine",d.detune.value=0,d.frequency.value=v,e.pitchBend&&e.pitchBend.forEach((function(t){var a=Math.max(0,t.time+u+c);d.frequency.setValueAtTime(r.basePitch*Math.pow(Math.pow(2,1/12),e.pitch-69+t.value),a)})));var V,k,R=e.pan&&64!=e.pan[0].value?e.pan[0].value/127*2-1:0;if(function(e,t,a){if(e.createStereoPanner)a>1&&(a=1),t.pan.value=a;else if(e.createPanner){var i=I(a);t.panningModel="equalpower",t.setPosition(i.x,i.y,i.z)}}(o,y,R),o.createStereoPanner||o.createPanner){var M=!0;if(o.createStereoPanner)e.pan&&e.pan.forEach((function(e){if(M)M=!1;else{var t=Math.min(1,64==e.value?0:e.value/127*2-1),a=Math.max(0,e.time+u+c);y.pan.setValueAtTime(t,a)}}));else if(o.createPanner)if(y.positionX){var N=!0;e.pan&&e.pan.forEach((function(e){if(N)N=!1;else{var t=I(64==e.value?0:e.value/127*2-1),a=Math.max(0,e.time+u+c);y.positionX.setValueAtTime(t.x,a),y.positionY.setValueAtTime(t.y,a),y.positionZ.setValueAtTime(t.z,a)}}))}else e.pan&&e.pan.forEach((function(e){if(M)M=!1;else{var t=setTimeout((function(){s.clearFunc("pan",t);var a=I(Math.min(1,64==e.value?0:e.value/127*2-1));y.setPosition(a.x,a.y,a.z)}),1e3*(e.time+u+c-o.currentTime));s.pushFunc({pan:t,stopFunc:function(){clearTimeout(t)}})}}));d.connect(y),y.connect(T)}else d.connect(T);if(T.connect(b),b.connect(A),A.connect(this.masterGainNode),this.masterGainNode.connect(o.destination),!t&&e.modulation&&(e.modulation.length>=2||e.modulation[0].value>0)){V=o.createOscillator(),k=o.createGain();var w=!0;e.modulation&&e.modulation.forEach((function(e){if(w)w=!1;else{var t=Math.min(1,e.value/127),a=Math.max(0,e.time+u+c);k.gain.setValueAtTime(10*v/440*t,a)}}));var O=Math.min(1,e.modulation?e.modulation[0].value/127:0);k.gain.value=10*v/440*O,V.frequency.value=6,V.connect(k),k.connect(d.frequency)}if(this.settings.isReverb&&e.reverb&&(e.reverb.length>=2||e.reverb[0].value>0)){var x=this.convolver,P=o.createGain(),D=!0;e.reverb&&e.reverb.forEach((function(e){if(D)D=!1;else{var t=Math.min(1,e.value/127),a=Math.max(0,e.time+u+c);P.gain.setValueAtTime(t,a)}}));var S=Math.min(1,e.reverb?e.reverb[0].value/127:0);P.gain.value=S,b.connect(A),A.connect(P),P.connect(x)}if(this.settings.isChorus&&e.chorus&&(e.chorus.length>=2||e.chorus[0].value>0)){var L=this.chorusDelayNode,W=o.createGain(),q=!0;e.chorus&&e.chorus.forEach((function(e){if(q)q=!1;else{var t=Math.min(1,e.value/127),a=Math.max(0,e.time+u+c);W.gain.setValueAtTime(t,a)}}));var B=Math.min(1,e.chorus?e.chorus[0].value/127:0);W.gain.value=B,b.connect(A),A.connect(W),W.connect(L)}return V&&(V.start(f),this.stopAudioNode(V,g,k)),d.start(f),t||i||n||this.stopAudioNode(d,g,A),{start:f,stop:g,pitch:v,channel:l,velocity:m,oscillator:d,panNode:y,gainNode:b,stopGainNode:A,isGainValueZero:!1}}function I(e){e>1&&(e=1);var t={},a=90*e;return t.x=Math.sin(a*(Math.PI/180)),t.y=0,t.z=-Math.cos(a*(Math.PI/180)),t}function R(e){var t=this,a=this.createBaseNote(e,!1,!0,!1,!0);if(a.isGainValueZero)return null;var i,n=a.oscillator,s=a.gainNode,r=a.stopGainNode,o=!1,u=!1;switch(1e3*this.channels[a.channel][0]||e.instrument){case 1e3:case 6:case 15:case 24:case 26:case 46:case 50:case 51:case 52:case 53:case 54:case 82:case 85:case 86:n.type="sine",s.gain.value*=1.5;break;case 2e3:case 4:case 12:case 13:case 16:case 19:case 20:case 32:case 34:case 45:case 48:case 49:case 55:case 56:case 57:case 61:case 62:case 63:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 84:n.type="square",s.gain.value*=.8;break;case 3e3:case 0:case 1:case 2:case 3:case 7:case 17:case 18:case 21:case 22:case 23:case 27:case 28:case 29:case 30:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 47:case 59:case 64:case 65:case 66:case 67:case 68:case 69:case 70:case 87:n.type="sawtooth";break;case 4e3:case 8:case 9:case 10:case 11:case 14:case 25:case 31:case 33:case 35:case 58:case 60:case 83:case 88:case 89:case 90:case 91:case 92:case 93:case 94:case 95:n.type="triangle",s.gain.value*=1.5;break;default:n.type="square"}switch(("sine"==n.type||"triangle"==n.type)&&!o&&a.stop-a.start>.01&&(u=!0),this.channels[a.channel][1]/10||e.instrument){case.2:case 12:case 13:case 45:case 55:o=!0,s.gain.value*=1.1,s.gain.setValueAtTime(s.gain.value,a.start),s.gain.linearRampToValueAtTime(0,a.start+.2),this.stopAudioNode(n,a.start+.2,r);break;case.3:case 0:case 1:case 2:case 3:case 6:case 9:case 11:case 14:case 15:case 32:case 36:case 37:case 46:case 47:s.gain.value*=1.1;var c=(128-e.pitch)/128;s.gain.setValueAtTime(s.gain.value,a.start),s.gain.linearRampToValueAtTime(.85*s.gain.value,a.start+c*c/8),s.gain.linearRampToValueAtTime(.8*s.gain.value,a.start+c*c/4),s.gain.setTargetAtTime(0,a.start+c*c/4,5*c*c),this.stopAudioNode(n,a.stop,r,u);break;case.4:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 34:s.gain.value*=1.1,s.gain.setValueAtTime(s.gain.value,a.start),s.gain.linearRampToValueAtTime(0,a.start+1+4*a.velocity),this.stopAudioNode(n,a.stop,r,u);break;case.5:case 4:case 5:case 7:case 8:case 10:case 33:case 35:s.gain.value*=1,s.gain.setValueAtTime(s.gain.value,a.start),s.gain.linearRampToValueAtTime(.95*s.gain.value,a.start+.1),s.gain.setValueAtTime(.95*s.gain.value,a.start+.1),s.gain.linearRampToValueAtTime(0,a.start+2+10*a.velocity),this.stopAudioNode(n,a.stop,r,u);break;case 119:if(s.gain.value=0,this.stopAudioNode(n,a.stop,r,u),(i=this.createBaseNote(e,!0,!0)).isGainValueZero)break;i.oscillator.playbackRate.setValueAtTime((e.pitch+1)/128,a.start),i.gainNode.gain.setValueAtTime(0,a.start),i.gainNode.gain.linearRampToValueAtTime(1.3,a.start+2),this.stopAudioNode(i.oscillator,a.stop,i.stopGainNode);break;default:s.gain.value*=1.1,s.gain.setValueAtTime(s.gain.value,a.start),this.stopAudioNode(n,a.stop,r,u)}return function(){t.stopAudioNode(n,0,r,!0),i&&i.oscillator&&t.stopAudioNode(i.oscillator,0,i.stopGainNode,!0)}}function M(e){var t=this,a=this.createBaseNote(e,!0,!1);if(a.isGainValueZero)return null;var i=a.oscillator,n=a.gainNode,s=a.stopGainNode,r=a.start,o=this.createBaseNote(e,!1,!1,!0),u=o.oscillator,c=o.gainNode,l=o.stopGainNode,m=e.nextSameNoteOnInterval;r<this.context.currentTime&&(r=this.context.currentTime);var h=0,p=0;switch(e.pitch){case 35:case 36:n.gain.value=.6,i.playbackRate.value=.02,h=.07,c.gain.value=1.1,u.frequency.setValueAtTime(120,r),u.frequency.linearRampToValueAtTime(50,r+.07),p=.07;break;case 38:case 40:i.playbackRate.value=.7,h=.05,c.gain.setValueAtTime(.8,r),c.gain.linearRampToValueAtTime(0,r+.05),u.frequency.setValueAtTime(300,r),u.frequency.linearRampToValueAtTime(200,r+.05),p=.05;break;case 41:case 43:case 45:case 47:case 48:case 50:i.playbackRate.value=.01,h=.1,u.type="square",c.gain.setValueAtTime(1,r),c.gain.linearRampToValueAtTime(.01,r+.1),u.frequency.setValueAtTime(150+20*(e.pitch-40),r),u.frequency.linearRampToValueAtTime(50+20*(e.pitch-40),r+.1),p=.1;break;case 42:case 44:i.playbackRate.value=1.5,h=.02,p=0;break;case 46:i.playbackRate.value=1.5,h=.3,n.gain.setValueAtTime(.9,r),n.gain.linearRampToValueAtTime(0,r+.3),p=0;break;case 49:case 52:case 53:case 55:case 57:i.playbackRate.value=1.2,h=.5,n.gain.setValueAtTime(1,r),n.gain.linearRampToValueAtTime(0,r+.5),p=0;break;case 51:i.playbackRate.value=1.1,h=.4,n.gain.setValueAtTime(.8,r),n.gain.linearRampToValueAtTime(0,r+.4),p=0;break;case 59:i.playbackRate.value=1.8,h=.3,n.gain.setValueAtTime(.5,r),n.gain.linearRampToValueAtTime(0,r+.3),p=0;break;case 60:case 61:i.playbackRate.value=.03,h=.03,c.gain.setValueAtTime(.8,r),c.gain.linearRampToValueAtTime(0,r+.1),u.frequency.setValueAtTime(400-40*(e.pitch-60),r),u.frequency.linearRampToValueAtTime(450-40*(e.pitch-60),r+.1),p=.1;break;case 62:i.playbackRate.value=.03,h=.03,c.gain.setValueAtTime(1,r),c.gain.linearRampToValueAtTime(0,r+.03),u.frequency.setValueAtTime(200,r),u.frequency.linearRampToValueAtTime(250,r+.03),p=.03;break;case 63:case 64:i.playbackRate.value=.03,h=.03,c.gain.setValueAtTime(1,r),c.gain.linearRampToValueAtTime(0,r+.1),u.frequency.setValueAtTime(200-30*(e.pitch-63),r),u.frequency.linearRampToValueAtTime(250-30*(e.pitch-63),r+.1),p=.1;break;case 56:case 75:i.playbackRate.value=.01,h=.1,c.gain.setValueAtTime(1,r),c.gain.linearRampToValueAtTime(0,r+.1),u.frequency.setValueAtTime(1e3+48*(e.pitch-56),r),p=.1;break;case 80:i.playbackRate.value=5,n.gain.setValueAtTime(.5,r),n.gain.linearRampToValueAtTime(0,r+.2),h=.05,u.type="triangle",c.gain.setValueAtTime(.7,r),c.gain.linearRampToValueAtTime(0,r+.2),u.frequency.setValueAtTime(6e3,r),p=.05;break;case 81:i.playbackRate.value=5,n.gain.setValueAtTime(.9,r),n.gain.linearRampToValueAtTime(0,r+.5),h=.5,u.type="triangle",c.gain.setValueAtTime(.8,r),c.gain.linearRampToValueAtTime(0,r+.3),u.frequency.setValueAtTime(6e3,r),p=.3;break;case 37:i.playbackRate.value=.26,n.gain.setValueAtTime(1.5,r),n.gain.linearRampToValueAtTime(0,r+.041),h=.041,u.frequency.setValueAtTime(330,r),u.frequency.linearRampToValueAtTime(120,r+.02),c.gain.setValueAtTime(1,r),c.gain.linearRampToValueAtTime(0,r+.02),p=.02;break;case 39:i.playbackRate.value=.5,n.gain.setValueAtTime(1.3,r),n.gain.linearRampToValueAtTime(0,r+.01),n.gain.setValueAtTime(1.3,r+.0101),n.gain.linearRampToValueAtTime(0,r+.02),n.gain.setValueAtTime(1.3,r+.0201),n.gain.linearRampToValueAtTime(0,r+.09),h=.09,u.type="triangle",u.frequency.setValueAtTime(180,r),c.gain.setValueAtTime(.8,r),c.gain.linearRampToValueAtTime(0,r+.01),c.gain.setValueAtTime(.8,r+.0101),c.gain.linearRampToValueAtTime(0,r+.02),c.gain.setValueAtTime(.8,r+.0201),c.gain.linearRampToValueAtTime(0,r+.03),p=.11;break;case 54:i.playbackRate.setValueAtTime(1,r);var T=54==e.pitch?1:.4,f=54==e.pitch?.01:0;n.gain.setValueAtTime(1*T/2,r),n.gain.linearRampToValueAtTime(1*T,r+f),n.gain.setTargetAtTime(0,r+f,.05),h=.3,u.frequency.setValueAtTime(54==e.pitch?6e3:495,r),T=54==e.pitch?1:2,c.gain.setValueAtTime(1*T/2,r),c.gain.linearRampToValueAtTime(1*T,r+f),c.gain.setTargetAtTime(0,r+f,.05),p=.3;break;case 58:i.playbackRate.setValueAtTime(.6,r),i.playbackRate.linearRampToValueAtTime(1,r+.8);n.gain.setValueAtTime(1.5,r),c.gain.setValueAtTime(.5,r);for(var g=0;g<40;g++)n.gain.linearRampToValueAtTime(.1*(40-g)/40,r+g/40*.8),n.gain.linearRampToValueAtTime(1.5*(40-(g+1))/40,r+(g+.99)/40*.8),c.gain.linearRampToValueAtTime(.025*(40-g)/40,r+g/40*.8),c.gain.linearRampToValueAtTime(.25*(40-(g+1))/40,r+(g+.99)/40*.8);n.gain.linearRampToValueAtTime(0,r+.8),c.gain.linearRampToValueAtTime(0,r+.8),h=.8,u.type="triangle",u.frequency.setValueAtTime(1e3,r),p=.8;break;case 65:case 66:var v=65==e.pitch?.22:.25;i.playbackRate.setValueAtTime(65==e.pitch?.25:.22,r),i.playbackRate.linearRampToValueAtTime(65==e.pitch?.2:.18,r+v),n.gain.setValueAtTime(1.3,r),n.gain.linearRampToValueAtTime(.2,r+v/3.5),n.gain.linearRampToValueAtTime(0,r+v),h=v,u.type="triangle",u.frequency.setValueAtTime(65==e.pitch?203.3:145.52,r),u.frequency.linearRampToValueAtTime(65==e.pitch?190:136,r+.1),c.gain.setValueAtTime(3.2,r),c.gain.setTargetAtTime(0,r,.08),p=1;break;case 67:case 68:i.playbackRate.value=1,n.gain.setValueAtTime(.5,r),n.gain.linearRampToValueAtTime(.1,r+.02),n.gain.linearRampToValueAtTime(0,r+.08),h=.08,u.type="triangle",u.frequency.setValueAtTime(67==e.pitch?1430:1055,r),c.gain.setValueAtTime(2,r),c.gain.setTargetAtTime(0,r,.06),p=.75;break;case 69:i.playbackRate.value=1,n.gain.setValueAtTime(.3,r),n.gain.linearRampToValueAtTime(.8,r+.03),n.gain.linearRampToValueAtTime(0,r+.08),h=.08,c.gain.value=0,p=0;break;case 70:i.playbackRate.value=1,n.gain.setValueAtTime(1.2,r),n.gain.linearRampToValueAtTime(0,r+.06),h=.06,c.gain.value=0,p=0;break;case 71:case 72:n.gain.value=0,h=0;var d=71==e.pitch?.07:.4;u.type="triangle",u.frequency.setValueAtTime(71==e.pitch?2408:2105,r),c.gain.setValueAtTime(0,r);for(var y=0;y<74*d;y++)c.gain.linearRampToValueAtTime(2.5,r+(y+.2)/75),c.gain.linearRampToValueAtTime(.5,r+(y+.9)/75);c.gain.linearRampToValueAtTime(0,r+d),p=d;break;case 73:case 74:var b=73==e.pitch?.05:.35;i.playbackRate.setValueAtTime((e.pitch,.2),r),i.playbackRate.linearRampToValueAtTime(73==e.pitch?.7:.5,r+b),n.gain.value=.2;for(var A=0;A<100*b;A++)n.gain.setValueAtTime(.4,r+A/100),n.gain.setValueAtTime(.9,r+(A+.7)/100);h=b,c.gain.value=0,p=0;break;case 76:case 77:i.playbackRate.value=.1,n.gain.setValueAtTime(1.2,r),n.gain.linearRampToValueAtTime(0,r+.015),h=.015,u.frequency.setValueAtTime(76==e.pitch?800:600,r),c.gain.setValueAtTime(0,r),c.gain.linearRampToValueAtTime(3,r+.005),c.gain.setTargetAtTime(0,r+.005,.02),p=.2;break;case 78:case 79:n.gain.value=0,h=0;var V=78==e.pitch?750:270;u.frequency.setValueAtTime(V,r),u.frequency.linearRampToValueAtTime(V,r+.06),78==e.pitch&&u.frequency.linearRampToValueAtTime(.9*V,r+.18),c.gain.setValueAtTime(0,r),c.gain.linearRampToValueAtTime(1.5,r+.005),c.gain.linearRampToValueAtTime(.5,r+.02),c.gain.linearRampToValueAtTime(3,r+.04),c.gain.linearRampToValueAtTime(2,r+.135),c.gain.linearRampToValueAtTime(0,r+.18),p=.18;break;case 27:i.playbackRate.value=1,n.gain.setValueAtTime(1,r),n.gain.linearRampToValueAtTime(0,r+.002),h=.002,u.frequency.setValueAtTime(1500,r),u.frequency.linearRampToValueAtTime(280,r+.015),u.frequency.linearRampToValueAtTime(0,r+.07),c.gain.setValueAtTime(1.9,r),c.gain.linearRampToValueAtTime(0,r+.07),p=.07;break;case 28:i.playbackRate.value=1,n.gain.setValueAtTime(1.3,r),n.gain.linearRampToValueAtTime(0,r+.01),n.gain.setValueAtTime(1.1,r+.0101),n.gain.linearRampToValueAtTime(0,r+.02),n.gain.setValueAtTime(.9,r+.0201),n.gain.setTargetAtTime(0,r+.0201,.03),h=.2,c.gain.value=0,p=0;break;case 29:case 30:var k=29==e.pitch?.05:.07,I=29==e.pitch?.06:.09,R=29==e.pitch?.07:.11,M=29==e.pitch?.1:.15,N=29==e.pitch?.25:.4,w=29==e.pitch?.1:.06,O=29==e.pitch?.3:.2,x=29==e.pitch?.18:.12;i.playbackRate.setValueAtTime(w,r),i.playbackRate.linearRampToValueAtTime(O,r+k),i.playbackRate.linearRampToValueAtTime(0,r+I),i.playbackRate.linearRampToValueAtTime(O,r+R),i.playbackRate.linearRampToValueAtTime(x,r+M),i.playbackRate.linearRampToValueAtTime(0,r+N),n.gain.setValueAtTime(0,r),n.gain.linearRampToValueAtTime(.4,r+k),n.gain.linearRampToValueAtTime(.1,r+R),n.gain.linearRampToValueAtTime(.3,r+M),n.gain.linearRampToValueAtTime(0,r+N),h=N;var P=29==e.pitch?500:400,D=29==e.pitch?1950:1200,S=29==e.pitch?430:250;u.frequency.setValueAtTime(P,r),u.frequency.linearRampToValueAtTime(D,r+k),u.frequency.linearRampToValueAtTime(0,r+I),u.frequency.linearRampToValueAtTime(D,r+R),u.frequency.linearRampToValueAtTime(S,r+M),u.frequency.linearRampToValueAtTime(0,r+N),c.gain.setValueAtTime(0,r),c.gain.linearRampToValueAtTime(.7,r+k),c.gain.linearRampToValueAtTime(.2,r+R),c.gain.linearRampToValueAtTime(.6,r+M),c.gain.linearRampToValueAtTime(0,r+N),p=N;break;case 31:i.playbackRate.setValueAtTime(.4,r),i.playbackRate.linearRampToValueAtTime(.5,r+.015),n.gain.setValueAtTime(1.2,r),n.gain.setTargetAtTime(0,r,.035),h=.3,u.frequency.setValueAtTime(3140,r),c.gain.setValueAtTime(1.2,r),c.gain.setTargetAtTime(0,r,.012),p=.3;break;case 32:n.gain.value=0,h=0,u.type="square",u.frequency.setValueAtTime(333,r),c.gain.setValueAtTime(0,r),c.gain.linearRampToValueAtTime(4,r+.0016),c.gain.linearRampToValueAtTime(0,r+.0032),p=.0032;break;case 33:case 34:i.playbackRate.setValueAtTime(.17,r),i.playbackRate.linearRampToValueAtTime(.22,r+.01),n.gain.setValueAtTime(1.5,r),n.gain.setTargetAtTime(0,r,.015),h=.3,34==e.pitch?(u.frequency.setValueAtTime(2040,r),c.gain.setValueAtTime(1,r),c.gain.setTargetAtTime(0,r,.12),p=1.1):(c.gain.value=0,p=0);break;case 82:i.playbackRate.value=1,n.gain.setValueAtTime(.5,r),n.gain.linearRampToValueAtTime(1,r+.02),n.gain.linearRampToValueAtTime(0,r+.07),h=.07,c.gain.value=0,p=0;break;case 83:i.playbackRate.value=1,n.gain.setValueAtTime(0,r),n.gain.linearRampToValueAtTime(1.2,r+.015),n.gain.setTargetAtTime(0,r+.015,.06),h=.5,u.type="triangle",u.frequency.setValueAtTime(2709,r),u.frequency.linearRampToValueAtTime(2657,r+.3),c.gain.setValueAtTime(0,r),c.gain.linearRampToValueAtTime(.7,r+.025),c.gain.setTargetAtTime(0,r+.025,.07),p=.5;break;case 84:i.playbackRate.value=1;for(var L=0;L<28;L++)n.gain.setValueAtTime(.1,r+L/24*.45),n.gain.setTargetAtTime(0,r+L/24*.45,.01),u.frequency.setValueAtTime(1380*(1+L/24),r+L/24*.45),c.gain.setValueAtTime(1*(.2+L/24),r+L/24*.45),c.gain.setTargetAtTime(0,r+L/24*.45,27==L?.2:.01);h=.5,p=1.5;break;case 85:i.playbackRate.setValueAtTime(.35,r),n.gain.setValueAtTime(1.3,r),n.gain.setTargetAtTime(0,r,.01),h=.1,u.frequency.setValueAtTime(1730,r),c.gain.setValueAtTime(.5,r),c.gain.setTargetAtTime(0,r,.01),p=.1;break;case 86:case 87:i.playbackRate.setValueAtTime(.02,r),i.playbackRate.linearRampToValueAtTime(.015,r+.5),n.gain.setValueAtTime(0,r),n.gain.linearRampToValueAtTime(2,r+.005),n.gain.setTargetAtTime(0,r+.005,86==e.pitch?.03:.06),h=.5,u.frequency.setValueAtTime(88,r),u.frequency.linearRampToValueAtTime(86,r+.3),c.gain.setValueAtTime(2.5,r),c.gain.setTargetAtTime(0,r,86==e.pitch?.1:.3),p=86==e.pitch?.5:1.5;break;default:i.playbackRate.value=e.pitch/69*2,h=.05,p=0}return this.settings.isSameDrumSoundOverlap||-1==m||(h>m&&(h=m),p>m&&(p=m)),this.stopAudioNode(i,r+h,s),this.stopAudioNode(u,r+p,l),e.drumStopTime=e.startTime+(h>=p?h:p),function(){t.stopAudioNode(i,0,s,!0),t.stopAudioNode(u,0,l,!0)}}function N(e,t,a,i){var n=t-.005,s=t;t<=this.context.currentTime&&(i?(n=this.context.currentTime,s=this.context.currentTime+.005):s=this.context.currentTime);try{i?(e.stop(s),a.gain.cancelScheduledValues(0),a.gain.setValueAtTime(1,n),a.gain.linearRampToValueAtTime(0,s)):e.stop(s)}catch(e){a.gain.cancelScheduledValues(0),i?(a.gain.setValueAtTime(1,n),a.gain.linearRampToValueAtTime(0,s)):a.gain.setValueAtTime(0,s)}}function w(e){(e.note||e.rootTimeout||e.pan||this.trigger.isNoteTrigger)&&this.states.stopFuncs.push(e)}function O(e,t){("note"==e||"rootTimeout"==e||"pan"==e||this.trigger.isNoteTrigger)&&this.states.stopFuncs.some((function(a,i,n){if(a[e]==t)return d.delete(n,i),!0}))}function x(e){var t=-1;if(this.tempoTrack&&this.tempoTrack.length>=1){if(e>=this.tempoTrack[this.tempoTrack.length-1].timing)return this.tempoTrack[this.tempoTrack.length-1].time;for(var a=0,i=this.tempoTrack.length-1;;){t=Math.floor(a+(i-a)/2);var n=this.tempoTrack[t].timing;if(e<n)i=t-1;else{if(!(e>n))break;a=t+1}if(a>i){e<n&&t--;break}}}var s=0,r=0,o=120;if(t>=0){var u=this.tempoTrack[t];s=u.time,r=u.timing,o=u.value}return s+=60/o/this.settings.resolution*(e-r)}function P(e){var t=-1;if(this.tempoTrack&&this.tempoTrack.length>=1){if(e>=this.tempoTrack[this.tempoTrack.length-1].time)return this.tempoTrack[this.tempoTrack.length-1].timing;for(var a=0,i=this.tempoTrack.length-1;;){t=Math.floor(a+(i-a)/2);var n=this.tempoTrack[t].time;if(e<n)i=t-1;else{if(!(e>n))break;a=t+1}if(a>i){e<n&&t--;break}}}var s=0,r=0,o=120;if(t>=0){var u=this.tempoTrack[t];s=u.time,r=u.timing,o=u.value}return r+=(e-s)/(60/o/this.settings.resolution)}function D(e){var t=e.smf,a=4,i={};i.size=y.getInt(t,4,8),i.format=t[9],i.trackcount=y.getInt(t,10,12),i.timemanage=t[12],i.resolution=y.getInt(t,12,14),a+=4+i.size;for(var n=[],s=this.settings.isWebMIDI?17:16,r=0;r<s;r++){var o={};n.push(o),o.indices=[],o.indicesLength=0,o.indicesHead=-1,o.indicesFoot=0,o.indicesCur=0,o.indicesPre=0,o.notes=[]}return e.p=a,e.header=i,e.channels=n,e}function S(e){for(var t=e.smf,a=e.p,i=e.header,n=e.channels,s=[],r=[],o=0,u=0;u<i.trackcount;u++){if(77!=t[a]||84!=t[a+1]||114!=t[a+2]||107!=t[a+3])return"Irregular SMF.";var c=(a+=4)+4+y.getInt(t,a,a+4);a+=4;for(var l=0,m=120,h=0,p=0,T=1,f=void 0;a<c;){if(null!=T){var g=y.variableLengthToInt(t,a,a+5);l+=f=g[0],a+=g[1]}var v=a;switch(t[a]>>4){case 8:case 9:case 10:case 11:case 14:var d=n[15&(T=t[a])];y.chIndicesInsert(this,d,l,a,3),a+=3;break;case 12:case 13:var b=n[15&(T=t[a])];y.chIndicesInsert(this,b,l,a,2),a+=2;break;case 15:switch(t[a]){case 240:case 247:var A=y.variableLengthToInt(t,a+1,a+1+4);if(A[0]>=7&&127==t[a+2]&&127==t[a+3]&&4==t[a+4]&&1==t[a+5])for(var V=0;V<16;V++){var k=n[V];y.chIndicesInsert(this,k,l,a,A[0])}a+=1+A[1]+A[0];break;case 241:a+=2;break;case 242:a+=3;break;case 243:a+=2;break;case 246:case 248:case 250:case 251:case 252:case 254:a+=1;break;case 255:switch(t[a+1]){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 32:break;case 47:l+=(this.settings.isSkipEnding?0:i.resolution)-f;break;case 81:for(var I=0;I<16;I++){var R=n[I];y.chIndicesInsert(this,R,l,a,6)}p+=60/m/i.resolution*(l-h),h=l,m=6e7/(65536*t[a+3]+256*t[a+4]+t[a+5]),s.push({timing:l,time:p,value:m});break;case 84:break;case 88:r.push({timing:l,value:[t[a+3],Math.pow(2,t[a+4])]})}var M=y.variableLengthToInt(t,a+2,a+2+4);a+=2+M[1]+M[0]}break;default:if(null==T)return"Irregular SMF. ("+a+" byte addr)";t[--a]=T,T=null}this.settings.isWebMIDI&&null!=T&&y.chIndicesInsert(this,n[16],l,v,a-v)}!this.settings.isSkipEnding&&o<l&&(o=l);for(var N=0;N<n.length;N++)n[N].indicesCur=n[N].indicesHead,n[N].indicesPre=n[N].indicesHead}return e.p=a,e.tempoTrack=s,e.beatTrack=r,e.songLength=o,e}function L(t){for(var a,i,n,s=this,r=t.smf,o=t.header,u=t.channels,c=t.tempoTrack,l=t.songLength,m=-1,h=-1,p=9007199254740991,T=9007199254740991,f=0,g=0,v=function(t){var c=u[t],l=2,v=0,y=64,b=127,A=100,V=0,k=0,I=s.settings.initReverb,R=0,M=127,N=127,w=0,O=127;a=120,i=0,n=0;for(var x=[],P=c.indicesHead,D=c.indices,S=new Array(128),L=function(){var e=D[P],u=D[P+2],L=D[P+3],W=60/a/o.resolution*(e-i)+n,q=r[u]>>4;switch(q){case 8:case 9:if(9==q&&0!=r[u+2]){var B={start:e,stop:null,startTime:W,stopTime:null,pitch:r[u+1],pitchBend:[{timing:e,time:W,value:v}],pan:[{timing:e,time:W,value:y}],expression:[{timing:e,time:W,value:b*(O/127)}],velocity:r[u+2]/127*(A/127),modulation:[{timing:e,time:W,value:V}],holdBeforeStop:null,reverb:[{timing:e,time:W,value:I}],chorus:[{timing:e,time:W,value:R}],instrument:w,channel:t,nextSameNoteOnInterval:-1,drumStopTime:2},E=S[r[u+1]];E&&(E.nextSameNoteOnInterval=W-E.startTime),S[r[u+1]]=B,x.some((function(t,a){var i=c.notes[t];i.pitch==r[u+1]&&null==i.stop&&(i.stop=e,i.stopTime=W,d.delete(x,a))})),x.push(c.notes.length),c.notes.push(B),e<p&&(p=e,T=W)}else x.some((function(t,a){var i=c.notes[t];if(i.pitch==r[u+1]&&null==i.stop)return k>=s.settings.holdOnValue?null==i.holdBeforeStop&&(i.holdBeforeStop=[{timing:e,time:W,value:k}]):(i.stop=e,i.stopTime=W,d.delete(x,a)),e>f&&(f=e,g=W),!0}));break;case 10:break;case 11:switch(r[u+1]){case 1:V=r[u+2],x.forEach((function(t){c.notes[t].modulation.push({timing:e,time:W,value:V})}));break;case 6:0==M&&0==N&&(l=r[u+2])>24&&(l=24);break;case 7:A=r[u+2];break;case 10:y=r[u+2],x.forEach((function(t){c.notes[t].pan.push({timing:e,time:W,value:y})}));break;case 11:b=r[u+2],x.forEach((function(t){c.notes[t].expression.push({timing:e,time:W,value:b*(O/127)})}));break;case 64:if((k=r[u+2])<s.settings.holdOnValue)for(var C=x.length-1;C>=0;C--){var G=x[C],F=c.notes[G];null==F.stop&&null!=F.holdBeforeStop&&(F.stop=e,F.stopTime=W,d.delete(x,C))}break;case 91:I=r[u+2],x.forEach((function(t){c.notes[t].reverb.push({timing:e,time:W,value:I})}));break;case 93:R=r[u+2],x.forEach((function(t){c.notes[t].chorus.push({timing:e,time:W,value:R})}));break;case 98:r[u+2];break;case 99:r[u+2];break;case 100:M=r[u+2];break;case 101:N=r[u+2];break;case 111:-1==m&&(m=e,h=W)}break;case 12:w=r[u+1];break;case 13:break;case 14:v=(128*r[u+2]+r[u+1]-8192)/8192*l,x.forEach((function(t){c.notes[t].pitchBend.push({timing:e,time:W,value:v})}));break;case 15:switch(r[u]){case 240:case 247:if(127==r[u+1]&&127==r[u+2]&&4==r[u+3]&&1==r[u+4]){var _=r[u+6];_>127&&(_=127),O=_,x.forEach((function(t){c.notes[t].expression.push({timing:e,time:W,value:b*(O/127)})}))}break;case 255:switch(r[u+1]){case 81:n+=60/a/o.resolution*(e-i),i=e,a=6e7/(65536*r[u+3]+256*r[u+4]+r[u+5])}}break;default:return{v:{v:"Error parseSMF. "}}}P=L};-1!=P;){var W=L();if("object"===e(W))return W.v}c.nowNoteOnIdxAry=x,s.debug||delete c.indices},y=0;y<16;y++){var b=v(y);if("object"===e(b))return b.v}for(var A=0;A<16;A++){for(var V=u[A],k=V.nowNoteOnIdxAry,I=function(e){var t=V.notes[k[e]];if(null==t.stop){t.stop=f,t.stopTime=g;["pitchBend","pan","expression","modulation","reverb","chorus"].forEach((function(e){for(var a=t[e],i=a.length-1;i>=1;i--){a[i].timing>f&&d.delete(a,i)}})),d.delete(k,e)}},R=k.length-1;R>=0;R--)I(R);delete V.nowNoteOnIdxAry}this.settings.isSkipEnding&&(l=f),c.push({timing:l,time:60/a/o.resolution*(l-i)+n,value:120});var M=[];if(this.settings.isWebMIDI)for(var N=u[16],w=120,O=0,x=0,P=N.indicesHead,D=N.indices;-1!=P;){var S=D[P],L=D[P+1],W=D[P+2],q=D[P+3],B=60/w/o.resolution*(S-O)+x;switch(r[W]){case 255:switch(r[W+1]){case 81:x+=60/w/o.resolution*(S-O),O=S,w=6e7/(65536*r[W+3]+256*r[W+4]+r[W+5])}}M.push({time:B,tick:S,smfPtr:W,smfPtrLen:L}),P=q}return t.songLength=l,t.cc111Tick=m,t.cc111Time=h,t.firstNoteOnTiming=p,t.firstNoteOnTime=T,t.lastNoteOffTiming=f,t.lastNoteOffTime=g,this.settings.isWebMIDI&&(t.messages=M,t.smfData=new Uint8Array(r)),t}function W(e){if(this.debug){console.log(e);var t=f.now()}var a=new Uint8Array(e);if(77!=a[0]||84!=a[1]||104!=a[2]||100!=a[3])return"Not Sandard MIDI File.";var i={};if(i.smf=a,D.call(this,i),this.debug)var n=f.now();if(S.call(this,i),this.debug)var s=f.now();L.call(this,i);var r={};if(r.header=i.header,r.tempoTrack=i.tempoTrack,r.beatTrack=i.beatTrack,r.channels=i.channels,r.songLength=i.songLength,r.cc111Tick=i.cc111Tick,r.cc111Time=i.cc111Time,r.firstNoteOnTiming=i.firstNoteOnTiming,r.firstNoteOnTime=i.firstNoteOnTime,r.lastNoteOffTiming=i.lastNoteOffTiming,r.lastNoteOffTime=i.lastNoteOffTime,this.settings.isWebMIDI&&(r.messages=i.messages,r.smfData=new Uint8Array(a)),this.debug){var o=f.now();console.log("parseSMF time",o-t),console.log("parseSMF(0/2) time",n-t),console.log("parseSMF(1/2) time",s-n),console.log("parseSMF(2/2) time",o-s),console.log(r)}return r}function q(){var e=this;if(navigator.requestMIDIAccess){var t=this.settings.WebMIDIPortSysEx,a=function(a){var i,n=a.outputs;return e.settings.WebMIDIPortOutputs=n,-1==e.settings.WebMIDIPort?e.settings.WebMIDIPortOutputs.forEach((function(e){i||(i=e)})):i=e.settings.WebMIDIPortOutputs.get(e.settings.WebMIDIPort),e.settings.WebMIDIPortOutput=i,e.settings.WebMIDIPortSysEx=t,i&&(i.open(),e.initStatus()),n};navigator.requestMIDIAccess({sysex:t}).then(a).catch((function e(i){console.log(i),t&&(t=!1,navigator.requestMIDIAccess({sysex:t}).then(a).catch(e))})),window.addEventListener("unload",(function(){for(var t=0;t<16;t++){e.settings.WebMIDIPortOutput.send([176+t,120,0]);for(var a=0;a<128;a++)e.settings.WebMIDIPortOutput.send([128+t,a,0])}}))}}return function(){function e(a){t(this,e),l.call(this,a)}return i(e,[{key:"init",value:function(e){return T.call(this,e)}},{key:"parseSMF",value:function(e){return W.call(this,e)}},{key:"setData",value:function(e){return g.call(this,e)}},{key:"play",value:function(e){return A.call(this,e)}},{key:"pause",value:function(e){return V.call(this,e)}},{key:"stop",value:function(e){return V.call(this,e)}},{key:"initStatus",value:function(e,t){return v.call(this,e,t)}},{key:"setStartTime",value:function(e){this.states.startTime-=e}},{key:"getTime",value:function(e){return x.call(this,e)}},{key:"getTiming",value:function(e){return P.call(this,e)}},{key:"createBaseNote",value:function(e,t,a,i,n){return k.call(this,e,t,a,i,n)}},{key:"createNote",value:function(e){return R.call(this,e)}},{key:"createPercussionNote",value:function(e){return M.call(this,e)}},{key:"stopAudioNode",value:function(e,t,a,i){return N.call(this,e,t,a,i)}},{key:"pushFunc",value:function(e){return w.call(this,e)}},{key:"clearFunc",value:function(e,t){return O.call(this,e,t)}},{key:"startWebMIDI",value:function(){return q.call(this)}},{key:"addEventListener",value:function(e,t){this.events.push({type:e,func:t})}},{key:"removeEventListener",value:function(e,t){for(var a=this.events.length;a>=0;a--)event.type==e&&event.func===t&&this.events.splice(a,1)}},{key:"removeAllEventListener",value:function(e){for(var t=this.events.length;t>=0;t--)event.type==e&&this.events.splice(t,1)}},{key:"fireEvent",value:function(e,t){this.events.forEach((function(a){if(a.type==e)try{a.func(t)}catch(e){console.log(e)}}))}},{key:"setOnSongEndListener",value:function(e){this.onSongEndListener=e}},{key:"onSongEnd",value:function(){if(this.onSongEndListener&&this.onSongEndListener())return;this.settings.loop&&(this.initStatus(!0),this.settings.isCC111&&-1!=this.cc111Time&&this.setStartTime(this.cc111Time),this.play(!0))}},{key:"getChannels",value:function(){return this.channels}},{key:"setChannels",value:function(e){var t=this;e.forEach((function(e,a){t.channels[a]=e}))}},{key:"initChannels",value:function(){for(var e=0;e<16;e++)this.channels[e]=[0,0,1]}},{key:"getMasterVolume",value:function(){return this.settings.masterVolume}},{key:"setMasterVolume",value:function(e){this.settings.masterVolume=e,this.isStarted&&(this.masterGainNode.gain.value=this.settings.masterVolume)}},{key:"isLoop",value:function(){return this.settings.loop}},{key:"setLoop",value:function(e){this.settings.loop=e}},{key:"isWebMIDI",value:function(){return this.settings.isWebMIDI}},{key:"setWebMIDI",value:function(e){this.settings.isWebMIDI=e}},{key:"isCC111",value:function(){return this.settings.isCC111}},{key:"setCC111",value:function(e){this.settings.isCC111=e}},{key:"isReverb",value:function(){return this.settings.isReverb}},{key:"setReverb",value:function(e){this.settings.isReverb=e}},{key:"getReverbVolume",value:function(){return this.settings.reverbVolume}},{key:"setReverbVolume",value:function(e){this.settings.reverbVolume=e}},{key:"isChorus",value:function(){return this.settings.isChorus}},{key:"setChorus",value:function(e){this.settings.isChorus=e}},{key:"getChorusVolume",value:function(){return this.settings.chorusVolume}},{key:"setChorusVolume",value:function(e){this.settings.chorusVolume=e}}]),e}()}();
var PicoAudio=function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var a=0;a<t.length;a++){var i=t[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function i(e,t,i){return t&&a(e.prototype,t),i&&a(e,i),e}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function r(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function u(e,t,a){return u=r()?Reflect.construct:function(e,t,a){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return a&&s(n,a.prototype),n},u.apply(null,arguments)}function o(e){var t="function"==typeof Map?new Map:void 0;return o=function(e){if(null===e||(a=e,-1===Function.toString.call(a).indexOf("[native code]")))return e;var a;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return u(e,arguments,n(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),s(i,e)},o(e)}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function l(e){for(var t in this.debug=!1,this.isStarted=!1,this.isPlayed=!1,this.settings={masterVolume:1,generateVolume:.15,tempo:120,basePitch:440,resolution:480,isWebMIDI:!1,WebMIDIPortOutputs:null,WebMIDIPortOutput:null,WebMIDIPort:-1,WebMIDIPortSysEx:!0,isReverb:!0,reverbVolume:1.5,initReverb:10,isChorus:!0,chorusVolume:.5,isCC111:!0,loop:!1,isSkipBeginning:!1,isSkipEnding:!0,holdOnValue:64,maxPoly:-1,maxPercPoly:-1,isOfflineRendering:!1,isSameDrumSoundOverlap:!1,baseLatency:-1},m(this,e,"debug"),this.settings)m(this.settings,e,t);this.events=[],this.trigger={isNoteTrigger:!0,play:function(){},stop:function(){},noteOn:function(){},noteOff:function(){},songEnd:function(){}},this.states={isPlaying:!1,startTime:0,stopTime:0,stopFuncs:[],webMIDIWaitState:null,webMIDIStopTime:0,playIndices:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],updateBufTime:100,updateBufMaxTime:350,updateIntervalTime:0,latencyLimitTime:0},this.hashedDataList=[],this.hashedMessageList=[],this.playData=null,this.channels=[],this.tempoTrack=[{timing:0,value:120},{timing:0,value:120}],this.cc111Time=-1,this.onSongEndListener=null,this.baseLatency=.01;for(var a=0;a<17;a++)this.channels.push([0,0,1]);e&&e.audioContext&&this.init(e)}function m(e,t,a){t&&null!=t[a]&&e&&null!=e[a]&&(e[a]=t[a])}var h=function(){function e(){t(this,e)}return i(e,null,[{key:"resetSeed",value:function(){this.init=!0,this.x=123456789,this.y=362436069,this.z=521288629,this.w=8867512}},{key:"random",value:function(){this.init||this.resetSeed();var e=this.x^this.x<<11;this.x=this.y,this.y=this.z,this.z=this.w;var t=this.w=this.w^this.w>>>19^e^e>>>8;return t=Math.abs(t)/2147483648%2}}]),e}(),p=function(){function e(){t(this,e)}return i(e,null,[{key:"lerpWave",value:function(e,t){var a=e.getChannelData(0).length,i=t[0].length;if(a==i)for(var n=0;n<2;n++)for(var s=e.getChannelData(n),r=t[n],u=0;u<a;u++)s[u]=r[u];else for(var o=i/a,c=0;c<2;c++)for(var l=e.getChannelData(c),m=t[c],h=0;h<a;h++){var p=h*o,T=Math.trunc(p),f=(T+1)%i,g=p-T,v=m[T]*(1-g)+m[f]*g;l[h]=v}}}]),e}();function T(e){if(!this.isStarted){this.isStarted=!0;var t=e&&e.audioContext,a=e&&e.picoAudio,i=window.AudioContext||window.webkitAudioContext;this.context=t||new i,this.masterGainNode=this.context.createGain(),this.masterGainNode.gain.value=this.settings.masterVolume;var n=this.context.sampleRate,s=n>=48e3?48e3:n;if(a&&a.whitenoise)this.whitenoise=a.whitenoise;else{h.resetSeed();for(var r=1*n,u=1*s,o=[],c=0;c<2;c++){o.push(new Float32Array(u));for(var l=o[c],m=0;m<u;m++){var T=h.random();l[m]=2*T-1}}this.whitenoise=this.context.createBuffer(2,r,n),p.lerpWave(this.whitenoise,o)}if(a&&a.impulseResponse)this.impulseResponse=a.impulseResponse;else{h.resetSeed();for(var f=3.5*n,g=3.5*s,v=[],d=0;d<2;d++){v.push(new Float32Array(g));for(var y=v[d],b=0;b<g;b++){var A=(g-b)/g,V=b/s,k=(V<.03?0:A)*(V>=.03&&V<.031?2*A:A)*(V>=.04&&V<.042?1.5*A:A)*(V>=.05&&V<.054?1.25*A:A)*h.random()*.2*Math.pow(A-.03,4);y[b]=k}}this.impulseResponse=this.context.createBuffer(2,f,this.context.sampleRate),p.lerpWave(this.impulseResponse,v)}this.convolver=this.context.createConvolver(),this.convolver.buffer=this.impulseResponse,this.convolver.normalize=!0,this.convolverGainNode=this.context.createGain(),this.convolverGainNode.gain.value=this.settings.reverbVolume,this.convolver.connect(this.convolverGainNode),this.convolverGainNode.connect(this.masterGainNode),this.masterGainNode.connect(this.context.destination),this.chorusDelayNode=this.context.createDelay(),this.chorusGainNode=this.context.createGain(),this.chorusOscillator=this.context.createOscillator(),this.chorusLfoGainNode=this.context.createGain(),this.chorusDelayNode.delayTime.value=.025,this.chorusLfoGainNode.gain.value=.01,this.chorusOscillator.frequency.value=.05,this.chorusGainNode.gain.value=this.settings.chorusVolume,this.chorusOscillator.connect(this.chorusLfoGainNode),this.chorusLfoGainNode.connect(this.chorusDelayNode.delayTime),this.chorusDelayNode.connect(this.chorusGainNode),this.chorusGainNode.connect(this.masterGainNode),this.masterGainNode.connect(this.context.destination),this.chorusOscillator.start(0),this.baseLatency=this.context.baseLatency||this.baseLatency,-1!=this.settings.baseLatency&&(this.baseLatency=this.settings.baseLatency)}}var f=function(){function e(){t(this,e)}return i(e,null,[{key:"now",value:function(){return null==this._now&&(void 0===window.performance?this._now=function(){return window.Date.now()}:this._now=function(){return window.performance.now()}),this._now()}}]),e}(),g=9007199254740991;function v(e){if(this.debug)var t=f.now();if(this.states.isPlaying&&this.stop(),this.playData=e,this.settings.resolution=e.header.resolution,this.settings.tempo=e.tempo||120,this.tempoTrack=e.tempoTrack,this.cc111Time=e.cc111Time,this.firstNoteOnTiming=e.firstNoteOnTiming,this.lastNoteOffTiming=e.lastNoteOffTiming,this.firstNoteOnTime=e.firstNoteOnTime,this.lastNoteOffTime=e.lastNoteOffTime,this.lastEventTiming=e.lastEventTiming,this.lastEventTime=e.lastEventTime,this.initStatus(),this.debug){var a=f.now();console.log("setData time",a-t)}return this}function d(e,t){if((!this.settings.isWebMIDI||null==this.states.webMIDIWaitState)&&(this.stop(e),this.states={isPlaying:!1,startTime:0,stopTime:0,stopFuncs:[],webMIDIWaitState:null,webMIDIStopTime:this.states.webMIDIStopTime,playIndices:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],updateBufTime:this.states.updateBufTime,updateBufMaxTime:this.states.updateBufMaxTime,updateIntervalTime:this.states.updateIntervalTime,latencyLimitTime:this.states.latencyLimitTime,noteOnAry:[],noteOffAry:[]},this.settings.isWebMIDI&&!t)){if(e)return;if(null==this.settings.WebMIDIPortOutput)return void this.startWebMIDI();if(this.settings.WebMIDIPortSysEx)this.settings.WebMIDIPortOutput.send([240,126,127,9,1,247]);else for(var a=0;a<16;a++)this.settings.WebMIDIPortOutput.send([192+a,0]),this.settings.WebMIDIPortOutput.send([224+a,0,64]),this.settings.WebMIDIPortOutput.send([176+a,100,0]),this.settings.WebMIDIPortOutput.send([176+a,101,0]),this.settings.WebMIDIPortOutput.send([176+a,6,2]),this.settings.WebMIDIPortOutput.send([176+a,100,1]),this.settings.WebMIDIPortOutput.send([176+a,96,0]),this.settings.WebMIDIPortOutput.send([176+a,97,64]),this.settings.WebMIDIPortOutput.send([176+a,7,100]),this.settings.WebMIDIPortOutput.send([176+a,10,64]),this.settings.WebMIDIPortOutput.send([176+a,11,127]),this.settings.WebMIDIPortOutput.send([176+a,98,0]),this.settings.WebMIDIPortOutput.send([176+a,99,0]),this.settings.WebMIDIPortOutput.send([176+a,122,0])}}var y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(l,e);var a,u,o=(a=l,u=r(),function(){var e,t=n(a);if(u){var i=n(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return c(this,e)});function l(){return t(this,l),o.apply(this,arguments)}return i(l,null,[{key:"delete",value:function(e,t){t==e.length-1?e.pop():0==t?e.shift():e.splice(t,1)}}]),l}(o(Array)),b=function(){function e(){t(this,e)}return i(e,null,[{key:"getInt",value:function(e,t,a){for(var i=0,n=t;n<a;n++)i=(i<<8)+e[n];return i}},{key:"variableLengthToInt",value:function(e,t,a){for(var i=t,n=0;i<a-1&&e[i]>=128;)i<t+4&&(n=(n<<7)+(e[i]-128)),i++;return[n=(n<<7)+e[i],++i-t]}},{key:"chIndicesInsert",value:function(e,t,a,i,n){var s=t.indices;if(t.indicesLength>=4&&a<s[t.indicesFoot])for(;-1!=t.indicesCur;){if(a<s[t.indicesCur]){t.indicesCur==t.indicesHead?t.indicesHead=t.indicesLength:s[t.indicesPre+3]=t.indicesLength,s[t.indicesLength]=a,s[t.indicesLength+1]=n,s[t.indicesLength+2]=i,s[t.indicesLength+3]=t.indicesCur,t.indicesPre=t.indicesLength,t.indicesLength+=4;break}t.indicesPre=t.indicesCur,t.indicesCur=s[t.indicesCur+3]}else t.indicesLength>=4?s[t.indicesFoot+3]=t.indicesLength:t.indicesHead=0,t.indicesFoot=t.indicesLength,s[t.indicesLength]=a,s[t.indicesLength+1]=n,s[t.indicesLength+2]=i,s[t.indicesLength+3]=-1,t.indicesLength+=4}}]),e}(),A=function(){function e(){t(this,e)}return i(e,null,[{key:"init",value:function(e,t){this.updatePreTime=f.now(),this.pPreTime=f.now(),this.cPreTime=1e3*e.context.currentTime,this.pTimeSum=0,this.cTimeSum=0,this.cnt=0,this.initCurrentTime=t}},{key:"update",value:function(e){var t=this,a=e.context,i=e.settings,n=e.states,s=e.baseLatency,r=f.now(),u=this.updatePreTime,o=this.pPreTime,c=this.cPreTime,l=this.pTimeSum,m=this.cTimeSum,h=this.cnt,p=r-u,T=r,g=1e3*a.currentTime;l+=T-o,m+=g-c,o=T,c=g;var v=l-m;if(n.latencyTime=v,v>=100?(n.latencyLimitTime+=v,m+=100):v<=-100?m=l:n.latencyLimitTime>0&&(n.latencyLimitTime-=.003*p,n.latencyLimitTime<0&&(n.latencyLimitTime=0)),n.updateIntervalTime=p,n.updateBufTime<p?n.updateBufTime=p:(n.updateBufMaxTime>350&&(n.updateBufMaxTime-=.002*n.updateBufMaxTime),n.updateBufTime<20&&(n.updateBufTime+=5e-4*n.updateBufTime),n.updateBufMaxTime>=10&&n.updateBufMaxTime<340&&(n.updateBufMaxTime+=.002*n.updateBufMaxTime)),n.updateBufTime>n.updateBufMaxTime){if(p>=900&&n.latencyLimitTime<=150)n.updateBufMaxTime+=p;else{var d=p-n.updateBufMaxTime;n.updateBufTime=n.updateBufMaxTime,n.updateBufMaxTime<10?(n.updateBufTime=n.updateBufMaxTime,n.updateBufMaxTime*=1.25):n.updateBufMaxTime+=d/2}n.updateBufMaxTime>1100&&(n.updateBufMaxTime=1100)}n.latencyLimitTime>150&&(m=l,n.latencyLimitTime-=5,n.latencyLimitTime>1e3&&(n.latencyLimitTime=1e3),n.updateBufMaxTime=1,n.updateBufTime=1,p=1);for(var y=0;y<16;y++){for(var A=e.playData.channels[y].notes,V=n.playIndices[y],k=function(){var r=A[V],u=0==h?t.initCurrentTime-n.startTime:a.currentTime-n.startTime;if(u>=r.stopTime)return"continue";if(0==h&&u>r.startTime+s)return"continue";if(u<r.startTime-n.updateBufTime/1e3)return"break";if(!i.isWebMIDI){if(n.stopFuncs.length>=350&&n.updateBufTime<1e3&&(n.updateBufTime=12,n.updateBufMaxTime=n.updateBufTime),-1!=i.maxPoly||-1!=i.maxPercPoly){var o=0,c=0;if(n.stopFuncs.forEach((function(e){e.note&&(9!=e.note.channel?r.start>=e.note.start&&r.start<e.note.stop&&o++:r.start==e.note.start&&c++)})),9!=r.channel&&o>=i.maxPoly||9==r.channel&&c>=i.maxPercPoly)return"continue"}var l=9!=r.channel?e.createNote(r):e.createPercussionNote(r);if(!l)return"continue";e.pushFunc({note:r,stopFunc:l})}n.noteOnAry.push(r)};V<A.length;V++){var I=k();if("continue"!==I&&"break"===I)break}n.playIndices[y]=V}if(this.checkNoteOn(e),this.checkNoteOff(e),i.isWebMIDI&&null!=i.WebMIDIPortOutput){for(var R=e.playData.messages,M=e.playData.smfData,N=n.playIndices[16];N<R.length;N++){var x=R[N],O=a.currentTime-n.startTime;if(!(O>x.time+1)){if(O<x.time-1)break;var P=x.smfPtrLen,w=x.smfPtr,D=x.time,S=M[w];if(255!=S)try{if(240==S||247==S){if(i.WebMIDIPortSysEx){var L=b.variableLengthToInt(M,w+1,w+1+4),E=w+1+L[1],W=E+L[0],q=new Uint8Array(1+L[0]);q[0]=S;for(var B=W-E,C=0;C<B;C++)q[C+1]=M[E+C];i.WebMIDIPortOutput.send(q,1e3*(D-a.currentTime+f.now()/1e3+n.startTime))}}else{for(var G=[],F=0;F<P;F++)G.push(M[w+F]);i.WebMIDIPortOutput.send(G,1e3*(D-a.currentTime+f.now()/1e3+n.startTime))}}catch(e){console.log(e,w,P,D,S)}}}n.playIndices[16]=N}h++,this.updatePreTime=r,this.pPreTime=o,this.cPreTime=c,this.pTimeSum=l,this.cTimeSum=m,this.cnt=h}},{key:"checkNoteOn",value:function(e){for(var t=e.context,a=e.trigger,i=e.states,n=e.states.noteOnAry,s=e.states.noteOffAry,r=0;r<n.length;r++){var u=n[r],o=t.currentTime-i.startTime;u.startTime-o<=0&&(y.delete(n,r),s.push(u),a.isNoteTrigger&&a.noteOn(u),e.fireEvent("noteOn",u),r--)}}},{key:"checkNoteOff",value:function(e){for(var t=e.context,a=e.trigger,i=e.states,n=e.states.noteOffAry,s=0;s<n.length;s++){var r=n[s],u=t.currentTime-i.startTime;(9!=r.channel&&r.stopTime-u<=0||9==r.channel&&r.drumStopTime-u<=0)&&(y.delete(n,s),e.clearFunc("note",r),a.isNoteTrigger&&a.noteOff(r),e.fireEvent("noteOff",r),s--)}}}]),e}();function V(e){var t=this,a=this.context,i=this.settings,n=this.trigger,s=this.states;if(a.resume&&a.resume(),!s.isPlaying){if(i.isWebMIDI&&!e){if("completed"!=s.webMIDIWaitState){if("waiting"!=s.webMIDIWaitState){s.webMIDIWaitState="waiting";var r=1e3-1e3*(a.currentTime-s.webMIDIStopTime);0==s.webMIDIStopTime&&(r=1e3),setTimeout((function(){s.webMIDIWaitState="completed",s.isPlaying=!1,t.play()}),r)}return}s.webMIDIWaitState=null}var u,o=a.currentTime;if(this.isPlayed=!0,s.isPlaying=!0,s.startTime=s.startTime||s.stopTime?s.startTime+o-s.stopTime:o,s.stopFuncs=[],i.isSkipBeginning){var c=this.firstNoteOnTime;-s.startTime+o<c&&this.setStartTime(c+s.startTime-o)}var l=1e3*(this.getTime(g)-a.currentTime+s.startTime);u=setTimeout((function e(){t.clearFunc("rootTimeout",u),t.getTime(g)-a.currentTime+s.startTime<=0?(n.songEnd(),t.onSongEnd(),t.fireEvent("songEnd")):(u=setTimeout(e,1),t.pushFunc({rootTimeout:u,stopFunc:function(){clearTimeout(u)}}))}),l),this.pushFunc({rootTimeout:u,stopFunc:function(){clearTimeout(u)}}),n.play(),this.fireEvent("play"),A.init(this,o);var m=setInterval((function(){A.update(t)}),1);this.pushFunc({rootTimeout:m,stopFunc:function(){clearInterval(m)}})}}function k(e){var t=this,a=this.states;if(0!=a.isPlaying){if(a.isPlaying=!1,a.stopTime=this.context.currentTime,a.stopFuncs.forEach((function(e){e.stopFunc()})),a.stopFuncs=[],a.playIndices.forEach((function(e,t,a){a[t]=0})),a.noteOnAry=[],a.noteOffAry=[],this.settings.isWebMIDI){if(e)return;if(null==this.settings.WebMIDIPortOutput)return;a.webMIDIStopTime=this.context.currentTime,setTimeout((function(){for(var e=0;e<16;e++)t.settings.WebMIDIPortOutput.send([176+e,120,0])}),1e3)}this.trigger.stop(),this.fireEvent("pause"),this.fireEvent("stop")}}function I(e,t,a,i,n){var s=this,r=this.settings,u=this.context,o=this.states.startTime,c=this.baseLatency,l=i?0:e.channel||0,m=e.velocity*Number(i?1:null!=this.channels[l][2]?this.channels[l][2]:1)*r.generateVolume,h=!0;if(m<=0)return{isGainValueZero:!0};var p=m*((e.expression?e.expression[0].value:100)/127),T=u.createGain();if(T.gain.value=p,a?e.expression&&e.expression.forEach((function(e){var t=m*(e.value/127);t>0&&(h=!1);var a=Math.max(0,e.time+o+c);T.gain.setValueAtTime(t,a)})):p>0&&(h=!1),h)return{isGainValueZero:!0};var f=e.startTime+o+c,g=e.stopTime+o+c,v=r.basePitch*Math.pow(Math.pow(2,1/12),(e.pitch||69)-69),d=t?u.createBufferSource():u.createOscillator(),y=u.createStereoPanner?u.createStereoPanner():u.createPanner?u.createPanner():{pan:{setValueAtTime:function(){}}},b=u.createGain(),A=u.createGain();t?(d.loop=!0,d.buffer=this.whitenoise):(d.type=e.type||"sine",d.detune.value=0,d.frequency.value=v,e.pitchBend&&e.pitchBend.forEach((function(t){var a=Math.max(0,t.time+o+c);d.frequency.setValueAtTime(r.basePitch*Math.pow(Math.pow(2,1/12),e.pitch-69+t.value),a)})));var V,k,I=e.pan&&64!=e.pan[0].value?e.pan[0].value/127*2-1:0;if(function(e,t,a){if(e.createStereoPanner)a>1&&(a=1),t.pan.value=a;else if(e.createPanner){var i=R(a);t.panningModel="equalpower",t.setPosition(i.x,i.y,i.z)}}(u,y,I),u.createStereoPanner||u.createPanner){var M=!0;if(u.createStereoPanner)e.pan&&e.pan.forEach((function(e){if(M)M=!1;else{var t=Math.min(1,64==e.value?0:e.value/127*2-1),a=Math.max(0,e.time+o+c);y.pan.setValueAtTime(t,a)}}));else if(u.createPanner)if(y.positionX){var N=!0;e.pan&&e.pan.forEach((function(e){if(N)N=!1;else{var t=R(64==e.value?0:e.value/127*2-1),a=Math.max(0,e.time+o+c);y.positionX.setValueAtTime(t.x,a),y.positionY.setValueAtTime(t.y,a),y.positionZ.setValueAtTime(t.z,a)}}))}else e.pan&&e.pan.forEach((function(e){if(M)M=!1;else{var t=setTimeout((function(){s.clearFunc("pan",t);var a=R(Math.min(1,64==e.value?0:e.value/127*2-1));y.setPosition(a.x,a.y,a.z)}),1e3*(e.time+o+c-u.currentTime));s.pushFunc({pan:t,stopFunc:function(){clearTimeout(t)}})}}));d.connect(y),y.connect(T)}else d.connect(T);if(T.connect(b),b.connect(A),A.connect(this.masterGainNode),this.masterGainNode.connect(u.destination),!t&&e.modulation&&(e.modulation.length>=2||e.modulation[0].value>0)){V=u.createOscillator(),k=u.createGain();var x=!0;e.modulation&&e.modulation.forEach((function(e){if(x)x=!1;else{var t=Math.min(1,e.value/127),a=Math.max(0,e.time+o+c);k.gain.setValueAtTime(10*v/440*t,a)}}));var O=Math.min(1,e.modulation?e.modulation[0].value/127:0);k.gain.value=10*v/440*O,V.frequency.value=6,V.connect(k),k.connect(d.frequency)}if(this.settings.isReverb&&e.reverb&&(e.reverb.length>=2||e.reverb[0].value>0)){var P=this.convolver,w=u.createGain(),D=!0;e.reverb&&e.reverb.forEach((function(e){if(D)D=!1;else{var t=Math.min(1,e.value/127),a=Math.max(0,e.time+o+c);w.gain.setValueAtTime(t,a)}}));var S=Math.min(1,e.reverb?e.reverb[0].value/127:0);w.gain.value=S,b.connect(A),A.connect(w),w.connect(P)}if(this.settings.isChorus&&e.chorus&&(e.chorus.length>=2||e.chorus[0].value>0)){var L=this.chorusDelayNode,E=u.createGain(),W=!0;e.chorus&&e.chorus.forEach((function(e){if(W)W=!1;else{var t=Math.min(1,e.value/127),a=Math.max(0,e.time+o+c);E.gain.setValueAtTime(t,a)}}));var q=Math.min(1,e.chorus?e.chorus[0].value/127:0);E.gain.value=q,b.connect(A),A.connect(E),E.connect(L)}return V&&(V.start(f),this.stopAudioNode(V,g,k)),d.start(f),t||i||n||this.stopAudioNode(d,g,A),{start:f,stop:g,pitch:v,channel:l,velocity:m,oscillator:d,panNode:y,gainNode:b,stopGainNode:A,isGainValueZero:!1}}function R(e){e>1&&(e=1);var t={},a=90*e;return t.x=Math.sin(a*(Math.PI/180)),t.y=0,t.z=-Math.cos(a*(Math.PI/180)),t}function M(e){var t=this,a=this.createBaseNote(e,!1,!0,!1,!0);if(a.isGainValueZero)return null;var i,n=a.oscillator,s=a.gainNode,r=a.stopGainNode,u=!1,o=!1;switch(1e3*this.channels[a.channel][0]||e.instrument){case 1e3:case 6:case 15:case 24:case 26:case 46:case 50:case 51:case 52:case 53:case 54:case 82:case 85:case 86:n.type="sine",s.gain.value*=1.5;break;case 2e3:case 4:case 12:case 13:case 16:case 19:case 20:case 32:case 34:case 45:case 48:case 49:case 55:case 56:case 57:case 61:case 62:case 63:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 84:n.type="square",s.gain.value*=.8;break;case 3e3:case 0:case 1:case 2:case 3:case 7:case 17:case 18:case 21:case 22:case 23:case 27:case 28:case 29:case 30:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 47:case 59:case 64:case 65:case 66:case 67:case 68:case 69:case 70:case 87:n.type="sawtooth";break;case 4e3:case 8:case 9:case 10:case 11:case 14:case 25:case 31:case 33:case 35:case 58:case 60:case 83:case 88:case 89:case 90:case 91:case 92:case 93:case 94:case 95:n.type="triangle",s.gain.value*=1.5;break;default:n.type="square"}switch(("sine"==n.type||"triangle"==n.type)&&!u&&a.stop-a.start>.01&&(o=!0),this.channels[a.channel][1]/10||e.instrument){case.2:case 12:case 13:case 45:case 55:u=!0,s.gain.value*=1.1,s.gain.setValueAtTime(s.gain.value,a.start),s.gain.linearRampToValueAtTime(0,a.start+.2),this.stopAudioNode(n,a.start+.2,r);break;case.3:case 0:case 1:case 2:case 3:case 6:case 9:case 11:case 14:case 15:case 32:case 36:case 37:case 46:case 47:s.gain.value*=1.1;var c=(128-e.pitch)/128;s.gain.setValueAtTime(s.gain.value,a.start),s.gain.linearRampToValueAtTime(.85*s.gain.value,a.start+c*c/8),s.gain.linearRampToValueAtTime(.8*s.gain.value,a.start+c*c/4),s.gain.setTargetAtTime(0,a.start+c*c/4,5*c*c),this.stopAudioNode(n,a.stop,r,o);break;case.4:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 34:s.gain.value*=1.1,s.gain.setValueAtTime(s.gain.value,a.start),s.gain.linearRampToValueAtTime(0,a.start+1+4*a.velocity),this.stopAudioNode(n,a.stop,r,o);break;case.5:case 4:case 5:case 7:case 8:case 10:case 33:case 35:s.gain.value*=1,s.gain.setValueAtTime(s.gain.value,a.start),s.gain.linearRampToValueAtTime(.95*s.gain.value,a.start+.1),s.gain.setValueAtTime(.95*s.gain.value,a.start+.1),s.gain.linearRampToValueAtTime(0,a.start+2+10*a.velocity),this.stopAudioNode(n,a.stop,r,o);break;case 119:if(s.gain.value=0,this.stopAudioNode(n,a.stop,r,o),(i=this.createBaseNote(e,!0,!0)).isGainValueZero)break;i.oscillator.playbackRate.setValueAtTime((e.pitch+1)/128,a.start),i.gainNode.gain.setValueAtTime(0,a.start),i.gainNode.gain.linearRampToValueAtTime(1.3,a.start+2),this.stopAudioNode(i.oscillator,a.stop,i.stopGainNode);break;default:s.gain.value*=1.1,s.gain.setValueAtTime(s.gain.value,a.start),this.stopAudioNode(n,a.stop,r,o)}return function(){t.stopAudioNode(n,0,r,!0),i&&i.oscillator&&t.stopAudioNode(i.oscillator,0,i.stopGainNode,!0)}}function N(e){var t=this,a=this.createBaseNote(e,!0,!1);if(a.isGainValueZero)return null;var i=a.oscillator,n=a.gainNode,s=a.stopGainNode,r=a.start,u=this.createBaseNote(e,!1,!1,!0),o=u.oscillator,c=u.gainNode,l=u.stopGainNode,m=e.nextSameNoteOnInterval;r<this.context.currentTime&&(r=this.context.currentTime);var h=0,p=0;switch(e.pitch){case 35:case 36:n.gain.value=.6,i.playbackRate.value=.02,h=.07,c.gain.value=1.1,o.frequency.setValueAtTime(120,r),o.frequency.linearRampToValueAtTime(50,r+.07),p=.07;break;case 38:case 40:i.playbackRate.value=.7,h=.05,c.gain.setValueAtTime(.8,r),c.gain.linearRampToValueAtTime(0,r+.05),o.frequency.setValueAtTime(300,r),o.frequency.linearRampToValueAtTime(200,r+.05),p=.05;break;case 41:case 43:case 45:case 47:case 48:case 50:i.playbackRate.value=.01,h=.1,o.type="square",c.gain.setValueAtTime(1,r),c.gain.linearRampToValueAtTime(.01,r+.1),o.frequency.setValueAtTime(150+20*(e.pitch-40),r),o.frequency.linearRampToValueAtTime(50+20*(e.pitch-40),r+.1),p=.1;break;case 42:case 44:i.playbackRate.value=1.5,h=.02,p=0;break;case 46:i.playbackRate.value=1.5,h=.3,n.gain.setValueAtTime(.9,r),n.gain.linearRampToValueAtTime(0,r+.3),p=0;break;case 49:case 52:case 53:case 55:case 57:i.playbackRate.value=1.2,h=.5,n.gain.setValueAtTime(1,r),n.gain.linearRampToValueAtTime(0,r+.5),p=0;break;case 51:i.playbackRate.value=1.1,h=.4,n.gain.setValueAtTime(.8,r),n.gain.linearRampToValueAtTime(0,r+.4),p=0;break;case 59:i.playbackRate.value=1.8,h=.3,n.gain.setValueAtTime(.5,r),n.gain.linearRampToValueAtTime(0,r+.3),p=0;break;case 60:case 61:i.playbackRate.value=.03,h=.03,c.gain.setValueAtTime(.8,r),c.gain.linearRampToValueAtTime(0,r+.1),o.frequency.setValueAtTime(400-40*(e.pitch-60),r),o.frequency.linearRampToValueAtTime(450-40*(e.pitch-60),r+.1),p=.1;break;case 62:i.playbackRate.value=.03,h=.03,c.gain.setValueAtTime(1,r),c.gain.linearRampToValueAtTime(0,r+.03),o.frequency.setValueAtTime(200,r),o.frequency.linearRampToValueAtTime(250,r+.03),p=.03;break;case 63:case 64:i.playbackRate.value=.03,h=.03,c.gain.setValueAtTime(1,r),c.gain.linearRampToValueAtTime(0,r+.1),o.frequency.setValueAtTime(200-30*(e.pitch-63),r),o.frequency.linearRampToValueAtTime(250-30*(e.pitch-63),r+.1),p=.1;break;case 56:case 75:i.playbackRate.value=.01,h=.1,c.gain.setValueAtTime(1,r),c.gain.linearRampToValueAtTime(0,r+.1),o.frequency.setValueAtTime(1e3+48*(e.pitch-56),r),p=.1;break;case 80:i.playbackRate.value=5,n.gain.setValueAtTime(.5,r),n.gain.linearRampToValueAtTime(0,r+.2),h=.05,o.type="triangle",c.gain.setValueAtTime(.7,r),c.gain.linearRampToValueAtTime(0,r+.2),o.frequency.setValueAtTime(6e3,r),p=.05;break;case 81:i.playbackRate.value=5,n.gain.setValueAtTime(.9,r),n.gain.linearRampToValueAtTime(0,r+.5),h=.5,o.type="triangle",c.gain.setValueAtTime(.8,r),c.gain.linearRampToValueAtTime(0,r+.3),o.frequency.setValueAtTime(6e3,r),p=.3;break;case 37:i.playbackRate.value=.26,n.gain.setValueAtTime(1.5,r),n.gain.linearRampToValueAtTime(0,r+.041),h=.041,o.frequency.setValueAtTime(330,r),o.frequency.linearRampToValueAtTime(120,r+.02),c.gain.setValueAtTime(1,r),c.gain.linearRampToValueAtTime(0,r+.02),p=.02;break;case 39:i.playbackRate.value=.5,n.gain.setValueAtTime(1.3,r),n.gain.linearRampToValueAtTime(0,r+.01),n.gain.setValueAtTime(1.3,r+.0101),n.gain.linearRampToValueAtTime(0,r+.02),n.gain.setValueAtTime(1.3,r+.0201),n.gain.linearRampToValueAtTime(0,r+.09),h=.09,o.type="triangle",o.frequency.setValueAtTime(180,r),c.gain.setValueAtTime(.8,r),c.gain.linearRampToValueAtTime(0,r+.01),c.gain.setValueAtTime(.8,r+.0101),c.gain.linearRampToValueAtTime(0,r+.02),c.gain.setValueAtTime(.8,r+.0201),c.gain.linearRampToValueAtTime(0,r+.03),p=.11;break;case 54:i.playbackRate.setValueAtTime(1,r);var T=54==e.pitch?1:.4,f=54==e.pitch?.01:0;n.gain.setValueAtTime(1*T/2,r),n.gain.linearRampToValueAtTime(1*T,r+f),n.gain.setTargetAtTime(0,r+f,.05),h=.3,o.frequency.setValueAtTime(54==e.pitch?6e3:495,r),T=54==e.pitch?1:2,c.gain.setValueAtTime(1*T/2,r),c.gain.linearRampToValueAtTime(1*T,r+f),c.gain.setTargetAtTime(0,r+f,.05),p=.3;break;case 58:i.playbackRate.setValueAtTime(.6,r),i.playbackRate.linearRampToValueAtTime(1,r+.8);var g=40;n.gain.setValueAtTime(1.5,r),c.gain.setValueAtTime(.5,r);for(var v=0;v<g;v++)n.gain.linearRampToValueAtTime(.1*(g-v)/g,r+v/g*.8),n.gain.linearRampToValueAtTime(1.5*(g-(v+1))/g,r+(v+.99)/g*.8),c.gain.linearRampToValueAtTime(.025*(g-v)/g,r+v/g*.8),c.gain.linearRampToValueAtTime(.25*(g-(v+1))/g,r+(v+.99)/g*.8);n.gain.linearRampToValueAtTime(0,r+.8),c.gain.linearRampToValueAtTime(0,r+.8),h=.8,o.type="triangle",o.frequency.setValueAtTime(1e3,r),p=.8;break;case 65:case 66:var d=65==e.pitch?.22:.25;i.playbackRate.setValueAtTime(65==e.pitch?.25:.22,r),i.playbackRate.linearRampToValueAtTime(65==e.pitch?.2:.18,r+d),n.gain.setValueAtTime(1.3,r),n.gain.linearRampToValueAtTime(.2,r+d/3.5),n.gain.linearRampToValueAtTime(0,r+d),h=d,o.type="triangle",o.frequency.setValueAtTime(65==e.pitch?203.3:145.52,r),o.frequency.linearRampToValueAtTime(65==e.pitch?190:136,r+.1),c.gain.setValueAtTime(3.2,r),c.gain.setTargetAtTime(0,r,.08),p=1;break;case 67:case 68:i.playbackRate.value=1,n.gain.setValueAtTime(.5,r),n.gain.linearRampToValueAtTime(.1,r+.02),n.gain.linearRampToValueAtTime(0,r+.08),h=.08,o.type="triangle",o.frequency.setValueAtTime(67==e.pitch?1430:1055,r),c.gain.setValueAtTime(2,r),c.gain.setTargetAtTime(0,r,.06),p=.75;break;case 69:i.playbackRate.value=1,n.gain.setValueAtTime(.3,r),n.gain.linearRampToValueAtTime(.8,r+.03),n.gain.linearRampToValueAtTime(0,r+.08),h=.08,c.gain.value=0,p=0;break;case 70:i.playbackRate.value=1,n.gain.setValueAtTime(1.2,r),n.gain.linearRampToValueAtTime(0,r+.06),h=.06,c.gain.value=0,p=0;break;case 71:case 72:n.gain.value=0,h=0;var y=71==e.pitch?.07:.4;o.type="triangle",o.frequency.setValueAtTime(71==e.pitch?2408:2105,r),c.gain.setValueAtTime(0,r);for(var b=0;b<74*y;b++)c.gain.linearRampToValueAtTime(2.5,r+(b+.2)/75),c.gain.linearRampToValueAtTime(.5,r+(b+.9)/75);c.gain.linearRampToValueAtTime(0,r+y),p=y;break;case 73:case 74:var A=73==e.pitch?.05:.35;i.playbackRate.setValueAtTime((e.pitch,.2),r),i.playbackRate.linearRampToValueAtTime(73==e.pitch?.7:.5,r+A),n.gain.value=.2;for(var V=0;V<100*A;V++)n.gain.setValueAtTime(.4,r+V/100),n.gain.setValueAtTime(.9,r+(V+.7)/100);h=A,c.gain.value=0,p=0;break;case 76:case 77:i.playbackRate.value=.1,n.gain.setValueAtTime(1.2,r),n.gain.linearRampToValueAtTime(0,r+.015),h=.015,o.frequency.setValueAtTime(76==e.pitch?800:600,r),c.gain.setValueAtTime(0,r),c.gain.linearRampToValueAtTime(3,r+.005),c.gain.setTargetAtTime(0,r+.005,.02),p=.2;break;case 78:case 79:n.gain.value=0,h=0;var k=.18,I=78==e.pitch?750:270;o.frequency.setValueAtTime(I,r),o.frequency.linearRampToValueAtTime(I,r+.06),78==e.pitch&&o.frequency.linearRampToValueAtTime(.9*I,r+k),c.gain.setValueAtTime(0,r),c.gain.linearRampToValueAtTime(1.5,r+.005),c.gain.linearRampToValueAtTime(.5,r+.02),c.gain.linearRampToValueAtTime(3,r+.04),c.gain.linearRampToValueAtTime(2,r+.135),c.gain.linearRampToValueAtTime(0,r+k),p=k;break;case 27:i.playbackRate.value=1,n.gain.setValueAtTime(1,r),n.gain.linearRampToValueAtTime(0,r+.002),h=.002,o.frequency.setValueAtTime(1500,r),o.frequency.linearRampToValueAtTime(280,r+.015),o.frequency.linearRampToValueAtTime(0,r+.07),c.gain.setValueAtTime(1.9,r),c.gain.linearRampToValueAtTime(0,r+.07),p=.07;break;case 28:i.playbackRate.value=1,n.gain.setValueAtTime(1.3,r),n.gain.linearRampToValueAtTime(0,r+.01),n.gain.setValueAtTime(1.1,r+.0101),n.gain.linearRampToValueAtTime(0,r+.02),n.gain.setValueAtTime(.9,r+.0201),n.gain.setTargetAtTime(0,r+.0201,.03),h=.2,c.gain.value=0,p=0;break;case 29:case 30:var R=29==e.pitch?.05:.07,M=29==e.pitch?.06:.09,N=29==e.pitch?.07:.11,x=29==e.pitch?.1:.15,O=29==e.pitch?.25:.4,P=29==e.pitch?.1:.06,w=29==e.pitch?.3:.2,D=29==e.pitch?.18:.12;i.playbackRate.setValueAtTime(P,r),i.playbackRate.linearRampToValueAtTime(w,r+R),i.playbackRate.linearRampToValueAtTime(0,r+M),i.playbackRate.linearRampToValueAtTime(w,r+N),i.playbackRate.linearRampToValueAtTime(D,r+x),i.playbackRate.linearRampToValueAtTime(0,r+O),n.gain.setValueAtTime(0,r),n.gain.linearRampToValueAtTime(.4,r+R),n.gain.linearRampToValueAtTime(.1,r+N),n.gain.linearRampToValueAtTime(.3,r+x),n.gain.linearRampToValueAtTime(0,r+O),h=O;var S=29==e.pitch?500:400,L=29==e.pitch?1950:1200,E=29==e.pitch?430:250;o.frequency.setValueAtTime(S,r),o.frequency.linearRampToValueAtTime(L,r+R),o.frequency.linearRampToValueAtTime(0,r+M),o.frequency.linearRampToValueAtTime(L,r+N),o.frequency.linearRampToValueAtTime(E,r+x),o.frequency.linearRampToValueAtTime(0,r+O),c.gain.setValueAtTime(0,r),c.gain.linearRampToValueAtTime(.7,r+R),c.gain.linearRampToValueAtTime(.2,r+N),c.gain.linearRampToValueAtTime(.6,r+x),c.gain.linearRampToValueAtTime(0,r+O),p=O;break;case 31:i.playbackRate.setValueAtTime(.4,r),i.playbackRate.linearRampToValueAtTime(.5,r+.015),n.gain.setValueAtTime(1.2,r),n.gain.setTargetAtTime(0,r,.035),h=.3,o.frequency.setValueAtTime(3140,r),c.gain.setValueAtTime(1.2,r),c.gain.setTargetAtTime(0,r,.012),p=.3;break;case 32:n.gain.value=0,h=0,o.type="square",o.frequency.setValueAtTime(333,r),c.gain.setValueAtTime(0,r),c.gain.linearRampToValueAtTime(4,r+.0016),c.gain.linearRampToValueAtTime(0,r+.0032),p=.0032;break;case 33:case 34:i.playbackRate.setValueAtTime(.17,r),i.playbackRate.linearRampToValueAtTime(.22,r+.01),n.gain.setValueAtTime(1.5,r),n.gain.setTargetAtTime(0,r,.015),h=.3,34==e.pitch?(o.frequency.setValueAtTime(2040,r),c.gain.setValueAtTime(1,r),c.gain.setTargetAtTime(0,r,.12),p=1.1):(c.gain.value=0,p=0);break;case 82:i.playbackRate.value=1,n.gain.setValueAtTime(.5,r),n.gain.linearRampToValueAtTime(1,r+.02),n.gain.linearRampToValueAtTime(0,r+.07),h=.07,c.gain.value=0,p=0;break;case 83:i.playbackRate.value=1,n.gain.setValueAtTime(0,r),n.gain.linearRampToValueAtTime(1.2,r+.015),n.gain.setTargetAtTime(0,r+.015,.06),h=.5,o.type="triangle",o.frequency.setValueAtTime(2709,r),o.frequency.linearRampToValueAtTime(2657,r+.3),c.gain.setValueAtTime(0,r),c.gain.linearRampToValueAtTime(.7,r+.025),c.gain.setTargetAtTime(0,r+.025,.07),p=.5;break;case 84:i.playbackRate.value=1;for(var W=0;W<28;W++)n.gain.setValueAtTime(.1,r+W/24*.45),n.gain.setTargetAtTime(0,r+W/24*.45,.01),o.frequency.setValueAtTime(1380*(1+W/24),r+W/24*.45),c.gain.setValueAtTime(1*(.2+W/24),r+W/24*.45),c.gain.setTargetAtTime(0,r+W/24*.45,27==W?.2:.01);h=.5,p=1.5;break;case 85:i.playbackRate.setValueAtTime(.35,r),n.gain.setValueAtTime(1.3,r),n.gain.setTargetAtTime(0,r,.01),h=.1,o.frequency.setValueAtTime(1730,r),c.gain.setValueAtTime(.5,r),c.gain.setTargetAtTime(0,r,.01),p=.1;break;case 86:case 87:i.playbackRate.setValueAtTime(.02,r),i.playbackRate.linearRampToValueAtTime(.015,r+.5),n.gain.setValueAtTime(0,r),n.gain.linearRampToValueAtTime(2,r+.005),n.gain.setTargetAtTime(0,r+.005,86==e.pitch?.03:.06),h=.5,o.frequency.setValueAtTime(88,r),o.frequency.linearRampToValueAtTime(86,r+.3),c.gain.setValueAtTime(2.5,r),c.gain.setTargetAtTime(0,r,86==e.pitch?.1:.3),p=86==e.pitch?.5:1.5;break;default:i.playbackRate.value=e.pitch/69*2,h=.05,p=0}return this.settings.isSameDrumSoundOverlap||-1==m||(h>m&&(h=m),p>m&&(p=m)),this.stopAudioNode(i,r+h,s),this.stopAudioNode(o,r+p,l),e.drumStopTime=e.startTime+(h>=p?h:p),function(){t.stopAudioNode(i,0,s,!0),t.stopAudioNode(o,0,l,!0)}}function x(e,t,a,i){var n=t-.005,s=t;t<=this.context.currentTime&&(i?(n=this.context.currentTime,s=this.context.currentTime+.005):s=this.context.currentTime);try{i?(e.stop(s),a.gain.cancelScheduledValues(0),a.gain.setValueAtTime(1,n),a.gain.linearRampToValueAtTime(0,s)):e.stop(s)}catch(e){a.gain.cancelScheduledValues(0),i?(a.gain.setValueAtTime(1,n),a.gain.linearRampToValueAtTime(0,s)):a.gain.setValueAtTime(0,s)}}function O(e){(e.note||e.rootTimeout||e.pan||this.trigger.isNoteTrigger)&&this.states.stopFuncs.push(e)}function P(e,t){("note"==e||"rootTimeout"==e||"pan"==e||this.trigger.isNoteTrigger)&&this.states.stopFuncs.some((function(a,i,n){if(a[e]==t)return y.delete(n,i),!0}))}function w(e){var t=-1;if(this.tempoTrack&&this.tempoTrack.length>=1){if(e>=this.tempoTrack[this.tempoTrack.length-1].timing)return this.tempoTrack[this.tempoTrack.length-1].time;for(var a=0,i=this.tempoTrack.length-1;;){t=Math.floor(a+(i-a)/2);var n=this.tempoTrack[t].timing;if(e<n)i=t-1;else{if(!(e>n))break;a=t+1}if(a>i){e<n&&t--;break}}}var s=0,r=0,u=120;if(t>=0){var o=this.tempoTrack[t];s=o.time,r=o.timing,u=o.value}return s+=60/u/this.settings.resolution*(e-r)}function D(e){var t=-1;if(this.tempoTrack&&this.tempoTrack.length>=1){if(e>=this.tempoTrack[this.tempoTrack.length-1].time)return this.tempoTrack[this.tempoTrack.length-1].timing;for(var a=0,i=this.tempoTrack.length-1;;){t=Math.floor(a+(i-a)/2);var n=this.tempoTrack[t].time;if(e<n)i=t-1;else{if(!(e>n))break;a=t+1}if(a>i){e<n&&t--;break}}}var s=0,r=0,u=120;if(t>=0){var o=this.tempoTrack[t];s=o.time,r=o.timing,u=o.value}return r+=(e-s)/(60/u/this.settings.resolution)}function S(e){var t=e.smf,a=4,i={};i.size=b.getInt(t,4,8),i.format=t[9],i.trackcount=b.getInt(t,10,12),i.timemanage=t[12],i.resolution=b.getInt(t,12,14),a+=4+i.size;for(var n=[],s=this.settings.isWebMIDI?17:16,r=0;r<s;r++){var u={};n.push(u),u.indices=[],u.indicesLength=0,u.indicesHead=-1,u.indicesFoot=0,u.indicesCur=0,u.indicesPre=0,u.notes=[]}return e.p=a,e.header=i,e.channels=n,e}function L(e){for(var t=e.smf,a=e.p,i=e.header,n=e.channels,s=[],r=[],u=0,o=0;o<i.trackcount;o++){if(77!=t[a]||84!=t[a+1]||114!=t[a+2]||107!=t[a+3])return"Irregular SMF.";var c=(a+=4)+4+b.getInt(t,a,a+4);a+=4;for(var l=0,m=120,h=0,p=0,T=1,f=void 0;a<c;){if(null!=T){var g=b.variableLengthToInt(t,a,a+5);l+=f=g[0],a+=g[1]}var v=a;switch(t[a]>>4){case 8:case 9:case 10:case 11:case 14:var d=n[15&(T=t[a])];b.chIndicesInsert(this,d,l,a,3),a+=3;break;case 12:case 13:var y=n[15&(T=t[a])];b.chIndicesInsert(this,y,l,a,2),a+=2;break;case 15:switch(t[a]){case 240:case 247:var A=b.variableLengthToInt(t,a+1,a+1+4);if(A[0]>=7&&127==t[a+2]&&127==t[a+3]&&4==t[a+4]&&1==t[a+5])for(var V=0;V<16;V++){var k=n[V];b.chIndicesInsert(this,k,l,a,A[0])}a+=1+A[1]+A[0];break;case 241:case 243:a+=2;break;case 242:a+=3;break;case 246:case 248:case 250:case 251:case 252:case 254:a+=1;break;case 255:switch(t[a+1]){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 32:case 84:break;case 47:l+=(this.settings.isSkipEnding?0:i.resolution)-f;break;case 81:for(var I=0;I<16;I++){var R=n[I];b.chIndicesInsert(this,R,l,a,6)}p+=60/m/i.resolution*(l-h),h=l,m=6e7/(65536*t[a+3]+256*t[a+4]+t[a+5]),s.push({timing:l,time:p,value:m});break;case 88:r.push({timing:l,value:[t[a+3],Math.pow(2,t[a+4])]})}var M=b.variableLengthToInt(t,a+2,a+2+4);a+=2+M[1]+M[0]}break;default:if(null==T)return"Irregular SMF. ("+a+" byte addr)";t[--a]=T,T=null}this.settings.isWebMIDI&&null!=T&&b.chIndicesInsert(this,n[16],l,v,a-v)}!this.settings.isSkipEnding&&u<l&&(u=l);for(var N=0;N<n.length;N++)n[N].indicesCur=n[N].indicesHead,n[N].indicesPre=n[N].indicesHead}return e.p=a,e.tempoTrack=s,e.beatTrack=r,e.songLength=u,e}function E(t){for(var a,i,n,s=this,r=t.smf,u=t.header,o=t.channels,c=t.tempoTrack,l=t.songLength,m=-1,h=-1,p=g,T=g,f=0,v=0,d=0,b=0,A=function(t){var c=o[t],l=2,g=0,A=64,V=127,k=100,I=0,R=0,M=s.settings.initReverb,N=0,x=127,O=127,P=0,w=127;a=120,i=0,n=0;for(var D=[],S=c.indicesHead,L=c.indices,E=new Array(128),W=function(){var e=L[S],o=L[S+2],W=L[S+3],q=60/a/u.resolution*(e-i)+n,B=r[o]>>4;switch(B){case 8:case 9:if(9==B&&0!=r[o+2]){var C={start:e,stop:null,startTime:q,stopTime:null,pitch:r[o+1],pitchBend:[{timing:e,time:q,value:g}],pan:[{timing:e,time:q,value:A}],expression:[{timing:e,time:q,value:V*(w/127)}],velocity:r[o+2]/127*(k/127),modulation:[{timing:e,time:q,value:I}],holdBeforeStop:null,reverb:[{timing:e,time:q,value:M}],chorus:[{timing:e,time:q,value:N}],instrument:P,channel:t,nextSameNoteOnInterval:-1,drumStopTime:2},G=E[r[o+1]];G&&(G.nextSameNoteOnInterval=q-G.startTime),E[r[o+1]]=C,D.some((function(t,a){var i=c.notes[t];i.pitch==r[o+1]&&null==i.stop&&(i.stop=e,i.stopTime=q,y.delete(D,a))})),D.push(c.notes.length),c.notes.push(C),e<p&&(p=e,T=q)}else D.some((function(t,a){var i=c.notes[t];if(i.pitch==r[o+1]&&null==i.stop)return R>=s.settings.holdOnValue?null==i.holdBeforeStop&&(i.holdBeforeStop=[{timing:e,time:q,value:R}]):(i.stop=e,i.stopTime=q,y.delete(D,a)),e>f&&(f=e,v=q),!0}));break;case 10:case 13:break;case 11:switch(r[o+1]){case 1:I=r[o+2],D.forEach((function(t){c.notes[t].modulation.push({timing:e,time:q,value:I})}));break;case 6:0==x&&0==O&&(l=r[o+2])>24&&(l=24);break;case 7:k=r[o+2];break;case 10:A=r[o+2],D.forEach((function(t){c.notes[t].pan.push({timing:e,time:q,value:A})}));break;case 11:V=r[o+2],D.forEach((function(t){c.notes[t].expression.push({timing:e,time:q,value:V*(w/127)})}));break;case 64:if((R=r[o+2])<s.settings.holdOnValue)for(var F=D.length-1;F>=0;F--){var _=D[F],j=c.notes[_];null==j.stop&&null!=j.holdBeforeStop&&(j.stop=e,j.stopTime=q,y.delete(D,F))}break;case 91:M=r[o+2],D.forEach((function(t){c.notes[t].reverb.push({timing:e,time:q,value:M})}));break;case 93:N=r[o+2],D.forEach((function(t){c.notes[t].chorus.push({timing:e,time:q,value:N})}));break;case 98:r[o+2];break;case 99:r[o+2];break;case 100:x=r[o+2];break;case 101:O=r[o+2];break;case 111:-1==m&&(m=e,h=q)}break;case 12:P=r[o+1];break;case 14:g=(128*r[o+2]+r[o+1]-8192)/8192*l,D.forEach((function(t){c.notes[t].pitchBend.push({timing:e,time:q,value:g})}));break;case 15:switch(r[o]){case 240:case 247:if(127==r[o+1]&&127==r[o+2]&&4==r[o+3]&&1==r[o+4]){var z=r[o+6];z>127&&(z=127),w=z,D.forEach((function(t){c.notes[t].expression.push({timing:e,time:q,value:V*(w/127)})}))}break;case 255:if(81===r[o+1])n+=60/a/u.resolution*(e-i),i=e,a=6e7/(65536*r[o+3]+256*r[o+4]+r[o+5])}break;default:return{v:{v:"Error parseSMF. "}}}S=W,e>d&&(d=e,b=q)};-1!=S;){var q=W();if("object"===e(q))return q.v}c.nowNoteOnIdxAry=D,s.debug||delete c.indices},V=0;V<16;V++){var k=A(V);if("object"===e(k))return k.v}for(var I=0;I<16;I++){for(var R=o[I],M=R.nowNoteOnIdxAry,N=function(e){var t=R.notes[M[e]];if(null==t.stop){t.stop=f,t.stopTime=v;["pitchBend","pan","expression","modulation","reverb","chorus"].forEach((function(e){for(var a=t[e],i=a.length-1;i>=1;i--){a[i].timing>f&&y.delete(a,i)}})),y.delete(M,e)}},x=M.length-1;x>=0;x--)N(x);delete R.nowNoteOnIdxAry}this.settings.isSkipEnding&&(l=f),this.settings.isCC111&&-1!=h&&(l=d),c.push({timing:l,time:60/a/u.resolution*(l-i)+n,value:120});var O=[];if(this.settings.isWebMIDI)for(var P=o[16],w=120,D=0,S=0,L=P.indicesHead,E=P.indices;-1!=L;){var W=E[L],q=E[L+1],B=E[L+2],C=E[L+3],G=60/w/u.resolution*(W-D)+S;if(255===r[B])if(81===r[B+1])S+=60/w/u.resolution*(W-D),D=W,w=6e7/(65536*r[B+3]+256*r[B+4]+r[B+5]);O.push({time:G,tick:W,smfPtr:B,smfPtrLen:q}),L=C}return t.songLength=l,t.cc111Tick=m,t.cc111Time=h,t.firstNoteOnTiming=p,t.firstNoteOnTime=T,t.lastNoteOffTiming=f,t.lastNoteOffTime=v,t.lastEventTiming=d,t.lastEventTime=b,this.settings.isWebMIDI&&(t.messages=O,t.smfData=new Uint8Array(r)),t}function W(e){if(this.debug){console.log(e);var t=f.now()}var a=new Uint8Array(e);if(77!=a[0]||84!=a[1]||104!=a[2]||100!=a[3])return"Not Sandard MIDI File.";var i={};if(i.smf=a,S.call(this,i),this.debug)var n=f.now();if(L.call(this,i),this.debug)var s=f.now();E.call(this,i);var r={};if(r.header=i.header,r.tempoTrack=i.tempoTrack,r.beatTrack=i.beatTrack,r.channels=i.channels,r.songLength=i.songLength,r.cc111Tick=i.cc111Tick,r.cc111Time=i.cc111Time,r.firstNoteOnTiming=i.firstNoteOnTiming,r.firstNoteOnTime=i.firstNoteOnTime,r.lastNoteOffTiming=i.lastNoteOffTiming,r.lastNoteOffTime=i.lastNoteOffTime,r.lastEventTiming=i.lastEventTiming,r.lastEventTime=i.lastEventTime,this.settings.isWebMIDI&&(r.messages=i.messages,r.smfData=new Uint8Array(a)),this.debug){var u=f.now();console.log("parseSMF time",u-t),console.log("parseSMF(0/2) time",n-t),console.log("parseSMF(1/2) time",s-n),console.log("parseSMF(2/2) time",u-s),console.log(r)}return r}function q(){var e=this;if(navigator.requestMIDIAccess){var t=this.settings.WebMIDIPortSysEx,a=function(a){var i,n=a.outputs;return e.settings.WebMIDIPortOutputs=n,-1==e.settings.WebMIDIPort?e.settings.WebMIDIPortOutputs.forEach((function(e){i||(i=e)})):i=e.settings.WebMIDIPortOutputs.get(e.settings.WebMIDIPort),e.settings.WebMIDIPortOutput=i,e.settings.WebMIDIPortSysEx=t,i&&(i.open(),e.initStatus()),n};navigator.requestMIDIAccess({sysex:t}).then(a).catch((function e(i){console.log(i),t&&(t=!1,navigator.requestMIDIAccess({sysex:t}).then(a).catch(e))})),window.addEventListener("unload",(function(){for(var t=0;t<16;t++){e.settings.WebMIDIPortOutput.send([176+t,120,0]);for(var a=0;a<128;a++)e.settings.WebMIDIPortOutput.send([128+t,a,0])}}))}}return function(){function e(a){t(this,e),l.call(this,a)}return i(e,[{key:"init",value:function(e){return T.call(this,e)}},{key:"parseSMF",value:function(e){return W.call(this,e)}},{key:"setData",value:function(e){return v.call(this,e)}},{key:"play",value:function(e){return V.call(this,e)}},{key:"pause",value:function(e){return k.call(this,e)}},{key:"stop",value:function(e){return k.call(this,e)}},{key:"initStatus",value:function(e,t){return d.call(this,e,t)}},{key:"setStartTime",value:function(e){this.states.startTime-=e}},{key:"getTime",value:function(e){return w.call(this,e)}},{key:"getTiming",value:function(e){return D.call(this,e)}},{key:"createBaseNote",value:function(e,t,a,i,n){return I.call(this,e,t,a,i,n)}},{key:"createNote",value:function(e){return M.call(this,e)}},{key:"createPercussionNote",value:function(e){return N.call(this,e)}},{key:"stopAudioNode",value:function(e,t,a,i){return x.call(this,e,t,a,i)}},{key:"pushFunc",value:function(e){return O.call(this,e)}},{key:"clearFunc",value:function(e,t){return P.call(this,e,t)}},{key:"startWebMIDI",value:function(){return q.call(this)}},{key:"addEventListener",value:function(e,t){this.events.push({type:e,func:t})}},{key:"removeEventListener",value:function(e,t){for(var a=this.events.length;a>=0;a--)event.type==e&&event.func===t&&this.events.splice(a,1)}},{key:"removeAllEventListener",value:function(e){for(var t=this.events.length;t>=0;t--)event.type==e&&this.events.splice(t,1)}},{key:"fireEvent",value:function(e,t){this.events.forEach((function(a){if(a.type==e)try{a.func(t)}catch(e){console.log(e)}}))}},{key:"setOnSongEndListener",value:function(e){this.onSongEndListener=e}},{key:"onSongEnd",value:function(){if(this.onSongEndListener&&this.onSongEndListener())return;this.settings.loop&&(this.initStatus(!0),this.settings.isCC111&&-1!=this.cc111Time&&this.setStartTime(this.cc111Time),this.play(!0))}},{key:"getChannels",value:function(){return this.channels}},{key:"setChannels",value:function(e){var t=this;e.forEach((function(e,a){t.channels[a]=e}))}},{key:"initChannels",value:function(){for(var e=0;e<16;e++)this.channels[e]=[0,0,1]}},{key:"getMasterVolume",value:function(){return this.settings.masterVolume}},{key:"setMasterVolume",value:function(e){this.settings.masterVolume=e,this.isStarted&&(this.masterGainNode.gain.value=this.settings.masterVolume)}},{key:"isLoop",value:function(){return this.settings.loop}},{key:"setLoop",value:function(e){this.settings.loop=e}},{key:"isWebMIDI",value:function(){return this.settings.isWebMIDI}},{key:"setWebMIDI",value:function(e){this.settings.isWebMIDI=e}},{key:"isCC111",value:function(){return this.settings.isCC111}},{key:"setCC111",value:function(e){this.settings.isCC111=e}},{key:"isReverb",value:function(){return this.settings.isReverb}},{key:"setReverb",value:function(e){this.settings.isReverb=e}},{key:"getReverbVolume",value:function(){return this.settings.reverbVolume}},{key:"setReverbVolume",value:function(e){this.settings.reverbVolume=e}},{key:"isChorus",value:function(){return this.settings.isChorus}},{key:"setChorus",value:function(e){this.settings.isChorus=e}},{key:"getChorusVolume",value:function(){return this.settings.chorusVolume}},{key:"setChorusVolume",value:function(e){this.settings.chorusVolume=e}}]),e}()}();
//# sourceMappingURL=PicoAudio.min.js.map
{
"name": "picoaudio",
"version": "1.1.0",
"version": "1.1.1",
"description": "PicoAudio.js is light MIDI player using Web Audio API",

@@ -5,0 +5,0 @@ "main": "dist/nodejs/picoaudio.js",

@@ -49,4 +49,4 @@ # PicoAudio.js

```
https://www.npmjs.com/package/picoaudio (`pico-audio-js` has deprecated)
## はじめ方

@@ -53,0 +53,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc