-
-
Notifications
You must be signed in to change notification settings - Fork 682
/
Copy pathp5.sound.min.js
3 lines (3 loc) · 223 KB
/
p5.sound.min.js
1
2
3
/** [p5.sound] Version: 1.0.2 - 2023-05-05 */
!function(n){var i={};function r(t){var e;return(i[t]||(e=i[t]={i:t,l:!1,exports:{}},n[t].call(e.exports,e,e.exports,r),e.l=!0,e)).exports}r.m=n,r.c=i,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=40)}([function(t,e,n){n=function(){"use strict";function l(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 l.prototype.set=function(t,e,n){var i;this.isObject(t)?n=e:this.isString(t)&&((i={})[t]=e,t=i);t:for(var r in t){e=t[r];var o=this;if(-1!==r.indexOf(".")){for(var s=r.split("."),a=0;a<s.length-1;a++)if((o=o[s[a]])instanceof l){s.splice(0,a+1);var u=s.join(".");o.set(u,e);continue t}r=s[s.length-1]}var c=o[r];this.isUndef(c)||(l.Signal&&c instanceof l.Signal||l.Param&&c instanceof l.Param?c.value!==e&&(this.isUndef(n)?c.value=e:c.rampTo(e,n)):c instanceof AudioParam?c.value!==e&&(c.value=e):c instanceof l?c.set(e):c!==e&&(o[r]=e))}return this},l.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],r=this,o=e;if(-1!==i.indexOf(".")){for(var s=i.split("."),a=0;a<s.length-1;a++){var u=s[a];o[u]=o[u]||{},o=o[u],r=r[u]}i=s[s.length-1]}var c=r[i];this.isObject(t[i])?o[i]=c.get():l.Signal&&c instanceof l.Signal||l.Param&&c instanceof l.Param||c instanceof AudioParam?o[i]=c.value:c instanceof l?o[i]=c.get():this.isFunction(c)||this.isUndef(c)||(o[i]=c)}return e},l.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},l.prototype.toString=function(){for(var t in l){var e=t[0].match(/^[A-Z]$/),n=l[t]===this.constructor;if(this.isFunction(l[t])&&e&&n)return t}return"Tone"},Object.defineProperty(l.prototype,"numberOfInputs",{get:function(){return this.input?this.isArray(this.input)?this.input.length:1:0}}),Object.defineProperty(l.prototype,"numberOfOutputs",{get:function(){return this.output?this.isArray(this.output)?this.output.length:1:0}}),l.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},l.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},l.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)},l.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},l.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},l.prototype.fan=function(){if(0<arguments.length)for(var t=0;t<arguments.length;t++)this.connect(arguments[t]);return this},AudioNode.prototype.chain=l.prototype.chain,AudioNode.prototype.fan=l.prototype.fan,l.prototype.defaultArg=function(t,e){if(this.isObject(t)&&this.isObject(e)){var n,i,r={};for(n in t)r[n]=this.defaultArg(e[n],t[n]);for(i in e)r[i]=this.defaultArg(t[i],e[i]);return r}return this.isUndef(t)?e:t},l.prototype.optionsObject=function(t,e,n){var i={};if(1===t.length&&this.isObject(t[0]))i=t[0];else for(var r=0;r<e.length;r++)i[e[r]]=t[r];return this.isUndef(n)?i:this.defaultArg(i,n)},l.prototype.isUndef=function(t){return void 0===t},l.prototype.isFunction=function(t){return"function"==typeof t},l.prototype.isNumber=function(t){return"number"==typeof t},l.prototype.isObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)&&t.constructor===Object},l.prototype.isBoolean=function(t){return"boolean"==typeof t},l.prototype.isArray=function(t){return Array.isArray(t)},l.prototype.isString=function(t){return"string"==typeof t},l.noOp=function(){},l.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})},l.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})},l.State={Started:"started",Stopped:"stopped",Paused:"paused"},l.prototype.equalPowerScale=function(t){var e=.5*Math.PI;return Math.sin(t*e)},l.prototype.dbToGain=function(t){return Math.pow(2,t/6)},l.prototype.gainToDb=function(t){return Math.log(t)/Math.LN10*20},l.prototype.intervalToFrequencyRatio=function(t){return Math.pow(2,t/12)},l.prototype.now=function(){return l.context.now()},l.now=function(){return l.context.now()},l.extend=function(t,e){function n(){}l.prototype.isUndef(e)&&(e=l),n.prototype=e.prototype,t.prototype=new n,(t.prototype.constructor=t)._super=e},Object.defineProperty(l,"context",{get:function(){return e},set:function(t){e=l.Context&&t instanceof l.Context?t:new l.Context(t),l.Context&&l.Context.emit("init",e)}}),Object.defineProperty(l.prototype,"context",{get:function(){return l.context}}),l.setContext=function(t){l.context=t},Object.defineProperty(l.prototype,"blockTime",{get:function(){return 128/this.context.sampleRate}}),Object.defineProperty(l.prototype,"sampleTime",{get:function(){return 1/this.context.sampleRate}}),Object.defineProperty(l,"supported",{get:function(){var t=window.hasOwnProperty("AudioContext")||window.hasOwnProperty("webkitAudioContext"),e=window.hasOwnProperty("Promise"),n=window.hasOwnProperty("Worker");return t&&e&&n}}),l.version="r10",window.TONE_SILENCE_VERSION_LOGGING,l}.call(e,n,e,t);void 0!==n&&(t.exports=n)},function(t,e,n){n=[n(0),n(2),n(10)],e=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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(6),n(9),n(18),n(10)],e=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,n);void 0!==e&&(t.exports=e)},function(t,s,a){"use strict";!function(t){a.d(s,"b",function(){return n}),a.d(s,"c",function(){return o});var e=a(22),i=a.n(e),e=a(0),e=a.n(e),r=(a(12),t.TONE_SILENCE_VERSION_LOGGING=!0,new window.AudioContext);function n(){return r}function o(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()(r,n,e)}e.a.setContext(r),s.a=r}.call(this,a(26))},function(t,e,n){n=[n(0),n(2),n(10)],e=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,n);void 0!==e&&(t.exports=e)},function(t,e){t.exports={recorderProcessor:"recorder-processor",soundFileProcessor:"sound-file-processor",amplitudeProcessor:"amplitude-processor"}},function(t,e,n){n=[n(0),n(15)],e=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++)this._curve[e]=t(e/(n-1)*2-1,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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(2),n(21)],e=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(),t=this.getValueAtTime(t);return this._toUnits(t)},set:function(t){t=this._fromUnits(t),this._initial=t,this.cancelScheduledValues(),this._param.value=t}}),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);(n=this._searchBefore(e))&&0===n.value&&this.setValueAtTime(this._minOutput,n.time),t=this._fromUnits(t);var n=Math.max(t,this._minOutput);return this._events.add({type:u.TimelineSignal.Type.Exponential,value:n,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 r=new Array(t.length),o=0;o<r.length;o++)r[o]=this._fromUnits(t[o])*i;e=this.toSeconds(e),n=this.toSeconds(n),this._events.add({type:u.TimelineSignal.Type.Curve,value:r,time:e,duration:n}),this._param.setValueAtTime(r[0],e);for(var s=1;s<r.length;s++){var a=e+s/(r.length-1)*n;this._param.linearRampToValueAtTime(r[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);return n&&n.time===t?this.cancelScheduledValues(t+this.sampleTime):n&&n.type===u.TimelineSignal.Type.Curve&&n.time+n.duration>t?(this.cancelScheduledValues(t),this.linearRampToValueAtTime(e,t)):((n=this._searchAfter(t))&&(this.cancelScheduledValues(t),n.type===u.TimelineSignal.Type.Linear?this.linearRampToValueAtTime(e,t):n.type===u.TimelineSignal.Type.Exponential&&this.exponentialRampToValueAtTime(e,t)),this.setValueAtTime(e,t)),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,n=this._searchAfter(t),i=this._searchBefore(t);return this._initial,null===i?this._initial:i.type===u.TimelineSignal.Type.Target?(e=null===(e=this._events.getBefore(i.time))?this._initial:e.value,this._exponentialApproach(i.time,e,i.value,i.constant,t)):i.type===u.TimelineSignal.Type.Curve?this._curveInterpolate(i.time,i.value,i.duration,t):null===n?i.value:n.type===u.TimelineSignal.Type.Linear?this._linearInterpolate(i.time,i.value,n.time,n.value,t):n.type===u.TimelineSignal.Type.Exponential?this._exponentialInterpolate(i.time,i.value,n.time,n.value,t):i.value},u.TimelineSignal.prototype.connect=u.SignalBase.prototype.connect,u.TimelineSignal.prototype._exponentialApproach=function(t,e,n,i,r){return n+(e-n)*Math.exp(-(r-t)/i)},u.TimelineSignal.prototype._linearInterpolate=function(t,e,n,i,r){return e+(r-t)/(n-t)*(i-e)},u.TimelineSignal.prototype._exponentialInterpolate=function(t,e,n,i,r){return(e=Math.max(this._minOutput,e))*Math.pow(i/e,(r-t)/(n-t))},u.TimelineSignal.prototype._curveInterpolate=function(t,e,n,i){var r,o=e.length;return t+n<=i?e[o-1]:i<=t?e[0]:(i=(i-t)/n,t=Math.floor((o-1)*i),n=Math.ceil((o-1)*i),r=e[t],e=e[n],n===t?r:this._linearInterpolate(t,r,n,e,i*(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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(4),n(1),n(2)],e=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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(16),n(30),n(31),n(12)],e=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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(18),n(9)],e=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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(7),n(39),n(14),n(12)],e=function(i){"use strict";return i.Clock=function(){i.Emitter.call(this);var t=this.optionsObject(arguments,["callback","frequency"],i.Clock.defaults);this.callback=t.callback,this._nextTick=0,this._lastState=i.State.Stopped,this.frequency=new i.TimelineSignal(t.frequency,i.Type.Frequency),this._readOnly("frequency"),this.ticks=0,this._state=new i.TimelineState(i.State.Stopped),this._boundLoop=this._loop.bind(this),this.context.on("tick",this._boundLoop)},i.extend(i.Clock,i.Emitter),i.Clock.defaults={callback:i.noOp,frequency:1,lookAhead:"auto"},Object.defineProperty(i.Clock.prototype,"state",{get:function(){return this._state.getValueAtTime(this.now())}}),i.Clock.prototype.start=function(t,e){return t=this.toSeconds(t),this._state.getValueAtTime(t)!==i.State.Started&&this._state.add({state:i.State.Started,time:t,offset:e}),this},i.Clock.prototype.stop=function(t){return t=this.toSeconds(t),this._state.cancel(t),this._state.setStateAtTime(i.State.Stopped,t),this},i.Clock.prototype.pause=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)===i.State.Started&&this._state.setStateAtTime(i.State.Paused,t),this},i.Clock.prototype._loop=function(){for(var t=this.now()+this.context.lookAhead+this.context.updateInterval+2*this.context.lag;t>this._nextTick&&this._state;){var e=this._state.getValueAtTime(this._nextTick),n=(e!==this._lastState&&(this._lastState=e,n=this._state.get(this._nextTick),e===i.State.Started?(this._nextTick=n.time,this.isUndef(n.offset)||(this.ticks=n.offset),this.emit("start",n.time,this.ticks)):e===i.State.Stopped?(this.ticks=0,this.emit("stop",n.time)):e===i.State.Paused&&this.emit("pause",n.time)),this._nextTick);this.frequency&&(this._nextTick+=1/this.frequency.getValueAtTime(this._nextTick),e===i.State.Started)&&(this.callback(n),this.ticks++)}},i.Clock.prototype.getStateAtTime=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)},i.Clock.prototype.dispose=function(){i.Emitter.prototype.dispose.call(this),this.context.off("tick",this._boundLoop),this._writable("frequency"),this.frequency.dispose(),this.frequency=null,this._boundLoop=null,this._nextTick=1/0,this.callback=null,this._state.dispose(),this._state=null},i.Clock}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(14)],e=function(i){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();"]),t=URL.createObjectURL(t);return(t=new Worker(t)).addEventListener("message",function(){this.emit("tick")}.bind(this)),t.addEventListener("message",function(){var t,e=this.now();this.isNumber(this._lastUpdate)&&(t=e-this._lastUpdate,this._computedUpdateInterval=Math.max(t,.97*this._computedUpdateInterval)),this._lastUpdate=e}.bind(this)),t},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 r=this._context.createBufferSource();return r.channelCount=1,r.channelCountMode="explicit",r.buffer=e,r.loop=!0,r.start(0),this._constants[t]=r},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&&(r=AudioNode.prototype.connect,o=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{o.apply(this,arguments)}catch(e){throw new Error("error disconnecting node: "+t+"\n"+e)}}),i.context=new i.Context),i.Context;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?r.call(this,t,e,n):r.call(this,t,e)}catch(e){throw new Error("error connecting to node: "+t+"\n"+e)}}var r,o}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(4),n(19),n(2),n(10)],e=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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0)],e=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 r=n[i];this._events.hasOwnProperty(r)||(this._events[r]=[]),this._events[r].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 r=this._events[t],o=0;o<r.length;o++)r[o]===e&&r.splice(o,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,r=n.length;i<r;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],r=s.Emitter.prototype[i];t[i]=r}},s.Emitter.prototype.dispose=function(){return s.prototype.dispose.call(this),this._events=null,this},s.Emitter}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0)],e=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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(17)],e=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"]);return(t=this._toNotationHelper(t,["1m","2n","2t","4n","4t","8n","8t","16n","16t","32n","32t","64n","64t","128n"])).split("+").length<e.split("+").length?t:e},n.Time.prototype._toNotationHelper=function(t,e){for(var n=this._notationToUnits(e[e.length-1]),i="",r=0;r<e.length;r++){var o=this._notationToUnits(e[r]),s=t/o;if(1-s%1<1e-6&&(s+=1e-6),0<(s=Math.floor(s))){if(i+=1===s?e[r]:s.toString()+"*"+e[r],(t-=s*o)<n)break;i+=" + "}}return""===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 r=n[i],o=t.match(r.regexp);if(o)return r.method.call(this,o[1])}},n.Time.prototype.toBarsBeatsSixteenths=function(){var t=this._beatsToUnits(1),e=(t=this.toSeconds()/t)%1*4;return[Math.floor(t/this._timeSignature()),Math.floor(t)%this._timeSignature(),e=3<(e=e.toString()).length?parseFloat(e).toFixed(3):e].join(":")},n.Time.prototype.toTicks=function(){var t=this._beatsToUnits(1),t=this.valueOf()/t;return Math.floor(t*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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0)],e=function(i){return i.TimeBase=function(t,e){if(!(this instanceof i.TimeBase))return new i.TimeBase(t,e);this._expr=this._noOp,t instanceof i.TimeBase?this.copy(t):!this.isUndef(e)||this.isNumber(t)?(e=this.defaultArg(e,this._defaultUnits),e=this._primaryExpressions[e].method,this._expr=e.bind(this,t)):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){return t=t._expr(),this.set(t)},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=function(t,e){for(var n=["_binaryExpressions","_unaryExpressions","_primaryExpressions","_syntaxGlue"],i=0;i<n.length;i++){var r,o=e[n[i]];for(r in o){var s=o[r],a=s.regexp;if(null!==(a=t.match(a)))return{method:s.method,precedence:s.precedence,regexp:s.regexp,value:a[0]}}}throw new SyntaxError("Tone.TimeBase: Unexpected token "+t)}(t=t.trim(),this);n.push(i),t=t.substr(i.value.length)}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)if((i=e[i]).regexp.test(t.value)){if(this.isUndef(n))return i;if(i.precedence===n)return i}return!1},i.TimeBase.prototype._parseBinary=function(t,e){for(var n,n=(e=this.isUndef(e)?2:e)<0?this._parseUnary(t):this._parseBinary(t,e-1),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=t.peek();return(n=this._matchGroup(n,this._unaryExpressions))?(t.next(),e=this._parseUnary(t),n.method.bind(this,e)):this._parsePrimary(t)},i.TimeBase.prototype._parsePrimary=function(t){var e,n=t.peek();if(this.isUndef(n))throw new SyntaxError("Tone.TimeBase: Unexpected end of expression");if(this._matchGroup(n,this._primaryExpressions))return e=(n=t.next()).value.match(n.regexp),n.method.bind(this,e[1],e[2],e[3]);if(n&&"("===n.value){if(t.next(),e=this._parseBinary(t),(n=t.next())&&")"===n.value)return e;throw new SyntaxError("Expected )")}throw new SyntaxError("Tone.TimeBase: Cannot process token "+n.value)},i.TimeBase.prototype._parseExprString=function(t){return this.isString(t)||(t=t.toString()),t=this._tokenize(t),this._parseBinary(t)},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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(9)],e=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 t=this._fromUnits(t),this._param.cancelScheduledValues(0),this._param.value=t}}),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){return!this.convert&&!this.isUndef(this.convert)||this.units!==i.Type.Decibels?t:this.gainToDb(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,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(1),n(2)],e=function(t){"use strict";return t.Negate=function(){this._multiply=this.input=this.output=new t.Multiply(-1)},t.extend(t.Negate,t.SignalBase),t.Negate.prototype.dispose=function(){return t.prototype.dispose.call(this),this._multiply.dispose(),this._multiply=null,this},t.Negate}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(2),n(1),n(6)],e=function(t){"use strict";return t.GreaterThanZero=function(){this._thresh=this.output=new t.WaveShaper(function(t){return t<=0?0:1},127),this._scale=this.input=new t.Multiply(1e4),this._scale.connect(this._thresh)},t.extend(t.GreaterThanZero,t.SignalBase),t.GreaterThanZero.prototype.dispose=function(){return t.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._thresh.dispose(),this._thresh=null,this},t.GreaterThanZero}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(9)],e=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");var e;return this._timeline.length?(e=this._search(t.time),this._timeline.splice(e+1,0,t)):this._timeline.push(t),this.length>this.memory&&(e=this.length-this.memory,this._timeline.splice(0,e)),this},e.Timeline.prototype.remove=function(t){return this._iterating?this._toRemove.push(t):-1!==(t=this._timeline.indexOf(t))&&this._timeline.splice(t,1),this},e.Timeline.prototype.get=function(t){return-1!==(t=this._search(t))?this._timeline[t]: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){return(t=this._search(t))+1<this._timeline.length?this._timeline[t+1]:null},e.Timeline.prototype.getBefore=function(t){var e=this._timeline.length;return 0<e&&this._timeline[e-1].time<t||0<=(e=this._search(t))-1?this._timeline[e-1]:null},e.Timeline.prototype.cancel=function(t){if(1<this._timeline.length){var e=this._search(t);if(0<=e)if(this._timeline[e].time===t){for(var n=e;0<=n&&this._timeline[n].time===t;n--)e=n;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&this._timeline[0].time>=t&&(this._timeline=[]);return this},e.Timeline.prototype.cancelBefore=function(t){return this._timeline.length&&0<=(t=this._search(t))&&(this._timeline=this._timeline.slice(t+1)),this},e.Timeline.prototype._search=function(t){var e=0,n=this._timeline.length,i=n;if(0<n&&this._timeline[n-1].time<=t)return n-1;for(;e<i;){var r=Math.floor(e+(i-e)/2),o=this._timeline[r],s=this._timeline[r+1];if(o.time===t){for(var a=r;a<this._timeline.length;a++)this._timeline[a].time===t&&(r=a);return r}if(o.time<t&&s.time>t)return r;o.time>t?i=r:o.time<t&&(e=r+1)}return-1},e.Timeline.prototype._iterate=function(t,e,n){this._iterating=!0,e=this.defaultArg(e,0),n=this.defaultArg(n,this._timeline.length-1);for(var i=e;i<=n;i++)t(this._timeline[i]);if(this._iterating=!1,0<this._toRemove.length){for(var r=0;r<this._toRemove.length;r++){var o=this._timeline.indexOf(this._toRemove[r]);-1!==o&&this._timeline.splice(o,1)}this._toRemove=[]}},e.Timeline.prototype.forEach=function(t){return this._iterate(t),this},e.Timeline.prototype.forEachBefore=function(t,e){return-1!==(t=this._search(t))&&this._iterate(e,0,t),this},e.Timeline.prototype.forEachAfter=function(t,e){return t=this._search(t),this._iterate(e,t+1),this},e.Timeline.prototype.forEachFrom=function(t,e){for(var n=this._search(t);0<=n&&this._timeline[n].time>=t;)n--;return this._iterate(e,n+1),this},e.Timeline.prototype.forEachAtTime=function(e,n){var t=this._search(e);return-1!==t&&this._iterate(function(t){t.time===e&&n(t)},0,t),this},e.Timeline.prototype.dispose=function(){e.prototype.dispose.call(this),this._timeline=null,this._toRemove=null},e.Timeline}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){var i;void 0!==(e="function"==typeof(i=function(){var s=function(t,e){this._dragged=!1,this._element=t,this._bindedMove=this._moved.bind(this),this._bindedEnd=this._ended.bind(this,e),t.addEventListener("touchstart",this._bindedEnd),t.addEventListener("touchmove",this._bindedMove),t.addEventListener("touchend",this._bindedEnd),t.addEventListener("mouseup",this._bindedEnd)};function i(t){return"running"===t.state}function o(e,n){(i(e)?n:function t(){i(e)?n():(requestAnimationFrame(t),e.resume&&e.resume())})()}return s.prototype._moved=function(t){this._dragged=!0},s.prototype._ended=function(t){var e,n;this._dragged||(e=(t=t).createBuffer(1,1,t.sampleRate),(n=t.createBufferSource()).buffer=e,n.connect(t.destination),n.start(0),t.resume&&t.resume()),this._dragged=!1},s.prototype.dispose=function(){this._element.removeEventListener("touchstart",this._bindedEnd),this._element.removeEventListener("touchmove",this._bindedMove),this._element.removeEventListener("touchend",this._bindedEnd),this._element.removeEventListener("mouseup",this._bindedEnd),this._bindedMove=null,this._bindedEnd=null,this._element=null},function(e,t,n){var i=new Promise(function(t){o(e,t)}),r=[];return function t(e,n,i){var r;if(Array.isArray(e)||NodeList&&e instanceof NodeList)for(var o=0;o<e.length;o++)t(e[o],n,i);else"string"==typeof e?t(document.querySelectorAll(e),n,i):e.jquery&&"function"==typeof e.toArray?t(e.toArray(),n,i):Element&&e instanceof Element&&(r=new s(e,i),n.push(r))}(t=t||document.body,r,e),i.then(function(){for(var t=0;t<r.length;t++)r[t].dispose();r=null,n&&n()}),i}})?i.apply(e,[]):i)&&(t.exports=e)},function(t,e,n){n=[n(0),n(2),n(32),n(38),n(10)],e=function(e){"use strict";return e.CrossFade=function(t){this.createInsOuts(2,1),this.a=this.input[0]=new e.Gain,this.b=this.input[1]=new e.Gain,this.fade=new e.Signal(this.defaultArg(t,.5),e.Type.NormalRange),this._equalPowerA=new e.EqualPowerGain,this._equalPowerB=new e.EqualPowerGain,this._invert=new e.Expr("1 - $0"),this.a.connect(this.output),this.b.connect(this.output),this.fade.chain(this._equalPowerB,this.b.gain),this.fade.chain(this._invert,this._equalPowerA,this.a.gain),this._readOnly("fade")},e.extend(e.CrossFade),e.CrossFade.prototype.dispose=function(){return e.prototype.dispose.call(this),this._writable("fade"),this._equalPowerA.dispose(),this._equalPowerA=null,this._equalPowerB.dispose(),this._equalPowerB=null,this.fade.dispose(),this.fade=null,this._invert.dispose(),this._invert=null,this.a.dispose(),this.a=null,this.b.dispose(),this.b=null,this},e.CrossFade}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e){function u(t){var i=this,r={},o=-1,e=(this.parameters.forEach(function(t,e){var n=s[++o]||(s[o]=new Float32Array(i.bufferSize));n.fill(t.value),r[e]=n}),this.processor.realm.exec("self.sampleRate=sampleRate="+this.context.sampleRate+";self.currentTime=currentTime="+this.context.currentTime),n(t.inputBuffer)),t=n(t.outputBuffer);this.instance.process([e],[t],r)}function n(t){for(var e=[],n=0;n<t.numberOfChannels;n++)e[n]=t.getChannelData(n);return e}function c(t){return t.$$processors||(t.$$processors={})}function i(t){this.$$context=t}var l,s;s=[],"function"!=typeof AudioWorkletNode&&(self.AudioWorkletNode=function(t,e,n){var i=c(t)[e],r=t.createScriptProcessor(void 0,2,n&&n.outputChannelCount?n.outputChannelCount[0]:2);if(r.parameters=new Map,i.properties)for(var o=0;o<i.properties.length;o++){var s=i.properties[o],a=t.createGain().gain;a.value=s.defaultValue,r.parameters.set(s.name,a)}return e=new MessageChannel,l=e.port2,n=new i.Processor(n||{}),l=null,r.port=e.port1,r.processor=i,r.instance=n,r.onaudioprocess=u,r},Object.defineProperty((self.AudioContext||self.webkitAudioContext).prototype,"audioWorklet",{get:function(){return this.$$audioWorklet||(this.$$audioWorklet=new self.AudioWorklet(this))}}),self.AudioWorklet=(i.prototype.addModule=function(t,e){var r=this;return fetch(t).then(function(t){if(t.ok)return t.text();throw Error(t.status)}).then(function(t){var n={sampleRate:0,currentTime:0,AudioWorkletProcessor:function(){this.port=l},registerProcessor:function(t,e){c(r.$$context)[t]={realm:i,context:n,Processor:e,properties:e.parameterDescriptors||[]}}},i=new function(t,e){var n,i;(r=document.createElement("iframe")).style.cssText="position:absolute;left:0;top:-999px;width:1px;height:1px;",e.appendChild(r);var r=(e=r.contentWindow).document,o="var window,$hook";for(n in e)n in t||"eval"===n||(o+=",",o+=n);for(i in t)o+=",",o+=i,o+="=self.",o+=i;var s=r.createElement("script");s.appendChild(r.createTextNode('function $hook(self,console) {"use strict";\n '+o+";return function() {return eval(arguments[0])}}")),r.body.appendChild(s),this.exec=e.$hook(t,console)}(n.self=n,document.documentElement);return i.exec((e&&e.transpile||String)(t)),null})},i))},function(t,e){function n(t){!t||t.setTargetAtTime||(t.setTargetAtTime=t.setTargetValueAtTime)}window,window.hasOwnProperty("webkitAudioContext")&&!window.hasOwnProperty("AudioContext")&&(window.AudioContext=window.webkitAudioContext,"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.createScriptProcessor&&(AudioContext.prototype.createScriptProcessor=AudioContext.prototype.createJavaScriptNode),"function"!=typeof AudioContext.prototype.createPeriodicWave&&(AudioContext.prototype.createPeriodicWave=AudioContext.prototype.createWaveTable),AudioContext.prototype.internal_createGain=AudioContext.prototype.createGain,AudioContext.prototype.createGain=function(){var t=this.internal_createGain();return n(t.gain),t},AudioContext.prototype.internal_createDelay=AudioContext.prototype.createDelay,AudioContext.prototype.createDelay=function(t){t=t?this.internal_createDelay(t):this.internal_createDelay();return n(t.delayTime),t},AudioContext.prototype.internal_createBufferSource=AudioContext.prototype.createBufferSource,AudioContext.prototype.createBufferSource=function(){var i=this.internal_createBufferSource();return i.start?(i.internal_start=i.start,i.start=function(t,e,n){void 0!==n?i.internal_start(t||0,e,n):i.internal_start(t||0,e||0)}):i.start=function(t,e,n){e||n?this.noteGrainOn(t||0,e,n):this.noteOn(t||0)},i.stop?(i.internal_stop=i.stop,i.stop=function(t){i.internal_stop(t||0)}):i.stop=function(t){this.noteOff(t||0)},n(i.playbackRate),i},AudioContext.prototype.internal_createDynamicsCompressor=AudioContext.prototype.createDynamicsCompressor,AudioContext.prototype.createDynamicsCompressor=function(){var t=this.internal_createDynamicsCompressor();return n(t.threshold),n(t.knee),n(t.ratio),n(t.reduction),n(t.attack),n(t.release),t},AudioContext.prototype.internal_createBiquadFilter=AudioContext.prototype.createBiquadFilter,AudioContext.prototype.createBiquadFilter=function(){var t=this.internal_createBiquadFilter();return n(t.frequency),n(t.detune),n(t.Q),n(t.gain),t},"function"!=typeof AudioContext.prototype.createOscillator)&&(AudioContext.prototype.internal_createOscillator=AudioContext.prototype.createOscillator,AudioContext.prototype.createOscillator=function(){var e=this.internal_createOscillator();return e.start?(e.internal_start=e.start,e.start=function(t){e.internal_start(t||0)}):e.start=function(t){this.noteOn(t||0)},e.stop?(e.internal_stop=e.stop,e.stop=function(t){e.internal_stop(t||0)}):e.stop=function(t){this.noteOff(t||0)},e.setPeriodicWave||(e.setPeriodicWave=e.setWaveTable),n(e.frequency),n(e.detune),e}),window.hasOwnProperty("webkitOfflineAudioContext")&&!window.hasOwnProperty("OfflineAudioContext")&&(window.OfflineAudioContext=window.webkitOfflineAudioContext),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;var i=document.createElement("audio");p5.prototype.isSupported=function(){return!!i.canPlayType};p5.prototype.isFileSupported=function(t){switch(t.toLowerCase()){case"mp3":return!!i.canPlayType&&i.canPlayType("audio/mpeg;");case"wav":return!!i.canPlayType&&i.canPlayType('audio/wav; codecs="1"');case"ogg":return!!i.canPlayType&&i.canPlayType('audio/ogg; codecs="vorbis"');case"aac":case"m4a":case"mp4":return!!i.canPlayType&&(i.canPlayType("audio/x-m4a;")||i.canPlayType("audio/aac;"));case"aif":case"aiff":return!!i.canPlayType&&i.canPlayType("audio/x-aiff;");default:return!1}}},function(t,e){var n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e),e.default='function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called"); } return self; }\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }\n// import dependencies via preval.require so that they\'re available as values at compile time\nvar processorNames = {\n "recorderProcessor": "recorder-processor",\n "soundFileProcessor": "sound-file-processor",\n "amplitudeProcessor": "amplitude-processor"\n};\nvar RingBuffer = {\n "default": /*#__PURE__*/function () {\n /**\n * @constructor\n * @param {number} length Buffer length in frames.\n * @param {number} channelCount Buffer channel count.\n */\n function RingBuffer(length, channelCount) {\n _classCallCheck(this, RingBuffer);\n this._readIndex = 0;\n this._writeIndex = 0;\n this._framesAvailable = 0;\n this._channelCount = channelCount;\n this._length = length;\n this._channelData = [];\n for (var i = 0; i < this._channelCount; ++i) {\n this._channelData[i] = new Float32Array(length);\n }\n }\n /**\n * Getter for Available frames in buffer.\n *\n * @return {number} Available frames in buffer.\n */\n _createClass(RingBuffer, [{\n key: "framesAvailable",\n get: function get() {\n return this._framesAvailable;\n }\n /**\n * Push a sequence of Float32Arrays to buffer.\n *\n * @param {array} arraySequence A sequence of Float32Arrays.\n */\n }, {\n key: "push",\n value: function push(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // Transfer data from the |arraySequence| storage to the internal buffer.\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\n for (var i = 0; i < sourceLength; ++i) {\n var writeIndex = (this._writeIndex + i) % this._length;\n for (var channel = 0; channel < this._channelCount; ++channel) {\n if (arraySequence[channel]) this._channelData[channel][writeIndex] = arraySequence[channel][i];\n }\n }\n this._writeIndex += sourceLength;\n if (this._writeIndex >= this._length) {\n this._writeIndex = 0;\n } // For excessive frames, the buffer will be overwritten.\n this._framesAvailable += sourceLength;\n if (this._framesAvailable > this._length) {\n this._framesAvailable = this._length;\n }\n }\n /**\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\n *\n * @param {array} arraySequence An array of Float32Arrays.\n */\n }, {\n key: "pull",\n value: function pull(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // If the FIFO is completely empty, do nothing.\n if (this._framesAvailable === 0) {\n return;\n }\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\n for (var i = 0; i < destinationLength; ++i) {\n var readIndex = (this._readIndex + i) % this._length;\n for (var channel = 0; channel < this._channelCount; ++channel) {\n arraySequence[channel][i] = this._channelData[channel][readIndex];\n }\n }\n this._readIndex += destinationLength;\n if (this._readIndex >= this._length) {\n this._readIndex = 0;\n }\n this._framesAvailable -= destinationLength;\n if (this._framesAvailable < 0) {\n this._framesAvailable = 0;\n }\n }\n }]);\n return RingBuffer;\n }()\n}["default"];\nvar RecorderProcessor = /*#__PURE__*/function (_AudioWorkletProcesso) {\n _inherits(RecorderProcessor, _AudioWorkletProcesso);\n var _super = _createSuper(RecorderProcessor);\n function RecorderProcessor(options) {\n var _this;\n _classCallCheck(this, RecorderProcessor);\n _this = _super.call(this);\n var processorOptions = options.processorOptions || {};\n _this.numOutputChannels = options.outputChannelCount || 2;\n _this.numInputChannels = processorOptions.numInputChannels || 2;\n _this.bufferSize = processorOptions.bufferSize || 1024;\n _this.recording = false;\n _this.clear();\n _this.port.onmessage = function (event) {\n var data = event.data;\n if (data.name === \'start\') {\n _this.record(data.duration);\n } else if (data.name === \'stop\') {\n _this.stop();\n }\n };\n return _this;\n }\n _createClass(RecorderProcessor, [{\n key: "process",\n value: function process(inputs) {\n if (!this.recording) {\n return true;\n } else if (this.sampleLimit && this.recordedSamples >= this.sampleLimit) {\n this.stop();\n return true;\n }\n var input = inputs[0];\n this.inputRingBuffer.push(input);\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\n for (var channel = 0; channel < this.numOutputChannels; ++channel) {\n var inputChannelCopy = this.inputRingBufferArraySequence[channel].slice();\n if (channel === 0) {\n this.leftBuffers.push(inputChannelCopy);\n if (this.numInputChannels === 1) {\n this.rightBuffers.push(inputChannelCopy);\n }\n } else if (channel === 1 && this.numInputChannels > 1) {\n this.rightBuffers.push(inputChannelCopy);\n }\n }\n this.recordedSamples += this.bufferSize;\n }\n return true;\n }\n }, {\n key: "record",\n value: function record(duration) {\n if (duration) {\n this.sampleLimit = Math.round(duration * sampleRate);\n }\n this.recording = true;\n }\n }, {\n key: "stop",\n value: function stop() {\n this.recording = false;\n var buffers = this.getBuffers();\n var leftBuffer = buffers[0].buffer;\n var rightBuffer = buffers[1].buffer;\n this.port.postMessage({\n name: \'buffers\',\n leftBuffer: leftBuffer,\n rightBuffer: rightBuffer\n }, [leftBuffer, rightBuffer]);\n this.clear();\n }\n }, {\n key: "getBuffers",\n value: function getBuffers() {\n var buffers = [];\n buffers.push(this.mergeBuffers(this.leftBuffers));\n buffers.push(this.mergeBuffers(this.rightBuffers));\n return buffers;\n }\n }, {\n key: "mergeBuffers",\n value: function mergeBuffers(channelBuffer) {\n var result = new Float32Array(this.recordedSamples);\n var offset = 0;\n var lng = channelBuffer.length;\n for (var i = 0; i < lng; i++) {\n var buffer = channelBuffer[i];\n result.set(buffer, offset);\n offset += buffer.length;\n }\n return result;\n }\n }, {\n key: "clear",\n value: function clear() {\n var _this2 = this;\n this.leftBuffers = [];\n this.rightBuffers = [];\n this.inputRingBuffer = new RingBuffer(this.bufferSize, this.numInputChannels);\n this.inputRingBufferArraySequence = new Array(this.numInputChannels).fill(null).map(function () {\n return new Float32Array(_this2.bufferSize);\n });\n this.recordedSamples = 0;\n this.sampleLimit = null;\n }\n }]);\n return RecorderProcessor;\n}( /*#__PURE__*/_wrapNativeSuper(AudioWorkletProcessor));\nregisterProcessor(processorNames.recorderProcessor, RecorderProcessor);'},function(t,e,n){"use strict";n.r(e),e.default='function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called"); } return self; }\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }\n// import dependencies via preval.require so that they\'re available as values at compile time\nvar processorNames = {\n "recorderProcessor": "recorder-processor",\n "soundFileProcessor": "sound-file-processor",\n "amplitudeProcessor": "amplitude-processor"\n};\nvar RingBuffer = {\n "default": /*#__PURE__*/function () {\n /**\n * @constructor\n * @param {number} length Buffer length in frames.\n * @param {number} channelCount Buffer channel count.\n */\n function RingBuffer(length, channelCount) {\n _classCallCheck(this, RingBuffer);\n this._readIndex = 0;\n this._writeIndex = 0;\n this._framesAvailable = 0;\n this._channelCount = channelCount;\n this._length = length;\n this._channelData = [];\n for (var i = 0; i < this._channelCount; ++i) {\n this._channelData[i] = new Float32Array(length);\n }\n }\n /**\n * Getter for Available frames in buffer.\n *\n * @return {number} Available frames in buffer.\n */\n _createClass(RingBuffer, [{\n key: "framesAvailable",\n get: function get() {\n return this._framesAvailable;\n }\n /**\n * Push a sequence of Float32Arrays to buffer.\n *\n * @param {array} arraySequence A sequence of Float32Arrays.\n */\n }, {\n key: "push",\n value: function push(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // Transfer data from the |arraySequence| storage to the internal buffer.\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\n for (var i = 0; i < sourceLength; ++i) {\n var writeIndex = (this._writeIndex + i) % this._length;\n for (var channel = 0; channel < this._channelCount; ++channel) {\n if (arraySequence[channel]) this._channelData[channel][writeIndex] = arraySequence[channel][i];\n }\n }\n this._writeIndex += sourceLength;\n if (this._writeIndex >= this._length) {\n this._writeIndex = 0;\n } // For excessive frames, the buffer will be overwritten.\n this._framesAvailable += sourceLength;\n if (this._framesAvailable > this._length) {\n this._framesAvailable = this._length;\n }\n }\n /**\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\n *\n * @param {array} arraySequence An array of Float32Arrays.\n */\n }, {\n key: "pull",\n value: function pull(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // If the FIFO is completely empty, do nothing.\n if (this._framesAvailable === 0) {\n return;\n }\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\n for (var i = 0; i < destinationLength; ++i) {\n var readIndex = (this._readIndex + i) % this._length;\n for (var channel = 0; channel < this._channelCount; ++channel) {\n arraySequence[channel][i] = this._channelData[channel][readIndex];\n }\n }\n this._readIndex += destinationLength;\n if (this._readIndex >= this._length) {\n this._readIndex = 0;\n }\n this._framesAvailable -= destinationLength;\n if (this._framesAvailable < 0) {\n this._framesAvailable = 0;\n }\n }\n }]);\n return RingBuffer;\n }()\n}["default"];\nvar SoundFileProcessor = /*#__PURE__*/function (_AudioWorkletProcesso) {\n _inherits(SoundFileProcessor, _AudioWorkletProcesso);\n var _super = _createSuper(SoundFileProcessor);\n function SoundFileProcessor(options) {\n var _this;\n _classCallCheck(this, SoundFileProcessor);\n _this = _super.call(this);\n var processorOptions = options.processorOptions || {};\n _this.bufferSize = processorOptions.bufferSize || 256;\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, 1);\n _this.inputRingBufferArraySequence = [new Float32Array(_this.bufferSize)];\n return _this;\n }\n _createClass(SoundFileProcessor, [{\n key: "process",\n value: function process(inputs) {\n var input = inputs[0];\n // we only care about the first input channel, because that contains the position data\n this.inputRingBuffer.push([input[0]]);\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\n var inputChannel = this.inputRingBufferArraySequence[0];\n var position = inputChannel[inputChannel.length - 1] || 0;\n this.port.postMessage({\n name: \'position\',\n position: position\n });\n }\n return true;\n }\n }]);\n return SoundFileProcessor;\n}( /*#__PURE__*/_wrapNativeSuper(AudioWorkletProcessor));\nregisterProcessor(processorNames.soundFileProcessor, SoundFileProcessor);'},function(t,e,n){"use strict";n.r(e),e.default='function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called"); } return self; }\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }\n// import dependencies via preval.require so that they\'re available as values at compile time\nvar processorNames = {\n "recorderProcessor": "recorder-processor",\n "soundFileProcessor": "sound-file-processor",\n "amplitudeProcessor": "amplitude-processor"\n};\nvar RingBuffer = {\n "default": /*#__PURE__*/function () {\n /**\n * @constructor\n * @param {number} length Buffer length in frames.\n * @param {number} channelCount Buffer channel count.\n */\n function RingBuffer(length, channelCount) {\n _classCallCheck(this, RingBuffer);\n this._readIndex = 0;\n this._writeIndex = 0;\n this._framesAvailable = 0;\n this._channelCount = channelCount;\n this._length = length;\n this._channelData = [];\n for (var i = 0; i < this._channelCount; ++i) {\n this._channelData[i] = new Float32Array(length);\n }\n }\n /**\n * Getter for Available frames in buffer.\n *\n * @return {number} Available frames in buffer.\n */\n _createClass(RingBuffer, [{\n key: "framesAvailable",\n get: function get() {\n return this._framesAvailable;\n }\n /**\n * Push a sequence of Float32Arrays to buffer.\n *\n * @param {array} arraySequence A sequence of Float32Arrays.\n */\n }, {\n key: "push",\n value: function push(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // Transfer data from the |arraySequence| storage to the internal buffer.\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\n for (var i = 0; i < sourceLength; ++i) {\n var writeIndex = (this._writeIndex + i) % this._length;\n for (var channel = 0; channel < this._channelCount; ++channel) {\n if (arraySequence[channel]) this._channelData[channel][writeIndex] = arraySequence[channel][i];\n }\n }\n this._writeIndex += sourceLength;\n if (this._writeIndex >= this._length) {\n this._writeIndex = 0;\n } // For excessive frames, the buffer will be overwritten.\n this._framesAvailable += sourceLength;\n if (this._framesAvailable > this._length) {\n this._framesAvailable = this._length;\n }\n }\n /**\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\n *\n * @param {array} arraySequence An array of Float32Arrays.\n */\n }, {\n key: "pull",\n value: function pull(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // If the FIFO is completely empty, do nothing.\n if (this._framesAvailable === 0) {\n return;\n }\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\n for (var i = 0; i < destinationLength; ++i) {\n var readIndex = (this._readIndex + i) % this._length;\n for (var channel = 0; channel < this._channelCount; ++channel) {\n arraySequence[channel][i] = this._channelData[channel][readIndex];\n }\n }\n this._readIndex += destinationLength;\n if (this._readIndex >= this._length) {\n this._readIndex = 0;\n }\n this._framesAvailable -= destinationLength;\n if (this._framesAvailable < 0) {\n this._framesAvailable = 0;\n }\n }\n }]);\n return RingBuffer;\n }()\n}["default"];\nvar AmplitudeProcessor = /*#__PURE__*/function (_AudioWorkletProcesso) {\n _inherits(AmplitudeProcessor, _AudioWorkletProcesso);\n var _super = _createSuper(AmplitudeProcessor);\n function AmplitudeProcessor(options) {\n var _this;\n _classCallCheck(this, AmplitudeProcessor);\n _this = _super.call(this);\n var processorOptions = options.processorOptions || {};\n _this.numOutputChannels = options.outputChannelCount || 1;\n _this.numInputChannels = processorOptions.numInputChannels || 2;\n _this.normalize = processorOptions.normalize || false;\n _this.smoothing = processorOptions.smoothing || 0;\n _this.bufferSize = processorOptions.bufferSize || 2048;\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, _this.numInputChannels);\n _this.outputRingBuffer = new RingBuffer(_this.bufferSize, _this.numOutputChannels);\n _this.inputRingBufferArraySequence = new Array(_this.numInputChannels).fill(null).map(function () {\n return new Float32Array(_this.bufferSize);\n });\n _this.stereoVol = [0, 0];\n _this.stereoVolNorm = [0, 0];\n _this.volMax = 0.001;\n _this.port.onmessage = function (event) {\n var data = event.data;\n if (data.name === \'toggleNormalize\') {\n _this.normalize = data.normalize;\n } else if (data.name === \'smoothing\') {\n _this.smoothing = Math.max(0, Math.min(1, data.smoothing));\n }\n };\n return _this;\n }\n\n // TO DO make this stereo / dependent on # of audio channels\n _createClass(AmplitudeProcessor, [{\n key: "process",\n value: function process(inputs, outputs) {\n var input = inputs[0];\n var output = outputs[0];\n var smoothing = this.smoothing;\n this.inputRingBuffer.push(input);\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\n for (var channel = 0; channel < this.numInputChannels; ++channel) {\n var inputBuffer = this.inputRingBufferArraySequence[channel];\n var bufLength = inputBuffer.length;\n var sum = 0;\n for (var i = 0; i < bufLength; i++) {\n var x = inputBuffer[i];\n if (this.normalize) {\n sum += Math.max(Math.min(x / this.volMax, 1), -1) * Math.max(Math.min(x / this.volMax, 1), -1);\n } else {\n sum += x * x;\n }\n }\n\n // ... then take the square root of the sum.\n var rms = Math.sqrt(sum / bufLength);\n this.stereoVol[channel] = Math.max(rms, this.stereoVol[channel] * smoothing);\n this.volMax = Math.max(this.stereoVol[channel], this.volMax);\n }\n\n // calculate stero normalized volume and add volume from all channels together\n var volSum = 0;\n for (var index = 0; index < this.stereoVol.length; index++) {\n this.stereoVolNorm[index] = Math.max(Math.min(this.stereoVol[index] / this.volMax, 1), 0);\n volSum += this.stereoVol[index];\n }\n\n // volume is average of channels\n var volume = volSum / this.stereoVol.length;\n\n // normalized value\n var volNorm = Math.max(Math.min(volume / this.volMax, 1), 0);\n this.port.postMessage({\n name: \'amplitude\',\n volume: volume,\n volNorm: volNorm,\n stereoVol: this.stereoVol,\n stereoVolNorm: this.stereoVolNorm\n });\n\n // pass input through to output\n this.outputRingBuffer.push(this.inputRingBufferArraySequence);\n }\n\n // pull 128 frames out of the ring buffer\n // if the ring buffer does not have enough frames, the output will be silent\n this.outputRingBuffer.pull(output);\n return true;\n }\n }]);\n return AmplitudeProcessor;\n}( /*#__PURE__*/_wrapNativeSuper(AudioWorkletProcessor));\nregisterProcessor(processorNames.amplitudeProcessor, AmplitudeProcessor);'},function(t,e,n){n=[n(0),n(17)],e=function(n){n.Frequency=function(t,e){if(!(this instanceof n.Frequency))return new n.Frequency(t,e);n.TimeBase.call(this,t,e)},n.extend(n.Frequency,n.TimeBase),n.Frequency.prototype._primaryExpressions=Object.create(n.TimeBase.prototype._primaryExpressions),n.Frequency.prototype._primaryExpressions.midi={regexp:/^(\d+(?:\.\d+)?midi)/,method:function(t){return this.midiToFrequency(t)}},n.Frequency.prototype._primaryExpressions.note={regexp:/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,method:function(t,e){return t=i[t.toLowerCase()]+12*(parseInt(e)+1),this.midiToFrequency(t)}},n.Frequency.prototype._primaryExpressions.tr={regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method:function(t,e,n){var i=1;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}},n.Frequency.prototype.transpose=function(t){return this._expr=function(t,e){return t()*this.intervalToFrequencyRatio(e)}.bind(this,this._expr,t),this},n.Frequency.prototype.harmonize=function(t){return this._expr=function(t,e){for(var n=t(),i=[],r=0;r<e.length;r++)i[r]=n*this.intervalToFrequencyRatio(e[r]);return i}.bind(this,this._expr,t),this},n.Frequency.prototype.toMidi=function(){return this.frequencyToMidi(this.valueOf())},n.Frequency.prototype.toNote=function(){var t=this.valueOf(),t=Math.log(t/n.Frequency.A4)/Math.LN2,t=Math.round(12*t)+57,e=Math.floor(t/12);return e<0&&(t+=-12*e),r[t%12]+e.toString()},n.Frequency.prototype.toSeconds=function(){return 1/this.valueOf()},n.Frequency.prototype.toFrequency=function(){return this.valueOf()},n.Frequency.prototype.toTicks=function(){var t=this._beatsToUnits(1),t=this.valueOf()/t;return Math.floor(t*n.Transport.PPQ)},n.Frequency.prototype._frequencyToUnits=function(t){return t},n.Frequency.prototype._ticksToUnits=function(t){return 1/(60*t/(n.Transport.bpm.value*n.Transport.PPQ))},n.Frequency.prototype._beatsToUnits=function(t){return 1/n.TimeBase.prototype._beatsToUnits.call(this,t)},n.Frequency.prototype._secondsToUnits=function(t){return 1/t},n.Frequency.prototype._defaultUnits="hz";var i={cbb:-2,cb:-1,c:0,"c#":1,cx:2,dbb:0,db:1,d:2,"d#":3,dx:4,ebb:2,eb:3,e:4,"e#":5,ex:6,fbb:3,fb:4,f:5,"f#":6,fx:7,gbb:5,gb:6,g:7,"g#":8,gx:9,abb:7,ab:8,a:9,"a#":10,ax:11,bbb:9,bb:10,b:11,"b#":12,bx:13},r=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];return n.Frequency.A4=440,n.Frequency.prototype.midiToFrequency=function(t){return n.Frequency.A4*Math.pow(2,(t-69)/12)},n.Frequency.prototype.frequencyToMidi=function(t){return 69+12*Math.log(t/n.Frequency.A4)/Math.LN2},n.Frequency}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(16)],e=function(n){return n.TransportTime=function(t,e){if(!(this instanceof n.TransportTime))return new n.TransportTime(t,e);n.Time.call(this,t,e)},n.extend(n.TransportTime,n.Time),n.TransportTime.prototype._unaryExpressions=Object.create(n.Time.prototype._unaryExpressions),n.TransportTime.prototype._unaryExpressions.quantize={regexp:/^@/,method:function(t){var t=this._secondsToTicks(t()),e=Math.ceil(n.Transport.ticks/t);return this._ticksToUnits(e*t)}},n.TransportTime.prototype._secondsToTicks=function(t){var e=this._beatsToUnits(1);return Math.round(t/e*n.Transport.PPQ)},n.TransportTime.prototype.valueOf=function(){return this._secondsToTicks(this._expr())+(this._plusNow?n.Transport.ticks:0)},n.TransportTime.prototype.toTicks=function(){return this.valueOf()},n.TransportTime.prototype.toSeconds=function(){return this._expr()+(this._plusNow?n.Transport.seconds:0)},n.TransportTime.prototype.toFrequency=function(){return 1/this.toSeconds()},n.TransportTime}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(4),n(13),n(1),n(33),n(20),n(34),n(19),n(35),n(36),n(37)],e=function(c){"use strict";function n(t,e,n){return t=new t,n._eval(e[0]).connect(t,0,0),n._eval(e[1]).connect(t,0,1),t}function i(t,e,n){return t=new t,n._eval(e[0]).connect(t,0,0),t}function r(t){return t?parseFloat(t):void 0}function o(t){return t&&t.args?parseFloat(t.args):void 0}return c.Expr=function(){var t=this._replacements(Array.prototype.slice.call(arguments)),e=this._parseInputs(t);this._nodes=[],this.input=new Array(e);for(var n=0;n<e;n++)this.input[n]=this.context.createGain();var i,r=this._parseTree(t);try{i=this._eval(r)}catch(e){throw this._disposeNodes(),new Error("Tone.Expr: Could evaluate expression: "+t)}this.output=i},c.extend(c.Expr,c.SignalBase),c.Expr._Expressions={value:{signal:{regexp:/^\d+\.\d+|^\d+/,method:function(t){return new c.Signal(r(t))}},input:{regexp:/^\$\d/,method:function(t,e){return e.input[r(t.substr(1))]}}},glue:{"(":{regexp:/^\(/},")":{regexp:/^\)/},",":{regexp:/^,/}},func:{abs:{regexp:/^abs/,method:i.bind(this,c.Abs)},mod:{regexp:/^mod/,method:function(t,e){var n=o(t[1]),n=new c.Modulo(n);return e._eval(t[0]).connect(n),n}},pow:{regexp:/^pow/,method:function(t,e){var n=o(t[1]),n=new c.Pow(n);return e._eval(t[0]).connect(n),n}},a2g:{regexp:/^a2g/,method:function(t,e){var n=new c.AudioToGain;return e._eval(t[0]).connect(n),n}}},binary:{"+":{regexp:/^\+/,precedence:1,method:n.bind(this,c.Add)},"-":{regexp:/^\-/,precedence:1,method:function(t,e){return 1===t.length?i(c.Negate,t,e):n(c.Subtract,t,e)}},"*":{regexp:/^\*/,precedence:0,method:n.bind(this,c.Multiply)}},unary:{"-":{regexp:/^\-/,method:i.bind(this,c.Negate)},"!":{regexp:/^\!/,method:i.bind(this,c.NOT)}}},c.Expr.prototype._parseInputs=function(t){var e=t.match(/\$\d/g),n=0;if(null!==e)for(var i=0;i<e.length;i++)var r=parseInt(e[i].substr(1))+1,n=Math.max(n,r);return n},c.Expr.prototype._replacements=function(t){for(var e=t.shift(),n=0;n<t.length;n++)e=e.replace(/\%/i,t[n]);return e},c.Expr.prototype._tokenize=function(t){for(var e=-1,n=[];0<t.length;){var i=function(t){for(var e in c.Expr._Expressions){var n,i=c.Expr._Expressions[e];for(n in i){var r=i[n],o=r.regexp;if(null!==(o=t.match(o)))return{type:e,value:o[0],method:r.method}}}throw new SyntaxError("Tone.Expr: Unexpected token "+t)}(t=t.trim());n.push(i),t=t.substr(i.value.length)}return{next:function(){return n[++e]},peek:function(){return n[e+1]}}},c.Expr.prototype._parseTree=function(t){var r=this._tokenize(t),o=this.isUndef.bind(this);function s(t,e){return!o(t)&&"glue"===t.type&&t.value===e}function a(t,e,n){var i=c.Expr._Expressions[e];if(!o(t))for(var r in i)if((r=i[r]).regexp.test(t.value)){if(o(n))return 1;if(r.precedence===n)return 1}}function u(t){for(var e,e=(t=o(t)?5:t)<0?function t(){var e=r.peek();if(a(e,"unary"))return e=r.next(),n=t(),{operator:e.value,method:e.method,args:[n]};if(e=r.peek(),o(e))throw new SyntaxError("Tone.Expr: Unexpected termination of expression");if("func"===e.type){var n=e=r.next(),i=[];if(!s(r.next(),"("))throw new SyntaxError('Tone.Expr: Expected ( in a function call "'+n.value+'"');if(s(r.peek(),")")||(i=function(){for(var t,e=[];t=u(),!o(t)&&(e.push(t),s(r.peek(),","));)r.next();return e}()),s(r.next(),")"))return{method:n.method,args:i,name:name};throw new SyntaxError('Tone.Expr: Expected ) in a function call "'+n.value+'"')}if("value"===e.type)return{method:(e=r.next()).method,args:e.value};if(s(e,"(")){if(r.next(),i=u(),s(e=r.next(),")"))return i;throw new SyntaxError("Expected )")}throw new SyntaxError("Tone.Expr: Parse error, cannot process token "+e.value)}():u(t-1),n=r.peek();a(n,"binary",t);)e={operator:(n=r.next()).value,method:n.method,args:[e,u(t-1)]},n=r.peek();return e}return u()},c.Expr.prototype._eval=function(t){if(!this.isUndef(t))return t=t.method(t.args,this),this._nodes.push(t),t},c.Expr.prototype._disposeNodes=function(){for(var t=0;t<this._nodes.length;t++){var e=this._nodes[t];this.isFunction(e.dispose)?e.dispose():this.isFunction(e.disconnect)&&e.disconnect(),this._nodes[t]=e=null}this._nodes=null},c.Expr.prototype.dispose=function(){c.prototype.dispose.call(this),this._disposeNodes()},c.Expr}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(20),n(13),n(2)],e=function(e){"use strict";return e.GreaterThan=function(t){this.createInsOuts(2,0),this._param=this.input[0]=new e.Subtract(t),this.input[1]=this._param.input[1],this._gtz=this.output=new e.GreaterThanZero,this._param.connect(this._gtz)},e.extend(e.GreaterThan,e.Signal),e.GreaterThan.prototype.dispose=function(){return e.prototype.dispose.call(this),this._param.dispose(),this._param=null,this._gtz.dispose(),this._gtz=null,this},e.GreaterThan}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(6),n(15)],e=function(t){"use strict";return t.Abs=function(){this._abs=this.input=this.output=new t.WaveShaper(function(t){return 0===t?0:Math.abs(t)},127)},t.extend(t.Abs,t.SignalBase),t.Abs.prototype.dispose=function(){return t.prototype.dispose.call(this),this._abs.dispose(),this._abs=null,this},t.Abs}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(6),n(1),n(13)],e=function(e){"use strict";return e.Modulo=function(t){this.createInsOuts(1,0),this._shaper=new e.WaveShaper(Math.pow(2,16)),this._multiply=new e.Multiply,this._subtract=this.output=new e.Subtract,this._modSignal=new e.Signal(t),this.input.fan(this._shaper,this._subtract),this._modSignal.connect(this._multiply,0,0),this._shaper.connect(this._multiply,0,1),this._multiply.connect(this._subtract,0,1),this._setWaveShaper(t)},e.extend(e.Modulo,e.SignalBase),e.Modulo.prototype._setWaveShaper=function(e){this._shaper.setMap(function(t){return Math.floor((t+1e-4)/e)})},Object.defineProperty(e.Modulo.prototype,"value",{get:function(){return this._modSignal.value},set:function(t){this._modSignal.value=t,this._setWaveShaper(t)}}),e.Modulo.prototype.dispose=function(){return e.prototype.dispose.call(this),this._shaper.dispose(),this._shaper=null,this._multiply.dispose(),this._multiply=null,this._subtract.dispose(),this._subtract=null,this._modSignal.dispose(),this._modSignal=null,this},e.Modulo}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(6)],e=function(e){"use strict";return e.Pow=function(t){this._exp=this.defaultArg(t,1),this._expScaler=this.input=this.output=new e.WaveShaper(this._expFunc(this._exp),8192)},e.extend(e.Pow,e.SignalBase),Object.defineProperty(e.Pow.prototype,"value",{get:function(){return this._exp},set:function(t){this._exp=t,this._expScaler.setMap(this._expFunc(this._exp))}}),e.Pow.prototype._expFunc=function(e){return function(t){return Math.pow(Math.abs(t),e)}},e.Pow.prototype.dispose=function(){return e.prototype.dispose.call(this),this._expScaler.dispose(),this._expScaler=null,this},e.Pow}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(6),n(2)],e=function(t){"use strict";return t.AudioToGain=function(){this._norm=this.input=this.output=new t.WaveShaper(function(t){return(t+1)/2})},t.extend(t.AudioToGain,t.SignalBase),t.AudioToGain.prototype.dispose=function(){return t.prototype.dispose.call(this),this._norm.dispose(),this._norm=null,this},t.AudioToGain}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(6)],e=function(t){"use strict";return t.EqualPowerGain=function(){this._eqPower=this.input=this.output=new t.WaveShaper(function(t){return Math.abs(t)<.001?0:this.equalPowerScale(t)}.bind(this),4096)},t.extend(t.EqualPowerGain,t.SignalBase),t.EqualPowerGain.prototype.dispose=function(){return t.prototype.dispose.call(this),this._eqPower.dispose(),this._eqPower=null,this},t.EqualPowerGain}.apply(e,n);void 0!==e&&(t.exports=e)},function(t,e,n){n=[n(0),n(21),n(9)],e=function(e){"use strict";return e.TimelineState=function(t){e.Timeline.call(this),this._initial=t},e.extend(e.TimelineState,e.Timeline),e.TimelineState.prototype.getValueAtTime=function(t){return null!==(t=this.get(t))?t.state:this._initial},e.TimelineState.prototype.setStateAtTime=function(t,e){this.add({state:t,time:e})},e.TimelineState}.apply(e,n);void 0!==e&&(t.exports=e)},function(V,t,e){"use strict";e.r(t);e(24),e(25);var c=e(3);function M(t){return(M="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)}function F(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==M(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==M(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===M(t)?t:String(t)}(i.key),i)}}function D(t,e,n){return e&&F(t.prototype,e),n&&F(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}var o=new(D(function t(){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");this.input=c.a.createGain(),this.output=c.a.createGain(),this.limiter=c.a.createDynamicsCompressor(),this.limiter.threshold.value=-3,this.limiter.ratio.value=20,this.limiter.knee.value=1,this.audiocontext=c.a,this.output.disconnect(),this.input.connect(this.limiter),this.limiter.connect(this.output),this.meter=c.a.createGain(),this.fftMeter=c.a.createGain(),this.output.connect(this.meter),this.output.connect(this.fftMeter),this.output.connect(this.audiocontext.destination),this.soundArray=[],this.parts=[],this.extensions=[]})),h=(p5.prototype.getOutputVolume=function(){return o.output.gain.value},p5.prototype.outputVolume=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;if("number"==typeof t){var i=o.audiocontext.currentTime,r=o.output.gain.value;o.output.gain.cancelScheduledValues(i+n),0!==e&&o.output.gain.linearRampToValueAtTime(r,i+n),o.output.gain.linearRampToValueAtTime(t,i+n+e)}else{if(!t)return o.output.gain;t.connect(o.output.gain)}},p5.prototype.soundOut=p5.soundOut=o,p5.soundOut._silentNode=o.audiocontext.createGain(),p5.soundOut._silentNode.gain.value=0,p5.soundOut._silentNode.connect(o.audiocontext.destination),o),t=e(5),I=e.n(t);function U(t){return(U="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)}function n(t){return 440*Math.pow(2,(t-69)/12)}function G(t){if("string"!=typeof t)return t;var e={A:33,B:35,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}return n(e)}function L(t){for(var e=t.getChannelData(0),t=1<t.numberOfChannels?t.getChannelData(1):e,n=z(e,t),e=new window.ArrayBuffer(44+2*n.length),i=new window.DataView(e),r=(a(i,0,"RIFF"),i.setUint32(4,36+2*n.length,!0),a(i,8,"WAVE"),a(i,12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,2,!0),i.setUint32(24,h.audiocontext.sampleRate,!0),i.setUint32(28,4*h.audiocontext.sampleRate,!0),i.setUint16(32,4,!0),i.setUint16(34,16,!0),a(i,36,"data"),i.setUint32(40,2*n.length,!0),n.length),o=44,s=0;s<r;s++)i.setInt16(o,32767*n[s],!0),o+=2;return i}function z(t,e){for(var n=t.length+e.length,i=new Float32Array(n),r=0,o=0;o<n;)i[o++]=t[r],i[o++]=e[r],r++;return i}function a(t,e,n){for(var i=n.length,r=0;r<i;r++)t.setUint8(e+r,n.charCodeAt(r))}function W(t){var e=new AudioWorkletNode(h.audiocontext,I.a.soundFileProcessor);return e instanceof ScriptProcessorNode&&(t=e.bufferSize),e.disconnect(),e=null,t}var l=function(t,e,n){var i=new Error;return i.name=t,i.originalStack=i.stack+e,t=i.stack+e,i.failedPath=n,e=t.split("\n").filter(function(t){return!t.match(/(p5.|native code|globalInit)/g)}),i.stack=e.join("\n"),i},Z=[e(27).default,e(28).default,e(29).default],X=h.audiocontext,Y=!1;p5.prototype.registerMethod("init",function(){var t;Y||(this.preload||window.preload||(this.preload=function(){}),this._incrementPreload(),t=function(){Y=!0,this._decrementPreload()}.bind(this),Promise.all(Z.map(function(t){t=new Blob([t],{type:"application/javascript"}),t=URL.createObjectURL(t);return X.audioWorklet.addModule(t).catch(function(){return Promise.resolve()})})).then(t))});var t=e(23),H=e.n(t);function $(t){return($="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)}function Q(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==$(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==$(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===$(t)?t:String(t)}(i.key),i)}}var u=function(){function t(){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");this.ac=h.audiocontext,this.input=this.ac.createGain(),this.output=this.ac.createGain(),this._drywet=new H.a(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(),h.soundArray.push(this)}var e,n,i;return e=t,(n=[{key:"amp",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=h.audiocontext.currentTime,i=n+(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0),e=i+e+.001,r=this.output.gain.value;this.output.gain.cancelScheduledValues(n),this.output.gain.linearRampToValueAtTime(r,i+.001),this.output.gain.linearRampToValueAtTime(t,e)}},{key:"chain",value: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}},{key:"drywet",value:function(t){return void 0!==t&&(this._drywet.fade.value=t),this._drywet.fade.value}},{key:"connect",value:function(t){var e=t||p5.soundOut.input;this.output.connect(e.input||e),t&&t._onNewInput&&t._onNewInput(this)}},{key:"disconnect",value:function(){this.output&&this.output.disconnect()}},{key:"dispose",value:function(){var t=h.soundArray.indexOf(this);h.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}}])&&Q(e.prototype,n),i&&Q(e,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();function r(t){return(r="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)}function K(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function J(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===r(t)?t:String(t)}(i.key),i)}}function tt(t,e,n){e&&J(t.prototype,e),n&&J(t,n),Object.defineProperty(t,"prototype",{writable:!1})}function et(){return(et="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}(t,e);if(i)return(i=Object.getOwnPropertyDescriptor(i,e)).get?i.get.call(arguments.length<3?t:n):i.value}).apply(this,arguments)}function nt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&it(t,e)}function it(t,e){return(it=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function rt(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=s(n),e=(t=i?(t=s(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var i=h.audiocontext,ot=(void 0!==i.createStereoPanner?function(){nt(n,u);var e=rt(n);function n(){var t;return K(this,n),(t=e.call(this)).stereoPanner=t.ac.createStereoPanner(),t.input.connect(t.stereoPanner),t.stereoPanner.connect(t.wet),t}return tt(n,[{key:"pan",value:function(t,e){"number"==typeof t?this.stereoPanner.pan.linearRampToValueAtTime(t,this.ac.currentTime+(e||0)):void 0!==t&&t.connect(this.stereoPanner.pan)}},{key:"getPan",value:function(){return this.stereoPanner.pan.value}},{key:"dispose",value:function(){et(s(n.prototype),"dispose",this).call(this),this.stereoPanner&&(this.stereoPanner.disconnect(),delete this.stereoPanner)}}]),n}:function(){nt(n,u);var e=rt(n);function n(){var t;return K(this,n),(t=e.call(this)).input.channelCountMode="explicit",t.panValue=0,t.left=i.createGain(),t.right=i.createGain(),t.left.channelInterpretation="discrete",t.right.channelInterpretation="discrete",t.splitter=i.createChannelSplitter(2),t.merger=i.createChannelMerger(2),t.input.connect(t.splitter),t.splitter.connect(t.left,1),t.splitter.connect(t.right,0),t.left.connect(t.merger,0,1),t.right.connect(t.merger,0,0),t.merger.connect(t.wet),t}return tt(n,[{key:"pan",value:function(t,e){this.panValue=t;var e=i.currentTime+(e||0),t=(t+1)/2,n=Math.cos(t*Math.PI/2),t=Math.sin(t*Math.PI/2);this.left.gain.linearRampToValueAtTime(t,e),this.right.gain.linearRampToValueAtTime(n,e)}},{key:"getPan",value:function(){return this.panValue}},{key:"dispose",value:function(){et(s(n.prototype),"dispose",this).call(this),this.left&&(this.left.disconnect(),delete this.left),this.right&&(this.right.disconnect(),delete this.right),this.splitter&&(this.splitter.disconnect(),delete this.splitter),this.merger&&(this.merger.disconnect(),delete this.merger)}}]),n})();function p(t){return(p="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)}function st(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==p(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===p(t)?t:String(t)}(i.key),i)}}function at(t,e,n){return e&&st(t.prototype,e),n&&st(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function ut(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var f=h.audiocontext,ct=at(function t(e,n,i,r){ut(this,t),this.callback=e,this.time=n,this.id=i,this.val=r});var lt=function(){function o(t,e,n,i){if(ut(this,o),void 0!==t){if("string"==typeof t||"string"==typeof t[0]){var r=p5.prototype._checkFileFormats(t);this.url=r}else if("object"===p(t)&&!(window.File&&window.FileReader&&window.FileList&&window.Blob))throw"Unable to load file because the File API is not supported";t.file&&(t=t.file),this.file=t}this._onended=function(){},this._looping=!1,this._playing=!1,this._paused=!1,this._pauseTime=0,this._cues=[],this._cueIDCounter=0,this._lastPos=0,this._counterNode=null,this._workletNode=null,this.bufferSourceNodes=[],this.bufferSourceNode=null,this.buffer=null,this.playbackRate=1,this.input=h.audiocontext.createGain(),this.output=h.audiocontext.createGain(),this.reversed=!1,this.startTime=0,this.endTime=null,this.pauseTime=0,this.mode="sustain",this.startMillis=null,this.panner=new ot,this.output.connect(this.panner),(this.url||this.file)&&this.load(e,n),h.soundArray.push(this),this._whileLoading="function"==typeof i?i:function(){},this._clearOnEnd=function(t){var t=t.target,e=this;t._playing=!1,t.removeEventListener("ended",e._clearOnEnd),e._onended(e),e.bufferSourceNodes.map(function(t,e){return e}).reverse().forEach(function(t){!1===e.bufferSourceNodes[t]._playing&&e.bufferSourceNodes.splice(t,1)}),0===e.bufferSourceNodes.length&&(e._playing=!1)}.bind(this),this.amp=this.setVolume,this.fade=this.setVolume}return at(o,[{key:"load",value:function(n,i){var r,t,o=this,s=(new Error).stack;void 0!==this.url&&""!==this.url?((r=new XMLHttpRequest).addEventListener("progress",function(t){o._updateProgress(t)},!1),r.open("GET",this.url,!0),r.responseType="arraybuffer",r.onload=function(){var t,e;200===r.status?o.panner&&f.decodeAudioData(r.response,function(t){o.panner&&(o.buffer=t,n)&&n(o)},function(){var t,e;o.panner&&(t=new l("decodeAudioData",s,o.url),e="AudioContext error at decodeAudioData for "+o.url,i)&&(t.msg=e,i(t))}):o.panner&&(t=new l("loadSound",s,o.url),e="Unable to load "+o.url+". The request status was: "+r.status+" ("+r.statusText+")",i)&&(t.message=e,i(t))},r.onerror=function(){var t=new l("loadSound",s,o.url),e="There was no response from the server at "+o.url+". Check the url and internet connectivity.";i&&(t.message=e,i(t))},r.send()):void 0!==this.file&&((t=new FileReader).onload=function(){o.panner&&f.decodeAudioData(t.result,function(t){o.panner&&(o.buffer=t,n)&&n(o)})},t.onerror=function(t){o.panner&&onerror&&onerror(t)},t.readAsArrayBuffer(this.file))}},{key:"_updateProgress",value:function(t){var e;t.lengthComputable?(e=t.loaded/t.total*.99,this._whileLoading(e,t)):this._whileLoading("size unknown")}},{key:"isLoaded",value:function(){return!!this.buffer}},{key:"play",value:function(t,e,n,i,r){if(this.output){var o,t=t||0;if(t<0&&(t=0),t+=h.audiocontext.currentTime,void 0!==e&&this.rate(e),void 0!==n&&this.setVolume(n),!this.buffer)throw"not ready to play file, buffer has yet to load. Try preload()";if(this._pauseTime=0,"restart"===this.mode&&this.buffer&&this.bufferSourceNode&&(this.bufferSourceNode.stop(t),this._counterNode.stop(t)),"untildone"!==this.mode||!this.isPlaying()){if(this.bufferSourceNode=this._initSourceNode(),delete this._counterNode,this._counterNode=this._initCounterNode(),i){if(!(0<=i&&i<this.buffer.duration))throw"start time out of range";o=i}else o=0;r=r&&(r<=this.buffer.duration-o?r:this.buffer.duration),this._paused?(this.bufferSourceNode.start(t,this.pauseTime,r),this._counterNode.start(t,this.pauseTime,r)):(this.bufferSourceNode.start(t,o,r),this._counterNode.start(t,o,r)),this._playing=!0,this._paused=!1,this.bufferSourceNodes.push(this.bufferSourceNode),this.bufferSourceNode._arrayIndex=this.bufferSourceNodes.length-1,this.bufferSourceNode.addEventListener("ended",this._clearOnEnd),this.bufferSourceNode.loop=this._looping,this._counterNode.loop=this._looping,!0===this._looping&&(e=r||o-1e-15,this.bufferSourceNode.loopStart=o,this.bufferSourceNode.loopEnd=e,this._counterNode.loopStart=o,this._counterNode.loopEnd=e)}}}},{key:"playMode",value:function(t){t=t.toLowerCase().trim();if("restart"===t&&this.buffer&&this.bufferSourceNode)for(var e=0;e<this.bufferSourceNodes.length;e++){var n=h.audiocontext.currentTime;this.bufferSourceNodes[e].stop(n)}if("restart"!==t&&"sustain"!==t&&"untildone"!==t)throw'Invalid play mode. Must be either "restart" or "sustain"';this.mode=t}},{key:"pause",value:function(t){t=(t||0)+h.audiocontext.currentTime;this.isPlaying()&&this.buffer&&this.bufferSourceNode?(this._paused=!0,this._playing=!1,this.pauseTime=this.currentTime(),this.bufferSourceNode.stop(t),this._counterNode.stop(t),this._pauseTime=this.currentTime()):this._pauseTime=0}},{key:"loop",value:function(t,e,n,i,r){this._looping=!0,this.play(t,e,n,i,r)}},{key:"setLoop",value:function(t){if(!0===t)this._looping=!0;else{if(!1!==t)throw"Error: setLoop accepts either true or false";this._looping=!1}this.bufferSourceNode&&(this.bufferSourceNode.loop=this._looping,this._counterNode.loop=this._looping)}},{key:"isLooping",value:function(){return!!this.bufferSourceNode&&!0===this._looping&&!0===this.isPlaying()}},{key:"isPlaying",value:function(){return this._playing}},{key:"isPaused",value:function(){return this._paused}},{key:"stop",value:function(t){var e,t=t||0;"sustain"===this.mode||"untildone"===this.mode?(this.stopAll(t),this._playing=!1,this.pauseTime=0,this._paused=!1):this.buffer&&this.bufferSourceNode&&(e=h.audiocontext.currentTime,this.pauseTime=0,this.bufferSourceNode.stop(e+t),this._counterNode.stop(e+t),this._playing=!1,this._paused=!1)}},{key:"stopAll",value:function(t){var e=h.audiocontext.currentTime,n=t||0;if(this.buffer&&this.bufferSourceNode){for(var i in this.bufferSourceNodes){i=this.bufferSourceNodes[i];if(i)try{i.stop(e+n)}catch(t){}}this._counterNode.stop(e+n)}}},{key:"getVolume",value:function(){return this.output.gain.value}},{key:"pan",value:function(t,e){this.panner.pan(t,e)}},{key:"getPan",value:function(){return this.panner.getPan()}},{key:"rate",value:function(t){var e,n=!1;return void 0!==t&&(0===(this.playbackRate=t)?t=1e-13:t<0&&!this.reversed?(t=Math.abs(t),n=!0):0<t&&this.reversed&&(n=!0),this.bufferSourceNode&&(e=h.audiocontext.currentTime,this.bufferSourceNode.playbackRate.cancelScheduledValues(e),this.bufferSourceNode.playbackRate.linearRampToValueAtTime(Math.abs(t),e),this._counterNode.playbackRate.cancelScheduledValues(e),this._counterNode.playbackRate.linearRampToValueAtTime(Math.abs(t),e)),n)&&this.reverseBuffer(),this.playbackRate}},{key:"setPitch",value:function(t){t=n(t)/n(60);this.rate(t)}},{key:"getPitch",value:function(){var t=this.rate()*n(60);return freqToMidi(t)}},{key:"getPlaybackRate",value:function(){return this.playbackRate}},{key:"setVolume",value:function(t,e,n){if("number"==typeof t){var e=e||0,n=n||0,i=h.audiocontext.currentTime,r=this.output.gain.value;this.output.gain.cancelScheduledValues(i+n),this.output.gain.linearRampToValueAtTime(r,i+n),this.output.gain.linearRampToValueAtTime(t,i+n+e)}else{if(!t)return this.output.gain;t.connect(this.output.gain)}}},{key:"duration",value:function(){return this.buffer?this.buffer.duration:0}},{key:"currentTime",value:function(){return this.reversed?Math.abs(this._lastPos-this.buffer.length)/f.sampleRate:this._lastPos/f.sampleRate}},{key:"jump",value:function(t,e){if(t<0||t>this.buffer.duration)throw"jump time out of range";if(e>this.buffer.duration-t)throw"end time out of range";t=t||0,e=e||void 0;this.isPlaying()&&(this.stop(0),this.play(0,this.playbackRate,this.output.gain.value,t,e))}},{key:"channels",value:function(){if(this.buffer)return this.buffer.numberOfChannels}},{key:"sampleRate",value:function(){if(this.buffer)return this.buffer.sampleRate}},{key:"frames",value:function(){if(this.buffer)return this.buffer.length}},{key:"getPeaks",value:function(t){if(!this.buffer)throw"Cannot load peaks yet, buffer is not loaded";if(t=t||5*window.innerWidth,this.buffer){for(var e=this.buffer,n=e.length/t,i=~~(n/10)||1,r=e.numberOfChannels,o=new Float32Array(Math.round(t)),s=0;s<r;s++)for(var a=e.getChannelData(s),u=0;u<t;u++){for(var c=~~(u*n),l=~~(c+n),p=0,h=c;h<l;h+=i){var f=a[h];(p<f||p<-f)&&(p=f)}(0===s||Math.abs(p)>o[u])&&(o[u]=p)}return o}}},{key:"reverseBuffer",value:function(){if(!this.buffer)throw"SoundFile is not done loading";for(var t=this._lastPos/f.sampleRate,e=this.getVolume(),n=(this.setVolume(0,.001),this.buffer.numberOfChannels),i=0;i<n;i++)this.buffer.getChannelData(i).reverse();this.reversed=!this.reversed,this.isPlaying()&&t&&this.jump(this.duration()-t),this.setVolume(e,.001)}},{key:"onended",value:function(t){return this._onended=t,this}},{key:"add",value:function(){}},{key:"dispose",value:function(){var t=h.audiocontext.currentTime,e=h.soundArray.indexOf(this);if(h.soundArray.splice(e,1),this.stop(t),this.buffer&&this.bufferSourceNode){for(var n=0;n<this.bufferSourceNodes.length-1;n++)if(null!==this.bufferSourceNodes[n]){this.bufferSourceNodes[n].disconnect();try{this.bufferSourceNodes[n].stop(t)}catch(t){}this.bufferSourceNodes[n]=null}if(this.isPlaying()){try{this._counterNode.stop(t)}catch(t){}this._counterNode=null}}this.output&&(this.output.disconnect(),this.output=null),this.panner&&(this.panner.dispose(),this.panner=null)}},{key:"connect",value:function(t){t?t.hasOwnProperty("input")?this.panner.connect(t.input):this.panner.connect(t):this.panner.connect(h.input),t&&t._onNewInput&&t._onNewInput(this)}},{key:"disconnect",value:function(){this.panner&&this.panner.disconnect()}},{key:"getLevel",value:function(){}},{key:"setPath",value:function(t,e){t=p5.prototype._checkFileFormats(t);this.url=t,this.load(e)}},{key:"setBuffer",value:function(t){var e=t.length,n=t[0].length,i=f.createBuffer(e,n,f.sampleRate);t[0]instanceof Float32Array||(t[0]=new Float32Array(t[0]));for(var r=0;r<e;r++)i.getChannelData(r).set(t[r]);this.buffer=i}},{key:"_initCounterNode",value:function(){var t,e=this,n=this,i=f.currentTime,r=f.createBufferSource();return n._workletNode||(t=W(256),n._workletNode=new AudioWorkletNode(f,I.a.soundFileProcessor,{processorOptions:{bufferSize:t}}),n._workletNode.port.onmessage=function(t){"position"===t.data.name&&0!==t.data.position&&(e._lastPos=t.data.position,e._onTimeUpdate(n._lastPos))},n._workletNode.connect(p5.soundOut._silentNode)),r.buffer=function(t){for(var e=t.length,t=f.createBuffer(1,t.length,f.sampleRate),n=t.getChannelData(0),i=0;i<e;i++)n[i]=i;return t}(n.buffer),r.playbackRate.setValueAtTime(n.playbackRate,i),r.connect(n._workletNode),r}},{key:"_initSourceNode",value:function(){var t=f.createBufferSource();return t.buffer=this.buffer,t.playbackRate.value=this.playbackRate,t.connect(this.output),t}},{key:"processPeaks",value:function(t,e,n,i){}},{key:"addCue",value:function(t,e,n){var i=this._cueIDCounter++,e=new ct(e,t,i,n);return this._cues.push(e),i}},{key:"removeCue",value:function(t){for(var e=this._cues.length,n=0;n<e;n++)if(this._cues[n].id===t){this._cues.splice(n,1);break}this._cues.length}},{key:"clearCues",value:function(){this._cues=[]}},{key:"_onTimeUpdate",value:function(t){for(var e=t/this.buffer.sampleRate,n=this._cues.length,i=0;i<n;i++){var r=this._cues[i],o=r.time,s=r.val;(this._prevUpdateTime||0)<=o&&o<=e&&r.callback(s)}this._prevUpdateTime=e}},{key:"save",value:function(t){p5.prototype.saveSound(this,t,"wav")}},{key:"getBlob",value:function(){var t=L(this.buffer);return new Blob([t],{type:"audio/wav"})}}]),o}();t=lt;function pt(t){return(pt="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)}function ht(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==pt(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===pt(t)?t:String(t)}(i.key),i)}}var ft=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.bufferSize=W(2048),this.audiocontext=h.audiocontext,this._workletNode=new AudioWorkletNode(this.audiocontext,I.a.amplitudeProcessor,{outputChannelCount:[1],parameterData:{smoothing:t||0},processorOptions:{normalize:!1,smoothing:t||0,numInputChannels:2,bufferSize:this.bufferSize}}),this._workletNode.port.onmessage=function(t){"amplitude"===t.data.name&&(this.volume=t.data.volume,this.volNorm=t.data.volNorm,this.stereoVol=t.data.stereoVol,this.stereoVolNorm=t.data.stereoVolNorm)}.bind(this),this.input=this._workletNode,this.output=this.audiocontext.createGain(),this.volume=0,this.volNorm=0,this.stereoVol=[0,0],this.stereoVolNorm=[0,0],this.normalize=!1,this._workletNode.connect(this.output),this.output.gain.value=0,this.output.connect(this.audiocontext.destination),h.meter.connect(this._workletNode),h.soundArray.push(this)}var t,n,i;return t=e,(n=[{key:"setInput",value:function(t,e){h.meter.disconnect(),e&&(this._workletNode.parameters.get("smoothing").value=e),null!=t&&t?(t.connect(this._workletNode),this._workletNode.disconnect(),this._workletNode.connect(this.output)):h.meter.connect(this._workletNode)}},{key:"getLevel",value:function(t){return void 0!==t?(this.normalize?this.stereoVolNorm:this.stereoVol)[t]:this.normalize?this.volNorm:this.volume}},{key:"toggleNormalize",value:function(t){this.normalize="boolean"==typeof t?t:!this.normalize,this._workletNode.port.postMessage({name:"toggleNormalize",normalize:this.normalize})}},{key:"smooth",value:function(t){0<=t&&t<1&&this._workletNode.port.postMessage({name:"smoothing",smoothing:t})}},{key:"dispose",value:function(){var t=h.soundArray.indexOf(this);h.soundArray.splice(t,1),this.input&&(this.input.disconnect(),delete this.input),this.output&&(this.output.disconnect(),delete this.output),this._workletNode.disconnect(),delete this._workletNode}}])&&ht(t.prototype,n),i&&ht(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function yt(t){return(yt="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)}function dt(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==yt(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===yt(t)?t:String(t)}(i.key),i)}}var mt=function(){function n(t,e){if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");this.input=this.analyser=h.audiocontext.createAnalyser(),Object.defineProperties(this,{bins:{get:function(){return this.analyser.fftSize/2},set:function(t){this.analyser.fftSize=2*t},configurable:!0,enumerable:!0},smoothing:{get:function(){return this.analyser.smoothingTimeConstant},set:function(t){this.analyser.smoothingTimeConstant=t},configurable:!0,enumerable:!0}}),this.smooth(t),this.bins=e||1024,h.fftMeter.connect(this.analyser),this.freqDomain=new Uint8Array(this.analyser.frequencyBinCount),this.timeDomain=new Uint8Array(this.analyser.frequencyBinCount),this.bass=[20,140],this.lowMid=[140,400],this.mid=[400,2600],this.highMid=[2600,5200],this.treble=[5200,14e3],h.soundArray.push(this)}var t,e,i;return t=n,(e=[{key:"setInput",value:function(t){t?(t.output?t.output.connect(this.analyser):t.connect&&t.connect(this.analyser),h.fftMeter.disconnect()):h.fftMeter.connect(this.analyser)}},{key:"waveform",value:function(){for(var t,e=new Array,n=0;n<arguments.length;n++)"number"==typeof arguments[n]&&(this.bins=arguments[n]),"string"==typeof arguments[n]&&(t=arguments[n]);if(t&&!p5.prototype._isSafari())return(i=this).timeDomain,i.timeDomain instanceof Float32Array==!1&&(i.timeDomain=new Float32Array(i.analyser.frequencyBinCount)),this.analyser.getFloatTimeDomainData(this.timeDomain),this.timeDomain;(i=this).timeDomain,i.timeDomain instanceof Uint8Array==!1&&(i.timeDomain=new Uint8Array(i.analyser.frequencyBinCount)),this.analyser.getByteTimeDomainData(this.timeDomain);for(var i,r=0;r<this.timeDomain.length;r++){var o=p5.prototype.map(this.timeDomain[r],0,255,-1,1);e.push(o)}return e}},{key:"analyze",value:function(){for(var t,e,n=0;n<arguments.length;n++)"number"==typeof arguments[n]&&(this.bins=arguments[n]),"string"==typeof arguments[n]&&(t=arguments[n]);return t&&"db"===t.toLowerCase()?((e=this).freqDomain instanceof Float32Array==!1&&(e.freqDomain=new Float32Array(e.analyser.frequencyBinCount)),this.analyser.getFloatFrequencyData(this.freqDomain),this.freqDomain):((e=this).freqDomain,e.freqDomain instanceof Uint8Array==!1&&(e.freqDomain=new Uint8Array(e.analyser.frequencyBinCount)),this.analyser.getByteFrequencyData(this.freqDomain),Array.apply([],this.freqDomain))}},{key:"getEnergy",value:function(t,e){var n=h.audiocontext.sampleRate/2;if("bass"===t?(t=this.bass[0],e=this.bass[1]):"lowMid"===t?(t=this.lowMid[0],e=this.lowMid[1]):"mid"===t?(t=this.mid[0],e=this.mid[1]):"highMid"===t?(t=this.highMid[0],e=this.highMid[1]):"treble"===t&&(t=this.treble[0],e=this.treble[1]),"number"!=typeof t)throw"invalid input for getEnergy()";if("number"!=typeof e)return i=Math.round(t/n*this.freqDomain.length),this.freqDomain[i];if(t<0||e<0)throw"invalid input for getEnergy(), frequency cannot be a negative number";e<t&&(i=e,e=t,t=i);for(var i=Math.round(t/n*this.freqDomain.length),r=Math.round(e/n*this.freqDomain.length),o=0,s=0,a=i;a<=r;a++)o+=this.freqDomain[a],s+=1;return o/s}},{key:"getFreq",value:function(t,e){return this.getEnergy(t,e)}},{key:"getCentroid",value:function(){for(var t=h.audiocontext.sampleRate/2,e=0,n=0,i=0;i<this.freqDomain.length;i++)e+=i*this.freqDomain[i],n+=this.freqDomain[i];var r=0;return(r=0!==n?e/n:r)*(t/this.freqDomain.length)}},{key:"smooth",value:function(t){return void 0!==t&&(this.smoothing=t),this.smoothing}},{key:"dispose",value:function(){var t=h.soundArray.indexOf(this);h.soundArray.splice(t,1),this.analyser&&(this.analyser.disconnect(),delete this.analyser)}},{key:"linAverages",value:function(t){for(var t=t||16,e=this.freqDomain,n=e.length,i=Math.floor(n/t),r=new Array(t),o=0,s=0;s<n;s++)r[o]=void 0!==r[o]?(r[o]+e[s])/2:e[s],s%i==i-1&&o++;return r}},{key:"logAverages",value:function(t){for(var e=h.audiocontext.sampleRate/2,n=this.freqDomain,i=n.length,r=new Array(t.length),o=0,s=0;s<i;s++)Math.round(s*e/this.freqDomain.length)>t[o].hi&&o++,r[o]=void 0!==r[o]?(r[o]+n[s])/2:n[s];return r}},{key:"getOctaveBands",value:function(t,e){for(var n=t||3,t=e||15.625,i=[],r={lo:t/Math.pow(2,1/(2*n)),ctr:t,hi:t*Math.pow(2,1/(2*n))},o=(i.push(r),h.audiocontext.sampleRate/2);r.hi<o;){var s={};s.lo=r.hi,s.ctr=r.ctr*Math.pow(2,1/n),s.hi=s.ctr*Math.pow(2,1/(2*n)),i.push(s),r=s}return i}},{key:"_onNewInput",value:function(){h.fftMeter.disconnect()}}])&&dt(t.prototype,e),i&&dt(t,i),Object.defineProperty(t,"prototype",{writable:!1}),n}(),vt=e(4),bt=e.n(vt),vt=e(1),y=e.n(vt),vt=e(8),gt=e.n(vt);function _t(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&wt(t,e)}function wt(t,e){return(wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function Tt(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=St(n),e=(t=i?(t=St(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function St(t){return(St=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function d(t){return(d="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)}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Pt(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==d(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==d(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===d(t)?t:String(t)}(i.key),i)}}function v(t,e,n){return e&&Pt(t.prototype,e),n&&Pt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function xt(t,e,n,i,r){for(var o=null,s=null,a=null,u=0;u<t.length;u++)if(t[u]instanceof n){o=0===u?i:t[u-1],s=u===t.length-1?r:t[u+1],a=t[u],t[u]=e;break}null===a&&(o=0===t.length?i:t[t.length-1],s=r,t.push(e)),o.disconnect(),null!==a&&(a.disconnect(),a.dispose()),o.connect(e),e.connect(s)}var b=function(){function i(t,e){var n;m(this,i),"string"==typeof t&&(n=e,e=t,t=n),"number"==typeof e&&(n=e,e=t,t=n),this.started=!1,this.phaseAmount=void 0,this.oscillator=h.audiocontext.createOscillator(),this.f=t||440,this.oscillator.type=e||"sine",this.oscillator.frequency.setValueAtTime(this.f,h.audiocontext.currentTime),this.output=h.audiocontext.createGain(),this._freqMods=[],this.output.gain.value=.5,this.output.gain.setValueAtTime(.5,h.audiocontext.currentTime),this.oscillator.connect(this.output),this.connection=h.input,this.panner=new ot,this.output.connect(this.panner),this.mathOps=[],h.soundArray.push(this),this.fade=this.amp}return v(i,[{key:"start",value:function(t,e){if(this.started&&(i=h.audiocontext.currentTime,this.stop(i)),!this.started){var n,i=e||this.f,e=this.oscillator.type;for(n in this.oscillator&&(this.oscillator.disconnect(),delete this.oscillator),this.oscillator=h.audiocontext.createOscillator(),this.oscillator.frequency.value=Math.abs(i),this.oscillator.type=e,this.oscillator.connect(this.output),this.oscillator.start((t=t||0)+h.audiocontext.currentTime),this.freqNode=this.oscillator.frequency,this._freqMods)void 0!==this._freqMods[n].connect&&this._freqMods[n].connect(this.oscillator.frequency);this.started=!0}}},{key:"stop",value:function(t){var e;this.started&&(e=h.audiocontext.currentTime,this.oscillator.stop((t||0)+e),this.started=!1)}},{key:"amp",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if("number"==typeof t){var n=h.audiocontext.currentTime;this.output.gain.linearRampToValueAtTime(t,n+(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)+e)}else{if(!t)return this.output.gain;t.connect(this.output.gain)}}},{key:"getAmp",value:function(){return this.output.gain.value}},{key:"freq",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;if("number"!=typeof t||isNaN(t)){if(!t)return this.oscillator.frequency;(t=t.output?t.output:t).connect(this.oscillator.frequency),this._freqMods.push(t)}else{this.f=t;var i=h.audiocontext.currentTime;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)}}},{key:"getFreq",value:function(){return this.oscillator.frequency.value}},{key:"setType",value:function(t){this.oscillator.type=t}},{key:"getType",value:function(){return this.oscillator.type}},{key:"connect",value: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(h.input),t&&t._onNewInput&&t._onNewInput(this)}},{key:"disconnect",value:function(){this.output&&this.output.disconnect(),this.panner&&(this.panner.disconnect(),this.output)&&this.output.connect(this.panner),this.oscMods=[]}},{key:"pan",value:function(t,e){this.panner.pan(t,e)}},{key:"getPan",value:function(){return this.panner.getPan()}},{key:"dispose",value:function(){var t=h.soundArray.indexOf(this);h.soundArray.splice(t,1),this.oscillator&&(t=h.audiocontext.currentTime,this.stop(t),this.disconnect(),this.panner.dispose(),this.panner=null,this.oscillator=null),this.osc2&&this.osc2.dispose()}},{key:"phase",value:function(t){var e=p5.prototype.map(t,0,1,0,1/this.f),n=h.audiocontext.currentTime;this.phaseAmount=t,this.dNode||(this.dNode=h.audiocontext.createDelay(),this.oscillator.disconnect(),this.oscillator.connect(this.dNode),this.dNode.connect(this.output)),this.dNode.delayTime.setValueAtTime(e,n)}},{key:"add",value:function(t){t=new bt.a(t);return xt(this.mathOps,t,bt.a,this.oscillator,this.output),this}},{key:"mult",value:function(t){t=new y.a(t);return xt(this.mathOps,t,y.a,this.oscillator,this.output),this}},{key:"scale",value:function(t,e,n,i){var r,n=4===arguments.length?(r=p5.prototype.map(0,t,e,n,i),p5.prototype.map(1,t,e,n,i)):(r=t,e),i=new gt.a(r,n);return xt(this.mathOps,i,gt.a,this.oscillator,this.output),this}}]),i}(),vt=function(){_t(n,b);var e=Tt(n);function n(t){return m(this,n),e.call(this,t,"sine")}return v(n)}(),kt=function(){_t(n,b);var e=Tt(n);function n(t){return m(this,n),e.call(this,t,"triangle")}return v(n)}(),Ot=function(){_t(n,b);var e=Tt(n);function n(t){return m(this,n),e.call(this,t,"sawtooth")}return v(n)}(),At=function(){_t(n,b);var e=Tt(n);function n(t){return m(this,n),e.call(this,t,"square")}return v(n)}(),Ct=b,Rt=e(7),jt=e.n(Rt);function Et(t){return(Et="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)}function Nt(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==Et(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==Et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===Et(t)?t:String(t)}(i.key),i)}}var qt=function(){function s(t,e,n,i,r,o){if(!(this instanceof s))throw new TypeError("Cannot call a class as a function");this.aTime=t||.1,this.aLevel=e||1,this.dTime=n||.5,this.dLevel=i||0,this.rTime=r||0,this.rLevel=o||0,this._rampHighPercentage=.98,this._rampLowPercentage=.02,this.output=h.audiocontext.createGain(),this.control=new jt.a,this._init(),this.control.connect(this.output),this.connection=null,this.mathOps=[this.control],this.isExponential=!1,this.sourceToClear=null,this.wasTriggered=!1,h.soundArray.push(this)}var t,e,n;return t=s,(e=[{key:"_init",value:function(){var t=h.audiocontext.currentTime;this.control.setTargetAtTime(1e-5,t,.001),this._setRampAD(this.aTime,this.dTime)}},{key:"set",value:function(t,e,n,i,r,o){this.aTime=t,this.aLevel=e,this.dTime=n||0,this.dLevel=i||0,this.rTime=r||0,this.rLevel=o||0,this._setRampAD(t,n)}},{key:"setADSR",value:function(t,e,n,i){this.aTime=t,this.dTime=e||0,this.sPercent=n||0,this.dLevel=void 0!==n?n*(this.aLevel-this.rLevel)+this.rLevel:0,this.rTime=i||0,this._setRampAD(t,e)}},{key:"setRange",value:function(t,e){this.aLevel=t||1,this.rLevel=e||0}},{key:"_setRampAD",value:function(t,e){this._rampAttackTime=this.checkExpInput(t),this._rampDecayTime=this.checkExpInput(e);var n=Math.log(1/this.checkExpInput(1-this._rampHighPercentage));this._rampAttackTC=t/this.checkExpInput(n),n=Math.log(1/this._rampLowPercentage),this._rampDecayTC=e/this.checkExpInput(n)}},{key:"setRampPercentages",value:function(t,e){this._rampHighPercentage=this.checkExpInput(t),this._rampLowPercentage=this.checkExpInput(e);t=Math.log(1/this.checkExpInput(1-this._rampHighPercentage));this._rampAttackTC=this._rampAttackTime/this.checkExpInput(t),t=Math.log(1/this._rampLowPercentage),this._rampDecayTC=this._rampDecayTime/this.checkExpInput(t)}},{key:"setInput",value:function(){for(var t=0;t<arguments.length;t++)this.connect(arguments[t])}},{key:"setExp",value:function(t){this.isExponential=t}},{key:"checkExpInput",value:function(t){return t=t<=0?1e-8:t}},{key:"play",value:function(t,e,n){e=e||0;t&&this.connection!==t&&this.connect(t),this.triggerAttack(t,e),this.triggerRelease(t,e+this.aTime+this.dTime+~~n)}},{key:"triggerAttack",value:function(t,e){e=h.audiocontext.currentTime+(e||0),this.lastAttack=e,this.wasTriggered=!0,t&&this.connection!==t&&this.connect(t),t=this.control.getValueAtTime(e);!0===this.isExponential?this.control.exponentialRampToValueAtTime(this.checkExpInput(t),e):this.control.linearRampToValueAtTime(t,e),e+=this.aTime,!0===this.isExponential?(this.control.exponentialRampToValueAtTime(this.checkExpInput(this.aLevel),e),t=this.checkExpInput(this.control.getValueAtTime(e)),this.control.cancelScheduledValues(e),this.control.exponentialRampToValueAtTime(t,e)):(this.control.linearRampToValueAtTime(this.aLevel,e),t=this.control.getValueAtTime(e),this.control.cancelScheduledValues(e),this.control.linearRampToValueAtTime(t,e)),e+=this.dTime,!0===this.isExponential?(this.control.exponentialRampToValueAtTime(this.checkExpInput(this.dLevel),e),t=this.checkExpInput(this.control.getValueAtTime(e)),this.control.cancelScheduledValues(e),this.control.exponentialRampToValueAtTime(t,e)):(this.control.linearRampToValueAtTime(this.dLevel,e),t=this.control.getValueAtTime(e),this.control.cancelScheduledValues(e),this.control.linearRampToValueAtTime(t,e))}},{key:"triggerRelease",value:function(t,e){this.wasTriggered&&(e=h.audiocontext.currentTime+(e||0),t&&this.connection!==t&&this.connect(t),t=this.control.getValueAtTime(e),!0===this.isExponential?this.control.exponentialRampToValueAtTime(this.checkExpInput(t),e):this.control.linearRampToValueAtTime(t,e),e+=this.rTime,!0===this.isExponential?(this.control.exponentialRampToValueAtTime(this.checkExpInput(this.rLevel),e),t=this.checkExpInput(this.control.getValueAtTime(e)),this.control.cancelScheduledValues(e),this.control.exponentialRampToValueAtTime(t,e)):(this.control.linearRampToValueAtTime(this.rLevel,e),t=this.control.getValueAtTime(e),this.control.cancelScheduledValues(e),this.control.linearRampToValueAtTime(t,e)),this.wasTriggered=!1)}},{key:"ramp",value:function(t,e,n,i){e=h.audiocontext.currentTime+(e||0),n=this.checkExpInput(n),i=void 0!==i?this.checkExpInput(i):void 0,t&&this.connection!==t&&this.connect(t),t=this.checkExpInput(this.control.getValueAtTime(e));t<n?(this.control.setTargetAtTime(n,e,this._rampAttackTC),e+=this._rampAttackTime):n<t&&(this.control.setTargetAtTime(n,e,this._rampDecayTC),e+=this._rampDecayTime),void 0!==i&&(n<i?this.control.setTargetAtTime(i,e,this._rampAttackTC):i<n&&this.control.setTargetAtTime(i,e,this._rampDecayTC))}},{key:"connect",value:function(t){(t=(this.connection=t)instanceof p5.Oscillator||t instanceof p5.SoundFile||t instanceof p5.AudioIn||t instanceof p5.Reverb||t instanceof p5.Noise||t instanceof p5.Filter||t instanceof p5.Delay?t.output.gain:t)instanceof AudioParam&&t.setValueAtTime(0,h.audiocontext.currentTime),this.output.connect(t),t&&t._onNewInput&&t._onNewInput(this)}},{key:"disconnect",value:function(){this.output&&this.output.disconnect()}},{key:"add",value:function(t){var t=new bt.a(t),e=this.mathOps.length,n=this.output;return p5.prototype._mathChain(this,t,e,n,bt.a)}},{key:"mult",value:function(t){var t=new y.a(t),e=this.mathOps.length,n=this.output;return p5.prototype._mathChain(this,t,e,n,y.a)}},{key:"scale",value:function(t,e,n,i){t=new gt.a(t,e,n,i),e=this.mathOps.length,n=this.output;return p5.prototype._mathChain(this,t,e,n,gt.a)}},{key:"dispose",value:function(){var t=h.soundArray.indexOf(this);h.soundArray.splice(t,1),this.disconnect(),this.control&&(this.control.dispose(),this.control=null);for(var e=1;e<this.mathOps.length;e++)this.mathOps[e].dispose()}}])&&Nt(t.prototype,e),n&&Nt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),s}();function g(t){return(g="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)}function Bt(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==g(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==g(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===g(t)?t:String(t)}(i.key),i)}}function Vt(t,e){return(Vt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function Mt(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=Ft(n),e=(t=i?(t=Ft(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===g(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function Ft(t){return(Ft=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Dt=function(){for(var t=2*h.audiocontext.sampleRate,e=h.audiocontext.createBuffer(1,t,h.audiocontext.sampleRate),n=e.getChannelData(0),i=0;i<t;i++)n[i]=2*Math.random()-1;return e.type="white",e}(),It=function(){for(var t,e=2*h.audiocontext.sampleRate,n=h.audiocontext.createBuffer(1,e,h.audiocontext.sampleRate),i=n.getChannelData(0),r=s=a=u=c=l=p=t=0;r<e;r++){var o=2*Math.random()-1,s=.99886*s+.0555179*o,a=.99332*a+.0750759*o,u=.969*u+.153852*o,c=.8665*c+.3104856*o,l=.55*l+.5329522*o,p=-.7616*p-.016898*o;i[r]=s+a+u+c+l+p+t+.5362*o,i[r]*=.11,t=.115926*o}return n.type="pink",n}(),Ut=function(){for(var t=2*h.audiocontext.sampleRate,e=h.audiocontext.createBuffer(1,t,h.audiocontext.sampleRate),n=e.getChannelData(0),i=0,r=0;r<t;r++){var o=2*Math.random()-1;n[r]=(i+.02*o)/1.02,i=n[r],n[r]*=3.5}return e.type="brown",e}(),Rt=function(){var t=r,e=Ct;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Vt(t,e);var n,i=Mt(r);function r(t){var e;if(this instanceof r)return delete(e=i.call(this)).f,delete e.freq,delete e.oscillator,e.buffer="brown"===t?Ut:"pink"===t?It:Dt,e;throw new TypeError("Cannot call a class as a function")}return t=r,(e=[{key:"setType",value:function(t){switch(t){case"white":this.buffer=Dt;break;case"pink":this.buffer=It;break;case"brown":this.buffer=Ut;break;default:this.buffer=Dt}this.started&&(t=h.audiocontext.currentTime,this.stop(t),this.start(t+.01))}},{key:"getType",value:function(){return this.buffer.type}},{key:"start",value:function(){this.started&&this.stop(),this.noise=h.audiocontext.createBufferSource(),this.noise.buffer=this.buffer,this.noise.loop=!0,this.noise.connect(this.output);var t=h.audiocontext.currentTime;this.noise.start(t),this.started=!0}},{key:"stop",value:function(){var t=h.audiocontext.currentTime;this.noise&&(this.noise.stop(t),this.started=!1)}},{key:"dispose",value:function(){var t=h.audiocontext.currentTime,e=h.soundArray.indexOf(this);h.soundArray.splice(e,1),this.noise&&(this.noise.disconnect(),this.stop(t)),this.output&&this.output.disconnect(),this.panner&&this.panner.disconnect(),this.output=null,this.panner=null,this.buffer=null,this.noise=null}}])&&Bt(t.prototype,e),n&&Bt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),r}(),Gt=e(2),Lt=e.n(Gt);function _(t){return(_="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)}function zt(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==_(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===_(t)?t:String(t)}(i.key),i)}}function Wt(t,e){return(Wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function Zt(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=Xt(n),e=(t=i?(t=Xt(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===_(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function Xt(t){return(Xt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Yt(){for(var t=h.audiocontext,e=t.createBuffer(1,2048,t.sampleRate),n=e.getChannelData(0),i=0;i<2048;i++)n[i]=1;t=t.createBufferSource();return t.buffer=e,t.loop=!0,t}Gt=function(){var t=r,e=Ct;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Wt(t,e);var n,i=Zt(r);function r(t,e){var n;if(!(this instanceof r))throw new TypeError("Cannot call a class as a function");(n=i.call(this,t,"sawtooth")).w=e||0,n.osc2=new Ot(t),n.dNode=h.audiocontext.createDelay(),n.dcOffset=Yt(),n.dcGain=h.audiocontext.createGain(),n.dcOffset.connect(n.dcGain),n.dcGain.connect(n.output),n.f=t||440;e=n.w/n.oscillator.frequency.value;return n.dNode.delayTime.value=e,n.dcGain.gain.value=1.7*(.5-n.w),n.osc2.disconnect(),n.osc2.panner.disconnect(),n.osc2.amp(-1),n.osc2.output.connect(n.dNode),n.dNode.connect(n.output),n.output.gain.value=1,n.output.connect(n.panner),n}return t=r,(e=[{key:"width",value:function(t){var e,n;"number"==typeof t?(t<=1&&0<=t&&(this.w=t,n=this.w/this.oscillator.frequency.value,this.dNode.delayTime.value=n),this.dcGain.gain.value=1.7*(.5-this.w)):(t.connect(this.dNode.delayTime),n=new Lt.a(-.5),t.connect(n),t=new y.a(-1),e=new y.a(1.7),(n=n.connect(t).connect(e)).connect(this.dcGain.gain))}},{key:"start",value:function(t,e){var n,i=h.audiocontext.currentTime,e=e||0;this.started||(t=t||this.f,n=this.oscillator.type,this.oscillator=h.audiocontext.createOscillator(),this.oscillator.frequency.setValueAtTime(t,i),this.oscillator.type=n,this.oscillator.connect(this.output),this.oscillator.start(e+i),this.osc2.oscillator=h.audiocontext.createOscillator(),this.osc2.oscillator.frequency.setValueAtTime(t,e+i),this.osc2.oscillator.type=n,this.osc2.oscillator.connect(this.osc2.output),this.osc2.start(e+i),this.freqNode=[this.oscillator.frequency,this.osc2.oscillator.frequency],this.dcOffset=Yt(),this.dcOffset.connect(this.dcGain),this.dcOffset.start(e+i),void 0!==this.mods&&void 0!==this.mods.frequency&&(this.mods.frequency.connect(this.freqNode[0]),this.mods.frequency.connect(this.freqNode[1])),this.started=!0,this.osc2.started=!0)}},{key:"stop",value:function(t){var e;this.started&&(e=h.audiocontext.currentTime,this.oscillator.stop((t=t||0)+e),this.osc2.oscillator&&this.osc2.oscillator.stop(t+e),this.dcOffset.stop(t+e),this.started=!1,this.osc2.started=!1)}},{key:"freq",value:function(t){var e,n,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;"number"==typeof t?(this.f=t,e=h.audiocontext.currentTime,n=this.oscillator.frequency.value,this.oscillator.frequency.cancelScheduledValues(e),this.oscillator.frequency.setValueAtTime(n,e+r),this.oscillator.frequency.exponentialRampToValueAtTime(t,r+i+e),this.osc2.oscillator.frequency.cancelScheduledValues(e),this.osc2.oscillator.frequency.setValueAtTime(n,e+r),this.osc2.oscillator.frequency.exponentialRampToValueAtTime(t,r+i+e),this.freqMod&&(this.freqMod.output.disconnect(),this.freqMod=null)):t.output&&(t.output.disconnect(),t.output.connect(this.oscillator.frequency),t.output.connect(this.osc2.oscillator.frequency),this.freqMod=t)}}])&&zt(t.prototype,e),n&&zt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),r}();function Ht(t){return(Ht="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)}function $t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==Ht(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==Ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===Ht(t)?t:String(t)}(i.key),i)}}h.inputSources=[];var Qt=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.input=h.audiocontext.createGain(),this.output=h.audiocontext.createGain(),this.stream=null,this.mediaStream=null,this.currentSource=null,this.enabled=!1,this.amplitude=new ft,this.output.connect(this.amplitude.input),window.MediaStreamTrack&&window.navigator.mediaDevices&&window.navigator.mediaDevices.getUserMedia||(t?t():window.alert("This browser does not support MediaStreamTrack and mediaDevices")),h.soundArray.push(this)}var t,n,i;return t=e,(n=[{key:"start",value:function(e,n){var i=this,t=(this.stream&&this.stop(),h.inputSources[i.currentSource]),r={audio:{sampleRate:h.audiocontext.sampleRate,echoCancellation:!1}};h.inputSources[this.currentSource]&&(r.audio.deviceId=t.deviceId),window.navigator.mediaDevices.getUserMedia(r).then(function(t){i.stream=t,i.enabled=!0,i.mediaStream=h.audiocontext.createMediaStreamSource(t),i.mediaStream.connect(i.output),i.amplitude.setInput(i.output),e&&e()}).catch(function(t){n&&n(t)})}},{key:"stop",value:function(){this.stream&&(this.stream.getTracks().forEach(function(t){t.stop()}),this.mediaStream.disconnect(),delete this.mediaStream,delete this.stream)}},{key:"connect",value:function(t){t?t.hasOwnProperty("input")?this.output.connect(t.input):t.hasOwnProperty("analyser")?this.output.connect(t.analyser):this.output.connect(t):this.output.connect(h.input),t&&t._onNewInput&&t._onNewInput(this)}},{key:"disconnect",value:function(){this.output&&(this.output.disconnect(),this.output.connect(this.amplitude.input))}},{key:"getLevel",value:function(t){return t&&this.amplitude.smooth(t),this.amplitude.getLevel()}},{key:"amp",value:function(t,e){var n;e?(e=e||0,n=this.output.gain.value,this.output.gain.cancelScheduledValues(h.audiocontext.currentTime),this.output.gain.setValueAtTime(n,h.audiocontext.currentTime),this.output.gain.linearRampToValueAtTime(t,e+h.audiocontext.currentTime)):(this.output.gain.cancelScheduledValues(h.audiocontext.currentTime),this.output.gain.setValueAtTime(t,h.audiocontext.currentTime))}},{key:"getSources",value:function(i,r){return new Promise(function(e,n){window.navigator.mediaDevices.enumerateDevices().then(function(t){h.inputSources=t.filter(function(t){return"audioinput"===t.kind}),e(h.inputSources),i&&i(h.inputSources)}).catch(function(t){n(t),r&&r(t)})})}},{key:"setSource",value:function(t){0<h.inputSources.length&&t<h.inputSources.length&&(this.currentSource=t),this.stream&&this.stream.active&&this.start()}},{key:"dispose",value:function(){var t=h.soundArray.indexOf(this);h.soundArray.splice(t,1),this.stop(),this.output&&this.output.disconnect(),this.amplitude&&this.amplitude.dispose(),delete this.amplitude,delete this.output}}])&&$t(t.prototype,n),i&&$t(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function w(t){return(w="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)}function Kt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Jt(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==w(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==w(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===w(t)?t:String(t)}(i.key),i)}}function te(t,e,n){return e&&Jt(t.prototype,e),n&&Jt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function ee(){return(ee="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=T(t)););return t}(t,e);if(i)return(i=Object.getOwnPropertyDescriptor(i,e)).get?i.get.call(arguments.length<3?t:n):i.value}).apply(this,arguments)}function ne(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ie(t,e)}function ie(t,e){return(ie=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function re(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=T(n),e=(t=i?(t=T(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===w(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function T(t){return(T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var oe=function(){ne(i,u);var n=re(i);function i(t){var e;return Kt(this,i),(e=n.call(this)).biquad=e.ac.createBiquadFilter(),e.input.connect(e.biquad),e.biquad.connect(e.wet),t&&e.setType(t),e._on=!0,e._untoggledType=e.biquad.type,e}return te(i,[{key:"process",value:function(t,e,n,i){t.connect(this.input),this.set(e,n,i)}},{key:"set",value:function(t,e,n){t&&this.freq(t,n),e&&this.res(e,n)}},{key:"freq",value:function(t,e){e=e||0;return"number"==typeof(t=t<=0?1:t)?(this.biquad.frequency.cancelScheduledValues(this.ac.currentTime+.01+e),this.biquad.frequency.exponentialRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.biquad.frequency),this.biquad.frequency.value}},{key:"res",value:function(t,e){e=e||0;return"number"==typeof t?(this.biquad.Q.value=t,this.biquad.Q.cancelScheduledValues(this.ac.currentTime+.01+e),this.biquad.Q.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.biquad.Q),this.biquad.Q.value}},{key:"gain",value:function(t,e){e=e||0;return"number"==typeof t?(this.biquad.gain.value=t,this.biquad.gain.cancelScheduledValues(this.ac.currentTime+.01+e),this.biquad.gain.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.biquad.gain),this.biquad.gain.value}},{key:"toggle",value:function(){return this._on=!this._on,!0===this._on?this.biquad.type=this._untoggledType:!1===this._on&&(this.biquad.type="allpass"),this._on}},{key:"setType",value:function(t){this.biquad.type=t,this._untoggledType=this.biquad.type}},{key:"dispose",value:function(){ee(T(i.prototype),"dispose",this).call(this),this.biquad&&(this.biquad.disconnect(),delete this.biquad)}}]),i}(),se=function(){ne(e,oe);var t=re(e);function e(){return Kt(this,e),t.call(this,"lowpass")}return te(e)}(),ae=function(){ne(e,oe);var t=re(e);function e(){return Kt(this,e),t.call(this,"highpass")}return te(e)}(),ue=function(){ne(e,oe);var t=re(e);function e(){return Kt(this,e),t.call(this,"bandpass")}return te(e)}(),ce=oe;function S(t){return(S="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)}function le(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==S(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===S(t)?t:String(t)}(i.key),i)}}function pe(t,e){return(pe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function he(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=fe(n),e=(t=i?(t=fe(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===S(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function fe(t){return(fe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ye=function(){var t=r,e=ce;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&pe(t,e);var n,i=he(r);function r(t,e){var n;if(this instanceof r)return(n=i.call(this,"peaking")).disconnect(),n.set(t,e),n.biquad.gain.value=0,delete n.input,delete n.output,delete n._drywet,delete n.wet,n;throw new TypeError("Cannot call a class as a function")}return t=r,(e=[{key:"amp",value:function(){}},{key:"drywet",value:function(){}},{key:"connect",value:function(t){t=t||p5.soundOut.input;(this.biquad||this.output).connect(t.input||t)}},{key:"disconnect",value:function(){this.biquad&&this.biquad.disconnect()}},{key:"dispose",value:function(){var t=h.soundArray.indexOf(this);h.soundArray.splice(t,1),this.disconnect(),delete this.biquad}}])&&le(t.prototype,e),n&&le(t,n),Object.defineProperty(t,"prototype",{writable:!1}),r}();function P(t){return(P="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)}function de(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==P(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===P(t)?t:String(t)}(i.key),i)}}function me(){return(me="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=x(t)););return t}(t,e);if(i)return(i=Object.getOwnPropertyDescriptor(i,e)).get?i.get.call(arguments.length<3?t:n):i.value}).apply(this,arguments)}function ve(t,e){return(ve=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function be(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=x(n),e=(t=i?(t=x(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===P(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function x(t){return(x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ge=function(){var t=a,e=u;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ve(t,e);var n,s=be(a);function a(t){var e,n,i,r;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");e=s.call(this),n=3===(t=3===t||8===t?t:3)?Math.pow(2,3):2,e.bands=[];for(var o=0;o<t;o++)r=o===t-1?(i=21e3,.01):0===o?(i=100,.1):(i=1===o?3===t?360*n:360:e.bands[o-1].freq()*n,1),e.bands[o]=e._newBand(i,r),(0<o?e.bands[o-1]:e.input).connect(e.bands[o].biquad);return e.bands[t-1].connect(e.output),e}return t=a,(e=[{key:"process",value:function(t){t.connect(this.input)}},{key:"set",value:function(){if(arguments.length!==2*this.bands.length)throw new Error("Argument mismatch. .set() should be called with "+2*this.bands.length+" arguments. (one frequency and gain value pair for each band of the eq)");for(var t=0;t<arguments.length;t+=2)this.bands[t/2].freq(arguments[t]),this.bands[t/2].gain(arguments[t+1])}},{key:"_newBand",value:function(t,e){return new ye(t,e)}},{key:"dispose",value:function(){if(me(x(a.prototype),"dispose",this).call(this),this.bands){for(;0<this.bands.length;)this.bands.pop().dispose();delete this.bands}}}])&&de(t.prototype,e),n&&de(t,n),Object.defineProperty(t,"prototype",{writable:!1}),a}();function _e(t){return(_e="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)}function we(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==_e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==_e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===_e(t)?t:String(t)}(i.key),i)}}var Te=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.ac=h.audiocontext,this.listener=this.ac.listener}var t,n,i;return t=e,(n=[{key:"process",value:function(t){t.connect(this.input)}},{key:"position",value:function(t,e,n,i){return this.positionX(t,i),this.positionY(e,i),this.positionZ(n,i),[this.listener.positionX.value,this.listener.positionY.value,this.listener.positionZ.value]}},{key:"positionX",value:function(t,e){e=e||0;return"number"==typeof t?(this.listener.positionX.value=t,this.listener.positionX.cancelScheduledValues(this.ac.currentTime+.01+e),this.listener.positionX.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.listener.positionX),this.listener.positionX.value}},{key:"positionY",value:function(t,e){e=e||0;return"number"==typeof t?(this.listener.positionY.value=t,this.listener.positionY.cancelScheduledValues(this.ac.currentTime+.01+e),this.listener.positionY.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.listener.positionY),this.listener.positionY.value}},{key:"positionZ",value:function(t,e){e=e||0;return"number"==typeof t?(this.listener.positionZ.value=t,this.listener.positionZ.cancelScheduledValues(this.ac.currentTime+.01+e),this.listener.positionZ.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.listener.positionZ),this.listener.positionZ.value}},{key:"orient",value:function(t,e,n,i,r,o,s){return 3===arguments.length||4===arguments.length?this.orientForward(t,e,n,s=i):6!==arguments.length&&7!==arguments||(this.orientForward(t,e,n),this.orientUp(i,r,o,s)),[this.listener.forwardX.value,this.listener.forwardY.value,this.listener.forwardZ.value,this.listener.upX.value,this.listener.upY.value,this.listener.upZ.value]}},{key:"orientForward",value:function(t,e,n,i){return this.forwardX(t,i),this.forwardY(e,i),this.forwardZ(n,i),[this.listener.forwardX,this.listener.forwardY,this.listener.forwardZ]}},{key:"orientUp",value:function(t,e,n,i){return this.upX(t,i),this.upY(e,i),this.upZ(n,i),[this.listener.upX,this.listener.upY,this.listener.upZ]}},{key:"forwardX",value:function(t,e){e=e||0;return"number"==typeof t?(this.listener.forwardX.value=t,this.listener.forwardX.cancelScheduledValues(this.ac.currentTime+.01+e),this.listener.forwardX.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.listener.forwardX),this.listener.forwardX.value}},{key:"forwardY",value:function(t,e){e=e||0;return"number"==typeof t?(this.listener.forwardY.value=t,this.listener.forwardY.cancelScheduledValues(this.ac.currentTime+.01+e),this.listener.forwardY.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.listener.forwardY),this.listener.forwardY.value}},{key:"forwardZ",value:function(t,e){e=e||0;return"number"==typeof t?(this.listener.forwardZ.value=t,this.listener.forwardZ.cancelScheduledValues(this.ac.currentTime+.01+e),this.listener.forwardZ.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.listener.forwardZ),this.listener.forwardZ.value}},{key:"upX",value:function(t,e){e=e||0;return"number"==typeof t?(this.listener.upX.value=t,this.listener.upX.cancelScheduledValues(this.ac.currentTime+.01+e),this.listener.upX.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.listener.upX),this.listener.upX.value}},{key:"upY",value:function(t,e){e=e||0;return"number"==typeof t?(this.listener.upY.value=t,this.listener.upY.cancelScheduledValues(this.ac.currentTime+.01+e),this.listener.upY.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.listener.upY),this.listener.upY.value}},{key:"upZ",value:function(t,e){e=e||0;return"number"==typeof t?(this.listener.upZ.value=t,this.listener.upZ.cancelScheduledValues(this.ac.currentTime+.01+e),this.listener.upZ.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.listener.upZ),this.listener.upZ.value}}])&&we(t.prototype,n),i&&we(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function k(t){return(k="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)}function Se(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==k(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===k(t)?t:String(t)}(i.key),i)}}function Pe(){return(Pe="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=O(t)););return t}(t,e);if(i)return(i=Object.getOwnPropertyDescriptor(i,e)).get?i.get.call(arguments.length<3?t:n):i.value}).apply(this,arguments)}function xe(t,e){return(xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function ke(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=O(n),e=(t=i?(t=O(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===k(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function O(t){return(O=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Oe=function(){var t=r,e=u;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&xe(t,e);var n,i=ke(r);function r(){var t;if(this instanceof r)return(t=i.call(this)).panner=t.ac.createPanner(),t.panner.panningModel="HRTF",t.panner.distanceModel="linear",t.panner.connect(t.output),t.input.connect(t.panner),t;throw new TypeError("Cannot call a class as a function")}return t=r,(e=[{key:"process",value:function(t){t.connect(this.input)}},{key:"set",value:function(t,e,n,i){return this.positionX(t,i),this.positionY(e,i),this.positionZ(n,i),[this.panner.positionX.value,this.panner.positionY.value,this.panner.positionZ.value]}},{key:"positionX",value:function(t,e){e=e||0;return"number"==typeof t?(this.panner.positionX.value=t,this.panner.positionX.cancelScheduledValues(this.ac.currentTime+.01+e),this.panner.positionX.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.panner.positionX),this.panner.positionX.value}},{key:"positionY",value:function(t,e){e=e||0;return"number"==typeof t?(this.panner.positionY.value=t,this.panner.positionY.cancelScheduledValues(this.ac.currentTime+.01+e),this.panner.positionY.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.panner.positionY),this.panner.positionY.value}},{key:"positionZ",value:function(t,e){e=e||0;return"number"==typeof t?(this.panner.positionZ.value=t,this.panner.positionZ.cancelScheduledValues(this.ac.currentTime+.01+e),this.panner.positionZ.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.panner.positionZ),this.panner.positionZ.value}},{key:"orient",value:function(t,e,n,i){return this.orientX(t,i),this.orientY(e,i),this.orientZ(n,i),[this.panner.orientationX.value,this.panner.orientationY.value,this.panner.orientationZ.value]}},{key:"orientX",value:function(t,e){e=e||0;return"number"==typeof t?(this.panner.orientationX.value=t,this.panner.orientationX.cancelScheduledValues(this.ac.currentTime+.01+e),this.panner.orientationX.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.panner.orientationX),this.panner.orientationX.value}},{key:"orientY",value:function(t,e){e=e||0;return"number"==typeof t?(this.panner.orientationY.value=t,this.panner.orientationY.cancelScheduledValues(this.ac.currentTime+.01+e),this.panner.orientationY.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.panner.orientationY),this.panner.orientationY.value}},{key:"orientZ",value:function(t,e){e=e||0;return"number"==typeof t?(this.panner.orientationZ.value=t,this.panner.orientationZ.cancelScheduledValues(this.ac.currentTime+.01+e),this.panner.orientationZ.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):t&&t.connect(this.panner.orientationZ),this.panner.orientationZ.value}},{key:"setFalloff",value:function(t,e){this.maxDist(t),this.rolloff(e)}},{key:"maxDist",value:function(t){return"number"==typeof t&&(this.panner.maxDistance=t),this.panner.maxDistance}},{key:"rolloff",value:function(t){return"number"==typeof t&&(this.panner.rolloffFactor=t),this.panner.rolloffFactor}},{key:"dispose",value:function(){Pe(O(r.prototype),"dispose",this).call(this),this.panner&&(this.panner.disconnect(),delete this.panner)}}])&&Se(t.prototype,e),n&&Se(t,n),Object.defineProperty(t,"prototype",{writable:!1}),r}();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)}function Ae(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==A(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==A(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===A(t)?t:String(t)}(i.key),i)}}function Ce(){return(Ce="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=C(t)););return t}(t,e);if(i)return(i=Object.getOwnPropertyDescriptor(i,e)).get?i.get.call(arguments.length<3?t:n):i.value}).apply(this,arguments)}function Re(t,e){return(Re=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function je(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=C(n),e=(t=i?(t=C(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===A(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function C(t){return(C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ee=function(){var t=r,e=u;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Re(t,e);var n,i=je(r);function r(){var t;if(this instanceof r)return(t=i.call(this))._split=t.ac.createChannelSplitter(2),t._merge=t.ac.createChannelMerger(2),t._leftGain=t.ac.createGain(),t._rightGain=t.ac.createGain(),t.leftDelay=t.ac.createDelay(),t.rightDelay=t.ac.createDelay(),t._leftFilter=new ce,t._rightFilter=new ce,t._leftFilter.disconnect(),t._rightFilter.disconnect(),t._leftFilter.biquad.frequency.setValueAtTime(1200,t.ac.currentTime),t._rightFilter.biquad.frequency.setValueAtTime(1200,t.ac.currentTime),t._leftFilter.biquad.Q.setValueAtTime(.3,t.ac.currentTime),t._rightFilter.biquad.Q.setValueAtTime(.3,t.ac.currentTime),t.input.connect(t._split),t.leftDelay.connect(t._leftGain),t.rightDelay.connect(t._rightGain),t._leftGain.connect(t._leftFilter.input),t._rightGain.connect(t._rightFilter.input),t._merge.connect(t.wet),t._leftFilter.biquad.gain.setValueAtTime(1,t.ac.currentTime),t._rightFilter.biquad.gain.setValueAtTime(1,t.ac.currentTime),t.setType(0),t._maxDelay=t.leftDelay.delayTime.maxValue,t.feedback(.5),t;throw new TypeError("Cannot call a class as a function")}return t=r,(e=[{key:"process",value:function(t,e,n,i){n=n||0,e=e||0;if(1<=n)throw new Error("Feedback value will force a positive feedback loop.");if(e>=this._maxDelay)throw new Error("Delay Time exceeds maximum delay time of "+this._maxDelay+" second.");t.connect(this.input),this.leftDelay.delayTime.setValueAtTime(e,this.ac.currentTime),this.rightDelay.delayTime.setValueAtTime(e,this.ac.currentTime),this._leftGain.gain.value=n,this._rightGain.gain.value=n,i&&(this._leftFilter.freq(i),this._rightFilter.freq(i))}},{key:"delayTime",value:function(t){"number"!=typeof t?(t.connect(this.leftDelay.delayTime),t.connect(this.rightDelay.delayTime)):(this.leftDelay.delayTime.cancelScheduledValues(this.ac.currentTime),this.rightDelay.delayTime.cancelScheduledValues(this.ac.currentTime),this.leftDelay.delayTime.linearRampToValueAtTime(t,this.ac.currentTime),this.rightDelay.delayTime.linearRampToValueAtTime(t,this.ac.currentTime))}},{key:"feedback",value:function(t){if(t&&"number"!=typeof t)t.connect(this._leftGain.gain),t.connect(this._rightGain.gain);else{if(1<=t)throw new Error("Feedback value will force a positive feedback loop.");"number"==typeof t&&(this._leftGain.gain.value=t,this._rightGain.gain.value=t)}return this._leftGain.gain.value}},{key:"filter",value:function(t,e){this._leftFilter.set(t,e),this._rightFilter.set(t,e)}},{key:"setType",value:function(t){1===t&&(t="pingPong"),this._split.disconnect(),this._leftFilter.disconnect(),this._rightFilter.disconnect(),this._split.connect(this.leftDelay,0),this._split.connect(this.rightDelay,1),"pingPong"===t?(this._rightFilter.setType(this._leftFilter.biquad.type),this._leftFilter.output.connect(this._merge,0,0),this._rightFilter.output.connect(this._merge,0,1),this._leftFilter.output.connect(this.rightDelay),this._rightFilter.output.connect(this.leftDelay)):(this._leftFilter.output.connect(this._merge,0,0),this._rightFilter.output.connect(this._merge,0,1),this._leftFilter.output.connect(this.leftDelay),this._rightFilter.output.connect(this.rightDelay))}},{key:"dispose",value:function(){Ce(C(r.prototype),"dispose",this).call(this),this._split.disconnect(),this._leftFilter.dispose(),this._rightFilter.dispose(),this._merge.disconnect(),this._leftGain.disconnect(),this._rightGain.disconnect(),this.leftDelay.disconnect(),this.rightDelay.disconnect(),this._split=void 0,this._leftFilter=void 0,this._rightFilter=void 0,this._merge=void 0,this._leftGain=void 0,this._rightGain=void 0,this.leftDelay=void 0,this.rightDelay=void 0}}])&&Ae(t.prototype,e),n&&Ae(t,n),Object.defineProperty(t,"prototype",{writable:!1}),r}();function R(t){return(R="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)}function Ne(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function qe(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==R(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==R(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===R(t)?t:String(t)}(i.key),i)}}function Be(t,e,n){e&&qe(t.prototype,e),n&&qe(t,n),Object.defineProperty(t,"prototype",{writable:!1})}function Ve(){return(Ve="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=j(t)););return t}(t,e);if(i)return(i=Object.getOwnPropertyDescriptor(i,e)).get?i.get.call(arguments.length<3?t:n):i.value}).apply(this,arguments)}function Me(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Fe(t,e)}function Fe(t,e){return(Fe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function De(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=j(n),e=(t=i?(t=j(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===R(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function j(t){return(j=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ie=function(){Me(n,u);var e=De(n);function n(){var t;return Ne(this,n),(t=e.call(this))._initConvolverNode(),t.input.gain.value=.5,t._seconds=3,t._decay=2,t._reverse=!1,t._buildImpulse(),t}return Be(n,[{key:"_initConvolverNode",value:function(){this.convolverNode=this.ac.createConvolver(),this.input.connect(this.convolverNode),this.convolverNode.connect(this.wet)}},{key:"_teardownConvolverNode",value:function(){this.convolverNode&&(this.input.disconnect(this.convolverNode),this.convolverNode.disconnect(),delete this.convolverNode)}},{key:"_setBuffer",value:function(t){this._teardownConvolverNode(),this._initConvolverNode(),this.convolverNode.buffer=t}},{key:"process",value:function(t,e,n,i){t.connect(this.input),this.set(e,n,i)}},{key:"set",value:function(t,e,n){var i=!1;t&&(this._seconds=t,i=!0),e&&(this._decay=e),n&&(this._reverse=n),i&&this._buildImpulse()}},{key:"_buildImpulse",value:function(){for(var t,e=this.ac.sampleRate,n=e*this._seconds,i=this._decay,e=this.ac.createBuffer(2,n,e),r=e.getChannelData(0),o=e.getChannelData(1),s=0;s<n;s++)t=this._reverse?n-s:s,r[s]=(2*Math.random()-1)*Math.pow(1-t/n,i),o[s]=(2*Math.random()-1)*Math.pow(1-t/n,i);this._setBuffer(e)}},{key:"dispose",value:function(){Ve(j(n.prototype),"dispose",this).call(this),this._teardownConvolverNode()}}]),n}(),Ue=function(){Me(o,Ie);var r=De(o);function o(t,e,n){var i;return Ne(this,o),(i=r.call(this))._initConvolverNode(),i.input.gain.value=.5,t?(i.impulses=[],i._loadBuffer(t,e,n)):(i._seconds=3,i._decay=2,i._reverse=!1,i._buildImpulse()),i.impulses=[],i.set=null,i}return Be(o,[{key:"_loadBuffer",value:function(t,i,n){var r=p5.prototype._checkFileFormats(t),o=this,s=(new Error).stack,a=Object(c.b)(),u=new XMLHttpRequest;u.open("GET",r,!0),u.responseType="arraybuffer",u.onload=function(){var t,e;200===u.status?a.decodeAudioData(u.response,function(t){var e={},n=r.split("/");e.name=n[n.length-1],e.audioBuffer=t,o.impulses.push(e),o._setBuffer(e.audioBuffer),i&&i(e)},function(){var t=new l("decodeAudioData",s,o.url),e="AudioContext error at decodeAudioData for "+o.url;n&&(t.msg=e,n(t))}):(t=new l("loadConvolver",s,o.url),e="Unable to load "+o.url+". The request status was: "+u.status+" ("+u.statusText+")",n&&(t.message=e,n(t)))},u.onerror=function(){var t=new l("loadConvolver",s,o.url),e="There was no response from the server at "+o.url+". Check the url and internet connectivity.";n&&(t.message=e,n(t))},u.send()}},{key:"process",value:function(t){t.connect(this.input)}},{key:"addImpulse",value:function(t,e,n){-1<window.location.origin.indexOf("file://")&&"undefined"===window.cordova&&alert("This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS"),this._loadBuffer(t,e,n)}},{key:"resetImpulse",value:function(t,e,n){-1<window.location.origin.indexOf("file://")&&"undefined"===window.cordova&&alert("This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS"),this.impulses=[],this._loadBuffer(t,e,n)}},{key:"toggleImpulse",value:function(t){if("number"==typeof t&&t<this.impulses.length&&this._setBuffer(this.impulses[t].audioBuffer),"string"==typeof t)for(var e=0;e<this.impulses.length;e++)if(this.impulses[e].name===t){this._setBuffer(this.impulses[e].audioBuffer);break}}},{key:"dispose",value:function(){for(var t in Ve(j(o.prototype),"dispose",this).call(this),this.impulses)this.impulses[t]&&(this.impulses[t]=null)}}]),o}();var Ge=e(11),Le=e.n(Ge);function ze(t){return(ze="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)}function We(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==ze(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===ze(t)?t:String(t)}(i.key),i)}}var Ze=function(){function t(){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");this.clock=new Le.a({callback:this.ontick.bind(this)}),this.syncedParts=[],this.bpm=120,this._init(),this.prevTick=0,this.tatumTime=0,this.tickCallback=function(){}}var e,n,i;return e=t,(n=[{key:"ontick",value:function(t){var i,e=t-this.prevTick,r=t-h.audiocontext.currentTime;e-this.tatumTime<=-.02||(this.prevTick=t,(i=this).syncedParts.forEach(function(t){t.isPlaying&&(t.incrementStep(r),t.phrases.forEach(function(t){var e=t.sequence,n=i.metroTicks%e.length;0!==e[n]&&(i.metroTicks<e.length||!t.looping)&&t.callback(r,e[n])}))}),this.metroTicks+=1,this.tickCallback(r))}},{key:"setBPM",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=60/(t*this.tatums),i=h.audiocontext.currentTime;this.tatumTime=n,this.clock.frequency.setValueAtTime(this.clock.frequency.value,i),this.clock.frequency.linearRampToValueAtTime(t,i+e),this.bpm=t}},{key:"getBPM",value:function(){return this.bpm}},{key:"_init",value:function(){this.metroTicks=0}},{key:"resetSync",value:function(t){this.syncedParts=[t]}},{key:"pushSync",value:function(t){this.syncedParts.push(t)}},{key:"start",value:function(t){var e=h.audiocontext.currentTime;this.clock.start(e+(t||0)),this.setBPM(this.bpm)}},{key:"stop",value:function(t){var e=h.audiocontext.currentTime;this.clock.stop(e+(t||0))}},{key:"beatLength",value:function(t){this.tatums=1/t/4}}])&&We(e.prototype,n),i&&We(e,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();function Xe(t){return(Xe="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)}function Ye(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==Xe(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==Xe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===Xe(t)?t:String(t)}(i.key),i)}}function He(t,e,n){return e&&Ye(t.prototype,e),n&&Ye(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function $e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var Qe=120,Ke=(p5.prototype.setBPM=function(t,e){for(var n in Qe=t,h.parts)h.parts[n]&&h.parts[n].setBPM(t,e)},He(function t(e,n,i){$e(this,t),this.phraseStep=0,this.name=e,this.callback=n,this.sequence=i})),e=function(){function n(t,e){$e(this,n),this.length=t||0,this.partStep=0,this.phrases=[],this.isPlaying=!1,this.noLoop(),this.tatums=e||.0625,this.metro=new Ze,this.metro._init(),this.metro.beatLength(this.tatums),this.metro.setBPM(Qe),h.parts.push(this),this.callback=function(){}}return He(n,[{key:"setBPM",value:function(t,e){this.metro.setBPM(t,e)}},{key:"getBPM",value:function(){return this.metro.getBPM()}},{key:"start",value:function(t){this.isPlaying||(this.isPlaying=!0,this.metro.resetSync(this),this.metro.start(t||0))}},{key:"loop",value:function(t){this.looping=!0,this.onended=function(){this.partStep=0},this.start(t||0)}},{key:"noLoop",value:function(){this.looping=!1,this.onended=function(){this.stop()}}},{key:"stop",value:function(t){this.partStep=0,this.pause(t)}},{key:"pause",value:function(t){this.isPlaying=!1,this.metro.stop(t||0)}},{key:"addPhrase",value:function(t,e,n){var i;if(3===arguments.length)i=new Ke(t,e,n);else{if(!(t instanceof Ke))throw"invalid input. addPhrase accepts name, callback, array or a p5.Phrase";i=t}this.phrases.push(i),i.sequence.length>this.length&&(this.length=i.sequence.length)}},{key:"removePhrase",value:function(t){for(var e in this.phrases)this.phrases[e].name===t&&this.phrases.splice(e,1)}},{key:"getPhrase",value:function(t){for(var e in this.phrases)if(this.phrases[e].name===t)return this.phrases[e]}},{key:"replaceSequence",value:function(t,e){for(var n in this.phrases)this.phrases[n].name===t&&(this.phrases[n].sequence=e)}},{key:"incrementStep",value:function(t){this.partStep<this.length-1?(this.callback(t),this.partStep+=1):this.looping||this.partStep!==this.length-1||this.onended()}},{key:"onStep",value:function(t){this.callback=t}}]),n}(),Ge=function(){function t(){$e(this,t),this.parts=[],this.currentPart=0;var e,n=this;for(e in arguments)this.parts[e]=arguments[e],0<e&&(this.parts[e-1].nextPart=this.parts[e]),this.parts[e].onended=function(){var t;n.resetPart(e),(t=n).currentPart++,t.currentPart>=t.parts.length?(t.scoreStep=0,t.onended()):(t.scoreStep=0,t.parts[t.currentPart-1].stop(),t.parts[t.currentPart].start())};this.looping=!1}return He(t,[{key:"onended",value:function(){this.looping?this.parts[0].start():this.parts[this.parts.length-1].onended=function(){this.stop(),this.resetParts()},this.currentPart=0}},{key:"start",value:function(){this.parts[this.currentPart].start(),this.scoreStep=0}},{key:"stop",value:function(){this.parts[this.currentPart].stop(),this.currentPart=0,this.scoreStep=0}},{key:"pause",value:function(){this.parts[this.currentPart].stop()}},{key:"loop",value:function(){this.looping=!0,this.start()}},{key:"noLoop",value:function(){this.looping=!1}},{key:"resetParts",value:function(){var e=this;this.parts.forEach(function(t){e.resetParts[t]})}},{key:"resetPart",value:function(t){for(var e in this.parts[t].stop(),this.parts[t].partStep=0,this.parts[t].phrases)this.parts[t]&&(this.parts[t].phrases[e].phraseStep=0)}},{key:"setBPM",value:function(t,e){for(var n in this.parts)this.parts[n]&&this.parts[n].setBPM(t,e)}}]),t}();function Je(t){return(Je="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)}function tn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==Je(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==Je(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===Je(t)?t:String(t)}(i.key),i)}}var en=function(){function i(t,e){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");Object.defineProperty(this,"bpm",{get:function(){return this._bpm},set:function(t){this.musicalTimeMode,this._bpm=t,this._update()}}),Object.defineProperty(this,"timeSignature",{get:function(){return this._timeSignature},set:function(t){this.musicalTimeMode,this._timeSignature=t,this._update()}}),Object.defineProperty(this,"interval",{get:function(){return this._interval},set:function(t){this.musicalTimeMode="number"!=typeof t,this._interval=t,this._update()}}),Object.defineProperty(this,"iterations",{get:function(){return this.clock.ticks}}),this.callback=t,this.musicalTimeMode="number"!=typeof this._interval,this._interval=e||1,this._timeSignature=4,this._bpm=60,this.isPlaying=!1,this.maxIterations=1/0;var n=this;this.clock=new Le.a({callback:function(t){t-=h.audiocontext.currentTime;0<t&&n.iterations<=n.maxIterations&&n.callback&&n.callback(t)},frequency:this._calcFreq()})}var t,e,n;return t=i,(e=[{key:"start",value:function(t){var e=h.audiocontext.currentTime;this.isPlaying||(this.clock.start(e+(t||0)),this.isPlaying=!0)}},{key:"stop",value:function(t){var e=h.audiocontext.currentTime;this.isPlaying&&(this.clock.stop(e+(t||0)),this.isPlaying=!1)}},{key:"pause",value:function(t){var e=h.audiocontext.currentTime;this.isPlaying&&(this.clock.pause(e+(t||0)),this.isPlaying=!1)}},{key:"syncedStart",value:function(t,e){var n,e=e||0,i=h.audiocontext.currentTime;t.isPlaying?t.isPlaying&&(n=t.clock._nextTick-h.audiocontext.currentTime,this.clock.start(i+n),this.isPlaying=!0):(t.clock.start(i+e),t.isPlaying=!0,this.clock.start(i+e),this.isPlaying=!0)}},{key:"_update",value:function(){this.clock.frequency.value=this._calcFreq()}},{key:"_calcFreq",value:function(){return"number"==typeof this._interval?(this.musicalTimeMode=!1,1/this._interval):"string"==typeof this._interval?(this.musicalTimeMode=!0,this._bpm/60/this._convertNotation(this._interval)*(this._timeSignature/4)):void 0}},{key:"_convertNotation",value:function(t){var e=t.slice(-1);switch(t=Number(t.slice(0,-1)),e){case"m":return this._measure(t);case"n":return this._note(t)}}},{key:"_measure",value:function(t){return t*this._timeSignature}},{key:"_note",value:function(t){return this._timeSignature/t}}])&&tn(t.prototype,e),n&&tn(t,n),Object.defineProperty(t,"prototype",{writable:!1}),i}();function E(t){return(E="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)}function nn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==E(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==E(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===E(t)?t:String(t)}(i.key),i)}}function rn(){return(rn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=N(t)););return t}(t,e);if(i)return(i=Object.getOwnPropertyDescriptor(i,e)).get?i.get.call(arguments.length<3?t:n):i.value}).apply(this,arguments)}function on(t,e){return(on=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function sn(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=N(n),e=(t=i?(t=N(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===E(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function N(t){return(N=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var an=function(){var t=r,e=u;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&on(t,e);var n,i=sn(r);function r(){var t;if(this instanceof r)return(t=i.call(this)).compressor=t.ac.createDynamicsCompressor(),t.input.connect(t.compressor),t.compressor.connect(t.wet),t;throw new TypeError("Cannot call a class as a function")}return t=r,(e=[{key:"process",value:function(t,e,n,i,r,o){t.connect(this.input),this.set(e,n,i,r,o)}},{key:"set",value:function(t,e,n,i,r){void 0!==t&&this.attack(t),void 0!==e&&this.knee(e),void 0!==n&&this.ratio(n),void 0!==i&&this.threshold(i),void 0!==r&&this.release(r)}},{key:"attack",value:function(t,e){e=e||0;return"number"==typeof t?(this.compressor.attack.value=t,this.compressor.attack.cancelScheduledValues(this.ac.currentTime+.01+e),this.compressor.attack.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):void 0!==t&&t.connect(this.compressor.attack),this.compressor.attack.value}},{key:"knee",value:function(t,e){e=e||0;return"number"==typeof t?(this.compressor.knee.value=t,this.compressor.knee.cancelScheduledValues(this.ac.currentTime+.01+e),this.compressor.knee.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):void 0!==t&&t.connect(this.compressor.knee),this.compressor.knee.value}},{key:"ratio",value:function(t,e){e=e||0;return"number"==typeof t?(this.compressor.ratio.value=t,this.compressor.ratio.cancelScheduledValues(this.ac.currentTime+.01+e),this.compressor.ratio.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):void 0!==t&&t.connect(this.compressor.ratio),this.compressor.ratio.value}},{key:"threshold",value:function(t,e){e=e||0;return"number"==typeof t?(this.compressor.threshold.value=t,this.compressor.threshold.cancelScheduledValues(this.ac.currentTime+.01+e),this.compressor.threshold.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):void 0!==t&&t.connect(this.compressor.threshold),this.compressor.threshold.value}},{key:"release",value:function(t,e){e=e||0;return"number"==typeof t?(this.compressor.release.value=t,this.compressor.release.cancelScheduledValues(this.ac.currentTime+.01+e),this.compressor.release.linearRampToValueAtTime(t,this.ac.currentTime+.02+e)):"undefined"!=typeof number&&t.connect(this.compressor.release),this.compressor.release.value}},{key:"reduction",value:function(){return this.compressor.reduction}},{key:"dispose",value:function(){rn(N(r.prototype),"dispose",this).call(this),this.compressor&&(this.compressor.disconnect(),delete this.compressor)}}])&&nn(t.prototype,e),n&&nn(t,n),Object.defineProperty(t,"prototype",{writable:!1}),r}();function un(t){return(un="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)}function cn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==un(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==un(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===un(t)?t:String(t)}(i.key),i)}}var ln=function(){function r(t,e,n,i){if(!(this instanceof r))throw new TypeError("Cannot call a class as a function");this.framesPerPeak=i||20,this.framesSinceLastPeak=0,this.decayRate=.95,this.threshold=n||.35,this.cutoff=0,this.cutoffMult=1.5,this.energy=0,this.penergy=0,this.currentValue=0,this.isDetected=!1,this.f1=t||40,this.f2=e||2e4,this._onPeak=function(){}}var t,e,n;return t=r,(e=[{key:"update",value:function(t){t=this.energy=t.getEnergy(this.f1,this.f2)/255;t>this.cutoff&&t>this.threshold&&0<t-this.penergy?(this._onPeak(),this.isDetected=!0,this.cutoff=t*this.cutoffMult,this.framesSinceLastPeak=0):(this.isDetected=!1,this.framesSinceLastPeak<=this.framesPerPeak?this.framesSinceLastPeak++:(this.cutoff*=this.decayRate,this.cutoff=Math.max(this.cutoff,this.threshold))),this.currentValue=t,this.penergy=t}},{key:"onPeak",value:function(t,e){var n=this;n._onPeak=function(){t(n.energy,e)}}}])&&cn(t.prototype,e),n&&cn(t,n),Object.defineProperty(t,"prototype",{writable:!1}),r}();function pn(t){return(pn="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)}function hn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==pn(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==pn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===pn(t)?t:String(t)}(i.key),i)}}var fn=h.audiocontext,yn=function(){function e(){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.input=fn.createGain(),this.output=fn.createGain(),this._inputChannels=2,this._outputChannels=2;var t=this.bufferSize=W(1024);this._workletNode=new AudioWorkletNode(fn,I.a.recorderProcessor,{outputChannelCount:[this._outputChannels],processorOptions:{numInputChannels:this._inputChannels,bufferSize:t}}),this._workletNode.port.onmessage=function(t){"buffers"===t.data.name&&(t=[new Float32Array(t.data.leftBuffer),new Float32Array(t.data.rightBuffer)],this._callback(t))}.bind(this),this._callback=function(){},this._workletNode.connect(p5.soundOut._silentNode),this.setInput(),h.soundArray.push(this)}var t,n,i;return t=e,(n=[{key:"setInput",value:function(t){this.input.disconnect(),this.input=null,this.input=fn.createGain(),this.input.connect(this._workletNode),this.input.connect(this.output),(t||p5.soundOut.output).connect(this.input)}},{key:"record",value:function(e,t,n){this._workletNode.port.postMessage({name:"start",duration:t}),e&&n?this._callback=function(t){e.setBuffer(t),n()}:e&&(this._callback=function(t){e.setBuffer(t)})}},{key:"stop",value:function(){this._workletNode.port.postMessage({name:"stop"})}},{key:"dispose",value:function(){var t=h.soundArray.indexOf(this);h.soundArray.splice(t,1),this._callback=function(){},this.input&&this.input.disconnect(),this.input=null,this._workletNode=null}}])&&hn(t.prototype,n),i&&hn(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function q(t){return(q="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)}function dn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==q(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===q(t)?t:String(t)}(i.key),i)}}function mn(){return(mn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=B(t)););return t}(t,e);if(i)return(i=Object.getOwnPropertyDescriptor(i,e)).get?i.get.call(arguments.length<3?t:n):i.value}).apply(this,arguments)}function vn(t,e){return(vn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function bn(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=B(n),e=(t=i?(t=B(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===q(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function B(t){return(B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function gn(t){for(var e,n="number"==typeof t?t:50,i=new Float32Array(44100),r=Math.PI/180,o=0;o<44100;++o)i[o]=(3+n)*(e=2*o/44100-1)*20*r/(Math.PI+n*Math.abs(e));return i}var _n=function(){var t=o,e=u;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&vn(t,e);var n,r=bn(o);function o(t,e){var n;if(!(this instanceof o))throw new TypeError("Cannot call a class as a function");if(n=r.call(this),"number"!=typeof(t=void 0===t?.25:t))throw new Error("amount must be a number");if("string"!=typeof(e=void 0===e?"2x":e))throw new Error("oversample must be a String");var i=p5.prototype.map(t,0,1,0,2e3);return n.waveShaperNode=n.ac.createWaveShaper(),n.amount=t,n.waveShaperNode.curve=gn(i),n.waveShaperNode.oversample=e,n.input.connect(n.waveShaperNode),n.waveShaperNode.connect(n.wet),n}return t=o,(e=[{key:"process",value:function(t,e,n){t.connect(this.input),this.set(e,n)}},{key:"set",value:function(t,e){var n;"number"==typeof t&&(n=p5.prototype.map(t,0,1,0,2e3),this.amount=t,this.waveShaperNode.curve=gn(n)),e&&(this.waveShaperNode.oversample=e)}},{key:"getAmount",value:function(){return this.amount}},{key:"getOversample",value:function(){return this.waveShaperNode.oversample}},{key:"dispose",value:function(){mn(B(o.prototype),"dispose",this).call(this),this.waveShaperNode&&(this.waveShaperNode.disconnect(),this.waveShaperNode=null)}}])&&dn(t.prototype,e),n&&dn(t,n),Object.defineProperty(t,"prototype",{writable:!1}),o}();function wn(t){return(wn="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)}function Tn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==wn(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==wn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===wn(t)?t:String(t)}(i.key),i)}}var Sn=function(){function t(){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");this.ac=h.audiocontext,this.input=this.ac.createGain(),this.output=this.ac.createGain(),this.input.gain.value=.5,this.input.connect(this.output),h.soundArray.push(this)}var e,n,i;return e=t,(n=[{key:"setInput",value:function(t){t.connect(this.input)}},{key:"connect",value:function(t){var e=t||p5.soundOut.input;this.output.connect(e.input||e),t&&t._onNewInput&&t._onNewInput(this)}},{key:"disconnect",value:function(){this.output&&this.output.disconnect()}},{key:"amp",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=h.audiocontext.currentTime,r=this.output.gain.value;this.output.gain.cancelScheduledValues(i),this.output.gain.linearRampToValueAtTime(r,i+n),this.output.gain.linearRampToValueAtTime(t,i+n+e)}},{key:"dispose",value:function(){var t=h.soundArray.indexOf(this);h.soundArray.splice(t,1),this.output&&(this.output.disconnect(),delete this.output),this.input&&(this.input.disconnect(),delete this.input)}}])&&Tn(e.prototype,n),i&&Tn(e,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();function Pn(t){return(Pn="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)}function xn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==Pn(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==Pn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===Pn(t)?t:String(t)}(i.key),i)}}function kn(t,e){return(kn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function On(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=An(n),e=(t=i?(t=An(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===Pn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function An(t){return(An=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Cn=function(){var t=a,e=qt;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&kn(t,e);var n,i,s=On(a);function a(t,e,n,i,r,o){if(this instanceof a)return s.call(this,t,e,n,i,r,o);throw new TypeError("Cannot call a class as a function")}return t=a,n&&xn(t.prototype,n),i&&xn(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}();function Rn(t){return(Rn="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)}function jn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==Rn(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==Rn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===Rn(t)?t:String(t)}(i.key),i)}}var En=function(){function t(){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");this.ac=h.audiocontext,this.output=this.ac.createGain(),this.connect(),h.soundArray.push(this)}var e,n,i;return e=t,(n=[{key:"play",value:function(t,e,n,i){}},{key:"triggerAttack",value:function(t,e,n){}},{key:"triggerRelease",value:function(t){}},{key:"amp",value:function(t,e){}},{key:"setADSR",value:function(t,e,n,i){}},{key:"connect",value:function(t){var e=t||h.input;this.output.connect(e.input||e),t&&t._onNewInput&&t._onNewInput(this)}},{key:"disconnect",value:function(){this.output.disconnect()}},{key:"dispose",value:function(){this.output&&(this.output.disconnect(),delete this.output)}}])&&jn(e.prototype,n),i&&jn(e,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();function Nn(t){return(Nn="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)}function qn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==Nn(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==Nn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===Nn(t)?t:String(t)}(i.key),i)}}function Bn(){return(Bn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Dn(t)););return t}(t,e);if(i)return(i=Object.getOwnPropertyDescriptor(i,e)).get?i.get.call(arguments.length<3?t:n):i.value}).apply(this,arguments)}function Vn(t,e){return(Vn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function Mn(n){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=Dn(n),e=(t=i?(t=Dn(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"===Nn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Fn(e)}}function Fn(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Dn(t){return(Dn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var In=function(){var t=r,e=En;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Vn(t,e);var n,i=Mn(r);function r(){var t;if(this instanceof r)return(t=i.call(this)).oscillator=new Ct,t.env=new qt,t.env.setRange(1,0),t.env.setExp(!0),t.setADSR(.02,.25,.05,.35),t.oscillator.disconnect(),t.oscillator.connect(t.output),t.env.disconnect(),t.env.setInput(t.output.gain),t.oscillator.output.gain.value=1,t.oscillator.start(),t.connect(),h.soundArray.push(Fn(t)),Object.defineProperties(Fn(t),{attack:{get:function(){return this.env.aTime},set:function(t){this.env.setADSR(t,this.env.dTime,this.env.sPercent,this.env.rTime)}},decay:{get:function(){return this.env.dTime},set:function(t){this.env.setADSR(this.env.aTime,t,this.env.sPercent,this.env.rTime)}},sustain:{get:function(){return this.env.sPercent},set:function(t){this.env.setADSR(this.env.aTime,this.env.dTime,t,this.env.rTime)}},release:{get:function(){return this.env.rTime},set:function(t){this.env.setADSR(this.env.aTime,this.env.dTime,this.env.sPercent,t)}}}),t;throw new TypeError("Cannot call a class as a function")}return t=r,(e=[{key:"play",value:function(t,e,n,i){this.triggerAttack(t,e,~~n),this.triggerRelease(~~n+(i||.15))}},{key:"triggerAttack",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,t=G(t),e=e||.1;this.oscillator.freq(t,0,n),this.env.ramp(this.output.gain,n,e)}},{key:"triggerRelease",value:function(){this.env.ramp(this.output.gain,0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,0)}},{key:"setADSR",value:function(t,e,n,i){this.env.setADSR(t,e,n,i)}},{key:"setType",value:function(t){this.oscillator.setType(t)}},{key:"getType",value:function(){return this.oscillator.getType()}},{key:"amp",value:function(t,e){return void 0!==t&&this.oscillator.amp(t,e||0),this.oscillator.amp().value}},{key:"connect",value:function(t){var e=t||h.input;this.output.connect(e.input||e),t&&t._onNewInput&&t._onNewInput(this)}},{key:"disconnect",value:function(){this.output&&this.output.disconnect()}},{key:"dispose",value:function(){Bn(Dn(r.prototype),"dispose",this).call(this),this.env&&this.env.dispose(),this.oscillator&&this.oscillator.dispose()}}])&&qn(t.prototype,e),n&&qn(t,n),Object.defineProperty(t,"prototype",{writable:!1}),r}();function Un(t){return(Un="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)}function Gn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==Un(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==Un(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===Un(t)?t:String(t)}(i.key),i)}}var Ln=function(){function r(t,e,n,i){if(!(this instanceof r))throw new TypeError("Cannot call a class as a function");this.isDetected=!1,this.freqLow=t,this.freqHigh=e,this.treshold=n,this.energy=0,this.penergy=0,this.sensitivity=500,this.callback=i}var t,e,n;return t=r,(e=[{key:"update",value:function(t,e){var n;this.energy=t.getEnergy(this.freqLow,this.freqHigh)/255,!1===this.isDetected&&this.energy-this.penergy>this.treshold&&(this.isDetected=!0,this.callback?this.callback(this.energy):e&&e(this.energy),n=this,setTimeout(function(){n.isDetected=!1},this.sensitivity)),this.penergy=this.energy}}])&&Gn(t.prototype,e),n&&Gn(t,n),Object.defineProperty(t,"prototype",{writable:!1}),r}();function zn(t){return(zn="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)}function Wn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==zn(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==zn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===zn(t)?t:String(t)}(i.key),i)}}var Zn=function(){function n(t,e){if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");this.audiovoices=[],this.notes={},this._newest=0,this._oldest=0,this.maxVoices=e||8,this.AudioVoice=void 0===t?p5.MonoSynth:t,this._voicesInUse=new jt.a(0),this.output=h.audiocontext.createGain(),this.connect(),this._allocateVoices(),h.soundArray.push(this)}var t,e,i;return t=n,(e=[{key:"_allocateVoices",value:function(){for(var t=0;t<this.maxVoices;t++)this.audiovoices.push(new this.AudioVoice),this.audiovoices[t].disconnect(),this.audiovoices[t].connect(this.output)}},{key:"play",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.1,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:1;this.noteAttack(t,e,n),this.noteRelease(t,n+i)}},{key:"noteADSR",value:function(t,e,n,i,r){var o=h.audiocontext.currentTime;this.audiovoices[this.notes[t].getValueAtTime(o+(5<arguments.length&&void 0!==arguments[5]?arguments[5]:0))].setADSR(e,n,i,r)}},{key:"setADSR",value:function(e,n,i,r){this.audiovoices.forEach(function(t){t.setADSR(e,n,i,r)})}},{key:"noteAttack",value:function(t,e){var n,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=h.audiocontext.currentTime+i,t=G(t),e=e||.1,o=(this.notes[t]&&null!==this.notes[t].getValueAtTime(r)&&this.noteRelease(t,0),this._voicesInUse.getValueAtTime(r)<this.maxVoices?n=Math.max(~~this._voicesInUse.getValueAtTime(r),0):(n=this._oldest,o=this.audiovoices[this._oldest].oscillator.freq().value,this.noteRelease(o),this._oldest=(this._oldest+1)%(this.maxVoices-1)),this.notes[t]=new jt.a,this.notes[t].setValueAtTime(n,r),null===this._voicesInUse._searchBefore(r)?0:this._voicesInUse._searchBefore(r).value);this._voicesInUse.setValueAtTime(o+1,r),this._updateAfter(r,1),this._newest=n,"number"==typeof e&&(e=(o=1/this._voicesInUse.getValueAtTime(r)*2)<e?o:e),this.audiovoices[n].triggerAttack(t,e,i)}},{key:"_updateAfter",value:function(t,e){null!==this._voicesInUse._searchAfter(t)&&(this._voicesInUse._searchAfter(t).value+=e,t=this._voicesInUse._searchAfter(t).time,this._updateAfter(t,e))}},{key:"noteRelease",value:function(t,e){var n=h.audiocontext.currentTime,i=e||0,e=n+i;if(t){n=G(t);this.notes[n]&&null!==this.notes[n].getValueAtTime(e)&&(t=Math.max(~~this._voicesInUse.getValueAtTime(e),1),this._voicesInUse.setValueAtTime(t-1,e),0<t&&this._updateAfter(e,-1),this.audiovoices[this.notes[n].getValueAtTime(e)].triggerRelease(i),this.notes[n].dispose(),delete this.notes[n],this._newest=0===this._newest?0:(this._newest-1)%(this.maxVoices-1))}else{for(var r in this.audiovoices.forEach(function(t){t.triggerRelease(i)}),this._voicesInUse.setValueAtTime(0,e),this.notes)this.notes[r].dispose(),delete this.notes[r];this._newest=0,this._oldest=0}}},{key:"connect",value:function(t){var e=t||h.input;this.output.connect(e.input||e),t&&t._onNewInput&&t._onNewInput(this)}},{key:"disconnect",value:function(){this.output&&this.output.disconnect()}},{key:"dispose",value:function(){this.audiovoices.forEach(function(t){t.dispose()}),this.output&&(this.output.disconnect(),delete this.output)}}])&&Wn(t.prototype,e),i&&Wn(t,i),Object.defineProperty(t,"prototype",{writable:!1}),n}();function Xn(t){return(Xn="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)}function Yn(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==Xn(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==Xn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===Xn(t)?t:String(t)}(i.key),i)}}function Hn(t,e,n){return e&&Yn(t.prototype,e),n&&Yn(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}var $n=Hn(function t(){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function")});p5.prototype.getAudioContext=c.b,p5.prototype.userStartAudio=c.c,p5.prototype.sampleRate=function(){return h.audiocontext.sampleRate},p5.prototype.freqToMidi=function(t){return t=Math.log(t/440)/Math.log(2),Math.round(12*t)+69},p5.prototype.midiToFreq=n,p5.prototype.noteToFreq=G,p5.prototype.soundFormats=function(){h.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!";h.extensions.push(arguments[t])}},p5.prototype.disposeSound=function(){for(var t=h.soundArray.length-1;0<=t;t--)h.soundArray[t].dispose()},p5.prototype._checkFileFormats=function(t){if("string"==typeof t){var e,n=(e=t).split(".").pop();if(-1<["mp3","wav","ogg","m4a","aac"].indexOf(n)){if(!p5.prototype.isFileSupported(n))for(var i=e.split("."),r=i[i.length-1],o=0;o<h.extensions.length;o++){var s=h.extensions[o];if(p5.prototype.isFileSupported(s)){r="",2===i.length&&(r+=i[0]);for(var a=1;a<=i.length-2;a++)r+="."+i[a];e=r+=".",e+=s;break}}}else for(var u=0;u<h.extensions.length;u++){var c=h.extensions[u];if(p5.prototype.isFileSupported(c)){e=e+"."+c;break}}}else if("object"===U(t))for(var l=0;l<t.length;l++){var p=t[l].split(".").pop();if(p5.prototype.isFileSupported(p)){e=t[l];break}}return e},p5.prototype._mathChain=function(t,e,n,i,r){for(var o in t.mathOps)t.mathOps[o]instanceof r&&(t.mathOps[o].dispose(),(n=o)<t.mathOps.length-1)&&(i=t.mathOps[o+1]);return t.mathOps[n-1].disconnect(),t.mathOps[n-1].connect(e),e.connect(i),t.mathOps[n]=e,t},p5.prototype.convertToWav=L,p5.prototype.interleave=z,p5.prototype.writeUTFBytes=a,p5.prototype.safeBufferSize=W,p5.prototype.saveSound=function(t,e){t=L(t.buffer),p5.prototype.writeFile([t],e,"wav")},p5.prototype.registerMethod("remove",p5.prototype.disposeSound),p5.Panner=ot,p5.SoundFile=t,p5.prototype.loadSound=function(t,e,n,i){-1<window.location.origin.indexOf("file://")&&"undefined"===window.cordova&&window.alert("This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS");var r=this;return new lt(t,function(){"function"==typeof e&&e.apply(r,arguments),"function"==typeof r._decrementPreload&&r._decrementPreload()},n,i)},p5.prototype.registerPreloadMethod("loadSound",p5.prototype),p5.Amplitude=ft,p5.FFT=mt,p5.Oscillator=Ct,p5.SinOsc=vt,p5.TriOsc=kt,p5.SawOsc=Ot,p5.SqrOsc=At,p5.Noise=Rt,p5.Pulse=Gt,p5.AudioIn=Qt,p5.Effect=u,p5.Filter=ce,p5.LowPass=se,p5.HighPass=ae,p5.BandPass=ue,p5.EQ=ge,p5.Listener3D=Te,p5.Panner3D=Oe,p5.Delay=Ee,p5.Reverb=Ie,p5.Convolver=Ue,p5.prototype.createConvolver=function(t,e,n){-1<window.location.origin.indexOf("file://")&&"undefined"===window.cordova&&alert("This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS");var i=this;return(t=new Ue(t,function(t){"function"==typeof e&&e(t),"function"==typeof i._decrementPreload&&i._decrementPreload()},n)).impulses=[],t},p5.prototype.registerPreloadMethod("createConvolver",p5.prototype),p5.Metro=Ze,p5.Phrase=Ke,p5.Part=e,p5.Score=Ge,p5.SoundLoop=en,p5.Compressor=an,p5.peakDetect=ln,p5.SoundRecorder=yn,p5.Distortion=_n,p5.Gain=Sn,p5.Envelope=qt,p5.Env=Cn,p5.AudioVoice=En,p5.MonoSynth=In,p5.OnsetDetect=Ln,p5.PolySynth=Zn,p5.PeakDetect=ln,p5.Signal=$n}]);
//# sourceMappingURL=p5.sound.min.js.map