diff --git a/build/Tone.Preset.js b/build/Tone.Preset.js index e63a55b5..946263ac 100644 --- a/build/Tone.Preset.js +++ b/build/Tone.Preset.js @@ -7,22 +7,120 @@ define(["Tone/core/Tone", "Tone/effect/AutoWah"], function(Tone){ * @type {Object} */ Tone.AutoWah.prototype.preset = { + "talker" : { + "baseFrequency" : 100, + "octaves" : 4, + "sensitivity" : 0, + "Q" : 2, + "gain" : 10, + "rolloff" : -12, + /** attributes for the envelope follower */ + "follower" : { + "attack" : 0.05, + "release" : 0.2 + } + }, + "yes" : { + "baseFrequency" : 250, + "octaves" : 5, + "sensitivity" : 0, + "Q" : 2, + "gain" : 20, + "rolloff" : -24, + /** attributes for the envelope follower */ + "follower" : { + "attack" : 0.1, + "release" : 0.2 + } + }, "springy" : { "baseFrequency" : 10, "octaves" : 8, "sensitivity" : 0, - "Q" : 20, + "Q" : 1, "gain" : 10, + "rolloff" : -48, /** attributes for the envelope follower */ "follower" : { - "attack" : 1, - "release" : 2 + "attack" : 0.02, + "release" : 1 } } }; return Tone.AutoWah.prototype.preset; }); +define(["Tone/core/Tone", "Tone/effect/AutoWah"], function(Tone){ + + /** + * named presets for the AutoWah + * @const + * @static + * @type {Object} + */ + Tone.Chorus.prototype.preset = { + "ether" : { + "rate" : 0.3, + "delayTime" : 8, + "type" : "triangle", + "depth" : 0.8, + "feedback" : 0.7 + }, + "harmony" : { + "rate" : 12, + "delayTime" : 3.5, + "type" : "sine", + "depth" : 0.8, + "feedback" : 0.2 + }, + "rattler" : { + "rate" : "16n", + "delayTime" : 15, + "type" : "square", + "depth" : 0.2, + "feedback" : 0.8 + } + }; + + return Tone.Chorus.prototype.preset; +}); +define(["Tone/core/Tone", "Tone/effect/AutoWah"], function(Tone){ + + /** + * named presets for the Phaser + * @const + * @static + * @type {Object} + */ + Tone.Phaser.prototype.preset = { + "testing" : { + "rate" : 10, + "depth" : 0.2, + "stages" : 4, + "Q" : 2, + "baseFrequency" : 700, + "feedback" : 0 + }, + "landing" : { + "rate" : 0.5, + "depth" : 1.2, + "stages" : 12, + "Q" : 20, + "baseFrequency" : 800, + "feedback" : 0.9 + }, + "bubbles" : { + "rate" : 4.5, + "depth" : 0.4, + "stages" : 6, + "Q" : 2, + "baseFrequency" : 300, + "feedback" : 0.6 + } + }; + + return Tone.Phaser.prototype.preset; +}); define(["Tone/core/Tone", "Tone/instrument/DuoSynth"], function(Tone){ /** diff --git a/build/Tone.js b/build/Tone.js index 77ccb7e7..ae95fa6b 100644 --- a/build/Tone.js +++ b/build/Tone.js @@ -5715,7 +5715,7 @@ define('Tone/effect/AutoWah',["Tone/core/Tone", "Tone/component/Follower", "Tone * @private */ this._bandpass = new Tone.Filter("bandpass"); - this._bandpass.setRolloff(-48); + this._bandpass.setRolloff(options.rolloff); // this._bandpass.type = "bandpass"; // this._bandpass.Q.value = options.Q; @@ -5750,6 +5750,7 @@ define('Tone/effect/AutoWah',["Tone/core/Tone", "Tone/component/Follower", "Tone "sensitivity" : 0, "Q" : 2, "gain" : 2, + "rolloff" : -48, /** attributes for the envelope follower */ "follower" : { "attack" : 0.3, @@ -6312,6 +6313,7 @@ function(Tone){ //set the initial values this.setDepth(this._depth); this.setRate(options.rate); + this.setType(options.type); }; Tone.extend(Tone.Chorus, Tone.StereoXFeedbackEffect); @@ -6324,7 +6326,8 @@ function(Tone){ "rate" : 1.5, "delayTime" : 3.5, "depth" : 0.7, - "feedback" : 0.4 + "feedback" : 0.4, + "type" : "sine" }; /** @@ -6357,6 +6360,15 @@ function(Tone){ this._lfoL.setFrequency(rate); }; + /** + * set the LFO type + * @param {number} type + */ + Tone.Chorus.prototype.setType = function(type){ + this._lfoL.setType(type); + this._lfoR.setType(type); + }; + /** * set multiple parameters at once with an object * @param {Object} params the parameters as an object @@ -6365,6 +6377,7 @@ function(Tone){ if (!this.isUndef(params.rate)) this.setRate(params.rate); if (!this.isUndef(params.delayTime)) this.setDelayTime(params.delayTime); if (!this.isUndef(params.depth)) this.setDepth(params.depth); + if (!this.isUndef(params.type)) this.setType(params.type); Tone.FeedbackEffect.prototype.set.call(this, params); }; @@ -6596,7 +6609,7 @@ function(Tone){ * @type {Array.} * @private */ - this._filtersR = this._makeFilters(options.stages, this._lfoR); + this._filtersR = this._makeFilters(options.stages, this._lfoR, options.Q); //connect them up this.effectSendL.connect(this._filtersL[0]); @@ -6627,6 +6640,7 @@ function(Tone){ "rate" : 0.5, "depth" : 1, "stages" : 4, + "Q" : 6, "baseFrequency" : 400, "feedback" : 0.6 }; @@ -6636,13 +6650,13 @@ function(Tone){ * @returns {Array} the number of filters all connected together * @private */ - Tone.Phaser.prototype._makeFilters = function(stages, connectToFreq){ + Tone.Phaser.prototype._makeFilters = function(stages, connectToFreq, Q){ var filters = new Array(stages); //make all the filters for (var i = 0; i < stages; i++){ var filter = this.context.createBiquadFilter(); filter.type = "allpass"; - filter.Q.value = 6; + filter.Q.value = Q; connectToFreq.connect(filter.frequency); filters[i] = filter; } diff --git a/build/Tone.min.js b/build/Tone.min.js index 4be02d5d..30fc526c 100644 --- a/build/Tone.min.js +++ b/build/Tone.min.js @@ -7,5 +7,5 @@ */ !function(t){"function"!=typeof define&&"function"!=typeof t.Tone&&(t.define=function(){var e=arguments[arguments.length-1],i=arguments[0];"Tone/core/Tone"===i?t.Tone=e():"function"==typeof e&&e(t.Tone)})}(this),define("Tone/core/Tone",[],function(){function t(t){return void 0===t}var e;if(t(window.AudioContext)&&(window.AudioContext=window.webkitAudioContext),t(window.OfflineAudioContext)&&(window.OfflineAudioContext=window.webkitOfflineAudioContext),t(AudioContext))throw new Error("Web Audio is not supported in this browser");e=new AudioContext,"function"!=typeof AudioContext.prototype.createGain&&(AudioContext.prototype.createGain=AudioContext.prototype.createGainNode),"function"!=typeof AudioContext.prototype.createDelay&&(AudioContext.prototype.createDelay=AudioContext.prototype.createDelayNode),"function"!=typeof AudioContext.prototype.createPeriodicWave&&(AudioContext.prototype.createPeriodicWave=AudioContext.prototype.createWaveTable),"function"!=typeof AudioBufferSourceNode.prototype.start&&(AudioBufferSourceNode.prototype.start=AudioBufferSourceNode.prototype.noteGrainOn),"function"!=typeof AudioBufferSourceNode.prototype.stop&&(AudioBufferSourceNode.prototype.stop=AudioBufferSourceNode.prototype.noteOff),"function"!=typeof OscillatorNode.prototype.start&&(OscillatorNode.prototype.start=OscillatorNode.prototype.noteOn),"function"!=typeof OscillatorNode.prototype.stop&&(OscillatorNode.prototype.stop=OscillatorNode.prototype.noteOff),"function"!=typeof OscillatorNode.prototype.setPeriodicWave&&(OscillatorNode.prototype.setPeriodicWave=OscillatorNode.prototype.setWaveTable),AudioNode.prototype._nativeConnect=AudioNode.prototype.connect,AudioNode.prototype.connect=function(e,i,n){if(e.input)Array.isArray(e.input)?(t(n)&&(n=0),this.connect(e.input[n])):this.connect(e.input);else try{e instanceof AudioNode?this._nativeConnect(e,i,n):this._nativeConnect(e,i)}catch(o){throw new Error("error connecting to node: "+e)}};var i=function(){this.input=this.context.createGain(),this.output=this.context.createGain()};i.context=e,i.prototype.context=i.context,i.prototype.bufferSize=2048,i.prototype.connect=function(t,e,i){Array.isArray(this.output)?(e=this.defaultArg(e,0),this.output[e].connect(t,0,i)):this.output.connect(t,e,i)},i.prototype.disconnect=function(){this.output.disconnect()},i.prototype.chain=function(){if(arguments.length>1)for(var t=arguments[0],e=1;e1)for(var e=1;ei){var n=i;i=e,e=n}else if(e==i)return 0;return(t-e)/(i-e)},i.prototype.dispose=function(){this.isUndef(this.input)||(this.input instanceof AudioNode&&this.input.disconnect(),this.input=null),this.isUndef(this.output)||(this.output instanceof AudioNode&&this.output.disconnect(),this.output=null)};var n=null;i.prototype.noGC=function(){this.output.connect(n)},AudioNode.prototype.noGC=function(){this.connect(n)},i.prototype.now=function(){return this.context.currentTime},i.prototype.samplesToSeconds=function(t){return t/this.context.sampleRate},i.prototype.toSamples=function(t){var e=this.toSeconds(t);return Math.round(e*this.context.sampleRate)},i.prototype.toSeconds=function(t,e){if(e=this.defaultArg(e,this.now()),"number"==typeof t)return t;if("string"==typeof t){var i=0;return"+"===t.charAt(0)&&(t=t.slice(1),i=e),parseFloat(t)+i}return e},i.prototype.frequencyToSeconds=function(t){return 1/parseFloat(t)},i.prototype.secondsToFrequency=function(t){return 1/t};var o={c:0,"c#":1,db:1,d:2,"d#":3,eb:3,e:4,f:5,"f#":6,gb:6,g:7,"g#":8,ab:8,a:9,"a#":10,bb:10,b:11},s=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],r=261.6255653005986;i.prototype.noteToFrequency=function(t){var e=t.split(/(\d+)/);if(3===e.length){var i=o[e[0].toLowerCase()],n=e[1],s=i+12*parseInt(n,10);return Math.pow(2,(s-48)/12)*r}return 0},i.prototype.frequencyToNote=function(t){var e=Math.log(t/r)/Math.LN2,i=Math.round(12*e)+48,n=Math.floor(i/12),o=s[i%12];return o+n.toString()};var a=[];return i._initAudioContext=function(t){t(i.context),a.push(t)},i.setContext=function(t){i.prototype.context=t,i.context=t;for(var e=0;es;s++)o[s]=1;i.curve=o,e.connect(i),e.start(0),e.noGC()}),t.Signal}),define("Tone/signal/Add",["Tone/core/Tone","Tone/signal/Signal"],function(t){return t.Add=function(e){this._value=new t.Signal(e),this.input=this.output=this.context.createGain(),this._value.connect(this.output)},t.extend(t.Add),t.Add.prototype.setValue=function(t){this._value.setValue(t)},t.Add.prototype.connect=t.Signal.prototype.connect,t.Add.prototype.dispose=function(){this._value.dispose(),this.output.disconnect(),this._value=null,this.output=null},t.Add}),define("Tone/signal/Multiply",["Tone/core/Tone","Tone/signal/Signal"],function(t){return t.Multiply=function(t){this.input=this.output=this.context.createGain(),this.input.gain.value=this.defaultArg(t,1)},t.extend(t.Multiply),t.Multiply.prototype.setValue=function(t){this.input.gain.value=t},t.Multiply.prototype.connect=t.Signal.prototype.connect,t.Multiply.prototype.dispose=function(){this.input.disconnect(),this.input=null},t.Multiply}),define("Tone/signal/Scale",["Tone/core/Tone","Tone/signal/Add","Tone/signal/Multiply","Tone/signal/Signal"],function(t){return t.Scale=function(e,i,n,o){t.call(this),2==arguments.length&&(n=e,o=i,e=-1,i=1),this._inputMin=e,this._inputMax=i,this._outputMin=n,this._outputMax=o,this._plusInput=new t.Add(0),this._scale=new t.Multiply(1),this._plusOutput=new t.Add(0),this.chain(this.input,this._plusInput,this._scale,this._plusOutput,this.output),this._setScalingParameters()},t.extend(t.Scale),t.Scale.prototype._setScalingParameters=function(){this._plusInput.setValue(-this._inputMin),this._scale.setValue((this._outputMax-this._outputMin)/(this._inputMax-this._inputMin)),this._plusOutput.setValue(this._outputMin)},t.Scale.prototype.setInputMin=function(t){this._inputMin=t,this._setScalingParameters()},t.Scale.prototype.setInputMax=function(t){this._inputMax=t,this._setScalingParameters()},t.Scale.prototype.setOutputMin=function(t){this._outputMin=t,this._setScalingParameters()},t.Scale.prototype.setOutputMax=function(t){this._outputMax=t,this._setScalingParameters()},t.Scale.prototype.connect=t.Signal.prototype.connect,t.Scale.prototype.dispose=function(){this.input.disconnect(),this.output.disconnect(),this._plusInput.dispose(),this._plusOutput.dispose(),this._scale.dispose(),this.input=null,this.output=null,this._plusInput=null,this._plusOutput=null,this._scale=null},t.Scale}),define("Tone/component/DryWet",["Tone/core/Tone","Tone/signal/Signal","Tone/signal/Scale"],function(t){return t.DryWet=function(e){t.call(this),this.dry=this.input,this.wet=this.context.createGain(),this.wetness=new t.Signal,this._invert=new t.Scale(0,1,1,0),this.dry.connect(this.output),this.wet.connect(this.output),this.chain(this.wetness,this.wet.gain),this.chain(this.wetness,this._invert,this.dry.gain),this.setDry(this.defaultArg(e,0))},t.extend(t.DryWet),t.DryWet.prototype.setDry=function(t,e){this.setWet(1-t,e)},t.DryWet.prototype.setWet=function(t,e){e?this.wetness.linearRampToValueNow(t,e):this.wetness.setValue(t)},t.DryWet.prototype.dispose=function(){t.prototype.dispose.call(this),this.dry.disconnect(),this.wet.disconnect(),this.wetness.dispose(),this._invert.dispose(),this.dry=null,this.wet=null,this.wetness=null,this._invert=null},t.DryWet}),define("Tone/component/Filter",["Tone/core/Tone","Tone/signal/Signal"],function(t){return t.Filter=function(){t.call(this);var e=this.optionsObject(arguments,["frequency","type","rolloff"],t.Filter.defaults);this._filters=[],this.frequency=new t.Signal(e.frequency),this.gain=new t.Signal(e.gain),this.Q=new t.Signal(e.Q),this._type=e.type,this.setRolloff(e.rolloff)},t.extend(t.Filter),t.Filter.defaults={type:"lowpass",frequency:350,rolloff:-12,Q:1,gain:0},t.Filter.prototype.set=function(t){this.isUndef(t.type)||this.setType(t.type),this.isUndef(t.frequency)||this.frequency.setValue(t.frequency),this.isUndef(t.Q)||this.Q.setValue(t.Q),this.isUndef(t.gain)||this.gain.setValue(t.gain),this.isUndef(t.rolloff)||this.setRolloff(t.rolloff)},t.Filter.prototype.setType=function(t){this._type=t;for(var e=0;en;n++){var o=this.context.createBiquadFilter();o.type=this._type,this.frequency.connect(o.frequency),this.Q.connect(o.Q),this.gain.connect(o.gain),this._filters[n]=o}var s=[this.input].concat(this._filters).concat([this.output]);this.chain.apply(this,s)},t.Filter.prototype.dispose=function(){for(var t=0;to;o++){var s,r=o/(i-1)*2-1;s=e>r?0:1,n[o]=s}t.curve=n},t.Threshold.prototype.setThreshold=function(t){this._setThresh(this._thresh,t)},t.Threshold.prototype.connect=t.Signal.prototype.connect,t.Threshold.prototype.dispose=function(){this._thresh.disconnect(),this._doubleThresh.disconnect(),this._thresh=null,this._doubleThresh=null},t.Threshold}),define("Tone/signal/EqualZero",["Tone/core/Tone","Tone/signal/Threshold","Tone/signal/Signal"],function(t){return t.EqualZero=function(){this._equals=this.context.createWaveShaper(),this._thresh=new t.Threshold(1),this.input=this._equals,this._equals.connect(this._thresh),this.output=this._thresh,this._setEquals()},t.extend(t.EqualZero),t.EqualZero.prototype._setEquals=function(){for(var t=1023,e=new Float32Array(t),i=0;t>i;i++){var n=i/(t-1)*2-1;e[i]=0===n?1:0}this._equals.curve=e},t.EqualZero.prototype.connect=t.Signal.prototype.connect,t.EqualZero.prototype.dispose=function(){this._equals.disconnect(),this._thresh.dispose(),this._equals=null,this._thresh=null},t.EqualZero}),define("Tone/signal/Equal",["Tone/core/Tone","Tone/signal/EqualZero","Tone/signal/Add","Tone/signal/Signal"],function(t){return t.Equal=function(e){this._adder=new t.Add(-e),this._equals=new t.EqualZero,this.input=this._adder,this.output=this._equals,this._adder.connect(this._equals)},t.extend(t.Equal),t.Equal.prototype.setValue=function(t){this._adder.setValue(-t)},t.Equal.prototype.connect=t.Signal.prototype.connect,t.Equal.prototype.dispose=function(){this._equals.disconnect(),this._adder.dispose(),this._equals=null,this._adder=null},t.Equal}),define("Tone/signal/Selector",["Tone/core/Tone","Tone/signal/Equal","Tone/signal/Signal"],function(t){t.Selector=function(i){i=this.defaultArg(i,2),this.input=new Array(i),this.output=this.context.createGain(),this.gate=new t.Signal(0);for(var n=0;i>n;n++){var o=new e(n);this.input[n]=o,this.gate.connect(o.selecter),o.connect(this.output)}},t.extend(t.Selector),t.Selector.prototype.select=function(t,e){t=Math.floor(t),this.gate.setValueAtTime(t,this.toSeconds(e))},t.Selector.prototype.connect=t.Signal.prototype.connect,t.Selector.prototype.dispose=function(){this.output.disconnect(),this.gate.dispose();for(var t=0;ti;i++){var n=i/(t-1)*2-1;e[i]=0>n?1:0}this._lt.curve=e},t.LessThan.prototype.setValue=function(t){this._adder.setValue(-t)},t.LessThan.prototype.connect=t.Signal.prototype.connect,t.LessThan.prototype.dispose=function(){this._lt.disconnect(),this._adder.disconnect(),this._thresh.dispose(),this._lt=null,this._adder=null,this._thresh=null},t.LessThan}),define("Tone/signal/Abs",["Tone/core/Tone","Tone/signal/Selector","Tone/signal/Negate","Tone/signal/LessThan","Tone/signal/Signal"],function(t){return t.Abs=function(){t.call(this),this._ltz=new t.LessThan(0),this._switch=new t.Selector(2),this._negate=new t.Negate,this.input.connect(this._switch,0,0),this.input.connect(this._negate),this._negate.connect(this._switch,0,1),this._switch.connect(this.output),this.chain(this.input,this._ltz,this._switch.gate)},t.extend(t.Abs),t.Abs.prototype.connect=t.Signal.prototype.connect,t.Abs.prototype.dispose=function(){this._switch.dispose(),this._ltz.dispose(),this._negate.dispose(),this.input.disconnect(),this.output.disconnect(),this._switch=null,this._ltz=null,this._negate=null,this.input=null,this.output=null},t.Abs}),define("Tone/component/Follower",["Tone/core/Tone","Tone/signal/Abs","Tone/signal/Negate","Tone/signal/Multiply","Tone/signal/Signal"],function(t){return t.Follower=function(){t.call(this);var e=this.optionsObject(arguments,["attack","release"],t.Follower.defaults);this._abs=new t.Abs,this._filter=this.context.createBiquadFilter(),this._filter.type="lowpass",this._filter.frequency.value=0,this._filter.Q.value=-100,this._frequencyValues=this.context.createWaveShaper(),this._negate=new t.Negate,this._difference=this.context.createGain(),this._delay=this.context.createDelay(),this._delay.delayTime.value=.02,this._mult=new t.Multiply(1e3),this._attack=this.secondsToFrequency(e.attack),this._release=this.secondsToFrequency(e.release),this.chain(this.input,this._abs,this._filter,this.output),this.chain(this._abs,this._negate,this._difference),this.chain(this._filter,this._delay,this._difference),this.chain(this._difference,this._mult,this._frequencyValues,this._filter.frequency),this._setAttackRelease(this._attack,this._release)},t.extend(t.Follower),t.Follower.defaults={attack:.05,release:.5},t.Follower.prototype._setAttackRelease=function(t,e){for(var i=1024,n=new Float32Array(i),o=0;i>o;o++){var s,r=o/(i-1)*2-1;s=0>=r?t:e,n[o]=s}this._frequencyValues.curve=n},t.Follower.prototype.setAttack=function(t){this._attack=this.secondsToFrequency(t),this._setAttackRelease(this._attack,this._release)},t.Follower.prototype.setRelease=function(t){this._release=this.secondsToFrequency(t),this._setAttackRelease(this._attack,this._release)},t.Follower.prototype.set=function(e){this.isUndef(e.attack)||this.setAttack(e.attack),this.isUndef(e.release)||this.setRelease(e.release),t.Effect.prototype.set.call(this,e)},t.Follower.prototype.connect=t.Signal.prototype.connect,t.Follower.prototype.dispose=function(){t.prototype.dispose.call(this),this._filter.disconnect(),this._frequencyValues.disconnect(),this._delay.disconnect(),this._difference.disconnect(),this._abs.dispose(),this._negate.dispose(),this._mult.dispose(),this._filter=null,this._delay=null,this._frequencyValues=null,this._abs=null,this._negate=null,this._difference=null,this._mult=null},t.Follower}),define("Tone/signal/GreaterThan",["Tone/core/Tone","Tone/signal/Threshold","Tone/signal/Add","Tone/signal/Signal"],function(t){return t.GreaterThan=function(e){this._gt=this.context.createWaveShaper(),this._thresh=new t.Threshold(.001),this._adder=new t.Add(this.defaultArg(-e,0)),this.input=this._adder,this.output=this._thresh,this.chain(this._adder,this._gt,this._thresh),this._setGreaterThanZero()},t.extend(t.GreaterThan),t.GreaterThan.prototype._setGreaterThanZero=function(){for(var t=1023,e=new Float32Array(t),i=0;t>i;i++){var n=i/(t-1)*2-1;e[i]=n>0?1:0}this._gt.curve=e},t.GreaterThan.prototype.setValue=function(t){this._adder.setValue(-t)},t.GreaterThan.prototype.connect=t.Signal.prototype.connect,t.GreaterThan.prototype.dispose=function(){this._gt.disconnect(),this._adder.disconnect(),this._thresh.dispose(),this._gt=null,this._adder=null,this._thresh=null},t.GreaterThan}),define("Tone/component/Gate",["Tone/core/Tone","Tone/component/Follower","Tone/signal/GreaterThan"],function(t){return t.Gate=function(e,i){t.call(this),e=this.defaultArg(e,-40),i=this.defaultArg(i,.1),this._follower=new t.Follower(i),this._gt=new t.GreaterThan(this.dbToGain(e)),this.chain(this.input,this.output),this.chain(this.input,this._follower,this._gt,this.output.gain)},t.extend(t.Gate),t.Gate.prototype.setThreshold=function(t){this._gt.setValue(this.dbToGain(t))},t.Gate.prototype.setSmoothTime=function(t){this._follower.setSmoothTime(t)},t.Gate.prototype.dispose=function(){t.prototype.dispose.call(this),this._follower.dispose(),this._gt.dispose(),this._follower=null,this._gt=null},t.Gate}),define("Tone/core/Clock",["Tone/core/Tone","Tone/signal/Signal"],function(t){return t.Clock=function(e,i){this._oscillator=null,this._jsNode=this.context.createScriptProcessor(this.bufferSize,1,1),this._jsNode.onaudioprocess=this._processBuffer.bind(this),this._controlSignal=new t.Signal(1),this._upTick=!1,this.tick=this.defaultArg(i,function(){}),this._jsNode.noGC(),this.setRate(e)},t.extend(t.Clock),t.Clock.prototype.setRate=function(t,e){var i=this.secondsToFrequency(this.toSeconds(t));e?this._controlSignal.exponentialRampToValueNow(i,e):(this._controlSignal.cancelScheduledValues(0),this._controlSignal.setValue(i))},t.Clock.prototype.getRate=function(){return this._controlSignal.getValue()},t.Clock.prototype.start=function(t){this._oscillator=this.context.createOscillator(),this._oscillator.type="square",this._oscillator.connect(this._jsNode),this._controlSignal.connect(this._oscillator.frequency),this._upTick=!1;var e=this.toSeconds(t);this._oscillator.start(e)},t.Clock.prototype.stop=function(t){var e=this.toSeconds(t);this._oscillator.stop(e)},t.Clock.prototype._processBuffer=function(t){for(var e=this.defaultArg(t.playbackTime,this.now()),i=this._jsNode.bufferSize,n=t.inputBuffer.getChannelData(0),o=this._upTick,s=0;i>s;s++){var r=n[s];r>0&&!o?(o=!0,this.tick(e+this.samplesToSeconds(s))):0>r&&o&&(o=!1)}this._upTick=o},t.Clock.prototype.dispose=function(){this._jsNode.disconnect(),this._controlSignal.dispose(),this._oscillator&&this._oscillator.disconnect(),this._jsNode.onaudioprocess=function(){},this._jsNode=null,this._controlSignal=null,this._oscillator=null},t.Clock}),define("Tone/core/Transport",["Tone/core/Tone","Tone/core/Clock","Tone/signal/Signal"],function(Tone){var Transport=function(){this._clock=new Tone.Clock(1,this._processTick.bind(this)),this.loop=!1,this.state=TransportState.STOPPED};Tone.extend(Transport);var timelineTicks=0,transportTicks=0,tatum=12,transportTimeSignature=4,loopStart=0,loopEnd=4*tatum,intervals=[],timeouts=[],transportTimeline=[],timelineProgress=0,SyncedSources=[],TransportState={STARTED:"started",PAUSED:"paused",STOPPED:"stopped"};Transport.prototype._processTick=function(t){processIntervals(t),processTimeouts(t),processTimeline(t),transportTicks+=1,timelineTicks+=1,this.loop&&timelineTicks===loopEnd&&this._setTicks(loopStart)},Transport.prototype._setTicks=function(t){timelineTicks=t;for(var e=0;e=t){timelineProgress=e;break}}};var processIntervals=function(t){for(var e=0,i=intervals.length;i>e;e++){var n=intervals[e];n.testInterval(transportTicks)&&n.doCallback(t)}},processTimeouts=function(t){for(var e=0,i=0,n=timeouts.length;n>i;i++){var o=timeouts[i],s=o.callbackTick();if(transportTicks>=s)o.doCallback(t),e++;else if(s>transportTicks)break}timeouts.splice(0,e)},processTimeline=function(t){for(var e=timelineProgress,i=transportTimeline.length;i>e;e++){var n=transportTimeline[e],o=n.callbackTick();if(o===timelineTicks)n.doCallback(t),timelineProgress=e;else if(o>timelineTicks)break}};Transport.prototype.setInterval=function(t,e,i){var n=this.toTicks(e),o=new TimelineEvent(t,i,n,transportTicks);return intervals.push(o),o.id},Transport.prototype.clearInterval=function(t){for(var e=0;es;s++){var a=timeouts[s];if(a.callbackTick()>o.callbackTick())return timeouts.splice(s,0,o),o.id}return timeouts.push(o),o.id},Transport.prototype.clearTimeout=function(t){for(var e=0;es;s++){var a=transportTimeline[s];if(a.callbackTick()>o.callbackTick())return transportTimeline.splice(s,0,o),o.id}return transportTimeline.push(o),o.id},Transport.prototype.clearTimeline=function(t){for(var e=0;e1){for(var oringalTime=time,i=0;ir;++r){var a,c=2/(r*Math.PI);switch(t){case"sine":a=1===r?1:0;break;case"square":a=1&r?2*c:0;break;case"sawtooth":a=c*(1&r?1:-1);break;case"triangle":a=1&r?2*c*c*(r-1>>1&1?-1:1):0;break;default:throw new TypeError("invalid oscillator type: "+t)}0!==a?(n[r]=-a*Math.sin(s),o[r]=a*Math.cos(s)):(n[r]=0,o[r]=0)}var h=this.context.createPeriodicWave(n,o);this._wave=h,this.oscillator.setPeriodicWave(this._wave),this._type=t},t.Oscillator.prototype.getType=function(){return this._type},t.Oscillator.prototype.setPhase=function(t){this._phase=t*Math.PI/180,this.setType(this._type)},t.Oscillator.prototype.set=function(t){this.isUndef(t.type)||this.setType(t.type),this.isUndef(t.phase)||this.setPhase(t.phase),this.isUndef(t.frequency)||this.frequency.setValue(t.frequency),this.isUndef(t.onended)||(this.onended=t.onended),this.isUndef(t.detune)||this.detune.setValue(t.detune)},t.Oscillator.prototype._onended=function(){this.state=t.Source.State.STOPPED,this.onended()},t.Oscillator.prototype.dispose=function(){t.Source.prototype.dispose.call(this),this.stop(),null!==this.oscillator&&(this.oscillator.disconnect(),this.oscillator=null),this.frequency.dispose(),this.detune.dispose(),this._wave=null,this.detune=null,this.frequency=null},t.Oscillator}),define("Tone/component/LFO",["Tone/core/Tone","Tone/source/Oscillator","Tone/signal/Scale","Tone/signal/Signal"],function(t){return t.LFO=function(e,i,n){this.oscillator=new t.Oscillator(this.defaultArg(e,1),"sine"),this.frequency=this.oscillator.frequency,this._scaler=new t.Scale(this.defaultArg(i,0),this.defaultArg(n,1)),this.output=this._scaler,this.chain(this.oscillator,this.output)},t.extend(t.LFO),t.LFO.prototype.start=function(t){this.oscillator.start(t)},t.LFO.prototype.stop=function(t){this.oscillator.stop(t)},t.LFO.prototype.sync=function(e){t.Transport.syncSource(this.oscillator,e),t.Transport.syncSignal(this.oscillator.frequency)},t.LFO.prototype.unsync=function(){t.Transport.unsyncSource(this.oscillator),t.Transport.unsyncSignal(this.oscillator.frequency)},t.LFO.prototype.setFrequency=function(t){this.oscillator.setFrequency(t)},t.LFO.prototype.setPhase=function(t){this.oscillator.setPhase(t)},t.LFO.prototype.setMin=function(t){this._scaler.setOutputMin(t)},t.LFO.prototype.setMax=function(t){this._scaler.setOutputMax(t)},t.LFO.prototype.setType=function(t){this.oscillator.setType(t)},t.LFO.prototype.set=function(t){this.isUndef(t.frequency)||this.setFrequency(t.frequency),this.isUndef(t.type)||this.setType(t.type),this.isUndef(t.min)||this.setMin(t.min),this.isUndef(t.max)||this.setMax(t.max)},t.LFO.prototype.connect=t.Signal.prototype.connect,t.LFO.prototype.dispose=function(){this.oscillator.dispose(),this._scaler.dispose(),this.oscillator=null,this.frequency=null,this.output=null},t.LFO}),define("Tone/component/Merge",["Tone/core/Tone"],function(t){return t.Merge=function(){this.output=this.context.createGain(),this.input=new Array(2),this.left=this.input[0]=this.context.createGain(),this.right=this.input[1]=this.context.createGain(),this._merger=this.context.createChannelMerger(2),this.left.connect(this._merger,0,0),this.right.connect(this._merger,0,1),this._merger.connect(this.output)},t.extend(t.Merge),t.Merge.prototype.dispose=function(){t.prototype.dispose.call(this),this.left.disconnect(),this.right.disconnect(),this._merger.disconnect(),this.left=null,this.right=null,this._merger=null},t.Merge}),define("Tone/core/Master",["Tone/core/Tone"],function(t){var e=function(){t.call(this),this.limiter=this.context.createDynamicsCompressor(),this.limiter.threshold.value=0,this.limiter.ratio.value=20,this.chain(this.input,this.limiter,this.output,this.context.destination)};return t.extend(e),e.prototype.mute=function(t){t=this.defaultArg(t,!0),this.output.gain.value=t?0:1},e.prototype.setVolume=function(t,e){var i=this.now();if(e){var n=this.output.gain.value;this.output.gain.cancelScheduledValues(i),this.output.gain.setValueAtTime(n,i),this.output.gain.linearRampToValueAtTime(t,i+this.toSeconds(e))}else this.output.gain.setValueAtTime(t,i)},t.prototype.toMaster=function(){this.connect(t.Master)},AudioNode.prototype.toMaster=function(){this.connect(t.Master)},t.Master=new e,t._initAudioContext(function(){e.call(t.Master)}),t.Master}),define("Tone/component/Meter",["Tone/core/Tone","Tone/core/Master"],function(t){return t.Meter=function(e,i,n){t.call(this),this.channels=this.defaultArg(e,1),this.smoothing=this.defaultArg(i,.8),this.clipMemory=this.defaultArg(n,500),this._volume=new Array(this.channels),this._values=new Array(this.channels);for(var o=0;oh;h++)o=s[h],!c&&o>.95&&(c=!0,this._lastClip=Date.now()),a+=o,r+=o*o;var l=a/e,u=Math.sqrt(r/e);this._volume[n]=Math.max(u,this._volume[n]*i),this._values[n]=l}},t.Meter.prototype.getLevel=function(t){t=this.defaultArg(t,0);var e=this._volume[t];return 1e-5>e?0:e},t.Meter.prototype.getValue=function(t){return t=this.defaultArg(t,0),this._values[t]},t.Meter.prototype.getDb=function(t){return this.gainToDb(this.getLevel(t))},t.Meter.prototype.isClipped=function(){return Date.now()-this._lastClipthis._recordEndSample?(this.state=e.STOPPED,this._callback(this._recordBuffers)):s>this._recordStartSample?(i=0,n=Math.min(this._recordEndSample-s,r),this._recordChannels(t.inputBuffer,i,n,r)):a>this._recordStartSample&&(n=a-this._recordStartSample,i=r-n,this._recordChannels(t.inputBuffer,i,n,r))}},t.Recorder.prototype._recordChannels=function(t,e,i,n){for(var o=this._recordBufferOffset,s=this._recordBuffers,r=0;rc;c++){var h=c-e;s[r][h+o]=a[c]}}this._recordBufferOffset+=i},t.Recorder.prototype.record=function(t,i,n){if(this.state===e.STOPPED){this.clear(),this._recordBufferOffset=0,i=this.defaultArg(i,0),this._recordDuration=this.toSamples(t),this._recordStartSample=this.toSamples("+"+i),this._recordEndSample=this._recordStartSample+this._recordDuration;for(var o=0;os;s++){var a=o[s];Array.isArray(n)?a.apply(window,[e].concat(n)):a(e,n)}}t.Note=function(e,i,n){this.value=n,this._channel=e,this._timelineID=t.Transport.setTimeline(this._trigger.bind(this),i)},t.Note.prototype._trigger=function(t){e(this._channel,t,this.value)},t.Note.prototype.dispose=function(){t.Tranport.clearTimeline(this._timelineID),this.value=null};var i={};return t.Note.route=function(t,e){i.hasOwnProperty(t)?i[t].push(e):i[t]=[e]},t.Note.unroute=function(t,e){if(i.hasOwnProperty(t)){var n=i[t],o=n.indexOf(e);-1!==o&&i[t].splice(o,1)}},t.Note.parseScore=function(e){var i=[];for(var n in e)for(var o=e[n],s=0;sn;n++){var o=n/e*2-1;i[n]=o>=0?Math.pow(o,t):o}this._expScaler.curve=i},t.ScaleExp.prototype.setInputMin=function(t){this._inputMin=t,this._setScalingParameters()},t.ScaleExp.prototype.setInputMax=function(t){this._inputMax=t,this._setScalingParameters()},t.ScaleExp.prototype.setOutputMin=function(t){this._outputMin=t,this._setScalingParameters()},t.ScaleExp.prototype.setOutputMax=function(t){this._outputMax=t,this._setScalingParameters()},t.ScaleExp.prototype.connect=t.Signal.prototype.connect,t.ScaleExp.prototype.dispose=function(){this.input.disconnect(),this.output.disconnect(),this._plusInput.dispose(),this._plusOutput.dispose(),this._normalize.dispose(),this._scale.dispose(),this.input=null,this.output=null,this._plusInput=null,this._plusOutput=null,this._scale=null},t.ScaleExp}),define("Tone/effect/AutoWah",["Tone/core/Tone","Tone/component/Follower","Tone/signal/ScaleExp","Tone/effect/Effect"],function(t){return t.AutoWah=function(){var e=this.optionsObject(arguments,["baseFrequency","octaves","sensitivity"],t.AutoWah.defaults);t.Effect.call(this,e),this._follower=new t.Follower(e.follower),this._sweepRange=new t.ScaleExp(0,1,0,1,.5),this._baseFrequency=e.baseFrequency,this._octaves=e.octaves,this._bandpass=new t.Filter("bandpass"),this._bandpass.setRolloff(-48),this._peaking=this.context.createBiquadFilter(),this._peaking.type="peaking",this._peaking.gain.value=e.gain,this.chain(this.effectSend,this._follower,this._sweepRange),this._sweepRange.connect(this._bandpass.frequency),this._sweepRange.connect(this._peaking.frequency),this.chain(this.effectSend,this._bandpass,this._peaking,this.effectReturn),this._setSweepRange(),this.setSensitiviy(e.sensitivity)},t.extend(t.AutoWah,t.Effect),t.AutoWah.defaults={baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:{attack:.3,release:.5}},t.AutoWah.prototype.setOctaves=function(t){this._octaves=t,this._setSweepRange()},t.AutoWah.prototype.setBaseFrequency=function(t){this._baseFrequency=t,this._setSweepRange()},t.AutoWah.prototype.setSensitiviy=function(t){this._sweepRange.setInputMax(this.dbToGain(t))},t.AutoWah.prototype._setSweepRange=function(){this._sweepRange.setOutputMin(this._baseFrequency),this._sweepRange.setOutputMax(Math.min(this._baseFrequency*Math.pow(2,this._octaves),this.context.sampleRate/2))},t.AutoWah.prototype.set=function(e){this.isUndef(e.baseFrequency)||this.setBaseFrequency(e.baseFrequency),this.isUndef(e.sensitivity)||this.setSensitiviy(e.sensitivity),this.isUndef(e.octaves)||this.setOctaves(e.octaves),this.isUndef(e.follower)||this._follower.set(e.follower),this.isUndef(e.Q)||(this._bandpass.Q.value=e.Q),this.isUndef(e.gain)||(this._peaking.gain.value=e.gain),t.Effect.prototype.set.call(this,e)},t.AutoWah.prototype.dispose=function(){t.Effect.prototype.dispose.call(this),this._follower.dispose(),this._sweepRange.dispose(),this._bandpass.disconnect(),this._peaking.disconnect(),this._follower=null,this._sweepRange=null,this._bandpass=null,this._peaking=null},t.AutoWah}),define("Tone/effect/BitCrusher",["Tone/core/Tone","Tone/effect/Effect"],function(t){return t.BitCrusher=function(){var e=this.optionsObject(arguments,["bits","frequency"],t.BitCrusher.defaults);t.Effect.call(this,e),this._bits=this.defaultArg(e.bits,8),this._frequency=this.defaultArg(e.frequency,.5),this._step=2*Math.pow(.5,this._bits),this._invStep=1/this._step,this._phasor=0,this._last=0,this._crusher=this.context.createScriptProcessor(this.bufferSize,1,1),this._crusher.onaudioprocess=this._audioprocess.bind(this),this.connectEffect(this._crusher)},t.extend(t.BitCrusher,t.Effect),t.BitCrusher.defaults={bits:8,frequency:.5},t.BitCrusher.prototype._audioprocess=function(t){for(var e=this._phasor,i=this._frequency,n=this._invStep,o=this._last,s=this._step,r=t.inputBuffer.getChannelData(0),a=t.outputBuffer.getChannelData(0),c=0,h=a.length;h>c;c++)e+=i,e>=1&&(e-=1,o=s*(r[c]*n|.5)),a[c]=o;this._phasor=e,this._last=o},t.BitCrusher.prototype.setBits=function(t){this._bits=t,this._step=2*Math.pow(.5,this._bits),this._invStep=1/this._step},t.BitCrusher.prototype.setFrequency=function(t){this._frequency=t},t.BitCrusher.prototype.set=function(e){this.isUndef(e.frequency)||this.setFrequency(e.frequency),this.isUndef(e.bits)||this.setBits(e.bits),t.Effect.prototype.set.call(this,e)},t.BitCrusher.prototype.dispose=function(){t.Effect.prototype.dispose.call(this),this._crusher.disconnect(),this._crusher=null},t.BitCrusher}),define("Tone/effect/StereoEffect",["Tone/core/Tone","Tone/effect/Effect","Tone/component/Split","Tone/component/Merge"],function(t){return t.StereoEffect=function(){t.call(this);var e=this.optionsObject(arguments,["dry"],t.Effect.defaults);this.dryWet=new t.DryWet,this._mono=new t.Merge,this._split=new t.Split,this.effectSendL=this._split.left,this.effectSendR=this._split.right,this._merge=new t.Merge,this.effectReturnL=this._merge.left,this.effectReturnR=this._merge.right,this.input.connect(this._mono,0,0),this.input.connect(this._mono,0,1),this._mono.connect(this._split),this._mono.connect(this.dryWet.dry),this._merge.connect(this.dryWet.wet),this.dryWet.connect(this.output),this.setDry(e.dry)},t.extend(t.StereoEffect,t.Effect),t.StereoEffect.prototype.dispose=function(){t.prototype.dispose.call(this),this.dryWet.dispose(),this._mono.dispose(),this._split.dispose(),this._merge.dispose(),this._mono=null,this._split=null,this._merge=null,this.effectSendL=null,this.effectSendR=null,this.effectReturnL=null,this.effectReturnR=null,this.dryWet=null},t.StereoEffect}),define("Tone/effect/FeedbackEffect",["Tone/core/Tone","Tone/effect/Effect","Tone/signal/Signal","Tone/signal/Multiply"],function(t){return t.FeedbackEffect=function(){var e=this.optionsObject(arguments,["feedback"]);e=this.defaultArg(e,t.FeedbackEffect.defaults),t.Effect.call(this,e),this.feedback=new t.Signal(e.feedback),this._half=new t.Multiply(.5),this._feedbackGain=this.context.createGain(),this.chain(this.effectReturn,this._feedbackGain,this.effectSend),this.chain(this.feedback,this._half,this._feedbackGain.gain)},t.extend(t.FeedbackEffect,t.Effect),t.FeedbackEffect.defaults={feedback:.25},t.FeedbackEffect.prototype.setFeedback=function(t,e){e?this.feedback.linearRampToValueNow(t,e):this.feedback.setValue(t)},t.FeedbackEffect.prototype.set=function(e){this.isUndef(e.feedback)||this.setFeedback(e.feedback),t.Effect.prototype.set.call(this,e)},t.FeedbackEffect.prototype.dispose=function(){t.Effect.prototype.dispose.call(this),this.feedback.dispose(),this._half.dispose(),this._feedbackGain.disconnect(),this.feedback=null,this._feedbackGain=null,this._half=null},t.FeedbackEffect}),define("Tone/effect/StereoXFeedbackEffect",["Tone/core/Tone","Tone/effect/StereoEffect","Tone/effect/FeedbackEffect"],function(t){return t.StereoXFeedbackEffect=function(){var e=this.optionsObject(arguments,["feedback"],t.FeedbackEffect.defaults);t.StereoEffect.call(this,e),this.feedback=new t.Signal(e.feedback),this._half=new t.Multiply(.5),this._feedbackLR=this.context.createGain(),this._feedbackRL=this.context.createGain(),this.chain(this.effectReturnL,this._feedbackLR,this.effectSendR),this.chain(this.effectReturnR,this._feedbackRL,this.effectSendL),this.feedback.connect(this._half),this.fan(this._half,this._feedbackLR.gain,this._feedbackRL.gain)},t.extend(t.StereoXFeedbackEffect,t.FeedbackEffect),t.StereoXFeedbackEffect.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this),this.feedback.dispose(),this._half.dispose(),this._feedbackLR.disconnect(),this._feedbackRL.disconnect(),this.feedback=null,this._feedbackLR=null,this._feedbackRL=null,this._half=null},t.StereoXFeedbackEffect}),define("Tone/effect/Chorus",["Tone/core/Tone","Tone/component/LFO","Tone/effect/StereoXFeedbackEffect"],function(t){return t.Chorus=function(){var e=this.optionsObject(arguments,["rate","delayTime","depth"],t.Chorus.defaults);t.StereoXFeedbackEffect.call(this,e),this._depth=e.depth,this._delayTime=e.delayTime/1e3,this._lfoL=new t.LFO(e.rate,0,1),this._lfoR=new t.LFO(e.rate,0,1),this._lfoR.setPhase(180),this._delayNodeL=this.context.createDelay(),this._delayNodeR=this.context.createDelay(),this.chain(this.effectSendL,this._delayNodeL,this.effectReturnL),this.chain(this.effectSendR,this._delayNodeR,this.effectReturnR),this.effectSendL.connect(this.effectReturnL),this.effectSendR.connect(this.effectReturnR),this._lfoL.connect(this._delayNodeL.delayTime),this._lfoR.connect(this._delayNodeR.delayTime),this._lfoL.start(),this._lfoR.start(),this._lfoL.frequency.connect(this._lfoR.frequency),this.setDepth(this._depth),this.setRate(e.rate)},t.extend(t.Chorus,t.StereoXFeedbackEffect),t.Chorus.defaults={rate:1.5,delayTime:3.5,depth:.7,feedback:.4},t.Chorus.prototype.setDepth=function(t){this._depth=t;var e=this._delayTime*t;this._lfoL.setMin(this._delayTime-e),this._lfoL.setMax(this._delayTime+e),this._lfoR.setMin(this._delayTime-e),this._lfoR.setMax(this._delayTime+e)},t.Chorus.prototype.setDelayTime=function(t){this._delayTime=t/1e3,this.setDepth(this._depth)},t.Chorus.prototype.setRate=function(t){this._lfoL.setFrequency(t)},t.Chorus.prototype.set=function(e){this.isUndef(e.rate)||this.setRate(e.rate),this.isUndef(e.delayTime)||this.setDelayTime(e.delayTime),this.isUndef(e.depth)||this.setDepth(e.depth),t.FeedbackEffect.prototype.set.call(this,e)},t.Chorus.prototype.dispose=function(){t.StereoXFeedbackEffect.prototype.dispose.call(this),this._lfoL.dispose(),this._lfoR.dispose(),this._delayNodeL.disconnect(),this._delayNodeR.disconnect(),this._lfoL=null,this._lfoR=null,this._delayNodeL=null,this._delayNodeR=null},t.Chorus}),define("Tone/effect/FeedbackDelay",["Tone/core/Tone","Tone/effect/FeedbackEffect","Tone/signal/Signal"],function(t){return t.FeedbackDelay=function(){var e=this.optionsObject(arguments,["delayTime"],t.FeedbackDelay.defaults);t.FeedbackEffect.call(this,e),this.delayTime=new t.Signal,this._delayNode=this.context.createDelay(4),this.connectEffect(this._delayNode),this.delayTime.connect(this._delayNode.delayTime),this.setDelayTime(e.delayTime)},t.extend(t.FeedbackDelay,t.FeedbackEffect),t.FeedbackDelay.defaults={delayTime:.25},t.FeedbackDelay.prototype.setDelayTime=function(t,e){e?this.delayTime.linearRampToValueNow(this.toSeconds(t),e):this.delayTime.setValue(this.toSeconds(t))},t.FeedbackDelay.prototype.set=function(e){this.isUndef(e.delayTime)||this.setDelayTime(e.delayTime),t.FeedbackEffect.prototype.set.call(this,e)},t.FeedbackDelay.prototype.dispose=function(){t.FeedbackEffect.prototype.dispose.call(this),this.delayTime.dispose(),this._delayNode.disconnect(),this._delayNode=null,this.delayTime=null -},t.FeedbackDelay}),define("Tone/effect/StereoFeedbackEffect",["Tone/core/Tone","Tone/effect/StereoEffect","Tone/effect/FeedbackEffect"],function(t){return t.StereoFeedbackEffect=function(){var e=this.optionsObject(arguments,["feedback"],t.FeedbackEffect.defaults);t.StereoEffect.call(this,e),this.feedback=new t.Signal(e.feedback),this._half=new t.Multiply(.5),this._feedbackL=this.context.createGain(),this._feedbackR=this.context.createGain(),this.chain(this.effectReturnL,this._feedbackL,this.effectSendL),this.chain(this.effectReturnR,this._feedbackR,this.effectSendR),this.feedback.connect(this._half),this.fan(this._half,this._feedbackL.gain,this._feedbackR.gain)},t.extend(t.StereoFeedbackEffect,t.FeedbackEffect),t.StereoFeedbackEffect.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this),this.feedback.dispose(),this._half.dispose(),this._feedbackL.disconnect(),this._feedbackR.disconnect(),this.feedback=null,this._feedbackL=null,this._feedbackR=null,this._half=null},t.StereoFeedbackEffect}),define("Tone/effect/Phaser",["Tone/core/Tone","Tone/component/LFO","Tone/effect/FeedbackEffect","Tone/component/Filter","Tone/effect/StereoFeedbackEffect"],function(t){return t.Phaser=function(){var e=this.optionsObject(arguments,["rate","depth","baseFrequency"],t.Phaser.defaults);t.StereoFeedbackEffect.call(this,e),this._lfoL=new t.LFO(e.rate,0,1),this._lfoR=new t.LFO(e.rate,0,1),this._lfoR.setPhase(180),this._baseFrequency=e.baseFrequency,this._depth=e.depth,this._filtersL=this._makeFilters(e.stages,this._lfoL),this._filtersR=this._makeFilters(e.stages,this._lfoR),this.effectSendL.connect(this._filtersL[0]),this.effectSendR.connect(this._filtersR[0]),this._filtersL[e.stages-1].connect(this.effectReturnL),this._filtersR[e.stages-1].connect(this.effectReturnR),this.effectSendL.connect(this.effectReturnL),this.effectSendR.connect(this.effectReturnR),this._lfoL.frequency.connect(this._lfoR.frequency),this.setBaseFrequency(e.baseFrequency),this.setDepth(e.depth),this.setRate(e.rate),this._lfoL.start(),this._lfoR.start()},t.extend(t.Phaser,t.StereoFeedbackEffect),t.Phaser.defaults={rate:.5,depth:1,stages:4,baseFrequency:400,feedback:.6},t.Phaser.prototype._makeFilters=function(t,e){for(var i=new Array(t),n=0;t>n;n++){var o=this.context.createBiquadFilter();o.type="allpass",o.Q.value=6,e.connect(o.frequency),i[n]=o}return this.chain.apply(this,i),i},t.Phaser.prototype.setDepth=function(t){this._depth=t;var e=this._baseFrequency+this._baseFrequency*t;this._lfoL.setMax(e),this._lfoR.setMax(e)},t.Phaser.prototype.setBaseFrequency=function(t){this._baseFrequency=t,this._lfoL.setMin(t),this._lfoR.setMin(t),this.setDepth(this._depth)},t.Phaser.prototype.setRate=function(t){this._lfoL.setFrequency(t)},t.Phaser.prototype.set=function(e){this.isUndef(e.rate)||this.setRate(e.rate),this.isUndef(e.baseFrequency)||this.setBaseFrequency(e.baseFrequency),this.isUndef(e.depth)||this.setDepth(e.depth),t.StereoFeedbackEffect.prototype.set.call(this,e)},t.Phaser.prototype.dispose=function(){t.StereoFeedbackEffect.prototype.dispose.call(this),this._lfoL.dispose(),this._lfoR.dispose();for(var e=0;e0){var i=this.frequency.getValue();this.frequency.setValueAtTime(i,e),this.frequency.exponentialRampToValueAtTime(t,e+this.portamento)}else this.frequency.setValueAtTime(t,e)},t.Monophonic.prototype.setPortamento=function(t){this.portamento=this.toSeconds(t)},t.Monophonic.prototype.setVolume=t.Source.prototype.setVolume,t.Monophonic.prototype.set=function(t){this.isUndef(t.volume)||this.setVolume(t.volume),this.isUndef(t.portamento)||this.setPortamento(t.portamento)},t.Monophonic.prototype.setPreset=function(t){!this.isUndef(this.preset)&&this.preset.hasOwnProperty(t)&&this.set(this.preset[t])},t.Monophonic.prototype.dispose=function(){t.prototype.dispose.call(this)},t.Monophonic}),define("Tone/instrument/MonoSynth",["Tone/core/Tone","Tone/component/Envelope","Tone/source/Oscillator","Tone/signal/Signal","Tone/component/Filter","Tone/signal/Add","Tone/instrument/Monophonic"],function(t){return t.MonoSynth=function(e){e=this.defaultArg(e,this.defaults),t.Monophonic.call(this,e),this.oscillator=new t.Oscillator(0,e.oscType),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new t.Filter(e.filter),this.filterEnvelope=new t.Envelope(e.filterEnvelope),this.envelope=new t.Envelope(e.envelope),this._amplitude=this.context.createGain(),this.oscillator.connect(this.filter),this.filter.connect(this._amplitude),this.oscillator.start(),this.filterEnvelope.connect(this.filter.frequency),this.envelope.connect(this._amplitude.gain),this._amplitude.connect(this.output)},t.extend(t.MonoSynth,t.Monophonic),t.MonoSynth.prototype.defaults={oscType:"square",filter:{Q:6,frequency:4e3,type:"lowpass",rolloff:-24},envelope:{attack:.005,decay:.1,sustain:.9,release:1},filterEnvelope:{attack:.06,decay:.2,sustain:.5,release:2,min:10,max:4e3}},t.MonoSynth.prototype.triggerEnvelopeAttack=function(t,e){this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t)},t.MonoSynth.prototype.triggerEnvelopeRelease=function(t){this.envelope.triggerRelease(t),this.filterEnvelope.triggerRelease(t)},t.MonoSynth.prototype.setOscType=function(t){this.oscillator.setType(t)},t.MonoSynth.prototype.set=function(e){this.isUndef(e.detune)||this.detune.setValue(e.detune),this.isUndef(e.oscType)||this.setOscType(e.oscType),this.isUndef(e.filterEnvelope)||this.filterEnvelope.set(e.filterEnvelope),this.isUndef(e.envelope)||this.envelope.set(e.envelope),this.isUndef(e.filter)||this.filter.set(e.filter),t.Monophonic.prototype.set.call(this,e)},t.MonoSynth.prototype.dispose=function(){t.Monophonic.prototype.dispose.call(this),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this.detune.dispose(),this._unison.dispose(),this.oscillator=null,this.filterEnvelope=null,this.envelope=null,this.filter=null,this.detune=null,this._unison=null},t.MonoSynth}),define("Tone/instrument/DuoSynth",["Tone/core/Tone","Tone/instrument/MonoSynth","Tone/component/LFO","Tone/signal/Signal","Tone/signal/Multiply","Tone/instrument/Monophonic"],function(t){return t.DuoSynth=function(e){e=this.defaultArg(e,t.DuoSynth.defaults),t.Monophonic.call(this,e),this.voice0=new t.MonoSynth(e.voice0),this.voice0.setVolume(-10),this.voice1=new t.MonoSynth(e.voice1),this.voice1.setVolume(-10),this._vibrato=new t.LFO(e.vibratoRate,-50,50),this._vibrato.start(),this._vibratoGain=this.context.createGain(),this._vibratoGain.gain.value=e.vibratoAmount,this._vibratoDelay=this.toSeconds(e.vibratoDelay),this._vibratoAmount=e.vibratoAmount,this.frequency=new t.Signal(440),this._harmonicity=new t.Multiply(e.harmonicity),this.frequency.connect(this.voice0.frequency),this.chain(this.frequency,this._harmonicity,this.voice1.frequency),this._vibrato.connect(this._vibratoGain),this.fan(this._vibratoGain,this.voice0.detune,this.voice1.detune),this.voice0.connect(this.output),this.voice1.connect(this.output)},t.extend(t.DuoSynth,t.Monophonic),t.DuoSynth.defaults={vibratoAmount:.5,vibratoRate:5,vibratoDelay:1,harmonicity:1.5,voice0:{volume:-10,portamento:0,oscType:"sine",filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}},voice1:{volume:-10,portamento:0,oscType:"sine",filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}},t.DuoSynth.prototype.triggerEnvelopeAttack=function(t,e){t=this.toSeconds(t),this.voice0.envelope.triggerAttack(t,e),this.voice1.envelope.triggerAttack(t,e),this.voice0.filterEnvelope.triggerAttack(t),this.voice1.filterEnvelope.triggerAttack(t)},t.DuoSynth.prototype.triggerEnvelopeRelease=function(t){this.voice0.triggerRelease(t),this.voice1.triggerRelease(t)},t.DuoSynth.prototype.setHarmonicity=function(t){this._harmonicity.setValue(t)},t.DuoSynth.prototype.setPortamento=function(t){this.portamento=this.toSeconds(t)},t.DuoSynth.prototype.setVibratoDelay=function(t){this._vibratoDelay=this.toSeconds(t)},t.DuoSynth.prototype.setVibratoAmount=function(t){this._vibratoAmount=t,this._vibratoGain.gain.setValueAtTime(t,this.now())},t.DuoSynth.prototype.setVibratoRate=function(t){this._vibrato.setFrequency(t)},t.DuoSynth.prototype.setVolume=t.Source.prototype.setVolume,t.DuoSynth.prototype.set=function(e){this.isUndef(e.harmonicity)||this.setHarmonicity(e.harmonicity),this.isUndef(e.vibratoRate)||this.setVibratoRate(e.vibratoRate),this.isUndef(e.vibratoAmount)||this.setVibratoAmount(e.vibratoAmount),this.isUndef(e.vibratoDelay)||this.setVibratoDelay(e.vibratoDelay),this.isUndef(e.voice0)||this.voice0.set(e.voice0),this.isUndef(e.voice1)||this.voice1.set(e.voice1),t.Monophonic.prototype.set.call(this,e)},t.DuoSynth.dispose=function(){t.Monophonic.prototype.dispose.call(this),this.voice0.dispose(),this.voice1.dispose(),this.frequency.dispose(),this._vibrato.dispose(),this._vibratoGain.disconnect(),this._harmonicity.dispose(),this.voice0=null,this.voice1=null,this.frequency=null,this._vibrato=null,this._vibratoGain=null,this._harmonicity=null},t.DuoSynth}),define("Tone/instrument/FMSynth",["Tone/core/Tone","Tone/instrument/MonoSynth","Tone/signal/Signal","Tone/signal/Multiply","Tone/instrument/Monophonic"],function(t){return t.FMSynth=function(e){e=this.defaultArg(e,t.FMSynth.defaults),t.Monophonic.call(this,e),this.carrier=new t.MonoSynth(e.carrier),this.carrier.setVolume(-10),this.modulator=new t.MonoSynth(e.modulator),this.modulator.setVolume(-10),this.frequency=new t.Signal(440),this._harmonicity=new t.Multiply(e.harmonicity),this._modulationIndex=new t.Multiply(e.modulationIndex),this._modulationNode=this.context.createGain(),this.frequency.connect(this.carrier.frequency),this.chain(this.frequency,this._harmonicity,this.modulator.frequency),this.chain(this.frequency,this._modulationIndex,this._modulationNode),this.modulator.connect(this._modulationNode.gain),this._modulationNode.gain.value=0,this._modulationNode.connect(this.carrier.frequency),this.carrier.connect(this.output)},t.extend(t.FMSynth,t.Monophonic),t.FMSynth.defaults={harmonicity:3,modulationIndex:10,carrier:{volume:-10,portamento:0,oscType:"sine",envelope:{attack:.01,decay:0,sustain:1,release:.5},filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5,min:2e4,max:2e4}},modulator:{volume:-10,portamento:0,oscType:"triangle",envelope:{attack:.01,decay:0,sustain:1,release:.5},filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5,min:2e4,max:2e4}}},t.FMSynth.prototype.triggerEnvelopeAttack=function(t,e){t=this.toSeconds(t),this.carrier.envelope.triggerAttack(t,e),this.modulator.envelope.triggerAttack(t),this.carrier.filterEnvelope.triggerAttack(t),this.modulator.filterEnvelope.triggerAttack(t)},t.FMSynth.prototype.triggerEnvelopeRelease=function(t){this.carrier.triggerRelease(t),this.modulator.triggerRelease(t)},t.FMSynth.prototype.setHarmonicity=function(t){this._harmonicity.setValue(t)},t.FMSynth.prototype.setModulationIndex=function(t){this._modulationIndex.setValue(t)},t.FMSynth.prototype.set=function(e){this.isUndef(e.harmonicity)||this.setHarmonicity(e.harmonicity),this.isUndef(e.modulationIndex)||this.setModulationIndex(e.modulationIndex),this.isUndef(e.carrier)||this.carrier.set(e.carrier),this.isUndef(e.modulator)||this.modulator.set(e.modulator),t.Monophonic.prototype.set.call(this,e)},t.FMSynth.dispose=function(){t.Monophonic.prototype.dispose.call(this),this.carrier.dispose(),this.modulator.dispose(),this.frequency.dispose(),this._modulationIndex.dispose(),this._harmonicity.dispose(),this._modulationNode.disconnect(),this.carrier=null,this.modulator=null,this.frequency=null,this._modulationIndex=null,this._harmonicity=null,this._modulationNode=null},t.FMSynth}),define("Tone/source/Player",["Tone/core/Tone","Tone/source/Source"],function(t){return t.Player=function(e,i){t.Source.call(this),this._source=null,this._buffer=null,this.duration=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this._playbackRate=1,this.retrigger=!1,this.onended=function(){},e&&this.load(e,i)},t.extend(t.Player,t.Source),t.Player.prototype.load=function(t,e){if(this._buffer)e&&e(this);else{var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer";var n=this;i.onload=function(){n.context.decodeAudioData(i.response,function(t){n.setBuffer(t),e&&e(n)})},i.send()}},t.Player.prototype.setBuffer=function(t){this._buffer=t,this.duration=t.duration},t.Player.prototype.start=function(e,i,n){(this.state===t.Source.State.STOPPED||this.retrigger)&&this._buffer&&(this.state=t.Source.State.STARTED,i=this.defaultArg(i,0),this.loop&&(i=this.loopStart),n=this.defaultArg(n,this._buffer.duration-i),this._source=this.context.createBufferSource(),this._source.buffer=this._buffer,this._source.loop=this.loop,this._source.loopStart=this.loopStart,this._source.loopEnd=this.loopEnd,this._source.playbackRate.value=this._playbackRate,this._source.onended=this._onended.bind(this),this.chain(this._source,this.output),this._source.start(this.toSeconds(e),this.toSeconds(i),this.toSeconds(n)))},t.Player.prototype.stop=function(e){this.state===t.Source.State.STARTED&&this._buffer&&this._source&&(e||(this.state=t.Source.State.STOPPED),this._source.stop(this.toSeconds(e)))},t.Player.prototype.setPlaybackRate=function(t,e){this._playbackRate=t,this._source&&(e?this._source.playbackRate.exponentialRampToValueAtTime(t,this.toSeconds(e)):this._source.playbackRate.value=e)},t.Player.prototype._onended=function(){this.state=t.Source.State.STOPPED,this.onended()},t.Player.prototype.dispose=function(){t.Source.prototype.dispose.call(this),null!==this._source&&(this._source.disconnect(),this._source=null),this._buffer=null},t.Player}),define("Tone/instrument/Sampler",["Tone/core/Tone","Tone/source/Player","Tone/component/Envelope","Tone/component/Filter"],function(t){return t.Sampler=function(){var e=this.optionsObject(arguments,["url","load"],t.Sampler.defaults);this.output=this.context.createGain(),this.player=new t.Player(e.url,e.load),this.player.retrigger=!0,this.envelope=new t.Envelope(e.envelope),this.filterEnvelope=new t.Envelope(e.filterEnvelope),this.filter=new t.Filter(e.filter),this.chain(this.player,this.filter,this.output),this.envelope.connect(this.player.output.gain),this.filterEnvelope.connect(this.filter.frequency)},t.extend(t.Sampler),t.Sampler.defaults={url:null,load:function(){},envelope:{attack:.001,decay:0,sustain:1,release:.1},filterEnvelope:{attack:.001,decay:.001,sustain:1,release:.5,min:0,max:2e4},filter:{type:"lowpass"}},t.Sampler.prototype.set=function(t){this.isUndef(t.filterEnvelope)||this.filterEnvelope.set(t.filterEnvelope),this.isUndef(t.envelope)||this.envelope.set(t.envelope),this.isUndef(t.filter)||this.filter.set(t.filter)},t.Sampler.prototype.triggerAttack=function(t,e){this.player.start(t),this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t)},t.Sampler.prototype.triggerRelease=function(t){this.filterEnvelope.triggerRelease(t),this.envelope.triggerRelease(t)},t.Sampler.prototype.dispose=function(){t.prototype.dispose.call(this),this.player.dispose(),this.filterEnvelope.dispose(),this.envelope.dispose(),this.filter.dispose(),this.player=null,this.filterEnvelope=null,this.envelope=null,this.filter=null},t.Sampler}),define("Tone/instrument/MultiSampler",["Tone/core/Tone","Tone/instrument/Sampler","Tone/source/Source"],function(t){return t.MultiSampler=function(t,e){this.output=this.context.createGain(),this.samples={},this._createSamples(t,e)},t.extend(t.MultiSampler),t.MultiSampler.prototype._createSamples=function(e,i){var n={total:0,loaded:0};for(var o in e)"string"==typeof e[o]&&n.total++;var s=function(){n.loaded++,n.loaded===n.total&&i&&i()};for(var r in e){var a=e[r],c=new t.Sampler(a,s);c.connect(this.output),this.samples[r]=c}},t.MultiSampler.prototype.triggerAttack=function(t,e){this.samples.hasOwnProperty(t)&&this.samples[t].triggerAttack(e)},t.MultiSampler.prototype.triggerRelease=function(t,e){this.samples.hasOwnProperty(t)&&this.samples[t].triggerRelease(e)},t.MultiSampler.prototype.set=function(t){for(var e in this.samples)this.samples[e].set(t)},t.MultiSampler.prototype.setVolume=t.Source.prototype.setVolume,t.MultiSampler.dispose=function(){t.prototype.dispose.call(this);for(var e in this.samples)this.samples[e].dispose(),this.samples[e]=null},t.MultiSampler}),define("Tone/instrument/PolySynth",["Tone/core/Tone","Tone/instrument/MonoSynth","Tone/source/Source"],function(t){return t.PolySynth=function(){var e=this.optionsObject(arguments,["polyphony","voice","voiceOptions"],t.PolySynth.defaults);this.output=this.context.createGain(),this._voices=new Array(e.polyphony),this._freeVoices=[],this._activeVoices={};for(var i=0;i0){var o=this._freeVoices.shift();o.triggerAttack(t,e),this._activeVoices[n]=o}},t.PolySynth.prototype.triggerAttackRelease=function(t,e,i,n){i=this.toSeconds(i),this.triggerAttack(t,i,n),this.triggerRelease(i+this.toSeconds(e))},t.PolySynth.prototype.triggerRelease=function(t,e){var i=JSON.stringify(t),n=this._activeVoices[i];n&&(n.triggerRelease(e),this._freeVoices.push(n),this._activeVoices[i]=null)},t.PolySynth.prototype.set=function(t){for(var e=0;ei){var n=e;e=i,i=n}this._min=new t.Min(i),this._max=new t.Max(e),this.chain(this.input,this._min,this._max,this.output)},t.extend(t.Clip),t.Clip.prototype.setMin=function(t){this._min.setMin(t)},t.Clip.prototype.setMax=function(t){this._max.setMax(t)},t.Clip.prototype.connect=t.Signal.prototype.connect,t.Clip.prototype.dispose=function(){this._min.dispose(),this._max.dispose(),this.input.disconnect(),this.output.disconnect(),this._min=null,this._max=null,this.input=null,this.output=null},t.Clip}),define("Tone/signal/Route",["Tone/core/Tone","Tone/signal/Equal","Tone/signal/Signal"],function(t){t.Route=function(i){i=this.defaultArg(i,2),this.output=new Array(i),this.input=this.context.createGain(),this.gate=new t.Signal(0);for(var n=0;i>n;n++){var o=new e(n);this.output[n]=o,this.gate.connect(o.selecter),this.input.connect(o)}},t.extend(t.Route),t.Route.prototype.select=function(t,e){t=Math.floor(t),this.gate.setValueAtTime(t,this.toSeconds(e))},t.Route.prototype.connect=t.Signal.prototype.connect,t.Route.prototype.dispose=function(){this.input.disconnect(),this.gate.dispose();for(var t=0;tf;f++){var d=2*Math.random()-1;n=.99886*n+.0555179*d,r=.99332*r+.0750759*d,a=.969*a+.153852*d,c=.8665*c+.3104856*d,h=.55*h+.5329522*d,l=-.7616*l-.016898*d,p[f]=n+r+a+c+h+l+u+.5362*d,p[f]*=.11,u=.115926*d}}return e}(),i=function(){for(var e=t.createBuffer(2,s,o),i=0;ia;a++){var c=2*Math.random()-1;n[a]=(r+.02*c)/1.02,r=n[a],n[a]*=3.5}return e}(),n=function(){for(var e=t.createBuffer(2,s,o),i=0;ir;r++)n[r]=2*Math.random()-1;return e}()}),t.Noise}),define("Tone/source/PulseOscillator",["Tone/core/Tone","Tone/source/Source","Tone/source/Oscillator","Tone/signal/Signal","Tone/signal/Threshold"],function(t){for(var e=new Float32Array(256),i=0;128>i;i++)e[i]=-1,e[i+128]=1;return t.PulseOscillator=function(i,n){t.Source.call(this),this.width=new t.Signal(this.defaultArg(n,.5)),this._sawtooth=new t.Oscillator(i,"sawtooth"),this.frequency=this._sawtooth.frequency,this.detune=this._sawtooth.detune,this._thresh=this.context.createWaveShaper(),this._thresh.curve=e,this.chain(this._sawtooth,this._thresh,this.output),this.width.connect(this._thresh)},t.extend(t.PulseOscillator,t.Source),t.PulseOscillator.prototype.setWidth=function(t){this.width.setValue(t)},t.PulseOscillator.prototype.start=function(e){this.state===t.Source.State.STOPPED&&(e=this.toSeconds(e),this._sawtooth.start(e),this.width.output.gain.setValueAtTime(1,e),this.state=t.Source.State.STARTED)},t.PulseOscillator.prototype.stop=function(e){this.state===t.Source.State.STARTED&&(e=this.toSeconds(e),this._sawtooth.stop(e),this.width.output.gain.setValueAtTime(0,e),this.state=t.Source.State.STOPPED)},t.PulseOscillator.prototype.dispose=function(){this._sawtooth.dispose(),this._sawtooth=null,this.width.dispose(),this.width=null},t.PulseOscillator}) \ No newline at end of file +var e=this.toSeconds(t);this._clock.stop(e);for(var i=0;i1){for(var oringalTime=time,i=0;ir;++r){var a,c=2/(r*Math.PI);switch(t){case"sine":a=1===r?1:0;break;case"square":a=1&r?2*c:0;break;case"sawtooth":a=c*(1&r?1:-1);break;case"triangle":a=1&r?2*c*c*(r-1>>1&1?-1:1):0;break;default:throw new TypeError("invalid oscillator type: "+t)}0!==a?(n[r]=-a*Math.sin(s),o[r]=a*Math.cos(s)):(n[r]=0,o[r]=0)}var h=this.context.createPeriodicWave(n,o);this._wave=h,this.oscillator.setPeriodicWave(this._wave),this._type=t},t.Oscillator.prototype.getType=function(){return this._type},t.Oscillator.prototype.setPhase=function(t){this._phase=t*Math.PI/180,this.setType(this._type)},t.Oscillator.prototype.set=function(t){this.isUndef(t.type)||this.setType(t.type),this.isUndef(t.phase)||this.setPhase(t.phase),this.isUndef(t.frequency)||this.frequency.setValue(t.frequency),this.isUndef(t.onended)||(this.onended=t.onended),this.isUndef(t.detune)||this.detune.setValue(t.detune)},t.Oscillator.prototype._onended=function(){this.state=t.Source.State.STOPPED,this.onended()},t.Oscillator.prototype.dispose=function(){t.Source.prototype.dispose.call(this),this.stop(),null!==this.oscillator&&(this.oscillator.disconnect(),this.oscillator=null),this.frequency.dispose(),this.detune.dispose(),this._wave=null,this.detune=null,this.frequency=null},t.Oscillator}),define("Tone/component/LFO",["Tone/core/Tone","Tone/source/Oscillator","Tone/signal/Scale","Tone/signal/Signal"],function(t){return t.LFO=function(e,i,n){this.oscillator=new t.Oscillator(this.defaultArg(e,1),"sine"),this.frequency=this.oscillator.frequency,this._scaler=new t.Scale(this.defaultArg(i,0),this.defaultArg(n,1)),this.output=this._scaler,this.chain(this.oscillator,this.output)},t.extend(t.LFO),t.LFO.prototype.start=function(t){this.oscillator.start(t)},t.LFO.prototype.stop=function(t){this.oscillator.stop(t)},t.LFO.prototype.sync=function(e){t.Transport.syncSource(this.oscillator,e),t.Transport.syncSignal(this.oscillator.frequency)},t.LFO.prototype.unsync=function(){t.Transport.unsyncSource(this.oscillator),t.Transport.unsyncSignal(this.oscillator.frequency)},t.LFO.prototype.setFrequency=function(t){this.oscillator.setFrequency(t)},t.LFO.prototype.setPhase=function(t){this.oscillator.setPhase(t)},t.LFO.prototype.setMin=function(t){this._scaler.setOutputMin(t)},t.LFO.prototype.setMax=function(t){this._scaler.setOutputMax(t)},t.LFO.prototype.setType=function(t){this.oscillator.setType(t)},t.LFO.prototype.set=function(t){this.isUndef(t.frequency)||this.setFrequency(t.frequency),this.isUndef(t.type)||this.setType(t.type),this.isUndef(t.min)||this.setMin(t.min),this.isUndef(t.max)||this.setMax(t.max)},t.LFO.prototype.connect=t.Signal.prototype.connect,t.LFO.prototype.dispose=function(){this.oscillator.dispose(),this._scaler.dispose(),this.oscillator=null,this.frequency=null,this.output=null},t.LFO}),define("Tone/component/Merge",["Tone/core/Tone"],function(t){return t.Merge=function(){this.output=this.context.createGain(),this.input=new Array(2),this.left=this.input[0]=this.context.createGain(),this.right=this.input[1]=this.context.createGain(),this._merger=this.context.createChannelMerger(2),this.left.connect(this._merger,0,0),this.right.connect(this._merger,0,1),this._merger.connect(this.output)},t.extend(t.Merge),t.Merge.prototype.dispose=function(){t.prototype.dispose.call(this),this.left.disconnect(),this.right.disconnect(),this._merger.disconnect(),this.left=null,this.right=null,this._merger=null},t.Merge}),define("Tone/core/Master",["Tone/core/Tone"],function(t){var e=function(){t.call(this),this.limiter=this.context.createDynamicsCompressor(),this.limiter.threshold.value=0,this.limiter.ratio.value=20,this.chain(this.input,this.limiter,this.output,this.context.destination)};return t.extend(e),e.prototype.mute=function(t){t=this.defaultArg(t,!0),this.output.gain.value=t?0:1},e.prototype.setVolume=function(t,e){var i=this.now();if(e){var n=this.output.gain.value;this.output.gain.cancelScheduledValues(i),this.output.gain.setValueAtTime(n,i),this.output.gain.linearRampToValueAtTime(t,i+this.toSeconds(e))}else this.output.gain.setValueAtTime(t,i)},t.prototype.toMaster=function(){this.connect(t.Master)},AudioNode.prototype.toMaster=function(){this.connect(t.Master)},t.Master=new e,t._initAudioContext(function(){e.call(t.Master)}),t.Master}),define("Tone/component/Meter",["Tone/core/Tone","Tone/core/Master"],function(t){return t.Meter=function(e,i,n){t.call(this),this.channels=this.defaultArg(e,1),this.smoothing=this.defaultArg(i,.8),this.clipMemory=this.defaultArg(n,500),this._volume=new Array(this.channels),this._values=new Array(this.channels);for(var o=0;oh;h++)o=s[h],!c&&o>.95&&(c=!0,this._lastClip=Date.now()),a+=o,r+=o*o;var l=a/e,u=Math.sqrt(r/e);this._volume[n]=Math.max(u,this._volume[n]*i),this._values[n]=l}},t.Meter.prototype.getLevel=function(t){t=this.defaultArg(t,0);var e=this._volume[t];return 1e-5>e?0:e},t.Meter.prototype.getValue=function(t){return t=this.defaultArg(t,0),this._values[t]},t.Meter.prototype.getDb=function(t){return this.gainToDb(this.getLevel(t))},t.Meter.prototype.isClipped=function(){return Date.now()-this._lastClipthis._recordEndSample?(this.state=e.STOPPED,this._callback(this._recordBuffers)):s>this._recordStartSample?(i=0,n=Math.min(this._recordEndSample-s,r),this._recordChannels(t.inputBuffer,i,n,r)):a>this._recordStartSample&&(n=a-this._recordStartSample,i=r-n,this._recordChannels(t.inputBuffer,i,n,r))}},t.Recorder.prototype._recordChannels=function(t,e,i,n){for(var o=this._recordBufferOffset,s=this._recordBuffers,r=0;rc;c++){var h=c-e;s[r][h+o]=a[c]}}this._recordBufferOffset+=i},t.Recorder.prototype.record=function(t,i,n){if(this.state===e.STOPPED){this.clear(),this._recordBufferOffset=0,i=this.defaultArg(i,0),this._recordDuration=this.toSamples(t),this._recordStartSample=this.toSamples("+"+i),this._recordEndSample=this._recordStartSample+this._recordDuration;for(var o=0;os;s++){var a=o[s];Array.isArray(n)?a.apply(window,[e].concat(n)):a(e,n)}}t.Note=function(e,i,n){this.value=n,this._channel=e,this._timelineID=t.Transport.setTimeline(this._trigger.bind(this),i)},t.Note.prototype._trigger=function(t){e(this._channel,t,this.value)},t.Note.prototype.dispose=function(){t.Tranport.clearTimeline(this._timelineID),this.value=null};var i={};return t.Note.route=function(t,e){i.hasOwnProperty(t)?i[t].push(e):i[t]=[e]},t.Note.unroute=function(t,e){if(i.hasOwnProperty(t)){var n=i[t],o=n.indexOf(e);-1!==o&&i[t].splice(o,1)}},t.Note.parseScore=function(e){var i=[];for(var n in e)for(var o=e[n],s=0;sn;n++){var o=n/e*2-1;i[n]=o>=0?Math.pow(o,t):o}this._expScaler.curve=i},t.ScaleExp.prototype.setInputMin=function(t){this._inputMin=t,this._setScalingParameters()},t.ScaleExp.prototype.setInputMax=function(t){this._inputMax=t,this._setScalingParameters()},t.ScaleExp.prototype.setOutputMin=function(t){this._outputMin=t,this._setScalingParameters()},t.ScaleExp.prototype.setOutputMax=function(t){this._outputMax=t,this._setScalingParameters()},t.ScaleExp.prototype.connect=t.Signal.prototype.connect,t.ScaleExp.prototype.dispose=function(){this.input.disconnect(),this.output.disconnect(),this._plusInput.dispose(),this._plusOutput.dispose(),this._normalize.dispose(),this._scale.dispose(),this.input=null,this.output=null,this._plusInput=null,this._plusOutput=null,this._scale=null},t.ScaleExp}),define("Tone/effect/AutoWah",["Tone/core/Tone","Tone/component/Follower","Tone/signal/ScaleExp","Tone/effect/Effect"],function(t){return t.AutoWah=function(){var e=this.optionsObject(arguments,["baseFrequency","octaves","sensitivity"],t.AutoWah.defaults);t.Effect.call(this,e),this._follower=new t.Follower(e.follower),this._sweepRange=new t.ScaleExp(0,1,0,1,.5),this._baseFrequency=e.baseFrequency,this._octaves=e.octaves,this._bandpass=new t.Filter("bandpass"),this._bandpass.setRolloff(e.rolloff),this._peaking=this.context.createBiquadFilter(),this._peaking.type="peaking",this._peaking.gain.value=e.gain,this.chain(this.effectSend,this._follower,this._sweepRange),this._sweepRange.connect(this._bandpass.frequency),this._sweepRange.connect(this._peaking.frequency),this.chain(this.effectSend,this._bandpass,this._peaking,this.effectReturn),this._setSweepRange(),this.setSensitiviy(e.sensitivity)},t.extend(t.AutoWah,t.Effect),t.AutoWah.defaults={baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,rolloff:-48,follower:{attack:.3,release:.5}},t.AutoWah.prototype.setOctaves=function(t){this._octaves=t,this._setSweepRange()},t.AutoWah.prototype.setBaseFrequency=function(t){this._baseFrequency=t,this._setSweepRange()},t.AutoWah.prototype.setSensitiviy=function(t){this._sweepRange.setInputMax(this.dbToGain(t))},t.AutoWah.prototype._setSweepRange=function(){this._sweepRange.setOutputMin(this._baseFrequency),this._sweepRange.setOutputMax(Math.min(this._baseFrequency*Math.pow(2,this._octaves),this.context.sampleRate/2))},t.AutoWah.prototype.set=function(e){this.isUndef(e.baseFrequency)||this.setBaseFrequency(e.baseFrequency),this.isUndef(e.sensitivity)||this.setSensitiviy(e.sensitivity),this.isUndef(e.octaves)||this.setOctaves(e.octaves),this.isUndef(e.follower)||this._follower.set(e.follower),this.isUndef(e.Q)||(this._bandpass.Q.value=e.Q),this.isUndef(e.gain)||(this._peaking.gain.value=e.gain),t.Effect.prototype.set.call(this,e)},t.AutoWah.prototype.dispose=function(){t.Effect.prototype.dispose.call(this),this._follower.dispose(),this._sweepRange.dispose(),this._bandpass.disconnect(),this._peaking.disconnect(),this._follower=null,this._sweepRange=null,this._bandpass=null,this._peaking=null},t.AutoWah}),define("Tone/effect/BitCrusher",["Tone/core/Tone","Tone/effect/Effect"],function(t){return t.BitCrusher=function(){var e=this.optionsObject(arguments,["bits","frequency"],t.BitCrusher.defaults);t.Effect.call(this,e),this._bits=this.defaultArg(e.bits,8),this._frequency=this.defaultArg(e.frequency,.5),this._step=2*Math.pow(.5,this._bits),this._invStep=1/this._step,this._phasor=0,this._last=0,this._crusher=this.context.createScriptProcessor(this.bufferSize,1,1),this._crusher.onaudioprocess=this._audioprocess.bind(this),this.connectEffect(this._crusher)},t.extend(t.BitCrusher,t.Effect),t.BitCrusher.defaults={bits:8,frequency:.5},t.BitCrusher.prototype._audioprocess=function(t){for(var e=this._phasor,i=this._frequency,n=this._invStep,o=this._last,s=this._step,r=t.inputBuffer.getChannelData(0),a=t.outputBuffer.getChannelData(0),c=0,h=a.length;h>c;c++)e+=i,e>=1&&(e-=1,o=s*(r[c]*n|.5)),a[c]=o;this._phasor=e,this._last=o},t.BitCrusher.prototype.setBits=function(t){this._bits=t,this._step=2*Math.pow(.5,this._bits),this._invStep=1/this._step},t.BitCrusher.prototype.setFrequency=function(t){this._frequency=t},t.BitCrusher.prototype.set=function(e){this.isUndef(e.frequency)||this.setFrequency(e.frequency),this.isUndef(e.bits)||this.setBits(e.bits),t.Effect.prototype.set.call(this,e)},t.BitCrusher.prototype.dispose=function(){t.Effect.prototype.dispose.call(this),this._crusher.disconnect(),this._crusher=null},t.BitCrusher}),define("Tone/effect/StereoEffect",["Tone/core/Tone","Tone/effect/Effect","Tone/component/Split","Tone/component/Merge"],function(t){return t.StereoEffect=function(){t.call(this);var e=this.optionsObject(arguments,["dry"],t.Effect.defaults);this.dryWet=new t.DryWet,this._mono=new t.Merge,this._split=new t.Split,this.effectSendL=this._split.left,this.effectSendR=this._split.right,this._merge=new t.Merge,this.effectReturnL=this._merge.left,this.effectReturnR=this._merge.right,this.input.connect(this._mono,0,0),this.input.connect(this._mono,0,1),this._mono.connect(this._split),this._mono.connect(this.dryWet.dry),this._merge.connect(this.dryWet.wet),this.dryWet.connect(this.output),this.setDry(e.dry)},t.extend(t.StereoEffect,t.Effect),t.StereoEffect.prototype.dispose=function(){t.prototype.dispose.call(this),this.dryWet.dispose(),this._mono.dispose(),this._split.dispose(),this._merge.dispose(),this._mono=null,this._split=null,this._merge=null,this.effectSendL=null,this.effectSendR=null,this.effectReturnL=null,this.effectReturnR=null,this.dryWet=null},t.StereoEffect}),define("Tone/effect/FeedbackEffect",["Tone/core/Tone","Tone/effect/Effect","Tone/signal/Signal","Tone/signal/Multiply"],function(t){return t.FeedbackEffect=function(){var e=this.optionsObject(arguments,["feedback"]);e=this.defaultArg(e,t.FeedbackEffect.defaults),t.Effect.call(this,e),this.feedback=new t.Signal(e.feedback),this._half=new t.Multiply(.5),this._feedbackGain=this.context.createGain(),this.chain(this.effectReturn,this._feedbackGain,this.effectSend),this.chain(this.feedback,this._half,this._feedbackGain.gain)},t.extend(t.FeedbackEffect,t.Effect),t.FeedbackEffect.defaults={feedback:.25},t.FeedbackEffect.prototype.setFeedback=function(t,e){e?this.feedback.linearRampToValueNow(t,e):this.feedback.setValue(t)},t.FeedbackEffect.prototype.set=function(e){this.isUndef(e.feedback)||this.setFeedback(e.feedback),t.Effect.prototype.set.call(this,e)},t.FeedbackEffect.prototype.dispose=function(){t.Effect.prototype.dispose.call(this),this.feedback.dispose(),this._half.dispose(),this._feedbackGain.disconnect(),this.feedback=null,this._feedbackGain=null,this._half=null},t.FeedbackEffect}),define("Tone/effect/StereoXFeedbackEffect",["Tone/core/Tone","Tone/effect/StereoEffect","Tone/effect/FeedbackEffect"],function(t){return t.StereoXFeedbackEffect=function(){var e=this.optionsObject(arguments,["feedback"],t.FeedbackEffect.defaults);t.StereoEffect.call(this,e),this.feedback=new t.Signal(e.feedback),this._half=new t.Multiply(.5),this._feedbackLR=this.context.createGain(),this._feedbackRL=this.context.createGain(),this.chain(this.effectReturnL,this._feedbackLR,this.effectSendR),this.chain(this.effectReturnR,this._feedbackRL,this.effectSendL),this.feedback.connect(this._half),this.fan(this._half,this._feedbackLR.gain,this._feedbackRL.gain)},t.extend(t.StereoXFeedbackEffect,t.FeedbackEffect),t.StereoXFeedbackEffect.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this),this.feedback.dispose(),this._half.dispose(),this._feedbackLR.disconnect(),this._feedbackRL.disconnect(),this.feedback=null,this._feedbackLR=null,this._feedbackRL=null,this._half=null},t.StereoXFeedbackEffect}),define("Tone/effect/Chorus",["Tone/core/Tone","Tone/component/LFO","Tone/effect/StereoXFeedbackEffect"],function(t){return t.Chorus=function(){var e=this.optionsObject(arguments,["rate","delayTime","depth"],t.Chorus.defaults);t.StereoXFeedbackEffect.call(this,e),this._depth=e.depth,this._delayTime=e.delayTime/1e3,this._lfoL=new t.LFO(e.rate,0,1),this._lfoR=new t.LFO(e.rate,0,1),this._lfoR.setPhase(180),this._delayNodeL=this.context.createDelay(),this._delayNodeR=this.context.createDelay(),this.chain(this.effectSendL,this._delayNodeL,this.effectReturnL),this.chain(this.effectSendR,this._delayNodeR,this.effectReturnR),this.effectSendL.connect(this.effectReturnL),this.effectSendR.connect(this.effectReturnR),this._lfoL.connect(this._delayNodeL.delayTime),this._lfoR.connect(this._delayNodeR.delayTime),this._lfoL.start(),this._lfoR.start(),this._lfoL.frequency.connect(this._lfoR.frequency),this.setDepth(this._depth),this.setRate(e.rate),this.setType(e.type)},t.extend(t.Chorus,t.StereoXFeedbackEffect),t.Chorus.defaults={rate:1.5,delayTime:3.5,depth:.7,feedback:.4,type:"sine"},t.Chorus.prototype.setDepth=function(t){this._depth=t;var e=this._delayTime*t;this._lfoL.setMin(this._delayTime-e),this._lfoL.setMax(this._delayTime+e),this._lfoR.setMin(this._delayTime-e),this._lfoR.setMax(this._delayTime+e)},t.Chorus.prototype.setDelayTime=function(t){this._delayTime=t/1e3,this.setDepth(this._depth)},t.Chorus.prototype.setRate=function(t){this._lfoL.setFrequency(t)},t.Chorus.prototype.setType=function(t){this._lfoL.setType(t),this._lfoR.setType(t)},t.Chorus.prototype.set=function(e){this.isUndef(e.rate)||this.setRate(e.rate),this.isUndef(e.delayTime)||this.setDelayTime(e.delayTime),this.isUndef(e.depth)||this.setDepth(e.depth),this.isUndef(e.type)||this.setType(e.type),t.FeedbackEffect.prototype.set.call(this,e)},t.Chorus.prototype.dispose=function(){t.StereoXFeedbackEffect.prototype.dispose.call(this),this._lfoL.dispose(),this._lfoR.dispose(),this._delayNodeL.disconnect(),this._delayNodeR.disconnect(),this._lfoL=null,this._lfoR=null,this._delayNodeL=null,this._delayNodeR=null},t.Chorus}),define("Tone/effect/FeedbackDelay",["Tone/core/Tone","Tone/effect/FeedbackEffect","Tone/signal/Signal"],function(t){return t.FeedbackDelay=function(){var e=this.optionsObject(arguments,["delayTime"],t.FeedbackDelay.defaults);t.FeedbackEffect.call(this,e),this.delayTime=new t.Signal,this._delayNode=this.context.createDelay(4),this.connectEffect(this._delayNode),this.delayTime.connect(this._delayNode.delayTime),this.setDelayTime(e.delayTime)},t.extend(t.FeedbackDelay,t.FeedbackEffect),t.FeedbackDelay.defaults={delayTime:.25},t.FeedbackDelay.prototype.setDelayTime=function(t,e){e?this.delayTime.linearRampToValueNow(this.toSeconds(t),e):this.delayTime.setValue(this.toSeconds(t))},t.FeedbackDelay.prototype.set=function(e){this.isUndef(e.delayTime)||this.setDelayTime(e.delayTime),t.FeedbackEffect.prototype.set.call(this,e) +},t.FeedbackDelay.prototype.dispose=function(){t.FeedbackEffect.prototype.dispose.call(this),this.delayTime.dispose(),this._delayNode.disconnect(),this._delayNode=null,this.delayTime=null},t.FeedbackDelay}),define("Tone/effect/StereoFeedbackEffect",["Tone/core/Tone","Tone/effect/StereoEffect","Tone/effect/FeedbackEffect"],function(t){return t.StereoFeedbackEffect=function(){var e=this.optionsObject(arguments,["feedback"],t.FeedbackEffect.defaults);t.StereoEffect.call(this,e),this.feedback=new t.Signal(e.feedback),this._half=new t.Multiply(.5),this._feedbackL=this.context.createGain(),this._feedbackR=this.context.createGain(),this.chain(this.effectReturnL,this._feedbackL,this.effectSendL),this.chain(this.effectReturnR,this._feedbackR,this.effectSendR),this.feedback.connect(this._half),this.fan(this._half,this._feedbackL.gain,this._feedbackR.gain)},t.extend(t.StereoFeedbackEffect,t.FeedbackEffect),t.StereoFeedbackEffect.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this),this.feedback.dispose(),this._half.dispose(),this._feedbackL.disconnect(),this._feedbackR.disconnect(),this.feedback=null,this._feedbackL=null,this._feedbackR=null,this._half=null},t.StereoFeedbackEffect}),define("Tone/effect/Phaser",["Tone/core/Tone","Tone/component/LFO","Tone/effect/FeedbackEffect","Tone/component/Filter","Tone/effect/StereoFeedbackEffect"],function(t){return t.Phaser=function(){var e=this.optionsObject(arguments,["rate","depth","baseFrequency"],t.Phaser.defaults);t.StereoFeedbackEffect.call(this,e),this._lfoL=new t.LFO(e.rate,0,1),this._lfoR=new t.LFO(e.rate,0,1),this._lfoR.setPhase(180),this._baseFrequency=e.baseFrequency,this._depth=e.depth,this._filtersL=this._makeFilters(e.stages,this._lfoL),this._filtersR=this._makeFilters(e.stages,this._lfoR,e.Q),this.effectSendL.connect(this._filtersL[0]),this.effectSendR.connect(this._filtersR[0]),this._filtersL[e.stages-1].connect(this.effectReturnL),this._filtersR[e.stages-1].connect(this.effectReturnR),this.effectSendL.connect(this.effectReturnL),this.effectSendR.connect(this.effectReturnR),this._lfoL.frequency.connect(this._lfoR.frequency),this.setBaseFrequency(e.baseFrequency),this.setDepth(e.depth),this.setRate(e.rate),this._lfoL.start(),this._lfoR.start()},t.extend(t.Phaser,t.StereoFeedbackEffect),t.Phaser.defaults={rate:.5,depth:1,stages:4,Q:6,baseFrequency:400,feedback:.6},t.Phaser.prototype._makeFilters=function(t,e,i){for(var n=new Array(t),o=0;t>o;o++){var s=this.context.createBiquadFilter();s.type="allpass",s.Q.value=i,e.connect(s.frequency),n[o]=s}return this.chain.apply(this,n),n},t.Phaser.prototype.setDepth=function(t){this._depth=t;var e=this._baseFrequency+this._baseFrequency*t;this._lfoL.setMax(e),this._lfoR.setMax(e)},t.Phaser.prototype.setBaseFrequency=function(t){this._baseFrequency=t,this._lfoL.setMin(t),this._lfoR.setMin(t),this.setDepth(this._depth)},t.Phaser.prototype.setRate=function(t){this._lfoL.setFrequency(t)},t.Phaser.prototype.set=function(e){this.isUndef(e.rate)||this.setRate(e.rate),this.isUndef(e.baseFrequency)||this.setBaseFrequency(e.baseFrequency),this.isUndef(e.depth)||this.setDepth(e.depth),t.StereoFeedbackEffect.prototype.set.call(this,e)},t.Phaser.prototype.dispose=function(){t.StereoFeedbackEffect.prototype.dispose.call(this),this._lfoL.dispose(),this._lfoR.dispose();for(var e=0;e0){var i=this.frequency.getValue();this.frequency.setValueAtTime(i,e),this.frequency.exponentialRampToValueAtTime(t,e+this.portamento)}else this.frequency.setValueAtTime(t,e)},t.Monophonic.prototype.setPortamento=function(t){this.portamento=this.toSeconds(t)},t.Monophonic.prototype.setVolume=t.Source.prototype.setVolume,t.Monophonic.prototype.set=function(t){this.isUndef(t.volume)||this.setVolume(t.volume),this.isUndef(t.portamento)||this.setPortamento(t.portamento)},t.Monophonic.prototype.setPreset=function(t){!this.isUndef(this.preset)&&this.preset.hasOwnProperty(t)&&this.set(this.preset[t])},t.Monophonic.prototype.dispose=function(){t.prototype.dispose.call(this)},t.Monophonic}),define("Tone/instrument/MonoSynth",["Tone/core/Tone","Tone/component/Envelope","Tone/source/Oscillator","Tone/signal/Signal","Tone/component/Filter","Tone/signal/Add","Tone/instrument/Monophonic"],function(t){return t.MonoSynth=function(e){e=this.defaultArg(e,this.defaults),t.Monophonic.call(this,e),this.oscillator=new t.Oscillator(0,e.oscType),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new t.Filter(e.filter),this.filterEnvelope=new t.Envelope(e.filterEnvelope),this.envelope=new t.Envelope(e.envelope),this._amplitude=this.context.createGain(),this.oscillator.connect(this.filter),this.filter.connect(this._amplitude),this.oscillator.start(),this.filterEnvelope.connect(this.filter.frequency),this.envelope.connect(this._amplitude.gain),this._amplitude.connect(this.output)},t.extend(t.MonoSynth,t.Monophonic),t.MonoSynth.prototype.defaults={oscType:"square",filter:{Q:6,frequency:4e3,type:"lowpass",rolloff:-24},envelope:{attack:.005,decay:.1,sustain:.9,release:1},filterEnvelope:{attack:.06,decay:.2,sustain:.5,release:2,min:10,max:4e3}},t.MonoSynth.prototype.triggerEnvelopeAttack=function(t,e){this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t)},t.MonoSynth.prototype.triggerEnvelopeRelease=function(t){this.envelope.triggerRelease(t),this.filterEnvelope.triggerRelease(t)},t.MonoSynth.prototype.setOscType=function(t){this.oscillator.setType(t)},t.MonoSynth.prototype.set=function(e){this.isUndef(e.detune)||this.detune.setValue(e.detune),this.isUndef(e.oscType)||this.setOscType(e.oscType),this.isUndef(e.filterEnvelope)||this.filterEnvelope.set(e.filterEnvelope),this.isUndef(e.envelope)||this.envelope.set(e.envelope),this.isUndef(e.filter)||this.filter.set(e.filter),t.Monophonic.prototype.set.call(this,e)},t.MonoSynth.prototype.dispose=function(){t.Monophonic.prototype.dispose.call(this),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this.detune.dispose(),this._unison.dispose(),this.oscillator=null,this.filterEnvelope=null,this.envelope=null,this.filter=null,this.detune=null,this._unison=null},t.MonoSynth}),define("Tone/instrument/DuoSynth",["Tone/core/Tone","Tone/instrument/MonoSynth","Tone/component/LFO","Tone/signal/Signal","Tone/signal/Multiply","Tone/instrument/Monophonic"],function(t){return t.DuoSynth=function(e){e=this.defaultArg(e,t.DuoSynth.defaults),t.Monophonic.call(this,e),this.voice0=new t.MonoSynth(e.voice0),this.voice0.setVolume(-10),this.voice1=new t.MonoSynth(e.voice1),this.voice1.setVolume(-10),this._vibrato=new t.LFO(e.vibratoRate,-50,50),this._vibrato.start(),this._vibratoGain=this.context.createGain(),this._vibratoGain.gain.value=e.vibratoAmount,this._vibratoDelay=this.toSeconds(e.vibratoDelay),this._vibratoAmount=e.vibratoAmount,this.frequency=new t.Signal(440),this._harmonicity=new t.Multiply(e.harmonicity),this.frequency.connect(this.voice0.frequency),this.chain(this.frequency,this._harmonicity,this.voice1.frequency),this._vibrato.connect(this._vibratoGain),this.fan(this._vibratoGain,this.voice0.detune,this.voice1.detune),this.voice0.connect(this.output),this.voice1.connect(this.output)},t.extend(t.DuoSynth,t.Monophonic),t.DuoSynth.defaults={vibratoAmount:.5,vibratoRate:5,vibratoDelay:1,harmonicity:1.5,voice0:{volume:-10,portamento:0,oscType:"sine",filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}},voice1:{volume:-10,portamento:0,oscType:"sine",filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}},t.DuoSynth.prototype.triggerEnvelopeAttack=function(t,e){t=this.toSeconds(t),this.voice0.envelope.triggerAttack(t,e),this.voice1.envelope.triggerAttack(t,e),this.voice0.filterEnvelope.triggerAttack(t),this.voice1.filterEnvelope.triggerAttack(t)},t.DuoSynth.prototype.triggerEnvelopeRelease=function(t){this.voice0.triggerRelease(t),this.voice1.triggerRelease(t)},t.DuoSynth.prototype.setHarmonicity=function(t){this._harmonicity.setValue(t)},t.DuoSynth.prototype.setPortamento=function(t){this.portamento=this.toSeconds(t)},t.DuoSynth.prototype.setVibratoDelay=function(t){this._vibratoDelay=this.toSeconds(t)},t.DuoSynth.prototype.setVibratoAmount=function(t){this._vibratoAmount=t,this._vibratoGain.gain.setValueAtTime(t,this.now())},t.DuoSynth.prototype.setVibratoRate=function(t){this._vibrato.setFrequency(t)},t.DuoSynth.prototype.setVolume=t.Source.prototype.setVolume,t.DuoSynth.prototype.set=function(e){this.isUndef(e.harmonicity)||this.setHarmonicity(e.harmonicity),this.isUndef(e.vibratoRate)||this.setVibratoRate(e.vibratoRate),this.isUndef(e.vibratoAmount)||this.setVibratoAmount(e.vibratoAmount),this.isUndef(e.vibratoDelay)||this.setVibratoDelay(e.vibratoDelay),this.isUndef(e.voice0)||this.voice0.set(e.voice0),this.isUndef(e.voice1)||this.voice1.set(e.voice1),t.Monophonic.prototype.set.call(this,e)},t.DuoSynth.dispose=function(){t.Monophonic.prototype.dispose.call(this),this.voice0.dispose(),this.voice1.dispose(),this.frequency.dispose(),this._vibrato.dispose(),this._vibratoGain.disconnect(),this._harmonicity.dispose(),this.voice0=null,this.voice1=null,this.frequency=null,this._vibrato=null,this._vibratoGain=null,this._harmonicity=null},t.DuoSynth}),define("Tone/instrument/FMSynth",["Tone/core/Tone","Tone/instrument/MonoSynth","Tone/signal/Signal","Tone/signal/Multiply","Tone/instrument/Monophonic"],function(t){return t.FMSynth=function(e){e=this.defaultArg(e,t.FMSynth.defaults),t.Monophonic.call(this,e),this.carrier=new t.MonoSynth(e.carrier),this.carrier.setVolume(-10),this.modulator=new t.MonoSynth(e.modulator),this.modulator.setVolume(-10),this.frequency=new t.Signal(440),this._harmonicity=new t.Multiply(e.harmonicity),this._modulationIndex=new t.Multiply(e.modulationIndex),this._modulationNode=this.context.createGain(),this.frequency.connect(this.carrier.frequency),this.chain(this.frequency,this._harmonicity,this.modulator.frequency),this.chain(this.frequency,this._modulationIndex,this._modulationNode),this.modulator.connect(this._modulationNode.gain),this._modulationNode.gain.value=0,this._modulationNode.connect(this.carrier.frequency),this.carrier.connect(this.output)},t.extend(t.FMSynth,t.Monophonic),t.FMSynth.defaults={harmonicity:3,modulationIndex:10,carrier:{volume:-10,portamento:0,oscType:"sine",envelope:{attack:.01,decay:0,sustain:1,release:.5},filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5,min:2e4,max:2e4}},modulator:{volume:-10,portamento:0,oscType:"triangle",envelope:{attack:.01,decay:0,sustain:1,release:.5},filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5,min:2e4,max:2e4}}},t.FMSynth.prototype.triggerEnvelopeAttack=function(t,e){t=this.toSeconds(t),this.carrier.envelope.triggerAttack(t,e),this.modulator.envelope.triggerAttack(t),this.carrier.filterEnvelope.triggerAttack(t),this.modulator.filterEnvelope.triggerAttack(t)},t.FMSynth.prototype.triggerEnvelopeRelease=function(t){this.carrier.triggerRelease(t),this.modulator.triggerRelease(t)},t.FMSynth.prototype.setHarmonicity=function(t){this._harmonicity.setValue(t)},t.FMSynth.prototype.setModulationIndex=function(t){this._modulationIndex.setValue(t)},t.FMSynth.prototype.set=function(e){this.isUndef(e.harmonicity)||this.setHarmonicity(e.harmonicity),this.isUndef(e.modulationIndex)||this.setModulationIndex(e.modulationIndex),this.isUndef(e.carrier)||this.carrier.set(e.carrier),this.isUndef(e.modulator)||this.modulator.set(e.modulator),t.Monophonic.prototype.set.call(this,e)},t.FMSynth.dispose=function(){t.Monophonic.prototype.dispose.call(this),this.carrier.dispose(),this.modulator.dispose(),this.frequency.dispose(),this._modulationIndex.dispose(),this._harmonicity.dispose(),this._modulationNode.disconnect(),this.carrier=null,this.modulator=null,this.frequency=null,this._modulationIndex=null,this._harmonicity=null,this._modulationNode=null},t.FMSynth}),define("Tone/source/Player",["Tone/core/Tone","Tone/source/Source"],function(t){return t.Player=function(e,i){t.Source.call(this),this._source=null,this._buffer=null,this.duration=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this._playbackRate=1,this.retrigger=!1,this.onended=function(){},e&&this.load(e,i)},t.extend(t.Player,t.Source),t.Player.prototype.load=function(t,e){if(this._buffer)e&&e(this);else{var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer";var n=this;i.onload=function(){n.context.decodeAudioData(i.response,function(t){n.setBuffer(t),e&&e(n)})},i.send()}},t.Player.prototype.setBuffer=function(t){this._buffer=t,this.duration=t.duration},t.Player.prototype.start=function(e,i,n){(this.state===t.Source.State.STOPPED||this.retrigger)&&this._buffer&&(this.state=t.Source.State.STARTED,i=this.defaultArg(i,0),this.loop&&(i=this.loopStart),n=this.defaultArg(n,this._buffer.duration-i),this._source=this.context.createBufferSource(),this._source.buffer=this._buffer,this._source.loop=this.loop,this._source.loopStart=this.loopStart,this._source.loopEnd=this.loopEnd,this._source.playbackRate.value=this._playbackRate,this._source.onended=this._onended.bind(this),this.chain(this._source,this.output),this._source.start(this.toSeconds(e),this.toSeconds(i),this.toSeconds(n)))},t.Player.prototype.stop=function(e){this.state===t.Source.State.STARTED&&this._buffer&&this._source&&(e||(this.state=t.Source.State.STOPPED),this._source.stop(this.toSeconds(e)))},t.Player.prototype.setPlaybackRate=function(t,e){this._playbackRate=t,this._source&&(e?this._source.playbackRate.exponentialRampToValueAtTime(t,this.toSeconds(e)):this._source.playbackRate.value=e)},t.Player.prototype._onended=function(){this.state=t.Source.State.STOPPED,this.onended()},t.Player.prototype.dispose=function(){t.Source.prototype.dispose.call(this),null!==this._source&&(this._source.disconnect(),this._source=null),this._buffer=null},t.Player}),define("Tone/instrument/Sampler",["Tone/core/Tone","Tone/source/Player","Tone/component/Envelope","Tone/component/Filter"],function(t){return t.Sampler=function(){var e=this.optionsObject(arguments,["url","load"],t.Sampler.defaults);this.output=this.context.createGain(),this.player=new t.Player(e.url,e.load),this.player.retrigger=!0,this.envelope=new t.Envelope(e.envelope),this.filterEnvelope=new t.Envelope(e.filterEnvelope),this.filter=new t.Filter(e.filter),this.chain(this.player,this.filter,this.output),this.envelope.connect(this.player.output.gain),this.filterEnvelope.connect(this.filter.frequency)},t.extend(t.Sampler),t.Sampler.defaults={url:null,load:function(){},envelope:{attack:.001,decay:0,sustain:1,release:.1},filterEnvelope:{attack:.001,decay:.001,sustain:1,release:.5,min:0,max:2e4},filter:{type:"lowpass"}},t.Sampler.prototype.set=function(t){this.isUndef(t.filterEnvelope)||this.filterEnvelope.set(t.filterEnvelope),this.isUndef(t.envelope)||this.envelope.set(t.envelope),this.isUndef(t.filter)||this.filter.set(t.filter)},t.Sampler.prototype.triggerAttack=function(t,e){this.player.start(t),this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t)},t.Sampler.prototype.triggerRelease=function(t){this.filterEnvelope.triggerRelease(t),this.envelope.triggerRelease(t)},t.Sampler.prototype.dispose=function(){t.prototype.dispose.call(this),this.player.dispose(),this.filterEnvelope.dispose(),this.envelope.dispose(),this.filter.dispose(),this.player=null,this.filterEnvelope=null,this.envelope=null,this.filter=null},t.Sampler}),define("Tone/instrument/MultiSampler",["Tone/core/Tone","Tone/instrument/Sampler","Tone/source/Source"],function(t){return t.MultiSampler=function(t,e){this.output=this.context.createGain(),this.samples={},this._createSamples(t,e)},t.extend(t.MultiSampler),t.MultiSampler.prototype._createSamples=function(e,i){var n={total:0,loaded:0};for(var o in e)"string"==typeof e[o]&&n.total++;var s=function(){n.loaded++,n.loaded===n.total&&i&&i()};for(var r in e){var a=e[r],c=new t.Sampler(a,s);c.connect(this.output),this.samples[r]=c}},t.MultiSampler.prototype.triggerAttack=function(t,e){this.samples.hasOwnProperty(t)&&this.samples[t].triggerAttack(e)},t.MultiSampler.prototype.triggerRelease=function(t,e){this.samples.hasOwnProperty(t)&&this.samples[t].triggerRelease(e)},t.MultiSampler.prototype.set=function(t){for(var e in this.samples)this.samples[e].set(t)},t.MultiSampler.prototype.setVolume=t.Source.prototype.setVolume,t.MultiSampler.dispose=function(){t.prototype.dispose.call(this);for(var e in this.samples)this.samples[e].dispose(),this.samples[e]=null},t.MultiSampler}),define("Tone/instrument/PolySynth",["Tone/core/Tone","Tone/instrument/MonoSynth","Tone/source/Source"],function(t){return t.PolySynth=function(){var e=this.optionsObject(arguments,["polyphony","voice","voiceOptions"],t.PolySynth.defaults);this.output=this.context.createGain(),this._voices=new Array(e.polyphony),this._freeVoices=[],this._activeVoices={};for(var i=0;i0){var o=this._freeVoices.shift();o.triggerAttack(t,e),this._activeVoices[n]=o}},t.PolySynth.prototype.triggerAttackRelease=function(t,e,i,n){i=this.toSeconds(i),this.triggerAttack(t,i,n),this.triggerRelease(i+this.toSeconds(e))},t.PolySynth.prototype.triggerRelease=function(t,e){var i=JSON.stringify(t),n=this._activeVoices[i];n&&(n.triggerRelease(e),this._freeVoices.push(n),this._activeVoices[i]=null)},t.PolySynth.prototype.set=function(t){for(var e=0;ei){var n=e;e=i,i=n}this._min=new t.Min(i),this._max=new t.Max(e),this.chain(this.input,this._min,this._max,this.output)},t.extend(t.Clip),t.Clip.prototype.setMin=function(t){this._min.setMin(t)},t.Clip.prototype.setMax=function(t){this._max.setMax(t)},t.Clip.prototype.connect=t.Signal.prototype.connect,t.Clip.prototype.dispose=function(){this._min.dispose(),this._max.dispose(),this.input.disconnect(),this.output.disconnect(),this._min=null,this._max=null,this.input=null,this.output=null},t.Clip}),define("Tone/signal/Route",["Tone/core/Tone","Tone/signal/Equal","Tone/signal/Signal"],function(t){t.Route=function(i){i=this.defaultArg(i,2),this.output=new Array(i),this.input=this.context.createGain(),this.gate=new t.Signal(0);for(var n=0;i>n;n++){var o=new e(n);this.output[n]=o,this.gate.connect(o.selecter),this.input.connect(o)}},t.extend(t.Route),t.Route.prototype.select=function(t,e){t=Math.floor(t),this.gate.setValueAtTime(t,this.toSeconds(e))},t.Route.prototype.connect=t.Signal.prototype.connect,t.Route.prototype.dispose=function(){this.input.disconnect(),this.gate.dispose();for(var t=0;tf;f++){var d=2*Math.random()-1;n=.99886*n+.0555179*d,r=.99332*r+.0750759*d,a=.969*a+.153852*d,c=.8665*c+.3104856*d,h=.55*h+.5329522*d,l=-.7616*l-.016898*d,p[f]=n+r+a+c+h+l+u+.5362*d,p[f]*=.11,u=.115926*d}}return e}(),i=function(){for(var e=t.createBuffer(2,s,o),i=0;ia;a++){var c=2*Math.random()-1;n[a]=(r+.02*c)/1.02,r=n[a],n[a]*=3.5}return e}(),n=function(){for(var e=t.createBuffer(2,s,o),i=0;ir;r++)n[r]=2*Math.random()-1;return e}()}),t.Noise}),define("Tone/source/PulseOscillator",["Tone/core/Tone","Tone/source/Source","Tone/source/Oscillator","Tone/signal/Signal","Tone/signal/Threshold"],function(t){for(var e=new Float32Array(256),i=0;128>i;i++)e[i]=-1,e[i+128]=1;return t.PulseOscillator=function(i,n){t.Source.call(this),this.width=new t.Signal(this.defaultArg(n,.5)),this._sawtooth=new t.Oscillator(i,"sawtooth"),this.frequency=this._sawtooth.frequency,this.detune=this._sawtooth.detune,this._thresh=this.context.createWaveShaper(),this._thresh.curve=e,this.chain(this._sawtooth,this._thresh,this.output),this.width.connect(this._thresh)},t.extend(t.PulseOscillator,t.Source),t.PulseOscillator.prototype.setWidth=function(t){this.width.setValue(t)},t.PulseOscillator.prototype.start=function(e){this.state===t.Source.State.STOPPED&&(e=this.toSeconds(e),this._sawtooth.start(e),this.width.output.gain.setValueAtTime(1,e),this.state=t.Source.State.STARTED)},t.PulseOscillator.prototype.stop=function(e){this.state===t.Source.State.STARTED&&(e=this.toSeconds(e),this._sawtooth.stop(e),this.width.output.gain.setValueAtTime(0,e),this.state=t.Source.State.STOPPED)},t.PulseOscillator.prototype.dispose=function(){this._sawtooth.dispose(),this._sawtooth=null,this.width.dispose(),this.width=null},t.PulseOscillator}) \ No newline at end of file