// ==UserScript==
// @name Nicopedia-FlMMLonHTML5
// @namespace https://github.com/kosh04/FlMMLonHTML5
// @version 0.20170604
// @description ニコニコ大百科のピコカキコプレーヤーをFlMMLonHTML5に置き換える (デバッグ用)
// @grant none
// @match http://dic.nicovideo.jp/*
// @match https://dic.nicovideo.jp/*
// @resource flmmlworker.js https://rawgit.com/carborane3/FlMMLonHTML5/master/project/flmmlworker-raw.js
// @author kosh (mono)
// ==/UserScript==
function loadScript(src) {
var s = document.createElement("script");
s.type = "text/javascript";
s.src = src;
document.head.appendChild(s);
}
loadScript("https://rawgit.com/carborane3/FlMMLonHTML5/master/project/flmmlonhtml5-raw.js");
loadScript("https://rawgit.com/carborane3/FlMMLonHTML5/master/project/flmmlplayer-raw.js");
var flmmlworker = (function() {
// FlMMLonHTML5/flmmlworker.js
// commit: e792cc1
var flmml;!function(t){var e=function(){function e(){this.m_noteNo=0,this.m_detune=0,this.m_freqNo=0,this.m_envelope1=new t.MEnvelope(0,60/127,30/127,1/127),this.m_envelope2=new t.MEnvelope(0,30/127,0,1),this.m_oscSet1=new t.MOscillator,this.m_oscMod1=this.m_oscSet1.getCurrent(),this.m_oscSet2=new t.MOscillator,this.m_oscSet2.asLFO(),this.m_oscSet2.setForm(t.MOscillator.SINE),this.m_oscMod2=this.m_oscSet2.getCurrent(),this.m_osc2Connect=0,this.m_filter=new t.MFilter,this.m_filterConnect=0,this.m_formant=new t.MFormant,this.m_volMode=0,this.setExpression(127),this.setVelocity(100),this.setPan(64),this.m_onCounter=0,this.m_lfoDelay=0,this.m_lfoDepth=0,this.m_lfoEnd=0,this.m_lpfAmt=0,this.m_lpfFrq=0,this.m_lpfRes=0,this.m_pulseWidth=.5,this.setInput(0,0),this.setOutput(0,0),this.setRing(0,0),this.setSync(0,0),this.m_portDepth=0,this.m_portDepthAdd=0,this.m_lastFreqNo=4800,this.m_portamento=0,this.m_portRate=0,this.m_voiceid=0,this.m_slaveVoice=!1}return e.boot=function(t){if(!this.s_init){var e;for(this.SAMPLE_RATE=msgr.SAMPLE_RATE,this.emptyBuffer=msgr.emptyBuffer,this.s_frequencyLen=this.s_frequencyMap.length,e=0;e<this.s_frequencyLen;e++)this.s_frequencyMap[e]=440*Math.pow(2,(e-69*this.PITCH_RESOLUTION)/(12*this.PITCH_RESOLUTION));for(this.s_volumeLen=128,this.s_volumeMap=new Array(3),e=0;3>e;e++)this.s_volumeMap[e]=new Array(this.s_volumeLen),this.s_volumeMap[e][0]=0;for(e=1;e<this.s_volumeLen;e++)this.s_volumeMap[0][e]=e/127,this.s_volumeMap[1][e]=Math.pow(10,(e-127)*(48/2540)),this.s_volumeMap[2][e]=Math.pow(10,(e-127)*(96/2540));this.s_init=1}this.s_samples=new Float32Array(t)},e.createPipes=function(t){this.s_pipeArr=new Array(t);for(var e=0;t>e;e++)this.s_pipeArr[e]=new Float32Array(this.s_samples.length)},e.createSyncSources=function(t){this.s_syncSources=new Array(t);for(var e=0;t>e;e++){this.s_syncSources[e]=new Array(this.s_samples.length);for(var s=0;s<this.s_samples.length;s++)this.s_syncSources[e][s]=!1}},e.getFrequency=function(t){return t|=0,t=0>t?0:t>=e.s_frequencyLen?e.s_frequencyLen-1:t,e.s_frequencyMap[t]},e.prototype.setExpression=function(s){this.m_expression=e.s_volumeMap[this.m_volMode][s],this.m_ampLevel=this.m_velocity*this.m_expression,this.m_oscSet1.getMod(t.MOscillator.OPM).setExpression(this.m_expression)},e.prototype.setVelocity=function(s){this.m_velocity=e.s_volumeMap[this.m_volMode][s],this.m_ampLevel=this.m_velocity*this.m_expression,this.m_oscSet1.getMod(t.MOscillator.OPM).setVelocity(s)},e.prototype.setNoteNo=function(t,s){void 0===s&&(s=!0),this.m_noteNo=t,this.m_freqNo=this.m_noteNo*e.PITCH_RESOLUTION+this.m_detune,this.m_oscMod1.setFrequency(e.getFrequency(this.m_freqNo)),1===this.m_portamento&&(s?this.m_portDepth+=this.m_lastFreqNo-this.m_freqNo:this.m_portDepth=this.m_lastFreqNo-this.m_freqNo,this.m_portDepthAdd=this.m_portDepth<0?this.m_portRate:-1*this.m_portRate),this.m_lastFreqNo=this.m_freqNo},e.prototype.setDetune=function(t){this.m_detune=t,this.m_freqNo=this.m_noteNo*e.PITCH_RESOLUTION+this.m_detune,this.m_oscMod1.setFrequency(e.getFrequency(this.m_freqNo))},e.prototype.getNoteNo=function(){return this.m_noteNo},e.prototype.isPlaying=function(){return this.m_oscSet1.getForm()===t.MOscillator.OPM?this.m_oscSet1.getCurrent().IsPlaying():this.m_envelope1.isPlaying()},e.prototype.getId=function(){return this.m_voiceid},e.prototype.getVoiceCount=function(){return this.isPlaying()?1:0},e.prototype.setSlaveVoice=function(t){this.m_slaveVoice=t},e.prototype.noteOnWidthId=function(t,e,s){this.m_voiceid=s,this.noteOn(t,e)},e.prototype.noteOn=function(e,s){this.setNoteNo(e,!1),this.m_envelope1.triggerEnvelope(0),this.m_envelope2.triggerEnvelope(1),this.m_oscMod1.resetPhase(),this.m_oscMod2.resetPhase(),this.m_filter.reset(),this.setVelocity(s),this.m_onCounter=0;var i=this.m_oscSet1.getMod(t.MOscillator.PULSE);i.setPWM(this.m_pulseWidth);var h=this.m_oscSet1;h.getMod(t.MOscillator.FC_NOISE).setNoteNo(this.m_noteNo),h.getMod(t.MOscillator.GB_NOISE).setNoteNo(this.m_noteNo),h.getMod(t.MOscillator.GB_S_NOISE).setNoteNo(this.m_noteNo),h.getMod(t.MOscillator.FC_DPCM).setNoteNo(this.m_noteNo),h.getMod(t.MOscillator.OPM).setNoteNo(this.m_noteNo)},e.prototype.noteOff=function(e){(0>e||e===this.m_noteNo)&&(this.m_envelope1.releaseEnvelope(),this.m_envelope2.releaseEnvelope(),this.m_oscSet1.getMod(t.MOscillator.OPM).noteOff())},e.prototype.setSoundOff=function(){this.m_envelope1.soundOff(),this.m_envelope2.soundOff()},e.prototype.close=function(){this.noteOff(this.m_noteNo),this.m_filter.setSwitch(0)},e.prototype.setNoiseFreq=function(e){var s=this.m_oscSet1.getMod(t.MOscillator.NOISE);s.setNoiseFreq(1-e*(1/128))},e.prototype.setForm=function(t,e){this.m_oscMod1=this.m_oscSet1.setForm(t),this.m_oscMod1.setWaveNo(e)},e.prototype.setEnvelope1Atk=function(t){this.m_envelope1.setAttack(t*(1/127))},e.prototype.setEnvelope1Point=function(t,e){this.m_envelope1.addPoint(t*(1/127),e*(1/127))},e.prototype.setEnvelope1Rel=function(t){this.m_envelope1.setRelease(t*(1/127))},e.prototype.setEnvelope2Atk=function(t){this.m_envelope2.setAttack(t*(1/127))},e.prototype.setEnvelope2Point=function(t,e){this.m_envelope2.addPoint(t*(1/127),e*(1/127))},e.prototype.setEnvelope2Rel=function(t){this.m_envelope2.setRelease(t*(1/127))},e.prototype.setPWM=function(e){if(this.m_oscSet1.getForm()!==t.MOscillator.FC_PULSE){var s=this.m_oscSet1.getMod(t.MOscillator.PULSE);0>e?(s.setMIX(1),e*=-1):s.setMIX(0),this.m_pulseWidth=.01*e,s.setPWM(this.m_pulseWidth)}else{var i=this.m_oscSet1.getMod(t.MOscillator.FC_PULSE);0>e&&(e*=-1),i.setPWM(.125*Math.floor(e))}},e.prototype.setPan=function(t){this.m_pan=(t-1)*(.5/63),this.m_pan<0&&(this.m_pan=0)},e.prototype.setFormant=function(t){t>=0?this.m_formant.setVowel(t):this.m_formant.disable()},e.prototype.setLFOFMSF=function(e,s){this.m_oscMod2=this.m_oscSet2.setForm(e>=0?e-1:-e-1),this.m_oscMod2.setWaveNo(s),this.m_osc2Sign=e>=0?1:-1,0>e&&(e=-e),e--,e>=t.MOscillator.MAX&&(this.m_osc2Connect=0)},e.prototype.setLFODPWD=function(s,i){this.m_lfoDepth=s,this.m_osc2Connect=0===s?0:1,this.m_oscMod2.setFrequency(i),this.m_oscMod2.resetPhase(),this.m_oscSet2.getMod(t.MOscillator.NOISE).setNoiseFreq(i/e.SAMPLE_RATE)},e.prototype.setLFODLTM=function(t,e){this.m_lfoDelay=t,this.m_lfoEnd=e>0?this.m_lfoDelay+e:0},e.prototype.setLFOTarget=function(t){this.m_lfoTarget=t},e.prototype.setLpfSwtAmt=function(t,s){t>-3&&3>t&&t!==this.m_filterConnect&&(this.m_filterConnect=t,this.m_filter.setSwitch(t)),this.m_lpfAmt=(-127>s?-127:127>s?s:127)*e.PITCH_RESOLUTION},e.prototype.setLpfFrqRes=function(t,s){0>t&&(t=0),t>127&&(t=127),this.m_lpfFrq=t*e.PITCH_RESOLUTION,this.m_lpfRes=s*(1/127),this.m_lpfRes<0&&(this.m_lpfRes=0),this.m_lpfRes>1&&(this.m_lpfRes=1)},e.prototype.setVolMode=function(t){switch(t){case 0:case 1:case 2:this.m_volMode=t}},e.prototype.setInput=function(e,s){this.m_inSens=(1<<e-1)*(1/8)*t.MOscMod.PHASE_LEN,this.m_inPipe=s},e.prototype.setOutput=function(t,e){this.m_outMode=t,this.m_outPipe=e},e.prototype.setRing=function(t,e){this.m_ringSens=(1<<t-1)/8,this.m_ringPipe=e},e.prototype.setSync=function(t,e){this.m_syncMode=t,this.m_syncPipe=e},e.prototype.setPortamento=function(t,e){this.m_portamento=0,this.m_portDepth=t,this.m_portDepthAdd=Math.floor(this.m_portDepth)/e*-1},e.prototype.setMidiPort=function(t){this.m_portamento=t,this.m_portDepth=0},e.prototype.setMidiPortRate=function(t){this.m_portRate=t},e.prototype.setPortBase=function(t){this.m_lastFreqNo=t},e.prototype.setVoiceLimit=function(t){},e.prototype.setHwLfo=function(e){var s=e>>27&3,i=e>>19&255,h=e>>12&127,o=e>>5&127,_=e>>2&7,r=e>>0&3,n=this.m_oscSet1.getMod(t.MOscillator.OPM);n.setWF(s),n.setLFRQ(i),n.setPMD(h),n.setAMD(o),n.setPMSAMS(_,r)},e.prototype.reset=function(){this.setSoundOff(),this.m_pulseWidth=.5,this.m_voiceid=0,this.setForm(0,0),this.setDetune(0),this.setExpression(127),this.setVelocity(100),this.setPan(64),this.setVolMode(0),this.setNoiseFreq(0),this.setLFOFMSF(0,0),this.m_osc2Connect=0,this.m_onCounter=0,this.m_lfoTarget=0,this.m_lfoDelay=0,this.m_lfoDepth=0,this.m_lfoEnd=0,this.setLpfSwtAmt(0,0),this.setLpfFrqRes(0,0),this.setFormant(-1),this.setInput(0,0),this.setOutput(0,0),this.setRing(0,0),this.setSync(0,0),this.m_portDepth=0,this.m_portDepthAdd=0,this.m_lastFreqNo=4800,this.m_portamento=0,this.m_portRate=0},e.prototype.clearOutPipe=function(t,s,i){1===this.m_outMode&&e.s_pipeArr[this.m_outPipe].set(e.emptyBuffer.subarray(0,i),s)},e.prototype.getNextCutoff=function(){var t=this.m_lpfFrq+this.m_lpfAmt*this.m_envelope2.getNextAmplitudeLinear();return t=e.getFrequency(t)*this.m_oscMod1.getFrequency()*(2*Math.PI/(440*e.SAMPLE_RATE)),1/127>t&&(t=0),t},e.prototype.getSamples=function(s,i,h,o){var _,r,n,m,a,p,c,l,u,f,g,S,v=h+o,y=e.s_samples,E=this.isPlaying();v>=i&&(v=i);var M=e.getFrequency(this.m_freqNo);if(1===this.m_outMode&&this.m_slaveVoice===!1&&(y=e.s_pipeArr[this.m_outPipe]),E&&(0===this.m_portDepth?this.m_inSens>=1e-6?0===this.m_osc2Connect?this.getSamplesF__(y,h,v):0===this.m_lfoTarget?this.getSamplesFP_(y,h,v):3===this.m_lfoTarget?this.getSamplesFW_(y,h,v):4===this.m_lfoTarget?this.getSamplesFF_(y,h,v):this.getSamplesF__(y,h,v):2===this.m_syncMode?0===this.m_osc2Connect?this.getSamplesI__(y,h,v):0===this.m_lfoTarget?this.getSamplesIP_(y,h,v):3===this.m_lfoTarget?this.getSamplesIW_(y,h,v):this.getSamplesI__(y,h,v):1===this.m_syncMode?0===this.m_osc2Connect?this.getSamplesO__(y,h,v):0===this.m_lfoTarget?this.getSamplesOP_(y,h,v):3===this.m_lfoTarget?this.getSamplesOW_(y,h,v):this.getSamplesO__(y,h,v):0===this.m_osc2Connect?this.getSamples___(y,h,v):0===this.m_lfoTarget?this.getSamples_P_(y,h,v):3===this.m_lfoTarget?this.getSamples_W_(y,h,v):this.getSamples___(y,h,v):this.m_inSens>=1e-6?0===this.m_osc2Connect?this.getSamplesF_P(y,h,v):0===this.m_lfoTarget?this.getSamplesFPP(y,h,v):3===this.m_lfoTarget?this.getSamplesFWP(y,h,v):4===this.m_lfoTarget?this.getSamplesFFP(y,h,v):this.getSamplesF_P(y,h,v):2===this.m_syncMode?0===this.m_osc2Connect?this.getSamplesI_P(y,h,v):0===this.m_lfoTarget?this.getSamplesIPP(y,h,v):3===this.m_lfoTarget?this.getSamplesIWP(y,h,v):this.getSamplesI_P(y,h,v):1===this.m_syncMode?0===this.m_osc2Connect?this.getSamplesO_P(y,h,v):0===this.m_lfoTarget?this.getSamplesOPP(y,h,v):3===this.m_lfoTarget?this.getSamplesOWP(y,h,v):this.getSamplesO_P(y,h,v):0===this.m_osc2Connect?this.getSamples__P(y,h,v):0===this.m_lfoTarget?this.getSamples_PP(y,h,v):3===this.m_lfoTarget?this.getSamples_WP(y,h,v):this.getSamples__P(y,h,v)),this.m_oscSet1.getForm()!==t.MOscillator.OPM&&(0===this.m_volMode?this.m_envelope1.ampSamplesLinear(y,h,v,this.m_ampLevel):this.m_envelope1.ampSamplesNonLinear(y,h,v,this.m_ampLevel,this.m_volMode)),1===this.m_lfoTarget&&0!==this.m_osc2Connect)for(u=this.m_osc2Sign*this.m_lfoDepth/127,g=h,f=h;v>f;f++)p=1,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(p+=this.m_oscMod2.getNextSample()*u),0>p&&(p=0),y[f]*=p,this.m_onCounter++;if(E&&this.m_ringSens>=1e-6)for(r=e.s_pipeArr[this.m_ringPipe],_=this.m_ringSens,f=h;v>f;f++)y[f]*=r[f]*_;if(a=E,E=E||this.m_formant.checkToSilence(),E!==a&&y.set(e.emptyBuffer.subarray(0,o),h),E&&this.m_formant.run(y,h,v),a=E,E=E||this.m_filter.checkToSilence(),E!==a&&y.set(e.emptyBuffer.subarray(0,o),h),E)if(2===this.m_lfoTarget&&0!==this.m_osc2Connect){u=this.m_osc2Sign*this.m_lfoDepth,g=h;do S=g+e.s_lfoDelta,S>v&&(S=v),c=this.m_lpfFrq,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(c+=this.m_oscMod2.getNextSample()*u|0,this.m_oscMod2.addPhase(S-g-1)),0>c?c=0:c>127*e.PITCH_RESOLUTION&&(c=127*e.PITCH_RESOLUTION),this.m_filter.run(e.s_samples,g,S,this.m_envelope2,c,this.m_lpfAmt,this.m_lpfRes,M),this.m_onCounter+=S-g,g=S;while(v>g)}else this.m_filter.run(y,h,v,this.m_envelope2,this.m_lpfFrq,this.m_lpfAmt,this.m_lpfRes,M);if(E)switch(this.m_outMode){case 0:var P=s[0],d=s[1];if(5===this.m_lfoTarget&&0!==this.m_osc2Connect)for(u=this.m_osc2Sign*this.m_lfoDepth*(1/127),f=h;v>f;f++)l=this.m_pan+this.m_oscMod2.getNextSample()*u,0>l?l=0:l>1&&(l=1),n=.5*y[f],m=n*l,P[f]+=n-m,d[f]+=m;else for(f=h;v>f;f++)n=.5*y[f],m=n*this.m_pan,P[f]+=n-m,d[f]+=m;break;case 1:if(r=e.s_pipeArr[this.m_outPipe],this.m_slaveVoice===!1)for(f=h;v>f;f++)r[f]=y[f];else for(f=h;v>f;f++)r[f]+=y[f];break;case 2:for(r=e.s_pipeArr[this.m_outPipe],f=h;v>f;f++)r[f]+=y[f]}else 1===this.m_outMode&&(r=e.s_pipeArr[this.m_outPipe],this.m_slaveVoice===!1&&r.set(e.emptyBuffer.subarray(0,o),h))},e.prototype.getSamples___=function(t,e,s){this.m_oscMod1.getSamples(t,e,s)},e.prototype.getSamples_P_=function(t,s,i){var h,o,_=s,r=this.m_osc2Sign*this.m_lfoDepth,n=this.m_oscMod1,m=this.m_oscMod2;do h=_+e.s_lfoDelta,h>i&&(h=i),o=this.m_freqNo,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(o+=m.getNextSample()*r|0,m.addPhase(h-_-1)),n.setFrequency(e.getFrequency(o)),n.getSamples(t,_,h),this.m_onCounter+=h-_,_=h;while(i>_)},e.prototype.getSamples_W_=function(s,i,h){var o,_,r=i,n=this.m_osc2Sign*this.m_lfoDepth*.01,m=this.m_oscSet1.getMod(t.MOscillator.PULSE),a=this.m_oscMod1,p=this.m_oscMod2;do o=r+e.s_lfoDelta,o>h&&(o=h),_=this.m_pulseWidth,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(_+=p.getNextSample()*n,p.addPhase(o-r-1)),0>_?_=0:_>100&&(_=100),m.setPWM(_),a.getSamples(s,r,o),this.m_onCounter+=o-r,r=o;while(h>r)},e.prototype.getSamplesF__=function(t,s,i){var h,o=this.m_inSens,_=e.s_pipeArr[this.m_inPipe],r=this.m_oscMod1;for(r.setFrequency(e.getFrequency(this.m_freqNo)),h=s;i>h;h++)t[h]=r.getNextSampleOfs(_[h]*o)},e.prototype.getSamplesFP_=function(t,s,i){var h,o,_=this.m_inSens,r=this.m_osc2Sign*this.m_lfoDepth,n=e.s_pipeArr[this.m_inPipe],m=this.m_oscMod1,a=this.m_oscMod2;for(h=s;i>h;h++)o=this.m_freqNo,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(o+=a.getNextSample()*r|0),m.setFrequency(e.getFrequency(o)),t[h]=m.getNextSampleOfs(n[h]*_),this.m_onCounter++},e.prototype.getSamplesFW_=function(s,i,h){var o,_,r=this.m_osc2Sign*this.m_lfoDepth*.01,n=this.m_oscSet1.getMod(t.MOscillator.PULSE),m=this.m_inSens,a=e.s_pipeArr[this.m_inPipe],p=this.m_oscMod1,c=this.m_oscMod2;for(p.setFrequency(e.getFrequency(this.m_freqNo)),o=i;h>o;o++)_=this.m_pulseWidth,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(_+=c.getNextSample()*r),0>_?_=0:_>100&&(_=100),n.setPWM(_),s[o]=p.getNextSampleOfs(a[o]*m),this.m_onCounter++},e.prototype.getSamplesFF_=function(t,s,i){var h,o,_=this.m_osc2Sign*this.m_lfoDepth*(1/127),r=e.s_pipeArr[this.m_inPipe],n=this.m_oscMod1,m=this.m_oscMod2;for(n.setFrequency(e.getFrequency(this.m_freqNo)),h=s;i>h;h++)o=this.m_inSens,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(o*=m.getNextSample()*_),t[h]=n.getNextSampleOfs(r[h]*o),this.m_onCounter++},e.prototype.getSamplesI__=function(t,s,i){this.m_oscMod1.getSamplesWithSyncIn(t,e.s_syncSources[this.m_syncPipe],s,i)},e.prototype.getSamplesIP_=function(t,s,i){var h,o,_=s,r=this.m_osc2Sign*this.m_lfoDepth,n=e.s_syncSources[this.m_syncPipe],m=this.m_oscMod1,a=this.m_oscMod2;do h=_+e.s_lfoDelta,h>i&&(h=i),o=this.m_freqNo,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(o+=a.getNextSample()*r|0,a.addPhase(h-_-1)),m.setFrequency(e.getFrequency(o)),m.getSamplesWithSyncIn(t,n,_,h),this.m_onCounter+=h-_,_=h;while(i>_)},e.prototype.getSamplesIW_=function(s,i,h){var o,_,r=i,n=this.m_osc2Sign*this.m_lfoDepth*.01,m=this.m_oscSet1.getMod(t.MOscillator.PULSE),a=e.s_syncSources[this.m_syncPipe],p=this.m_oscMod1,c=this.m_oscMod2;do o=r+e.s_lfoDelta,o>h&&(o=h),_=this.m_pulseWidth,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(_+=c.getNextSample()*n,c.addPhase(o-r-1)),0>_?_=0:_>100&&(_=100),m.setPWM(_),p.getSamplesWithSyncIn(s,a,r,o),this.m_onCounter+=o-r,r=o;while(h>r)},e.prototype.getSamplesO__=function(t,s,i){this.m_oscMod1.getSamplesWithSyncOut(t,e.s_syncSources[this.m_syncPipe],s,i)},e.prototype.getSamplesOP_=function(t,s,i){var h,o,_=s,r=this.m_osc2Sign*this.m_lfoDepth,n=e.s_syncSources[this.m_syncPipe],m=this.m_oscMod1,a=this.m_oscMod2;do h=_+e.s_lfoDelta,h>i&&(h=i),o=this.m_freqNo,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(o+=a.getNextSample()*r|0,a.addPhase(h-_-1)),m.setFrequency(e.getFrequency(o)),m.getSamplesWithSyncOut(t,n,_,h),this.m_onCounter+=h-_,_=h;while(i>_)},e.prototype.getSamplesOW_=function(s,i,h){var o,_,r=i,n=this.m_osc2Sign*this.m_lfoDepth*.01,m=this.m_oscSet1.getMod(t.MOscillator.PULSE),a=e.s_syncSources[this.m_syncPipe],p=this.m_oscMod1,c=this.m_oscMod2;do o=r+e.s_lfoDelta,o>h&&(o=h),_=this.m_pulseWidth,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(_+=c.getNextSample()*n,c.addPhase(o-r-1)),0>_?_=0:_>100&&(_=100),m.setPWM(_),p.getSamplesWithSyncOut(s,a,r,o),this.m_onCounter+=o-r,r=o;while(h>r)},e.prototype.getSamples__P=function(t,s,i){var h,o,_=s,r=this.m_oscMod1;do h=_+e.s_lfoDelta,h>i&&(h=i),o=this.m_freqNo,0!==this.m_portDepth&&(o+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd*(h-_-1),this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),r.setFrequency(e.getFrequency(o)),r.getSamples(t,_,h),_=h;while(i>_);0===this.m_portDepth&&r.setFrequency(e.getFrequency(this.m_freqNo))},e.prototype.getSamples_PP=function(t,s,i){var h,o,_=s,r=this.m_osc2Sign*this.m_lfoDepth,n=this.m_oscMod1,m=this.m_oscMod2;do h=_+e.s_lfoDelta,h>i&&(h=i),o=this.m_freqNo,0!==this.m_portDepth&&(o+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd*(h-_-1),this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(o+=m.getNextSample()*r,m.addPhase(h-_-1),this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),n.setFrequency(e.getFrequency(o)),n.getSamples(t,_,h),this.m_onCounter+=h-_,_=h;while(i>_)},e.prototype.getSamples_WP=function(s,i,h){var o,_,r,n=i,m=this.m_osc2Sign*this.m_lfoDepth*.01,a=this.m_oscSet1.getMod(t.MOscillator.PULSE),p=this.m_oscMod1,c=this.m_oscMod2;do o=n+e.s_lfoDelta,o>h&&(o=h),r=this.m_freqNo,0!==this.m_portDepth&&(r+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd*(o-n-1),this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),p.setFrequency(e.getFrequency(r)),_=this.m_pulseWidth,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(_+=c.getNextSample()*m,c.addPhase(o-n-1)),0>_?_=0:_>100&&(_=100),a.setPWM(_),p.getSamples(s,n,o),this.m_onCounter+=o-n,n=o;while(h>n);0===this.m_portDepth&&p.setFrequency(e.getFrequency(this.m_freqNo))},e.prototype.getSamplesF_P=function(t,s,i){var h,o,_=this.m_inSens,r=e.s_pipeArr[this.m_inPipe],n=this.m_oscMod1;for(o=s;i>o;o++)h=this.m_freqNo,0!==this.m_portDepth&&(h+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd,this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),n.setFrequency(e.getFrequency(h)),t[o]=n.getNextSampleOfs(r[o]*_)},e.prototype.getSamplesFPP=function(t,s,i){var h,o,_=this.m_inSens,r=this.m_osc2Sign*this.m_lfoDepth,n=e.s_pipeArr[this.m_inPipe],m=this.m_oscMod1,a=this.m_oscMod2;for(h=s;i>h;h++)o=this.m_freqNo,0!==this.m_portDepth&&(o+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd,this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(o+=a.getNextSample()*r|0),m.setFrequency(e.getFrequency(o)),t[h]=m.getNextSampleOfs(n[h]*_),this.m_onCounter++},e.prototype.getSamplesFWP=function(s,i,h){var o,_,r,n=this.m_osc2Sign*this.m_lfoDepth*.01,m=this.m_oscSet1.getMod(t.MOscillator.PULSE),a=this.m_inSens,p=e.s_pipeArr[this.m_inPipe],c=this.m_oscMod1,l=this.m_oscMod2;for(o=i;h>o;o++)_=this.m_freqNo,0!==this.m_portDepth&&(_+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd,this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),c.setFrequency(e.getFrequency(_)),r=this.m_pulseWidth,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(r+=l.getNextSample()*n),0>r?r=0:r>100&&(r=100),m.setPWM(r),s[o]=c.getNextSampleOfs(p[o]*a),this.m_onCounter++},e.prototype.getSamplesFFP=function(t,s,i){var h,o,_,r=this.m_osc2Sign*this.m_lfoDepth*(1/127),n=e.s_pipeArr[this.m_inPipe],m=this.m_oscMod1,a=this.m_oscMod2;for(h=s;i>h;h++)o=this.m_freqNo,0!==this.m_portDepth&&(o+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd,this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),m.setFrequency(e.getFrequency(o)),_=this.m_inSens,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(_*=a.getNextSample()*r),t[h]=m.getNextSampleOfs(n[h]*_),this.m_onCounter++},e.prototype.getSamplesI_P=function(t,s,i){var h,o,_=s,r=e.s_syncSources[this.m_syncPipe],n=this.m_oscMod1;do h=_+e.s_lfoDelta,h>i&&(h=i),o=this.m_freqNo,0!==this.m_portDepth&&(o+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd*(h-_-1),this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),n.setFrequency(e.getFrequency(o)),n.getSamplesWithSyncIn(t,r,_,h),this.m_onCounter+=h-_,_=h;while(i>_);0===this.m_portDepth&&n.setFrequency(e.getFrequency(this.m_freqNo))},e.prototype.getSamplesIPP=function(t,s,i){var h,o,_=s,r=this.m_osc2Sign*this.m_lfoDepth,n=e.s_syncSources[this.m_syncPipe],m=this.m_oscMod1,a=this.m_oscMod2;do h=_+e.s_lfoDelta,h>i&&(h=i),o=this.m_freqNo,0!==this.m_portDepth&&(o+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd*(h-_-1),this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(o+=a.getNextSample()*r|0,a.addPhase(h-_-1)),m.setFrequency(e.getFrequency(o)),m.getSamplesWithSyncIn(t,n,_,h),this.m_onCounter+=h-_,_=h;while(i>_)},e.prototype.getSamplesIWP=function(s,i,h){var o,_,r,n=i,m=this.m_osc2Sign*this.m_lfoDepth*.01,a=this.m_oscSet1.getMod(t.MOscillator.PULSE),p=e.s_syncSources[this.m_syncPipe],c=this.m_oscMod1,l=this.m_oscMod2;do o=n+e.s_lfoDelta,o>h&&(o=h),_=this.m_freqNo,0!==this.m_portDepth&&(_+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd*(o-n-1),this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),c.setFrequency(e.getFrequency(_)),r=this.m_pulseWidth,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(r+=l.getNextSample()*m,l.addPhase(o-n-1)),0>r?r=0:r>100&&(r=100),a.setPWM(r),c.getSamplesWithSyncIn(s,p,n,o),this.m_onCounter+=o-n,n=o;while(h>n);0===this.m_portDepth&&c.setFrequency(e.getFrequency(this.m_freqNo))},e.prototype.getSamplesO_P=function(t,s,i){var h,o,_=s,r=e.s_syncSources[this.m_syncPipe],n=this.m_oscMod1;do h=_+e.s_lfoDelta,h>i&&(h=i),o=this.m_freqNo,0!==this.m_portDepth&&(o+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd*(h-_-1),this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),n.setFrequency(e.getFrequency(o)),n.getSamplesWithSyncOut(t,r,_,h),this.m_onCounter+=h-_,_=h;while(i>_);0===this.m_portDepth&&n.setFrequency(e.getFrequency(this.m_freqNo))},e.prototype.getSamplesOPP=function(t,s,i){var h,o,_=s,r=this.m_osc2Sign*this.m_lfoDepth,n=e.s_syncSources[this.m_syncPipe],m=this.m_oscMod1,a=this.m_oscMod2;do h=_+e.s_lfoDelta,h>i&&(h=i),o=this.m_freqNo,0!==this.m_portDepth&&(o+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd*(h-_-1),this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(o+=a.getNextSample()*r|0,a.addPhase(h-_-1)),m.setFrequency(e.getFrequency(o)),m.getSamplesWithSyncOut(t,n,_,h),this.m_onCounter+=h-_,_=h;while(i>_)},e.prototype.getSamplesOWP=function(s,i,h){var o,_,r,n=i,m=this.m_osc2Sign*this.m_lfoDepth*.01,a=this.m_oscSet1.getMod(t.MOscillator.PULSE),p=e.s_syncSources[this.m_syncPipe],c=this.m_oscMod1,l=this.m_oscMod2;do o=n+e.s_lfoDelta,o>h&&(o=h),_=this.m_freqNo,0!==this.m_portDepth&&(_+=0|this.m_portDepth,this.m_portDepth+=this.m_portDepthAdd*(o-n-1),this.m_portDepth*this.m_portDepthAdd>0&&(this.m_portDepth=0)),c.setFrequency(e.getFrequency(_)),r=this.m_pulseWidth,this.m_onCounter>=this.m_lfoDelay&&(0===this.m_lfoEnd||this.m_onCounter<this.m_lfoEnd)&&(r+=l.getNextSample()*m,l.addPhase(o-n-1)),0>r?r=0:r>100&&(r=100),a.setPWM(r),c.getSamplesWithSyncOut(s,p,n,o),this.m_onCounter+=o-n,n=o;while(h>n);0===this.m_portDepth&&c.setFrequency(e.getFrequency(this.m_freqNo))},e.PITCH_RESOLUTION=100,e.s_init=0,e.s_frequencyMap=new Array(128*e.PITCH_RESOLUTION),e.s_lfoDelta=245,e}();t.MChannel=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function e(t,e,s,i){this.setAttack(t),this.addPoint(e,s),this.setRelease(i),this.m_playing=!1,this.m_currentVal=0,this.m_releasing=!0,this.m_releaseStep=0}return e.boot=function(){if(!this.s_init){var t;for(this.SAMPLE_RATE=msgr.SAMPLE_RATE,this.s_volumeLen=256,t=0;3>t;t++)this.s_volumeMap[t]=new Array(this.s_volumeLen),this.s_volumeMap[t][0]=0;for(t=1;t<this.s_volumeLen;t++)this.s_volumeMap[0][t]=t/255,this.s_volumeMap[1][t]=Math.pow(10,(t-255)*(48/5100)),this.s_volumeMap[2][t]=Math.pow(10,(t-255)*(96/5100));this.s_init=1}},e.prototype.setAttack=function(e){this.m_envelopePoint=this.m_envelopeLastPoint=new t.MEnvelopePoint,this.m_envelopePoint.time=0,this.m_envelopePoint.level=0,this.addPoint(e,1)},e.prototype.setRelease=function(t){if(this.m_releaseTime=(t>0?t:1/127)*e.SAMPLE_RATE,this.m_playing&&!this.m_releasing){for(this.m_counter=this.m_timeInSamples,this.m_currentPoint=this.m_envelopePoint;null!==this.m_currentPoint.next&&this.m_counter>=this.m_currentPoint.next.time;)this.m_currentPoint=this.m_currentPoint.next,this.m_counter-=this.m_currentPoint.time;null==this.m_currentPoint.next?this.m_currentVal=this.m_currentPoint.level:(this.m_step=(this.m_currentPoint.next.level-this.m_currentPoint.level)/this.m_currentPoint.next.time,this.m_currentVal=this.m_currentPoint.level+this.m_step*this.m_counter)}},e.prototype.addPoint=function(s,i){var h=new t.MEnvelopePoint;h.time=s*e.SAMPLE_RATE,h.level=i,this.m_envelopeLastPoint.next=h,this.m_envelopeLastPoint=h},e.prototype.triggerEnvelope=function(t){this.m_playing=!0,this.m_releasing=!1,this.m_currentPoint=this.m_envelopePoint,this.m_currentVal=this.m_currentPoint.level=t?0:this.m_currentVal,this.m_step=(1-this.m_currentVal)/this.m_currentPoint.next.time,this.m_timeInSamples=this.m_counter=0},e.prototype.releaseEnvelope=function(){this.m_releasing=!0,this.m_releaseStep=this.m_currentVal/this.m_releaseTime},e.prototype.soundOff=function(){this.releaseEnvelope(),this.m_playing=!1},e.prototype.getNextAmplitudeLinear=function(){if(!this.m_playing)return 0;if(this.m_releasing)this.m_currentVal-=this.m_releaseStep;else if(null==this.m_currentPoint.next)this.m_currentVal=this.m_currentPoint.level;else{for(var t=!1;this.m_counter>=this.m_currentPoint.next.time;){if(this.m_counter=0,this.m_currentPoint=this.m_currentPoint.next,null==this.m_currentPoint.next){this.m_currentVal=this.m_currentPoint.level,t=!0;break}this.m_step=(this.m_currentPoint.next.level-this.m_currentPoint.level)/this.m_currentPoint.next.time,this.m_currentVal=this.m_currentPoint.level,t=!0}t||(this.m_currentVal+=this.m_step),this.m_counter++}return this.m_currentVal<=0&&this.m_releasing&&(this.m_playing=!1,this.m_currentVal=0),this.m_timeInSamples++,this.m_currentVal},e.prototype.ampSamplesLinear=function(t,e,s,i){var h,o=this.m_currentVal*i;for(h=e;s>h;h++)if(this.m_playing){if(this.m_releasing)this.m_currentVal-=this.m_releaseStep,o=this.m_currentVal*i;else if(null==this.m_currentPoint.next);else{for(var _=!1;this.m_counter>=this.m_currentPoint.next.time;){if(this.m_counter=0,this.m_currentPoint=this.m_currentPoint.next,null==this.m_currentPoint.next){this.m_currentVal=this.m_currentPoint.level,_=!0;break}this.m_step=(this.m_currentPoint.next.level-this.m_currentPoint.level)/this.m_currentPoint.next.time,this.m_currentVal=this.m_currentPoint.level,_=!0}_||(this.m_currentVal+=this.m_step),o=this.m_currentVal*i,this.m_counter++}this.m_currentVal<=0&&this.m_releasing&&(this.m_playing=!1,o=this.m_currentVal=0),this.m_timeInSamples++,t[h]*=o}else t[h]=0},e.prototype.ampSamplesNonLinear=function(t,s,i,h,o){var _;for(_=s;i>_;_++)if(this.m_playing){if(this.m_releasing)this.m_currentVal-=this.m_releaseStep;else if(null==this.m_currentPoint.next)this.m_currentVal=this.m_currentPoint.level;else{for(var r=!1;this.m_counter>=this.m_currentPoint.next.time;){if(this.m_counter=0,this.m_currentPoint=this.m_currentPoint.next,null==this.m_currentPoint.next){this.m_currentVal=this.m_currentPoint.level,r=!0;break}this.m_step=(this.m_currentPoint.next.level-this.m_currentPoint.level)/this.m_currentPoint.next.time,this.m_currentVal=this.m_currentPoint.level,r=!0}r||(this.m_currentVal+=this.m_step),this.m_counter++}this.m_currentVal<=0&&this.m_releasing&&(this.m_playing=!1,this.m_currentVal=0),this.m_timeInSamples++;var n=255*this.m_currentVal|0;n>255&&(n=0),t[_]*=e.s_volumeMap[o][n]*h}else t[_]=0},e.prototype.isPlaying=function(){return this.m_playing},e.prototype.isReleasing=function(){return this.m_releasing},e.s_init=0,e.s_volumeMap=new Array(3),e}();t.MEnvelope=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function t(){this.next=null}return t}();t.MEnvelopePoint=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function t(t){this.TEMPO_SCALE=100,this.set(1,0,0),this.setTick(t)}return t.prototype.set=function(t,e,s){this.m_status=t,this.m_data0=e,this.m_data1=s},t.prototype.setEOT=function(){this.set(0,0,0)},t.prototype.setNoteOn=function(t,e){this.set(2,t,e)},t.prototype.setNoteOff=function(t,e){this.set(3,t,e)},t.prototype.setTempo=function(t){this.set(4,t*this.TEMPO_SCALE,0)},t.prototype.setVolume=function(t){this.set(5,t,0)},t.prototype.setNote=function(t){this.set(6,t,0)},t.prototype.setForm=function(t,e){this.set(7,t,e)},t.prototype.setEnvelope1Atk=function(t){this.set(8,t,0)},t.prototype.setEnvelope1Point=function(t,e){this.set(9,t,e)},t.prototype.setEnvelope1Rel=function(t){this.set(10,t,0)},t.prototype.setEnvelope2Atk=function(t){this.set(24,t,0)},t.prototype.setEnvelope2Point=function(t,e){this.set(25,t,e)},t.prototype.setEnvelope2Rel=function(t){this.set(26,t,0)},t.prototype.setNoiseFreq=function(t){this.set(11,t,0)},t.prototype.setPWM=function(t){this.set(12,t,0)},t.prototype.setPan=function(t){this.set(13,t,0)},t.prototype.setFormant=function(t){this.set(14,t,0)},t.prototype.setDetune=function(t){this.set(15,t,0)},t.prototype.setLFOFMSF=function(t,e){this.set(16,t,e)},t.prototype.setLFODPWD=function(t,e){this.set(17,t,e)},t.prototype.setLFODLTM=function(t,e){this.set(18,t,e)},t.prototype.setLFOTarget=function(t){this.set(19,t,0)},t.prototype.setLPFSWTAMT=function(t,e){this.set(20,t,e)},t.prototype.setLPFFRQRES=function(t,e){this.set(21,t,e)},t.prototype.setClose=function(){this.set(22,0,0)},t.prototype.setVolMode=function(t){this.set(23,t,0)},t.prototype.setInput=function(t,e){this.set(27,t,e)},t.prototype.setOutput=function(t,e){this.set(28,t,e)},t.prototype.setExpression=function(t){this.set(29,t,0)},t.prototype.setRing=function(t,e){this.set(30,t,e)},t.prototype.setSync=function(t,e){this.set(31,t,e)},t.prototype.setDelta=function(t){this.m_delta=t},t.prototype.setTick=function(t){this.m_tick=t},t.prototype.setPortamento=function(t,e){this.set(32,t,e)},t.prototype.setMidiPort=function(t){this.set(33,t,0)},t.prototype.setMidiPortRate=function(t){this.set(34,t,0)},t.prototype.setPortBase=function(t){this.set(35,t,0)},t.prototype.setPoly=function(t){this.set(36,t,0)},t.prototype.setResetAll=function(){this.set(38,0,0)},t.prototype.setSoundOff=function(){this.set(37,0,0)},t.prototype.setHwLfo=function(t,e,s,i,h,o,_){this.set(39,(3&t)<<27|(255&e)<<19|(127&s)<<12|(127&i)<<5|(7&h)<<2|3&o,0)},t.prototype.getStatus=function(){return this.m_status},t.prototype.getDelta=function(){return this.m_delta},t.prototype.getTick=function(){return this.m_tick},t.prototype.getNoteNo=function(){return this.m_data0},t.prototype.getVelocity=function(){
return this.m_data1},t.prototype.getTempo=function(){return Math.floor(this.m_data0)/this.TEMPO_SCALE},t.prototype.getVolume=function(){return this.m_data0},t.prototype.getForm=function(){return this.m_data0},t.prototype.getSubForm=function(){return this.m_data1},t.prototype.getEnvelopeA=function(){return this.m_data0},t.prototype.getEnvelopeT=function(){return this.m_data0},t.prototype.getEnvelopeL=function(){return this.m_data1},t.prototype.getEnvelopeR=function(){return this.m_data0},t.prototype.getNoiseFreq=function(){return this.m_data0},t.prototype.getPWM=function(){return this.m_data0},t.prototype.getPan=function(){return this.m_data0},t.prototype.getVowel=function(){return this.m_data0},t.prototype.getDetune=function(){return this.m_data0},t.prototype.getLFODepth=function(){return this.m_data0},t.prototype.getLFOWidth=function(){return this.m_data1},t.prototype.getLFOForm=function(){return this.m_data0},t.prototype.getLFOSubForm=function(){return this.m_data1},t.prototype.getLFODelay=function(){return this.m_data0},t.prototype.getLFOTime=function(){return this.m_data1},t.prototype.getLFOTarget=function(){return this.m_data0},t.prototype.getLPFSwt=function(){return this.m_data0},t.prototype.getLPFAmt=function(){return this.m_data1},t.prototype.getLPFFrq=function(){return this.m_data0},t.prototype.getLPFRes=function(){return this.m_data1},t.prototype.getVolMode=function(){return this.m_data0},t.prototype.getInputSens=function(){return this.m_data0},t.prototype.getInputPipe=function(){return this.m_data1},t.prototype.getOutputMode=function(){return this.m_data0},t.prototype.getOutputPipe=function(){return this.m_data1},t.prototype.getExpression=function(){return this.m_data0},t.prototype.getRingSens=function(){return this.m_data0},t.prototype.getRingInput=function(){return this.m_data1},t.prototype.getSyncMode=function(){return this.m_data0},t.prototype.getSyncPipe=function(){return this.m_data1},t.prototype.getPorDepth=function(){return this.m_data0},t.prototype.getPorLen=function(){return this.m_data1},t.prototype.getMidiPort=function(){return this.m_data0},t.prototype.getMidiPortRate=function(){return this.m_data0},t.prototype.getPortBase=function(){return this.m_data0},t.prototype.getVoiceCount=function(){return this.m_data0},t.prototype.getHwLfoData=function(){return this.m_data0},t}();t.MEvent=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function e(){e.SAMPLE_RATE||(e.SAMPLE_RATE=msgr.SAMPLE_RATE),this.setSwitch(0)}return e.prototype.reset=function(){this.m_t1=this.m_t2=this.m_b0=this.m_b1=this.m_b2=this.m_b3=this.m_b4=0},e.prototype.setSwitch=function(t){this.reset(),this.sw=t},e.prototype.checkToSilence=function(){switch(this.sw){case 0:return!1;case 1:case-1:return-1e-6<=this.m_b0&&this.m_b0<=1e-6&&-1e-6<=this.m_b1&&this.m_b1<=1e-6;case 2:case-2:return-1e-6<=this.m_t1&&this.m_t1<=1e-6&&-1e-6<=this.m_t2&&this.m_t2<=1e-6&&-1e-6<=this.m_b0&&this.m_b0<=1e-6&&-1e-6<=this.m_b1&&this.m_b1<=1e-6&&-1e-6<=this.m_b2&&this.m_b2<=1e-6&&-1e-6<=this.m_b3&&this.m_b3<=1e-6&&-1e-6<=this.m_b4&&this.m_b4<=1e-6}return!1},e.prototype.run=function(t,e,s,i,h,o,_,r){switch(this.sw){case-2:this.hpf2(t,e,s,i,h,o,_,r);break;case-1:this.hpf1(t,e,s,i,h,o,_,r);break;case 0:return;case 1:this.lpf1(t,e,s,i,h,o,_,r);break;case 2:this.lpf2(t,e,s,i,h,o,_,r)}},e.prototype.lpf1=function(s,i,h,o,_,r,n,m){var a,p,c,l=this.m_b0,u=this.m_b1,f=m*(2*Math.PI/(440*e.SAMPLE_RATE));if(r>1e-4||-1e-4>r)for(a=i;h>a;a++)c=t.MChannel.getFrequency(_+r*o.getNextAmplitudeLinear())*f,1/127>c&&(c=0),c>.9999&&(c=.9999),p=n+n/(1-c),l+=c*(s[a]-l+p*(l-u)),s[a]=u+=c*(l-u);else for(c=t.MChannel.getFrequency(_)*f,1/127>c&&(c=0),c>.9999&&(c=.9999),p=n+n/(1-c),a=i;h>a;a++)l+=c*(s[a]-l+p*(l-u)),s[a]=u+=c*(l-u);this.m_b0=l,this.m_b1=u},e.prototype.lpf2=function(s,i,h,o,_,r,n,m){for(var a=this.m_t1,p=this.m_t2,c=this.m_b0,l=this.m_b1,u=this.m_b2,f=this.m_b3,g=this.m_b4,S=m*(2*Math.PI/(440*e.SAMPLE_RATE)),v=i;h>v;v++){var y=t.MChannel.getFrequency(_+r*o.getNextAmplitudeLinear())*S;1/127>y&&(y=0),y>1&&(y=1);var E=1-y,M=y+.8*y*E,P=M+M-1;E=n*(1+.5*E*(1-E+5.6*E*E));var d=s[v];d-=E*g,a=l,l=(d+c)*M-l*P,p=u,u=(l+a)*M-u*P,a=f,f=(u+p)*M-f*P,g=(f+a)*M-g*P,g-=g*g*g*.166667,c=d,s[v]=g}this.m_t1=a,this.m_t2=p,this.m_b0=c,this.m_b1=l,this.m_b2=u,this.m_b3=f,this.m_b4=g},e.prototype.hpf1=function(s,i,h,o,_,r,n,m){var a,p,c,l,u=this.m_b0,f=this.m_b1,g=m*(2*Math.PI/(440*e.SAMPLE_RATE));if(r>1e-4||-1e-4>r)for(a=i;h>a;a++)c=t.MChannel.getFrequency(_+r*o.getNextAmplitudeLinear())*g,1/127>c&&(c=0),c>.9999&&(c=.9999),p=n+n/(1-c),l=s[a],u+=c*(l-u+p*(u-f)),f+=c*(u-f),s[a]=l-u;else for(c=t.MChannel.getFrequency(_)*g,1/127>c&&(c=0),c>.9999&&(c=.9999),p=n+n/(1-c),a=i;h>a;a++)l=s[a],u+=c*(l-u+p*(u-f)),f+=c*(u-f),s[a]=l-u;this.m_b0=u,this.m_b1=f},e.prototype.hpf2=function(s,i,h,o,_,r,n,m){for(var a=this.m_t1,p=this.m_t2,c=this.m_b0,l=this.m_b1,u=this.m_b2,f=this.m_b3,g=this.m_b4,S=m*(2*Math.PI/(440*e.SAMPLE_RATE)),v=i;h>v;v++){var y=t.MChannel.getFrequency(_+r*o.getNextAmplitudeLinear())*S;1/127>y&&(y=0),y>1&&(y=1);var E=1-y,M=y+.8*y*E,P=M+M-1;E=n*(1+.5*E*(1-E+5.6*E*E));var d=s[v];d-=E*g,a=l,l=(d+c)*M-l*P,p=u,u=(l+a)*M-u*P,a=f,f=(u+p)*M-f*P,g=(f+a)*M-g*P,g-=g*g*g*.166667,c=d,s[v]=d-g}this.m_t1=a,this.m_t2=p,this.m_b0=c,this.m_b1=l,this.m_b2=u,this.m_b3=f,this.m_b4=g},e.SAMPLE_RATE=null,e}();t.MFilter=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function t(){this.m_ca0=811044e-11,this.m_ca1=8.943665402,this.m_ca2=-36.83889529,this.m_ca3=92.01697887,this.m_ca4=-154.337906,this.m_ca5=181.6233289,this.m_ca6=-151.8651235,this.m_ca7=89.09614114,this.m_ca8=-35.10298511,this.m_ca9=8.388101016,this.m_caA=-.923313471,this.m_ce0=436215e-11,this.m_ce1=8.90438318,this.m_ce2=-36.55179099,this.m_ce3=91.05750846,this.m_ce4=-152.422234,this.m_ce5=179.1170248,this.m_ce6=-149.6496211,this.m_ce7=87.78352223,this.m_ce8=-34.60687431,this.m_ce9=8.282228154,this.m_ceA=-.914150747,this.m_ci0=333819e-11,this.m_ci1=8.893102966,this.m_ci2=-36.49532826,this.m_ci3=90.96543286,this.m_ci4=-152.4545478,this.m_ci5=179.4835618,this.m_ci6=-150.315433,this.m_ci7=88.43409371,this.m_ci8=-34.98612086,this.m_ci9=8.407803364,this.m_ciA=-.932568035,this.m_co0=113572e-11,this.m_co1=8.994734087,this.m_co2=-37.2084849,this.m_co3=93.22900521,this.m_co4=-156.6929844,this.m_co5=184.596544,this.m_co6=-154.3755513,this.m_co7=90.49663749,this.m_co8=-35.58964535,this.m_co9=8.478996281,this.m_coA=-.929252233,this.m_cu0=4.09431e-7,this.m_cu1=8.997322763,this.m_cu2=-37.20218544,this.m_cu3=93.11385476,this.m_cu4=-156.2530937,this.m_cu5=183.7080141,this.m_cu6=-153.2631681,this.m_cu7=89.59539726,this.m_cu8=-35.12454591,this.m_cu9=8.338655623,this.m_cuA=-.910251753,this.m_vowel=t.VOWEL_A,this.m_power=!1,this.reset()}return t.prototype.setVowel=function(t){this.m_power=!0,this.m_vowel=t},t.prototype.disable=function(){this.m_power=!1,this.reset()},t.prototype.reset=function(){this.m_m0=this.m_m1=this.m_m2=this.m_m3=this.m_m4=this.m_m5=this.m_m6=this.m_m7=this.m_m8=this.m_m9=0},t.prototype.checkToSilence=function(){return this.m_power&&-1e-6<=this.m_m0&&this.m_m0<=1e-6&&-1e-6<=this.m_m1&&this.m_m1<=1e-6&&-1e-6<=this.m_m2&&this.m_m2<=1e-6&&-1e-6<=this.m_m3&&this.m_m3<=1e-6&&-1e-6<=this.m_m4&&this.m_m4<=1e-6&&-1e-6<=this.m_m5&&this.m_m5<=1e-6&&-1e-6<=this.m_m6&&this.m_m6<=1e-6&&-1e-6<=this.m_m7&&this.m_m7<=1e-6&&-1e-6<=this.m_m8&&this.m_m8<=1e-6&&-1e-6<=this.m_m9&&this.m_m9<=1e-6},t.prototype.run=function(t,e,s){if(this.m_power){var i;switch(this.m_vowel){case 0:for(i=e;s>i;i++)t[i]=this.m_ca0*t[i]+this.m_ca1*this.m_m0+this.m_ca2*this.m_m1+this.m_ca3*this.m_m2+this.m_ca4*this.m_m3+this.m_ca5*this.m_m4+this.m_ca6*this.m_m5+this.m_ca7*this.m_m6+this.m_ca8*this.m_m7+this.m_ca9*this.m_m8+this.m_caA*this.m_m9,this.m_m9=this.m_m8,this.m_m8=this.m_m7,this.m_m7=this.m_m6,this.m_m6=this.m_m5,this.m_m5=this.m_m4,this.m_m4=this.m_m3,this.m_m3=this.m_m2,this.m_m2=this.m_m1,this.m_m1=this.m_m0,this.m_m0=t[i];return;case 1:for(i=e;s>i;i++)t[i]=this.m_ce0*t[i]+this.m_ce1*this.m_m0+this.m_ce2*this.m_m1+this.m_ce3*this.m_m2+this.m_ce4*this.m_m3+this.m_ce5*this.m_m4+this.m_ce6*this.m_m5+this.m_ce7*this.m_m6+this.m_ce8*this.m_m7+this.m_ce9*this.m_m8+this.m_ceA*this.m_m9,this.m_m9=this.m_m8,this.m_m8=this.m_m7,this.m_m7=this.m_m6,this.m_m6=this.m_m5,this.m_m5=this.m_m4,this.m_m4=this.m_m3,this.m_m3=this.m_m2,this.m_m2=this.m_m1,this.m_m1=this.m_m0,this.m_m0=t[i];return;case 2:for(i=e;s>i;i++)t[i]=this.m_ci0*t[i]+this.m_ci1*this.m_m0+this.m_ci2*this.m_m1+this.m_ci3*this.m_m2+this.m_ci4*this.m_m3+this.m_ci5*this.m_m4+this.m_ci6*this.m_m5+this.m_ci7*this.m_m6+this.m_ci8*this.m_m7+this.m_ci9*this.m_m8+this.m_ciA*this.m_m9,this.m_m9=this.m_m8,this.m_m8=this.m_m7,this.m_m7=this.m_m6,this.m_m6=this.m_m5,this.m_m5=this.m_m4,this.m_m4=this.m_m3,this.m_m3=this.m_m2,this.m_m2=this.m_m1,this.m_m1=this.m_m0,this.m_m0=t[i];return;case 3:for(i=e;s>i;i++)t[i]=this.m_co0*t[i]+this.m_co1*this.m_m0+this.m_co2*this.m_m1+this.m_co3*this.m_m2+this.m_co4*this.m_m3+this.m_co5*this.m_m4+this.m_co6*this.m_m5+this.m_co7*this.m_m6+this.m_co8*this.m_m7+this.m_co9*this.m_m8+this.m_coA*this.m_m9,this.m_m9=this.m_m8,this.m_m8=this.m_m7,this.m_m7=this.m_m6,this.m_m6=this.m_m5,this.m_m5=this.m_m4,this.m_m4=this.m_m3,this.m_m3=this.m_m2,this.m_m2=this.m_m1,this.m_m1=this.m_m0,this.m_m0=t[i];return;case 4:for(i=e;s>i;i++)t[i]=this.m_cu0*t[i]+this.m_cu1*this.m_m0+this.m_cu2*this.m_m1+this.m_cu3*this.m_m2+this.m_cu4*this.m_m3+this.m_cu5*this.m_m4+this.m_cu6*this.m_m5+this.m_cu7*this.m_m6+this.m_cu8*this.m_m7+this.m_cu9*this.m_m8+this.m_cuA*this.m_m9,this.m_m9=this.m_m8,this.m_m8=this.m_m7,this.m_m7=this.m_m6,this.m_m6=this.m_m5,this.m_m5=this.m_m4,this.m_m4=this.m_m3,this.m_m3=this.m_m2,this.m_m2=this.m_m1,this.m_m1=this.m_m0,this.m_m0=t[i];return}}},t.VOWEL_A=0,t.VOWEL_E=1,t.VOWEL_I=2,t.VOWEL_O=3,t.VOWEL_U=4,t}();t.MFormant=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function e(){this.m_sequencer=new t.MSequencer}return e.isWhitespace=function(t){return" "===t||" "===t||"\n"===t||"\r"===t||" "===t?!0:!1},e.removeWhitespace=function(t){return t.replace(new RegExp("[ \n\r \f]+","g"),"")},e.remove=function(t,e,s){return t.substring(0,e)+t.substring(s+1)},e.prototype.getWarnings=function(){return this.m_warning},e.prototype.warning=function(e,s){this.m_warning+=t.MWarning.getString(e,s)+"\n"},e.prototype.len2tick=function(t){return 0===t?this.m_length:384/t|0},e.prototype.note=function(t){if(t+=this.m_noteShift+this.getKeySig(),"*"===this.getChar())this.m_beforeNote=t+12*this.m_octave,this.m_portamento=1,this.next();else{var e,s,i,h=0,o=0,_=0===this.m_keyoff?0:1;for(this.m_keyoff=1;;){if("%"!==this.getChar()?e=0:(e=1,this.next()),s=this.getUInt(0),1===o&&0===s){this.m_keyoff=0;break}if(i=e?s:this.len2tick(s),h+=this.getDot(i),o=0,"&"!==this.getChar())break;o=1,this.next()}1===this.m_portamento&&this.m_tracks[this.m_trackNo].recPortamento(this.m_beforeNote-(t+12*this.m_octave),h),this.m_tracks[this.m_trackNo].recNote(t+12*this.m_octave,h,this.m_velocity,_,this.m_keyoff),1===this.m_portamento&&(this.m_tracks[this.m_trackNo].recPortamento(0,0),this.m_portamento=0)}},e.prototype.rest=function(){var t=0;"%"===this.getChar()&&(t=1,this.next());var e;e=this.getUInt(0);var s=t?e:this.len2tick(e);s=this.getDot(s),this.m_tracks[this.m_trackNo].recRest(s)},e.prototype.atmark=function(){var s,i,h,o,_=this,r=this.getChar(),n=1,m=0,a=64,p=32,c=0,l=0,u=0,f=0,g=0;switch(r){case"v":this.m_velDetail=!0,this.next(),this.m_velocity=this.getUInt(this.m_velocity),this.m_velocity>127&&(this.m_velocity=127);break;case"x":this.next(),n=this.getUInt(127),n>127&&(n=127),this.m_tracks[this.m_trackNo].recExpression(n);break;case"e":!function(){var t,e=new Array,s=new Array;for(_.next(),n=_.getUInt(n),","===_.getChar()&&_.next(),m=_.getUInt(m),t=_.m_letter;;){if(","!==_.getChar())break;if(_.next(),t=_.m_letter-1,a=_.getUInt(a),","!==_.getChar()){_.m_letter=t;break}_.next(),p=_.getUInt(p),e.push(a),s.push(p)}0===e.length&&(e.push(a),s.push(p)),","===_.getChar()&&_.next(),c=_.getUInt(c),_.m_tracks[_.m_trackNo].recEnvelope(n,m,e,s,c)}();break;case"m":if(this.next(),"h"===this.getChar()){this.next(),f=0,g=0,s=0,i=0,h=0,o=0,p=1;do{if(f=this.getUInt(f),","!==this.getChar())break;if(this.next(),g=this.getUInt(g),","!==this.getChar())break;if(this.next(),s=this.getUInt(s),","!==this.getChar())break;if(this.next(),i=this.getUInt(i),","!==this.getChar())break;if(this.next(),h=this.getUInt(h),","!==this.getChar())break;if(this.next(),o=this.getUInt(o),","!==this.getChar())break;this.next(),p=this.getUInt(p)}while(!1);this.m_tracks[this.m_trackNo].recHwLfo(f,g,s,i,h,o,p)}break;case"n":this.next(),"s"===this.getChar()?(this.next(),this.m_noteShift+=this.getSInt(0)):(n=this.getUInt(0),(0>n||n>127)&&(n=0),this.m_tracks[this.m_trackNo].recNoiseFreq(n));break;case"w":this.next(),n=this.getSInt(50),0>n?(n>-1&&(n=-1),-99>n&&(n=-99)):(1>n&&(n=1),n>99&&(n=99)),this.m_tracks[this.m_trackNo].recPWM(n);break;case"p":this.next(),"l"===this.getChar()?(this.next(),n=this.getUInt(this.m_polyVoice),n=Math.max(0,Math.min(this.m_polyVoice,n)),this.m_tracks[this.m_trackNo].recPoly(n)):(n=this.getUInt(64),1>n&&(n=1),n>127&&(n=127),this.m_tracks[this.m_trackNo].recPan(n));break;case"'":if(this.next(),n=this.m_string.indexOf("'",this.m_letter),n>=0){var S=this.m_string.substring(this.m_letter,n),v=0;switch(S){case"a":v=t.MFormant.VOWEL_A;break;case"e":v=t.MFormant.VOWEL_E;break;case"i":v=t.MFormant.VOWEL_I;break;case"o":v=t.MFormant.VOWEL_O;break;case"u":v=t.MFormant.VOWEL_U;break;default:v=-1}this.m_tracks[this.m_trackNo].recFormant(v),this.m_letter=n+1}break;case"d":this.next(),n=this.getSInt(0),this.m_tracks[this.m_trackNo].recDetune(n);break;case"l":!function(){var t=0,e=0,s=1,i=0,h=1,o=0,r=0,n=0;_.next(),t=_.getUInt(t),","===_.getChar()&&_.next(),e=_.getUInt(e),","===_.getChar()&&(_.next(),"-"===_.getChar()&&(h=-1,_.next()),s=(_.getUInt(s)+1)*h,"-"===_.getChar()&&(_.next(),i=_.getUInt(0)),","===_.getChar()&&(_.next(),o=_.getUInt(o),","===_.getChar()&&(_.next(),r=_.getUInt(r),","===_.getChar()&&(_.next(),n=_.getUInt(n))))),_.m_tracks[_.m_trackNo].recLFO(t,e,s,i,o,r,n)}();break;case"f":!function(){var t=0,e=0,s=0,i=0;_.next(),t=_.getSInt(t),","===_.getChar()&&(_.next(),e=_.getSInt(e),","===_.getChar()&&(_.next(),s=_.getUInt(s),","===_.getChar()&&(_.next(),i=_.getUInt(i)))),_.m_tracks[_.m_trackNo].recLPF(t,e,s,i)}();break;case"q":this.next(),this.m_tracks[this.m_trackNo].recGate2(2*this.getUInt(2));break;case"i":l=0,this.next(),l=this.getUInt(l),","===this.getChar()&&(this.next(),m=this.getUInt(m),m>this.m_maxPipe&&(m=this.m_maxPipe)),this.m_tracks[this.m_trackNo].recInput(l,m);break;case"o":u=0,this.next(),u=this.getUInt(u),","===this.getChar()&&(this.next(),m=this.getUInt(m),m>this.m_maxPipe&&(this.m_maxPipe=m,this.m_maxPipe>=e.MAX_PIPE&&(this.m_maxPipe=m=e.MAX_PIPE))),this.m_tracks[this.m_trackNo].recOutput(u,m);break;case"r":!function(){l=0,_.next(),l=_.getUInt(l),","===_.getChar()&&(_.next(),m=_.getUInt(m),m>_.m_maxPipe&&(m=_.m_maxPipe)),_.m_tracks[_.m_trackNo].recRing(l,m)}();break;case"s":u=0,this.next(),u=this.getUInt(u),","===this.getChar()&&(this.next(),m=this.getUInt(m),1===u?m>this.m_maxSyncSource&&(this.m_maxSyncSource=m,this.m_maxSyncSource>=e.MAX_SYNCSOURCE&&(this.m_maxSyncSource=m=e.MAX_SYNCSOURCE)):2===u&&m>this.m_maxSyncSource&&(m=this.m_maxSyncSource)),this.m_tracks[this.m_trackNo].recSync(u,m);break;case"u":this.next();var y;switch(u=this.getUInt(0)){case 0:case 1:this.m_tracks[this.m_trackNo].recMidiPort(u);break;case 2:y=0,","===this.getChar()&&(this.next(),y=this.getUInt(0),0>y&&(y=0),y>127&&(y=127)),this.m_tracks[this.m_trackNo].recMidiPortRate(1*y);break;case 3:if(","===this.getChar()){this.next();var E,M=-1;switch("o"!==this.getChar()?E=this.m_octave:(this.next(),E=this.getUInt(0)),r=this.getChar()){case"c":M=0;break;case"d":M=2;break;case"e":M=4;break;case"f":M=5;break;case"g":M=7;break;case"a":M=9;break;case"b":M=11}M>=0?(this.next(),M+=this.m_noteShift+this.getKeySig(),M+=12*E):M=this.getUInt(60),0>M&&(M=0),M>127&&(M=127),this.m_tracks[this.m_trackNo].recPortBase(M)}}break;default:this.m_form=this.getUInt(this.m_form),m=0,"-"===this.getChar()&&(this.next(),m=this.getUInt(0)),this.m_tracks[this.m_trackNo].recForm(this.m_form,m)}},e.prototype.firstLetter=function(){var e,s,i=this.getCharNext();switch(i){case"c":this.note(0);break;case"d":this.note(2);break;case"e":this.note(4);break;case"f":this.note(5);break;case"g":this.note(7);break;case"a":this.note(9);break;case"b":this.note(11);break;case"r":this.rest();break;case"o":this.m_octave=this.getUInt(this.m_octave),this.m_octave<-2&&(this.m_octave=-2),this.m_octave>8&&(this.m_octave=8);break;case"v":this.m_velDetail=!1,this.m_velocity=8*this.getUInt((this.m_velocity-7)/8)+7,this.m_velocity<0&&(this.m_velocity=0),this.m_velocity>127&&(this.m_velocity=127);break;case"(":case")":s=this.getUInt(1),"("===i&&this.m_velDir||")"===i&&!this.m_velDir?(this.m_velocity+=this.m_velDetail?1*s:8*s,this.m_velocity>127&&(this.m_velocity=127)):(this.m_velocity-=this.m_velDetail?1*s:8*s,this.m_velocity<0&&(this.m_velocity=0));break;case"l":this.m_length=this.len2tick(this.getUInt(0)),this.m_length=this.getDot(this.m_length);break;case"t":this.m_tempo=this.getUNumber(this.m_tempo),this.m_tempo<1&&(this.m_tempo=1),this.m_tracks[t.MTrack.TEMPO_TRACK].recTempo(this.m_tracks[this.m_trackNo].getRecGlobalTick(),this.m_tempo);break;case"q":this.m_gate=this.getUInt(this.m_gate),this.m_tracks[this.m_trackNo].recGate(this.m_gate/this.m_maxGate);break;case"<":this.m_relativeDir?this.m_octave++:this.m_octave--;break;case">":this.m_relativeDir?this.m_octave--:this.m_octave++;break;case";":this.m_keyoff=1,this.m_tracks[this.m_trackNo].getNumEvents()>0&&this.m_trackNo++,this.m_tracks[this.m_trackNo]=this.createTrack();break;case"@":this.atmark();break;case"x":this.m_tracks[this.m_trackNo].recVolMode(this.getUInt(1));break;case"n":e=this.getChar(),"s"===e?(this.next(),this.m_noteShift=this.getSInt(this.m_noteShift)):this.warning(t.MWarning.UNKNOWN_COMMAND,i+e);break;case"[":this.m_tracks[this.m_trackNo].recChordStart();break;case"]":this.m_tracks[this.m_trackNo].recChordEnd();break;default:var h=i.charCodeAt(0);128>h&&this.warning(t.MWarning.UNKNOWN_COMMAND,i)}},e.prototype.getCharNext=function(){return this.m_letter<this.m_string.length?this.m_string.charAt(this.m_letter++):""},e.prototype.getChar=function(){return this.m_letter<this.m_string.length?this.m_string.charAt(this.m_letter):""},e.prototype.next=function(t){void 0===t&&(t=1),this.m_letter+=1},e.prototype.getKeySig=function(){for(var t=0,e=1;e;){var s=this.getChar();switch(s){case"+":case"#":t++,this.next();break;case"-":t--,this.next();break;default:e=0}}return t},e.prototype.getUInt=function(t){for(var e=0,s=this.m_letter,i=1;i;){var h=this.getChar();switch(h){case"0":e=10*e+0,this.next();break;case"1":e=10*e+1,this.next();break;case"2":e=10*e+2,this.next();break;case"3":e=10*e+3,this.next();break;case"4":e=10*e+4,this.next();break;case"5":e=10*e+5,this.next();break;case"6":e=10*e+6,this.next();break;case"7":e=10*e+7,this.next();break;case"8":e=10*e+8,this.next();break;case"9":e=10*e+9,this.next();break;default:i=0}}return this.m_letter===s?t:e},e.prototype.getUNumber=function(t){var e=this.getUInt(0|t),s=1;if("."===this.getChar()){this.next();for(var i=!0;i;){var h=this.getChar();switch(s*=.1,h){case"0":e+=0*s,this.next();break;case"1":e+=1*s,this.next();break;case"2":e+=2*s,this.next();break;case"3":e+=3*s,this.next();break;case"4":e+=4*s,this.next();break;case"5":e+=5*s,this.next();break;case"6":e+=6*s,this.next();break;case"7":e+=7*s,this.next();break;case"8":e+=8*s,this.next();break;case"9":e+=9*s,this.next();break;default:i=!1}}}return e},e.prototype.getSInt=function(t){var e=this.getChar(),s=1;return"-"===e?(s=-1,this.next()):"+"===e&&this.next(),this.getUInt(t)*s},e.prototype.getDot=function(t){for(var e=this.getChar(),s=t;"."===e;)this.next(),s/=2,t+=s,e=this.getChar();return t},e.prototype.createTrack=function(){return this.m_octave=4,this.m_velocity=100,this.m_noteShift=0,new t.MTrack},e.prototype.begin=function(){this.m_letter=0},e.prototype.process=function(){for(this.begin();this.m_letter<this.m_string.length;)this.firstLetter()},e.prototype.processRepeat=function(){this.m_string=this.m_string.toLowerCase(),this.begin();for(var e=new Array,s=new Array,i=new Array,h=new Array,o=-1;this.m_letter<this.m_string.length;){var _=this.getCharNext();switch(_){case"/":":"===this.getChar()?(this.next(),s[++o]=this.m_letter-2,e[o]=this.getUInt(2),i[o]=this.m_letter,h[o]=-1):o>=0&&(h[o]=this.m_letter-1,this.m_string=this.m_string.substring(0,this.m_letter-1)+this.m_string.substring(this.m_letter),this.m_letter--);break;case":":if("/"===this.getChar()&&o>=0){this.next();for(var r=this.m_string.substring(i[o],this.m_letter-2),n=this.m_string.substring(0,s[o]),m=0;m<e[o];m++)n+=m<e[o]-1||h[o]<0?r:this.m_string.substring(i[o],h[o]);var a=n.length;n+=this.m_string.substring(this.m_letter),this.m_string=n,this.m_letter=a,o--}}}o>=0&&this.warning(t.MWarning.UNCLOSED_REPEAT,"")},e.prototype.replaceMacro=function(s){for(var i in s){var h=s[i];if(this.m_string.substr(this.m_letter,h.id.length)===h.id){var o=this.m_letter,_=this.m_letter+h.id.length,r=h.code;this.m_letter+=h.id.length;for(var n=this.getCharNext();e.isWhitespace(n);)n=this.getCharNext();var m=new Array,a=0;if(h.args.length>0){if("{"===n){for(n=this.getCharNext();1===a||"}"!==n&&""!==n;)'"'===n&&(a=1-a),"$"===n&&this.replaceMacro(s),n=this.getCharNext();_=this.m_letter;for(var p=this.m_string.substring(o+h.id.length+1,_-1),c="",l=!1,u=0;u<p.length;u++)l||'"'!==p.charAt(u)?l&&u+1<p.length&&"\\"===p.charAt(u)&&'"'===p.charAt(u+1)?(c+='"',u++):l&&'"'===p.charAt(u)?l=!1:l||","!==p.charAt(u)?c+=p.charAt(u):(m.push(c),c=""):l=!0;m.push(c),l&&this.warning(t.MWarning.UNCLOSED_ARGQUOTE,"")}for(var f=0;f<r.length;f++)for(var g=0;g<m.length&&!(g>=h.args.length);g++)if(r.substr(f,h.args[g].id.length+1)==="%"+h.args[g].id){r=r.substring(0,f)+r.substring(f).replace("%"+h.args[g].id,m[h.args[g].index]),f+=m[h.args[g].index].length-1;break}}return this.m_string=this.m_string.substring(0,o-1)+r+this.m_string.substring(_),this.m_letter=o-1,!0}}return!1},e.prototype.processMacro=function(){var s,i,h=/^#OCTAVE\s+REVERSE\s*$/m;if(this.m_string.match(h)&&(this.m_string=this.m_string.replace(h,""),this.m_relativeDir=!1),h=/^#VELOCITY\s+REVERSE\s*$/m,this.m_string.match(h)&&(this.m_string=this.m_string.replace(h,""),this.m_velDir=!1),this.m_metaTitle=this.findMetaDescN("TITLE"),this.m_metaArtist=this.findMetaDescN("ARTIST"),this.m_metaComment=this.findMetaDescN("COMMENT"),this.m_metaCoding=this.findMetaDescN("CODING"),this.findMetaDescN("PRAGMA"),h=/^#OPM@(\d+)[ \t]*{([^}]*)}/gm,i=this.m_string.match(h)){this.m_string=this.m_string.replace(h,"");var o;for(s=0;s<i.length;s++)o=i[s].match(/^#OPM@(\d+)[ \t]*{([^}]*)}/m),t.MOscOPM.setTimber(parseInt(o[1]),t.MOscOPM.TYPE_OPM,o[2])}if(h=/^#OPN@(\d+)[ \t]*{([^}]*)}/gm,i=this.m_string.match(h)){this.m_string=this.m_string.replace(h,"");var _;for(s=0;s<i.length;s++)_=i[s].match(/^#OPN@(\d+)[ \t]*{([^}]*)}/m),t.MOscOPM.setTimber(parseInt(_[1]),t.MOscOPM.TYPE_OPN,_[2])}var r=this.findMetaDescV("FMGAIN");for(s=0;s<r.length;s++)t.MOscOPM.setCommonGain(20*parseInt(r[s])/127);var n=this.findMetaDescN("USING\\s+POLY");if(n=n.replace("\r",""),n=n.replace("\n"," "),n=n.toLowerCase(),n.length>0){var m=n.split(" ");for(m.length<1?this.m_usingPoly=!1:(this.m_usingPoly=!0,this.m_polyVoice=Math.min(Math.max(1,parseInt(m[0])),e.MAX_POLYVOICE)),s=1;s<m.length;s++)"force"===m[s]&&(this.m_polyForce=!0);this.m_polyVoice<=1&&(this.m_usingPoly=!1,this.m_polyForce=!1)}if(h=/^#WAV10\s.*$/gm,i=this.m_string.match(h))for(s=0;s<i.length;s++){this.m_string=this.m_string.replace(h,"");for(var a=i[s].split(" "),p="",c=1;c<a.length;c++)p+=a[c];var l=p.split(","),u=parseInt(l[0]);0>u&&(u=0),u>=t.MOscGbWave.MAX_WAVE&&(u=t.MOscGbWave.MAX_WAVE-1),t.MOscGbWave.setWave(u,(l[1].toLowerCase()+"00000000000000000000000000000000").substr(0,32))}if(h=/^#WAV13\s.*$/gm,i=this.m_string.match(h))for(s=0;s<i.length;s++){for(this.m_string=this.m_string.replace(h,""),a=i[s].split(" "),p="",c=1;c<a.length;c++)p+=a[c];l=p.split(","),u=parseInt(l[0]),0>u&&(u=0),u>=t.MOscWave.MAX_WAVE&&(u=t.MOscWave.MAX_WAVE-1),t.MOscWave.setWave(u,l[1].toLowerCase())}if(h=/^#WAV9\s.*$/gm,i=this.m_string.match(h))for(s=0;s<i.length;s++){for(this.m_string=this.m_string.replace(h,""),a=i[s].split(" "),p="",c=1;c<a.length;c++)p+=a[c];l=p.split(","),u=parseInt(l[0]),0>u&&(u=0),u>=t.MOscFcDpcm.MAX_WAVE&&(u=t.MOscFcDpcm.MAX_WAVE-1);var f=parseInt(l[1]);0>f&&(f=0),f>127&&(f=127);var g=parseInt(l[2]);0>g&&(g=0),g>1&&(g=1),t.MOscFcDpcm.setWave(u,f,g,l[3])}this.begin();for(var S=!0,v=new Array,y=/^\s*/m,E=/\s*$/m;this.m_letter<this.m_string.length;){var M=this.getCharNext();switch(M){case"$":if(S){var P=this.m_string.indexOf(";",this.m_letter);if(P>this.m_letter){var d=this.m_string.indexOf("=",this.m_letter);if(d>this.m_letter&&P>d){var A=this.m_letter,b=this.m_string.indexOf("{");(0>b||b>=d)&&(b=d);var N=this.m_string.substring(A,b),O=N.match("[a-zA-Z_][a-zA-Z_0-9#+()]*");if(null!==O){var T=O[0];if(N=N.replace(y,"").replace(E,""),N!==T&&this.warning(t.MWarning.INVALID_MACRO_NAME,N),T.length>0){var k=new Array;if(d>b){var F=this.m_string.substring(b+1,this.m_string.indexOf("}",b));for(k=F.split(","),s=0;s<k.length;s++){var C=k[s].match("[a-zA-Z_][a-zA-Z_0-9#+()]*");k[s]={id:null!==C?C[0]:"",index:s}}k.sort(function(t,e){return t.id.length>e.id.length?-1:t.id.length===e.id.length?0:1})}for(this.m_letter=d+1,M=this.getCharNext();this.m_letter<P;)"$"===M&&(this.replaceMacro(v)||this.m_string.substr(this.m_letter,T.length)===T&&(this.m_letter--,this.m_string=e.remove(this.m_string,this.m_letter,this.m_letter+T.length),this.warning(t.MWarning.RECURSIVE_MACRO,T)),P=this.m_string.indexOf(";",this.m_letter)),M=this.getCharNext();for(var L=0;L<v.length;L++)if(v[L].id!==T){if(v[L].id.length<T.length)break}else v.splice(L,1),L--;v.splice(L,0,{id:T,code:this.m_string.substring(d+1,P),args:k}),this.m_string=e.remove(this.m_string,A-1,P),this.m_letter=A-1}}}else this.replaceMacro(v),S=!1}else this.replaceMacro(v),S=!1}else this.replaceMacro(v),S=!1;break;case";":S=!0;break;default:e.isWhitespace(M)||(S=!1)}}},e.prototype.findMetaDescV=function(t){var e,s,i,h,o,_=new Array;if(h=new RegExp("^#"+t+"(\\s*|\\s+(.*))$","gm"),o=new RegExp("^#"+t+"(\\s*|\\s+(.*))$","m"),s=this.m_string.match(h))for(this.m_string=this.m_string.replace(h,""),e=0;e<s.length;e++)i=s[e].match(o),void 0!==i[2]&&_.push(i[2]);return _},e.prototype.findMetaDescN=function(t){var e,s,i,h,o,_="";if(h=new RegExp("^#"+t+"(\\s*|\\s+(.*))$","gm"),o=new RegExp("^#"+t+"(\\s*|\\s+(.*))$","m"),s=this.m_string.match(h))for(this.m_string=this.m_string.replace(h,""),e=0;e<s.length;e++)i=s[e].match(o),void 0!==i[2]&&(_+=i[2],e+1<s.length&&(_+="\r\n"));return _},e.prototype.processComment=function(s){this.m_string=s,this.begin();for(var i=-1;this.m_letter<this.m_string.length;){var h=this.getCharNext();switch(h){case"/":"*"===this.getChar()&&(0>i&&(i=this.m_letter-1),this.next());break;case"*":"/"===this.getChar()&&(i>=0?(this.m_string=e.remove(this.m_string,i,this.m_letter),this.m_letter=i,i=-1):this.warning(t.MWarning.UNOPENED_COMMENT,""))}}for(i>=0&&this.warning(t.MWarning.UNCLOSED_COMMENT,""),this.begin(),i=-1;this.m_letter<this.m_string.length;)"`"===this.getCharNext()&&(0>i?i=this.m_letter-1:(this.m_string=e.remove(this.m_string,i,this.m_letter-1),this.m_letter=i,i=-1))},e.prototype.processGroupNotes=function(){var e,s,i,h,o,_,r,n,m,a,p=-1,c=0,l=96;for(this.begin();this.m_letter<this.m_string.length;){var u=this.getCharNext();switch(u){case"l":l=this.len2tick(this.getUInt(0)),l=this.getDot(l);break;case"{":p=this.m_letter-1,c=0;break;case"}":for(s=this.m_letter,0>p&&this.warning(t.MWarning.UNOPENED_GROUPNOTES,""),h=0;;){if("%"!==this.getChar()?m=0:(m=1,this.next()),i=this.getUInt(0),0===i){0===h&&(h=l);break}if(o=m?i:this.len2tick(i),o=this.getDot(o),h+=o,"&"!==this.getChar())break;this.next()}for(e=this.m_letter,this.m_letter=p+1,a=this.m_string.substring(0,p),o=0,_=h/c,c=1,n=0;this.m_letter<s;){switch(u=this.getCharNext()){case"+":case"#":case"-":break;default:if((u>="a"&&"g">=u||"r"===u)&&0===n){n=1;break}1===n&&(r=Math.round(c*_-o),c++,o+=r,o>h&&(r-=o-h,o=h),a+="%",a+=r.toString()),n=0,(u>="a"&&"g">=u||"r"===u)&&(n=1)}"}"!==u&&(a+=u)}this.m_letter=a.length,a+=this.m_string.substring(e),this.m_string=a,p=-1;break;default:(u>="a"&&"g">=u||"r"===u)&&c++}}p>=0&&this.warning(t.MWarning.UNCLOSED_GROUPNOTES,"")},e.prototype.play=function(t){return this.m_sequencer.isPaused()?void this.m_sequencer.play():(msgr.onstopsound=this.play2.bind(this,t),void msgr.stopSound(!0))},e.prototype.play2=function(s){this.m_sequencer.disconnectAll(),this.m_tracks=new Array,this.m_tracks[0]=this.createTrack(),this.m_tracks[1]=this.createTrack(),this.m_warning="",this.m_trackNo=t.MTrack.FIRST_TRACK,this.m_octave=4,this.m_relativeDir=!0,this.m_velocity=100,this.m_velDetail=!0,this.m_velDir=!0,this.m_length=this.len2tick(4),this.m_tempo=t.MTrack.DEFAULT_BPM,this.m_keyoff=1,this.m_gate=15,this.m_maxGate=16,this.m_form=t.MOscillator.PULSE,this.m_noteShift=0,this.m_maxPipe=0,this.m_maxSyncSource=0,this.m_beforeNote=0,this.m_portamento=0,this.m_usingPoly=!1,this.m_polyVoice=1,this.m_polyForce=!1,this.m_metaTitle="",this.m_metaArtist="",this.m_metaCoding="",this.m_metaComment="",this.processComment(s),this.processMacro(),this.m_string=e.removeWhitespace(this.m_string),this.processRepeat(),this.processGroupNotes(),this.process(),0===this.m_tracks[this.m_tracks.length-1].getNumEvents()&&this.m_tracks.pop(),this.m_tracks[t.MTrack.TEMPO_TRACK].conduct(this.m_tracks);for(var i=t.MTrack.TEMPO_TRACK;i<this.m_tracks.length;i++)i>t.MTrack.TEMPO_TRACK&&(this.m_usingPoly&&(this.m_polyForce||this.m_tracks[i].findPoly())&&this.m_tracks[i].usingPoly(this.m_polyVoice),this.m_tracks[i].recRestMSec(2e3),this.m_tracks[i].recClose()),this.m_sequencer.connect(this.m_tracks[i]);this.m_sequencer.createPipes(this.m_maxPipe+1),this.m_sequencer.createSyncSources(this.m_maxSyncSource+1),msgr.compileComplete(),this.m_sequencer.play(),msgr.onstopsound=null},e.prototype.stop=function(){this.m_sequencer.stop()},e.prototype.pause=function(){this.m_sequencer.pause()},e.prototype.resume=function(){this.m_sequencer.play()},e.prototype.isPlaying=function(){return this.m_sequencer.isPlaying()},e.prototype.isPaused=function(){return this.m_sequencer.isPaused()},e.prototype.getTotalMSec=function(){return this.m_tracks[t.MTrack.TEMPO_TRACK].getTotalMSec()},e.prototype.getTotalTimeStr=function(){return this.m_tracks[t.MTrack.TEMPO_TRACK].getTotalTimeStr()},e.prototype.getNowMSec=function(){return this.m_sequencer.getNowMSec()},e.prototype.getNowTimeStr=function(){return this.m_sequencer.getNowTimeStr()},e.prototype.getVoiceCount=function(){var t,e=0;for(t=0;t<this.m_tracks.length;t++)e+=this.m_tracks[t].getVoiceCount();return e},e.prototype.getMetaTitle=function(){return this.m_metaTitle},e.prototype.getMetaComment=function(){return this.m_metaComment},e.prototype.getMetaArtist=function(){return this.m_metaArtist},e.prototype.getMetaCoding=function(){return this.m_metaCoding},e.MAX_PIPE=3,e.MAX_SYNCSOURCE=3,e.MAX_POLYVOICE=64,e}();t.MML=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function e(){this.SAMPLE_RATE=msgr.SAMPLE_RATE,this.BUFFER_SIZE=msgr.BUFFER_SIZE,msgr.emptyBuffer=this.emptyBuffer=new Float32Array(this.BUFFER_SIZE*e.MULTIPLE);var s=this.BUFFER_SIZE*e.MULTIPLE;t.MChannel.boot(s),t.MOscillator.boot(),t.MEnvelope.boot(),this.m_trackArr=new Array,this.m_playSide=1,this.m_playSize=0,this.m_step=0,this.m_buffer=[[new Float32Array(s),new Float32Array(s)],[new Float32Array(s),new Float32Array(s)]],this.m_maxProcTime=this.BUFFER_SIZE/this.SAMPLE_RATE*1e3*.8,this.processAllBinded=this.processAll.bind(this),msgr.onrequestbuffer=this.onSampleData.bind(this),this.stop()}return e.getTimer=function(){return self.performance?self.performance.now():(new Date).getTime();
},e.prototype.play=function(){if(1===this.m_status){this.BUFFER_SIZE/this.SAMPLE_RATE*1e3;this.m_status=3,msgr.playSound(),this.startProcTimer()}else{this.m_globalSample=0,this.m_totalMSec=this.getTotalMSec();for(var t=0;t<this.m_trackArr.length;t++)this.m_trackArr[t].seekTop();this.m_status=2,this.processStart()}this.m_lastTime=0,this.m_waitPause=!1,msgr.infoInterval>0&&(clearInterval(msgr.tIDInfo),msgr.tIDInfo=setInterval(msgr.onInfoTimerBinded,msgr.infoInterval))},e.prototype.stop=function(){clearTimeout(this.m_procTimer),msgr.stopSound(!0),this.m_status=0,this.m_lastTime=0,this.m_maxNowMSec=0,this.m_waitPause=!1},e.prototype.pause=function(){switch(this.m_status){case 2:this.m_waitPause=!0;break;case 3:msgr.stopSound(),this.m_status=1,this.m_waitPause&&(msgr.syncInfo(),this.m_waitPause=!1)}},e.prototype.disconnectAll=function(){for(;this.m_trackArr.pop(););this.m_status=0},e.prototype.connect=function(t){this.m_trackArr.push(t)},e.prototype.reqBuffering=function(){this.m_buffTimer||(this.m_buffTimer=setTimeout(this.onBufferingReq.bind(this),0))},e.prototype.onBufferingReq=function(){this.m_status=2,this.startProcTimer(),this.m_buffTimer=0},e.prototype.startProcTimer=function(t){void 0===t&&(t=0),clearTimeout(this.m_procTimer),0!==this.m_status&&(this.m_procTimer=setTimeout(this.processAllBinded,t))},e.prototype.processStart=function(){this.m_step=1,this.startProcTimer()},e.prototype.processAll=function(){var s=this.m_buffer[1-this.m_playSide],i=this.BUFFER_SIZE,h=i*e.MULTIPLE,o=2*i,_=this.m_trackArr.length,r=msgr;switch(this.m_step){case 1:if(s=this.m_buffer[1-this.m_playSide],s[0].set(this.emptyBuffer),s[1].set(this.emptyBuffer),_>0){var n=this.m_trackArr[t.MTrack.TEMPO_TRACK];n.onSampleData(null,0,i*e.MULTIPLE,!0)}this.m_processTrack=t.MTrack.FIRST_TRACK,this.m_processOffset=0,this.m_step++,this.startProcTimer();break;case 2:var m=this.m_status,a=this.m_lastTime?this.m_maxProcTime+this.m_lastTime:0,p=r.infoInterval,c=r.lastInfoTime+p;do{if(this.m_trackArr[this.m_processTrack].onSampleData(s,this.m_processOffset,this.m_processOffset+o),this.m_processOffset+=o,this.m_processOffset>=h&&(this.m_processTrack++,this.m_processOffset=0),2===m&&r.buffering((this.m_processTrack*h+this.m_processOffset)/(_*h)*100|0),this.m_processTrack>=_){this.m_step++;break}p>0&&e.getTimer()>c&&(r.syncInfo(),c=r.lastInfoTime+p)}while(3>m||e.getTimer()<a);p>0&&(r.syncInfo(),clearInterval(r.tIDInfo),r.tIDInfo=setInterval(r.onInfoTimerBinded,r.infoInterval)),this.startProcTimer();break;case 3:this.m_step=4,2===this.m_status&&(this.m_status=3,this.m_playSide=1-this.m_playSide,this.m_playSize=0,this.m_waitPause?(this.pause(),this.m_step=1):(r.playSound(),this.processStart()))}},e.prototype.onSampleData=function(s){if(this.m_lastTime=e.getTimer(),!(this.m_status<3)){if(this.m_globalSample/this.SAMPLE_RATE*1e3>=this.m_totalMSec)return this.stop(),void msgr.complete();if(this.m_playSize>=e.MULTIPLE){if(4!==this.m_step)return void this.reqBuffering();if(this.m_playSide=1-this.m_playSide,this.m_playSize=0,this.processStart(),4===this.m_status)return;3===this.m_status&&this.m_trackArr[t.MTrack.TEMPO_TRACK].isEnd()&&(this.m_status=4)}var i=this.BUFFER_SIZE,h=s.retBuf||[new Float32Array(i),new Float32Array(i)],o=i*this.m_playSize;h[0].set(this.m_buffer[this.m_playSide][0].subarray(o,o+i)),h[1].set(this.m_buffer[this.m_playSide][1].subarray(o,o+i)),msgr.sendBuffer(h),this.m_playSize++,this.m_globalSample+=i}},e.prototype.createPipes=function(e){t.MChannel.createPipes(e)},e.prototype.createSyncSources=function(e){t.MChannel.createSyncSources(e)},e.prototype.isPlaying=function(){return this.m_status>1},e.prototype.isPaused=function(){return 1===this.m_status},e.prototype.getTotalMSec=function(){return this.m_trackArr[t.MTrack.TEMPO_TRACK]?this.m_trackArr[t.MTrack.TEMPO_TRACK].getTotalMSec():0},e.prototype.getNowMSec=function(){if(0===this.m_status)return 0;var t=this.m_globalSample/this.SAMPLE_RATE*1e3,s=this.m_lastTime?e.getTimer()-this.m_lastTime:0,i=this.BUFFER_SIZE/this.SAMPLE_RATE*1e3;return this.m_maxNowMSec=Math.max(this.m_maxNowMSec,t+Math.min(s,i)),this.m_maxNowMSec},e.prototype.getNowTimeStr=function(){var t=this.getNowMSec()/1e3,e="0"+(t/60|0),s="0"+(t%60|0);return e.substr(e.length-2,2)+":"+s.substr(s.length-2,2)},e.MULTIPLE=32,e}();t.MSequencer=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function t(){this.resetPhase(),this.setFrequency(440),t.SAMPLE_RATE||(t.SAMPLE_RATE=msgr.SAMPLE_RATE)}return t.prototype.resetPhase=function(){this.m_phase=0},t.prototype.addPhase=function(e){this.m_phase=this.m_phase+this.m_freqShift*e&t.PHASE_MSK},t.prototype.getNextSample=function(){return 0},t.prototype.getNextSampleOfs=function(t){return 0},t.prototype.getSamples=function(t,e,s){},t.prototype.getSamplesWithSyncIn=function(t,e,s,i){this.getSamples(t,s,i)},t.prototype.getSamplesWithSyncOut=function(t,e,s,i){this.getSamples(t,s,i)},t.prototype.getFrequency=function(){return this.m_frequency},t.prototype.setFrequency=function(e){this.m_frequency=e,this.m_freqShift=e*(t.PHASE_LEN/t.SAMPLE_RATE)|0},t.prototype.setWaveNo=function(t){},t.prototype.setNoteNo=function(t){},t.TABLE_LEN=65536,t.PHASE_SFT=14,t.PHASE_LEN=t.TABLE_LEN<<t.PHASE_SFT,t.PHASE_HLF=t.TABLE_LEN<<t.PHASE_SFT-1,t.PHASE_MSK=t.PHASE_LEN-1,t}();t.MOscMod=e}(flmml||(flmml={}));var __extends=this.__extends||function(t,e){function s(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);s.prototype=e.prototype,t.prototype=new s},flmml;!function(t){var e=function(t){function e(){e.boot(),this.m_readCount=0,this.m_address=0,this.m_bit=0,this.m_wav=0,this.m_length=0,this.m_ofs=0,t.call(this),this.setWaveNo(0)}return __extends(e,t),e.boot=function(){this.s_init||(this.FC_DPCM_NEXT=msgr.SAMPLE_RATE<<this.FC_DPCM_PHASE_SFT,this.s_table=new Array(this.MAX_WAVE),this.s_intVol=new Array(this.MAX_WAVE),this.s_loopFg=new Array(this.MAX_WAVE),this.s_length=new Array(this.MAX_WAVE),this.setWave(0,127,0,""),this.s_init=1)},e.setWave=function(t,e,s,i){this.s_intVol[t]=e,this.s_loopFg[t]=s,this.s_length[t]=0,this.s_table[t]=new Array(this.FC_DPCM_TABLE_MAX_LEN);for(var h=0,o=0,_=0,r=0,n=0;n<this.FC_DPCM_TABLE_MAX_LEN;n++)this.s_table[t][n]=0;for(h=0;h<i.length;h++){var m=i.charCodeAt(h);for(m>=65&&90>=m?m-=65:m>=97&&122>=m?m-=71:m>=48&&57>=m?m-=-4:m=43===m?62:47===m?63:0,n=5;n>=0;n--)this.s_table[t][r]+=(m>>n&1)<<8*o+7-_,_++,_>=8&&(_=0,o++),this.s_length[t]++,o>=4&&(o=0,r++,r>=this.FC_DPCM_TABLE_MAX_LEN&&(r=this.FC_DPCM_TABLE_MAX_LEN-1))}this.s_length[t]-=(this.s_length[t]-8)%128,this.s_length[t]>8*this.FC_DPCM_MAX_LEN&&(this.s_length[t]=8*this.FC_DPCM_MAX_LEN),0===this.s_length[t]&&(this.s_length[t]=8)},e.prototype.setWaveNo=function(t){t>=e.MAX_WAVE&&(t=e.MAX_WAVE-1),e.s_table[t]||(t=0),this.m_waveNo=t},e.prototype.getValue=function(){return this.m_length>0?(e.s_table[this.m_waveNo][this.m_address]>>this.m_bit&1?this.m_wav<126&&(this.m_wav+=2):this.m_wav>1&&(this.m_wav-=2),this.m_bit++,this.m_bit>=32&&(this.m_bit=0,this.m_address++),this.m_length--,0===this.m_length&&e.s_loopFg[this.m_waveNo]&&(this.m_address=0,this.m_bit=0,this.m_length=e.s_length[this.m_waveNo]),(this.m_wav-64)/64):(this.m_wav-64)/64},e.prototype.resetPhase=function(){this.m_phase=0,this.m_address=0,this.m_bit=0,this.m_ofs=0,this.m_wav=e.s_intVol[this.m_waveNo],this.m_length=e.s_length[this.m_waveNo]},e.prototype.getNextSample=function(){var t=(this.m_wav-64)/64;for(this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK;e.FC_DPCM_NEXT<=this.m_phase;)this.m_phase-=e.FC_DPCM_NEXT,this.m_length>0?(e.s_table[this.m_waveNo][this.m_address]>>this.m_bit&1?this.m_wav<126&&(this.m_wav+=2):this.m_wav>1&&(this.m_wav-=2),this.m_bit++,this.m_bit>=32&&(this.m_bit=0,this.m_address++),this.m_length--,0===this.m_length&&e.s_loopFg[this.m_waveNo]&&(this.m_address=0,this.m_bit=0,this.m_length=e.s_length[this.m_waveNo]),t=(this.m_wav-64)/64):t=(this.m_wav-64)/64;return t},e.prototype.getNextSampleOfs=function(t){var s=(this.m_wav-64)/64;for(this.m_phase=this.m_phase+this.m_freqShift+(t-this.m_ofs>>e.PHASE_SFT-7)&e.PHASE_MSK;e.FC_DPCM_NEXT<=this.m_phase;)this.m_phase-=e.FC_DPCM_NEXT,this.m_length>0?(e.s_table[this.m_waveNo][this.m_address]>>this.m_bit&1?this.m_wav<126&&(this.m_wav+=2):this.m_wav>1&&(this.m_wav-=2),this.m_bit++,this.m_bit>=32&&(this.m_bit=0,this.m_address++),this.m_length--,0===this.m_length&&e.s_loopFg[this.m_waveNo]&&(this.m_address=0,this.m_bit=0,this.m_length=e.s_length[this.m_waveNo]),s=(this.m_wav-64)/64):s=(this.m_wav-64)/64;return this.m_ofs=t,s},e.prototype.getSamples=function(t,s,i){var h,o=(this.m_wav-64)/64;for(h=s;i>h;h++){for(this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK;e.FC_DPCM_NEXT<=this.m_phase;)this.m_phase-=e.FC_DPCM_NEXT,this.m_length>0?(e.s_table[this.m_waveNo][this.m_address]>>this.m_bit&1?this.m_wav<126&&(this.m_wav+=2):this.m_wav>1&&(this.m_wav-=2),this.m_bit++,this.m_bit>=32&&(this.m_bit=0,this.m_address++),this.m_length--,0===this.m_length&&e.s_loopFg[this.m_waveNo]&&(this.m_address=0,this.m_bit=0,this.m_length=e.s_length[this.m_waveNo]),o=(this.m_wav-64)/64):o=(this.m_wav-64)/64;t[h]=o}},e.prototype.setFrequency=function(t){this.m_freqShift=t*(1<<e.FC_DPCM_PHASE_SFT+4)|0},e.prototype.setDpcmFreq=function(t){0>t&&(t=0),t>15&&(t=15),this.m_freqShift=(e.FC_CPU_CYCLE<<e.FC_DPCM_PHASE_SFT)/e.s_interval[t]|0},e.prototype.setNoteNo=function(t){this.setDpcmFreq(t)},e.MAX_WAVE=16,e.FC_CPU_CYCLE=1789773,e.FC_DPCM_PHASE_SFT=2,e.FC_DPCM_MAX_LEN=4081,e.FC_DPCM_TABLE_MAX_LEN=(e.FC_DPCM_MAX_LEN>>2)+2,e.s_interval=[428,380,340,320,286,254,226,214,190,160,142,128,106,85,72,54],e}(t.MOscMod);t.MOscFcDpcm=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.setLongMode(),this.m_fcr=32768,this.m_val=this.getValue(),this.setNoiseFreq(0)}return __extends(e,t),e.prototype.getValue=function(){return this.m_fcr>>=1,this.m_fcr|=(1&(this.m_fcr^this.m_fcr>>this.m_snz))<<15,1&this.m_fcr?1:-1},e.prototype.setShortMode=function(){this.m_snz=6},e.prototype.setLongMode=function(){this.m_snz=1},e.prototype.resetPhase=function(){},e.prototype.addPhase=function(t){for(this.m_phase=this.m_phase+e.FC_NOISE_PHASE_DLT*t|0;this.m_phase>=this.m_freqShift;)this.m_phase-=this.m_freqShift,this.m_val=this.getValue()},e.boot=function(){e.FC_NOISE_PHASE_DLT=e.FC_NOISE_PHASE_SEC/msgr.SAMPLE_RATE|0},e.prototype.getNextSample=function(){for(var t=this.m_val,s=0,i=0,h=e.FC_NOISE_PHASE_DLT;h>=this.m_freqShift;)h-=this.m_freqShift,this.m_phase=0,s+=this.getValue(),i+=1;return i>0&&(this.m_val=s/i),this.m_phase=this.m_phase+h|0,this.m_phase>=this.m_freqShift&&(this.m_phase-=this.m_freqShift,this.m_val=this.getValue()),t},e.prototype.getNextSampleOfs=function(t){for(var s=this.m_fcr,i=this.m_phase,h=this.m_val,o=0,_=0,r=e.FC_NOISE_PHASE_DLT+t;r>=this.m_freqShift;)r-=this.m_freqShift,this.m_phase=0,o+=this.getValue(),_+=1;return _>0&&(this.m_val=o/_),this.m_phase=this.m_phase+r|0,this.m_phase>=this.m_freqShift&&(this.m_phase=this.m_freqShift,this.m_val=this.getValue()),this.m_fcr=s,this.m_phase=i,this.getNextSample(),h},e.prototype.getSamples=function(t,e,s){for(var i=e;s>i;i++)t[i]=this.getNextSample()},e.prototype.setFrequency=function(t){this.m_freqShift=e.FC_NOISE_PHASE_SEC/t|0},e.prototype.setNoiseFreq=function(t){0>t&&(t=0),t>15&&(t=15),this.m_freqShift=e.s_interval[t]<<e.FC_NOISE_PHASE_SFT|0},e.prototype.setNoteNo=function(t){this.setNoiseFreq(t)},e.FC_NOISE_PHASE_SFT=10,e.FC_NOISE_PHASE_SEC=1789773<<e.FC_NOISE_PHASE_SFT|0,e.s_interval=[4,8,16,32,64,96,128,160,202,254,380,508,762,1016,2034,4068],e}(t.MOscMod);t.MOscFcNoise=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.setWaveNo(0)}return __extends(e,t),e.boot=function(){if(!this.s_init){this.s_table=new Array(this.MAX_WAVE),this.s_table[0]=new Array(this.FC_TRI_TABLE_LEN),this.s_table[1]=new Array(this.FC_TRI_TABLE_LEN);var t;for(t=0;16>t;t++)this.s_table[0][t]=this.s_table[0][31-t]=2*t/15-1;for(t=0;32>t;t++)this.s_table[1][t]=8>t?2*t/14:24>t?2*(8-t)/15+1:2*(t-24)/15-1;this.s_init=1}},e.prototype.getNextSample=function(){var t=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT+11];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,t},e.prototype.getNextSampleOfs=function(t){var s=e.s_table[this.m_waveNo][(this.m_phase+t&e.PHASE_MSK)>>e.PHASE_SFT+11];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,s},e.prototype.getSamples=function(t,s,i){var h;for(h=s;i>h;h++)t[h]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT+11],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncIn=function(t,s,i,h){var o;for(o=i;h>o;o++)s[o]&&this.resetPhase(),t[o]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT+11],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncOut=function(t,s,i,h){var o;for(o=i;h>o;o++)t[o]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT+11],this.m_phase+=this.m_freqShift,s[o]=this.m_phase>e.PHASE_MSK,this.m_phase&=e.PHASE_MSK},e.prototype.setWaveNo=function(t){this.m_waveNo=Math.min(t,e.MAX_WAVE-1)},e.FC_TRI_TABLE_LEN=32,e.MAX_WAVE=2,e.s_init=0,e}(t.MOscMod);t.MOscFcTri=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.m_sum=0,this.m_skip=0}return __extends(e,t),e.boot=function(){if(!this.s_init){for(var t=65535,e=1,s=0;s<this.GB_NOISE_TABLE_LEN;s++)0===t&&(t=1),t+=t+(1&(t>>14^t>>13))|0,e^=1&t,this.s_table[s]=2*e-1;this.s_init=1}},e.prototype.getNextSample=function(){var t=e.s_table[this.m_phase>>e.GB_NOISE_PHASE_SFT];this.m_skip>0&&(t=(t+this.m_sum)/(this.m_skip+1)),this.m_sum=0,this.m_skip=0;for(var s=this.m_freqShift;s>e.GB_NOISE_PHASE_DLT;)this.m_phase=(this.m_phase+e.GB_NOISE_PHASE_DLT)%e.GB_NOISE_TABLE_MOD,s-=e.GB_NOISE_PHASE_DLT,this.m_sum+=e.s_table[this.m_phase>>e.GB_NOISE_PHASE_SFT],this.m_skip++;return this.m_phase=(this.m_phase+s)%e.GB_NOISE_TABLE_MOD,t},e.prototype.getNextSampleOfs=function(t){var s=(this.m_phase+t)%e.GB_NOISE_TABLE_MOD,i=e.s_table[s+(s>>31&e.GB_NOISE_TABLE_MOD)>>e.GB_NOISE_PHASE_SFT];return this.m_phase=(this.m_phase+this.m_freqShift)%e.GB_NOISE_TABLE_MOD,i},e.prototype.getSamples=function(t,s,i){var h,o;for(h=s;i>h;h++){o=e.s_table[this.m_phase>>e.GB_NOISE_PHASE_SFT],this.m_skip>0&&(o=(o+this.m_sum)/(this.m_skip+1)),t[h]=o,this.m_sum=0,this.m_skip=0;for(var _=this.m_freqShift;_>e.GB_NOISE_PHASE_DLT;)this.m_phase=(this.m_phase+e.GB_NOISE_PHASE_DLT)%e.GB_NOISE_TABLE_MOD,_-=e.GB_NOISE_PHASE_DLT,this.m_sum+=e.s_table[this.m_phase>>e.GB_NOISE_PHASE_SFT],this.m_skip++;this.m_phase=(this.m_phase+_)%e.GB_NOISE_TABLE_MOD}},e.prototype.setFrequency=function(t){this.m_frequency=t},e.prototype.setNoiseFreq=function(t){0>t&&(t=0),t>63&&(t=63),this.m_freqShift=(1048576<<e.GB_NOISE_PHASE_SFT-2)/(11025*e.s_interval[t])|0},e.prototype.setNoteNo=function(t){this.setNoiseFreq(t)},e.GB_NOISE_PHASE_SFT=12,e.GB_NOISE_PHASE_DLT=1<<e.GB_NOISE_PHASE_SFT,e.GB_NOISE_TABLE_LEN=32767,e.GB_NOISE_TABLE_MOD=(e.GB_NOISE_TABLE_LEN<<e.GB_NOISE_PHASE_SFT)-1,e.s_init=0,e.s_table=new Array(e.GB_NOISE_TABLE_LEN),e.s_interval=[2,4,8,12,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,256,320,384,448,512,640,768,896,1024,1280,1536,1792,2048,2560,3072,3584,4096,5120,6144,7168,8192,10240,12288,14336,16384,20480,24576,28672,32768,40960,49152,57344,65536,81920,98304,114688,131072,163840,196608,229376,262144,327680,393216,458752],e}(t.MOscMod);t.MOscGbLNoise=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.m_sum=0,this.m_skip=0}return __extends(e,t),e.boot=function(){if(!this.s_init){for(var t=65535,e=1,s=0;s<this.GB_NOISE_TABLE_LEN;s++)0===t&&(t=1),t+=t+(1&(t>>6^t>>5))|0,e^=1&t,this.s_table[s]=2*e-1;this.s_init=1}},e.prototype.getNextSample=function(){var t=e.s_table[this.m_phase>>e.GB_NOISE_PHASE_SFT];this.m_skip>0&&(t=(t+this.m_sum)/Number(this.m_skip+1)),this.m_sum=0,this.m_skip=0;for(var s=this.m_freqShift;s>e.GB_NOISE_PHASE_DLT;)this.m_phase=(this.m_phase+e.GB_NOISE_PHASE_DLT)%e.GB_NOISE_TABLE_MOD,s-=e.GB_NOISE_PHASE_DLT,this.m_sum+=e.s_table[this.m_phase>>e.GB_NOISE_PHASE_SFT],this.m_skip++;return this.m_phase=(this.m_phase+s)%e.GB_NOISE_TABLE_MOD,t},e.prototype.getNextSampleOfs=function(t){var s=(this.m_phase+t)%e.GB_NOISE_TABLE_MOD,i=e.s_table[s+(s>>31&e.GB_NOISE_TABLE_MOD)>>e.GB_NOISE_PHASE_SFT];return this.m_phase=(this.m_phase+this.m_freqShift)%e.GB_NOISE_TABLE_MOD,i},e.prototype.getSamples=function(t,s,i){var h,o;for(h=s;i>h;h++){o=e.s_table[this.m_phase>>e.GB_NOISE_PHASE_SFT],this.m_skip>0&&(o=(o+this.m_sum)/Number(this.m_skip+1)),t[h]=o,this.m_sum=0,this.m_skip=0;for(var _=this.m_freqShift;_>e.GB_NOISE_PHASE_DLT;)this.m_phase=(this.m_phase+e.GB_NOISE_PHASE_DLT)%e.GB_NOISE_TABLE_MOD,_-=e.GB_NOISE_PHASE_DLT,this.m_sum+=e.s_table[this.m_phase>>e.GB_NOISE_PHASE_SFT],this.m_skip++;this.m_phase=(this.m_phase+_)%e.GB_NOISE_TABLE_MOD}},e.prototype.setFrequency=function(t){this.m_frequency=t},e.prototype.setNoiseFreq=function(t){0>t&&(t=0),t>63&&(t=63),this.m_freqShift=(1048576<<e.GB_NOISE_PHASE_SFT-2)/(11025*e.s_interval[t])},e.prototype.setNoteNo=function(t){this.setNoiseFreq(t)},e.GB_NOISE_PHASE_SFT=12,e.GB_NOISE_PHASE_DLT=1<<e.GB_NOISE_PHASE_SFT,e.GB_NOISE_TABLE_LEN=127,e.GB_NOISE_TABLE_MOD=(e.GB_NOISE_TABLE_LEN<<e.GB_NOISE_PHASE_SFT)-1,e.s_init=0,e.s_table=new Array(e.GB_NOISE_TABLE_LEN),e.s_interval=[2,4,8,12,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,256,320,384,448,512,640,768,896,1024,1280,1536,1792,2048,2560,3072,3584,4096,5120,6144,7168,8192,10240,12288,14336,16384,20480,24576,28672,32768,40960,49152,57344,65536,81920,98304,114688,131072,163840,196608,229376,262144,327680,393216,458752],e}(t.MOscMod);t.MOscGbSNoise=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.setWaveNo(0)}return __extends(e,t),e.boot=function(){this.s_init||(this.s_table=new Array(this.MAX_WAVE),this.setWave(0,"0123456789abcdeffedcba9876543210"),this.s_init=1)},e.setWave=function(t,e){this.s_table[t]=new Array(this.GB_WAVE_TABLE_LEN);for(var s=0;32>s;s++){var i=e.charCodeAt(s);i>=48&&58>i?i-=48:i>=97&&103>i?i-=87:i=0,this.s_table[t][s]=(i-7.5)/7.5}},e.prototype.setWaveNo=function(t){t>=e.MAX_WAVE&&(t=e.MAX_WAVE-1),e.s_table[t]||(t=0),this.m_waveNo=t},e.prototype.getNextSample=function(){var t=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT+11];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,t},e.prototype.getNextSampleOfs=function(t){var s=e.s_table[this.m_waveNo][(this.m_phase+t&e.PHASE_MSK)>>e.PHASE_SFT+11];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,s},e.prototype.getSamples=function(t,s,i){var h;for(h=s;i>h;h++)t[h]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT+11],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncIn=function(t,s,i,h){var o;for(o=i;h>o;o++)s[o]&&this.resetPhase(),t[o]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT+11],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncOut=function(t,s,i,h){var o;for(o=i;h>o;o++)t[o]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT+11],this.m_phase+=this.m_freqShift,s[o]=this.m_phase>e.PHASE_MSK,this.m_phase&=e.PHASE_MSK},e.MAX_WAVE=32,e.GB_WAVE_TABLE_LEN=32,e.s_init=0,e}(t.MOscMod);t.MOscGbWave=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function e(){e.boot(),this.m_osc=new Array(e.MAX),this.m_osc[e.SINE]=new t.MOscSine,this.m_osc[e.SAW]=new t.MOscSaw,this.m_osc[e.TRIANGLE]=new t.MOscTriangle,this.m_osc[e.PULSE]=new t.MOscPulse,this.m_osc[e.NOISE]=new t.MOscNoise,this.m_osc[e.FC_PULSE]=new t.MOscPulse,this.m_osc[e.FC_TRI]=new t.MOscFcTri,this.m_osc[e.FC_NOISE]=new t.MOscFcNoise,this.m_osc[e.FC_S_NOISE]=null,this.m_osc[e.FC_DPCM]=new t.MOscFcDpcm,this.m_osc[e.GB_WAVE]=new t.MOscGbWave,this.m_osc[e.GB_NOISE]=new t.MOscGbLNoise,this.m_osc[e.GB_S_NOISE]=new t.MOscGbSNoise,this.m_osc[e.WAVE]=new t.MOscWave,this.m_osc[e.OPM]=new t.MOscOPM,this.setForm(e.PULSE),this.setNoiseToPulse()}return e.prototype.asLFO=function(){this.m_osc[e.NOISE]&&this.m_osc[e.NOISE].disableResetPhase()},e.boot=function(){this.s_init||(t.MOscSine.boot(),t.MOscSaw.boot(),t.MOscTriangle.boot(),t.MOscPulse.boot(),t.MOscNoise.boot(),t.MOscFcTri.boot(),t.MOscFcNoise.boot(),t.MOscFcDpcm.boot(),t.MOscGbWave.boot(),t.MOscGbLNoise.boot(),t.MOscGbSNoise.boot(),t.MOscWave.boot(),t.MOscOPM.boot(),this.s_init=1)},e.prototype.setForm=function(t){var s,i;switch(t>=e.MAX&&(t=e.MAX-1),this.m_form=t,t){case e.NOISE:s=this.m_osc[e.NOISE],s.restoreFreq();break;case e.FC_NOISE:i=this.getMod(e.FC_NOISE),i.setLongMode();break;case e.FC_S_NOISE:i=this.getMod(e.FC_S_NOISE),i.setShortMode()}return this.getMod(t)},e.prototype.getForm=function(){return this.m_form},e.prototype.getCurrent=function(){return this.getMod(this.m_form)},e.prototype.getMod=function(t){return t!==e.FC_S_NOISE?this.m_osc[t]:this.m_osc[e.FC_NOISE]},e.prototype.setNoiseToPulse=function(){var t=this.getMod(e.PULSE),s=this.getMod(e.NOISE);t.setNoise(s)},e.SINE=0,e.SAW=1,e.TRIANGLE=2,e.PULSE=3,e.NOISE=4,e.FC_PULSE=5,e.FC_TRI=6,e.FC_NOISE=7,e.FC_S_NOISE=8,e.FC_DPCM=9,e.GB_WAVE=10,e.GB_NOISE=11,e.GB_S_NOISE=12,e.WAVE=13,e.OPM=14,e.MAX=15,e.s_init=0,e}();t.MOscillator=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.setNoiseFreq(1),this.m_phase=0,this.m_counter=0,this.m_resetPhase=!0}return __extends(e,t),e.prototype.disableResetPhase=function(){this.m_resetPhase=!1},e.boot=function(){if(!this.s_init){for(var t=0;t<this.TABLE_LEN;t++)this.s_table[t]=2*Math.random()-1;this.s_init=1}},e.prototype.resetPhase=function(){this.m_resetPhase&&(this.m_phase=0)},e.prototype.addPhase=function(t){this.m_counter=this.m_counter+this.m_freqShift*t,this.m_phase=this.m_phase+(this.m_counter>>e.NOISE_PHASE_SFT)&e.TABLE_MSK,this.m_counter&=e.NOISE_PHASE_MSK},e.prototype.getNextSample=function(){var t=e.s_table[this.m_phase];return this.m_counter=this.m_counter+this.m_freqShift,this.m_phase=this.m_phase+(this.m_counter>>e.NOISE_PHASE_SFT)&e.TABLE_MSK,this.m_counter&=e.NOISE_PHASE_MSK,t},e.prototype.getNextSampleOfs=function(t){var s=e.s_table[this.m_phase+(t<<e.PHASE_SFT)&e.TABLE_MSK];return this.m_counter=this.m_counter+this.m_freqShift,this.m_phase=this.m_phase+(this.m_counter>>e.NOISE_PHASE_SFT)&e.TABLE_MSK,this.m_counter&=e.NOISE_PHASE_MSK,s},e.prototype.getSamples=function(t,s,i){var h;for(h=s;i>h;h++)t[h]=e.s_table[this.m_phase],this.m_counter=this.m_counter+this.m_freqShift,this.m_phase=this.m_phase+(this.m_counter>>e.NOISE_PHASE_SFT)&e.TABLE_MSK,this.m_counter&=e.NOISE_PHASE_MSK},e.prototype.setFrequency=function(t){this.m_frequency=t},e.prototype.setNoiseFreq=function(t){this.m_noiseFreq=t*(1<<e.NOISE_PHASE_SFT),this.m_freqShift=this.m_noiseFreq},e.prototype.restoreFreq=function(){this.m_freqShift=this.m_noiseFreq},e.TABLE_MSK=e.TABLE_LEN-1,e.NOISE_PHASE_SFT=30,e.NOISE_PHASE_MSK=(1<<e.NOISE_PHASE_SFT)-1,e.s_init=0,e.s_table=new Array(e.TABLE_LEN),e}(t.MOscMod);t.MOscNoise=e}(flmml||(flmml={}));var fmgenAs;!function(t){var e=function(){function t(){this.regta=new Array(2)}return t.prototype.Reset=function(){this.timera_count=0,this.timerb_count=0},t.prototype.Count=function(t){var e=!1;if(0!==this.timera_count&&(this.timera_count-=t<<16,this.timera_count<=0)){for(e=!0,this.TimerA();this.timera_count<=0;)this.timera_count+=this.timera;4&this.regtc&&this.SetStatus(1)}if(0!==this.timerb_count&&(this.timerb_count-=t<<12,this.timerb_count<=0)){for(e=!0;this.timerb_count<=0;)this.timerb_count+=this.timerb;8&this.regtc&&this.SetStatus(2)}return e},t.prototype.GetNextEvent=function(){var t=(this.timera_count+65535>>16)-1,e=(this.timerb_count+4095>>12)-1;return(e>t?t:e)+1},t.prototype.SetStatus=function(t){},t.prototype.ResetStatus=function(t){},t.prototype.SetTimerBase=function(t){this.timer_step=65536e6/t|0},t.prototype.SetTimerA=function(t,e){var s;this.regta[1&t]=0|e,s=(this.regta[0]<<2)+(3&this.regta[1]),this.timera=(1024-s)*this.timer_step},t.prototype.SetTimerB=function(t){this.timerb=(256-t)*this.timer_step},t.prototype.SetTimerControl=function(t){var e=this.regtc^t;this.regtc=0|t,16&t&&this.ResetStatus(1),32&t&&this.ResetStatus(2),1&e&&(this.timera_count=1&t?this.timera:0),2&e&&(this.timerb_count=2&t?this.timerb:0)},t.prototype.TimerA=function(){},t}();t.Timer=e}(fmgenAs||(fmgenAs={}));var fmgenAs;!function(t){var e=function(){function t(){}return t.I2=function(t,e){for(var s=new Array(t),i=0;t>i;i++)s[i]=new Array(e);return s},t.I3=function(t,e,s){for(var i=new Array(t),h=0;t>h;h++){i[h]=new Array(e);for(var o=0;e>o;o++)i[h][o]=new Array(s)}return i},t}();t.JaggArray=e}(fmgenAs||(fmgenAs={}));var fmgenAs;!function(t){var e=function(){function e(){this.chip_=null,this.ar_=this.dr_=this.sr_=this.rr_=this.key_scale_rate_=0,this.ams_=e.amtable[0][0],this.mute_=!1,this.keyon_=!1,this.tl_out_=0,this.ssg_type_=0,this.multiple_=0,this.detune_=0,this.detune2_=0,this.ms_=0}return e.prototype.SetChip=function(t){this.chip_=t},e.prototype.Reset=function(){this.tl_=this.tl_latch_=127,this.ShiftPhase(t.EGPhase.off),this.eg_count_=0,this.eg_curve_count_=0,this.ssg_phase_=0,this.pg_count_=0,this.out_=this.out2_=0,this.param_changed_=!0},e.prototype.SetDPBN=function(t,e){this.dp_=t,this.bn_=e,this.param_changed_=!0},e.prototype.Prepare=function(){if(this.param_changed_!==!1){switch(this.param_changed_=!1,this.pg_diff_=(this.dp_+e.dttable[this.detune_+this.bn_])*this.chip_.GetMulValue(this.detune2_,this.multiple_),this.pg_diff_lfo_=this.pg_diff_>>11,this.key_scale_rate_=this.bn_>>3-this.ks_,this.tl_out_=this.mute_?1023:8*this.tl_,this.eg_phase_){case t.EGPhase.attack:this.SetEGRate(0!==this.ar_?Math.min(63,this.ar_+this.key_scale_rate_):0);break;case t.EGPhase.decay:this.SetEGRate(0!==this.dr_?Math.min(63,this.dr_+this.key_scale_rate_):0),this.eg_level_on_next_phase_=8*this.sl_;break;case t.EGPhase.sustain:this.SetEGRate(0!==this.sr_?Math.min(63,this.sr_+this.key_scale_rate_):0);break;case t.EGPhase.release:this.SetEGRate(Math.min(63,this.rr_+this.key_scale_rate_))}if(0!==this.ssg_type_&&this.eg_phase_!==t.EGPhase.release){var s=this.ar_>=(8===this.ssg_type_||12===this.ssg_type_?56:60)?1:0;this.ssg_offset_=512*e.ssgenvtable[7&this.ssg_type_][s][this.ssg_phase_][0],this.ssg_vector_=e.ssgenvtable[7&this.ssg_type_][s][this.ssg_phase_][1]}this.ams_=e.amtable[0|this.type_][this.amon_?this.ms_>>4&3:0],this.EGUpdate()}},e.prototype.ShiftPhase=function(s){switch(s){case t.EGPhase.attack:if(this.tl_=this.tl_latch_,0!==this.ssg_type_){this.ssg_phase_=this.ssg_phase_+1,this.ssg_phase_>2&&(this.ssg_phase_=1);var i=this.ar_>=(8===this.ssg_type_||12===this.ssg_type_?56:60)?1:0;this.ssg_offset_=512*e.ssgenvtable[7&this.ssg_type_][i][this.ssg_phase_][0],this.ssg_vector_=e.ssgenvtable[7&this.ssg_type_][i][this.ssg_phase_][1]}if(this.ar_+this.key_scale_rate_<62){this.SetEGRate(0!==this.ar_?Math.min(63,this.ar_+this.key_scale_rate_):0),this.eg_phase_=t.EGPhase.attack;break}case t.EGPhase.decay:if(0!==this.sl_){this.eg_level_=0,this.eg_level_on_next_phase_=0!==this.ssg_type_?Math.min(8*this.sl_,512):8*this.sl_,this.SetEGRate(0!==this.dr_?Math.min(63,this.dr_+this.key_scale_rate_):0),this.eg_phase_=t.EGPhase.decay;break}case t.EGPhase.sustain:this.eg_level_=8*this.sl_,this.eg_level_on_next_phase_=0!==this.ssg_type_?512:1024,this.SetEGRate(0!==this.sr_?Math.min(63,this.sr_+this.key_scale_rate_):0),this.eg_phase_=t.EGPhase.sustain;break;case t.EGPhase.release:if(0!==this.ssg_type_&&(this.eg_level_=this.eg_level_*this.ssg_vector_+this.ssg_offset_,this.ssg_vector_=1,this.ssg_offset_=0),this.eg_phase_===t.EGPhase.attack||this.eg_level_<955){this.eg_level_on_next_phase_=1024,this.SetEGRate(Math.min(63,this.rr_+this.key_scale_rate_)),this.eg_phase_=t.EGPhase.release;break}case t.EGPhase.off:default:this.eg_level_=955,this.eg_level_on_next_phase_=955,this.EGUpdate(),this.SetEGRate(0),this.eg_phase_=t.EGPhase.off}},e.prototype.SetFNum=function(t){this.dp_=(2047&t)<<(t>>11&7),this.bn_=e.notetable[t>>7&127],this.param_changed_=!0},e.prototype.SINE=function(t){return e.sinetable[1023&t]},e.prototype.LogToLin=function(t){return 8192>t?e.cltable[t]:0},e.prototype.EGUpdate=function(){var t=0===this.ssg_type_?this.tl_out_+this.eg_level_:this.tl_out_+this.eg_level_*this.ssg_vector_+this.ssg_offset_;this.eg_out_=1023>t?t<<3:8184},e.prototype.SetEGRate=function(t){this.eg_rate_=t,this.eg_count_diff_=e.decaytable2[t/4|0]*this.chip_.GetRatio()},e.prototype.EGCalc=function(){if(this.eg_count_=786048,this.eg_phase_===t.EGPhase.attack){var s=e.attacktable[this.eg_rate_][7&this.eg_curve_count_];s>=0&&(this.eg_level_-=1+(this.eg_level_>>s),this.eg_level_<=0&&this.ShiftPhase(t.EGPhase.decay)),this.EGUpdate()}else if(0===this.ssg_type_)this.eg_level_+=e.decaytable1[this.eg_rate_][7&this.eg_curve_count_],this.eg_level_>=this.eg_level_on_next_phase_&&this.ShiftPhase(this.eg_phase_+1),this.EGUpdate();else if(this.eg_level_+=4*e.decaytable1[this.eg_rate_][7&this.eg_curve_count_],this.eg_level_>=this.eg_level_on_next_phase_)switch(this.EGUpdate(),this.eg_phase_){case t.EGPhase.decay:this.ShiftPhase(t.EGPhase.sustain);break;case t.EGPhase.sustain:this.ShiftPhase(t.EGPhase.attack);break;case t.EGPhase.release:this.ShiftPhase(t.EGPhase.off)}this.eg_curve_count_++},e.prototype.EGStep=function(){this.eg_count_-=this.eg_count_diff_,this.eg_count_<=0&&this.EGCalc()},e.prototype.PGCalc=function(){var t=this.pg_count_;return this.pg_count_+=this.pg_diff_,t},e.prototype.PGCalcL=function(){var t=this.pg_count_;return this.pg_count_+=this.pg_diff_+(this.pg_diff_lfo_*this.chip_.GetPMV()>>5),t},e.prototype.Calc=function(s){if(this.eg_count_-=this.eg_count_diff_,this.eg_count_<=0){if(this.eg_count_=786048,this.eg_phase_===t.EGPhase.attack){var i=e.attacktable[this.eg_rate_][7&this.eg_curve_count_];i>=0&&(this.eg_level_-=1+(this.eg_level_>>i),this.eg_level_<=0&&this.ShiftPhase(t.EGPhase.decay))}else this.eg_level_+=e.decaytable1[this.eg_rate_][7&this.eg_curve_count_],this.eg_level_>=this.eg_level_on_next_phase_&&this.ShiftPhase(this.eg_phase_+1);var h=this.tl_out_+this.eg_level_;this.eg_out_=1023>h?h<<3:8184,this.eg_curve_count_++}this.out2_=this.out_;var o=this.pg_count_;this.pg_count_+=this.pg_diff_;var _=o>>19;_+=s>>19-(2+e.IS2EC_SHIFT);var r=this.eg_out_+e.sinetable[1023&_];return this.out_=8192>r?e.cltable[r]:0,this.out_},e.prototype.CalcL=function(s){if(this.eg_count_-=this.eg_count_diff_,this.eg_count_<=0){if(this.eg_count_=786048,this.eg_phase_===t.EGPhase.attack){var i=e.attacktable[this.eg_rate_][7&this.eg_curve_count_];i>=0&&(this.eg_level_-=1+(this.eg_level_>>i),this.eg_level_<=0&&this.ShiftPhase(t.EGPhase.decay))}else this.eg_level_+=e.decaytable1[this.eg_rate_][7&this.eg_curve_count_],this.eg_level_>=this.eg_level_on_next_phase_&&this.ShiftPhase(this.eg_phase_+1);var h=this.tl_out_+this.eg_level_;this.eg_out_=1023>h?h<<3:8184,this.eg_curve_count_++}var o=this.pg_count_;this.pg_count_+=this.pg_diff_+(this.pg_diff_lfo_*this.chip_.pmv_>>5);var _=o>>19;_+=s>>19-(2+e.IS2EC_SHIFT);var r=this.eg_out_+e.sinetable[1023&_]+this.ams_[this.chip_.aml_];return this.out_=8192>r?e.cltable[r]:0,this.out_},e.prototype.CalcN=function(t){this.EGStep();var e=Math.max(0,1023-(this.tl_out_+this.eg_level_))<<1;return t=(1&t)-1,this.out_=e+t^t,this.out_},e.prototype.CalcFB=function(s){if(this.eg_count_-=this.eg_count_diff_,this.eg_count_<=0){if(this.eg_count_=786048,this.eg_phase_===t.EGPhase.attack){var i=e.attacktable[this.eg_rate_][7&this.eg_curve_count_];i>=0&&(this.eg_level_-=1+(this.eg_level_>>i),this.eg_level_<=0&&this.ShiftPhase(t.EGPhase.decay))}else this.eg_level_+=e.decaytable1[this.eg_rate_][7&this.eg_curve_count_],this.eg_level_>=this.eg_level_on_next_phase_&&this.ShiftPhase(this.eg_phase_+1);var h=this.tl_out_+this.eg_level_;this.eg_out_=1023>h?h<<3:8184,this.eg_curve_count_++}var o=this.out_+this.out2_;this.out2_=this.out_;var _=this.pg_count_;this.pg_count_+=this.pg_diff_;var r=_>>19;31>s&&(r+=o<<1+e.IS2EC_SHIFT>>s>>19);var n=this.eg_out_+e.sinetable[1023&r];
return this.out_=8192>n?e.cltable[n]:0,this.out2_},e.prototype.CalcFBL=function(s){if(this.eg_count_-=this.eg_count_diff_,this.eg_count_<=0){if(this.eg_count_=786048,this.eg_phase_===t.EGPhase.attack){var i=e.attacktable[this.eg_rate_][7&this.eg_curve_count_];i>=0&&(this.eg_level_-=1+(this.eg_level_>>i),this.eg_level_<=0&&this.ShiftPhase(t.EGPhase.decay))}else this.eg_level_+=e.decaytable1[this.eg_rate_][7&this.eg_curve_count_],this.eg_level_>=this.eg_level_on_next_phase_&&this.ShiftPhase(this.eg_phase_+1);var h=this.tl_out_+this.eg_level_;this.eg_out_=1023>h?h<<3:8184,this.eg_curve_count_++}var o=this.out_+this.out2_;this.out2_=this.out_;var _=this.pg_count_;this.pg_count_+=this.pg_diff_+(this.pg_diff_lfo_*this.chip_.pmv_>>5);var r=_>>19;31>s&&(r+=o<<1+e.IS2EC_SHIFT>>s>>19);var n=this.eg_out_+e.sinetable[1023&r]+this.ams_[this.chip_.aml_];return this.out_=8192>n?e.cltable[n]:0,this.out_},e.prototype.ResetFB=function(){this.out_=this.out2_=0},e.prototype.KeyOn=function(){this.keyon_||(this.keyon_=!0,(this.eg_phase_===t.EGPhase.off||this.eg_phase_===t.EGPhase.release)&&(this.ssg_phase_=-1,this.ShiftPhase(t.EGPhase.attack),this.EGUpdate(),this.in2_=this.out_=this.out2_=0,this.pg_count_=0))},e.prototype.KeyOff=function(){this.keyon_&&(this.keyon_=!1,this.ShiftPhase(t.EGPhase.release))},e.prototype.IsOn=function(){return this.eg_phase_!==t.EGPhase.off},e.prototype.SetDT=function(t){this.detune_=32*t,this.param_changed_=!0},e.prototype.SetDT2=function(t){this.detune2_=3&t,this.param_changed_=!0},e.prototype.SetMULTI=function(t){this.multiple_=t,this.param_changed_=!0},e.prototype.SetTL=function(t,e){e||(this.tl_=t,this.param_changed_=!0),this.tl_latch_=t},e.prototype.SetAR=function(t){this.ar_=t,this.param_changed_=!0},e.prototype.SetDR=function(t){this.dr_=t,this.param_changed_=!0},e.prototype.SetSR=function(t){this.sr_=t,this.param_changed_=!0},e.prototype.SetSL=function(t){this.sl_=t,this.param_changed_=!0},e.prototype.SetRR=function(t){this.rr_=t,this.param_changed_=!0},e.prototype.SetKS=function(t){this.ks_=t,this.param_changed_=!0},e.prototype.SetAMON=function(t){this.amon_=t,this.param_changed_=!0},e.prototype.Mute=function(t){this.mute_=t,this.param_changed_=!0},e.prototype.SetMS=function(t){this.ms_=t,this.param_changed_=!0},e.prototype.Out=function(){return this.out_},e.prototype.Refresh=function(){this.param_changed_=!0},e.notetable=[0,0,0,0,0,0,0,1,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,5,6,7,7,7,7,7,7,7,8,8,8,8,8,8,8,9,10,11,11,11,11,11,11,11,12,12,12,12,12,12,12,13,14,15,15,15,15,15,15,15,16,16,16,16,16,16,16,17,18,19,19,19,19,19,19,19,20,20,20,20,20,20,20,21,22,23,23,23,23,23,23,23,24,24,24,24,24,24,24,25,26,27,27,27,27,27,27,27,28,28,28,28,28,28,28,29,30,31,31,31,31,31,31,31],e.dttable=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,4,4,4,4,4,6,6,6,8,8,8,10,10,12,12,14,16,16,16,16,2,2,2,2,4,4,4,4,4,6,6,6,8,8,8,10,10,12,12,14,16,16,18,20,22,24,26,28,32,32,32,32,4,4,4,4,4,6,6,6,8,8,8,10,10,12,12,14,16,16,18,20,22,24,26,28,32,34,38,40,44,44,44,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-2,-2,-2,-2,-2,-2,-2,-2,-4,-4,-4,-4,-4,-6,-6,-6,-8,-8,-8,-10,-10,-12,-12,-14,-16,-16,-16,-16,-2,-2,-2,-2,-4,-4,-4,-4,-4,-6,-6,-6,-8,-8,-8,-10,-10,-12,-12,-14,-16,-16,-18,-20,-22,-24,-26,-28,-32,-32,-32,-32,-4,-4,-4,-4,-4,-6,-6,-6,-8,-8,-8,-10,-10,-12,-12,-14,-16,-16,-18,-20,-22,-24,-26,-28,-32,-34,-38,-40,-44,-44,-44,-44],e.decaytable1=[[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1],[1,1,1,0,1,1,1,0],[1,1,1,0,1,1,1,0],[1,0,1,0,1,0,1,0],[1,1,1,0,1,0,1,0],[1,1,1,0,1,1,1,0],[1,1,1,1,1,1,1,0],[1,0,1,0,1,0,1,0],[1,1,1,0,1,0,1,0],[1,1,1,0,1,1,1,0],[1,1,1,1,1,1,1,0],[1,0,1,0,1,0,1,0],[1,1,1,0,1,0,1,0],[1,1,1,0,1,1,1,0],[1,1,1,1,1,1,1,0],[1,0,1,0,1,0,1,0],[1,1,1,0,1,0,1,0],[1,1,1,0,1,1,1,0],[1,1,1,1,1,1,1,0],[1,0,1,0,1,0,1,0],[1,1,1,0,1,0,1,0],[1,1,1,0,1,1,1,0],[1,1,1,1,1,1,1,0],[1,0,1,0,1,0,1,0],[1,1,1,0,1,0,1,0],[1,1,1,0,1,1,1,0],[1,1,1,1,1,1,1,0],[1,0,1,0,1,0,1,0],[1,1,1,0,1,0,1,0],[1,1,1,0,1,1,1,0],[1,1,1,1,1,1,1,0],[1,0,1,0,1,0,1,0],[1,1,1,0,1,0,1,0],[1,1,1,0,1,1,1,0],[1,1,1,1,1,1,1,0],[1,0,1,0,1,0,1,0],[1,1,1,0,1,0,1,0],[1,1,1,0,1,1,1,0],[1,1,1,1,1,1,1,0],[1,0,1,0,1,0,1,0],[1,1,1,0,1,0,1,0],[1,1,1,0,1,1,1,0],[1,1,1,1,1,1,1,0],[1,1,1,1,1,1,1,1],[2,1,1,1,2,1,1,1],[2,1,2,1,2,1,2,1],[2,2,2,1,2,2,2,1],[2,2,2,2,2,2,2,2],[4,2,2,2,4,2,2,2],[4,2,4,2,4,2,4,2],[4,4,4,2,4,4,4,2],[4,4,4,4,4,4,4,4],[8,4,4,4,8,4,4,4],[8,4,8,4,8,4,8,4],[8,8,8,4,8,8,8,4],[16,16,16,16,16,16,16,16],[16,16,16,16,16,16,16,16],[16,16,16,16,16,16,16,16],[16,16,16,16,16,16,16,16]],e.decaytable2=[1,2,4,8,16,32,64,128,256,512,1024,2047,2047,2047,2047,2047],e.attacktable=[[-1,-1,-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1,-1,-1],[4,4,4,4,4,4,4,4],[4,4,4,4,4,4,4,4],[4,4,4,4,4,4,4,4],[4,4,4,4,4,4,4,4],[4,4,4,-1,4,4,4,-1],[4,4,4,-1,4,4,4,-1],[4,-1,4,-1,4,-1,4,-1],[4,4,4,-1,4,-1,4,-1],[4,4,4,-1,4,4,4,-1],[4,4,4,4,4,4,4,-1],[4,-1,4,-1,4,-1,4,-1],[4,4,4,-1,4,-1,4,-1],[4,4,4,-1,4,4,4,-1],[4,4,4,4,4,4,4,-1],[4,-1,4,-1,4,-1,4,-1],[4,4,4,-1,4,-1,4,-1],[4,4,4,-1,4,4,4,-1],[4,4,4,4,4,4,4,-1],[4,-1,4,-1,4,-1,4,-1],[4,4,4,-1,4,-1,4,-1],[4,4,4,-1,4,4,4,-1],[4,4,4,4,4,4,4,-1],[4,-1,4,-1,4,-1,4,-1],[4,4,4,-1,4,-1,4,-1],[4,4,4,-1,4,4,4,-1],[4,4,4,4,4,4,4,-1],[4,-1,4,-1,4,-1,4,-1],[4,4,4,-1,4,-1,4,-1],[4,4,4,-1,4,4,4,-1],[4,4,4,4,4,4,4,-1],[4,-1,4,-1,4,-1,4,-1],[4,4,4,-1,4,-1,4,-1],[4,4,4,-1,4,4,4,-1],[4,4,4,4,4,4,4,-1],[4,-1,4,-1,4,-1,4,-1],[4,4,4,-1,4,-1,4,-1],[4,4,4,-1,4,4,4,-1],[4,4,4,4,4,4,4,-1],[4,-1,4,-1,4,-1,4,-1],[4,4,4,-1,4,-1,4,-1],[4,4,4,-1,4,4,4,-1],[4,4,4,4,4,4,4,-1],[4,-1,4,-1,4,-1,4,-1],[4,4,4,-1,4,-1,4,-1],[4,4,4,-1,4,4,4,-1],[4,4,4,4,4,4,4,-1],[4,4,4,4,4,4,4,4],[3,4,4,4,3,4,4,4],[3,4,3,4,3,4,3,4],[3,3,3,4,3,3,3,4],[3,3,3,3,3,3,3,3],[2,3,3,3,2,3,3,3],[2,3,2,3,2,3,2,3],[2,2,2,3,2,2,2,3],[2,2,2,2,2,2,2,2],[1,2,2,2,1,2,2,2],[1,2,1,2,1,2,1,2],[1,1,1,2,1,1,1,2],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0]],e.ssgenvtable=[[[[1,1],[1,1],[1,1]],[[0,1],[1,1],[1,1]]],[[[0,1],[2,0],[2,0]],[[0,1],[2,0],[2,0]]],[[[1,-1],[0,1],[1,-1]],[[0,1],[1,-1],[0,1]]],[[[1,-1],[0,0],[0,0]],[[0,1],[0,0],[0,0]]],[[[2,-1],[2,-1],[2,-1]],[[1,-1],[2,-1],[2,-1]]],[[[1,-1],[0,0],[0,0]],[[1,-1],[0,0],[0,0]]],[[[0,1],[1,-1],[0,1]],[[1,-1],[0,1],[1,-1]]],[[[0,1],[2,0],[2,0]],[[1,-1],[2,0],[2,0]]]],e.sinetable=function(){for(var t=[],e=Math.log(2),s=0;512>s;s++){var i=(2*s+1)*Math.PI/1024,h=-256*Math.log(Math.sin(i))/e,o=Math.floor(h+.5)+1;t[s]=2*o,t[512+s|0]=2*o+1}return t}(),e.cltable=function(){var t,e,s=[];for(t=0,e=0;256>t;t++){var i=Math.floor(Math.pow(2,13-t/256));i=i+2&-4,s[e++]=i,s[e++]=-i}for(t=e;8192>e;)s[e++]=s[t++-512]/2|0;return s}(),e.amtable=function(){for(var e,s,i=t.JaggArray.I3(2,8,256),h=[[31,6,4,3],[31,2,1,0]],o=0;2>o;o++)for(e=0;4>e;e++)for(s=0;256>s;s++)i[o][e][s]=2*(4*s>>h[o][e])<<2;return i}(),e.IS2EC_SHIFT=16,e}();t.Operator=e}(fmgenAs||(fmgenAs={}));var fmgenAs;!function(t){var e=function(e){function s(){e.call(this),this.amplevel=16384,this.kc=new Array(8),this.kf=new Array(8),this.pan=new Array(8),this.chip=new t.Chip,this.buf=new Array(4),this.ch=[new t.Channel4,new t.Channel4,new t.Channel4,new t.Channel4,new t.Channel4,new t.Channel4,new t.Channel4,new t.Channel4],this.lfo_count_=0,this.lfo_count_prev_=-1,s.BuildLFOTable();for(var i=0;8>i;i++)this.ch[i].SetChip(this.chip),this.ch[i].SetType(t.OpType.typeM);this.ix=this.ch[0].ix,this.ox=this.ch[0].ox}return __extends(s,e),s.BuildLFOTable=function(){if(!this.s_init){for(var t=0;4>t;t++)for(var e=0,s=0;512>s;s++){var i=0,h=0;switch(t){case 0:h=(s+256&511)/2-128,i=255-s/2;break;case 1:i=256>s?255:0,h=256>s?127:-128;break;case 2:h=s+128&511,h=256>h?h-128:383-h,i=256>s?255-s:s-256;break;case 3:0===(3&s)&&(e=(32768*Math.random()|0)/17&255),i=e,h=e-128}this.amtable[t][s]=i,this.pmtable[t][s]=-h-1}this.s_init=!0}},s.prototype.Init=function(t,e){return this.SetRate(t,e)?(this.Reset(),this.SetVolume(0),this.SetChannelMask(0),!0):!1},s.prototype.SetRate=function(t,e){return this.clock=t,this.pcmrate=e,this.rate=e,this.RebuildTimeTable(),!0},s.prototype.SetChannelMask=function(t){for(var e=0;8>e;e++)this.ch[e].Mute(0!==(t&1<<e))},s.prototype.Reset=function(){var t;for(t=0;256>t;t++)this.SetReg(t,0);for(this.SetReg(25,128),e.prototype.Reset.call(this),this.status=0,this.noise=12345,this.noisecount=0,t=0;8>t;t++)this.ch[t].Reset()},s.prototype.RebuildTimeTable=function(){var t=this.clock/64|0;this.rateratio=((t<<7)+this.rate/2)/this.rate|0,this.SetTimerBase(t),this.chip.SetRatio(this.rateratio)},s.prototype.TimerA=function(){if(128&this.regtc)for(var t=0;8>t;t++)this.ch[t].KeyControl(0),this.ch[t].KeyControl(15)},s.prototype.SetVolume=function(t){t=Math.min(t,20),t>-192?this.fmvolume=16384*Math.pow(10,t/40)|0:this.fmvolume=0},s.prototype.SetExpression=function(t){this.amplevel=16384*t|0},s.prototype.ReadStatus=function(){return 3&this.status},s.prototype.SetStatus=function(t){0===(this.status&t)&&(this.status|=t,this.Intr(!0))},s.prototype.ResetStatus=function(t){this.status&t&&(this.status&=~t,0===this.status&&this.Intr(!1))},s.prototype.SetReg=function(t,e){if(!(t>=256)){var s=7&t;switch(255&t){case 1:2&e&&(this.lfo_count_=0,this.lfo_count_prev_=-1),this.reg01=e;break;case 8:0===(128&this.regtc)?this.ch[7&e].KeyControl(e>>3):(s=7&e,0===(8&e)&&this.ch[s].op[0].KeyOff(),0===(16&e)&&this.ch[s].op[1].KeyOff(),0===(32&e)&&this.ch[s].op[2].KeyOff(),0===(64&e)&&this.ch[s].op[3].KeyOff());break;case 16:case 17:this.SetTimerA(t,e);break;case 18:this.SetTimerB(e);break;case 20:this.SetTimerControl(e);break;case 24:this.lfofreq=e,this.lfo_count_diff_=this.rateratio*(16+(15&this.lfofreq)<<5)/(1<<15-(this.lfofreq>>4));break;case 25:128&e?this.pmd=127&e:this.amd=127&e;break;case 27:this.lfowaveform=3&e;break;case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:this.ch[s].SetFB(e>>3&7),this.ch[s].SetAlgorithm(7&e),this.pan[s]=e>>6&3;break;case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:this.kc[s]=e,this.ch[s].SetKCKF(this.kc[s],this.kf[s]);break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:this.kf[s]=e>>2,this.ch[s].SetKCKF(this.kc[s],this.kf[s]);break;case 56:case 57:case 58:case 59:case 60:case 61:case 62:case 63:this.ch[s].SetMS(e<<4|e>>4);break;case 15:this.noisedelta=e,this.noisecount=0;break;default:t>=64&&this.SetParameter(t,e)}}},s.prototype.SetParameter=function(t,e){var i=s.slottable[t>>3&3],h=this.ch[7&t].op[i];switch(t>>5&7){case 2:h.SetDT(e>>4&7),h.SetMULTI(15&e);break;case 3:h.SetTL(127&e,0!==(128&this.regtc));break;case 4:h.SetKS(e>>6&3),h.SetAR(2*(31&e));break;case 5:h.SetDR(2*(31&e)),h.SetAMON(0!==(128&e));break;case 6:h.SetSR(2*(31&e)),h.SetDT2(e>>6&3);break;case 7:h.SetSL(s.sltable[e>>4&15]),h.SetRR(4*(15&e)+2)}},s.prototype.Mix=function(e,i,h){var o,_=0;for(o=0;8>o;o++)_=_<<2|this.ch[o].Prepare();if(21845&_){2&this.reg01&&(_&=21845);var r,n,m,a,p,c,l,u=(this.ch[0].algo_,this.ch[0].fb),f=this.ch[0].op[0],g=this.ch[0].op[1],S=this.ch[0].op[2],v=this.ch[0].op[3],y=this.buf,E=this.ix,M=this.ox,P=s.cltable,d=s.sinetable,A=s.attacktable,b=s.decaytable1;if(3!==this.lfowaveform)var N=s.pmtable,O=s.amtable;for(o=i;i+h>o;o++)3!==this.lfowaveform?(n=this.lfo_count_>>15&510,this.chip.pml_=N[this.lfowaveform][n]*this.pmd/128+128&255,this.chip.aml_=O[this.lfowaveform][n]*this.amd/128&255):-131072&(this.lfo_count_^this.lfo_count_prev_)&&(n=(32768*Math.random()|0)/17&255,this.chip.pml_=(n-128)*this.pmd/128+128&255,this.chip.aml_=n*this.amd/128&255),this.lfo_count_prev_=this.lfo_count_,this.lfo_step_++,0===(7&this.lfo_step_)&&(this.lfo_count_+=this.lfo_count_diff_),m=0,16384&_&&(43690&_?(this.ch[0].chip_.pmv_=this.ch[0].pms[this.ch[0].chip_.pml_],y[1]=y[2]=y[3]=0,y[0]=f.out_,f.eg_count_-=f.eg_count_diff_,f.eg_count_<=0&&(f.eg_count_=786048,f.eg_phase_===t.EGPhase.attack?(n=A[f.eg_rate_][7&f.eg_curve_count_],n>=0&&(f.eg_level_-=1+(f.eg_level_>>n),f.eg_level_<=0&&f.ShiftPhase(t.EGPhase.decay))):(f.eg_level_+=b[f.eg_rate_][7&f.eg_curve_count_],f.eg_level_>=f.eg_level_on_next_phase_&&f.ShiftPhase(f.eg_phase_+1)),r=f.tl_out_+f.eg_level_,f.eg_out_=1023>r?r<<3:8184,f.eg_curve_count_++),a=f.out_+f.out2_,f.out2_=f.out_,p=f.pg_count_,f.pg_count_+=f.pg_diff_+(f.pg_diff_lfo_*f.chip_.pmv_>>5),c=p>>19,31>u&&(c+=a<<1+t.Operator.IS2EC_SHIFT>>u>>19),l=f.eg_out_+d[1023&c]+f.ams_[f.chip_.aml_],f.out_=8192>l?P[l]:0,g.eg_count_-=g.eg_count_diff_,g.eg_count_<=0&&(g.eg_count_=786048,g.eg_phase_===t.EGPhase.attack?(n=A[g.eg_rate_][7&g.eg_curve_count_],n>=0&&(g.eg_level_-=1+(g.eg_level_>>n),g.eg_level_<=0&&g.ShiftPhase(t.EGPhase.decay))):(g.eg_level_+=b[g.eg_rate_][7&g.eg_curve_count_],g.eg_level_>=g.eg_level_on_next_phase_&&g.ShiftPhase(g.eg_phase_+1)),r=g.tl_out_+g.eg_level_,g.eg_out_=1023>r?r<<3:8184,g.eg_curve_count_++),a=y[E[0]],g.out2_=g.out_,p=g.pg_count_,g.pg_count_+=g.pg_diff_+(g.pg_diff_lfo_*g.chip_.pmv_>>5),c=p>>19,c+=a>>19-(2+t.Operator.IS2EC_SHIFT),l=g.eg_out_+d[1023&c]+g.ams_[g.chip_.aml_],g.out_=8192>l?P[l]:0,y[M[0]]+=g.out_,S.eg_count_-=S.eg_count_diff_,S.eg_count_<=0&&(S.eg_count_=786048,S.eg_phase_===t.EGPhase.attack?(n=A[S.eg_rate_][7&S.eg_curve_count_],n>=0&&(S.eg_level_-=1+(S.eg_level_>>n),S.eg_level_<=0&&S.ShiftPhase(t.EGPhase.decay))):(S.eg_level_+=b[S.eg_rate_][7&S.eg_curve_count_],S.eg_level_>=S.eg_level_on_next_phase_&&S.ShiftPhase(S.eg_phase_+1)),r=S.tl_out_+S.eg_level_,S.eg_out_=1023>r?r<<3:8184,S.eg_curve_count_++),a=y[E[1]],S.out2_=S.out_,p=S.pg_count_,S.pg_count_+=S.pg_diff_+(S.pg_diff_lfo_*S.chip_.pmv_>>5),c=p>>19,c+=a>>19-(2+t.Operator.IS2EC_SHIFT),l=S.eg_out_+d[1023&c]+S.ams_[S.chip_.aml_],S.out_=8192>l?P[l]:0,y[M[1]]+=S.out_,v.eg_count_-=v.eg_count_diff_,v.eg_count_<=0&&(v.eg_count_=786048,v.eg_phase_===t.EGPhase.attack?(n=A[v.eg_rate_][7&v.eg_curve_count_],n>=0&&(v.eg_level_-=1+(v.eg_level_>>n),v.eg_level_<=0&&v.ShiftPhase(t.EGPhase.decay))):(v.eg_level_+=b[v.eg_rate_][7&v.eg_curve_count_],v.eg_level_>=v.eg_level_on_next_phase_&&v.ShiftPhase(v.eg_phase_+1)),r=v.tl_out_+v.eg_level_,v.eg_out_=1023>r?r<<3:8184,v.eg_curve_count_++),a=y[E[2]],v.out2_=v.out_,p=v.pg_count_,v.pg_count_+=v.pg_diff_+(v.pg_diff_lfo_*v.chip_.pmv_>>5),c=p>>19,c+=a>>19-(2+t.Operator.IS2EC_SHIFT),l=v.eg_out_+d[1023&c]+v.ams_[v.chip_.aml_],v.out_=8192>l?P[l]:0,m=y[M[2]]+v.out_):(y[1]=y[2]=y[3]=0,y[0]=f.out_,f.eg_count_-=f.eg_count_diff_,f.eg_count_<=0&&(f.eg_count_=786048,f.eg_phase_===t.EGPhase.attack?(n=A[f.eg_rate_][7&f.eg_curve_count_],n>=0&&(f.eg_level_-=1+(f.eg_level_>>n),f.eg_level_<=0&&f.ShiftPhase(t.EGPhase.decay))):(f.eg_level_+=b[f.eg_rate_][7&f.eg_curve_count_],f.eg_level_>=f.eg_level_on_next_phase_&&f.ShiftPhase(f.eg_phase_+1)),r=f.tl_out_+f.eg_level_,f.eg_out_=1023>r?r<<3:8184,f.eg_curve_count_++),a=f.out_+f.out2_,f.out2_=f.out_,p=f.pg_count_,f.pg_count_+=f.pg_diff_,c=p>>19,31>u&&(c+=a<<1+t.Operator.IS2EC_SHIFT>>u>>19),l=f.eg_out_+d[1023&c],f.out_=8192>l?P[l]:0,g.eg_count_-=g.eg_count_diff_,g.eg_count_<=0&&(g.eg_count_=786048,g.eg_phase_===t.EGPhase.attack?(n=A[g.eg_rate_][7&g.eg_curve_count_],n>=0&&(g.eg_level_-=1+(g.eg_level_>>n),g.eg_level_<=0&&g.ShiftPhase(t.EGPhase.decay))):(g.eg_level_+=b[g.eg_rate_][7&g.eg_curve_count_],g.eg_level_>=g.eg_level_on_next_phase_&&g.ShiftPhase(g.eg_phase_+1)),r=g.tl_out_+g.eg_level_,g.eg_out_=1023>r?r<<3:8184,g.eg_curve_count_++),a=y[E[0]],g.out2_=g.out_,p=g.pg_count_,g.pg_count_+=g.pg_diff_,c=p>>19,c+=a>>19-(2+t.Operator.IS2EC_SHIFT),l=g.eg_out_+d[1023&c],g.out_=8192>l?P[l]:0,y[M[0]]+=g.out_,S.eg_count_-=S.eg_count_diff_,S.eg_count_<=0&&(S.eg_count_=786048,S.eg_phase_===t.EGPhase.attack?(n=A[S.eg_rate_][7&S.eg_curve_count_],n>=0&&(S.eg_level_-=1+(S.eg_level_>>n),S.eg_level_<=0&&S.ShiftPhase(t.EGPhase.decay))):(S.eg_level_+=b[S.eg_rate_][7&S.eg_curve_count_],S.eg_level_>=S.eg_level_on_next_phase_&&S.ShiftPhase(S.eg_phase_+1)),r=S.tl_out_+S.eg_level_,S.eg_out_=1023>r?r<<3:8184,S.eg_curve_count_++),a=y[E[1]],S.out2_=S.out_,p=S.pg_count_,S.pg_count_+=S.pg_diff_,c=p>>19,c+=a>>19-(2+t.Operator.IS2EC_SHIFT),l=S.eg_out_+d[1023&c],S.out_=8192>l?P[l]:0,y[M[1]]+=S.out_,v.eg_count_-=v.eg_count_diff_,v.eg_count_<=0&&(v.eg_count_=786048,v.eg_phase_===t.EGPhase.attack?(n=A[v.eg_rate_][7&v.eg_curve_count_],n>=0&&(v.eg_level_-=1+(v.eg_level_>>n),v.eg_level_<=0&&v.ShiftPhase(t.EGPhase.decay))):(v.eg_level_+=b[v.eg_rate_][7&v.eg_curve_count_],v.eg_level_>=v.eg_level_on_next_phase_&&v.ShiftPhase(v.eg_phase_+1)),r=v.tl_out_+v.eg_level_,v.eg_out_=1023>r?r<<3:8184,v.eg_curve_count_++),a=y[E[2]],v.out2_=v.out_,p=v.pg_count_,v.pg_count_+=v.pg_diff_,c=p>>19,c+=a>>19-(2+t.Operator.IS2EC_SHIFT),l=v.eg_out_+d[1023&c],v.out_=8192>l?P[l]:0,m=y[M[2]]+v.out_),e[o]=((m*this.fmvolume>>14)*this.amplevel>>14)/8192)}else e.set(msgr.emptyBuffer.subarray(0,h),i)},s.prototype.Intr=function(t){},s.prototype.IsOn=function(e){var s=this.ch[7&e];switch(s.algo_){case 0:case 1:case 2:case 3:return s.op[3].eg_phase_!==t.EGPhase.off;case 4:return s.op[1].eg_phase_!==t.EGPhase.off||s.op[3].eg_phase_!==t.EGPhase.off;case 5:case 6:return s.op[1].eg_phase_!==t.EGPhase.off||s.op[2].eg_phase_!==t.EGPhase.off||s.op[3].eg_phase_!==t.EGPhase.off;case 7:return s.op[0].eg_phase_!==t.EGPhase.off||s.op[1].eg_phase_!==t.EGPhase.off||s.op[2].eg_phase_!==t.EGPhase.off||s.op[3].eg_phase_!==t.EGPhase.off}return!1},s.s_init=!1,s.amtable=t.JaggArray.I2(4,512),s.pmtable=t.JaggArray.I2(4,512),s.sltable=[0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,124],s.slottable=[0,2,1,3],s.decaytable1=t.Operator.decaytable1,s.attacktable=t.Operator.attacktable,s.sinetable=t.Operator.sinetable,s.cltable=t.Operator.cltable,s}(t.Timer);t.OPM=e}(fmgenAs||(fmgenAs={}));var flmml;!function(t){var e=fmgenAs.OPM,s=function(t){function s(){this.m_fm=new e,this.m_oneSample=new Float32Array(1),this.m_velocity=127,this.m_al=0,this.m_tl=new Array(4),t.call(this),s.boot(),this.m_fm.Init(s.OPM_CLOCK,msgr.SAMPLE_RATE),this.m_fm.Reset(),this.m_fm.SetVolume(s.s_comGain),this.setOpMask(15),this.setWaveNo(0)}return __extends(s,t),s.boot=function(){0===this.s_init&&(this.s_table[0]=this.defTimbre,this.s_init=1)},s.clearTimber=function(){for(var t=0;t<this.s_table.length;t++)0===t?this.s_table[t]=this.defTimbre:this.s_table[t]=null},s.trim=function(t){var e=/^[,]*/m,s=/[,]*$/m;return t.replace(e,"").replace(s,"")},s.setTimber=function(t,e,s){if(!(0>t||this.MAX_WAVE<=t)){s=s.replace(/[,;\s\t\r\n]+/gm,","),s=this.trim(s);var i=s.split(","),h=new Array(this.TIMB_SZ_M);switch(e){case this.TYPE_OPM:if(i.length<46)return;break;case this.TYPE_OPN:if(i.length<42)return;break;default:return}var o,_,r;switch(e){case this.TYPE_OPM:for(r=Math.min(this.TIMB_SZ_M,i.length),o=0;r>o;o++)h[o]=0|i[o];for(;o<this.TIMB_SZ_M;o++)h[o]=this.zeroTimbre[o];break;case this.TYPE_OPN:for(o=0,_=0;2>o;o++,_++)h[o]=0|i[_];for(;46>o;o++)(o-2)%11===9?h[o]=0:h[o]=0|i[_++];for(r=Math.min(this.TIMB_SZ_N,i.length);r>_;o++,_++)h[o]=0|i[_];for(;o<this.TIMB_SZ_M;o++)h[o]=this.zeroTimbre[o]}this.s_table[t]=h}},s.prototype.loadTimbre=function(t){this.SetFBAL(t[1],t[0]);var e,i,h=s.slottable;for(e=2,i=0;4>i;i++,e+=11)this.SetDT1ML(h[i],t[e+8],t[e+7]),this.m_tl[i]=t[e+5],this.SetTL(h[i],t[e+5]),this.SetKSAR(h[i],t[e+6],t[e+0]),this.SetDRAMS(h[i],t[e+1],t[e+10]),this.SetDT2SR(h[i],t[e+9],t[e+2]),this.SetSLRR(h[i],t[e+4],t[e+3]);this.setVelocity(this.m_velocity),this.setOpMask(t[e+0]),this.setWF(t[e+1]),this.setLFRQ(t[e+2]),this.setPMD(t[e+3]),this.setAMD(t[e+4]),this.setPMSAMS(t[e+5],t[e+6]),this.setNENFRQ(t[e+7],t[e+8])},s.setCommonGain=function(t){this.s_comGain=t},s.prototype.SetFBAL=function(t,e){var s=3;this.m_al=7&e,this.m_fm.SetReg(32,(3&s)<<6|(7&t)<<3|7&e)},s.prototype.SetDT1ML=function(t,e,s){this.m_fm.SetReg(64|(3&t)<<3,(7&e)<<4|15&s)},s.prototype.SetTL=function(t,e){0>e&&(e=0),e>127&&(e=127),this.m_fm.SetReg(96|(3&t)<<3,127&e)},s.prototype.SetKSAR=function(t,e,s){this.m_fm.SetReg(128|(3&t)<<3,(3&e)<<6|31&s)},s.prototype.SetDRAMS=function(t,e,s){this.m_fm.SetReg(160|(3&t)<<3,(1&s)<<7|31&e)},s.prototype.SetDT2SR=function(t,e,s){this.m_fm.SetReg(192|(3&t)<<3,(3&e)<<6|31&s)},s.prototype.SetSLRR=function(t,e,s){this.m_fm.SetReg(224|(3&t)<<3,(15&e)<<4|15&s)},s.prototype.setPMSAMS=function(t,e){this.m_fm.SetReg(56,(7&t)<<4|3&e)},s.prototype.setPMD=function(t){this.m_fm.SetReg(25,128|127&t)},s.prototype.setAMD=function(t){this.m_fm.SetReg(25,0|127&t)},s.prototype.setNENFRQ=function(t,e){this.m_fm.SetReg(15,(1&t)<<7|31&e)},s.prototype.setLFRQ=function(t){this.m_fm.SetReg(24,255&t)},s.prototype.setWF=function(t){this.m_fm.SetReg(27,3&t)},s.prototype.noteOn=function(){this.m_fm.SetReg(1,2),this.m_fm.SetReg(1,0),this.m_fm.SetReg(8,this.m_opMask<<3)},s.prototype.noteOff=function(){this.m_fm.SetReg(8,0)},s.prototype.setWaveNo=function(t){t>=s.MAX_WAVE&&(t=s.MAX_WAVE-1),null==s.s_table[t]&&(t=0),this.m_fm.SetVolume(s.s_comGain),this.loadTimbre(s.s_table[t])},s.prototype.setNoteNo=function(t){this.noteOn()},s.prototype.setOpMask=function(t){this.m_opMask=15&t},s.prototype.setVelocity=function(t){this.m_velocity=t;var e=this.m_al,i=this.m_tl,h=s.carrierop[e],o=s.slottable;this.SetTL(o[0],i[0]+(8&h?127-t:0)),this.SetTL(o[1],i[1]+(16&h?127-t:0)),this.SetTL(o[2],i[2]+(32&h?127-t:0)),this.SetTL(o[3],i[3]+(64&h?127-t:0))},s.prototype.setExpression=function(t){this.m_fm.SetExpression(t)},s.prototype.setFrequency=function(e){if(this.m_frequency!==e){t.prototype.setFrequency.call(this,e);var i=1200*Math.log(e/440)*Math.LOG2E+5700+s.OPM_RATIO+.5|0,h=i/100|0,o=i%100,_=64*o/100+.5|0,r=(h-1)/12<<4|s.kctable[(h+1200)%12];this.m_fm.SetReg(48,_<<2),this.m_fm.SetReg(40,r)}},s.prototype.getNextSample=function(){return this.m_fm.Mix(this.m_oneSample,0,1),this.m_oneSample[0]},s.prototype.getNextSampleOfs=function(t){return this.m_fm.Mix(this.m_oneSample,0,1),this.m_oneSample[0]},s.prototype.getSamples=function(t,e,s){this.m_fm.Mix(t,e,s-e)},s.prototype.IsPlaying=function(){return this.m_fm.IsOn(0)},s.MAX_WAVE=128,s.OPM_CLOCK=358e4,s.OPM_RATIO=0,s.TIMB_SZ_M=55,s.TIMB_SZ_N=51,s.TYPE_OPM=0,s.TYPE_OPN=1,s.s_init=0,s.s_table=new Array(s.MAX_WAVE),s.s_comGain=14.25,s.kctable=[14,0,1,2,4,5,6,8,9,10,12,13],s.slottable=[0,2,1,3],s.carrierop=[64,64,64,64,80,112,112,120],s.defTimbre=[4,5,31,5,0,0,0,23,1,1,3,0,0,20,10,3,7,8,0,1,1,3,0,0,31,3,0,0,0,25,1,1,7,0,0,31,12,3,7,10,2,1,1,7,0,0,15,0,0,0,0,0,0,0,0],s.zeroTimbre=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,0,0,0,0],s}(t.MOscMod);t.MOscOPM=s}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.setPWM(.5),this.setMIX(0)}return __extends(e,t),e.boot=function(){},e.prototype.getNextSample=function(){var t=this.m_phase<this.m_pwm?1:this.m_mix?this.m_modNoise.getNextSample():-1;return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,t},e.prototype.getNextSampleOfs=function(t){var s=(this.m_phase+t&e.PHASE_MSK)<this.m_pwm?1:this.m_mix?this.m_modNoise.getNextSampleOfs(t):-1;return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,s},e.prototype.getSamples=function(t,s,i){var h;if(this.m_mix)for(h=s;i>h;h++)t[h]=this.m_phase<this.m_pwm?1:this.m_modNoise.getNextSample(),this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK;else for(h=s;i>h;h++)t[h]=this.m_phase<this.m_pwm?1:-1,this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncIn=function(t,s,i,h){var o;if(this.m_mix)for(o=i;h>o;o++)s[o]&&this.resetPhase(),t[o]=this.m_phase<this.m_pwm?1:this.m_modNoise.getNextSample(),this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK;else for(o=i;h>o;o++)s[o]&&this.resetPhase(),t[o]=this.m_phase<this.m_pwm?1:-1,this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncOut=function(t,s,i,h){var o;if(this.m_mix)for(o=i;h>o;o++)t[o]=this.m_phase<this.m_pwm?1:this.m_modNoise.getNextSample(),this.m_phase+=this.m_freqShift,s[o]=this.m_phase>e.PHASE_MSK,this.m_phase&=e.PHASE_MSK;else for(o=i;h>o;o++)t[o]=this.m_phase<this.m_pwm?1:-1,this.m_phase+=this.m_freqShift,s[o]=this.m_phase>e.PHASE_MSK,this.m_phase&=e.PHASE_MSK},e.prototype.setPWM=function(t){this.m_pwm=t*e.PHASE_LEN},e.prototype.setMIX=function(t){this.m_mix=t},e.prototype.setNoise=function(t){this.m_modNoise=t},e}(t.MOscMod);t.MOscPulse=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.setWaveNo(0)}return __extends(e,t),e.boot=function(){if(!this.s_init){var t,e,s=1/this.TABLE_LEN;for(this.s_table=new Array(this.MAX_WAVE),e=0;e<this.MAX_WAVE;e++)this.s_table[e]=new Array(this.TABLE_LEN);for(e=0,t=0;e<this.TABLE_LEN;e++)this.s_table[0][e]=2*t-1,this.s_table[1][e]=.5>t?2*t:2*t-2,t+=s;this.s_init=1}},e.prototype.getNextSample=function(){var t=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,t},e.prototype.getNextSampleOfs=function(t){var s=e.s_table[this.m_waveNo][(this.m_phase+t&e.PHASE_MSK)>>e.PHASE_SFT];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,s},e.prototype.getSamples=function(t,s,i){var h;for(h=s;i>h;h++)t[h]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncIn=function(t,s,i,h){var o;for(o=i;h>o;o++)s[o]&&this.resetPhase(),t[o]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncOut=function(t,s,i,h){var o;for(o=i;h>o;o++)t[o]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT],this.m_phase+=this.m_freqShift,s[o]=this.m_phase>e.PHASE_MSK,this.m_phase&=e.PHASE_MSK},e.prototype.setWaveNo=function(t){this.m_waveNo=Math.min(t,e.MAX_WAVE-1)},e.MAX_WAVE=2,e.s_init=0,e}(t.MOscMod);t.MOscSaw=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.setWaveNo(0)}return __extends(e,t),e.boot=function(){if(!this.s_init){var t,e,s=2*Math.PI/this.TABLE_LEN;for(e=0;e<this.MAX_WAVE;e++)this.s_table[e]=new Array(this.TABLE_LEN);for(e=0,t=0;e<this.TABLE_LEN;e++)this.s_table[0][e]=Math.sin(t),this.s_table[1][e]=Math.max(0,this.s_table[0][e]),this.s_table[2][e]=this.s_table[0][e]>=0?this.s_table[0][e]:-1*this.s_table[0][e],t+=s;this.s_init=1}},e.prototype.getNextSample=function(){var t=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,t},e.prototype.getNextSampleOfs=function(t){var s=e.s_table[this.m_waveNo][(this.m_phase+t&e.PHASE_MSK)>>e.PHASE_SFT];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,s},e.prototype.getSamples=function(t,s,i){var h,o=e.s_table[this.m_waveNo];for(h=s;i>h;h++)t[h]=o[this.m_phase>>e.PHASE_SFT],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncIn=function(t,s,i,h){var o,_=e.s_table[this.m_waveNo];for(o=i;h>o;o++)s[o]&&this.resetPhase(),t[o]=_[this.m_phase>>e.PHASE_SFT],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncOut=function(t,s,i,h){var o,_=e.s_table[this.m_waveNo];for(o=i;h>o;o++)t[o]=_[this.m_phase>>e.PHASE_SFT],this.m_phase+=this.m_freqShift,s[o]=this.m_phase>e.PHASE_MSK,this.m_phase&=e.PHASE_MSK},e.prototype.setWaveNo=function(t){t>=e.MAX_WAVE&&(t=e.MAX_WAVE-1),e.s_table[t]||(t=0),this.m_waveNo=t},e.MAX_WAVE=3,e.s_init=0,e.s_table=new Array(e.MAX_WAVE),e}(t.MOscMod);t.MOscSine=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.setWaveNo(0)}return __extends(e,t),e.boot=function(){if(!this.s_init){var t,e,s=1/this.TABLE_LEN;for(this.s_table=new Array(this.MAX_WAVE),e=0;e<this.MAX_WAVE;e++)this.s_table[e]=new Array(this.TABLE_LEN);for(e=0,t=0;e<this.TABLE_LEN;e++)this.s_table[0][e]=.5>t?1-4*t:1-4*(1-t),this.s_table[1][e]=.25>t?0-4*t:.75>t?-2+4*t:4-4*t,t+=s;this.s_init=1}},e.prototype.getNextSample=function(){var t=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,t},e.prototype.getNextSampleOfs=function(t){var s=e.s_table[this.m_waveNo][(this.m_phase+t&e.PHASE_MSK)>>e.PHASE_SFT];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,s},e.prototype.getSamples=function(t,s,i){var h;for(h=s;i>h;h++)t[h]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncIn=function(t,s,i,h){var o;for(o=i;h>o;o++)s[o]&&this.resetPhase(),t[o]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncOut=function(t,s,i,h){var o;for(o=i;h>o;o++)t[o]=e.s_table[this.m_waveNo][this.m_phase>>e.PHASE_SFT],this.m_phase+=this.m_freqShift,s[o]=this.m_phase>e.PHASE_MSK,this.m_phase&=e.PHASE_MSK},e.prototype.setWaveNo=function(t){this.m_waveNo=Math.min(t,e.MAX_WAVE-1)},e.MAX_WAVE=2,e.s_init=0,e}(t.MOscMod);t.MOscTriangle=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(t){function e(){e.boot(),t.call(this),this.setWaveNo(0)}return __extends(e,t),e.boot=function(){this.s_init||(this.s_table=new Array(this.MAX_WAVE),this.s_length=new Array(this.MAX_WAVE),this.setWave(0,"00112233445566778899AABBCCDDEEFFFFEEDDCCBBAA99887766554433221100"),this.s_init=1)},e.setWave=function(t,e){this.s_length[t]=0,this.s_table[t]=new Array(e.length/2|0),this.s_table[t][0]=0;for(var s=0,i=0,h=0;s<this.MAX_LENGTH&&s<e.length;s++,i++){var o=e.charCodeAt(s);o>=48&&58>o?o-=48:o>=97&&103>o?o-=87:o=0,1&i?(h+=o,this.s_table[t][this.s_length[t]]=(Number(h)-127.5)/127.5,this.s_length[t]++):h=o<<4}0===this.s_length[t]&&(this.s_length[t]=1),this.s_length[t]=(this.PHASE_MSK+1)/this.s_length[t]},e.prototype.setWaveNo=function(t){t>=e.MAX_WAVE&&(t=e.MAX_WAVE-1),e.s_table[t]||(t=0),this.m_waveNo=t},e.prototype.getNextSample=function(){var t=e.s_table[this.m_waveNo][Math.floor(this.m_phase/e.s_length[this.m_waveNo])];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,t},e.prototype.getNextSampleOfs=function(t){var s=e.s_table[this.m_waveNo][Math.floor((this.m_phase+t&e.PHASE_MSK)/e.s_length[this.m_waveNo])];return this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK,s},e.prototype.getSamples=function(t,s,i){var h;for(h=s;i>h;h++)t[h]=e.s_table[this.m_waveNo][Math.floor(this.m_phase/e.s_length[this.m_waveNo])],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncIn=function(t,s,i,h){var o;for(o=i;h>o;o++)s[o]&&this.resetPhase(),t[o]=e.s_table[this.m_waveNo][Math.floor(this.m_phase/e.s_length[this.m_waveNo])],this.m_phase=this.m_phase+this.m_freqShift&e.PHASE_MSK},e.prototype.getSamplesWithSyncOut=function(t,s,i,h){var o;for(o=i;h>o;o++)t[o]=e.s_table[this.m_waveNo][Math.floor(this.m_phase/e.s_length[this.m_waveNo])],this.m_phase+=this.m_freqShift,s[o]=this.m_phase>e.PHASE_MSK,this.m_phase&=e.PHASE_MSK},e.MAX_WAVE=32,e.MAX_LENGTH=2048,e.s_init=0,e}(t.MOscMod);t.MOscWave=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function e(e){this.m_voices=new Array(e);for(var s=0;s<this.m_voices.length;s++)this.m_voices[s]=new t.MChannel;this.m_form=t.MOscillator.FC_PULSE,this.m_subform=0,this.m_voiceId=0,this.m_volMode=0,this.m_voiceLimit=e,this.m_lastVoice=null,this.m_voiceLen=this.m_voices.length}return e.prototype.setExpression=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setExpression(t)},e.prototype.setVelocity=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setVelocity(t)},e.prototype.setNoteNo=function(t,e){void 0===e&&(e=!0),null!==this.m_lastVoice&&this.m_lastVoice.isPlaying()&&this.m_lastVoice.setNoteNo(t,e)},e.prototype.setDetune=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setDetune(t)},e.prototype.getVoiceCount=function(){var t,e=0;for(t=0;t<this.m_voiceLen;t++)e+=this.m_voices[t].getVoiceCount();return e},e.prototype.noteOn=function(t,e){var s,i=null;if(this.getVoiceCount()<=this.m_voiceLimit)for(s=0;s<this.m_voiceLen;s++)if(this.m_voices[s].isPlaying()===!1){i=this.m_voices[s];break}if(null==i){var h=Number.MAX_VALUE;for(s=0;s<this.m_voiceLen;s++)h>this.m_voices[s].getId()&&(h=this.m_voices[s].getId(),
i=this.m_voices[s])}i.setForm(this.m_form,this.m_subform),i.setVolMode(this.m_volMode),i.noteOnWidthId(t,e,this.m_voiceId++),this.m_lastVoice=i},e.prototype.noteOff=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].getNoteNo()===t&&this.m_voices[e].noteOff(t)},e.prototype.setSoundOff=function(){for(var t=0;t<this.m_voiceLen;t++)this.m_voices[t].setSoundOff()},e.prototype.close=function(){for(var t=0;t<this.m_voiceLen;t++)this.m_voices[t].close()},e.prototype.setNoiseFreq=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setNoiseFreq(t)},e.prototype.setForm=function(t,e){this.m_form=t,this.m_subform=e},e.prototype.setEnvelope1Atk=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setEnvelope1Atk(t)},e.prototype.setEnvelope1Point=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setEnvelope1Point(t,e)},e.prototype.setEnvelope1Rel=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setEnvelope1Rel(t)},e.prototype.setEnvelope2Atk=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setEnvelope2Atk(t)},e.prototype.setEnvelope2Point=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setEnvelope2Point(t,e)},e.prototype.setEnvelope2Rel=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setEnvelope2Rel(t)},e.prototype.setPWM=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setPWM(t)},e.prototype.setPan=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setPan(t)},e.prototype.setFormant=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setFormant(t)},e.prototype.setLFOFMSF=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setLFOFMSF(t,e)},e.prototype.setLFODPWD=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setLFODPWD(t,e)},e.prototype.setLFODLTM=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setLFODLTM(t,e)},e.prototype.setLFOTarget=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setLFOTarget(t)},e.prototype.setLpfSwtAmt=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setLpfSwtAmt(t,e)},e.prototype.setLpfFrqRes=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setLpfFrqRes(t,e)},e.prototype.setVolMode=function(t){this.m_volMode=t},e.prototype.setInput=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setInput(t,e)},e.prototype.setOutput=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setOutput(t,e)},e.prototype.setRing=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setRing(t,e)},e.prototype.setSync=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setSync(t,e)},e.prototype.setPortamento=function(t,e){for(var s=0;s<this.m_voiceLen;s++)this.m_voices[s].setPortamento(t,e)},e.prototype.setMidiPort=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setMidiPort(t)},e.prototype.setMidiPortRate=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setMidiPortRate(t)},e.prototype.setPortBase=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setPortBase(t)},e.prototype.setVoiceLimit=function(t){this.m_voiceLimit=Math.max(1,Math.min(t,this.m_voiceLen))},e.prototype.setHwLfo=function(t){for(var e=0;e<this.m_voiceLen;e++)this.m_voices[e].setHwLfo(t)},e.prototype.reset=function(){this.m_form=0,this.m_subform=0,this.m_voiceId=0,this.m_volMode=0;for(var t=0;t<this.m_voiceLen;t++)this.m_voices[t].reset()},e.prototype.getSamples=function(t,e,s,i){for(var h=!1,o=0;o<this.m_voiceLen;o++)this.m_voices[o].isPlaying()&&(this.m_voices[o].setSlaveVoice(h),this.m_voices[o].getSamples(t,e,s,i),h=!0);h===!1&&this.m_voices[0].clearOutPipe(e,s,i)},e}();t.MPolyChannel=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function e(){this.m_isEnd=0,this.m_ch=new t.MChannel,this.m_needle=0,this.m_polyFound=!1,this.playTempo(e.DEFAULT_BPM),this.m_volume=100,this.recGate(.9375),this.recGate2(0),this.m_events=new Array,this.m_pointer=0,this.m_delta=0,this.m_globalTick=0,this.m_lfoWidth=0,this.m_totalMSec=0,this.m_chordBegin=0,this.m_chordEnd=0,this.m_chordMode=!1,e.SAMPLE_RATE||(e.SAMPLE_RATE=msgr.SAMPLE_RATE)}return e.prototype.getNumEvents=function(){return this.m_events.length},e.prototype.onSampleData=function(t,s,i,h){if(void 0===h&&(h=!1),!this.isEnd())for(var o=s;i>o;){var _,r,n=0,m=this.m_events.length;do if(n=0,this.m_pointer<m&&(_=this.m_events[this.m_pointer],r=_.getDelta()*this.m_spt,this.m_needle>=r)){switch(n=1,_.getStatus()){case 2:this.m_ch.noteOn(_.getNoteNo(),_.getVelocity());break;case 3:this.m_ch.noteOff(_.getNoteNo());break;case 6:this.m_ch.setNoteNo(_.getNoteNo());break;case 5:break;case 4:this.playTempo(_.getTempo());break;case 7:this.m_ch.setForm(_.getForm(),_.getSubForm());break;case 8:this.m_ch.setEnvelope1Atk(_.getEnvelopeA());break;case 9:this.m_ch.setEnvelope1Point(_.getEnvelopeT(),_.getEnvelopeL());break;case 10:this.m_ch.setEnvelope1Rel(_.getEnvelopeR());break;case 24:this.m_ch.setEnvelope2Atk(_.getEnvelopeA());break;case 25:this.m_ch.setEnvelope2Point(_.getEnvelopeT(),_.getEnvelopeL());break;case 26:this.m_ch.setEnvelope2Rel(_.getEnvelopeR());break;case 11:this.m_ch.setNoiseFreq(_.getNoiseFreq());break;case 12:this.m_ch.setPWM(_.getPWM());break;case 13:this.m_ch.setPan(_.getPan());break;case 14:this.m_ch.setFormant(_.getVowel());break;case 15:this.m_ch.setDetune(_.getDetune());break;case 16:this.m_ch.setLFOFMSF(_.getLFOForm(),_.getLFOSubForm());break;case 17:this.m_lfoWidth=_.getLFOWidth()*this.m_spt,this.m_ch.setLFODPWD(_.getLFODepth(),e.SAMPLE_RATE/this.m_lfoWidth);break;case 18:this.m_ch.setLFODLTM(_.getLFODelay()*this.m_spt,_.getLFOTime()*this.m_lfoWidth);break;case 19:this.m_ch.setLFOTarget(_.getLFOTarget());break;case 20:this.m_ch.setLpfSwtAmt(_.getLPFSwt(),_.getLPFAmt());break;case 21:this.m_ch.setLpfFrqRes(_.getLPFFrq(),_.getLPFRes());break;case 23:this.m_ch.setVolMode(_.getVolMode());break;case 27:this.m_ch.setInput(_.getInputSens(),_.getInputPipe());break;case 28:this.m_ch.setOutput(_.getOutputMode(),_.getOutputPipe());break;case 29:this.m_ch.setExpression(_.getExpression());break;case 30:this.m_ch.setRing(_.getRingSens(),_.getRingInput());break;case 31:this.m_ch.setSync(_.getSyncMode(),_.getSyncPipe());break;case 32:this.m_ch.setPortamento(100*_.getPorDepth(),_.getPorLen()*this.m_spt);break;case 33:this.m_ch.setMidiPort(_.getMidiPort());break;case 34:var a=_.getMidiPortRate();this.m_ch.setMidiPortRate((8-7.99*a/128)/a);break;case 35:this.m_ch.setPortBase(100*_.getPortBase());break;case 36:this.m_ch.setVoiceLimit(_.getVoiceCount());break;case 39:this.m_ch.setHwLfo(_.getHwLfoData());break;case 37:this.m_ch.setSoundOff();break;case 38:this.m_ch.reset();break;case 22:this.m_ch.close();break;case 0:this.m_isEnd=1;break;case 1:}this.m_needle-=r,this.m_pointer++}while(n);var p;if(!(this.m_pointer<m))break;_=this.m_events[this.m_pointer],r=_.getDelta()*this.m_spt,p=Math.ceil(r-this.m_needle),o+p>=i&&(p=i-o),this.m_needle+=p,h||this.m_ch.getSamples(t,i,o,p),o+=p}},e.prototype.seek=function(t){this.m_delta+=t,this.m_globalTick+=t,this.m_chordEnd=Math.max(this.m_chordEnd,this.m_globalTick)},e.prototype.seekChordStart=function(){this.m_globalTick=this.m_chordBegin},e.prototype.recDelta=function(t){t.setDelta(this.m_delta),this.m_delta=0},e.prototype.recNote=function(t,e,s,i,h){void 0===i&&(i=1),void 0===h&&(h=1);var o=this.makeEvent();if(i?o.setNoteOn(t,s):o.setNote(t),this.pushEvent(o),h){var _;_=(e*this.m_gate|0)-this.m_gate2,0>=_&&(_=0),this.seek(_),this.recNoteOff(t,s),this.seek(e-_),this.m_chordMode&&this.seekChordStart()}else this.seek(e)},e.prototype.recNoteOff=function(t,e){var s=this.makeEvent();s.setNoteOff(t,e),this.pushEvent(s)},e.prototype.recRest=function(t){this.seek(t),this.m_chordMode&&(this.m_chordBegin+=t)},e.prototype.recChordStart=function(){this.m_chordMode===!1&&(this.m_chordMode=!0,this.m_chordBegin=this.m_globalTick)},e.prototype.recChordEnd=function(){this.m_chordMode&&(this.m_events.length>0?this.m_delta=this.m_chordEnd-this.m_events[this.m_events.length-1].getTick():this.m_delta=0,this.m_globalTick=this.m_chordEnd,this.m_chordMode=!1)},e.prototype.recRestMSec=function(t){var s=t*e.SAMPLE_RATE/(1e3*this.m_spt)|0;this.seek(s)},e.prototype.recVolume=function(t){var e=this.makeEvent();e.setVolume(t),this.pushEvent(e)},e.prototype.recGlobal=function(t,e){for(var s=this.m_events.length,i=0,h=0;s>h;h++){var o=this.m_events[h],_=i+o.getDelta();if(_>t||_===t&&4!==o.getStatus())return o.setDelta(_-t),e.setDelta(t-i),void this.m_events.splice(h,0,e);i=_}e.setDelta(t-i),this.m_events.push(e)},e.prototype.insertEvent=function(t){for(var e=this.m_events.length,s=0,i=t.getTick(),h=0;e>h;h++){var o=this.m_events[h],_=s+o.getDelta();if(_>i)return o.setDelta(_-i),t.setDelta(i-s),void this.m_events.splice(h,0,t);s=_}t.setDelta(i-s),this.m_events.push(t)},e.prototype.makeEvent=function(){var e=new t.MEvent(this.m_globalTick);return e.setDelta(this.m_delta),this.m_delta=0,e},e.prototype.pushEvent=function(t){this.m_chordMode===!1?this.m_events.push(t):this.insertEvent(t)},e.prototype.recTempo=function(e,s){var i=new t.MEvent(e);i.setTempo(s),this.recGlobal(e,i)},e.prototype.recEOT=function(){var t=this.makeEvent();t.setEOT(),this.pushEvent(t)},e.prototype.recGate=function(t){this.m_gate=t},e.prototype.recGate2=function(t){0>t&&(t=0),this.m_gate2=t},e.prototype.recForm=function(t,e){var s=this.makeEvent();s.setForm(t,e),this.pushEvent(s)},e.prototype.recEnvelope=function(t,e,s,i,h){var o=this.makeEvent();1===t?o.setEnvelope1Atk(e):o.setEnvelope2Atk(e),this.pushEvent(o);for(var _=0,r=s.length;r>_;_++)o=this.makeEvent(),1===t?o.setEnvelope1Point(s[_],i[_]):o.setEnvelope2Point(s[_],i[_]),this.pushEvent(o);o=this.makeEvent(),1===t?o.setEnvelope1Rel(h):o.setEnvelope2Rel(h),this.pushEvent(o)},e.prototype.recNoiseFreq=function(t){var e=this.makeEvent();e.setNoiseFreq(t),this.pushEvent(e)},e.prototype.recPWM=function(t){var e=this.makeEvent();e.setPWM(t),this.pushEvent(e)},e.prototype.recPan=function(t){var e=this.makeEvent();e.setPan(t),this.pushEvent(e)},e.prototype.recFormant=function(t){var e=this.makeEvent();e.setFormant(t),this.pushEvent(e)},e.prototype.recDetune=function(t){var e=this.makeEvent();e.setDetune(t),this.pushEvent(e)},e.prototype.recLFO=function(t,e,s,i,h,o,_){var r=this.makeEvent();r.setLFOFMSF(s,i),this.pushEvent(r),r=this.makeEvent(),r.setLFODPWD(t,e),this.pushEvent(r),r=this.makeEvent(),r.setLFODLTM(h,o),this.pushEvent(r),r=this.makeEvent(),r.setLFOTarget(_),this.pushEvent(r)},e.prototype.recLPF=function(t,e,s,i){var h=this.makeEvent();h.setLPFSWTAMT(t,e),this.pushEvent(h),h=this.makeEvent(),h.setLPFFRQRES(s,i),this.pushEvent(h)},e.prototype.recVolMode=function(t){var e=this.makeEvent();e.setVolMode(t),this.pushEvent(e)},e.prototype.recInput=function(t,e){var s=this.makeEvent();s.setInput(t,e),this.pushEvent(s)},e.prototype.recOutput=function(t,e){var s=this.makeEvent();s.setOutput(t,e),this.pushEvent(s)},e.prototype.recExpression=function(t){var e=this.makeEvent();e.setExpression(t),this.pushEvent(e)},e.prototype.recRing=function(t,e){var s=this.makeEvent();s.setRing(t,e),this.pushEvent(s)},e.prototype.recSync=function(t,e){var s=this.makeEvent();s.setSync(t,e),this.pushEvent(s)},e.prototype.recClose=function(){var t=this.makeEvent();t.setClose(),this.pushEvent(t)},e.prototype.recPortamento=function(t,e){var s=this.makeEvent();s.setPortamento(t,e),this.pushEvent(s)},e.prototype.recMidiPort=function(t){var e=this.makeEvent();e.setMidiPort(t),this.pushEvent(e)},e.prototype.recMidiPortRate=function(t){var e=this.makeEvent();e.setMidiPortRate(t),this.pushEvent(e)},e.prototype.recPortBase=function(t){var e=this.makeEvent();e.setPortBase(t),this.pushEvent(e)},e.prototype.recPoly=function(t){var e=this.makeEvent();e.setPoly(t),this.pushEvent(e),this.m_polyFound=!0},e.prototype.recHwLfo=function(t,e,s,i,h,o,_){var r=this.makeEvent();r.setHwLfo(t,e,s,i,h,o,_),this.pushEvent(r)},e.prototype.isEnd=function(){return this.m_isEnd},e.prototype.getRecGlobalTick=function(){return this.m_globalTick},e.prototype.seekTop=function(){this.m_globalTick=0},e.prototype.conduct=function(t){var s,i,h,o=this.m_events.length,_=t.length,r=0,n=0,m=this.calcSpt(e.DEFAULT_BPM);for(s=0;o>s;s++)switch(h=this.m_events[s],r+=h.getDelta(),n+=h.getDelta()*m,h.getStatus()){case 4:for(m=this.calcSpt(h.getTempo()),i=e.FIRST_TRACK;_>i;i++)t[i].recTempo(r,h.getTempo())}var a=0;for(i=e.FIRST_TRACK;_>i;i++)a<t[i].getRecGlobalTick()&&(a=t[i].getRecGlobalTick());h=this.makeEvent(),h.setClose(),this.recGlobal(a,h),n+=(a-r)*m,this.recRestMSec(3e3),this.recEOT(),n+=3*e.SAMPLE_RATE,this.m_totalMSec=1e3*n/e.SAMPLE_RATE},e.prototype.calcSpt=function(t){var s=96*t/60;return e.SAMPLE_RATE/s},e.prototype.playTempo=function(t){this.m_bpm=t,this.m_spt=this.calcSpt(t)},e.prototype.getTotalMSec=function(){return this.m_totalMSec},e.prototype.getTotalTimeStr=function(){var t=Math.ceil(this.m_totalMSec/1e3),e="0"+Math.floor(t/60),s="0"+t%60;return e.substr(e.length-2,2)+":"+s.substr(s.length-2,2)},e.prototype.getVoiceCount=function(){return this.m_ch.getVoiceCount()},e.prototype.usingMono=function(){this.m_ch=new t.MChannel},e.prototype.usingPoly=function(e){this.m_ch=new t.MPolyChannel(e)},e.prototype.findPoly=function(){return this.m_polyFound},e.TEMPO_TRACK=0,e.FIRST_TRACK=1,e.DEFAULT_BPM=120,e}();t.MTrack=e}(flmml||(flmml={}));var flmml;!function(t){var e=function(){function t(){}return t.getString=function(t,e){return this.s_string[t].replace("%s",e)},t.UNKNOWN_COMMAND=0,t.UNCLOSED_REPEAT=1,t.UNOPENED_COMMENT=2,t.UNCLOSED_COMMENT=3,t.RECURSIVE_MACRO=4,t.UNCLOSED_ARGQUOTE=5,t.UNCLOSED_GROUPNOTES=6,t.UNOPENED_GROUPNOTES=7,t.INVALID_MACRO_NAME=8,t.s_string=["対応していないコマンド '%s' があります。","終わりが見つからない繰り返しがあります。","始まりが見つからないコメントがあります。","終わりが見つからないコメントがあります。","マクロが再帰的に呼び出されています。",'マクロ引数指定の "" が閉じられていません',"終りが見つからない連符があります","始まりが見つからない連符があります","マクロ名に使用できない文字が含まれています。'%s'"],t}();t.MWarning=e}(flmml||(flmml={}));var fmgenAs;!function(t){var e=function(){function e(){this.buf=new Array(4),this.ix=new Array(3),this.ox=new Array(3),this.op=[new t.Operator,new t.Operator,new t.Operator,new t.Operator],this.SetAlgorithm(0),this.pms=e.pmtable[0][0]}return e.prototype.SetType=function(t){for(var e=0;4>e;e++)this.op[e].type_=t},e.prototype.SetFB=function(t){this.fb=e.fbtable[t]},e.prototype.SetMS=function(t){this.op[0].SetMS(t),this.op[1].SetMS(t),this.op[2].SetMS(t),this.op[3].SetMS(t)},e.prototype.Mute=function(t){for(var e=0;4>e;e++)this.op[e].Mute(t)},e.prototype.Refresh=function(){for(var t=0;4>t;t++)this.op[t].Refresh()},e.prototype.SetChip=function(t){this.chip_=t;for(var e=0;4>e;e++)this.op[e].SetChip(t)},e.prototype.Reset=function(){this.op[0].Reset(),this.op[1].Reset(),this.op[2].Reset(),this.op[3].Reset()},e.prototype.Prepare=function(){var t=this.op;t[0].Prepare(),t[1].Prepare(),t[2].Prepare(),t[3].Prepare(),this.pms=e.pmtable[t[0].type_][7&t[0].ms_];var s=t[0].IsOn()||t[1].IsOn()||t[2].IsOn()||t[3].IsOn()?1:0,i=t[0].ms_&(t[0].amon_||t[1].amon_||t[2].amon_||t[3].amon_?55:7)?2:0;return s|i},e.prototype.SetFNum=function(t){for(var e=0;4>e;e++)this.op[e].SetFNum(t)},e.prototype.SetKCKF=function(t,s){var i=19-(t>>4&7),h=e.kctable[15&t];h=4*((h+2)/4|0);var o=h*e.kftable[63&s];o>>=19,o<<=19,o>>=i;var _=t>>2&31;this.op[0].SetDPBN(o,_),this.op[1].SetDPBN(o,_),this.op[2].SetDPBN(o,_),this.op[3].SetDPBN(o,_)},e.prototype.KeyControl=function(t){var e=this.op;1&t?e[0].KeyOn():e[0].KeyOff(),2&t?e[1].KeyOn():e[1].KeyOff(),4&t?e[2].KeyOn():e[2].KeyOff(),8&t?e[3].KeyOn():e[3].KeyOff()},e.prototype.SetAlgorithm=function(t){var s=e.iotable;this.ix[0]=s[t][0],this.ox[0]=s[t][1],this.ix[1]=s[t][2],this.ox[1]=s[t][3],this.ix[2]=s[t][4],this.ox[2]=s[t][5],this.op[0].ResetFB(),this.algo_=t},e.prototype.GetAlgorithm=function(){return this.algo_},e.prototype.Calc=function(){var t=0;switch(this.algo_){case 0:this.op[2].Calc(this.op[1].Out()),this.op[1].Calc(this.op[0].Out()),t=this.op[3].Calc(this.op[2].Out()),this.op[0].CalcFB(this.fb);break;case 1:this.op[2].Calc(this.op[0].Out()+this.op[1].Out()),this.op[1].Calc(0),t=this.op[3].Calc(this.op[2].Out()),this.op[0].CalcFB(this.fb);break;case 2:this.op[2].Calc(this.op[1].Out()),this.op[1].Calc(0),t=this.op[3].Calc(this.op[0].Out()+this.op[2].Out()),this.op[0].CalcFB(this.fb);break;case 3:this.op[2].Calc(0),this.op[1].Calc(this.op[0].Out()),t=this.op[3].Calc(this.op[1].Out()+this.op[2].Out()),this.op[0].CalcFB(this.fb);break;case 4:this.op[2].Calc(0),t=this.op[1].Calc(this.op[0].Out()),t+=this.op[3].Calc(this.op[2].Out()),this.op[0].CalcFB(this.fb);break;case 5:t=this.op[2].Calc(this.op[0].Out()),t+=this.op[1].Calc(this.op[0].Out()),t+=this.op[3].Calc(this.op[0].Out()),this.op[0].CalcFB(this.fb);break;case 6:t=this.op[2].Calc(0),t+=this.op[1].Calc(this.op[0].Out()),t+=this.op[3].Calc(0),this.op[0].CalcFB(this.fb);break;case 7:t=this.op[2].Calc(0),t+=this.op[1].Calc(0),t+=this.op[3].Calc(0),t+=this.op[0].CalcFB(this.fb)}return t},e.prototype.CalcL=function(){this.chip_.SetPMV(this.pms[this.chip_.GetPML()]);var t=0;switch(this.algo_){case 0:this.op[2].CalcL(this.op[1].Out()),this.op[1].CalcL(this.op[0].Out()),t=this.op[3].CalcL(this.op[2].Out()),this.op[0].CalcFBL(this.fb);break;case 1:this.op[2].CalcL(this.op[0].Out()+this.op[1].Out()),this.op[1].CalcL(0),t=this.op[3].CalcL(this.op[2].Out()),this.op[0].CalcFBL(this.fb);break;case 2:this.op[2].CalcL(this.op[1].Out()),this.op[1].CalcL(0),t=this.op[3].CalcL(this.op[0].Out()+this.op[2].Out()),this.op[0].CalcFBL(this.fb);break;case 3:this.op[2].CalcL(0),this.op[1].CalcL(this.op[0].Out()),t=this.op[3].CalcL(this.op[1].Out()+this.op[2].Out()),this.op[0].CalcFBL(this.fb);break;case 4:this.op[2].CalcL(0),t=this.op[1].CalcL(this.op[0].Out()),t+=this.op[3].CalcL(this.op[2].Out()),this.op[0].CalcFBL(this.fb);break;case 5:t=this.op[2].CalcL(this.op[0].Out()),t+=this.op[1].CalcL(this.op[0].Out()),t+=this.op[3].CalcL(this.op[0].Out()),this.op[0].CalcFBL(this.fb);break;case 6:t=this.op[2].CalcL(0),t+=this.op[1].CalcL(this.op[0].Out()),t+=this.op[3].CalcL(0),this.op[0].CalcFBL(this.fb);break;case 7:t=this.op[2].CalcL(0),t+=this.op[1].CalcL(0),t+=this.op[3].CalcL(0),t+=this.op[0].CalcFBL(this.fb)}return t},e.prototype.CalcN=function(t){this.buf[1]=this.buf[2]=this.buf[3]=0,this.buf[0]=this.op[0].Out(),this.op[0].CalcFB(this.fb),this.buf[this.ox[0]]+=this.op[1].Calc(this.buf[this.ix[0]]),this.buf[this.ox[1]]+=this.op[2].Calc(this.buf[this.ix[1]]);var e=this.op[3].Out();return this.op[3].CalcN(t),this.buf[this.ox[2]]+e},e.prototype.CalcLN=function(t){this.chip_.SetPMV(this.pms[this.chip_.GetPML()]),this.buf[1]=this.buf[2]=this.buf[3]=0,this.buf[0]=this.op[0].Out(),this.op[0].CalcFBL(this.fb),this.buf[this.ox[0]]+=this.op[1].CalcL(this.buf[this.ix[0]]),this.buf[this.ox[1]]+=this.op[2].CalcL(this.buf[this.ix[1]]);var e=this.op[3].Out();return this.op[3].CalcN(t),this.buf[this.ox[2]]+e},e.fbtable=[31,7,6,5,4,3,2,1],e.kftable=[65536,65595,65654,65713,65773,65832,65891,65951,66010,66070,66130,66189,66249,66309,66369,66429,66489,66549,66609,66669,66729,66789,66850,66910,66971,67031,67092,67152,67213,67273,67334,67395,67456,67517,67578,67639,67700,67761,67822,67883,67945,68006,68067,68129,68190,68252,68314,68375,68437,68499,68561,68623,68685,68747,68809,68871,68933,68995,69057,69120,69182,69245,69307,69370],e.kctable=[5197,5506,5833,6180,6180,6547,6937,7349,7349,7786,8249,8740,8740,9259,9810,10394],e.iotable=[[0,1,1,2,2,3],[1,0,0,1,1,2],[1,1,1,0,0,2],[0,1,2,1,1,2],[0,1,2,2,2,1],[0,1,0,1,0,1],[0,1,2,1,2,1],[1,0,1,0,1,0]],e.pmtable=function(){for(var e,s,i=t.JaggArray.I3(2,8,256),h=[[0,1/360,2/360,3/360,4/360,6/360,12/360,24/360],[0,1/480,2/480,4/480,10/480,20/480,80/480,140/480]],o=0;2>o;o++)for(e=0;8>e;e++){var _=h[o][e];for(s=0;256>s;s++){var r=(Math.pow(2,_*(2*s-256+1)/255),.6*_*Math.sin(2*s*Math.PI/256)+1);i[o][e][s]=65536*(r-1)|0}}return i}(),e}();t.Channel4=e}(fmgenAs||(fmgenAs={}));var fmgenAs;!function(t){var e=[1,1.414,1.581,1.732],s=function(){function s(){this.ratio_=0,this.aml_=0,this.pml_=0,this.pmv_=0,this.multable_=t.JaggArray.I2(4,16)}return s.prototype.Chip=function(){this.MakeTable()},s.prototype.SetRatio=function(t){this.ratio_!==t&&(this.ratio_=t,this.MakeTable())},s.prototype.SetAML=function(t){this.aml_=255&t},s.prototype.SetPML=function(t){this.pml_=255&t},s.prototype.SetPMV=function(t){this.pmv_=t},s.prototype.GetMulValue=function(t,e){return this.multable_[t][e]},s.prototype.GetAML=function(){return this.aml_},s.prototype.GetPML=function(){return this.pml_},s.prototype.GetPMV=function(){return this.pmv_},s.prototype.GetRatio=function(){return this.ratio_},s.prototype.MakeTable=function(){var t,s;for(t=0;4>t;t++){var i=e[t]*this.ratio_/1;for(s=0;16>s;s++){var h=0!==s?2*s:1;this.multable_[t][s]=h*i|0}}},s}();t.Chip=s}(fmgenAs||(fmgenAs={}));var fmgenAs;!function(t){var e=function(){function t(){}return t.next=0,t.attack=1,t.decay=2,t.sustain=3,t.release=4,t.off=5,t}();t.EGPhase=e}(fmgenAs||(fmgenAs={}));var fmgenAs;!function(t){var e=function(){function t(){}return t.typeN=0,t.typeM=1,t}();t.OpType=e}(fmgenAs||(fmgenAs={}));var messenger;!function(t){var e=flmml.MML,s=1,i=2,h=3,o=4,_=5,r=6,n=7,m=8,a=9,p=10,c=11,l=12,u=function(){function t(){this.onstopsound=null,this.onrequestbuffer=null,this.onInfoTimerBinded=this.onInfoTimer.bind(this),addEventListener("message",this.onMessage.bind(this))}return t.prototype.onMessage=function(t){var r=t.data,n=r.type,m=this.mml;switch(n){case s:this.SAMPLE_RATE=r.sampleRate,this.BUFFER_SIZE=r.bufferSize,this.mml=new e;break;case i:m.play(r.mml);break;case h:m.stop(),this.syncInfo();break;case o:m.pause(),this.syncInfo();break;case _:this.onrequestbuffer&&this.onrequestbuffer(r);break;case a:"number"==typeof r.interval?(this.infoInterval=r.interval,clearInterval(this.tIDInfo),this.infoInterval>0&&this.mml.isPlaying()&&(this.tIDInfo=setInterval(this.onInfoTimerBinded,this.infoInterval))):this.syncInfo();break;case c:this.onstopsound&&this.onstopsound()}},t.prototype.buffering=function(t){postMessage({type:n,progress:t})},t.prototype.compileComplete=function(){var t=this.mml;postMessage({type:r,info:{totalMSec:t.getTotalMSec(),totalTimeStr:t.getTotalTimeStr(),warnings:t.getWarnings(),metaTitle:t.getMetaTitle(),metaComment:t.getMetaComment(),metaArtist:t.getMetaArtist(),metaCoding:t.getMetaCoding()}})},t.prototype.playSound=function(){postMessage({type:p}),this.syncInfo()},t.prototype.stopSound=function(t){void 0===t&&(t=!1),postMessage({type:c,isFlushBuf:t})},t.prototype.sendBuffer=function(t){postMessage({type:_,buffer:t},[t[0].buffer,t[1].buffer])},t.prototype.complete=function(){postMessage({type:m}),this.syncInfo()},t.prototype.syncInfo=function(){var t=this.mml;this.lastInfoTime=self.performance?self.performance.now():(new Date).getTime(),postMessage({type:a,info:{_isPlaying:t.isPlaying(),_isPaused:t.isPaused(),nowMSec:t.getNowMSec(),nowTimeStr:t.getNowTimeStr(),voiceCount:t.getVoiceCount()}})},t.prototype.onInfoTimer=function(){this.mml.isPlaying()?this.syncInfo():clearInterval(this.tIDInfo)},t.prototype.debug=function(t){void 0===t&&(t=""),postMessage({type:l,str:t})},t}();t.Messenger=u}(messenger||(messenger={}));var msgr=new messenger.Messenger;
}).toString();
var code = "(" + flmmlworker + ")()";
var blob = new Blob([code], { type: "text/javascript" });
var workerURL = URL.createObjectURL(blob);
var pikoList = document.querySelectorAll("[id^=piko]");
[].forEach.call(pikoList, function(piko) {
var m = piko.id.match(/^piko(?:bbs|list)?(\d+)/);
if (!m) return;
var mml_id = m[1]; // "piko777" -> "777"
var code = "(function(elem) { var player = new FlMMLPlayer(%s); elem.parentNode.replaceChild(player.svg, elem); })(this)".replace("%s", JSON.stringify({
mmlURL: "/mml/" + mml_id,
height: "1.65em",
underground: true,
workerURL: workerURL
}));
var imgPikoplayer = piko.children.item(0);
imgPikoplayer.setAttribute("onclick", code);
});