returnt(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),t(AudioNode.prototype._nativeConnect)&&(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,h,l,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(h=r.split("."),l=0;l<h.length-1;l++)a=a[h[l]];r=h[h.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,h,l,u,c,p;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,h=n,-1!==r.indexOf(".")){for(l=r.split("."),u=0;u<l.length-1;u++)c=l[u],h[c]=h[c]||{},h=h[c],a=a[c];r=l[l.length-1]}p=a[r],this.isObject(i[r])?h[r]=p.get():s.Signal&&pinstanceofs.Signal?h[r]=p.value:s.Param&&pinstanceofs.Param?h[r]=p.value:pinstanceofAudioParam?h[r]=p.value:pinstanceofs?h[r]=p.get():e(p)||t(p)||(h[r]=p)}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.isUndef(t)?this.output.disconnect():this.output.disconnect(t),this},s.protot
varn,o;if(i=this.toSeconds(i),this.triggerAttack(t,i,s),this.isArray(e)&&this.isArray(t))for(n=0;n<t.length;n++)o=e[Math.min(n,e.length-1)],this.triggerRelease(t[n],i+this.toSeconds(o));elsethis.triggerRelease(t,i+this.toSeconds(e));returnthis},t.PolySynth.prototype.triggerRelease=function(t,e){vari,s,n,o;for(Array.isArray(t)||(t=[t]),e=this.toSeconds(e),i=0;i<t.length;i++)for(s=JSON.stringify(t[i]),n=0;n<this._triggers.length;n++)o=this._triggers[n],o.note===s&&o.release>e&&(o.voice.triggerRelease(e),o.release=e);returnthis},t.PolySynth.prototype.set=function(t,e,i){for(vars=0;s<this.voices.length;s++)this.voices[s].set(t,e,i);returnthis},t.PolySynth.prototype.get=function(t){returnthis.voices[0].get(t)},t.PolySynth.prototype.releaseAll=function(t){vare,i;for(t=this.toSeconds(t),e=0;e<this._triggers.length;e++)i=this._triggers[e],i.release>t&&(i.release=t,i.voice.triggerRelease(t));returnthis},t.PolySynth.prototype.dispose=function(){t.Instrument.prototype.dispose.call(this);for(vare=0;e<this.voices.length;e++)this.voices[e].dispose(),this.voices[e]=null;returnthis._writable("detune"),this.detune.dispose(),this.detune=null,this.voices=null,this._triggers=null,this},t.PolySynth.MAX_POLYPHONY=20,t.PolySynth}),e(function(t){returnt.Player=function(e){vari;einstanceoft.Buffer?(e=e.get(),i=t.Player.defaults):i=this.optionsObject(arguments,["url","onload"],t.Player.defaults),t.Source.call(this,i),this._source=null,this.autostart=i.autostart,this._buffer=newt.Buffer({url:i.url,onload:this._onload.bind(this,i.onload),reverse:i.reverse}),einstanceofAudioBuffer&&this._buffer.set(e),this._loop=i.loop,this._loopStart=i.loopStart,this._loopEnd=i.loopEnd,this._playbackRate=i.playbackRate,this.retrigger=i.retrigger},t.extend(t.Player,t.Source),t.Player.defaults={onload:t.noOp,playbackRate:1,loop:!1,autostart:!1,loopStart:0,loopEnd:0,retrigger:!1,reverse:!1},t.Player.prototype.load=function(t,e){returnthis._buffer.load(t,this._onload.bind(this,e)),this},t.Player.prototype._onload=function(t){t(this),this.autostart&&this.start()},t.Player.prototype._start=function(e,i,s){if(!this._buffer.loaded)throwError("Tone.Player: tried to start Player before the buffer was loaded");returni=this._loop?this.defaultArg(i,this._loopStart):this.defaultArg(i,0),i=this.toSeconds(i),s=this.defaultArg(s,this._buffer.duration-i),e=this.toSeconds(e),s=this.toSeconds(s),this._source=this.context.createBufferSource(),this._source.buffer=this._buffer.get(),this._loop?(this._source.loop=this._loop,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)