UNPKG

p5

Version:

[![npm version](https://badge.fury.io/js/p5.svg)](https://www.npmjs.com/package/p5)

2 lines 185 kB
/** [p5.sound] Version: 0.3.12 - 2020-01-06 */ !function(n){var i={};function o(t){if(i[t])return i[t].exports;var e=i[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}o.m=n,o.c=i,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=31)}([function(t,e,n){var i;void 0===(i=function(){"use strict";function c(t,e){this.isUndef(t)||1===t?this.input=this.context.createGain():1<t&&(this.input=new Array(t)),this.isUndef(e)||1===e?this.output=this.context.createGain():1<e&&(this.output=new Array(t))}var e;return c.prototype.set=function(t,e,n){if(this.isObject(t))n=e;else if(this.isString(t)){var i={};i[t]=e,t=i}t:for(var o in t){e=t[o];var r=this;if(-1!==o.indexOf(".")){for(var s=o.split("."),a=0;a<s.length-1;a++)if((r=r[s[a]])instanceof c){s.splice(0,a+1);var u=s.join(".");r.set(u,e);continue t}o=s[s.length-1]}var p=r[o];this.isUndef(p)||(c.Signal&&p instanceof c.Signal||c.Param&&p instanceof c.Param?p.value!==e&&(this.isUndef(n)?p.value=e:p.rampTo(e,n)):p instanceof AudioParam?p.value!==e&&(p.value=e):p instanceof c?p.set(e):p!==e&&(r[o]=e))}return this},c.prototype.get=function(t){this.isUndef(t)?t=this._collectDefaults(this.constructor):this.isString(t)&&(t=[t]);for(var e={},n=0;n<t.length;n++){var i=t[n],o=this,r=e;if(-1!==i.indexOf(".")){for(var s=i.split("."),a=0;a<s.length-1;a++){var u=s[a];r[u]=r[u]||{},r=r[u],o=o[u]}i=s[s.length-1]}var p=o[i];this.isObject(t[i])?r[i]=p.get():c.Signal&&p instanceof c.Signal?r[i]=p.value:c.Param&&p instanceof c.Param?r[i]=p.value:p instanceof AudioParam?r[i]=p.value:p instanceof c?r[i]=p.get():this.isFunction(p)||this.isUndef(p)||(r[i]=p)}return e},c.prototype._collectDefaults=function(t){var e=[];if(this.isUndef(t.defaults)||(e=Object.keys(t.defaults)),!this.isUndef(t._super))for(var n=this._collectDefaults(t._super),i=0;i<n.length;i++)-1===e.indexOf(n[i])&&e.push(n[i]);return e},c.prototype.toString=function(){for(var t in c){var e=t[0].match(/^[A-Z]$/),n=c[t]===this.constructor;if(this.isFunction(c[t])&&e&&n)return t}return"Tone"},Object.defineProperty(c.prototype,"numberOfInputs",{get:function(){return this.input?this.isArray(this.input)?this.input.length:1:0}}),Object.defineProperty(c.prototype,"numberOfOutputs",{get:function(){return this.output?this.isArray(this.output)?this.output.length:1:0}}),c.prototype.dispose=function(){return 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),this},c.prototype.connect=function(t,e,n){return Array.isArray(this.output)?(e=this.defaultArg(e,0),this.output[e].connect(t,0,n)):this.output.connect(t,e,n),this},c.prototype.disconnect=function(t,e,n){this.isArray(this.output)?this.isNumber(t)?this.output[t].disconnect():(e=this.defaultArg(e,0),this.output[e].disconnect(t,0,n)):this.output.disconnect.apply(this.output,arguments)},c.prototype.connectSeries=function(){if(1<arguments.length)for(var t=arguments[0],e=1;e<arguments.length;e++){var n=arguments[e];t.connect(n),t=n}return this},c.prototype.chain=function(){if(0<arguments.length)for(var t=this,e=0;e<arguments.length;e++){var n=arguments[e];t.connect(n),t=n}return this},c.prototype.fan=function(){if(0<arguments.length)for(var t=0;t<arguments.length;t++)this.connect(arguments[t]);return this},AudioNode.prototype.chain=c.prototype.chain,AudioNode.prototype.fan=c.prototype.fan,c.prototype.defaultArg=function(t,e){if(this.isObject(t)&&this.isObject(e)){var n={};for(var i in t)n[i]=this.defaultArg(e[i],t[i]);for(var o in e)n[o]=this.defaultArg(t[o],e[o]);return n}return this.isUndef(t)?e:t},c.prototype.optionsObject=function(t,e,n){var i={};if(1===t.length&&this.isObject(t[0]))i=t[0];else for(var o=0;o<e.length;o++)i[e[o]]=t[o];return this.isUndef(n)?i:this.defaultArg(i,n)},c.prototype.isUndef=function(t){return void 0===t},c.prototype.isFunction=function(t){return"function"==typeof t},c.prototype.isNumber=function(t){return"number"==typeof t},c.prototype.isObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)&&t.constructor===Object},c.prototype.isBoolean=function(t){return"boolean"==typeof t},c.prototype.isArray=function(t){return Array.isArray(t)},c.prototype.isString=function(t){return"string"==typeof t},c.noOp=function(){},c.prototype._readOnly=function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this._readOnly(t[e]);else Object.defineProperty(this,t,{writable:!1,enumerable:!0})},c.prototype._writable=function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this._writable(t[e]);else Object.defineProperty(this,t,{writable:!0})},c.State={Started:"started",Stopped:"stopped",Paused:"paused"},c.prototype.equalPowerScale=function(t){var e=.5*Math.PI;return Math.sin(t*e)},c.prototype.dbToGain=function(t){return Math.pow(2,t/6)},c.prototype.gainToDb=function(t){return Math.log(t)/Math.LN10*20},c.prototype.intervalToFrequencyRatio=function(t){return Math.pow(2,t/12)},c.prototype.now=function(){return c.context.now()},c.now=function(){return c.context.now()},c.extend=function(t,e){function n(){}c.prototype.isUndef(e)&&(e=c),n.prototype=e.prototype,t.prototype=new n,(t.prototype.constructor=t)._super=e},Object.defineProperty(c,"context",{get:function(){return e},set:function(t){e=c.Context&&t instanceof c.Context?t:new c.Context(t),c.Context&&c.Context.emit("init",e)}}),Object.defineProperty(c.prototype,"context",{get:function(){return c.context}}),c.setContext=function(t){c.context=t},Object.defineProperty(c.prototype,"blockTime",{get:function(){return 128/this.context.sampleRate}}),Object.defineProperty(c.prototype,"sampleTime",{get:function(){return 1/this.context.sampleRate}}),Object.defineProperty(c,"supported",{get:function(){var t=window.hasOwnProperty("AudioContext")||window.hasOwnProperty("webkitAudioContext"),e=window.hasOwnProperty("Promise"),n=window.hasOwnProperty("Worker");return t&&e&&n}}),c.version="r10",window.TONE_SILENCE_VERSION_LOGGING,c}.call(e,n,e,t))||(t.exports=i)},function(t,e,n){"use strict";var i,o;i=[n(17)],void 0===(o=function(t){var r=new function(){this.input=t.createGain(),this.output=t.createGain(),this.limiter=t.createDynamicsCompressor(),this.limiter.threshold.value=-3,this.limiter.ratio.value=20,this.limiter.knee.value=1,this.audiocontext=t,this.output.disconnect(),this.input.connect(this.limiter),this.limiter.connect(this.output),this.meter=t.createGain(),this.fftMeter=t.createGain(),this.output.connect(this.meter),this.output.connect(this.fftMeter),this.output.connect(this.audiocontext.destination),this.soundArray=[],this.parts=[],this.extensions=[]};return p5.prototype.getMasterVolume=function(){return r.output.gain.value},p5.prototype.masterVolume=function(t,e,n){if("number"==typeof t){e=e||0,n=n||0;var i=r.audiocontext.currentTime,o=r.output.gain.value;r.output.gain.cancelScheduledValues(i+n),r.output.gain.linearRampToValueAtTime(o,i+n),r.output.gain.linearRampToValueAtTime(t,i+n+e)}else{if(!t)return r.output.gain;t.connect(r.output.gain)}},p5.prototype.soundOut=p5.soundOut=r,p5.soundOut._silentNode=r.audiocontext.createGain(),p5.soundOut._silentNode.gain.value=0,p5.soundOut._silentNode.connect(r.audiocontext.destination),r}.apply(e,i))||(t.exports=o)},function(t,e,n){var i,o;i=[n(0),n(5),n(8),n(22),n(9)],void 0===(o=function(e){"use strict";return e.Signal=function(){var t=this.optionsObject(arguments,["value","units"],e.Signal.defaults);this.output=this._gain=this.context.createGain(),t.param=this._gain.gain,e.Param.call(this,t),this.input=this._param=this._gain.gain,this.context.getConstant(1).chain(this._gain)},e.extend(e.Signal,e.Param),e.Signal.defaults={value:0,units:e.Type.Default,convert:!0},e.Signal.prototype.connect=e.SignalBase.prototype.connect,e.Signal.prototype.dispose=function(){return e.Param.prototype.dispose.call(this),this._param=null,this._gain.disconnect(),this._gain=null,this},e.Signal}.apply(e,i))||(t.exports=o)},function(t,e,n){var i,o;i=[n(0),n(2),n(9)],void 0===(o=function(e){"use strict";return e.Multiply=function(t){this.createInsOuts(2,0),this._mult=this.input[0]=this.output=new e.Gain,this._param=this.input[1]=this.output.gain,this._param.value=this.defaultArg(t,0)},e.extend(e.Multiply,e.Signal),e.Multiply.prototype.dispose=function(){return e.prototype.dispose.call(this),this._mult.dispose(),this._mult=null,this._param=null,this},e.Multiply}.apply(e,i))||(t.exports=o)},function(t,e,n){"use strict";var i;void 0===(i=function(t){var r=n(1),e=n(51);return p5.Effect=function(){this.ac=r.audiocontext,this.input=this.ac.createGain(),this.output=this.ac.createGain(),this._drywet=new e(1),this.wet=this.ac.createGain(),this.input.connect(this._drywet.a),this.wet.connect(this._drywet.b),this._drywet.connect(this.output),this.connect(),r.soundArray.push(this)},p5.Effect.prototype.amp=function(t,e,n){e=e||0,n=n||0;var i=r.audiocontext.currentTime,o=this.output.gain.value;this.output.gain.cancelScheduledValues(i),this.output.gain.linearRampToValueAtTime(o,i+n+.001),this.output.gain.linearRampToValueAtTime(t,i+n+e+.001)},p5.Effect.prototype.chain=function(){if(0<arguments.length){this.connect(arguments[0]);for(var t=1;t<arguments.length;t+=1)arguments[t-1].connect(arguments[t])}return this},p5.Effect.prototype.drywet=function(t){return void 0!==t&&(this._drywet.fade.value=t),this._drywet.fade.value},p5.Effect.prototype.connect=function(t){var e=t||p5.soundOut.input;this.output.connect(e.input?e.input:e)},p5.Effect.prototype.disconnect=function(){this.output&&this.output.disconnect()},p5.Effect.prototype.dispose=function(){var t=r.soundArray.indexOf(this);r.soundArray.splice(t,1),this.input&&(this.input.disconnect(),delete this.input),this.output&&(this.output.disconnect(),delete this.output),this._drywet&&(this._drywet.disconnect(),delete this._drywet),this.wet&&(this.wet.disconnect(),delete this.wet),this.ac=void 0},p5.Effect}.call(e,n,e,t))||(t.exports=i)},function(t,e,n){var i,o;i=[n(0),n(19)],void 0===(o=function(t){"use strict";return t.WaveShaper=function(t,e){this._shaper=this.input=this.output=this.context.createWaveShaper(),this._curve=null,Array.isArray(t)?this.curve=t:isFinite(t)||this.isUndef(t)?this._curve=new Float32Array(this.defaultArg(t,1024)):this.isFunction(t)&&(this._curve=new Float32Array(this.defaultArg(e,1024)),this.setMap(t))},t.extend(t.WaveShaper,t.SignalBase),t.WaveShaper.prototype.setMap=function(t){for(var e=0,n=this._curve.length;e<n;e++){var i=e/(n-1)*2-1;this._curve[e]=t(i,e)}return this._shaper.curve=this._curve,this},Object.defineProperty(t.WaveShaper.prototype,"curve",{get:function(){return this._shaper.curve},set:function(t){this._curve=new Float32Array(t),this._shaper.curve=this._curve}}),Object.defineProperty(t.WaveShaper.prototype,"oversample",{get:function(){return this._shaper.oversample},set:function(t){if(-1===["none","2x","4x"].indexOf(t))throw new RangeError("Tone.WaveShaper: oversampling must be either 'none', '2x', or '4x'");this._shaper.oversample=t}}),t.WaveShaper.prototype.dispose=function(){return t.prototype.dispose.call(this),this._shaper.disconnect(),this._shaper=null,this._curve=null,this},t.WaveShaper}.apply(e,i))||(t.exports=o)},function(t,e,o){"use strict";var n;function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}void 0===(n=function(t){var u=o(1),i=o(10);p5.prototype.sampleRate=function(){return u.audiocontext.sampleRate},p5.prototype.freqToMidi=function(t){var e=Math.log(t/440)/Math.log(2);return Math.round(12*e)+69};var n=p5.prototype.midiToFreq=function(t){return 440*Math.pow(2,(t-69)/12)};function p(t,e,n){for(var i=n.length,o=0;o<i;o++)t.setUint8(e+o,n.charCodeAt(o))}return p5.prototype.soundFormats=function(){u.extensions=[];for(var t=0;t<arguments.length;t++){if(arguments[t]=arguments[t].toLowerCase(),!(-1<["mp3","wav","ogg","m4a","aac"].indexOf(arguments[t])))throw arguments[t]+" is not a valid sound format!";u.extensions.push(arguments[t])}},p5.prototype.disposeSound=function(){for(var t=0;t<u.soundArray.length;t++)u.soundArray[t].dispose()},p5.prototype.registerMethod("remove",p5.prototype.disposeSound),p5.prototype._checkFileFormats=function(t){var e;if("string"==typeof t){var n=(e=t).split(".").pop();if(-1<["mp3","wav","ogg","m4a","aac"].indexOf(n))if(p5.prototype.isFileSupported(n))e=e;else for(var i=e.split("."),o=i[i.length-1],r=0;r<u.extensions.length;r++){var s=u.extensions[r];if(p5.prototype.isFileSupported(s)){o="",2===i.length&&(o+=i[0]);for(r=1;r<=i.length-2;r++){o+="."+i[r]}e=o+=".",e=e+=s;break}}else for(r=0;r<u.extensions.length;r++){s=u.extensions[r];if(p5.prototype.isFileSupported(s)){e=e+"."+s;break}}}else if("object"===a(t))for(r=0;r<t.length;r++){s=t[r].split(".").pop();if(p5.prototype.isFileSupported(s)){e=t[r];break}}return e},p5.prototype._mathChain=function(t,e,n,i,o){for(var r in t.mathOps)t.mathOps[r]instanceof o&&(t.mathOps[r].dispose(),(n=r)<t.mathOps.length-1&&(i=t.mathOps[r+1]));return t.mathOps[n-1].disconnect(),t.mathOps[n-1].connect(e),e.connect(i),t.mathOps[n]=e,t},{convertToWav:function(t){var e,n=function(t,e){for(var n=t.length+e.length,i=new Float32Array(n),o=0,r=0;r<n;)i[r++]=t[o],i[r++]=e[o],o++;return i}(e=t.getChannelData(0),1<t.numberOfChannels?t.getChannelData(1):e),i=new window.ArrayBuffer(44+2*n.length),o=new window.DataView(i);p(o,0,"RIFF"),o.setUint32(4,36+2*n.length,!0),p(o,8,"WAVE"),p(o,12,"fmt "),o.setUint32(16,16,!0),o.setUint16(20,1,!0),o.setUint16(22,2,!0),o.setUint32(24,u.audiocontext.sampleRate,!0),o.setUint32(28,4*u.audiocontext.sampleRate,!0),o.setUint16(32,4,!0),o.setUint16(34,16,!0),p(o,36,"data"),o.setUint32(40,2*n.length,!0);for(var r=n.length,s=44,a=0;a<r;a++)o.setInt16(s,32767*n[a],!0),s+=2;return o},midiToFreq:n,noteToFreq:function(t){if("string"!=typeof t)return t;var e={A:21,B:23,C:24,D:26,E:28,F:29,G:31}[t[0].toUpperCase()];switch(e+=12*(~~t.slice(-1)-1),t[1]){case"#":e+=1;break;case"b":e-=1}return n(e)},safeBufferSize:function(t){var e=t,n=new AudioWorkletNode(u.audiocontext,i.soundFileProcessor);return n instanceof ScriptProcessorNode&&(e=n.bufferSize),n.disconnect(),n=null,e}}}.call(e,o,e,t))||(t.exports=n)},function(t,e,n){var i,o;i=[n(0),n(2),n(9)],void 0===(o=function(e){"use strict";return e.Add=function(t){this.createInsOuts(2,0),this._sum=this.input[0]=this.input[1]=this.output=new e.Gain,this._param=this.input[1]=new e.Signal(t),this._param.connect(this._sum)},e.extend(e.Add,e.Signal),e.Add.prototype.dispose=function(){return e.prototype.dispose.call(this),this._sum.dispose(),this._sum=null,this._param.dispose(),this._param=null,this},e.Add}.apply(e,i))||(t.exports=o)},function(t,e,n){var i,o;i=[n(0),n(20),n(45),n(46),n(12)],void 0===(o=function(e){return e.Type={Default:"number",Time:"time",Frequency:"frequency",TransportTime:"transportTime",Ticks:"ticks",NormalRange:"normalRange",AudioRange:"audioRange",Decibels:"db",Interval:"interval",BPM:"bpm",Positive:"positive",Cents:"cents",Degrees:"degrees",MIDI:"midi",BarsBeatsSixteenths:"barsBeatsSixteenths",Samples:"samples",Hertz:"hertz",Note:"note",Milliseconds:"milliseconds",Seconds:"seconds",Notation:"notation"},e.prototype.toSeconds=function(t){return this.isNumber(t)?t:this.isUndef(t)?this.now():this.isString(t)?new e.Time(t).toSeconds():t instanceof e.TimeBase?t.toSeconds():void 0},e.prototype.toFrequency=function(t){return this.isNumber(t)?t:this.isString(t)||this.isUndef(t)?new e.Frequency(t).valueOf():t instanceof e.TimeBase?t.toFrequency():void 0},e.prototype.toTicks=function(t){return this.isNumber(t)||this.isString(t)?new e.TransportTime(t).toTicks():this.isUndef(t)?e.Transport.ticks:t instanceof e.TimeBase?t.toTicks():void 0},e}.apply(e,i))||(t.exports=o)},function(t,e,n){var i,o;i=[n(0),n(22),n(8)],void 0===(o=function(n){"use strict";return window.GainNode&&!AudioContext.prototype.createGain&&(AudioContext.prototype.createGain=AudioContext.prototype.createGainNode),n.Gain=function(){var t=this.optionsObject(arguments,["gain","units"],n.Gain.defaults);this.input=this.output=this._gainNode=this.context.createGain(),this.gain=new n.Param({param:this._gainNode.gain,units:t.units,value:t.gain,convert:t.convert}),this._readOnly("gain")},n.extend(n.Gain),n.Gain.defaults={gain:1,convert:!0},n.Gain.prototype.dispose=function(){n.Param.prototype.dispose.call(this),this._gainNode.disconnect(),this._gainNode=null,this._writable("gain"),this.gain.dispose(),this.gain=null},n.prototype.createInsOuts=function(t,e){1===t?this.input=new n.Gain:1<t&&(this.input=new Array(t)),1===e?this.output=new n.Gain:1<e&&(this.output=new Array(t))},n.Gain}.apply(e,i))||(t.exports=o)},function(t,e){t.exports={recorderProcessor:"recorder-processor",soundFileProcessor:"sound-file-processor",amplitudeProcessor:"amplitude-processor"}},function(t,e,n){"use strict";var i;void 0===(i=function(){return function(t,e,n){var i,o,r=new Error;return r.name=t,r.originalStack=r.stack+e,i=r.stack+e,r.failedPath=n,o=(o=i.split("\n")).filter(function(t){return!t.match(/(p5.|native code|globalInit)/g)}),r.stack=o.join("\n"),r}}.call(e,n,e,t))||(t.exports=i)},function(t,e,n){var i,o;i=[n(0),n(18)],void 0===(o=function(i){function t(t,e,n){if(t.input)Array.isArray(t.input)?(i.prototype.isUndef(n)&&(n=0),this.connect(t.input[n])):this.connect(t.input,e,n);else try{t instanceof AudioNode?o.call(this,t,e,n):o.call(this,t,e)}catch(e){throw new Error("error connecting to node: "+t+"\n"+e)}}var o,r;return!window.hasOwnProperty("AudioContext")&&window.hasOwnProperty("webkitAudioContext")&&(window.AudioContext=window.webkitAudioContext),i.Context=function(t){for(var e in i.Emitter.call(this),t=t||new window.AudioContext,this._context=t,this._context)this._defineProperty(this._context,e);this._latencyHint="interactive",this._lookAhead=.1,this._updateInterval=this._lookAhead/3,this._computedUpdateInterval=0,this._worker=this._createWorker(),this._constants={}},i.extend(i.Context,i.Emitter),i.Emitter.mixin(i.Context),i.Context.prototype._defineProperty=function(e,n){this.isUndef(this[n])&&Object.defineProperty(this,n,{get:function(){return"function"==typeof e[n]?e[n].bind(e):e[n]},set:function(t){e[n]=t}})},i.Context.prototype.now=function(){return this._context.currentTime},i.Context.prototype._createWorker=function(){window.URL=window.URL||window.webkitURL;var t=new Blob(["var timeoutTime = "+(1e3*this._updateInterval).toFixed(1)+";self.onmessage = function(msg){\ttimeoutTime = parseInt(msg.data);};function tick(){\tsetTimeout(tick, timeoutTime);\tself.postMessage('tick');}tick();"]),e=URL.createObjectURL(t),n=new Worker(e);return n.addEventListener("message",function(){this.emit("tick")}.bind(this)),n.addEventListener("message",function(){var t=this.now();if(this.isNumber(this._lastUpdate)){var e=t-this._lastUpdate;this._computedUpdateInterval=Math.max(e,.97*this._computedUpdateInterval)}this._lastUpdate=t}.bind(this)),n},i.Context.prototype.getConstant=function(t){if(this._constants[t])return this._constants[t];for(var e=this._context.createBuffer(1,128,this._context.sampleRate),n=e.getChannelData(0),i=0;i<n.length;i++)n[i]=t;var o=this._context.createBufferSource();return o.channelCount=1,o.channelCountMode="explicit",o.buffer=e,o.loop=!0,o.start(0),this._constants[t]=o},Object.defineProperty(i.Context.prototype,"lag",{get:function(){var t=this._computedUpdateInterval-this._updateInterval;return Math.max(t,0)}}),Object.defineProperty(i.Context.prototype,"lookAhead",{get:function(){return this._lookAhead},set:function(t){this._lookAhead=t}}),Object.defineProperty(i.Context.prototype,"updateInterval",{get:function(){return this._updateInterval},set:function(t){this._updateInterval=Math.max(t,i.prototype.blockTime),this._worker.postMessage(Math.max(1e3*t,1))}}),Object.defineProperty(i.Context.prototype,"latencyHint",{get:function(){return this._latencyHint},set:function(t){var e=t;if(this._latencyHint=t,this.isString(t))switch(t){case"interactive":e=.1,this._context.latencyHint=t;break;case"playback":e=.8,this._context.latencyHint=t;break;case"balanced":e=.25,this._context.latencyHint=t;break;case"fastest":e=.01}this.lookAhead=e,this.updateInterval=e/3}}),i.supported&&(o=AudioNode.prototype.connect,r=AudioNode.prototype.disconnect,AudioNode.prototype.connect!==t&&(AudioNode.prototype.connect=t,AudioNode.prototype.disconnect=function(t,e,n){if(t&&t.input&&Array.isArray(t.input))i.prototype.isUndef(n)&&(n=0),this.disconnect(t.input[n],e,n);else if(t&&t.input)this.disconnect(t.input,e,n);else try{r.apply(this,arguments)}catch(e){throw new Error("error disconnecting node: "+t+"\n"+e)}}),i.context=new i.Context),i.Context}.apply(e,i))||(t.exports=o)},function(t,e,n){var i,o;i=[n(0),n(7),n(3),n(2)],void 0===(o=function(n){"use strict";return n.Scale=function(t,e){this._outputMin=this.defaultArg(t,0),this._outputMax=this.defaultArg(e,1),this._scale=this.input=new n.Multiply(1),this._add=this.output=new n.Add(0),this._scale.connect(this._add),this._setRange()},n.extend(n.Scale,n.SignalBase),Object.defineProperty(n.Scale.prototype,"min",{get:function(){return this._outputMin},set:function(t){this._outputMin=t,this._setRange()}}),Object.defineProperty(n.Scale.prototype,"max",{get:function(){return this._outputMax},set:function(t){this._outputMax=t,this._setRange()}}),n.Scale.prototype._setRange=function(){this._add.value=this._outputMin,this._scale.value=this._outputMax-this._outputMin},n.Scale.prototype.dispose=function(){return n.prototype.dispose.call(this),this._add.dispose(),this._add=null,this._scale.dispose(),this._scale=null,this},n.Scale}.apply(e,i))||(t.exports=o)},function(t,e,n){var i,o;i=[n(0),n(2),n(24)],void 0===(o=function(u){"use strict";return u.TimelineSignal=function(){var t=this.optionsObject(arguments,["value","units"],u.Signal.defaults);this._events=new u.Timeline(10),u.Signal.apply(this,t),t.param=this._param,u.Param.call(this,t),this._initial=this._fromUnits(this._param.value)},u.extend(u.TimelineSignal,u.Param),u.TimelineSignal.Type={Linear:"linear",Exponential:"exponential",Target:"target",Curve:"curve",Set:"set"},Object.defineProperty(u.TimelineSignal.prototype,"value",{get:function(){var t=this.now(),e=this.getValueAtTime(t);return this._toUnits(e)},set:function(t){var e=this._fromUnits(t);this._initial=e,this.cancelScheduledValues(),this._param.value=e}}),u.TimelineSignal.prototype.setValueAtTime=function(t,e){return t=this._fromUnits(t),e=this.toSeconds(e),this._events.add({type:u.TimelineSignal.Type.Set,value:t,time:e}),this._param.setValueAtTime(t,e),this},u.TimelineSignal.prototype.linearRampToValueAtTime=function(t,e){return t=this._fromUnits(t),e=this.toSeconds(e),this._events.add({type:u.TimelineSignal.Type.Linear,value:t,time:e}),this._param.linearRampToValueAtTime(t,e),this},u.TimelineSignal.prototype.exponentialRampToValueAtTime=function(t,e){e=this.toSeconds(e);var n=this._searchBefore(e);n&&0===n.value&&this.setValueAtTime(this._minOutput,n.time),t=this._fromUnits(t);var i=Math.max(t,this._minOutput);return this._events.add({type:u.TimelineSignal.Type.Exponential,value:i,time:e}),t<this._minOutput?(this._param.exponentialRampToValueAtTime(this._minOutput,e-this.sampleTime),this.setValueAtTime(0,e)):this._param.exponentialRampToValueAtTime(t,e),this},u.TimelineSignal.prototype.setTargetAtTime=function(t,e,n){return t=this._fromUnits(t),t=Math.max(this._minOutput,t),n=Math.max(this._minOutput,n),e=this.toSeconds(e),this._events.add({type:u.TimelineSignal.Type.Target,value:t,time:e,constant:n}),this._param.setTargetAtTime(t,e,n),this},u.TimelineSignal.prototype.setValueCurveAtTime=function(t,e,n,i){i=this.defaultArg(i,1);for(var o=new Array(t.length),r=0;r<o.length;r++)o[r]=this._fromUnits(t[r])*i;e=this.toSeconds(e),n=this.toSeconds(n),this._events.add({type:u.TimelineSignal.Type.Curve,value:o,time:e,duration:n}),this._param.setValueAtTime(o[0],e);for(var s=1;s<o.length;s++){var a=e+s/(o.length-1)*n;this._param.linearRampToValueAtTime(o[s],a)}return this},u.TimelineSignal.prototype.cancelScheduledValues=function(t){return t=this.toSeconds(t),this._events.cancel(t),this._param.cancelScheduledValues(t),this},u.TimelineSignal.prototype.setRampPoint=function(t){t=this.toSeconds(t);var e=this._toUnits(this.getValueAtTime(t)),n=this._searchBefore(t);if(n&&n.time===t)this.cancelScheduledValues(t+this.sampleTime);else if(n&&n.type===u.TimelineSignal.Type.Curve&&n.time+n.duration>t)this.cancelScheduledValues(t),this.linearRampToValueAtTime(e,t);else{var i=this._searchAfter(t);i&&(this.cancelScheduledValues(t),i.type===u.TimelineSignal.Type.Linear?this.linearRampToValueAtTime(e,t):i.type===u.TimelineSignal.Type.Exponential&&this.exponentialRampToValueAtTime(e,t)),this.setValueAtTime(e,t)}return this},u.TimelineSignal.prototype.linearRampToValueBetween=function(t,e,n){return this.setRampPoint(e),this.linearRampToValueAtTime(t,n),this},u.TimelineSignal.prototype.exponentialRampToValueBetween=function(t,e,n){return this.setRampPoint(e),this.exponentialRampToValueAtTime(t,n),this},u.TimelineSignal.prototype._searchBefore=function(t){return this._events.get(t)},u.TimelineSignal.prototype._searchAfter=function(t){return this._events.getAfter(t)},u.TimelineSignal.prototype.getValueAtTime=function(t){t=this.toSeconds(t);var e=this._searchAfter(t),n=this._searchBefore(t),i=this._initial;if(null===n)i=this._initial;else if(n.type===u.TimelineSignal.Type.Target){var o,r=this._events.getBefore(n.time);o=null===r?this._initial:r.value,i=this._exponentialApproach(n.time,o,n.value,n.constant,t)}else i=n.type===u.TimelineSignal.Type.Curve?this._curveInterpolate(n.time,n.value,n.duration,t):null===e?n.value:e.type===u.TimelineSignal.Type.Linear?this._linearInterpolate(n.time,n.value,e.time,e.value,t):e.type===u.TimelineSignal.Type.Exponential?this._exponentialInterpolate(n.time,n.value,e.time,e.value,t):n.value;return i},u.TimelineSignal.prototype.connect=u.SignalBase.prototype.connect,u.TimelineSignal.prototype._exponentialApproach=function(t,e,n,i,o){return n+(e-n)*Math.exp(-(o-t)/i)},u.TimelineSignal.prototype._linearInterpolate=function(t,e,n,i,o){return e+(o-t)/(n-t)*(i-e)},u.TimelineSignal.prototype._exponentialInterpolate=function(t,e,n,i,o){return(e=Math.max(this._minOutput,e))*Math.pow(i/e,(o-t)/(n-t))},u.TimelineSignal.prototype._curveInterpolate=function(t,e,n,i){var o=e.length;if(t+n<=i)return e[o-1];if(i<=t)return e[0];var r=(i-t)/n,s=Math.floor((o-1)*r),a=Math.ceil((o-1)*r),u=e[s],p=e[a];return a===s?u:this._linearInterpolate(s,u,a,p,r*(o-1))},u.TimelineSignal.prototype.dispose=function(){u.Signal.prototype.dispose.call(this),u.Param.prototype.dispose.call(this),this._events.dispose(),this._events=null},u.TimelineSignal}.apply(e,i))||(t.exports=o)},function(t,e,n){"use strict";var i;void 0===(i=function(t){var e=n(4);return p5.Filter=function(t){e.call(this),this.biquad=this.ac.createBiquadFilter(),this.input.connect(this.biquad),this.biquad.connect(this.wet),t&&this.setType(t),this._on=!0,this._untoggledType=this.biquad.type},p5.Filter.prototype=Object.create(e.prototype),p5.Filter.prototype.process=function(t,e,n,i){t.connect(this.input),this.set(e,n,i)},p5.Filter.prototype.set=function(t,e,n){t&&this.freq(t,n),e&&this.res(e,n)},p5.Filter.prototype.freq=function(t,e){var n=e||0;return t<=0&&(t=1),"number"==typeof t?(this.biquad.frequency.cancelScheduledValues(this.ac.currentTime+.01+n),this.biquad.frequency.exponentialRampToValueAtTime(t,this.ac.currentTime+.02+n)):t&&t.connect(this.biquad.frequency),this.biquad.frequency.value},p5.Filter.prototype.res=function(t,e){var n=e||0;return"number"==typeof t?(this.biquad.Q.value=t,this.biquad.Q.cancelScheduledValues(this.ac.currentTime+.01+n),this.biquad.Q.linearRampToValueAtTime(t,this.ac.currentTime+.02+n)):t&&t.connect(this.biquad.Q),this.biquad.Q.value},p5.Filter.prototype.gain=function(t,e){var n=e||0;return"number"==typeof t?(this.biquad.gain.value=t,this.biquad.gain.cancelScheduledValues(this.ac.currentTime+.01+n),this.biquad.gain.linearRampToValueAtTime(t,this.ac.currentTime+.02+n)):t&&t.connect(this.biquad.gain),this.biquad.gain.value},p5.Filter.prototype.toggle=function(){return this._on=!this._on,!0===this._on?this.biquad.type=this._untoggledType:!1===this._on&&(this.biquad.type="allpass"),this._on},p5.Filter.prototype.setType=function(t){this.biquad.type=t,this._untoggledType=this.biquad.type},p5.Filter.prototype.dispose=function(){e.prototype.dispose.apply(this),this.biquad&&(this.biquad.disconnect(),delete this.biquad)},p5.LowPass=function(){p5.Filter.call(this,"lowpass")},p5.LowPass.prototype=Object.create(p5.Filter.prototype),p5.HighPass=function(){p5.Filter.call(this,"highpass")},p5.HighPass.prototype=Object.create(p5.Filter.prototype),p5.BandPass=function(){p5.Filter.call(this,"bandpass")},p5.BandPass.prototype=Object.create(p5.Filter.prototype),p5.Filter}.call(e,n,e,t))||(t.exports=i)},function(t,e,n){var i,o;i=[n(0),n(7),n(25),n(2),n(9)],void 0===(o=function(e){"use strict";return e.Subtract=function(t){this.createInsOuts(2,0),this._sum=this.input[0]=this.output=new e.Gain,this._neg=new e.Negate,this._param=this.input[1]=new e.Signal(t),this._param.chain(this._neg,this._sum)},e.extend(e.Subtract,e.Signal),e.Subtract.prototype.dispose=function(){return e.prototype.dispose.call(this),this._neg.dispose(),this._neg=null,this._sum.disconnect(),this._sum=null,this._param.dispose(),this._param=null,this},e.Subtract}.apply(e,i))||(t.exports=o)},function(i,o,r){"use strict";(function(t){var e,n;t.TONE_SILENCE_VERSION_LOGGING=!0,e=[r(35),r(12),r(0)],void 0===(n=function(i,t,e){var o=new window.AudioContext;return e.context.dispose(),e.setContext(o),p5.prototype.getAudioContext=function(){return o},p5.prototype.userStartAudio=function(t,e){var n=t;return t instanceof p5.Element?n=t.elt:t instanceof Array&&t[0]instanceof p5.Element&&(n=t.map(function(t){return t.elt})),i(o,n,e)},o}.apply(o,e))||(i.exports=n)}).call(this,r(34))},function(t,e,n){var i,o;i=[n(0)],void 0===(o=function(s){"use strict";return s.Emitter=function(){this._events={}},s.extend(s.Emitter),s.Emitter.prototype.on=function(t,e){for(var n=t.split(/\W+/),i=0;i<n.length;i++){var o=n[i];this._events.hasOwnProperty(o)||(this._events[o]=[]),this._events[o].push(e)}return this},s.Emitter.prototype.off=function(t,e){for(var n=t.split(/\W+/),i=0;i<n.length;i++)if(t=n[i],this._events.hasOwnProperty(t))if(s.prototype.isUndef(e))this._events[t]=[];else for(var o=this._events[t],r=0;r<o.length;r++)o[r]===e&&o.splice(r,1);return this},s.Emitter.prototype.emit=function(t){if(this._events){var e=Array.apply(null,arguments).slice(1);if(this._events.hasOwnProperty(t))for(var n=this._events[t],i=0,o=n.length;i<o;i++)n[i].apply(this,e)}return this},s.Emitter.mixin=function(t){var e=["on","off","emit"];t._events={};for(var n=0;n<e.length;n++){var i=e[n],o=s.Emitter.prototype[i];t[i]=o}},s.Emitter.prototype.dispose=function(){return s.prototype.dispose.call(this),this._events=null,this},s.Emitter}.apply(e,i))||(t.exports=o)},function(t,e,n){var i,o;i=[n(0)],void 0===(o=function(i){"use strict";return i.SignalBase=function(){},i.extend(i.SignalBase),i.SignalBase.prototype.connect=function(t,e,n){return i.Signal&&i.Signal===t.constructor||i.Param&&i.Param===t.constructor||i.TimelineSignal&&i.TimelineSignal===t.constructor?(t._param.cancelScheduledValues(0),t._param.value=0,t.overridden=!0):t instanceof AudioParam&&(t.cancelScheduledValues(0),t.value=0),i.prototype.connect.call(this,t,e,n),this},i.SignalBase}.apply(e,i))||(t.exports=o)},function(t,e,n){var i,o;i=[n(0),n(21)],void 0===(o=function(n){return n.Time=function(t,e){if(!(this instanceof n.Time))return new n.Time(t,e);this._plusNow=!1,n.TimeBase.call(this,t,e)},n.extend(n.Time,n.TimeBase),n.Time.prototype._unaryExpressions=Object.create(n.TimeBase.prototype._unaryExpressions),n.Time.prototype._unaryExpressions.quantize={regexp:/^@/,method:function(t){return n.Transport.nextSubdivision(t())}},n.Time.prototype._unaryExpressions.now={regexp:/^\+/,method:function(t){return this._plusNow=!0,t()}},n.Time.prototype.quantize=function(t,e){return e=this.defaultArg(e,1),this._expr=function(t,e,n){return t=t(),e=e.toSeconds(),t+(Math.round(t/e)*e-t)*n}.bind(this,this._expr,new this.constructor(t),e),this},n.Time.prototype.addNow=function(){return this._plusNow=!0,this},n.Time.prototype._defaultExpr=function(){return this._plusNow=!0,this._noOp},n.Time.prototype.copy=function(t){return n.TimeBase.prototype.copy.call(this,t),this._plusNow=t._plusNow,this},n.Time.prototype.toNotation=function(){var t=this.toSeconds(),e=this._toNotationHelper(t,["1m","2n","4n","8n","16n","32n","64n","128n"]),n=this._toNotationHelper(t,["1m","2n","2t","4n","4t","8n","8t","16n","16t","32n","32t","64n","64t","128n"]);return n.split("+").length<e.split("+").length?n:e},n.Time.prototype._toNotationHelper=function(t,e){for(var n=this._notationToUnits(e[e.length-1]),i="",o=0;o<e.length;o++){var r=this._notationToUnits(e[o]),s=t/r;if(1-s%1<1e-6&&(s+=1e-6),0<(s=Math.floor(s))){if(i+=1===s?e[o]:s.toString()+"*"+e[o],(t-=s*r)<n)break;i+=" + "}}return""===i&&(i="0"),i},n.Time.prototype._notationToUnits=function(t){for(var e=this._primaryExpressions,n=[e.n,e.t,e.m],i=0;i<n.length;i++){var o=n[i],r=t.match(o.regexp);if(r)return o.method.call(this,r[1])}},n.Time.prototype.toBarsBeatsSixteenths=function(){var t=this._beatsToUnits(1),e=this.toSeconds()/t,n=Math.floor(e/this._timeSignature()),i=e%1*4;return e=Math.floor(e)%this._timeSignature(),3<(i=i.toString()).length&&(i=parseFloat(i).toFixed(3)),[n,e,i].join(":")},n.Time.prototype.toTicks=function(){var t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*n.Transport.PPQ)},n.Time.prototype.toSamples=function(){return this.toSeconds()*this.context.sampleRate},n.Time.prototype.toFrequency=function(){return 1/this.toSeconds()},n.Time.prototype.toSeconds=function(){return this.valueOf()},n.Time.prototype.toMilliseconds=function(){return 1e3*this.toSeconds()},n.Time.prototype.valueOf=function(){return this._expr()+(this._plusNow?this.now():0)},n.Time}.apply(e,i))||(t.exports=o)},function(t,e,n){var i,o;i=[n(0)],void 0===(o=function(i){return i.TimeBase=function(t,e){if(!(this instanceof i.TimeBase))return new i.TimeBase(t,e);if(this._expr=this._noOp,t instanceof i.TimeBase)this.copy(t);else if(!this.isUndef(e)||this.isNumber(t)){e=this.defaultArg(e,this._defaultUnits);var n=this._primaryExpressions[e].method;this._expr=n.bind(this,t)}else this.isString(t)?this.set(t):this.isUndef(t)&&(this._expr=this._defaultExpr())},i.extend(i.TimeBase),i.TimeBase.prototype.set=function(t){return this._expr=this._parseExprString(t),this},i.TimeBase.prototype.clone=function(){var t=new this.constructor;return t.copy(this),t},i.TimeBase.prototype.copy=function(t){var e=t._expr();return this.set(e)},i.TimeBase.prototype._primaryExpressions={n:{regexp:/^(\d+)n/i,method:function(t){return 1===(t=parseInt(t))?this._beatsToUnits(this._timeSignature()):this._beatsToUnits(4/t)}},t:{regexp:/^(\d+)t/i,method:function(t){return t=parseInt(t),this._beatsToUnits(8/(3*parseInt(t)))}},m:{regexp:/^(\d+)m/i,method:function(t){return this._beatsToUnits(parseInt(t)*this._timeSignature())}},i:{regexp:/^(\d+)i/i,method:function(t){return this._ticksToUnits(parseInt(t))}},hz:{regexp:/^(\d+(?:\.\d+)?)hz/i,method:function(t){return this._frequencyToUnits(parseFloat(t))}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method:function(t,e,n){var i=0;return t&&"0"!==t&&(i+=this._beatsToUnits(this._timeSignature()*parseFloat(t))),e&&"0"!==e&&(i+=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(i+=this._beatsToUnits(parseFloat(n)/4)),i}},s:{regexp:/^(\d+(?:\.\d+)?s)/,method:function(t){return this._secondsToUnits(parseFloat(t))}},samples:{regexp:/^(\d+)samples/,method:function(t){return parseInt(t)/this.context.sampleRate}},default:{regexp:/^(\d+(?:\.\d+)?)/,method:function(t){return this._primaryExpressions[this._defaultUnits].method.call(this,t)}}},i.TimeBase.prototype._binaryExpressions={"+":{regexp:/^\+/,precedence:2,method:function(t,e){return t()+e()}},"-":{regexp:/^\-/,precedence:2,method:function(t,e){return t()-e()}},"*":{regexp:/^\*/,precedence:1,method:function(t,e){return t()*e()}},"/":{regexp:/^\//,precedence:1,method:function(t,e){return t()/e()}}},i.TimeBase.prototype._unaryExpressions={neg:{regexp:/^\-/,method:function(t){return-t()}}},i.TimeBase.prototype._syntaxGlue={"(":{regexp:/^\(/},")":{regexp:/^\)/}},i.TimeBase.prototype._tokenize=function(t){for(var e=-1,n=[];0<t.length;){var i=o(t=t.trim(),this);n.push(i),t=t.substr(i.value.length)}function o(t,e){for(var n=["_binaryExpressions","_unaryExpressions","_primaryExpressions","_syntaxGlue"],i=0;i<n.length;i++){var o=e[n[i]];for(var r in o){var s=o[r],a=s.regexp,u=t.match(a);if(null!==u)return{method:s.method,precedence:s.precedence,regexp:s.regexp,value:u[0]}}}throw new SyntaxError("Tone.TimeBase: Unexpected token "+t)}return{next:function(){return n[++e]},peek:function(){return n[e+1]}}},i.TimeBase.prototype._matchGroup=function(t,e,n){if(!this.isUndef(t))for(var i in e){var o=e[i];if(o.regexp.test(t.value)){if(this.isUndef(n))return o;if(o.precedence===n)return o}}return!1},i.TimeBase.prototype._parseBinary=function(t,e){var n;this.isUndef(e)&&(e=2),n=e<0?this._parseUnary(t):this._parseBinary(t,e-1);for(var i=t.peek();i&&this._matchGroup(i,this._binaryExpressions,e);)n=(i=t.next()).method.bind(this,n,this._parseBinary(t,e-1)),i=t.peek();return n},i.TimeBase.prototype._parseUnary=function(t){var e,n;e=t.peek();var i=this._matchGroup(e,this._unaryExpressions);return i?(e=t.next(),n=this._parseUnary(t),i.method.bind(this,n)):this._parsePrimary(t)},i.TimeBase.prototype._parsePrimary=function(t){var e,n;if(e=t.peek(),this.isUndef(e))throw new SyntaxError("Tone.TimeBase: Unexpected end of expression");if(this._matchGroup(e,this._primaryExpressions)){var i=(e=t.next()).value.match(e.regexp);return e.method.bind(this,i[1],i[2],i[3])}if(e&&"("===e.value){if(t.next(),n=this._parseBinary(t),!(e=t.next())||")"!==e.value)throw new SyntaxError("Expected )");return n}throw new SyntaxError("Tone.TimeBase: Cannot process token "+e.value)},i.TimeBase.prototype._parseExprString=function(t){this.isString(t)||(t=t.toString());var e=this._tokenize(t);return this._parseBinary(e)},i.TimeBase.prototype._noOp=function(){return 0},i.TimeBase.prototype._defaultExpr=function(){return this._noOp},i.TimeBase.prototype._defaultUnits="s",i.TimeBase.prototype._frequencyToUnits=function(t){return 1/t},i.TimeBase.prototype._beatsToUnits=function(t){return 60/i.Transport.bpm.value*t},i.TimeBase.prototype._secondsToUnits=function(t){return t},i.TimeBase.prototype._ticksToUnits=function(t){return t*(this._beatsToUnits(1)/i.Transport.PPQ)},i.TimeBase.prototype._timeSignature=function(){return i.Transport.timeSignature},i.TimeBase.prototype._pushExpr=function(t,e,n){return t instanceof i.TimeBase||(t=new this.constructor(t,n)),this._expr=this._binaryExpressions[e].method.bind(this,this._expr,t._expr),this},i.TimeBase.prototype.add=function(t,e){return this._pushExpr(t,"+",e)},i.TimeBase.prototype.sub=function(t,e){return this._pushExpr(t,"-",e)},i.TimeBase.prototype.mult=function(t,e){return this._pushExpr(t,"*",e)},i.TimeBase.prototype.div=function(t,e){return this._pushExpr(t,"/",e)},i.TimeBase.prototype.valueOf=function(){return this._expr()},i.TimeBase.prototype.dispose=function(){this._expr=null},i.TimeBase}.apply(e,i))||(t.exports=o)},function(t,e,n){var i,o;i=[n(0),n(8)],void 0===(o=function(i){"use strict";return i.Param=function(){var t=this.optionsObject(arguments,["param","units","convert"],i.Param.defaults);this._param=this.input=t.param,this.units=t.units,this.convert=t.convert,this.overridden=!1,this._lfo=null,this.isObject(t.lfo)?this.value=t.lfo:this.isUndef(t.value)||(this.value=t.value)},i.extend(i.Param),i.Param.defaults={units:i.Type.Default,convert:!0,param:void 0},Object.defineProperty(i.Param.prototype,"value",{get:function(){return this._toUnits(this._param.value)},set:function(t){if(this.isObject(t)){if(this.isUndef(i.LFO))throw new Error("Include 'Tone.LFO' to use an LFO as a Param value.");this._lfo&&this._lfo.dispose(),this._lfo=new i.LFO(t).start(),this._lfo.connect(this.input)}else{var e=this._fromUnits(t);this._param.cancelScheduledValues(0),this._param.value=e}}}),i.Param.prototype._fromUnits=function(t){if(!this.convert&&!this.isUndef(this.convert))return t;switch(this.units){case i.Type.Time:return this.toSeconds(t);case i.Type.Frequency:return this.toFrequency(t);case i.Type.Decibels:return this.dbToGain(t);case i.Type.NormalRange:return Math.min(Math.max(t,0),1);case i.Type.AudioRange:return Math.min(Math.max(t,-1),1);case i.Type.Positive:return Math.max(t,0);default:return t}},i.Param.prototype._toUnits=function(t){if(!this.convert&&!this.isUndef(this.convert))return t;switch(this.units){case i.Type.Decibels:return this.gainToDb(t);default:return t}},i.Param.prototype._minOutput=1e-5,i.Param.prototype.setValueAtTime=function(t,e){return t=this._fromUnits(t),(e=this.toSeconds(e))<=this.now()+this.blockTime?this._param.value=t:this._param.setValueAtTime(t,e),this},i.Param.prototype.setRampPoint=function(t){t=this.defaultArg(t,this.now());var e=this._param.value;return 0===e&&(e=this._minOutput),this._param.setValueAtTime(e,t),this},i.Param.prototype.linearRampToValueAtTime=function(t,e){return t=this._fromUnits(t),this._param.linearRampToValueAtTime(t,this.toSeconds(e)),this},i.Param.prototype.exponentialRampToValueAtTime=function(t,e){return t=this._fromUnits(t),t=Math.max(this._minOutput,t),this._param.exponentialRampToValueAtTime(t,this.toSeconds(e)),this},i.Param.prototype.exponentialRampToValue=function(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(t,n+this.toSeconds(e)),this},i.Param.prototype.linearRampToValue=function(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(t,n+this.toSeconds(e)),this},i.Param.prototype.setTargetAtTime=function(t,e,n){return t=this._fromUnits(t),t=Math.max(this._minOutput,t),n=Math.max(this._minOutput,n),this._param.setTargetAtTime(t,this.toSeconds(e),n),this},i.Param.prototype.setValueCurveAtTime=function(t,e,n){for(var i=0;i<t.length;i++)t[i]=this._fromUnits(t[i]);return this._param.setValueCurveAtTime(t,this.toSeconds(e),this.toSeconds(n)),this},i.Param.prototype.cancelScheduledValues=function(t){return this._param.cancelScheduledValues(this.toSeconds(t)),this},i.Param.prototype.rampTo=function(t,e,n){return e=this.defaultArg(e,0),this.units===i.Type.Frequency||this.units===i.Type.BPM||this.units===i.Type.Decibels?this.exponentialRampToValue(t,e,n):this.linearRampToValue(t,e,n),this},Object.defineProperty(i.Param.prototype,"lfo",{get:function(){return this._lfo}}),i.Param.prototype.dispose=function(){return i.prototype.dispose.call(this),this._param=null,this._lfo&&(this._lfo.dispose(),this._lfo=null),this},i.Param}.apply(e,i))||(t.exports=o)},function(t,e,n){"use strict";var i;void 0===(i=function(t){var s=n(1),o=n(7),r=n(3),p=n(13);p5.Oscillator=function(t,e){if("string"==typeof t){var n=e;e=t,t=n}if("number"==typeof e){n=e;e=t,t=n}this.started=!1,this.phaseAmount=void 0,this.oscillator=s.audiocontext.createOscillator(),this.f=t||440,this.oscillator.type=e||"sine",this.oscillator.frequency.setValueAtTime(this.f,s.audiocontext.currentTime),this.output=s.audiocontext.createGain(),this._freqMods=[],this.output.gain.value=.5,this.output.gain.setValueAtTime(.5,s.audiocontext.currentTime),this.oscillator.connect(this.output),this.panPosition=0,this.connection=s.input,this.panner=new p5.Panner(this.output,this.connection,1),this.mathOps=[this.output],s.soundArray.push(this)},p5.Oscillator.prototype.start=function(t,e){if(this.started){var n=s.audiocontext.currentTime;this.stop(n)}if(!this.started){var i=e||this.f,o=this.oscillator.type;for(var r in this.oscillator&&(this.oscillator.disconnect(),delete this.oscillator),this.oscillator=s.audiocontext.createOscillator(),this.oscillator.frequency.value=Math.abs(i),this.oscillator.type=o,this.oscillator.connect(this.output),t=t||0,this.oscillator.start(t+s.audiocontext.currentTime),this.freqNode=this.oscillator.frequency,this._freqMods)void 0!==this._freqMods[r].connect&&this._freqMods[r].connect(this.oscillator.frequency);this.started=!0}},p5.Oscillator.prototype.stop=function(t){if(this.started){var e=t||0,n=s.audiocontext.currentTime;this.oscillator.stop(e+n),this.started=!1}},p5.Oscillator.prototype.amp=function(t,e,n){if("number"==typeof t){e=e||0,n=n||0;var i=s.audiocontext.currentTime;this.output.gain.linearRampToValueAtTime(t,i+n+e)}else{if(!t)return this.output.gain;t.connect(this.output.gain)}},p5.Oscillator.prototype.fade=p5.Oscillator.prototype.amp,p5.Oscillator.prototype.getAmp=function(){return this.output.gain.value},p5.Oscillator.prototype.freq=function(t,e,n){if("number"!=typeof t||isNaN(t)){if(!t)return this.oscillator.frequency;t.output&&(t=t.output),t.connect(this.oscillator.frequency),this._freqMods.push(t)}else{this.f=t;var i=s.audiocontext.currentTime;n=n||0,e=e||0;0===e?this.oscillator.frequency.setValueAtTime(t,n+i):0<t?this.oscillator.frequency.exponentialRampToValueAtTime(t,n+e+i):this.oscillator.frequency.linearRampToValueAtTime(t,n+e+i),this.phaseAmount&&this.phase(this.phaseAmount)}},p5.Oscillator.prototype.getFreq=function(){return this.oscillator.frequency.value},p5.Oscillator.prototype.setType=function(t){this.oscillator.type=t},p5.Oscillator.prototype.getType=function(){return this.oscillator.type},p5.Oscillator.prototype.connect=function(t){t?t.hasOwnProperty("input")?(this.panner.connect(t.input),this.connection=t.input):(this.panner.connect(t),this.connection=t):this.panner.connect(s.input)},p5.Oscillator.prototype.disconnect=function(){this.output&&this.output.disconnect(),this.panner&&(this.panner.disconnect(),this.output&&this.output.connect(this.panner)),this.oscMods=[]},p5.Oscillator.prototype.pan=function(t,e){this.panPosition=t,this.panner.pan(t,e)},p5.Oscillator.prototype.getPan=function(){return this.panPosition},p5.Oscillator.prototype.dispose=function(){var t=s.soundArray.indexOf(this);if(s.soundArray.splice(t,1),this.oscillator){var e=s.audiocontext.currentTime;this.stop(e),this.disconnect(),this.panner=null,this.oscillator=null}this.osc2&&this.osc2.dispose()},p5.Oscillator.prototype.phase=function(t){var e=p5.prototype.map(t,0,1,0,1/this.f),n=s.audiocontext.currentTime;this.phaseAmount=t,this.dNode||(this.dNode=s.audiocontext.createDelay(),this.oscillator.disconnect(),this.oscillator.connect(this.dNode),this.dNode.connect(this.output)),this.dNode.delayTime.setValueAtTime(e,n)};function c(t,e,n,i,o){var r=t.oscillator;for(var s in t.mathOps)t.mathOps[s]instanceof o&&(r.disconnect(),t.mathOps[s].dispose(),(n=s)<t.mathOps.length-2&&(i=t.mathOps[s+1]));return n===t.mathOps.length-1&&t.mathOps.push(i),0<s&&(r=t.mathOps[s-1]),r.disconnect(),r.connect(e),e.connect(i),t.mathOps[n]=e,t}p5.Oscillator.prototype.add=function(t){var e=new o(t),n=this.mathOps.length-1,i=this.output;return c(this,e,n,i,o)},p5.Oscillator.prototype.mult=function(t){var e=new r(t),n=this.mathOps.length-1,i=this.output;return c(this,e,n,i,r)},p5.Oscillator.prototype.scale=function(t,e,n,i){var o,r;r=4===arguments.length?(o=p5.prototype.map(n,t,e,0,1)-.5,p5.prototype.map(i,t,e,0,1)-.5):(o=t,e);var s=new p(o,r),a=this.mathOps.length-1,u=this.output;return c(this,s,a,u,p)},p5.SinOsc=function(t){p5.Oscillator.call(this,t,"sine")},p5.SinOsc.prototype=Object.create(p5.Oscillator.prototype),p5.TriOsc=function(t){p5.Oscillator.call(this,t,"triangle")},p5.TriOsc.prototype=Object.create(p5.Oscillator.prototype),p5.SawOsc=function(t){p5.Oscillator.call(this,t,"sawtooth")},p5.SawOsc.prototype=Object.create(p5.Oscillator.prototype),p5.SqrOsc=function(t){p5.Oscillator.call(this,t,"square")},p5.SqrOsc.prototype=Object.create(p5.Oscillator.prototype)}.call(e,n,e,t))||(t.exports=i)},function(t,e,n){var i,o;i=[n(0),n(8)],void 0===(o=function(e){"use strict";return e.Timeline=function(){var t=this.optionsObject(arguments,["memory"],e.Timeline.defaults);this._timeline=[],this._toRemove=[],this._iterating=!1,this.memory=t.memory},e.extend(e.Timeline),e.Timeline.defaults={memory:1/0},Object.defineProperty(e.Timeline.prototype,"length",{get:function(){return this._timeline.length}}),e.Timeline.prototype.add=function(t){if(this.isUndef(t.time))throw new Error("Tone.Timeline: events must have a time attribute");if(this._timeline.length){var e=this._search(t.time);this._timeline.splice(e+1,0,t)}else this._timeline.push(t);if(this.length>this.memory){var n=this.length-this.memory;this._timeline.splice(0,n)}return this},e.Timeline.prototype.remove=function(t){if(this._iterating)this._toRemove.push(t);else{var e=this._timeline.indexOf(t);-1!==e&&this._timeline.splice(e,1)}return this},e.Timeline.prototype.get=function(t){var e=this._search(t);return-1!==e?this._timeline[e]:null},e.Timeline.prototype.peek=function(){return this._timeline[0]},e.Timeline.prototype.shift=function(){return this._timeline.shift()},e.Timeline.prototype.getAfter=function(t){var e=this._search(t);return e+1<this._timeline.length?this._timeline[e+1]:null},e.Timeline.prototype.getBefore=function(t){var e=this._t