unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-
unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-unblock github on kisd-
var beepbox,__extends=this&&this.t||function(){var t=function(i,s){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var s in i)i.hasOwnProperty(s)&&(t[s]=i[s])})(i,s)};return function(i,s){function e(){this.constructor=i}t(i,s),i.prototype=null===s?Object.create(s):(e.prototype=s.prototype,new e)}}();!function(t){function i(t){if(!function(t){return!(!t||t&t-1)}(t))throw new Error("FFT array length must be a power of 2.");return Math.round(Math.log(t)/Math.log(2))}t.scaleElementsByFactor=function(t,i){for(var s=0;s<t.length;s++)t[s]*=i},t.inverseRealFourierTransform=function(t){var s=t.length,e=i(s);if(s<4)throw new Error("FFT array length must be at least 4.");for(var n=e-1;n>=2;n--)for(var h=1<<n,r=h>>1,o=h<<1,a=2*Math.PI/o,l=Math.cos(a),u=Math.sin(a),f=2*l,c=0;c<s;c+=o){var d=c,v=d+r,p=d+h,b=p+r,m=p+h,w=t[d],g=t[p];t[d]=w+g,t[v]*=2,t[p]=w-g,t[b]*=2;for(var x=l,y=-u,M=1,k=0,A=1;A<r;A++){var E=d+A,N=p-A,B=p+A,R=m-A,L=t[E],S=t[N],I=t[B],Z=t[R],C=L-S,G=I+Z;t[E]=L+S,t[N]=Z-I,t[B]=C*x-G*y,t[R]=G*x+C*y;var U=f*x-M,j=f*y-k;M=x,k=y,x=U,y=j}}for(A=0;A<s;A+=4){var z=A+1,D=A+2,Y=A+3,T=(L=t[A],S=2*t[z],t[D]),F=2*t[Y];C=L+T,G=L-T,t[A]=C+S,t[z]=C-S,t[D]=G+F,t[Y]=G-F}!function(t){var s=t.length,e=i(s);if(e>16)throw new Error("FFT array length must not be greater than 2^16.");for(var n=16-e,h=0;h<s;h++){var r=void 0;if((r=((r=(61680&(r=(52428&(r=(43690&h)>>1|(21845&h)<<1))>>2|(13107&r)<<2))>>4|(3855&r)<<4)>>8|(255&r)<<8)>>n)>h){var o=t[h];t[h]=t[r],t[r]=o}}}(t)}}(beepbox||(beepbox={})),function(t){var i=function(){function i(){}return i.i=function(t){for(var i=0,s=0;s<t.length;s++)i+=t[s];var e=i/t.length;for(s=0;s<t.length;s++)t[s]-=e;return new Float64Array(t)},i.getDrumWave=function(s){var e=i.s[s];if(null==e)if(e=new Float32Array(32768),i.s[s]=e,0==s)for(var n=1,h=0;h<32768;h++){e[h]=2*(1&n)-1,1==(n+(r=n>>1)&1)&&(r+=16384),n=r}else if(1==s)for(h=0;h<32768;h++)e[h]=2*Math.random()-1;else if(2==s)for(n=1,h=0;h<32768;h++){e[h]=2*(1&n)-1,1==(n+(r=n>>1)&1)&&(r+=32768),n=r}else if(3==s)for(n=1,h=0;h<32768;h++){var r;e[h]=2*(1&n)-1,1==(n+(r=n>>1)&1)&&(r+=40),n=r}else{if(4!=s)throw new Error("Unrecognized drum index: "+s);i.drawNoiseSpectrum(e,10,11,1,1,0),i.drawNoiseSpectrum(e,11,14,-2,-2,0),t.inverseRealFourierTransform(e),t.scaleElementsByFactor(e,1/Math.sqrt(e.length))}return e},i.drawNoiseSpectrum=function(t,i,s,e,n,h){for(var r=0|Math.pow(2,i),o=0|Math.pow(2,s),a=Math.log(2),l=r;l<o;l++){var u=Math.pow(2,e+(n-e)*(Math.log(l)/a-i)/(s-i));u*=Math.pow(l/2048,h);var f=Math.random()*Math.PI*2;t[l]=Math.cos(f)*u,t[32768-l]=Math.sin(f)*u}},i.generateSineWave=function(){for(var t=new Float64Array(i.sineWaveLength+1),s=0;s<i.sineWaveLength+1;s++)t[s]=Math.sin(s*Math.PI*2/i.sineWaveLength);return t},i.scaleNames=["easy :)","easy :(","island :)","island :(","blues :)","blues :(","normal :)","normal :(","dbl harmonic :)","dbl harmonic :(","enigma","expert"],i.scaleFlags=[[!0,!1,!0,!1,!0,!1,!1,!0,!1,!0,!1,!1],[!0,!1,!1,!0,!1,!0,!1,!0,!1,!1,!0,!1],[!0,!1,!1,!1,!0,!0,!1,!0,!1,!1,!1,!0],[!0,!0,!1,!0,!1,!1,!1,!0,!0,!1,!1,!1],[!0,!1,!0,!0,!0,!1,!1,!0,!1,!0,!1,!1],[!0,!1,!1,!0,!1,!0,!0,!0,!1,!1,!0,!1],[!0,!1,!0,!1,!0,!0,!1,!0,!1,!0,!1,!0],[!0,!1,!0,!0,!1,!0,!1,!0,!0,!1,!0,!1],[!0,!0,!1,!1,!0,!0,!1,!0,!0,!1,!1,!0],[!0,!1,!0,!0,!1,!1,!0,!0,!0,!1,!1,!0],[!0,!1,!0,!1,!0,!1,!0,!1,!0,!1,!dab","#a0ffa0","#ffc0ff","#d0d0ff"],i.drumChannelColorsDim=["#6f6f6f","#996633"],i.drumChannelColorsBright=["#aaaaaa","#ddaa77"],i.drumNoteColorsDim=["#aaaaaa","#cc9966"],i.drumNoteColorsBright=["#eeeeee","#f0d0bb"],i.midiPitchChannelNames=["cyan channel","yellow channel","orange channel","green channel","purple channel","blue channel"],i.midiDrumChannelNames=["gray channel","brown channel"],i.midiSustainInstruments=[71,80,70,68,81,81,81,81,74],i.midiDecayInstruments=[46,46,6,24,25,25,106,106,33],i.drumInterval=6,i.drumCount=12,i.pitchCount=37,i.maxPitch=84,i.pitchChannelCountMin=1,i.pitchChannelCountMax=6,i.drumChannelCountMin=0,i.drumChannelCountMax=2,i.waves=[i.i([1/15,.2,5/15,7/15,.6,11/15,13/15,1,1,13/15,11/15,.6,7/15,5/15,.2,1/15,-1/15,-.2,-5/15,-7/15,-.6,-11/15,-13/15,-1,-1,-13/15,-11/15,-.6,-7/15,-5/15,-.2,-1/15]),i.i([1,-1]),i.i([1,-1,-1,-1]),i.i([1,-1,-1,-1,-1,-1,-1,-1]),i.i([1/31,3/31,5/31,7/31,9/31,11/31,13/31,15/31,17/31,19/31,21/31,23/31,25/31,27/31,29/31,1,-1,-29/31,-27/31,-25/31,-23/31,-21/31,-19/31,-17/31,-15/31,-13/31,-11/31,-9/31,-7/31,-5/31,-3/31,-1/31]),i.i([0,-.2,-.4,-.6,-.8,-1,1,-.8,-.6,-.4,-.2,1,.8,.6,.4,.2]),i.i([1,1,1,1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1]),i.i([1,-1,1,-1,1,0]),i.i([0,.2,.4,.5,.6,.7,.8,.85,.9,.95,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,.95,.9,.85,.8,.7,.6,.5,.4,.2,0,-.2,-.4,-.5,-.6,-.7,-.8,-.85,-.9,-.95,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-.95,-.9,-.85,-.8,-.7,-.6,-.5,-.4,-.2])],i.sineWaveLength=256,i.sineWaveMask=i.sineWaveLength-1,i.sineWave=i.generateSineWave(),i}();t.Config=i;var s=function(){function t(t,i,s,e){this.h=[],this.o=0;for(var n=s;n<e;n++){var h=t[i.charCodeAt(n)];this.h.push(h>>5&1),this.h.push(h>>4&1),this.h.push(h>>3&1),this.h.push(h>>2&1),this.h.push(h>>1&1),this.h.push(1&h)}}return t.prototype.read=function(t){for(var i=0;t>0;)i<<=1,i+=this.h[this.o++],t--;return i},t.prototype.readLongTail=function(t,i){for(var s=t,e=i;this.h[this.o++];)s+=1<<e,e++;for(;e>0;)e--,this.h[this.o++]&&(s+=1<<e);return s},t.prototype.readPartDuration=function(){return this.readLongTail(1,2)},t.prototype.readPinCount=function(){return this.readLongTail(1,0)},t.prototype.readPitchInterval=function(){return this.read(1)?-this.readLongTail(1,3):this.readLongTail(1,3)},t}(),e=function(){function t(){this.h=[]}return t.prototype.write=function(t,i){for(t--;t>=0;)this.h.push(i>>>t&1),t--},t.prototype.writeLongTail=function(t,i,s){if(s<t)throw new Error("value out of bounds");s-=t;for(var e=i;s>=1<<e;)this.h.push(1),s-=1<<e,e++;for(this.h.push(0);e>0;)e--,this.h.push(s>>>e&1)},t.prototype.writePartDuration=function(t){this.writeLongTail(1,2,t)},t.prototype.writePinCount=function(t){this.writeLongTail(1,0,t)},t.prototype.writePitchInterval=function(t){t<0?(this.write(1,1),this.writeLongTail(1,3,-t)):(this.write(1,0),this.writeLongTail(1,3,t))},t.prototype.concat=function(t){this.h=this.h.concat(t.h)},t.prototype.encodeBase64=function(t,i){for(var s=0;s<this.h.length;s+=6){var e=this.h[s]<<5|this.h[s+1]<<4|this.h[s+2]<<3|this.h[s+3]<<2|this.h[s+4]<<1|this.h[s+5];i.push(t[e])}return i},t.prototype.lengthBase64=function(){return Math.ceil(this.h.length/6)},t}();function n(t,i,s){return{interval:t,time:i,volume:s}}function h(t,i,s,e,h){return void 0===h&&(h=!1),{pitches:[t],pins:[n(0,0,e),n(0,s-i,h?0:e)],start:i,end:s}}t.makeNotePin=n,t.makeNote=h;var r=function(){function t(){this.notes=[],this.instrument=0}return t.prototype.cloneNotes=function(){for(var t=[],i=0,s=this.notes;i<s.length;i++){var e=s[i],r=h(-1,e.start,e.end,3);r.pitches=e.pitches.concat(),r.pins=[];for(var o=0,a=e.pins;o<a.length;o++){var l=a[o];r.pins.push(n(l.interval,l.time,l.volume))}t.push(r)}return t},t.prototype.reset=function(){this.notes.length=0,this.instrument=0},t}();t.Pattern=r;var o=function(){function t(t){this.frequency=0,this.amplitude=0,this.envelope=0,this.reset(t)}return t.prototype.reset=function(t){this.frequency=0,this.amplitude=t<=1?i.operatorAmplitudeMax:0,this.envelope=0==t?0:1},t.prototype.copy=function(t){this.frequency=t.frequency,this.amplitude=t.amplitude,this.envelope=t.envelope},t}();t.Operator=o;var a=function(){function t(){this.type=0,this.wave=1,this.filter=1,this.transition=1,this.effect=0,this.chorus=0,this.volume=0,this.algorithm=0,this.feedbackType=0,this.feedbackAmplitude=0,this.feedbackEnvelope=1,this.operators=[];for(var t=0;t<i.operatorCount;t++)this.operators.push(new o(t))}return t.prototype.setTypeAndReset=function(t){switch(this.type=t,t){case 0:this.wave=1,this.filter=1,this.transition=1,this.effect=0,this.chorus=0,this.volume=0;break;case 1:this.wave=1,this.transition=1,this.volume=0;break;case 2:this.transition=1,this.effect=0,this.algorithm=0,this.feedbackType=0,this.feedbackAmplitude=0,this.feedbackEnvelope=1;for(var i=0;i<this.operators.length;i++)this.operators[i].reset(i)}},t.prototype.copy=function(t){this.type=t.type,this.wave=t.wave,this.filter=t.filter,this.transition=t.transition,this.effect=t.effect,this.chorus=t.chorus,this.volume=t.volume,this.algorithm=t.algorithm,this.feedbackType=t.feedbackType,this.feedbackAmplitude=t.feedbackAmplitude,this.feedbackEnvelope=t.feedbackEnvelope;for(var i=0;i<this.operators.length;i++)this.operators[i].copy(t.operators[i])},t}();t.Instrument=a;var l=function(){return function(){this.octave=0,this.instruments=[],this.patterns=[],this.bars=[]}}();t.Channel=l;var u=function(){function t(t){this.channels=[],void 0!=t?this.fromBase64String(t):this.initToDefault(!0)}return t.prototype.getChannelCount=function(){return this.pitchChannelCount+this.drumChannelCount},t.prototype.getChannelIsDrum=function(t){return t>=this.pitchChannelCount},t.prototype.getChannelColorDim=function(t){return t<this.pitchChannelCount?i.pitchChannelColorsDim[t]:i.drumChannelColorsDim[t-this.pitchChannelCount]},t.prototype.getChannelColorBright=function(t){return t<this.pitchChannelCount?i.pitchChannelColorsBright[t]:i.drumChannelColorsBright[t-this.pitchChannelCount]},t.prototype.getNoteColorDim=function(t){return t<this.pitchChannelCount?i.pitchNoteColorsDim[t]:i.drumNoteColorsDim[t-this.pitchChannelCount]},t.prototype.getNoteColorBright=function(t){return t<this.pitchChannelCount?i.pitchNoteColorsBright[t]:i.drumNoteColorsBright[t-this.pitchChannelCount]},t.prototype.initToDefault=function(t){if(void 0===t&&(t=!0),this.scale=0,this.key=i.keyNames.length-1,this.loopStart=0,this.loopLength=4,this.tempo=7,this.reverb=0,this.beatsPerBar=8,this.barCount=16,this.patternsPerChannel=8,this.partsPerBeat=4,this.instrumentsPerChannel=1,t){this.pitchChannelCount=3,this.drumChannelCount=1;for(var s=0;s<this.getChannelCount();s++){this.channels.length<=s&&(this.channels[s]=new l);var e=this.channels[s];e.octave=3-s;for(var n=0;n<this.patternsPerChannel;n++)e.patterns.length<=n?e.patterns[n]=new r:e.patterns[n].reset();e.patterns.length=this.patternsPerChannel;for(var h=0;h<this.instrumentsPerChannel;h++)e.instruments.length<=h&&(e.instruments[h]=new a),e.instruments[h].setTypeAndReset(s<this.pitchChannelCount?0:2);e.instruments.length=this.instrumentsPerChannel;for(var o=0;o<this.barCount;o++)e.bars[o]=1;e.bars.length=this.barCount}this.channels.length=this.getChannelCount()}},t.prototype.toBase64String=function(){var s,n=[],h=t.l;n.push(h[t.u]),n.push(110,h[this.pitchChannelCount],h[this.drumChannelCount]),n.push(115,h[this.scale]),n.push(107,h[this.key]),n.push(108,h[this.loopStart>>6],h[63&this.loopStart]),n.push(101,h[this.loopLength-1>>6],h[this.loopLength-1&63]),n.push(116,h[this.tempo]),n.push(109,h[this.reverb]),n.push(97,h[this.beatsPerBar-1]),n.push(103,h[this.barCount-1>>6],h[this.barCount-1&63]),n.push(106,h[this.patternsPerChannel-1]),n.push(105,h[this.instrumentsPerChannel-1]),n.push(114,h[i.partCounts.indexOf(this.partsPerBeat)]),n.push(111);for(var r=0;r<this.getChannelCount();r++)n.push(h[this.channels[r].octave]);for(r=0;r<this.getChannelCount();r++)for(var o=0;o<this.instrumentsPerChannel;o++){var a=this.channels[r].instruments[o];if(n.push(84,h[a.type]),0==a.type)n.push(119,h[a.wave]),n.push(102,h[a.filter]),n.push(100,h[a.transition]),n.push(99,h[a.effect]),n.push(104,h[a.chorus]),n.push(118,h[a.volume]);else if(1==a.type){n.push(100,h[a.transition]),n.push(99,h[a.effect]),n.push(65,h[a.algorithm]),n.push(70,h[a.feedbackType]),n.push(66,h[a.feedbackAmplitude]),n.push(86,h[a.feedbackEnvelope]),n.push(81);for(var l=0;l<i.operatorCount;l++)n.push(h[a.operators[artCounts[p[e.charCodeAt(o++)]];else if(111==x)if(f)y=p[e.charCodeAt(o++)],this.channels[y].octave=t.m(0,5,p[e.charCodeAt(o++)]);else for(y=0;y<this.getChannelCount();y++)this.channels[y].octave=t.m(0,5,p[e.charCodeAt(o++)]);else if(84==x){++g>=this.instrumentsPerChannel&&(w++,g=0),this.channels[w].instruments[g].setTypeAndReset(t.m(0,3,p[e.charCodeAt(o++)]))}else if(119==x)if(f)y=p[e.charCodeAt(o++)],this.channels[y].instruments[0].wave=t.m(0,i.waveNames.length,p[e.charCodeAt(o++)]);else if(v)for(y=0;y<this.getChannelCount();y++)for(var L=y>=this.pitchChannelCount,S=0;S<this.instrumentsPerChannel;S++)this.channels[y].instruments[S].wave=t.m(0,L?i.drumNames.length:i.waveNames.length,p[e.charCodeAt(o++)]);else{L=w>=this.pitchChannelCount;this.channels[w].instruments[g].wave=t.m(0,L?i.drumNames.length:i.waveNames.length,p[e.charCodeAt(o++)])}else if(102==x)if(f)y=p[e.charCodeAt(o++)],this.channels[y].instruments[0].filter=[1,3,4,5][t.m(0,i.filterNames.length,p[e.charCodeAt(o++)])];else if(v)for(y=0;y<this.getChannelCount();y++)for(S=0;S<this.instrumentsPerChannel;S++)this.channels[y].instruments[S].filter=t.m(0,i.filterNames.length,p[e.charCodeAt(o++)]+1);else this.channels[w].instruments[g].filter=t.m(0,i.filterNames.length,p[e.charCodeAt(o++)]);else if(100==x)if(f)y=p[e.charCodeAt(o++)],this.channels[y].instruments[0].transition=t.m(0,i.transitionNames.length,p[e.charCodeAt(o++)]);else if(v)for(y=0;y<this.getChannelCount();y++)for(S=0;S<this.instrumentsPerChannel;S++)this.channels[y].instruments[S].transition=t.m(0,i.transitionNames.length,p[e.charCodeAt(o++)]);else this.channels[w].instruments[g].transition=t.m(0,i.transitionNames.length,p[e.charCodeAt(o++)]);else if(99==x)if(f){y=p[e.charCodeAt(o++)];var I=t.m(0,i.effectNames.length,p[e.charCodeAt(o++)]);1==I?I=3:3==I&&(I=5),this.channels[y].instruments[0].effect=I}else if(v)for(y=0;y<this.getChannelCount();y++)for(S=0;S<this.instrumentsPerChannel;S++)this.channels[y].instruments[S].effect=t.m(0,i.effectNames.length,p[e.charCodeAt(o++)]);else this.channels[w].instruments[g].effect=t.m(0,i.effectNames.length,p[e.charCodeAt(o++)]);else if(104==x)if(f)y=p[e.charCodeAt(o++)],this.channels[y].instruments[0].chorus=t.m(0,i.chorusNames.length,p[e.charCodeAt(o++)]);else if(v)for(y=0;y<this.getChannelCount();y++)for(S=0;S<this.instrumentsPerChannel;S++)this.channels[y].instruments[S].chorus=t.m(0,i.chorusNames.length,p[e.charCodeAt(o++)]);else this.channels[w].instruments[g].chorus=t.m(0,i.chorusNames.length,p[e.charCodeAt(o++)]);else if(118==x)if(f)y=p[e.charCodeAt(o++)],this.channels[y].instruments[0].volume=t.m(0,i.volumeNames.length,p[e.charCodeAt(o++)]);else if(v)for(y=0;y<this.getChannelCount();y++)for(S=0;S<this.instrumentsPerChannel;S++)this.channels[y].instruments[S].volume=t.m(0,i.volumeNames.length,p[e.charCodeAt(o++)]);else this.channels[w].instruments[g].volume=t.m(0,i.volumeNames.length,p[e.charCodeAt(o++)]);else if(65==x)this.channels[w].instruments[g].algorithm=t.m(0,i.operatorAlgorithmNames.length,p[e.charCodeAt(o++)]);else if(70==x)this.channels[w].instruments[g].feedbackType=t.m(0,i.operatorFeedbackNames.length,p[e.charCodeAt(o++)]);else if(66==x)this.channels[w].instruments[g].feedbackAmplitude=t.m(0,i.operatorAmplitudeMax+1,p[e.charCodeAt(o++)]);else if(86==x)this.channels[w].instruments[g].feedbackEnvelope=t.m(0,i.operatorEnvelopeNames.length,p[e.charCodeAt(o++)]);else if(81==x)for(var Z=0;Z<i.operatorCount;Z++)this.channels[w].instruments[g].operators[Z].frequency=t.m(0,i.operatorFrequencyNames.length,p[e.charCodeAt(o++)]);else if(80==x)for(Z=0;Z<i.operatorCount;Z++)this.channels[w].instruments[g].operators[Z].amplitude=t.m(0,i.operatorAmplitudeMax+1,p[e.charCodeAt(o++)]);else if(69==x)for(Z=0;Z<i.operatorCount;Z++)this.channels[w].instruments[g].operators[Z].envelope=t.m(0,i.operatorEnvelopeNames.length,p[e.charCodeAt(o++)]);else if(98==x){var C=void 0;if(f){y=p[e.charCodeAt(o++)];var G=p[e.charCodeAt(o++)];C=Math.ceil(.5*G);var U=new s(p,e,o,o+C);for(S=0;S<G;S++)this.channels[y].bars[S]=U.read(3)+1}else if(d){for(var j=0;1<<j<this.patternsPerChannel;)j++;C=Math.ceil(this.getChannelCount()*this.barCount*j/6);U=new s(p,e,o,o+C);for(y=0;y<this.getChannelCount();y++)for(S=0;S<this.barCount;S++)this.channels[y].bars[S]=U.read(j)+1}else{for(j=0;1<<j<this.patternsPerChannel+1;)j++;C=Math.ceil(this.getChannelCount()*this.barCount*j/6);U=new s(p,e,o,o+C);for(y=0;y<this.getChannelCount();y++)for(S=0;S<this.barCount;S++)this.channels[y].bars[S]=U.read(j)}o+=C}else if(112==x){var z=0;if(f)y=p[e.charCodeAt(o++)],o++,z=p[e.charCodeAt(o++)],z<<=6,z+=p[e.charCodeAt(o++)];else{y=0;for(var D=p[e.charCodeAt(o++)];D>0;)z<<=6,z+=p[e.charCodeAt(o++)],D--}U=new s(p,e,o,o+z);o+=z;for(var Y=0;1<<Y<this.instrumentsPerChannel;)Y++;for(;;){var T=this.getChannelIsDrum(y),F=T?0:12*this.channels[y].octave,V=null,P=null,O=(T?4:12)+F,W=T?[4,6,7,2,3,8,0,10]:[12,19,24,31,36,7,0],J=[];for(S=0;S<W.length;S++)W[S]+=F;for(S=0;S<this.patternsPerChannel;S++){var Q=this.channels[y].patterns[S];if(Q.reset(),Q.instrument=U.read(Y),f||0!=U.read(1))for(var H=0,X=Q.notes;H<this.beatsPerBar*this.partsPerBeat;){var _=1==U.read(1),K=!1,q=0;if(_?q=U.readLongTail(0,0):K=1==U.read(1),_||K){var $=void 0,tt=void 0,it=void 0;if(_)$=J[q],J.splice(q,1);else{for(($={}).pitchCount=1;$.pitchCount<4&&1==U.read(1);)$.pitchCount++;$.pinCount=U.readPinCount(),$.initialVolume=U.read(2),$.pins=[],$.length=0,$.bendCount=0;for(var st=0;st<$.pinCount;st++)(tt={}).pitchBend=1==U.read(1),tt.pitchBend&&$.bendCount++,$.length+=U.readPartDuration(),tt.time=$.length,tt.volume=U.read(2),$.pins.push(tt)}J.unshift($),J.length>10&&J.pop(),(V=h(0,H,H+$.length,$.initialVolume)).pitches=[],V.pins.length=1;var et=[];for(st=0;st<$.pitchCount+$.bendCount;st++){if(1==U.read(1)){var nt=U.read(3);it=W[nt],W.splice(nt,1)}else{var ht=U.readPitchInterval();it=O;for(var rt=ht;rt>0;){for(it++;-1!=W.indexOf(it);)it++;rt--}for(;rt<0;){for(it--;-1!=W.indexOf(it);)it--;rt++}}W.unshift(it),W.length>8&&W.pop(),st<$.pitchCount?V.pitches.push(it):et.push(it),O=st==$.pitchCount-1?V.pitches[0]:it}et.unshift(V.pitches[0]);for(var ot=0,at=$.pins;ot<at.length;ot++){var lt=at[ot];lt.pitchBend&&et.shift(),P=n(et[0]-V.pitches[0],lt.time,lt.volume),V.pins.push(P)}H=V.end,X.push(V)}else{H+=U.readPartDuration()}}}if(f)break;if(++y>=this.getChannelCount())break}}}}}else this.fromJsonObject(JSON.parse(0==o?e:e.substring(o)))}else this.initToDefault(!0)},t.prototype.toJsonObject=function(s,e,n){void 0===s&&(s=!0),void 0===e&&(e=1),void 0===n&&(n=!0);for(var h=[],r=0;r<this.getChannelCount();r++){for(var o=[],a=this.getChannelIsDrum(r),l=0;l<this.instrumentsPerChannel;l++){var u=this.channels[r].instruments[l];if(2==u.type)o.push({type:i.instrumentTypeNames[u.type],volume:20*(5-u.volume),wave:i.drumNames[u.wave],transition:i.transitionNames[u.transition]});else if(0==u.type)o.push({type:i.instrumentTypeNames[u.type],volume:20*(5-u.volume),wave:i.waveNames[u.wave],transition:i.transitionNames[u.transition],filter:i.filterNames[u.filter],chorus:i.chorusNames[u.chorus],effect:i.effectNames[u.effect]});else{if(1!=u.type)throw new Error("Unrecognized instrument type");for(var f=[],c=0,d=u.operators;c<d.length;c++){var v=d[c];f.push({frequency:i.operatorFrequencyNames[v.frequency],amplitude:v.amplitude,envelope:i.operatorEnvelopeNames[v.envelope]})}o.push({type:i.instrumentTypeNames[u.type],transition:i.transitionNames[u.transition],effect:i.effectNames[u.effect],algorithm:i.operatorAlgorithmNames[u.algorithm],feedbackType:i.operatorFeedbackNames[u.feedbackType],feedbackAmplitude:u.feedbackAmplitude,feedbackEnvelope:i.operatorEnvelopeNames[u.feedbackEnvelope],operators:f})}}for(var p=[],b=0,m=this.channels[r].patterns;b<m.length;b++){for(var w=m[b],g=[],x=0,y=w.notes;x<y.length;x++){for(var M=y[x],k=[],A=0,E=M.pins;A<E.length;A++){var N=E[A];k.push({tick:N.time+M.start,pitchBend:N.interval,volume:Math.round(100*N.volume/3)})}g.push({pitches:M.pitches,points:k})}p.push({instrument:w.instrument+1,notes:g})}var B=[];if(s)for(l=0;l<this.loopStart;l++)B.push(this.channels[r].bars[l]);for(var R=0;R<e;R++)for(l=this.loopStart;l<this.loopStart+this.loopLength;l++)B.push(this.channels[r].bars[l]);if(n)for(l=this.loopStart+this.loopLength;l<this.barCount;l++)B.push(this.channels[r].bars[l]);h.push({type:a?"drum":"pitch",octaveScrollBar:this.channels[r].octave,instruments:o,patterns:p,sequence:B})}return{format:t.g,version:t.u,scale:i.scaleNames[this.scale],key:i.keyNames[this.key],introBars:this.loopStart,loopBars:this.loopLength,beatsPerBar:this.beatsPerBar,ticksPerBeat:this.partsPerBeat,beatsPerMinute:this.getBeatsPerMinute(),reverb:this.reverb,channels:h}},t.prototype.fromJsonObject=function(s){if((this.initToDefault(!0),s)&&!(s.version>t.g)){if(this.scale=11,void 0!=s.scale){var e={"romani :)":8,"romani :(":9},o=void 0!=e[s.scale]?e[s.scale]:i.scaleNames.indexOf(s.scale);-1!=o&&(this.scale=o)}if(void 0!=s.key)if("number"==typeof s.key)this.key=i.keyNames.length-1-(s.key+1200>>>0)%i.keyNames.length;else if("string"==typeof s.key){var u=s.key,f=u.charAt(0).toUpperCase(),c=u.charAt(1).toLowerCase(),d={C:11,D:9,E:7,F:6,G:4,A:2,B:0}[f],v=on(t){"string"==typeof t?this.song=new u(t):t instanceof u&&(this.song=t)},s.prototype.play=function(){if(this.paused){this.paused=!1,s.warmUpSynthesizer(this.song);var t=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.oAudioContext||window.msAudioContext;this.audioCtx=this.audioCtx||new t,this.scriptNode=this.audioCtx.createScriptProcessor?this.audioCtx.createScriptProcessor(2048,0,1):this.audioCtx.createJavaScriptNode(2048,0,1),this.scriptNode.onaudioprocess=this.audioProcessCallback,this.scriptNode.channelCountMode="explicit",this.scriptNode.channelInterpretation="speakers",this.scriptNode.connect(this.audioCtx.destination),this.samplesPerSecond=this.audioCtx.sampleRate,this.effectAngle=2*Math.PI/(this.effectDuration*this.samplesPerSecond),this.effectYMult=2*Math.cos(this.effectAngle),this.limitDecay=1/(2*this.samplesPerSecond)}},s.prototype.pause=function(){this.paused||(this.paused=!0,this.scriptNode.disconnect(this.audioCtx.destination),this.audioCtx.close&&(this.audioCtx.close(),this.audioCtx=null),this.scriptNode=null)},s.prototype.snapToStart=function(){this.bar=0,this.enableIntro=!0,this.snapToBar()},s.prototype.snapToBar=function(t){void 0!==t&&(this.bar=t),this.playheadInternal=this.bar,this.beat=0,this.part=0,this.arpeggio=0,this.arpeggioSampleCountdown=0,this.effectPhase=0;for(var i=0,s=this.tones;i<s.length;i++){s[i].reset()}this.reverbDelayPos=0,this.reverbFeedback0=0,this.reverbFeedback1=0,this.reverbFeedback2=0,this.reverbFeedback3=0;for(var e=0;e<this.reverbDelayLine.length;e++)this.reverbDelayLine[e]=0},s.prototype.nextBar=function(){if(this.song){var t=this.bar;this.bar++,this.enableOutro?this.bar>=this.song.barCount&&(this.bar=this.enableIntro?0:this.song.loopStart):(this.bar>=this.song.loopStart+this.song.loopLength||this.bar>=this.song.barCount)&&(this.bar=this.song.loopStart),this.playheadInternal+=this.bar-t}},s.prototype.prevBar=function(){if(this.song){var t=this.bar;this.bar--,this.bar<0&&(this.bar=this.song.loopStart+this.song.loopLength-1),this.bar>=this.song.barCount&&(this.bar=this.song.barCount-1),this.bar<this.song.loopStart&&(this.enableIntro=!0),!this.enableOutro&&this.bar>=this.song.loopStart+this.song.loopLength&&(this.bar=this.song.loopStart+this.song.loopLength-1),this.playheadInternal+=this.bar-t}},s.prototype.synthesize=function(i,e){if(null!=this.song){var n=this.song.getChannelCount();for(V=this.tones.length;V<n;V++)this.tones[V]=new f;this.tones.length=n;var h=this.getSamplesPerArpeggio(),r=0,o=!1;(0==this.arpeggioSampleCountdown||this.arpeggioSampleCountdown>h)&&(this.arpeggioSampleCountdown=h),this.part>=this.song.partsPerBeat&&(this.beat++,this.part=0,this.arpeggio=0,this.arpeggioSampleCountdown=h),this.beat>=this.song.beatsPerBar&&(this.bar++,this.beat=0,this.part=0,this.arpeggio=0,this.arpeggioSampleCountdown=h,-1==this.loopCount&&(this.bar<this.song.loopStart&&!this.enableIntro&&(this.bar=this.song.loopStart),this.bar>=this.song.loopStart+this.song.loopLength&&!this.enableOutro&&(this.bar=this.song.loopStart))),this.bar>=this.song.barCount&&(this.enableOutro?(this.bar=0,this.enableIntro=!0,o=!0,this.pause()):this.bar=this.song.loopStart),this.bar>=this.song.loopStart&&(this.enableIntro=!1);var a=performance.now();for(V=0;V<e;)i[V++]=0,i[V++]=0,i[V++]=0,i[V++]=0;(null==this.samplesForReverb||this.samplesForReverb.length<e)&&(this.samplesForReverb=new Float32Array(e));var l=this.samplesForReverb;for(V=0;V<e;)l[V++]=0,l[V++]=0,l[V++]=0,l[V++]=0;for(;r<e&&!o;)for(;r<e;){for(var u=e-r,c=this.arpeggioSampleCountdown<=u?this.arpeggioSampleCountdown:u,d=0;d<this.song.getChannelCount();d++){var v=this.song.channels[d].instruments[this.song.getPatternInstrument(d,this.bar)];s.computeTone(this,this.song,d,h,c,v);var p=this.tones[d];if(p.active){var b=this.song.getChannelIsDrum(d)?i:l;s.getGeneratedSynthesizer(v)(this,b,r,c,p,v)}}if(r+=c,this.effectPhase=(this.effectPhase+this.effectAngle*c)%(2*Math.PI),this.arpeggioSampleCountdown-=c,this.arpeggioSampleCountdown<=0&&(this.arpeggio++,this.arpeggioSampleCountdown=h,4==this.arpeggio&&(this.arpeggio=0,this.part++,this.part==this.song.partsPerBeat&&(this.part=0,this.beat++,this.beat==this.song.beatsPerBar)))){this.beat=0,this.bar++,this.effectPhase=0,this.bar<this.song.loopStart?this.enableIntro||(this.bar=this.song.loopStart):this.enableIntro=!1,this.bar>=this.song.loopStart+this.song.loopLength&&(this.loopCount>0&&this.loopCount--,(this.loopCount>0||!this.enableOutro)&&(this.bar=this.song.loopStart)),this.bar>=this.song.barCount&&(this.bar=0,this.enableIntro=!0,o=!0,this.pause());break}}var m=+this.volume,w=this.reverbDelayLine,g=0|this.reverbDelayPos,x=+this.reverbFeedback0,y=+this.reverbFeedback1,M=+this.reverbFeedback2,k=+this.reverbFeedback3,A=.425*Math.pow(this.song.reverb/t.Config.reverbRange,.667),E=+this.limitDecay,N=+this.limit;for(V=0;V<e;V++){var B=l[V],R=g+3041&16383,L=g+6426&16383,S=g+10907&16383,I=w[g]+B,Z=w[R],C=w[L],G=w[S],U=-I+Z,j=-I-Z,z=-C+G,D=-C-G;x+=.5*((U+z)*A-x),y+=.5*((j+D)*A-y),M+=.5*((U-z)*A-M),k+=.5*((j-D)*A-k),w[R]=x,w[L]=y,w[S]=M,w[g]=k,g=g+1&16383;var Y=i[V]+I+Z+C+G,T=Y<0?-Y:Y;N<T&&(N=T),i[V]=Y/(.75*N+.25)*m,N-=E}this.reverbDelayPos=g,this.reverbFeedback0=x,this.reverbFeedback1=y,this.reverbFeedback2=M,this.reverbFeedback3=k,this.limit=N,this.playheadInternal=(((this.arpeggio+1-this.arpeggioSampleCountdown/h)/4+this.part)/this.song.partsPerBeat+this.beat)/this.song.beatsPerBar+this.bar;var F=performance.now()-a;e,F}else for(var V=0;V<e;V++)i[V]=0},s.computeOperatorEnvelope=function(t,s,e,n){switch(i.operatorEnvelopeType[t]){case 0:return n;case 1:return 1;case 4:var h=1/(1+s*i.operatorEnvelopeSpeed[t]);return i.operatorEnvelopeInverted[t]?1-h:h;case 5:return.5-.5*Math.cos(2*e*Math.PI*i.operatorEnvelopeSpeed[t]);case 2:return Math.max(1,2-10*s);case 3:var r=i.operatorEnvelopeSpeed[t],o=.25/Math.sqrt(r);return s<o?s/o:1/(1+(s-o)*r);default:throw new Error("Unrecognized operator envelope type.")}},s.computeTone=function(t,e,n,h,r,o){var a=e.getChannelIsDrum(n),l=t.tones[n],u=e.getPattern(n,t.bar),f=t.pianoPressed&&n==t.pianoChannel,c=a?i.drumBasePitches[o.wave]:i.keyTransposes[e.key],d=a?i.drumInterval:1,v=a?i.drumWaveIsSoft[o.wave]?24:60:48,p=4*h/t.samplesPerSecond,b=1/e.partsPerBeat;l.phaseDeltaScale=0,l.filter=1,l.filterScale=1,l.vibratoScale=0,l.harmonyMult=1,l.harmonyVolumeMult=1,l.active=!1;for(var m=0,w=t.arpeggio,g=t.arpeggioSampleCountdown,x=null,y=!0,M=0,k=0,A=1,E=1,N=0,B=0,R=0,L=0,S=0,I=0,Z=0;Z<i.operatorCount;Z++)l.phaseDeltas[Z]=0,l.volumeStarts[Z]=0,l.volumeDeltas[Z]=0;if(f)x=t.pianoPitch,A=E=1,N=B=1,y=!1;else if(null!=u){var C=t.part+t.beat*e.partsPerBeat,G=null,U=null,j=null;for(Z=0;Z<u.notes.length;Z++)if(u.notes[Z].end<=C)U=u.notes[Z];else if(u.notes[Z].start<=C&&u.notes[Z].end>C)G=u.notes[Z];else if(u.notes[Z].start>C){j=u.notes[Z];break}if(null!=G&&null!=U&&U.end!=G.start&&(U=null),null!=G&&null!=j&&j.start!=G.end&&(j=null),null!=G){x=G.pitches,m=C-G.start;var z=void 0;for(z=1;z<G.pins.length-1&&!(G.pins[z].time+G.start>C);z++);var D=G.pins[z-1],Y=G.pins[z],T=4*G.start,F=4*G.end,V=4*(G.start+D.time),P=4*(G.start+Y.time),O=4*C+w,W=4*C+w+1,J=(O-V)/(P-V),Q=(W-V)/(P-V),H=D.volume+(Y.volume-D.volume)*J,X=D.volume+(Y.volume-D.volume)*Q,_=1,K=1,q=D.interval+(Y.interval-D.interval)*J,$=D.interval+(Y.interval-D.interval)*Q,tt=D.time+(Y.time-D.time)*J,it=D.time+(Y.time-D.time)*Q,st=tt,et=it,nt=1-g/h,ht=1-(g-r)/h;y=O+nt-T==0;var rt=o.transition;O==T&&(0==rt?y=!1:2==rt?_=0:3==rt&&(null==U?_=0:0==U.pins[U.pins.length-1].volume||0==G.pins[0].volume?_=0:(q=.5*(U.pitches[0]+U.pins[U.pins.length-1].interval-G.pitches[0]),st=.5*U.pins[U.pins.length-1].time,y=!1))),W==F&&(0==rt?null==j&&G.start+Y.time!=e.partsPerBeat*e.beatsPerBar&&(K=0):1==rt||2==rt?K=0:3==rt&&(null==j?K=0:0==G.pins[G.pins.length-1].volume||0==j.pins[0].volume?K=0:($=.5*(j.pitches[0]-G.pitches[0]+G.pins[G.pins.length-1].interval),et*=.5))),M=q+($-q)*nt,k=q+($-q)*ht,N=t.volumeConversion(H+(X-H)*nt),B=t.volumeConversion(H+(X-H)*ht),A=_+(K-_)*nt,E=_+(K-_)*ht,R=G.start+tt+(it-tt)*nt,L=G.start+tt+(it-tt)*ht,S=st+(et-st)*nt,I=st+(et-st)*ht}}if(null!=x){var ot=1/t.samplesPerSecond;if(l.active=!0,a||1!=o.type){mt=x[0];if(i.chorusHarmonizes[o.chorus]){var at=0;2==x.length?at=x[1]-x[0]:3==x.length?at=x[1+(w>>1)]-x[0]:4==x.length&&(at=x[(3==w?1:w)+1]-x[0]),l.harmonyMult=Math.pow(2,at/12),l.harmonyVolumeMult=Math.pow(2,-at/v)}else 2==x.length?mt=x[w>>1]:3==x.length?mt=x[3==w?1:w]:4==x.length&&(mt=x[w]);gt=(mt+M)*d,Bt=(mt+k)*d,xt=t.frequencyFromPitch(c+gt),Et=Math.pow(2,-gt/v),Nt=Math.pow(2,-Bt/v);a&&i.drumWaveIsSoft[o.wave]&&(l.filter=Math.min(1,xt*ot*i.drumPitchFilterMult[o.wave]));var lt=void 0;if(a)lt=.19*i.drumVolumes[o.wave];else{var ut=i.filterDecays[o.filter];l.filter=Math.pow(2,-ut*p*S);var ft=Math.pow(2,-ut*p*I);l.filterScale=Math.pow(ft/l.filter,1/r),lt=.135*i.waveVolumes[o.wave]*i.filterVolumes[o.filter]*i.chorusVolumes[o.chorus]}y&&!a&&l.reset(),l.phaseDeltas[0]=xt*ot;var ct=5==o.volume?0:Math.pow(2,-{var u=l[a];n.appendChild(u)}return n}}(beepbox||(beepbox={})),function(t){var i=document.createElement("style");i.type="text/css",i.appendChild(document.createTextNode('\n\n.beepboxEditor {\n\tdisplay: flex;\n\t-webkit-touch-callout: none;\n\t-webkit-user-select: none;\n\t-khtml-user-select: none;\n\t-moz-user-select: none;\n\t-ms-user-select: none;\n\tuser-select: none;\n\tposition: relative;\n\ttouch-action: manipulation;\n\tcursor: default;\n\tfont-size: small;\n\toverflow: hidden;\n}\n\n.beepboxEditor div {\n\tmargin: 0;\n\tpadding: 0;\n}\n\n.beepboxEditor .promptContainer {\n\tposition: absolute;\n\ttop: 0;\n\tleft: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbackground: rgba(0,0,0,0.5);\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n}\n\n.beepboxEditor .prompt {\n\tmargin: auto;\n\ttext-align: center;\n\tbackground: #000;\n\tborder-radius: 15px;\n\tborder: 4px solid #444;\n\tcolor: #fff;\n\tpadding: 20px;\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.beepboxEditor .prompt > *:not(:first-child) {\n\tmargin-top: 1.5em;\n}\n\n/* Use psuedo-elements to add cross-browser up & down arrows to select elements: */\n.beepboxEditor .selectContainer {\n\tposition: relative;\n}\n.beepboxEditor .selectContainer:not(.menu)::before {\n\tcontent: "";\n\tposition: absolute;\n\tright: 0.3em;\n\ttop: 0.4em;\n\tborder-bottom: 0.4em solid currentColor;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tpointer-events: none;\n}\n.beepboxEditor .selectContainer:not(.menu)::after {\n\tcontent: "";\n\tposition: absolute;\n\tright: 0.3em;\n\tbottom: 0.4em;\n\tborder-top: 0.4em solid currentColor;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tpointer-events: none;\n}\n.beepboxEditor .selectContainer.menu::after {\n\tcontent: "";\n\tposition: absolute;\n\tright: 0.7em;\n\tmargin: auto;\n\ttop: 0;\n\tbottom: 0;\n\theight: 0;\n\tborder-top: 0.4em solid currentColor;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tpointer-events: none;\n}\n.beepboxEditor select {\n\tmargin: 0;\n\tpadding: 0 0.3em;\n\tdisplay: block;\n\theight: 2em;\n\tborder: none;\n\tborder-radius: 0.4em;\n\tbackground: #444444;\n\tcolor: inherit;\n\tfont-size: inherit;\n\tcursor: pointer;\n\tfont-family: inherit;\n\n\t-webkit-appearance:none;\n\t-moz-appearance: none;\n\tappearance: none;\n}\n.beepboxEditor .menu select {\n\tpadding: 0 2em;\n}\n.beepboxEditor select:focus {\n\tbackground: #777777;\n\toutline: none;\n}\n.beepboxEditor .menu select {\n\ttext-align: center;\n\ttext-align-last: center;\n}\n\n/* This makes it look better in firefox on my computer... What about others?\n@-moz-document url-prefix() {\n\t.beepboxEditor select { padding: 0 2px; }\n}\n*/\n.beepboxEditor button {\n\tmargin: 0;\n\tposition: relative;\n\theight: 2em;\n\tborder: none;\n\tborder-radius: 0.4em;\n\tbackground: #444;\n\tcolor: inherit;\n\tfont-size: inherit;\n\tfont-family: inherit;\n\tcursor: pointer;\n}\n.beepboxEditor button:focus {\n\tbackground: #777;\n\toutline: none;\n}\n.beepboxEditor button.playButton, .beepboxEditor button.pauseButton {\n\tpadding-left: 2em;\n}\n.beepboxEditor button.playButton::before {\n\tcontent: "";\n\tposition: absolute;\n\tleft: 0.7em;\n\ttop: 50%;\n\tmargin-top: -0.65em;\n\tborder-left: 1em solid currentColor;\n\tborder-top: 0.65em solid transparent;\n\tborder-bottom: 0.65em solid transparent;\n\tpointer-events: none;\n}\n.beepboxEditor button.pauseButton::before {\n\tcontent: "";\n\tposition: absolute;\n\tleft: 0.7em;\n\ttop: 50%;\n\tmargin-top: -0.65em;\n\twidth: 0.3em;\n\theight: 1.3em;\n\tbackground: currentColor;\n\tpointer-events: none;\n}\n.beepboxEditor button.pauseButton::after {\n\tcontent: "";\n\tposition: absolute;\n\tleft: 1.4em;\n\ttop: 50%;\n\tmargin-top: -0.65em;\n\twidth: 0.3em;\n\theight: 1.3em;\n\tbackground: currentColor;\n\tpointer-events: none;\n}\n\n.beepboxEditor button.prevBarButton::before {\n\tcontent: "";\n\tposition: absolute;\n\tleft: 50%;\n\ttop: 50%;\n\tmargin-left: -0.5em;\n\tmargin-top: -0.5em;\n\twidth: 0.2em;\n\theight: 1em;\n\tbackground: currentColor;\n\tpointer-events: none;\n}\n.beepboxEditor button.prevBarButton::after {\n\tcontent: "";\n\tposition:ts[i.getCurrentInstrument()].filter!=s&&(i.song.channels[i.channel].instruments[i.getCurrentInstrument()].filter=s,i.notifier.changed(),e.P()),e}return __extends(i,t),i}(t.Change);t.ChangeFilter=f;var c=function(t){function i(i,s){var e=t.call(this)||this;return i.song.channels[i.channel].instruments[i.getCurrentInstrument()].algorithm!=s&&(i.song.channels[i.channel].instruments[i.getCurrentInstrument()].algorithm=s,i.notifier.changed(),e.P()),e}return __extends(i,t),i}(t.Change);t.ChangeAlgorithm=c;var d=function(t){function i(i,s){var e=t.call(this)||this;return i.song.channels[i.channel].instruments[i.getCurrentInstrument()].feedbackType!=s&&(i.song.channels[i.channel].instruments[i.getCurrentInstrument()].feedbackType=s,i.notifier.changed(),e.P()),e}return __extends(i,t),i}(t.Change);t.ChangeFeedbackType=d;var v=function(t){function i(i,s){var e=t.call(this)||this;return i.song.channels[i.channel].instruments[i.getCurrentInstrument()].feedbackEnvelope!=s&&(i.song.channels[i.channel].instruments[i.getCurrentInstrument()].feedbackEnvelope=s,i.notifier.changed(),e.P()),e}return __extends(i,t),i}(t.Change);t.ChangeFeedbackEnvelope=v;var p=function(t){function i(i,s,e){var n=t.call(this)||this;return i.song.channels[i.channel].instruments[i.getCurrentInstrument()].operators[s].envelope!=e&&(i.song.channels[i.channel].instruments[i.getCurrentInstrument()].operators[s].envelope=e,i.notifier.changed(),n.P()),n}return __extends(i,t),i}(t.Change);t.ChangeOperatorEnvelope=p;var b=function(t){function i(i,s,e){var n=t.call(this)||this;return i.song.channels[i.channel].instruments[i.getCurrentInstrument()].operators[s].frequency!=e&&(i.song.channels[i.channel].instruments[i.getCurrentInstrument()].operators[s].frequency=e,i.notifier.changed(),n.P()),n}return __extends(i,t),i}(t.Change);t.ChangeOperatorFrequency=b;var m=function(t){function i(i,s,e,n){var h=t.call(this)||this;return i.song.channels[i.channel].instruments[i.getCurrentInstrument()].operators[s].amplitude=n,i.notifier.changed(),e!=n&&h.P(),h}return __extends(i,t),i}(t.Change);t.ChangeOperatorAmplitude=m;var w=function(t){function i(i,s,e){var n=t.call(this)||this;return i.song.channels[i.channel].instruments[i.getCurrentInstrument()].feedbackAmplitude=e,i.notifier.changed(),s!=e&&n.P(),n}return __extends(i,t),i}(t.Change);t.ChangeFeedbackAmplitude=w;var g=function(i){function s(s,e){var n=i.call(this)||this;if(s.song.instrumentsPerChannel!=e){for(var h=0;h<s.song.getChannelCount();h++){for(var r=s.song.channels[h].instruments[s.song.instrumentsPerChannel-1],o=s.song.instrumentsPerChannel;o<e;o++){var a=new t.Instrument;a.copy(r),s.song.channels[h].instruments[o]=a}s.song.channels[h].instruments.length=e;for(o=0;o<s.song.patternsPerChannel;o++)s.song.channels[h].patterns[o].instrument>=e&&(s.song.channels[h].patterns[o].instrument=0)}s.song.instrumentsPerChannel=e,s.notifier.changed(),n.P()}return n}return __extends(s,i),s}(t.Change);t.ChangeInstrumentsPerChannel=g;var x=function(t){function i(i,s){var e=t.call(this)||this;return i.song.key!=s&&(i.song.key=s,i.notifier.changed(),e.P()),e}return __extends(i,t),i}(t.Change);t.ChangeKey=x;var y=function(t){function i(i,s,e,n,h){var r=t.call(this)||this;return r.K=i,r.oldStart=s,r.oldLength=e,r.newStart=n,r.newLength=h,r.K.song.loopStart=r.newStart,r.K.song.loopLength=r.newLength,r.K.notifier.changed(),r.oldStart==r.newStart&&r.oldLength==r.newLength||r.P(),r}return __extends(i,t),i}(t.Change);t.ChangeLoop=y;var M=function(t){function i(i,s,e,n,h){void 0===h&&(h=!1);var r=t.call(this,h)||this;return r.K=i,r.q=s,r.at=e,r.lt=n,r.P(),r.redo(),r}return __extends(i,t),i.prototype.J=function(){this.q.pitches.splice(this.lt,0,this.at),this.K.notifier.changed()},i.prototype.H=function(){this.q.pitches.splice(this.lt,1),this.K.notifier.changed()},i}(t.UndoableChange);t.ChangePitchAdded=M;var k=function(t){function i(i,s,e){var n=t.call(this)||this;return n.oldValue=s,i.song.channels[i.channel].octave=e,i.notifier.changed(),s!=e&&n.P(),n}return __extends(i,t),i}(t.Change);t.ChangeOctave=k;var A=function(t){function i(i,s){var e=t.call(this)||this;if(i.song.partsPerBeat!=s){for(var n=0;n<i.song.getChannelCount();n++)for(var h=0;h<i.song.channels[n].patterns.length;h++)e.append(new S(i,i.song.channels[n].patterns[h],i.song.partsPerBeat,s));i.song.partsPerBeat=s,i.notifier.changed(),e.P()}return e}return __extends(i,t),i}(t.ChangeGroup);t.ChangePartsPerBeat=A;var E=function(t){function i(i,s,e,n,h){var r=t.call(this)||this;return s.notes=e,i.song.partsPerBeat!=h&&r.append(new S(i,s,h,i.song.partsPerBeat)),i.song.beatsPerBar!=n&&r.append(new D(i,s,i.song.beatsPerBar*i.song.partsPerBeat,n*i.song.partsPerBeat)),i.notifier.changed(),r.P(),r}return __extends(i,t),i}(t.ChangeGroup);t.ChangePaste=E;var N=function(t){function i(i,s,e){var n=t.call(this)||this;return e.instrument!=s&&(e.instrument=s,i.notifier.changed(),n.P()),n}return __extends(i,t),i}(t.Change);t.ChangePatternInstrument=N;var B=function(i){function s(s,e){var n=i.call(this)||this;if(s.song.patternsPerChannel!=e){for(var h=0;h<s.song.getChannelCount();h++){for(var r=s.song.channels[h].bars,o=s.song.channels[h].patterns,a=0;a<r.length;a++)r[a]>e&&(r[a]=0);for(a=o.length;a<e;a++)o[a]=new t.Pattern;o.length=e}s.song.patternsPerChannel=e,s.notifier.changed(),n.P()}return n}return __extends(s,i),s}(t.Change);t.ChangePatternsPerChannel=B;var R=function(i){function s(s,e,n,h){var r=i.call(this,s,e)||this;h-=r.$;for(var o=r.et[n].time,a=Math.min(o,h),l=Math.max(o,h),u=!1,f=0;f<r.et.length;f++){var c=e.pins[f],d=c.time;d<a?r.nt.push(t.makeNotePin(c.interval,d,c.volume)):d>l&&(u||(r.nt.push(t.makeNotePin(r.et[n].interval,h,r.et[n].volume)),u=!0),r.nt.push(t.makeNotePin(c.interval,d,c.volume)))}return u||r.nt.push(t.makeNotePin(r.et[n].interval,h,r.et[n].volume)),r.ot(),r}return __extends(s,i),s}(i);t.ChangePinTime=R;var L=function(i){function s(s,e,n,h,r,o){var a=i.call(this,s,e)||this;n-=a.$,h-=a.$,r-=e.pitches[o];var l,u,f,c,d=!1,v=!1,p=0,b=3,m=!0;for(h>n?(l=0,u=1,f=e.pins.length,c=function(t){a.nt.push(t)}):(l=e.pins.length-1,u=-1,f=-1,c=function(t){a.nt.unshift(t)});l!=f;l+=u)for(var w=e.pins[l],g=w.time;;)if(d){if(v){if(g*u==h*u)break;w.interval!=p&&(m=!1),c(t.makeNotePin(m?r:w.interval,g,w.volume));break}if(g*u<=h*u&&(p=w.interval,b=w.volume),g*u<h*u)break;c(t.makeNotePin(r,h,b)),v=!0}else{if(g*u<=n*u&&(p=w.interval,b=w.volume),g*u<n*u){c(t.makeNotePin(w.interval,g,w.volume));break}c(t.makeNotePin(p,n,b)),d=!0}return v||c(t.makeNotePin(r,h,b)),a.ot(),a}return __extends(s,i),s}(i);t.ChangePitchBend=L;var S=function(t){function i(i,s,e,n){var h,r=t.call(this)||this;if(e>n)h=function(t){return Math.ceil(t*n/e)};else{if(!(e<n))throw new Error("ChangeRhythm couldn't handle rhythm change from "+e+" to "+n+".");h=function(t){return Math.floor(t*n/e)}}for(var o=0;o<s.notes.length;){var a=s.notes[o];h(a.start)>=h(a.end)?r.append(new j(i,s,a,o,!0)):(r.append(new I(i,a,h)),o++)}return r}return __extends(i,t),i}(t.ChangeSequence);t.ChangeRhythm=S;var I=function(i){function s(s,e,n){for(var h=i.call(this,s,e)||this,r=0,o=h.et;r<o.length;r++){var a=o[r];h.nt.push(t.makeNotePin(a.interval,n(a.time+h.$)-h.$,a.volume))}return h.ot(),h}return __extends(s,i),s}(i);t.ChangeRhythmNote=I;var Z=function(t){function i(i,s){var e=t.call(this)||this;return i.song.scale!=s&&(i.song.scale=s,i.notifier.changed(),e.P()),e}return __extends(i,t),i}(t.Change);t.ChangeScale=Z;var C=function(t){function i(i,s){var e=t.call(this)||this;return i.song.fromBase64String(s),i.channel=Math.min(i.channel,i.song.getChannelCount()-1),i.bar=Math.max(0,Math.min(i.song.barCount-1,i.bar)),i.barScrollPos=Math.max(0,Math.min(i.song.barCount-i.trackVisibleBars,i.barScrollPos)),i.barScrollPos=Math.min(i.bar,Math.max(i.bar-(i.trackVisibleBars-1),i.barScrollPos)),i.notifier.changed(),e.P(),e}return __extends(i,t),i}(t.Change);t.ChangeSong=C;var G=function(t){function i(i,s,e){var n=t.call(this)||this;return i.song.tempo=e,i.notifier.changed(),s!=e&&n.P(),n}return __extends(i,t),i}(t.Change);t.ChangeTempo=G;var U=function(t){function i(i,s,e){var n=t.call(this)||this;return i.song.reverb=e,i.notifier.changed(),s!=e&&n.P(),n}return __extends(i,t),i}(t.Change);t.ChangeReverb=U;var j=function(t){function i(i,s,e,n,h){void 0===h&&(h=!1);var r=t.call(this,h)||this;return r.K=i,r.ut=s,r.q=e,r.lt=n,r.P(),r.redo(),r}return __extends(i,t),i.prototype.J=function(){this.ut.notes.splice(this.lt,0,this.q),this.K.notifier.changed()},i.prototype.H=function(){this.ut.notes.splice(this.lt,1),this.K.notifier.changed()},i}(t.UndoableChange);t.ChangeNoteAdded=j;var z=function(i){function s(s,e,n,h){var r=i.call(this,s,e)||this;n-=r.$,h-=r.$;var o,a=!1,l=r.et[0].volume,u=r.et[0].interval,f=!0;for(o=0;o<r.et.length;o++){var c=r.et[o];if(c.time<n)l=c.volume,u=c.interval;else{if(!(c.time<=h))break;if(c.time>n&&!a&&r.nt.push(t.makeNotePin(u,n,l)),r.nt.push(t.makeNotePin(c.interval,c.time,c.volume)),a=!0,c.time==h){f=!1;break}}}return f&&r.nt.push(t.makeNotePin(r.et[o].interval,h,r.et[o].volume)),r.ot(),r}return __extends(s,i),s}(i);t.ChangeNoteLength=z;var D=function(t){function i(i,s,e,n,h){for(var r=t.call(this)||this,o=0;o<s.notes.length;){var a=s.notes[o];if(a==h&&void 0!=h)o++;else if(a.end<=e)o++;else{if(a.start>=n)break;a.start<e?(r.append(new z(i,a,a.start,e)),o++):a.end>n?(r.append(new z(i,a,n,a.end)),o++):r.append(new j(i,s,a,o,!0))}}return r}return __extends(i,t),i}(t.ChangeSequence);t.ChangeNoteTruncate=D;var Y=function(i){function s(s,e,n){var h=i.call(this,!1)||this;h.K=s,h.q=e,h.et=e.pins,h.nt=[],h.ht=e.pitches,h.rt=[];for(var r=s.song.getChannelIsDrum(s.channel)?t.Config.drumCount-1:t.Config.maxPitch,o=0;o<h.ht.length;o++){var a=h.ht[o];if(n){for(var l=a+1;l<=r;l++)if(s.song.getChannelIsDrum(s.channel)||t.Config.scaleFlags[s.song.scale][l%12]){a=l;break}}else for(l=a-1;l>=0;l--)if(s.song.getChannelIsDrum(s.channel)||t.Config.scaleFlags[s.song.scale][l%12]){a=l;break}var u=!1;for(l=0;l<h.rt.length;l++)if(h.rt[l]==a){u=!0;break}u||h.rt.push(a)}var f=0,c=r;for(o=1;o<h.rt.length;o++){var d=h.rt[0]-h.rt[o];f<d&&(f=d),c>d+r&&(c=d+r)}for(var v=0,p=h.et;v<p.length;v++){var b=p[v],m=b.interval+h.ht[0];if(m<f&&(m=f),m>c&&(m=c),n){for(o=m+1;o<=c;o++)if(s.song.getChannelIsDrum(s.channel)||t.Config.scaleFlags[s.song.scale][o%12]){m=o;break}}else for(o=m-1;o>=f;o--)if(s.song.getChannelIsDrum(s.channel)||t.Config.scaleFlags[s.song.scale][o%12]){m=o;break}m-=h.rt[0],h.nt.push(t.makeNotePin(m,b.time,b.volume))}if(0!=h.nt[0].interval)throw new Error("wrong pin start interval");for(o=1;o<h.nt.length-1;)h.nt[o-1].interval==h.nt[o].interval&&h.nt[o].interval==h.nt[o+1].interval&&h.nt[o-1].volume==h.nt[o].volume&&h.nt[o].volume==h.nt[o+1].volume?h.nt.splice(o,1):o++;return h.J(),h.P(),h}return __extends(s,i),s.prototype.J=function(){this.q.pins=this.nt,this.q.pitches=this.rt,this.K.notifier.changed()},s.prototype.H=function(){this.q.pins=this.et,this.q.pitches=this.ht,this.K.notifier.changed()},s}(t.UndoableChange);t.ChangeTransposeNote=Y;var T=function(t){function i(i,s,e){for(var n=t.call(this)||this,h=0;h<s.notes.length;h++)n.append(new Y(i,s.notes[h],e));return n}return __extends(i,t),i}(t.ChangeSequence);t.ChangeTranspose=T;var F=function(t){function i(i,s,e){var n=t.call(this)||this;return i.song.channels[i.channel].instruments[i.getCurrentInstrument()].volume=e,i.notifier.changed(),s!=e&&n.P(),n}return __extends(i,t),i}(t.Change);t.ChangeVolume=F;var V=function(i){function s(s,e,n,h,r){var o=i.call(this,!1)||this;o.K=s,o.q=e,o.et=e.pins,o.nt=[];for(var a=!1,l=0,u=e.pins;l<u.length;l++){var f=u[l];f.time<n?o.nt.push(f):f.time==n?(o.nt.push(t.makeNotePin(r,n,h)),a=!0):(a||(o.nt.push(t.makeNotePin(r,n,h)),a=!0),o.nt.push(f))}for(var c=1;c<o.nt.length-1;)o.nt[c-1].interval==o.nt[c].interval&&o.nt[c].interval==o.nt[c+1].interval&&o.nt[c-1].volume==o.nt[c].volume&&o.nt[c].volume==o.nt[c+1].volume?o.nt.splice(c,1):c++;return o.J(),o.P(),o}return __extends(s,i),s.prototype.J=function(){this.q.pins=this.nt,this.K.notifier.changed()},s.prototype.H=function(){this.q.pins=this.et,this.K.notifier.changed()},s}(t.UndoableChange);t.ChangeVolumeBend=V;var P=function(t){function i(i,s){var e=t.call(this)||this;return i.song.channels[i.channel].instruments[i.getCurrentInstrument()].wave!=s&&(i.song.channels[i.channel].instruments[i.getCurrentInstrument()].wave=s,i.notifier.changed(),e.P()),e}return __extends(i,t),i}(t.Change);t.ChangeWave=P}(beepbox||(beepbox={})),function(t){function i(t){return t.toFixed(2).replace(/\.?0*$/,"")}var s=function(){return function(){this.valid=!1,this.prevNote=null,this.curNote=null,this.nextNote=null,this.pitch=0,this.pitchIndex=-1,this.curIndex=0,this.start=0,this.end=0,this.part=0,this.notePart=0,this.neam=Math.round(Math.max(this.Vt.curNote.start,Math.min(this.Vt.curNote.end,this.Et/this.pi)))-this.Vt.curNote.start,w=void 0,g=this.Vt.curNote.pins[0],x=0,y=0;for(c=1;c<this.Vt.curNote.pins.length;c++)if(w=g,!(m>(g=this.Vt.curNote.pins[c]).time)){if(m<w.time)throw new Error;var M=(m-w.time)/(g.time-w.time);(x=Math.round(w.volume*(1-M)+g.volume*M+(this.Gt-this.Nt)/25))<0&&(x=0),x>3&&(x=3),y=this.Mi(w.interval*(1-M)+g.interval*M+this.Vt.curNote.pitches[0],0,t.Config.maxPitch)-this.Vt.curNote.pitches[0];break}this.zt=this.Vt.curNote.start+m,this.Dt=this.Vt.curNote.pitches[-1==this.Vt.pitchIndex?0:this.Vt.pitchIndex]+y,this.Yt=x,this.Tt=!0,o.append(new t.ChangeVolumeBend(this.K,this.Vt.curNote,m,x,y)),this.fi(this.Vt.curNote)}else{this.Yt=this.Vt.curNote.pins[this.Vt.nearPinIndex].volume;var k=void 0,A=void 0;this.Et>=this.Ct?(k=this.Vt.part,A=r+1):(k=this.Vt.part+1,A=r),A<0&&(A=0),A>this.K.song.beatsPerBar*this.K.song.partsPerBeat&&(A=this.K.song.beatsPerBar*this.K.song.partsPerBeat),A>this.Vt.curNote.end&&o.append(new t.ChangeNoteTruncate(this.K,this.ut,this.Vt.curNote.start,A,this.Vt.curNote)),A<this.Vt.curNote.start&&o.append(new t.ChangeNoteTruncate(this.K,this.ut,A,this.Vt.curNote.end,this.Vt.curNote));for(var E=Number.MAX_VALUE,N=-Number.MAX_VALUE,B=0,R=this.Vt.curNote.pitches;B<R.length;B++){var L=R[B];E>L&&(E=L),N<L&&(N=L)}E-=this.Vt.curNote.pitches[this.Vt.pitchIndex],N-=this.Vt.curNote.pitches[this.Vt.pitchIndex];var S=this.Mi(this.yi(this.Nt),-E,(this.K.song.getChannelIsDrum(this.K.channel)?t.Config.drumCount-1:t.Config.maxPitch)-N);o.append(new t.ChangePitchBend(this.K,this.Vt.curNote,k,A,S,this.Vt.pitchIndex)),this.fi(this.Vt.curNote),this.zt=A,this.Dt=S,this.Tt=!0}}this.Ut=this.Et,this.jt=this.Nt}else this.ci(),this.di()}},e.prototype.di=function(){if(this.It)if(this.Bt&&this.Vt.valid&&this.Lt&&this.Tt&&null!=this.ut){this.bt.setAttribute("visibility","visible");var t=this.pi*this.zt,s=this.xi(this.Dt-this.Ot),e=this.bi/2,n="";n+="M "+i(t)+" "+i(s-e*(this.Yt/3))+" ",n+="L "+i(t)+" "+i(s-e*(this.Yt/3)-60)+" ",n+="M "+i(t)+" "+i(s+e*(this.Yt/3))+" ",n+="L "+i(t)+" "+i(s+e*(this.Yt/3)+60)+" ",n+="M "+i(t)+" "+i(s-e*(this.Yt/3))+" ",n+="L "+i(t+80)+" "+i(s-e*(this.Yt/3))+" ",n+="M "+i(t)+" "+i(s+e*(this.Yt/3))+" ",n+="L "+i(t+80)+" "+i(s+e*(this.Yt/3))+" ",n+="M "+i(t)+" "+i(s-e*(this.Yt/3))+" ",n+="L "+i(t-80)+" "+i(s-e*(this.Yt/3))+" ",n+="M "+i(t)+" "+i(s+e*(this.Yt/3))+" ",n+="L "+i(t-80)+" "+i(s+e*(this.Yt/3))+" ",this.bt.setAttribute("d",n)}else this.bt.setAttribute("visibility","hidden");else this.Rt&&!this.Bt&&this.Vt.valid&&null!=this.ut?(this.bt.setAttribute("visibility","visible"),this.gi(this.bt,this.Vt.pitch,this.Vt.start,this.Vt.pins,this.bi/2+1,!0,this.Ot)):this.bt.setAttribute("visibility","hidden")},e.prototype.gi=function(t,s,e,n,h,r,o){for(var a=n[0],l="M "+i(this.pi*(e+a.time)+1)+" "+i(this.xi(s-o)+h*(r?a.volume/3:1))+" ",u=1;u<n.length;u++){var f=a;a=n[u];var c=this.pi*(e+f.time)+(1==u?1:0),d=this.pi*(e+a.time)-(u==n.length-1?1:0),v=this.xi(s+f.interval-o),p=this.xi(s+a.interval-o),b=r?f.volume/3:1,m=r?a.volume/3:1;l+="L "+i(c)+" "+i(v-h*b)+" ",f.interval>a.interval&&(l+="L "+i(c+1)+" "+i(v-h*b)+" "),f.interval<a.interval&&(l+="L "+i(d-1)+" "+i(p-h*m)+" "),l+="L "+i(d)+" "+i(p-h*m)+" "}for(u=n.length-2;u>=0;u--){f=a;a=n[u];c=this.pi*(e+f.time)-(u==n.length-2?1:0),d=this.pi*(e+a.time)+(0==u?1:0),v=this.xi(s+f.interval-o),p=this.xi(s+a.interval-o),b=r?f.volume/3:1,m=r?a.volume/3:1;l+="L "+i(c)+" "+i(v+h*b)+" ",f.interval<a.interval&&(l+="L "+i(c-1)+" "+i(v+h*b)+" "),f.interval>a.interval&&(l+="L "+i(d+1)+" "+i(p+h*m)+" "),l+="L "+i(d)+" "+i(p+h*m)+" "}l+="z",t.setAttribute("d",l)},e.prototype.xi=function(t){return this.bi*(this.mi-t-.5)},e}();t.PatternEditor=e}(beepbox||(beepbox={})),function(t){var i=function(){function i(i,s,e,n){this.ki=t.html.text("1"),this.Ai=t.svgElement("text",{x:16,y:23,"font-family":"sans-serif","font-size":20,"text-anchor":"middle","font-weight":"bold",fill:"red"},[this.ki]),this.Ei=t.svgElement("rect",{width:30,height:30,x:1,y:1}),this.container=t.svgElement("svg",void 0,[this.Ei,this.Ai]),this.Ni=1,this.Bi=!0,this.Ri=!1,this.Li="",this.container.setAttribute("x",""+32*s),this.container.setAttribute("y",""+32*e),this.Ei.setAttribute("fill","#444444"),this.Ai.setAttribute("fill",n)}return i.prototype.setSquashed=function(t,i){t?(this.container.setAttribute("y",""+27*i),this.Ei.setAttribute("height","25"),this.Ai.setAttribute("y","21")):(this.container.setAttribute("y",""+32*i),this.Ei.setAttribute("height","30"),this.Ai.setAttribute("y","23"))},i.prototype.setIndex=function(t,i,s,e,n){this.Ni!=t&&(this.Ri||0==t==(0==this.Ni)||this.Ei.setAttribute("fill",0==t?"#000000":"#444444"),this.Ni=t,this.ki.data=""+t),this.Bi==i&&this.Li==n||(this.Bi=i,s?this.Ai.setAttribute("fill","#000000"):this.Ai.setAttribute("fill",n)),this.Ri==s&&this.Li==n||(this.Ri=s,s?(this.Ei.setAttribute("fill",n),this.Ai.setAttribute("fill","#000000")):(this.Ei.setAttribute("fill",0==this.Ni?"#000000":"#444444"),this.Ai.setAttribute("fill",n))),this.Li=n},i}(),s=function(){function s(i,s){var e=this;this.K=i,this.Si=s,this.Ii=32,this.wt=t.svgElement("svg",{style:"background-color: #000000; position: absolute;",height:128}),this.Zi=t.html.select({className:"trackSelectBox",style:"width: 32px; height: 32px; background: none; border: none; appearance: none; color: transparent; position: absolute;"}),this.container=t.html.div({style:"height: 128px; position: relative; overflow:hidden;"},[this.wt,this.Zi]),this.Ci=t.svgElement("g"),this.Gi=t.svgElement("rect",{fill:"white",x:0,y:0,width:4,height:128}),this.Ui=t.svgElement("rect",{fill:"none",stroke:"white","stroke-width":2,"pointer-events":"none",x:1,y:1,width:30,height:30}),this.ji=t.svgElement("path",{his.Zi.selectedIndex!=d&&(this.Zi.selectedIndex=d)},s.prototype.render=function(){this.ut=this.K.getCurrentPattern();var t=!(window.innerWidth>700)||this.K.song.getChannelCount()>4||this.K.song.barCount>this.K.trackVisibleBars&&this.K.song.getChannelCount()>3;if(this.Ti=t?27:32,this.Fi!=this.K.song.getChannelCount()){for(var s=this.Fi;s<this.K.song.getChannelCount();s++){this.Di[s]=[];for(var e=0;e<this.Vi;e++){(u=new i(s,e,s,this.K.song.getChannelColorDim(s))).setSquashed(t,s),this.Ci.appendChild(u.container),this.Di[s][e]=u}}for(s=this.K.song.getChannelCount();s<this.Fi;s++)for(e=0;e<this.Vi;e++)this.Ci.removeChild(this.Di[s][e].container);this.Di.length=this.K.song.getChannelCount()}if(this.Vi!=this.K.song.barCount){for(s=0;s<this.K.song.getChannelCount();s++){for(e=this.Vi;e<this.K.song.barCount;e++){(u=new i(s,e,s,this.K.song.getChannelColorDim(s))).setSquashed(t,s),this.Ci.appendChild(u.container),this.Di[s][e]=u}for(e=this.K.song.barCount;e<this.Vi;e++)this.Ci.removeChild(this.Di[s][e].container);this.Di[s].length=this.K.song.barCount}this.Vi=this.K.song.barCount;var n=32*this.K.song.barCount;this.container.style.width=n+"px",this.wt.setAttribute("width",n+"")}if(this.Wi!=t)for(s=0;s<this.K.song.getChannelCount();s++)for(e=0;e<this.Vi;e++)this.Di[s][e].setSquashed(t,s);this.Wi==t&&this.Fi==this.K.song.getChannelCount()||(this.Wi=t,this.Fi=this.K.song.getChannelCount(),this.At=this.K.song.getChannelCount()*this.Ti,this.wt.setAttribute("height",""+this.At),this.Gi.setAttribute("height",""+this.At),this.container.style.height=this.At+"px");for(var h=0;h<this.K.song.getChannelCount();h++)for(var r=0;r<this.Vi;r++){var o=this.K.song.getPattern(h,r),a=r==this.K.bar&&h==this.K.channel,l=null==o||0==o.notes.length,u=this.Di[h][r];r<this.K.song.barCount?(u.setIndex(this.K.song.channels[h].bars[r],l,a,h,l&&!a?this.K.song.getChannelColorDim(h):this.K.song.getChannelColorBright(h)),u.container.style.visibility="visible"):u.container.style.visibility="hidden"}this.di()},s}();t.TrackEditor=s}(beepbox||(beepbox={})),function(t){var i=function(){function i(i){var s=this;this.K=i,this.Ii=32,this.At=20,this.qi=0,this.$i=1,this.ts=2,this.ss=t.svgElement("path",{fill:"none",stroke:"#7744ff","stroke-width":4}),this.es=t.svgElement("path",{fill:"white","pointer-events":"none"}),this.wt=t.svgElement("svg",{style:"background-color: #000000; touch-action: pan-y; position: absolute;",height:this.At},[this.ss,this.es]),this.container=t.html.div({style:"height: 20px; position: relative; margin: 5px 0;"},[this.wt]),this.ns=null,this.Vt={startBar:-1,mode:-1},this.Et=0,this.Nt=0,this.hs=0,this.rs=0,this.os=!1,this.as=!1,this.Bt=!1,this.Rt=!1,this.ls=-1,this.us=-1,this.Vi=0,this.si=function(t){s.Rt||(s.Rt=!0,s.di())},this.ei=function(t){s.Rt&&(s.Rt=!1,s.di())},this.ni=function(t){t.preventDefault(),s.Bt=!0;var i=s.wt.getBoundingClientRect();s.Et=(t.clientX||t.pageX)-i.left,s.Nt=(t.clientY||t.pageY)-i.top,s.ci(),s.di(),s.oi(t)},this.ri=function(t){s.Bt=!0;var i=s.wt.getBoundingClientRect();s.Et=t.touches[0].clientX-i.left,s.Nt=t.touches[0].clientY-i.top,s.ci(),s.di(),s.hs=t.touches[0].clientX,s.rs=t.touches[0].clientY,s.as=!1,s.os=!1},this.oi=function(t){var i=s.wt.getBoundingClientRect();s.Et=(t.clientX||t.pageX)-i.left,s.Nt=(t.clientY||t.pageY)-i.top,s.ai()},this.li=function(t){if(s.Bt){var i=s.wt.getBoundingClientRect();s.Et=t.touches[0].clientX-i.left,s.Nt=t.touches[0].clientY-i.top,s.as||s.os||(Math.abs(t.touches[0].clientY-s.rs)>10?s.os=!0:Math.abs(t.touches[0].clientX-s.hs)>10&&(s.as=!0)),s.as&&(s.ai(),t.preventDefault())}},this.fs=function(t){t.preventDefault(),s.os||(s.ai(),s.Rt=!1,s.ui(t),s.di())},this.ui=function(t){null!=s.ns&&s.K.record(s.ns),s.ns=null,s.Bt=!1,s.ci(),s.cs()},this.vi=function(){s.cs()},this.ci(),this.cs(),this.K.notifier.watch(this.vi),this.container.addEventListener("mousedown",this.ni),document.addEventListener("mousemove",this.oi),document.addEventListener("mouseup",this.ui),this.container.addEventListener("mouseover",this.si),this.container.addEventListener("mouseout",this.ei),this.container.addEventListener("touchstart",this.ri),this.container.addEventListener("touchmove",this.li),this.container.addEventListener("touchend",this.fs),this.container.addEventListener("touchcancel",this.fs)}return i.prototype.ci=function(){var t=this.Et/this.Ii;this.Vt.startBar=t,t>this.K.song.loopStart-.25&&t<this.K.song.loopStart+this.K.song.loopLength+.25?t-this.K.song.loopStart<.5*this.K.song.loopLength?this.Vt.mode=this.qi:this.Vt.mode=this.$i:this.Vt.mode=this.ts},i.prototype.ds=function(t){var i=Math.round(t-this.K.song.loopLength/2),s=i+this.K.song.loopLength;return i<0&&(s-=i,i=0),s>this.K.song.barCount&&(i-=s-this.K.song.barCount,s=this.K.song.barCount),{start:i,length:s-i}},i.prototype.ai=function(){if(this.Bt){var i=this.K.song.loopStart,s=this.K.song.loopStart+this.K.song.loopLength;null!=this.ns&&this.K.lastChangeWas(this.ns)&&(s=(i=this.ns.oldStart)+this.ns.oldLength);var e=this.Et/this.Ii,n=void 0,h=void 0,r=void 0;if(this.Vt.mode==this.qi)h=s,(n=i+Math.round(e-this.Vt.startBar))<0&&(n=0),n>=this.K.song.barCount&&(n=this.K.song.barCount),n==h?n=h-1:n>h&&(r=n,n=h,h=r),this.ns=new t.ChangeLoop(this.K,i,s-i,n,h-n);else if(this.Vt.mode==this.$i)n=i,(h=s+Math.round(e-this.Vt.startBar))<0&&(h=0),h>=this.K.song.barCount&&(h=this.K.song.barCount),h==n?h=n+1:h<n&&(r=n,n=h,h=r),this.ns=new t.ChangeLoop(this.K,i,s-i,n,h-n);else if(this.Vt.mode==this.ts){var o=this.ds(e);this.ns=new t.ChangeLoop(this.K,i,s-i,o.start,o.length)}this.K.setProspectiveChange(this.ns)}else this.ci(),this.di()},i.prototype.di=function(){var t=this.Rt&&!this.Bt;if(this.es.style.visibility=t?"visible":"hidden",t){var i=this.At/2,s=this.K.song.loopStart*this.Ii,e=(this.K.song.loopStart+this.K.song.loopLength)*this.Ii;if(this.Vt.mode==this.qi)e=this.K.song.loopStart*this.Ii+2*i;else if(this.Vt.mode==this.$i)s=(this.K.song.loopStart+this.K.song.loopLength)*this.Ii-2*i;else{var n=this.ds(this.Vt.startBar);s=n.start*this.Ii,e=(n.start+n.length)*this.Ii}this.es.setAttribute("d","M "+(s+i)+" 4 L "+(e-i)+" 4 A "+(i-4)+" "+(i-4)+" 0 0 1 "+(e-i)+" "+(this.At-4)+" L "+(s+i)+" "+(this.At-4)+" A "+(i-4)+" "+(i-4)+" 0 0 1 "+(s+i)+" 4 z")}},i.prototype.cs=function(){var t=this.At/2,i=this.K.song.loopStart*this.Ii,s=(this.K.song.loopStart+this.K.song.loopLength)*this.Ii;if(this.Vi!=this.K.song.barCount){this.Vi=this.K.song.barCount;var e=32*this.K.song.barCount;this.container.style.width=e+"px",this.wt.setAttribute("width",e+"")}this.ls==i&&this.us==s||(this.ls=i,this.us=s,this.ss.setAttribute("d","M "+(i+t)+" 2 L "+(s-t)+" 2 A "+(t-2)+" "+(t-2)+" 0 0 1 "+(s-t)+" "+(this.At-2)+" L "+(i+t)+" "+(this.At-2)+" A "+(t-2)+" "+(t-2)+" 0 0 1 "+(i+t)+" 2 z")),this.di()},i}();t.LoopEditor=i}(beepbox||(beepbox={})),function(t){var i=function(){function i(i,s){var e=this;this.K=i,this.vs=s,this.ii=512,this.At=20,this.ps=t.svgElement("svg",{"pointer-events":"none"}),this.bs=t.svgElement("rect",{fill:"#444444",x:0,y:2,width:10,height:this.At-4}),this.ms=t.svgElement("rect",{fill:"none",stroke:"white","stroke-width":2,"pointer-events":"none",x:0,y:1,width:10,height:this.At-2}),this.ws=t.svgElement("path",{fill:"white","pointer-events":"none"}),this.gs=t.svgElement("path",{fill:"white","pointer-events":"none"}),this.wt=t.svgElement("svg",{style:"background-color: #000000; touch-action: pan-y; position: absolute;",width:this.ii,height:this.At},[this.ps,this.bs,this.ms,this.ws,this.gs]),this.container=t.html.div({className:"barScrollBar",style:"width: 512px; height: 20px; overflow: hidden; position: relative;"},[this.wt]),this.Et=0,this.Nt=0,this.Bt=!1,this.Rt=!1,this.xs=!1,this.ys=-1,this.Ms=-1,this.ks=function(t){e.K.barScrollPos=e.vs.scrollLeft/32},this.si=function(t){e.Rt||(e.Rt=!0,e.di())},this.ei=function(t){e.Rt&&(e.Rt=!1,e.di())},this.ni=function(t){t.preventDefault(),e.Bt=!0;var i=e.wt.getBoundingClientRect();e.Et=(t.clientX||t.pageX)-i.left,e.Nt=(t.clientY||t.pageY)-i.top,e.di(),e.Et>=e.K.barScrollPos*e.Ii&&e.Et<=(e.K.barScrollPos+e.K.trackVisibleBars)*e.Ii&&(e.xs=!0,e.As=e.Et)},this.ri=function(t){t.preventDefault(),e.Bt=!0;var i=e.wt.getBoundingClientRect();e.Et=t.touches[0].clientX-i.left,e.Nt=t.touches[0].clientY-i.top,e.di(),e.Et>=e.K.barScrollPos*e.Ii&&e.Et<=(e.K.barScrollPos+e.K.trackVisibleBars)*e.Ii&&(e.xs=!0,e.As=e.Et)},this.oi=function(t){var i=e.wt.getBoundingClientRect();e.Et=(t.clientX||t.pageX)-i.left,e.Nt=(t.clientY||t.pageY)-i.top,e.ai()},this.li=function(t){if(e.Bt){t.preventDefault();var i=e.wt.getBoundingClientRect();e.Et=t.touches[0].clientX-i.left,e.Nt=t.touches[0].clientY-i.top,e.ai()}},this.ui=function(t){!e.xs&&e.Bt&&(e.Et<(e.K.barScrollPos+8)*e.Ii?(e.K.barScrollPos>0&&e.K.barScrollPos--,e.K.notifier.changed()):(e.K.barScrollPos<e.K.song.barCount-e.K.trackVisibleBars&&e.K.barScrollPos++,e.K.notifier.changed())),e.Bt=!1,e.xs=!1,e.di()};var n=.5*this.At;this.ws.setAttribute("d","M 9 "+n+" L 20 "+(n+6)+" L 20 "+(n-6)+" z"),this.gs.setAttribute("d","M "+(this.ii-9)+" "+n+" L "+(this.ii-20)+" "+(n+6)+" L "+(this.ii-20)+" "+(n-6)+" z"),this.container.addEventListener("mousedown",this.ni),document.addEventListener("mousemove",this.oi),document.addEventListener("mouseup",this.ui),this.container.addEventListener("mouseover",this.si),this.container.addEventListener("mouseout",this.ei),this.container.addEventListener("touchstart",this.ri),this.container.addEventListener("touchmove",this.li),this.container.addEventListener("touchend",this.ui),this.container.addEventListener("touchcancel",this.ui),this.vs.addEventListener("scroll",this.ks,{capture:!1,passive:!0})}return i.prototype.ai=function(){if(this.xs){for(;this.Et-this.As<.5*-this.Ii&&this.K.barScrollPos>0;)this.K.barScrollPos--,this.As-=this.Ii,this.K.notifier.changed();for(;this.Et-this.As>.5*this.Ii&&this.K.barScrollPos<this.K.song.barCount-this.K.trackVisibleBars;)this.K.barScrollPos++,this.As+=this.Ii,this.K.notifier.changed()}this.Rt&&this.di()},i.prototype.di=function(){var t=!1,i=!1,s=!1;this.Rt&&!this.Bt&&(this.Et<this.K.barScrollPos*this.Ii?t=!0:this.Et>(this.K.barScrollPos+this.K.trackVisibleBars)*this.Ii?i=!0:s=!0),this.ws.style.visibility=t?"visible":"hidden",this.gs.style.visibility=i?"visible":"hidden",this.ms.style.visibility=s?"visible":"hidden"},i.prototype.render=function(){this.Ii=(this.ii-1)/Math.max(this.K.trackVisibleBars,this.K.song.barCount);var i=this.ys!=this.K.song.barCount;if(i){for(this.ys=this.K.song.barCount;this.ps.firstChild;)this.ps.removeChild(this.ps.firstChild);for(var s=0;s<=this.K.song.barCount;s++){var e=s%16==0?0:s%4==0?this.At/8:this.At/3;this.ps.appendChild(t.svgElement("rect",{fill:"#444444",x:s*this.Ii-1,y:e,width:2,height:this.At-2*e}))}}(i||this.Ms!=this.K.barScrollPos)&&(this.Ms=this.K.barScrollPos,this.bs.setAttribute("x",""+this.Ii*this.K.barScrollPos),this.bs.setAttribute("width",""+this.Ii*this.K.trackVisibleBars),this.ms.setAttribute("x",""+this.Ii*this.K.barScrollPos),this.ms.setAttribute("width",""+this.Ii*this.K.trackVisibleBars)),this.di(),this.vs.scrollLeft=32*this.K.barScrollPos},i}();t.BarScrollBar=i}(beepbox||(beepbox={})),function(t){var i=function(){function i(i){var s=this;this.K=i,this.ii=20,this.At=481,this.Es=4,this.Ns=7,this.Bs=(this.At-this.Es)/this.Ns,this.Rs=3*this.Bs+this.Es,this.bs=t.svgElement("rect",{fill:"#444444",x:2,y:0,width:this.ii-4,height:this.Rs}),this.ms=t.svgElement("rect",{fill:"none",stroke:"white","stroke-width":2,"pointer-events":"none",x:1,y:0,width:this.ii-2,height:this.Rs}),this.ji=t.svgElement("path",{fill:"white","pointer-events":"none"}),this.zi=t.svgElement("path",{fill:"white","pointer-events":"none"}),this.wt=t.svgElement("svg",{style:"background-color: #000000; touch-action: pan-x; position: absolute;",width:this.ii,height:"100%",viewBox:"0 0 20 481",preserveAspectRatio:"none"}),this.container=t.html.div({id:"octaveScrollBarContainer",style:"width: 20px; height: 100%; overflow: hidden; position: relative; flex-shrink: 0;"},[this.wt]),this.Et=0,this.Nt=0,this.Bt=!1,this.Rt=!1,this.xs=!1,this.Ls=-1,this.ns=null,this.si=function(t){s.Rt||(s.Rt=!0,s.di())},this.ei=function(t){s.Rt&&(s.Rt=!1,s.di())},this.ni=function(t){t.preventDefault(),s.Bt=!0;var i=s.wt.getBoundingClientRect();s.Et=(t.clientX||t.pageX)-i.left,s.Nt=((t.clientY||t.pageY)-i.top)*s.At/(i.bottom-i.top),isNaN(s.Nt)&&(s.Nt=0),s.K.song.getChannelIsDrum(s.K.channel)||(s.di(),s.Nt>=s.Ss-s.Rs&&s.Nt<=s.Ss&&(s.xs=!0,s.ns=null,s.As=s.Nt))},this.ri=function(t){t.preventDefault(),s.Bt=!0;var i=s.wt.getBoundingClientRect();s.Et=t.touches[0].clientX-i.left,s.Nt=(t.touches[0].clientY-i.top)*s.At/(i.bottom-i.top),isNaN(s.Nt)&&(s.Nt=0),s.K.song.getChannelIsDrum(s.K.channel)||(s.di(),s.Nt>=s.Ss-s.Rs&&s.Nt<=s.Ss&&(s.xs=!0,s.ns=null,s.As=s.Nt))},this.oi=function(t){var i=s.wt.getBoundingClientRect();s.Et=(t.clientX||t.pageX)-i.left,s.Nt=((t.clientY||t.pageY)-i.top)*s.At/(i.bottom-i.top),isNaN(s.Nt)&&(s.Nt=0),s.ai()},this.li=function(t){if(s.Bt){t.preventDefault();var i=s.wt.getBoundingClientRect();s.Et=t.touches[0].clientX-i.left,s.Nt=(t.touches[0].clientY-i.top)*s.At/(i.bottom-i.top),isNaN(s.Nt)&&(s.Nt=0),s.ai()}},this.ui=function(i){if(!s.K.song.getChannelIsDrum(s.K.channel)&&s.Bt)if(s.xs)null!=s.ns&&s.K.record(s.ns);else{var e=s.K.lastChangeWas(s.ns),n=e?s.ns.oldValue:s.K.song.channels[s.K.channel].octave,h=s.K.song.channels[s.K.channel].octave;s.Nt<s.Ss-.5*s.Rs?h<4&&(s.ns=new t.ChangeOctave(s.K,n,h+1),s.K.record(s.ns,e)):h>0&&(s.ns=new t.ChangeOctave(s.K,n,h-1),s.K.record(s.ns,e))}s.Bt=!1,s.xs=!1,s.di()},this.vi=function(){s.Ss=s.At-s.Bs*s.K.song.channels[s.K.channel].octave,s.cs()},this.K.notifier.watch(this.vi),this.vi(),this.wt.appendChild(this.bs);for(var e=0;e<=this.Ns;e++)this.wt.appendChild(t.svgElement("rect",{fill:"#886644",x:0,y:e*this.Bs,width:this.ii,height:this.Es}));this.wt.appendChild(this.ms),this.wt.appendChild(thi[s({className:"editor-song-settings"},[s({style:"margin: 3px 0; text-align: center; color: #999;"},[o("Song Settings")]),s({className:"selectRow"},[e({},[o("Scale: ")]),s({className:"selectContainer"},[this.Ie])]),s({className:"selectRow"},[e({},[o("Key: ")]),s({className:"selectContainer"},[this.Ze])]),s({className:"selectRow"},[e({},[o("Tempo: ")]),this.Ce.input]),s({className:"selectRow"},[e({},[o("Reverb: ")]),this.Ge.input]),s({className:"selectRow"},[e({},[o("Rhythm: ")]),s({className:"selectContainer"},[this.Ue])])]),s({className:"editor-instrument-settings"},[s({style:"margin: 3px 0; text-align: center; color: #999;"},[o("Instrument Settings")]),this.an])])])]),this.ln]),this.un=null,this.fn=[],this.cn=[],this.dn=[],this.vn=[],this.pn=function(){d.mainLayer.focus()},this.whenUpdated=function(){var i=d.vs.getBoundingClientRect();d.K.trackVisibleBars=Math.floor((i.right-i.left)/32),d.ge.render(),d.me.render();for(var s=[(d.K.autoPlay?"✓ ":"")+"Auto Play On Load",(d.K.autoFollow?"✓ ":"")+"Auto Follow Track",(d.K.showLetters?"✓ ":"")+"Show Piano",(d.K.showFifth?"✓ ":"")+"Highlight 'Fifth' Notes",(d.K.showChannels?"✓ ":"")+"Show All Channels",(d.K.showScrollBar?"✓ ":"")+"Octave Scroll Bar"],e=0;e<s.length;e++){var n=d.Re.children[e+1];n.innerText!=s[e]&&(n.innerText=s[e])}var h=d.K.song.channels[d.K.channel],r=d.K.getCurrentPattern(),o=d.K.getCurrentInstrument(),a=h.instruments[o],f=d.mainLayer.contains(document.activeElement),c=document.activeElement;if(u(d.Ie,d.K.song.scale),u(d.Ze,d.K.song.key),d.Ce.updateValue(d.K.song.tempo),d.Ce.input.title=d.K.song.getBeatsPerMinute()+" beats per minute",d.Ge.updateValue(d.K.song.reverb),u(d.Ue,t.Config.partCounts.indexOf(d.K.song.partsPerBeat)),2==a.type)d.Oe.style.display="",d.Je.style.display="",d.Qe.style.display="",d.De.style.display="none",d.Te.style.display="none",d.sn.style.display="none",d.nn.style.display="none",d.on.style.display="none",d.We.style.display="none",d._e.style.display="none",d.$e.style.display="none",d.in.style.display="none";else if(0==a.type)d.De.style.display="",d.in.style.display="",d.Je.style.display="none",d.Oe.style.display="",d.We.style.display="",d.Qe.style.display="",d._e.style.display="",d.$e.style.display="",d.Te.style.display="none",d.sn.style.display="none",d.nn.style.display="none",d.on.style.display="none";else{if(1!=a.type)throw new Error("Unrecognized instrument type: "+a.type);d.De.style.display="",d.in.style.display="",d.Je.style.display="none",d.Te.style.display="",d.sn.style.display="",d.nn.style.display="",d.on.style.display="",d.Oe.style.display="none",d.Qe.style.display="none",d._e.style.display="none",d.$e.style.display="none"}if(u(d.je,a.type),u(d.Ye,a.algorithm),d.Ve.style.display=d.K.song.instrumentsPerChannel>1?"":"none",d.Ve.style.visibility=null==r?"hidden":"",d.Fe.children.length!=d.K.song.instrumentsPerChannel){for(;d.Fe.firstChild;)d.Fe.removeChild(d.Fe.firstChild);var v=[];for(e=0;e<d.K.song.instrumentsPerChannel;e++)v.push(e+1);l(d.Fe,v)}d.an.style.color=d.K.song.getNoteColorBright(d.K.channel),u(d.We,a.wave),u(d.Je,a.wave),u(d.Xe,a.filter),u(d.He,a.transition),u(d.tn,a.effect),u(d.Ke,a.chorus),u(d.en,a.feedbackType),d.hn.updateValue(a.feedbackAmplitude),u(d.rn,a.feedbackEnvelope),d.rn.parentElement.style.color=a.feedbackAmplitude>0?"":"#999",d.Pe.updateValue(-a.volume),u(d.Fe,o);for(e=0;e<t.Config.operatorCount;e++){var p=e<t.Config.operatorCarrierCounts[a.algorithm];d.fn[e].style.color=p?"white":"",u(d.vn[e],a.operators[e].frequency),d.cn[e].updateValue(a.operators[e].amplitude),u(d.dn[e],a.operators[e].envelope);var b=(p?"Voice ":"Modulator ")+(e+1);d.vn[e].title=b+" Frequency",d.cn[e].input.title=b+(p?" Volume":" Amplitude"),d.dn[e].title=b+" Envelope",d.dn[e].parentElement.style.color=a.operators[e].amplitude>0?"":"#999"}d.ye.container.style.display=d.K.showLetters?"":"none",d.xe.container.style.display=d.K.showScrollBar?"":"none",d.ge.container.style.display=d.K.song.barCount>d.K.trackVisibleBars?"":"none",d.ze.style.display=1==a.type?"":"none",d.qe.style.display=t.Config.chorusHarmonizes[a.chorus]?"":"none";var m=512;d.K.showLetters&&(m-=32),d.K.showScrollBar&&(m-=20),d.be.container.style.width=String(m)+"px",d.Ne.value=String(d.K.volume),f&&0==c.clientWidth&&d.pn(),d.bn(d.K.prompt),d.K.autoFollow&&!d.K.synth.playing&&d.K.synth.snapToBar(d.K.bar)},this.mn=function(i){if(d.prompt)27==i.keyCode&&window.history.back();else switch(d.me.onKeyPressed(i),i.keyCode){case 32:d.wn(),i.preventDefault();break;case 90:i.shiftKey?d.K.redo():d.K.undo(),i.preventDefault();break;case 89:d.K.redo(),i.preventDefault();break;case 67:d.gn(),i.preventDefault();break;case 86:d.xn(),i.preventDefault();break;case 219:d.K.synth.prevBar(),d.K.autoFollow&&new t.ChangeChannelBar(d.K,d.K.channel,Math.floor(d.K.synth.playhead)),i.preventDefault();break;case 221:d.K.synth.nextBar(),d.K.autoFollow&&new t.ChangeChannelBar(d.K,d.K.channel,Math.floor(d.K.synth.playhead)),i.preventDefault();break;case 189:case 173:d.yn(!1),i.preventDefault();break;case 187:case 61:d.yn(!0),i.preventDefault()}},this.Mn=function(){d.K.synth.prevBar()},this.kn=function(){d.K.synth.nextBar()},this.wn=function(){d.K.synth.playing?d.An():d.En()},this.Nn=function(){d.K.setVolume(Number(d.Ne.value))},this.Bn=function(){d.K.record(new t.ChangeSong(d.K,"")),d.be.resetCopiedPins()},this.Rn=function(){d.Ln("export")},this.Sn=function(){d.Ln("instrumentType")},this.In=function(){d.Ln("chorus")},this.Zn=function(){d.K.record(new t.ChangeScale(d.K,d.Ie.selectedIndex))},this.Cn=function(){d.K.record(new t.ChangeKey(d.K,d.Ze.selectedIndex))},this.Gn=function(){d.K.record(new t.ChangePartsPerBeat(d.K,t.Config.partCounts[d.Ue.selectedIndex]))},this.Un=function(){d.K.record(new t.ChangeInstrumentType(d.K,d.je.selectedIndex))},this.jn=function(){d.K.record(new t.ChangeFeedbackType(d.K,d.en.selectedIndex))},this.zn=function(){d.K.record(new t.ChangeFeedbackEnvelope(d.K,d.rn.selectedIndex))},this.Dn=function(){d.K.record(new t.ChangeAlgorithm(d.K,d.Ye.selectedIndex))},this.Yn=function(){var i=d.K.getCurrentPattern();null!=i&&d.K.record(new t.ChangePatternInstrument(d.K,d.Fe.selectedIndex,i))},this.Tn=function(){d.K.record(new t.ChangeWave(d.K,d.We.selectedIndex))},this.Fn=function(){d.K.record(new t.ChangeWave(d.K,d.Je.selectedIndex))},this.Vn=function(){d.K.record(new t.ChangeFilter(d.K,d.Xe.selectedIndex))},this.Pn=function(){d.K.record(new t.ChangeTransition(d.K,d.He.selectedIndex))},this.On=function(){d.K.record(new t.ChangeEffect(d.K,d.tn.selectedIndex))},this.Wn=function(){d.K.record(new t.ChangeChorus(d.K,d.Ke.selectedIndex))},this.Jn=function(t){switch(d.Be.value){case"undo":d.K.undo();break;case"redo":d.K.redo();break;case"copy":d.gn();break;case"paste":d.xn();break;case"transposeUp":d.yn(!0);break;case"transposeDown":d.yn(!1);break;case"import":d.Ln("import");break;case"duration":d.Ln("duration")}d.Be.selectedIndex=0},this.Qn=function(t){switch(d.Re.value){case"autoPlay":d.K.autoPlay=!d.K.autoPlay;break;case"autoFollow":d.K.autoFollow=!d.K.autoFollow;break;case"showLetters":d.K.showLetters=!d.K.showLetters;break;case"showFifth":d.K.showFifth=!d.K.showFifth;break;case"showChannels":d.K.showChannels=!d.K.showChannels;break;case"showScrollBar":d.K.showScrollBar=!d.K.showScrollBar}d.Re.selectedIndex=0,d.K.notifier.changed(),d.K.savePreferences()},this.K.notifier.watch(this.whenUpdated),this.sn.appendChild(s({className:"operatorRow",style:"color: #999; height: 1em; margin-top: 0.5em;"},[s({style:"margin-right: .1em; visibility: hidden;"},[o("1.")]),s({style:"width: 3em; margin-right: .3em;"},[o("Freq:")]),s({style:"width: 4em; margin: 0;"},[o("Volume:")]),s({style:"width: 5em; margin-left: .3em;"},[o("Envelope:")])]));for(var v=function(i){var e=i,h=s({style:"margin-right: .1em; color: #999;"},[o(i+1+".")]),a=l(n({style:"width: 100%;",title:"Frequency"}),t.Config.operatorFrequencyNames),u=new f(r({style:"margin: 0; width: 4em;",type:"range",min:"0",max:t.Config.operatorAmplitudeMax,value:"0",step:"1",title:"Volume"}),p.K,function(i,s){return new t.ChangeOperatorAmplitude(d.K,e,i,s)}),c=l(n({style:"width: 100%;",title:"Envelope"}),t.Config.operatorEnvelopeNames),v=s({className:"operatorRow"},[h,s({className:"selectContainer",style:"width: 3em; margin-right: .3em;"},[a]),u.input,s({className:"selectContainer",style:"width: 5em; margin-left: .3em;"},[c])]);p.sn.appendChild(v),p.fn[i]=v,p.cn[i]=u,p.dn[i]=c,p.vn[i]=a,c.addEventListener("change",function(){d.K.record(new t.ChangeOperatorEnvelope(d.K,e,c.selectedIndex))}),a.addEventListener("change",function(){d.K.record(new t.ChangeOperatorFrequency(d.K,e,a.selectedIndex))})},p=this,b=0;b<t.Config.operatorCount;b++)v(b);this.Be.addEventListener("change",this.Jn),this.Re.addEventListener("change",this.Qn),this.Ie.addEventListener("change",this.Zn),this.Ze.addEventListener("change",this.Cn),this.Ue.addEventListener("change",this.Gn),this.je.addEventListener("change",this.Un),this.Ye.addEventListener("change",this.Dn),this.Fe.addEventListener("change",this.Yn),this.en.addEventListener("change",this.jn),this.rn.addEventListener("change",this.zn),this.We.addEventListener("change",this.Tn),this.Je.addEventListener("change",this.Fn),this.He.addEventListener("change",this.Pn),this.Xe.addEventListener("change",this.Vn),this.Ke.addEventListener("change",this.Wn),this.tn.addEventListener("change",this.On),this.ke.addEventListener("click",this.wn),this.Ae.addEventListener("click",this.Mn),this.Ee.addEventListener("click",this.kn),this.Le.addEventListener("click",this.Bn),this.Se.addEventListener("click",this.Rn),this.Ne.addEventListener("input",this.Nn),this.ze.addEventListener("click",this.Sn),this.qe.addEventListener("click",this.In),this.Me.addEventListener("mousedown",this.pn),this.mainLayer.addEventListener("keydown",this.mn),a&&(this.Re.children[1].disabled=!0)}return c.prototype.Ln=function(t){this.K.openPrompt(t),this.bn(t)},c.prototype.bn=function(i){if(this.prompt&&(this.Hn&&this.En(),this.Hn=!1,this.ln.style.display="none",this.ln.removeChild(this.prompt.container),this.prompt.cleanUp(),this.prompt=null,this.mainLayer.focus()),i){switch(i){case"export":this.prompt=new t.ExportPrompt(this.K,this);break;case"import":this.prompt=new t.ImportPrompt(this.K,this);break;case"duration":this.prompt=new t.SongDurationPrompt(this.K,this);break;case"instrumentType":this.prompt=new t.InstrumentTypePrompt(this.K,this);break;case"chorus":this.prompt=new t.ChorusPrompt(this.K,this);break;default:throw new Error("Unrecognized prompt type.")}this.prompt&&(this.Hn=this.K.synth.playing,this.An(),this.ln.style.display=null,this.ln.appendChild(this.prompt.container))}},c.prototype.updatePlayButton=function(){this.K.synth.playing?(this.ke.classList.remove("playButton"),this.ke.classList.add("pauseButton"),this.ke.title="Pause (Space)",this.ke.innerText="Pause"):(this.ke.classList.remove("pauseButton"),this.ke.classList.add("playButton"),this.ke.title="Play (Space)",this.ke.innerText="Play")},c.prototype.En=function(){this.K.synth.play(),this.updatePlayButton()},c.prototype.An=function(){this.K.synth.pause(),this.K.autoFollow?this.K.synth.snapToBar(this.K.bar):this.K.synth.snapToBar(),this.updatePlayButton()},c.prototype.gn=function(){var t=this.K.getCurrentPattern();if(null!=t){var i={notes:t.notes,beatsPerBar:this.K.song.beatsPerBar,partsPerBeat:this.K.song.partsPerBeat,drums:this.K.song.getChannelIsDrum(this.K.channel)};window.localStorage.setItem("patternCopy",JSON.stringify(i))}},c.prototype.xn=function(){var i=this.K.getCurrentPattern();if(null!=i){var s=JSON.parse(String(window.localStorage.getItem("patternCopy")));null!=s&&s.drums==this.K.song.getChannelIsDrum(this.K.channel)&&this.K.record(new t.ChangePaste(this.K,i,s.notes,s.beatsPerBar,s.partsPerBeat))}},c.prototype.yn=function(i){var s=this.K.getCurrentPattern();if(null!=s){var e=this.K.lastChangeWas(this.un);this.un=new t.ChangeTranspose(this.K,s,i),this.K.record(this.un,e)}},c}();t.SongEditor=c;var d=new t.SongDocument(location.hash),v=new c(d);if(document.getElementById("beepboxEditorContainer").appendChild(v.mainLayer),v.whenUpdated(),v.mainLayer.focus(),!a&&d.autoPlay){function p(){document.hidden||(d.synth.play(),v.updatePlayButton(),window.removeEventListener("visibilitychange",p))}document.hidden?window.addEventListener("visibilitychange",p):p()}"scrollRestoration"in history&&(history.scrollRestoration="manual"),v.updatePlayButton()}(beepbox||(beepbox={}));
</script>
</body></html>
i remember one time i made an octopuss cat (not octocat) and when {when] i showed it to siblings they told me to change the name
/\_/\
( ./ . )
. `-' (-'¯)
`-'; ( ,
-' `¯