Main(function(){functiont(t){returnvoid0===t}functione(t){return"function"==typeoft}vari,s,n,o;if(t(window.AudioContext)&&(window.AudioContext=window.webkitAudioContext),t(window.OfflineAudioContext)&&(window.OfflineAudioContext=window.webkitOfflineAudioContext),t(AudioContext))thrownewError("Web Audio is not supported in this browser");returni=newAudioContext,e(AudioContext.prototype.createGain)||(AudioContext.prototype.createGain=AudioContext.prototype.createGainNode),e(AudioContext.prototype.createDelay)||(AudioContext.prototype.createDelay=AudioContext.prototype.createDelayNode),e(AudioContext.prototype.createPeriodicWave)||(AudioContext.prototype.createPeriodicWave=AudioContext.prototype.createWaveTable),e(AudioBufferSourceNode.prototype.start)||(AudioBufferSourceNode.prototype.start=AudioBufferSourceNode.prototype.noteGrainOn),e(AudioBufferSourceNode.prototype.stop)||(AudioBufferSourceNode.prototype.stop=AudioBufferSourceNode.prototype.noteOff),e(OscillatorNode.prototype.start)||(OscillatorNode.prototype.start=OscillatorNode.prototype.noteOn),e(OscillatorNode.prototype.stop)||(OscillatorNode.prototype.stop=OscillatorNode.prototype.noteOff),e(OscillatorNode.prototype.setPeriodicWave)||(OscillatorNode.prototype.setPeriodicWave=OscillatorNode.prototype.setWaveTable),AudioNode.prototype._nativeConnect=AudioNode.prototype.connect,AudioNode.prototype.connect=function(e,i,s){if(e.input)Array.isArray(e.input)?(t(s)&&(s=0),this.connect(e.input[s])):this.connect(e.input,i,s);elsetry{einstanceofAudioNode?this._nativeConnect(e,i,s):this._nativeConnect(e,i)}catch(n){thrownewError("error connecting to node: "+e)}},s=function(e,i){t(e)||1===e?this.input=this.context.createGain():e>1&&(this.input=newArray(e)),t(i)||1===i?this.output=this.context.createGain():i>1&&(this.output=newArray(e))},s.prototype.set=function(e,i,n){varo,r,a,l,h,u;this.isObject(e)?n=i:this.isString(e)&&(o={},o[e]=i,e=o);for(rine){if(i=e[r],a=this,-1!==r.indexOf(".")){for(l=r.split("."),h=0;h<l.length-1;h++)a=a[l[h]];r=l[l.length-1]}u=a[r],t(u)||(s.Signal&&uinstanceofs.Signal||s.Param&&uinstanceofs.Param?u.value!==i&&(t(n)?u.value=i:u.rampTo(i,n)):uinstanceofAudioParam?u.value!==i&&(u.value=i):uinstanceofs?u.set(i):u!==i&&(a[r]=i))}returnthis},s.prototype.get=function(i){varn,o,r,a,l,h,u,p,c;for(t(i)?i=this._collectDefaults(this.constructor):this.isString(i)&&(i=[i]),n={},o=0;o<i.length;o++){if(r=i[o],a=this,l=n,-1!==r.indexOf(".")){for(h=r.split("."),u=0;u<h.length-1;u++)p=h[u],l[p]=l[p]||{},l=l[p],a=a[p];r=h[h.length-1]}c=a[r],this.isObject(i[r])?l[r]=c.get():s.Signal&&cinstanceofs.Signal?l[r]=c.value:s.Param&&cinstanceofs.Param?l[r]=c.value:cinstanceofAudioParam?l[r]=c.value:cinstanceofs?l[r]=c.get():e(c)||t(c)||(l[r]=c)}returnn},s.prototype._collectDefaults=function(e){vari,s,n=[];if(t(e.defaults)||(n=Object.keys(e.defaults)),!t(e._super))for(i=this._collectDefaults(e._super),s=0;s<i.length;s++)-1===n.indexOf(i[s])&&n.push(i[s]);returnn},s.prototype.toString=function(){vart,i,n;for(tins)if(i=t[0].match(/^[A-Z]$/),n=s[t]===this.constructor,e(s[t])&&i&&n)returnt;return"Tone"},s.context=i,s.prototype.context=s.context,s.prototype.bufferSize=2048,s.prototype.blockTime=128/s.context.sampleRate,s.prototype.sampleTime=1/s.context.sampleRate,s.prototype.dispose=function(){returnthis.isUndef(this.input)||(this.inputinstanceofAudioNode&&this.input.disconnect(),this.input=null),this.isUndef(this.output)||(this.outputinstanceofAudioNode&&this.output.disconnect(),this.output=null),this},n=null,s.prototype.noGC=function(){returnthis.output.connect(n),this},AudioNode.prototype.noGC=function(){returnthis.connect(n),this},s.prototype.connect=function(t,e,i){returnArray.isArray(this.output)?(e=this.defaultArg(e,0),this.output[e].connect(t,0,i)):this.output.connect(t,e,i),this},s.prototype.disconnect=function(t){returnArray.isArray(this.output)?(t=this.defaultArg(t,0),this.output[t].disconnect()):this.output.disconnect(),this},s.prototype.connectSeries=function(){vart,e,i;if(arguments.length>1)for(t=arguments[0],e=1;e<a
e.prototype.searchAfter=function(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)},e.prototype.traverse=function(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)},e.prototype.updateHeight=function(){this.height=null!==this.left&&null!==this.right?Math.max(this.left.height,this.right.height)+1:null!==this.right?this.right.height+1:null!==this.left?this.left.height+1:0},e.prototype.updateMax=function(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))},e.prototype.getBalance=function(){vart=0;returnnull!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t},e.prototype.isLeftChild=function(){returnnull!==this.parent&&this.parent.left===this},Object.defineProperty(e.prototype,"left",{get:function(){returnthis._left},set:function(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}}),Object.defineProperty(e.prototype,"right",{get:function(){returnthis._right},set:function(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}}),e.prototype.dispose=function(){this.parent=null,this._left=null,this._right=null,this.event=null},t.IntervalTimeline}),Module(function(t){t.Transport=function(){t.Emitter.call(this),this.loop=!1,this._loopStart=0,this._loopEnd=0,this._ppq=e.defaults.PPQ,this._clock=newt.Clock({callback:this._processTick.bind(this),frequency:0}),this.bpm=this._clock.frequency,this.bpm._toUnits=this._toUnits.bind(this),this.bpm._fromUnits=this._fromUnits.bind(this),this.bpm.units=t.Type.BPM,this.bpm.value=e.defaults.bpm,this._readOnly("bpm"),this._timeSignature=e.defaults.timeSignature,this._scheduledEvents={},this._eventID=0,this._timeline=newt.Timeline,this._repeatedEvents=newt.IntervalTimeline,this._onceEvents=newt.Timeline,this._syncedSignals=[];vari=this.notationToSeconds(e.defaults.swingSubdivision,e.defaults.bpm,e.defaults.timeSignature);this._swingTicks=i/(60/e.defaults.bpm)*this._ppq,this._swingAmount=0},t.extend(t.Transport,t.Emitter),t.Transport.defaults={bpm:120,swing:0,swingSubdivision:"16n",timeSignature:4,loopStart:0,loopEnd:"4m",PPQ:48},t.Transport.prototype._processTick=function(t){this._swingAmount>0&&this._clock.ticks%this._ppq!==0&&this._clock.ticks%this._swingTicks===0&&(t+=this.ticksToSeconds(this._swingTicks)*this._swingAmount),this.loop&&this._clock.ticks===this._loopEnd&&(this.ticks=this._loopStart,this.trigger("loop",t));vare=this._clock.ticks;this._onceEvents.forEachBefore(e,function(e){e.callback(t)}),this._onceEvents.cancelBefore(e),this._timeline.forEachAtTime(e,function(e){e.callback(t)}),this._repeatedEvents.forEachOverlap(e,function(i){(e-i.time)%i.interval===0&&i.callback(t)})},t.Transport.prototype.schedule=function(t,e){vari={time:this.toTicks(e),callback:t},s=this._eventID++;returnthis._scheduledEvents[s.toString()]={event:i,timeline:this._timeline},this._timeline.addEvent(i),s},t.Transport.prototype.scheduleRepeat=function(t,e,i,s){varn,o;if(0>=e)thrownewError("repeat events must have an interval larger than 0");returnn={time:this.toTicks(i),duration:this.toTicks(this.defaultArg(s,1/0)),interval:this.toTicks(e),callback:t},o=this._eventID++,this._scheduledEvents[o.toString()]={event:n,timeline:this._repeatedEvents},this._repeatedEvents.addEvent(n),o},t.Transport.prototype.scheduleOnce=function(t,e){vari={time:this.toTicks(e),callback:t},s=this._eventID++;returnthis._scheduledEvents[s.toString()]={event:i,timeline:this._onceEvents},this._onceEvents.addEvent(i),s},t.Transport.prototype.clear=function(t){if(this._scheduledEvents.hasOwnProperty(t)){vare=this._scheduledEvents[t.toString()];e.timeline.removeEvent(e.event),deletethis._scheduledEvents[t.toString()]}returnthis},t.Transport.prototype.cancel=function(t){returnt=this.defaultArg(t,0),t=this.toTicks(t),this._timeline.cancel(t),this._onceEvents.c
this._source.loopStart=this.toSeconds(this._loopStart),this._source.loopEnd=this.toSeconds(this._loopEnd)):this._state.setStateAtTime(t.State.Stopped,e+s),this._source.playbackRate.value=this._playbackRate,this._source.connect(this.output),this._loop?this._source.start(e,i):this._source.start(e,i,s),this},t.Player.prototype._stop=function(t){returnthis._source&&(this._source.stop(this.toSeconds(t)),this._source=null),this},t.Player.prototype.setLoopPoints=function(t,e){returnthis.loopStart=t,this.loopEnd=e,this},Object.defineProperty(t.Player.prototype,"loopStart",{get:function(){returnthis._loopStart},set:function(t){this._loopStart=t,this._source&&(this._source.loopStart=this.toSeconds(t))}}),Object.defineProperty(t.Player.prototype,"loopEnd",{get:function(){returnthis._loopEnd},set:function(t){this._loopEnd=t,this._source&&(this._source.loopEnd=this.toSeconds(t))}}),Object.defineProperty(t.Player.prototype,"buffer",{get:function(){returnthis._buffer},set:function(t){this._buffer.set(t)}}),Object.defineProperty(t.Player.prototype,"loop",{get:function(){returnthis._loop},set:function(t){this._loop=t,this._source&&(this._source.loop=t)}}),Object.defineProperty(t.Player.prototype,"playbackRate",{get:function(){returnthis._playbackRate},set:function(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}}),Object.defineProperty(t.Player.prototype,"reverse",{get:function(){returnthis._buffer.reverse},set:function(t){this._buffer.reverse=t}}),t.Player.prototype.dispose=function(){returnt.Source.prototype.dispose.call(this),null!==this._source&&(this._source.disconnect(),this._source=null),this._buffer.dispose(),this._buffer=null,this},t.Player}),Module(function(t){returnt.Sampler=function(e,i){i=this.defaultArg(i,t.Sampler.defaults),t.Instrument.call(this,i),this.player=newt.Player(i.player),this.player.retrigger=!0,this._buffers={},this.envelope=newt.AmplitudeEnvelope(i.envelope),this.filterEnvelope=newt.FrequencyEnvelope(i.filterEnvelope),this._sample=i.sample,this._pitch=i.pitch,this.filter=newt.Filter(i.filter),this._loadBuffers(e),this.pitch=i.pitch,this.player.chain(this.filter,this.envelope,this.output),this.filterEnvelope.connect(this.filter.frequency),this._readOnly(["player","filterEnvelope","envelope","filter"])},t.extend(t.Sampler,t.Instrument),t.Sampler.defaults={sample:0,pitch:0,player:{loop:!1},envelope:{attack:.001,decay:0,sustain:1,release:.1},filterEnvelope:{attack:.001,decay:.001,sustain:1,release:.5,baseFrequency:20,octaves:10},filter:{type:"lowpass"}},t.Sampler.prototype._loadBuffers=function(e){vari,s;if(this.isString(e))this._buffers[0]=newt.Buffer(e,function(){this.sample="0"}.bind(this));else{e=this._flattenUrls(e);for(iine)this._sample=i,s=e[i],this._buffers[i]=newt.Buffer(s)}},t.Sampler.prototype._flattenUrls=function(t){vare,i,s,n={};for(eint)if(t.hasOwnProperty(e))if(this.isObject(t[e])){i=this._flattenUrls(t[e]);for(sini)i.hasOwnProperty(s)&&(n[e+"."+s]=i[s])}elsen[e]=t[e];returnn},t.Sampler.prototype.triggerAttack=function(t,e,i){returne=this.toSeconds(e),t&&(this.sample=t),this.player.start(e),this.envelope.triggerAttack(e,i),this.filterEnvelope.triggerAttack(e),this},t.Sampler.prototype.triggerRelease=function(t){returnt=this.toSeconds(t),this.filterEnvelope.triggerRelease(t),this.envelope.triggerRelease(t),this.player.stop(this.toSeconds(this.envelope.release)+t),this},Object.defineProperty(t.Sampler.prototype,"sample",{get:function(){returnthis._sample},set:function(t){if(!this._buffers.hasOwnProperty(t))thrownewError("Sampler does not have a sample named "+t);this._sample=t,this.player.buffer=this._buffers[t]}}),Object.defineProperty(t.Sampler.prototype,"reverse",{get:function(){for(vartinthis._buffers)returnthis._buffers[t].reverse},set:function(t){for(vareinthis._buffers)this._buffers[e].reverse=t}}),Object.defineProperty(t.Sampler.prototype,"pitch",{get:function(){returnthis._pitch},set:function(t){this._pitch=t,this.player.playbackRate=this.intervalToFrequencyRatio(t)}}),t.Sampler.prototype.dispose=function(){t.Instrument.proto