summaryrefslogtreecommitdiff
path: root/bundle.js
blob: 27e771045abbcf73a72fb66a65618ed687fcf9f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
!function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var i={};e.m=t,e.c=i,e.i=function(t){return t},e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=10)}([function(t,e,i){var n;!function(s,o){void 0!==(n=function(){return o()}.call(e,i,e,t))&&(t.exports=n)}(0,function(){"use strict";function t(t){t(e)}var e;/**
	 *  Tone.js
	 *  @author Yotam Mann
	 *  @license http://opensource.org/licenses/MIT MIT License
	 *  @copyright 2014-2018 Yotam Mann
	 */
return function(t){e=t()}(function(){var t=function(){if(!(this instanceof t))throw new Error("constructor needs to be called with the 'new' keyword")};t.prototype.toString=function(){for(var e in t){var i=e[0].match(/^[A-Z]$/),n=t[e]===this.constructor;if(t.isFunction(t[e])&&i&&n)return e}return"Tone"},t.prototype.dispose=function(){return this},t.prototype.set=function(e,i,n){if(t.isObject(e))n=i;else if(t.isString(e)){var s={};s[e]=i,e=s}t:for(var o in e){i=e[o];var r=this;if(-1!==o.indexOf(".")){for(var a=o.split("."),h=0;h<a.length-1;h++)if((r=r[a[h]])instanceof t){a.splice(0,h+1);var u=a.join(".");r.set(u,i);continue t}o=a[a.length-1]}var l=r[o];t.isUndef(l)||(t.Signal&&l instanceof t.Signal||t.Param&&l instanceof t.Param?l.value!==i&&(t.isUndef(n)?l.value=i:l.rampTo(i,n)):l instanceof AudioParam?l.value!==i&&(l.value=i):t.TimeBase&&l instanceof t.TimeBase?r[o]=i:l instanceof t?l.set(i):l!==i&&(r[o]=i))}return this},t.prototype.get=function(e){t.isUndef(e)?e=this._collectDefaults(this.constructor):t.isString(e)&&(e=[e]);for(var i={},n=0;n<e.length;n++){var s=e[n],o=this,r=i;if(-1!==s.indexOf(".")){for(var a=s.split("."),h=0;h<a.length-1;h++){var u=a[h];r[u]=r[u]||{},r=r[u],o=o[u]}s=a[a.length-1]}var l=o[s];t.isObject(e[s])?r[s]=l.get():t.Signal&&l instanceof t.Signal?r[s]=l.value:t.Param&&l instanceof t.Param?r[s]=l.value:l instanceof AudioParam?r[s]=l.value:l instanceof t?r[s]=l.get():!t.isFunction(l)&&t.isDefined(l)&&(r[s]=l)}return i},t.prototype._collectDefaults=function(e){var i=[];if(t.isDefined(e.defaults)&&(i=Object.keys(e.defaults)),t.isDefined(e._super))for(var n=this._collectDefaults(e._super),s=0;s<n.length;s++)-1===i.indexOf(n[s])&&i.push(n[s]);return i},t.defaults=function(e,i,n){var s={};if(1===e.length&&t.isObject(e[0]))s=e[0];else for(var o=0;o<i.length;o++)s[i[o]]=e[o];return t.isDefined(n.defaults)?t.defaultArg(s,n.defaults):t.isObject(n)?t.defaultArg(s,n):s},t.defaultArg=function(e,i){if(t.isObject(e)&&t.isObject(i)){var n={};for(var s in e)n[s]=t.defaultArg(i[s],e[s]);for(var o in i)n[o]=t.defaultArg(e[o],i[o]);return n}return t.isUndef(e)?i:e},t.connectSeries=function(){for(var e=arguments[0],i=1;i<arguments.length;i++){var n=arguments[i];e.connect(n),e=n}return t},t.isUndef=function(t){return void 0===t},t.isDefined=function(e){return!t.isUndef(e)},t.isFunction=function(t){return"function"==typeof t},t.isNumber=function(t){return"number"==typeof t},t.isObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)&&t.constructor===Object},t.isBoolean=function(t){return"boolean"==typeof t},t.isArray=function(t){return Array.isArray(t)},t.isString=function(t){return"string"==typeof t},t.isNote=function(e){return t.isString(e)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(e)},t.noOp=function(){},t.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})},t.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})},t.State={Started:"started",Stopped:"stopped",Paused:"paused"},t.equalPowerScale=function(t){var e=.5*Math.PI;return Math.sin(t*e)},t.dbToGain=function(t){return Math.pow(10,t/20)},t.gainToDb=function(t){return Math.log(t)/Math.LN10*20},t.intervalToFrequencyRatio=function(t){return Math.pow(2,t/12)},t.prototype.now=function(){return t.context.now()},t.now=function(){return t.context.now()},t.extend=function(e,i){function n(){}t.isUndef(i)&&(i=t),n.prototype=i.prototype,e.prototype=new n,e.prototype.constructor=e,e._super=i};var e=null;return Object.defineProperty(t,"context",{get:function(){return e},set:function(i){e=t.Context&&i instanceof t.Context?i:new t.Context(i),t.Context.emit("init",e)}}),Object.defineProperty(t.prototype,"context",{get:function(){return t.context}}),t.setContext=function(e){t.context=e},Object.defineProperty(t.prototype,"blockTime",{get:function(){return 128/this.context.sampleRate}}),Object.defineProperty(t.prototype,"sampleTime",{get:function(){return 1/this.context.sampleRate}}),Object.defineProperty(t,"supported",{get:function(){var t=window.hasOwnProperty("AudioContext")||window.hasOwnProperty("webkitAudioContext"),e=window.hasOwnProperty("Promise"),i=window.hasOwnProperty("Worker");return t&&e&&i}}),Object.defineProperty(t,"initialized",{get:function(){return null!==e}}),t.getContext=function(e){if(t.initialized)e(t.context);else{var i=function(){e(t.context),t.Context.off("init",i)};t.Context.on("init",i)}return t},t.version="r12",t}),t(function(t){return t.Emitter=function(){t.call(this),this._events={}},t.extend(t.Emitter),t.Emitter.prototype.on=function(t,e){for(var i=t.split(/\W+/),n=0;n<i.length;n++){var s=i[n];this._events.hasOwnProperty(s)||(this._events[s]=[]),this._events[s].push(e)}return this},t.Emitter.prototype.once=function(t,e){var i=function(){e.apply(this,arguments),this.off(t,i)}.bind(this);return this.on(t,i),this},t.Emitter.prototype.off=function(e,i){for(var n=e.split(/\W+/),s=0;s<n.length;s++)if(e=n[s],this._events.hasOwnProperty(e))if(t.isUndef(i))this._events[e]=[];else for(var o=this._events[e],r=0;r<o.length;r++)o[r]===i&&o.splice(r,1);return this},t.Emitter.prototype.emit=function(t){if(this._events){var e=Array.apply(null,arguments).slice(1);if(this._events.hasOwnProperty(t))for(var i=this._events[t].slice(0),n=0,s=i.length;n<s;n++)i[n].apply(this,e)}return this},t.Emitter.mixin=function(e){var i=["on","once","off","emit"];e._events={};for(var n=0;n<i.length;n++){var s=i[n],o=t.Emitter.prototype[s];e[s]=o}return t.Emitter},t.Emitter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._events=null,this},t.Emitter}),t(function(t){return t.Timeline=function(){var e=t.defaults(arguments,["memory"],t.Timeline);t.call(this),this._timeline=[],this.memory=e.memory},t.extend(t.Timeline),t.Timeline.defaults={memory:1/0},Object.defineProperty(t.Timeline.prototype,"length",{get:function(){return this._timeline.length}}),t.Timeline.prototype.add=function(e){if(t.isUndef(e.time))throw new Error("Tone.Timeline: events must have a time attribute");e.time=e.time.valueOf();var i=this._search(e.time);if(this._timeline.splice(i+1,0,e),this.length>this.memory){var n=this.length-this.memory;this._timeline.splice(0,n)}return this},t.Timeline.prototype.remove=function(t){var e=this._timeline.indexOf(t);return-1!==e&&this._timeline.splice(e,1),this},t.Timeline.prototype.get=function(e,i){i=t.defaultArg(i,"time");var n=this._search(e,i);return-1!==n?this._timeline[n]:null},t.Timeline.prototype.peek=function(){return this._timeline[0]},t.Timeline.prototype.shift=function(){return this._timeline.shift()},t.Timeline.prototype.getAfter=function(e,i){i=t.defaultArg(i,"time");var n=this._search(e,i);return n+1<this._timeline.length?this._timeline[n+1]:null},t.Timeline.prototype.getBefore=function(e,i){i=t.defaultArg(i,"time");var n=this._timeline.length;if(n>0&&this._timeline[n-1][i]<e)return this._timeline[n-1];var s=this._search(e,i);return s-1>=0?this._timeline[s-1]:null},t.Timeline.prototype.cancel=function(t){if(this._timeline.length>1){var e=this._search(t);if(e>=0)if(this._timeline[e].time===t){for(var i=e;i>=0&&this._timeline[i].time===t;i--)e=i;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},t.Timeline.prototype.cancelBefore=function(t){var e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this},t.Timeline.prototype.previousEvent=function(t){var e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null},t.Timeline.prototype._search=function(e,i){if(0===this._timeline.length)return-1;i=t.defaultArg(i,"time");var n=0,s=this._timeline.length,o=s;if(s>0&&this._timeline[s-1][i]<=e)return s-1;for(;n<o;){var r=Math.floor(n+(o-n)/2),a=this._timeline[r],h=this._timeline[r+1];if(a[i]===e){for(var u=r;u<this._timeline.length;u++){this._timeline[u][i]===e&&(r=u)}return r}if(a[i]<e&&h[i]>e)return r;a[i]>e?o=r:n=r+1}return-1},t.Timeline.prototype._iterate=function(e,i,n){i=t.defaultArg(i,0),n=t.defaultArg(n,this._timeline.length-1),this._timeline.slice(i,n+1).forEach(function(t){e.call(this,t)}.bind(this))},t.Timeline.prototype.forEach=function(t){return this._iterate(t),this},t.Timeline.prototype.forEachBefore=function(t,e){var i=this._search(t);return-1!==i&&this._iterate(e,0,i),this},t.Timeline.prototype.forEachAfter=function(t,e){var i=this._search(t);return this._iterate(e,i+1),this},t.Timeline.prototype.forEachBetween=function(t,e,i){var n=this._search(t),s=this._search(e);return-1!==n&&-1!==s?(this._timeline[n].time!==t&&(n+=1),this._timeline[s].time===e&&(s-=1),this._iterate(i,n,s)):-1===n&&this._iterate(i,0,s),this},t.Timeline.prototype.forEachFrom=function(t,e){for(var i=this._search(t);i>=0&&this._timeline[i].time>=t;)i--;return this._iterate(e,i+1),this},t.Timeline.prototype.forEachAtTime=function(t,e){var i=this._search(t);return-1!==i&&this._iterate(function(i){i.time===t&&e.call(this,i)},0,i),this},t.Timeline.prototype.dispose=function(){return t.prototype.dispose.call(this),this._timeline=null,this},t.Timeline}),t(function(t){if(t.supported){!window.hasOwnProperty("OfflineAudioContext")&&window.hasOwnProperty("webkitOfflineAudioContext")&&(window.OfflineAudioContext=window.webkitOfflineAudioContext);new OfflineAudioContext(1,1,44100).startRendering()instanceof Promise||(OfflineAudioContext.prototype._native_startRendering=OfflineAudioContext.prototype.startRendering,OfflineAudioContext.prototype.startRendering=function(){return new Promise(function(t){this.oncomplete=function(e){t(e.renderedBuffer)},this._native_startRendering()}.bind(this))})}}),t(function(t){if(t.supported){!window.hasOwnProperty("AudioContext")&&window.hasOwnProperty("webkitAudioContext")&&(window.AudioContext=window.webkitAudioContext),AudioContext.prototype.close||(AudioContext.prototype.close=function(){return t.isFunction(this.suspend)&&this.suspend(),Promise.resolve()}),AudioContext.prototype.resume||(AudioContext.prototype.resume=function(){return Promise.resolve()}),!AudioContext.prototype.createGain&&AudioContext.prototype.createGainNode&&(AudioContext.prototype.createGain=AudioContext.prototype.createGainNode),!AudioContext.prototype.createDelay&&AudioContext.prototype.createDelayNode&&(AudioContext.prototype.createDelay=AudioContext.prototype.createDelayNode);var e=!1,i=new OfflineAudioContext(1,1,44100),n=new Uint32Array([1179011410,48,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,8,0,0,0,0]).buffer;try{i.decodeAudioData(n)instanceof Promise&&(e=!0)}catch(t){e=!1}e||(AudioContext.prototype._native_decodeAudioData=AudioContext.prototype.decodeAudioData,AudioContext.prototype.decodeAudioData=function(t){return new Promise(function(e,i){this._native_decodeAudioData(t,e,i)}.bind(this))})}}),t(function(t){t.Context=function(){t.Emitter.call(this);var i=t.defaults(arguments,["context"],t.Context);if(!i.context&&(i.context=new window.AudioContext,!i.context))throw new Error("could not create AudioContext. Possibly too many AudioContexts running already.");this._context=i.context;for(var n in this._context)this._defineProperty(this._context,n);this._latencyHint=i.latencyHint,this._constants={},this.lookAhead=i.lookAhead,this._computedUpdateInterval=0,this._ticker=new e(this.emit.bind(this,"tick"),i.clockSource,i.updateInterval),this._timeouts=new t.Timeline,this._timeoutIds=0,this.on("tick",this._timeoutLoop.bind(this))},t.extend(t.Context,t.Emitter),t.Emitter.mixin(t.Context),t.Context.defaults={clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.03},t.Context.prototype._defineProperty=function(e,i){t.isUndef(this[i])&&Object.defineProperty(this,i,{get:function(){return"function"==typeof e[i]?e[i].bind(e):e[i]},set:function(t){e[i]=t}})},t.Context.prototype.now=function(){return this._context.currentTime+this.lookAhead},t.Context.prototype.ready=function(){return new Promise(function(t){"running"===this._context.state?t():this._context.resume().then(function(){t()})}.bind(this))},t.Context.prototype.close=function(){return this._context.close().then(function(){t.Context.emit("close",this)}.bind(this))},t.Context.prototype.getConstant=function(t){if(this._constants[t])return this._constants[t];for(var e=this._context.createBuffer(1,128,this._context.sampleRate),i=e.getChannelData(0),n=0;n<i.length;n++)i[n]=t;var s=this._context.createBufferSource();return s.channelCount=1,s.channelCountMode="explicit",s.buffer=e,s.loop=!0,s.start(0),this._constants[t]=s,s},t.Context.prototype._timeoutLoop=function(){for(var t=this.now();this._timeouts&&this._timeouts.length&&this._timeouts.peek().time<=t;)this._timeouts.shift().callback()},t.Context.prototype.setTimeout=function(t,e){this._timeoutIds++;var i=this.now();return this._timeouts.add({callback:t,time:i+e,id:this._timeoutIds}),this._timeoutIds},t.Context.prototype.clearTimeout=function(t){return this._timeouts.forEach(function(e){e.id===t&&this.remove(e)}),this},Object.defineProperty(t.Context.prototype,"updateInterval",{get:function(){return this._ticker.updateInterval},set:function(t){this._ticker.updateInterval=t}}),Object.defineProperty(t.Context.prototype,"clockSource",{get:function(){return this._ticker.type},set:function(t){this._ticker.type=t}}),Object.defineProperty(t.Context.prototype,"latencyHint",{get:function(){return this._latencyHint},set:function(e){var i=e;if(this._latencyHint=e,t.isString(e))switch(e){case"interactive":i=.1,this._context.latencyHint=e;break;case"playback":i=.8,this._context.latencyHint=e;break;case"balanced":i=.25,this._context.latencyHint=e;break;case"fastest":this._context.latencyHint="interactive",i=.01}this.lookAhead=i,this.updateInterval=i/3}}),t.Context.prototype.dispose=function(){return this.close().then(function(){t.Emitter.prototype.dispose.call(this),this._ticker.dispose(),this._ticker=null,this._timeouts.dispose(),this._timeouts=null;for(var e in this._constants)this._constants[e].disconnect();this._constants=null}.bind(this))};var e=function(e,i,n){this._type=i,this._updateInterval=n,this._callback=t.defaultArg(e,t.noOp),this._createClock()};return e.Type={Worker:"worker",Timeout:"timeout",Offline:"offline"},e.prototype._createWorker=function(){window.URL=window.URL||window.webkitURL;var t=new Blob(["var timeoutTime = "+(1e3*this._updateInterval).toFixed(1)+";self.onmessage = function(msg){\ttimeoutTime = parseInt(msg.data);};function tick(){\tsetTimeout(tick, timeoutTime);\tself.postMessage('tick');}tick();"]),e=URL.createObjectURL(t),i=new Worker(e);i.onmessage=this._callback.bind(this),this._worker=i},e.prototype._createTimeout=function(){this._timeout=setTimeout(function(){this._createTimeout(),this._callback()}.bind(this),1e3*this._updateInterval)},e.prototype._createClock=function(){if(this._type===e.Type.Worker)try{this._createWorker()}catch(t){this._type=e.Type.Timeout,this._createClock()}else this._type===e.Type.Timeout&&this._createTimeout()},Object.defineProperty(e.prototype,"updateInterval",{get:function(){return this._updateInterval},set:function(t){this._updateInterval=Math.max(t,128/44100),this._type===e.Type.Worker&&this._worker.postMessage(Math.max(1e3*t,1))}}),Object.defineProperty(e.prototype,"type",{get:function(){return this._type},set:function(t){this._disposeClock(),this._type=t,this._createClock()}}),e.prototype._disposeClock=function(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null),this._worker&&(this._worker.terminate(),this._worker.onmessage=null,this._worker=null)},e.prototype.dispose=function(){this._disposeClock(),this._callback=null},t.getContext(function(){function e(e,i,s){if(e.input)return s=t.defaultArg(s,0),t.isArray(e.input)?this.connect(e.input[s]):this.connect(e.input,i,s);try{return e instanceof AudioNode?(n.call(this,e,i,s),e):(n.call(this,e,i),e)}catch(t){throw new Error("error connecting to node: "+e+"\n"+t)}}function i(e,i,n){if(e&&e.input&&t.isArray(e.input))n=t.defaultArg(n,0),this.disconnect(e.input[n],i,0);else if(e&&e.input)this.disconnect(e.input,i,n);else try{s.apply(this,arguments)}catch(t){throw new Error("error disconnecting node: "+e+"\n"+t)}}var n=AudioNode.prototype.connect,s=AudioNode.prototype.disconnect;AudioNode.prototype.connect!==e&&(AudioNode.prototype.connect=e,AudioNode.prototype.disconnect=i)}),t.supported&&!t.initialized?(t.context=new t.Context,window.TONE_SILENCE_VERSION_LOGGING||console.log("%c * Tone.js "+t.version+" * ","background: #000; color: #fff")):t.supported||console.warn("This browser does not support Tone.js"),t.Context}),t(function(t){return t.AudioNode=function(){t.call(this);var e=t.defaults(arguments,["context"],{context:t.context});this._context=e.context},t.extend(t.AudioNode),Object.defineProperty(t.AudioNode.prototype,"context",{get:function(){return this._context}}),t.AudioNode.prototype.createInsOuts=function(t,e){1===t?this.input=this.context.createGain():t>1&&(this.input=new Array(t)),1===e?this.output=this.context.createGain():e>1&&(this.output=new Array(e))},Object.defineProperty(t.AudioNode.prototype,"channelCount",{get:function(){return this.output.channelCount},set:function(t){return this.output.channelCount=t}}),Object.defineProperty(t.AudioNode.prototype,"channelCountMode",{get:function(){return this.output.channelCountMode},set:function(t){return this.output.channelCountMode=t}}),Object.defineProperty(t.AudioNode.prototype,"channelInterpretation",{get:function(){return this.output.channelInterpretation},set:function(t){return this.output.channelInterpretation=t}}),Object.defineProperty(t.AudioNode.prototype,"numberOfInputs",{get:function(){return this.input?t.isArray(this.input)?this.input.length:1:0}}),Object.defineProperty(t.AudioNode.prototype,"numberOfOutputs",{get:function(){return this.output?t.isArray(this.output)?this.output.length:1:0}}),t.AudioNode.prototype._onConnect=function(){},t.AudioNode.prototype.connect=function(e,i,n){return e._onConnect&&e._onConnect(this),t.isArray(this.output)?(i=t.defaultArg(i,0),this.output[i].connect(e,0,n)):this.output.connect(e,i,n),this},t.AudioNode.prototype.disconnect=function(e,i,n){t.isArray(this.output)?t.isNumber(e)?this.output[e].disconnect():(i=t.defaultArg(i,0),this.output[i].disconnect(e,0,n)):this.output.disconnect.apply(this.output,arguments)},t.AudioNode.prototype.chain=function(){for(var t=this,e=0;e<arguments.length;e++){var i=arguments[e];t.connect(i),t=i}return this},t.AudioNode.prototype.fan=function(){for(var t=0;t<arguments.length;t++)this.connect(arguments[t]);return this},window.AudioNode&&(AudioNode.prototype.chain=t.AudioNode.prototype.chain,AudioNode.prototype.fan=t.AudioNode.prototype.fan),t.AudioNode.prototype.dispose=function(){return t.isDefined(this.input)&&(this.input instanceof AudioNode&&this.input.disconnect(),this.input=null),t.isDefined(this.output)&&(this.output instanceof AudioNode&&this.output.disconnect(),this.output=null),this._context=null,this},t.AudioNode}),t(function(t){return t.SignalBase=function(){t.AudioNode.call(this)},t.extend(t.SignalBase,t.AudioNode),t.SignalBase.prototype.connect=function(e,i,n){return t.Signal&&t.Signal===e.constructor||t.Param&&t.Param===e.constructor?(e._param.cancelScheduledValues(0),e._param.value=0,e.overridden=!0):e instanceof AudioParam&&(e.cancelScheduledValues(0),e.value=0),t.AudioNode.prototype.connect.call(this,e,i,n),this},t.SignalBase}),t(function(t){if(t.supported){var e=navigator.userAgent.toLowerCase();if(e.includes("safari")&&!e.includes("chrome")){var i=function(t){this._internalNode=this.input=this.output=t._native_createWaveShaper(),this._curve=null;for(var e in this._internalNode)this._defineProperty(this._internalNode,e)};Object.defineProperty(i.prototype,"curve",{get:function(){return this._curve},set:function(t){this._curve=t;var e=new Float32Array(t.length+1);e.set(t,1),e[0]=t[0],this._internalNode.curve=e}}),i.prototype._defineProperty=function(e,i){t.isUndef(this[i])&&Object.defineProperty(this,i,{get:function(){return"function"==typeof e[i]?e[i].bind(e):e[i]},set:function(t){e[i]=t}})},AudioContext.prototype._native_createWaveShaper=AudioContext.prototype.createWaveShaper,AudioContext.prototype.createWaveShaper=function(){return new i(this)}}}}),t(function(t){return t.WaveShaper=function(e,i){t.SignalBase.call(this),this._shaper=this.input=this.output=this.context.createWaveShaper(),this._curve=null,Array.isArray(e)?this.curve=e:isFinite(e)||t.isUndef(e)?this._curve=new Float32Array(t.defaultArg(e,1024)):t.isFunction(e)&&(this._curve=new Float32Array(t.defaultArg(i,1024)),this.setMap(e))},t.extend(t.WaveShaper,t.SignalBase),t.WaveShaper.prototype.setMap=function(t){for(var e=new Array(this._curve.length),i=0,n=this._curve.length;i<n;i++){var s=i/(n-1)*2-1;e[i]=t(s,i)}return this.curve=e,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(!["none","2x","4x"].includes(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.SignalBase.prototype.dispose.call(this),this._shaper.disconnect(),this._shaper=null,this._curve=null,this},t.WaveShaper}),t(function(t){return t.TimeBase=function(e,i){if(!(this instanceof t.TimeBase))return new t.TimeBase(e,i);if(this._val=e,this._units=i,t.isUndef(this._units)&&t.isString(this._val)&&parseFloat(this._val)==this._val&&"+"!==this._val.charAt(0))this._val=parseFloat(this._val),this._units=this._defaultUnits;else if(e&&e.constructor===this.constructor)this._val=e._val,this._units=e._units;else if(e instanceof t.TimeBase)switch(this._defaultUnits){case"s":this._val=e.toSeconds();break;case"i":this._val=e.toTicks();break;case"hz":this._val=e.toFrequency();break;case"midi":this._val=e.toMidi();break;default:throw new Error("Unrecognized default units "+this._defaultUnits)}},t.extend(t.TimeBase),t.TimeBase.prototype._expressions={n:{regexp:/^(\d+)n(\.?)$/i,method:function(t,e){t=parseInt(t);var i="."===e?1.5:1;return 1===t?this._beatsToUnits(this._getTimeSignature())*i:this._beatsToUnits(4/t)*i}},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._getTimeSignature())}},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,i){var n=0;return t&&"0"!==t&&(n+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(n+=this._beatsToUnits(parseFloat(e))),i&&"0"!==i&&(n+=this._beatsToUnits(parseFloat(i)/4)),n}},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._expressions[this._defaultUnits].method.call(this,t)}}},t.TimeBase.prototype._defaultUnits="s",t.TimeBase.prototype._getBpm=function(){return t.Transport?t.Transport.bpm.value:120},t.TimeBase.prototype._getTimeSignature=function(){return t.Transport?t.Transport.timeSignature:4},t.TimeBase.prototype._getPPQ=function(){return t.Transport?t.Transport.PPQ:192},t.TimeBase.prototype._now=function(){return this.now()},t.TimeBase.prototype._frequencyToUnits=function(t){return 1/t},t.TimeBase.prototype._beatsToUnits=function(t){return 60/this._getBpm()*t},t.TimeBase.prototype._secondsToUnits=function(t){return t},t.TimeBase.prototype._ticksToUnits=function(t){return t*(this._beatsToUnits(1)/this._getPPQ())},t.TimeBase.prototype._noArg=function(){return this._now()},t.TimeBase.prototype.valueOf=function(){if(t.isUndef(this._val))return this._noArg();if(t.isString(this._val)&&t.isUndef(this._units))for(var e in this._expressions)if(this._expressions[e].regexp.test(this._val.trim())){this._units=e;break}if(t.isDefined(this._units)){var i=this._expressions[this._units],n=this._val.toString().trim().match(i.regexp);return n?i.method.apply(this,n.slice(1)):i.method.call(this,parseFloat(this._val))}return this._val},t.TimeBase.prototype.toSeconds=function(){return this.valueOf()},t.TimeBase.prototype.toFrequency=function(){return 1/this.toSeconds()},t.TimeBase.prototype.toSamples=function(){return this.toSeconds()*this.context.sampleRate},t.TimeBase.prototype.toMilliseconds=function(){return 1e3*this.toSeconds()},t.TimeBase.prototype.dispose=function(){this._val=null,this._units=null},t.TimeBase}),t(function(t){t.Frequency=function(e,i){if(!(this instanceof t.Frequency))return new t.Frequency(e,i);t.TimeBase.call(this,e,i)},t.extend(t.Frequency,t.TimeBase),t.Frequency.prototype._expressions=Object.assign({},t.TimeBase.prototype._expressions,{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method:function(e){return"midi"===this._defaultUnits?e:t.Frequency.mtof(e)}},note:{regexp:/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,method:function(i,n){var s=e[i.toLowerCase()],o=s+12*(parseInt(n)+1);return"midi"===this._defaultUnits?o:t.Frequency.mtof(o)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method:function(t,e,i){var n=1;return t&&"0"!==t&&(n*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(n*=this._beatsToUnits(parseFloat(e))),i&&"0"!==i&&(n*=this._beatsToUnits(parseFloat(i)/4)),n}}}),t.Frequency.prototype.transpose=function(e){return new this.constructor(this.valueOf()*t.intervalToFrequencyRatio(e))},t.Frequency.prototype.harmonize=function(t){return t.map(function(t){return this.transpose(t)}.bind(this))},t.Frequency.prototype.toMidi=function(){return t.Frequency.ftom(this.valueOf())},t.Frequency.prototype.toNote=function(){var e=this.toFrequency(),n=Math.log2(e/t.Frequency.A4),s=Math.round(12*n)+57,o=Math.floor(s/12);return o<0&&(s+=-12*o),i[s%12]+o.toString()},t.Frequency.prototype.toSeconds=function(){return 1/t.TimeBase.prototype.toSeconds.call(this)},t.Frequency.prototype.toFrequency=function(){return t.TimeBase.prototype.toFrequency.call(this)},t.Frequency.prototype.toTicks=function(){var e=this._beatsToUnits(1),i=this.valueOf()/e;return Math.floor(i*t.Transport.PPQ)},t.Frequency.prototype._noArg=function(){return 0},t.Frequency.prototype._frequencyToUnits=function(t){return t},t.Frequency.prototype._ticksToUnits=function(e){return 1/(60*e/(t.Transport.bpm.value*t.Transport.PPQ))},t.Frequency.prototype._beatsToUnits=function(e){return 1/t.TimeBase.prototype._beatsToUnits.call(this,e)},t.Frequency.prototype._secondsToUnits=function(t){return 1/t},t.Frequency.prototype._defaultUnits="hz";var e={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},i=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];return t.Frequency.A4=440,t.Frequency.mtof=function(e){return t.Frequency.A4*Math.pow(2,(e-69)/12)},t.Frequency.ftom=function(e){return 69+Math.round(12*Math.log2(e/t.Frequency.A4))},t.Frequency}),t(function(t){return t.Time=function(e,i){if(!(this instanceof t.Time))return new t.Time(e,i);t.TimeBase.call(this,e,i)},t.extend(t.Time,t.TimeBase),t.Time.prototype._expressions=Object.assign({},t.TimeBase.prototype._expressions,{quantize:{regexp:/^@(.+)/,method:function(e){if(t.Transport){var i=new this.constructor(e);return t.Transport.nextSubdivision(i)}return 0}},now:{regexp:/^\+(.+)/,method:function(t){return this._now()+new this.constructor(t)}}}),t.Time.prototype.quantize=function(e,i){i=t.defaultArg(i,1);var n=new this.constructor(e),s=this.valueOf();return s+(Math.round(s/n)*n-s)*i},t.Time.prototype.toNotation=function(){for(var e=this.toSeconds(),i=["1m"],n=1;n<8;n++){var s=Math.pow(2,n);i.push(s+"n."),i.push(s+"n"),i.push(s+"t")}i.push("0");var o=i[0],r=t.Time(i[0]).toSeconds();return i.forEach(function(i){var n=t.Time(i).toSeconds();Math.abs(n-e)<Math.abs(r-e)&&(o=i,r=n)}),o},t.Time.prototype.toBarsBeatsSixteenths=function(){var t=this._beatsToUnits(1),e=this.valueOf()/t,i=Math.floor(e/this._getTimeSignature()),n=e%1*4;return e=Math.floor(e)%this._getTimeSignature(),n=n.toString(),n.length>3&&(n=parseFloat(parseFloat(n).toFixed(3))),[i,e,n].join(":")},t.Time.prototype.toTicks=function(){var t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.round(e*this._getPPQ())},t.Time.prototype.toSeconds=function(){return this.valueOf()},t.Time.prototype.toMidi=function(){return t.Frequency.ftom(this.toFrequency())},t.Time}),t(function(t){return t.TransportTime=function(e,i){if(!(this instanceof t.TransportTime))return new t.TransportTime(e,i);t.Time.call(this,e,i)},t.extend(t.TransportTime,t.Time),t.TransportTime.prototype._now=function(){return t.Transport.seconds},t.TransportTime}),t(function(t){return t.Type={Default:"number",Time:"time",Frequency:"frequency",TransportTime:"transportTime",Ticks:"ticks",NormalRange:"normalRange",AudioRange:"audioRange",Decibels:"db",Interval:"interval",BPM:"bpm",Positive:"positive",Gain:"gain",Cents:"cents",Degrees:"degrees",MIDI:"midi",BarsBeatsSixteenths:"barsBeatsSixteenths",Samples:"samples",Hertz:"hertz",Note:"note",Milliseconds:"milliseconds",Seconds:"seconds",Notation:"notation"},t.prototype.toSeconds=function(e){return t.isNumber(e)?e:t.isUndef(e)?this.now():t.isString(e)?new t.Time(e).toSeconds():e instanceof t.TimeBase?e.toSeconds():void 0},t.prototype.toFrequency=function(e){return t.isNumber(e)?e:t.isString(e)||t.isUndef(e)?new t.Frequency(e).valueOf():e instanceof t.TimeBase?e.toFrequency():void 0},t.prototype.toTicks=function(e){return t.isNumber(e)||t.isString(e)?new t.TransportTime(e).toTicks():t.isUndef(e)?t.Transport.ticks:e instanceof t.TimeBase?e.toTicks():void 0},t}),t(function(t){return t.Param=function(){var e=t.defaults(arguments,["param","units","convert"],t.Param);t.AudioNode.call(this),this._param=this.input=e.param,this.units=e.units,this.convert=e.convert,this.overridden=!1,this._events=new t.Timeline(1e3),t.isDefined(e.value)&&this._param&&(this.value=e.value)},t.extend(t.Param,t.AudioNode),t.Param.defaults={units:t.Type.Default,convert:!0,param:void 0},Object.defineProperty(t.Param.prototype,"value",{get:function(){var t=this.now();return this._toUnits(this.getValueAtTime(t))},set:function(t){this._initialValue=this._fromUnits(t),this.cancelScheduledValues(this.context.currentTime),this.setValueAtTime(t,this.context.currentTime)}}),Object.defineProperty(t.Param.prototype,"minValue",{get:function(){return this.units===t.Type.Time||this.units===t.Type.Frequency||this.units===t.Type.NormalRange||this.units===t.Type.Positive||this.units===t.Type.BPM?0:this.units===t.Type.AudioRange?-1:this.units===t.Type.Decibels?-1/0:this._param.minValue}}),Object.defineProperty(t.Param.prototype,"maxValue",{get:function(){return this.units===t.Type.NormalRange||this.units===t.Type.AudioRange?1:this._param.maxValue}}),t.Param.prototype._fromUnits=function(e){if(!this.convert&&!t.isUndef(this.convert)||this.overridden)return e;switch(this.units){case t.Type.Time:return this.toSeconds(e);case t.Type.Frequency:return this.toFrequency(e);case t.Type.Decibels:return t.dbToGain(e);case t.Type.NormalRange:return Math.min(Math.max(e,0),1);case t.Type.AudioRange:return Math.min(Math.max(e,-1),1);case t.Type.Positive:return Math.max(e,0);default:return e}},t.Param.prototype._toUnits=function(e){if(!this.convert&&!t.isUndef(this.convert))return e;switch(this.units){case t.Type.Decibels:return t.gainToDb(e);default:return e}},t.Param.prototype._minOutput=1e-5,t.Param.AutomationType={Linear:"linearRampToValueAtTime",Exponential:"exponentialRampToValueAtTime",Target:"setTargetAtTime",SetValue:"setValueAtTime"},t.Param.prototype.setValueAtTime=function(e,i){return i=this.toSeconds(i),e=this._fromUnits(e),this._events.add({type:t.Param.AutomationType.SetValue,value:e,time:i}),this._param.setValueAtTime(e,i),this},t.Param.prototype.getValueAtTime=function(e){e=this.toSeconds(e);var i=this._events.getAfter(e),n=this._events.get(e),s=t.defaultArg(this._initialValue,this._param.defaultValue),o=s;if(null===n)o=s;else if(n.type===t.Param.AutomationType.Target){var r,a=this._events.getBefore(n.time);r=null===a?s:a.value,o=this._exponentialApproach(n.time,r,n.value,n.constant,e)}else o=null===i?n.value:i.type===t.Param.AutomationType.Linear?this._linearInterpolate(n.time,n.value,i.time,i.value,e):i.type===t.Param.AutomationType.Exponential?this._exponentialInterpolate(n.time,n.value,i.time,i.value,e):n.value;return o},t.Param.prototype.setRampPoint=function(t){t=this.toSeconds(t);var e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),0===e&&(e=this._minOutput),this.setValueAtTime(this._toUnits(e),t),this},t.Param.prototype.linearRampToValueAtTime=function(e,i){return e=this._fromUnits(e),i=this.toSeconds(i),this._events.add({type:t.Param.AutomationType.Linear,value:e,time:i}),this._param.linearRampToValueAtTime(e,i),this},t.Param.prototype.exponentialRampToValueAtTime=function(e,i){return e=this._fromUnits(e),e=Math.max(this._minOutput,e),i=this.toSeconds(i),this._events.add({type:t.Param.AutomationType.Exponential,time:i,value:e}),this._param.exponentialRampToValueAtTime(e,i),this},t.Param.prototype.exponentialRampTo=function(t,e,i){return i=this.toSeconds(i),this.setRampPoint(i),this.exponentialRampToValueAtTime(t,i+this.toSeconds(e)),this},t.Param.prototype.linearRampTo=function(t,e,i){return i=this.toSeconds(i),this.setRampPoint(i),this.linearRampToValueAtTime(t,i+this.toSeconds(e)),this},t.Param.prototype.targetRampTo=function(t,e,i){return i=this.toSeconds(i),this.setRampPoint(i),this.exponentialApproachValueAtTime(t,i,e),this},t.Param.prototype.exponentialApproachValueAtTime=function(t,e,i){var n=Math.log(this.toSeconds(i)+1)/Math.log(200);return e=this.toSeconds(e),this.setTargetAtTime(t,e,n)},t.Param.prototype.setTargetAtTime=function(e,i,n){if(e=this._fromUnits(e),n<=0)throw new Error("timeConstant must be greater than 0");return i=this.toSeconds(i),this._events.add({type:t.Param.AutomationType.Target,value:e,time:i,constant:n}),this._param.setTargetAtTime(e,i,n),this},t.Param.prototype.setValueCurveAtTime=function(e,i,n,s){s=t.defaultArg(s,1),n=this.toSeconds(n),i=this.toSeconds(i),this.setValueAtTime(e[0]*s,i);for(var o=n/(e.length-1),r=1;r<e.length;r++)this.linearRampToValueAtTime(e[r]*s,i+r*o);return this},t.Param.prototype.cancelScheduledValues=function(t){return t=this.toSeconds(t),this._events.cancel(t),this._param.cancelScheduledValues(t),this},t.Param.prototype.cancelAndHoldAtTime=function(e){var i=this.getValueAtTime(e),n=this._events.get(e),s=this._events.getAfter(e);return n&&n.time===e?s?this._events.cancel(s.time):this._events.cancel(e+1e-6):s&&(this._events.cancel(s.time),this._param.cancelAndHoldAtTime||this._param.cancelScheduledValues(e),s.type===t.Param.AutomationType.Linear?this._param.cancelAndHoldAtTime?this._events.add({type:t.Param.AutomationType.Linear,value:i,time:e}):this.linearRampToValueAtTime(i,e):s.type===t.Param.AutomationType.Exponential&&(this._param.cancelAndHoldAtTime?this._events.add({type:t.Param.AutomationType.Exponential,value:i,time:e}):this.exponentialRampToValueAtTime(i,e))),this._events.add({type:t.Param.AutomationType.SetValue,value:i,time:e}),this._param.cancelAndHoldAtTime?this._param.cancelAndHoldAtTime(e):this._param.setValueAtTime(i,e),this},t.Param.prototype.rampTo=function(e,i,n){return i=t.defaultArg(i,.1),this.units===t.Type.Frequency||this.units===t.Type.BPM||this.units===t.Type.Decibels?this.exponentialRampTo(e,i,n):this.linearRampTo(e,i,n),this},t.Param.prototype._exponentialApproach=function(t,e,i,n,s){return i+(e-i)*Math.exp(-(s-t)/n)},t.Param.prototype._linearInterpolate=function(t,e,i,n,s){return e+(s-t)/(i-t)*(n-e)},t.Param.prototype._exponentialInterpolate=function(t,e,i,n,s){return e*Math.pow(n/e,(s-t)/(i-t))},t.Param.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._param=null,this._events=null,this},t.Param}),t(function(t){return t.OfflineContext=function(e,i,n){var s=new OfflineAudioContext(e,i*n,n);t.Context.call(this,{context:s,clockSource:"offline",lookAhead:0,updateInterval:128/n}),this._duration=i,this._currentTime=0},t.extend(t.OfflineContext,t.Context),t.OfflineContext.prototype.now=function(){return this._currentTime},t.OfflineContext.prototype.render=function(){for(;this._duration-this._currentTime>=0;)this.emit("tick"),this._currentTime+=this.blockTime;return this._context.startRendering()},t.OfflineContext.prototype.close=function(){return this._context=null,Promise.resolve()},t.OfflineContext}),t(function(t){if(t.supported){var e=navigator.userAgent.toLowerCase();e.includes("safari")&&!e.includes("chrome")&&e.includes("mobile")&&(t.OfflineContext.prototype.createBufferSource=function(){var t=this._context.createBufferSource(),e=t.start;return t.start=function(i){this.setTimeout(function(){e.call(t,i)}.bind(this),0)}.bind(this),t})}}),t(function(t){return t.Gain=function(){var e=t.defaults(arguments,["gain","units"],t.Gain);t.AudioNode.call(this),this.input=this.output=this._gainNode=this.context.createGain(),this.gain=new t.Param({param:this._gainNode.gain,units:e.units,value:e.gain,convert:e.convert}),this._readOnly("gain")},t.extend(t.Gain,t.AudioNode),t.Gain.defaults={gain:1,convert:!0},t.Gain.prototype.dispose=function(){t.AudioNode.prototype.dispose.call(this),this._gainNode.disconnect(),this._gainNode=null,this._writable("gain"),this.gain.dispose(),this.gain=null},t.Gain}),t(function(t){if(t.supported&&!AudioContext.prototype.createConstantSource){var e=function(t){this.context=t;for(var e=t.createBuffer(1,128,t.sampleRate),i=e.getChannelData(0),n=0;n<i.length;n++)i[n]=1;this._bufferSource=t.createBufferSource(),this._bufferSource.channelCount=1,this._bufferSource.channelCountMode="explicit",this._bufferSource.buffer=e,this._bufferSource.loop=!0;var s=this._output=t.createGain();this.offset=s.gain,this._bufferSource.connect(s)};e.prototype.start=function(t){return this._bufferSource.start(t),this},e.prototype.stop=function(t){return this._bufferSource.stop(t),this},e.prototype.connect=function(){return this._output.connect.apply(this._output,arguments),this},e.prototype.disconnect=function(){return this._output.disconnect.apply(this._output,arguments),this},AudioContext.prototype.createConstantSource=function(){return new e(this)},t.Context.prototype.createConstantSource=function(){return new e(this)}}}),t(function(t){return t.Signal=function(){var e=t.defaults(arguments,["value","units"],t.Signal);t.Param.call(this,e),this._proxies=[],this._sourceStarted=!1,this._constantSource=this.context.createConstantSource(),this._param=this._constantSource.offset,this.value=e.value,this.output=this._constantSource,this.input=this._param=this.output.offset},t.extend(t.Signal,t.Param),t.Signal.defaults={value:0,units:t.Type.Default,convert:!0},t.Signal.prototype.connect=function(e){return this._isParam(e)&&!this._sourceStarted?(this._proxies.push(e),e.overridden=!0,this._applyAutomations(e)):(t.SignalBase.prototype.connect.apply(this,arguments),this._sourceStarted||(this._sourceStarted=!0,this._constantSource.start(0))),this},t.Signal.prototype._isParam=function(e){return t.Param&&t.Param===e.constructor||e instanceof AudioParam},t.Signal.prototype._connectProxies=function(){this._sourceStarted||(this._sourceStarted=!0,this._constantSource.start(0)),this._proxies.forEach(function(e){t.SignalBase.prototype.connect.call(this,e),e._proxies&&e._connectProxies()}.bind(this))},t.Signal.prototype._onConnect=function(t){this._isParam(t)||this._connectProxies()},t.Signal.prototype._applyAutomations=function(t){var e=this.context.currentTime;t.cancelScheduledValues(e);var i=this.getValueAtTime(e);t.setValueAtTime(i,e),this._events.forEachFrom(e,function(e){t[e.type](e.value,e.time,e.constant)})},t.Signal.prototype.disconnect=function(e){if(this._proxies.includes(e)){var i=this._proxies.indexOf(e);this._proxies.splice(i,1)}else e||(this._proxies=[]);return t.SignalBase.prototype.disconnect.apply(this,arguments)},t.Signal.prototype.getValueAtTime=function(e){return this._param.getValueAtTime?this._param.getValueAtTime(e):t.Param.prototype.getValueAtTime.call(this,e)},["setValueAtTime","linearRampToValueAtTime","exponentialRampToValueAtTime","setTargetAtTime"].forEach(function(e){var i=t.Signal.prototype[e];t.Signal.prototype[e]=function(){var t=arguments;i.apply(this,arguments),t[0]=this._fromUnits(t[0]),t[1]=this.toSeconds(t[1]),this._proxies.forEach(function(i){i[e].apply(i,t)})}}),["cancelScheduledValues","cancelAndHoldAtTime"].forEach(function(e){var i=t.Signal.prototype[e];t.Signal.prototype[e]=function(){var t=arguments;i.apply(this,arguments),t[0]=this.toSeconds(t[0]),this._proxies.forEach(function(i){i[e].apply(i,t)})}}),t.Signal.prototype.dispose=function(){return t.Param.prototype.dispose.call(this),this._constantSource.disconnect(),this._constantSource=null,this._proxies=null,this},t.Signal}),t(function(t){return t.Pow=function(e){t.SignalBase.call(this),this._exp=t.defaultArg(e,1),this._expScaler=this.input=this.output=new t.WaveShaper(this._expFunc(this._exp),8192)},t.extend(t.Pow,t.SignalBase),Object.defineProperty(t.Pow.prototype,"value",{get:function(){return this._exp},set:function(t){this._exp=t,this._expScaler.setMap(this._expFunc(this._exp))}}),t.Pow.prototype._expFunc=function(t){return function(e){return Math.pow(Math.abs(e),t)}},t.Pow.prototype.dispose=function(){return t.SignalBase.prototype.dispose.call(this),this._expScaler.dispose(),this._expScaler=null,this},t.Pow}),t(function(t){return t.Envelope=function(){var e=t.defaults(arguments,["attack","decay","sustain","release"],t.Envelope);t.AudioNode.call(this),this.attack=e.attack,this.decay=e.decay,this.sustain=e.sustain,this.release=e.release,this._attackCurve="linear",this._releaseCurve="exponential",this._sig=this.output=new t.Signal(0),this.attackCurve=e.attackCurve,this.releaseCurve=e.releaseCurve},t.extend(t.Envelope,t.AudioNode),t.Envelope.defaults={attack:.01,decay:.1,sustain:.5,release:1,attackCurve:"linear",releaseCurve:"exponential"},Object.defineProperty(t.Envelope.prototype,"value",{get:function(){return this.getValueAtTime(this.now())}}),Object.defineProperty(t.Envelope.prototype,"attackCurve",{get:function(){if(t.isString(this._attackCurve))return this._attackCurve;if(t.isArray(this._attackCurve)){for(var e in t.Envelope.Type)if(t.Envelope.Type[e].In===this._attackCurve)return e;return this._attackCurve}},set:function(e){if(t.Envelope.Type.hasOwnProperty(e)){var i=t.Envelope.Type[e];t.isObject(i)?this._attackCurve=i.In:this._attackCurve=i}else{if(!t.isArray(e))throw new Error("Tone.Envelope: invalid curve: "+e);this._attackCurve=e}}}),Object.defineProperty(t.Envelope.prototype,"releaseCurve",{get:function(){if(t.isString(this._releaseCurve))return this._releaseCurve;if(t.isArray(this._releaseCurve)){for(var e in t.Envelope.Type)if(t.Envelope.Type[e].Out===this._releaseCurve)return e;return this._releaseCurve}},set:function(e){if(t.Envelope.Type.hasOwnProperty(e)){var i=t.Envelope.Type[e];t.isObject(i)?this._releaseCurve=i.Out:this._releaseCurve=i}else{if(!t.isArray(e))throw new Error("Tone.Envelope: invalid curve: "+e);this._releaseCurve=e}}}),t.Envelope.prototype.triggerAttack=function(e,i){e=this.toSeconds(e);var n=this.toSeconds(this.attack),s=n,o=this.toSeconds(this.decay);i=t.defaultArg(i,1);var r=this.getValueAtTime(e);if(r>0){s=(1-r)/(1/s)}if("linear"===this._attackCurve)this._sig.linearRampTo(i,s,e);else if("exponential"===this._attackCurve)this._sig.targetRampTo(i,s,e);else if(s>0){this._sig.cancelAndHoldAtTime(e);var a=this._attackCurve;if(s<n){var h=1-s/n,u=Math.floor(h*this._attackCurve.length);a=this._attackCurve.slice(u),a[0]=r}this._sig.setValueCurveAtTime(a,e,s,i)}return o&&this._sig.targetRampTo(i*this.sustain,o,s+e),this},t.Envelope.prototype.triggerRelease=function(e){e=this.toSeconds(e);var i=this.getValueAtTime(e);if(i>0){var n=this.toSeconds(this.release);if("linear"===this._releaseCurve)this._sig.linearRampTo(0,n,e);else if("exponential"===this._releaseCurve)this._sig.targetRampTo(0,n,e);else{var s=this._releaseCurve;t.isArray(s)&&(this._sig.cancelAndHoldAtTime(e),this._sig.setValueCurveAtTime(s,e,n,i))}}return this},t.Envelope.prototype.getValueAtTime=function(t){return this._sig.getValueAtTime(t)},t.Envelope.prototype.triggerAttackRelease=function(t,e,i){return e=this.toSeconds(e),this.triggerAttack(e,i),this.triggerRelease(e+this.toSeconds(t)),this},t.Envelope.prototype.cancel=function(t){return this._sig.cancelScheduledValues(t),this},t.Envelope.prototype.connect=t.SignalBase.prototype.connect,function(){function e(t){for(var e=new Array(t.length),i=0;i<t.length;i++)e[i]=1-t[i];return e}var i,n,s=[];for(i=0;i<128;i++)s[i]=Math.sin(i/127*(Math.PI/2));var o=[];for(i=0;i<127;i++){n=i/127;var r=Math.sin(n*(2*Math.PI)*6.4-Math.PI/2)+1;o[i]=r/10+.83*n}o[127]=1;var a=[];for(i=0;i<128;i++)a[i]=Math.ceil(i/127*5)/5;var h=[];for(i=0;i<128;i++)n=i/127,h[i]=.5*(1-Math.cos(Math.PI*n));var u=[];for(i=0;i<128;i++){n=i/127;var l=4*Math.pow(n,3)+.2,c=Math.cos(l*Math.PI*2*n);u[i]=Math.abs(c*(1-n))}t.Envelope.Type={linear:"linear",exponential:"exponential",bounce:{In:e(u),Out:u},cosine:{In:s,Out:function(t){return t.slice(0).reverse()}(s)},step:{In:a,Out:e(a)},ripple:{In:o,Out:e(o)},sine:{In:h,Out:e(h)}}}(),t.Envelope.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._sig.dispose(),this._sig=null,this._attackCurve=null,this._releaseCurve=null,this},t.Envelope}),t(function(t){return t.AmplitudeEnvelope=function(){t.Envelope.apply(this,arguments),this.input=this.output=new t.Gain,this._sig.connect(this.output.gain)},t.extend(t.AmplitudeEnvelope,t.Envelope),t.AmplitudeEnvelope.prototype.dispose=function(){return t.Envelope.prototype.dispose.call(this),this},t.AmplitudeEnvelope}),t(function(t){t.supported&&(AnalyserNode.prototype.getFloatTimeDomainData||(AnalyserNode.prototype.getFloatTimeDomainData=function(t){var e=new Uint8Array(t.length);this.getByteTimeDomainData(e);for(var i=0;i<e.length;i++)t[i]=(e[i]-128)/128}))}),t(function(t){return t.Analyser=function(){var e=t.defaults(arguments,["type","size"],t.Analyser);t.AudioNode.call(this),this._analyser=this.input=this.output=this.context.createAnalyser(),this._type=e.type,this._buffer=null,this.size=e.size,this.type=e.type},t.extend(t.Analyser,t.AudioNode),t.Analyser.defaults={size:1024,type:"fft",smoothing:.8},t.Analyser.Type={Waveform:"waveform",FFT:"fft"},t.Analyser.prototype.getValue=function(){return this._type===t.Analyser.Type.FFT?this._analyser.getFloatFrequencyData(this._buffer):this._type===t.Analyser.Type.Waveform&&this._analyser.getFloatTimeDomainData(this._buffer),this._buffer},Object.defineProperty(t.Analyser.prototype,"size",{get:function(){return this._analyser.frequencyBinCount},set:function(t){this._analyser.fftSize=2*t,this._buffer=new Float32Array(t)}}),Object.defineProperty(t.Analyser.prototype,"type",{get:function(){return this._type},set:function(e){if(e!==t.Analyser.Type.Waveform&&e!==t.Analyser.Type.FFT)throw new TypeError("Tone.Analyser: invalid type: "+e);this._type=e}}),Object.defineProperty(t.Analyser.prototype,"smoothing",{get:function(){return this._analyser.smoothingTimeConstant},set:function(t){this._analyser.smoothingTimeConstant=t}}),t.Analyser.prototype.dispose=function(){t.AudioNode.prototype.dispose.call(this),this._analyser.disconnect(),this._analyser=null,this._buffer=null},t.Analyser}),t(function(t){return t.Compressor=function(){var e=t.defaults(arguments,["threshold","ratio"],t.Compressor);t.AudioNode.call(this),this._compressor=this.input=this.output=this.context.createDynamicsCompressor(),this.threshold=new t.Param({param:this._compressor.threshold,units:t.Type.Decibels,convert:!1}),this.attack=new t.Param(this._compressor.attack,t.Type.Time),this.release=new t.Param(this._compressor.release,t.Type.Time),this.knee=new t.Param({param:this._compressor.knee,units:t.Type.Decibels,convert:!1}),this.ratio=new t.Param({param:this._compressor.ratio,convert:!1}),this._readOnly(["knee","release","attack","ratio","threshold"]),this.set(e)},t.extend(t.Compressor,t.AudioNode),t.Compressor.defaults={ratio:12,threshold:-24,release:.25,attack:.003,knee:30},t.Compressor.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._writable(["knee","release","attack","ratio","threshold"]),this._compressor.disconnect(),this._compressor=null,this.attack.dispose(),this.attack=null,this.release.dispose(),this.release=null,this.threshold.dispose(),this.threshold=null,this.ratio.dispose(),this.ratio=null,this.knee.dispose(),this.knee=null,this},t.Compressor}),t(function(t){return t.Add=function(e){t.Signal.call(this),this.createInsOuts(2,0),this._sum=this.input[0]=this.input[1]=this.output=new t.Gain,this._param=this.input[1]=new t.Signal(e),this._param.connect(this._sum)},t.extend(t.Add,t.Signal),t.Add.prototype.dispose=function(){return t.Signal.prototype.dispose.call(this),this._sum.dispose(),this._sum=null,this},t.Add}),t(function(t){return t.Multiply=function(e){t.Signal.call(this),this.createInsOuts(2,0),this._mult=this.input[0]=this.output=new t.Gain,this._param=this.input[1]=this.output.gain,this.value=t.defaultArg(e,0)},t.extend(t.Multiply,t.Signal),t.Multiply.prototype.dispose=function(){return t.Signal.prototype.dispose.call(this),this._mult.dispose(),this._mult=null,this._param=null,this},t.Multiply}),t(function(t){return t.Negate=function(){t.SignalBase.call(this),this._multiply=this.input=this.output=new t.Multiply(-1)},t.extend(t.Negate,t.SignalBase),t.Negate.prototype.dispose=function(){return t.SignalBase.prototype.dispose.call(this),this._multiply.dispose(),this._multiply=null,this},t.Negate}),t(function(t){return t.Subtract=function(e){t.Signal.call(this),this.createInsOuts(2,0),this._sum=this.input[0]=this.output=new t.Gain,this._neg=new t.Negate,this._param=this.input[1]=new t.Signal(e),this._param.chain(this._neg,this._sum)},t.extend(t.Subtract,t.Signal),t.Subtract.prototype.dispose=function(){return t.Signal.prototype.dispose.call(this),this._neg.dispose(),this._neg=null,this._sum.disconnect(),this._sum=null,this},t.Subtract}),t(function(t){return t.EqualPowerGain=function(){t.SignalBase.call(this),this._eqPower=this.input=this.output=new t.WaveShaper(function(e){return Math.abs(e)<.001?0:t.equalPowerScale(e)}.bind(this),4096)},t.extend(t.EqualPowerGain,t.SignalBase),t.EqualPowerGain.prototype.dispose=function(){return t.SignalBase.prototype.dispose.call(this),this._eqPower.dispose(),this._eqPower=null,this},t.EqualPowerGain}),t(function(t){return t.CrossFade=function(e){t.AudioNode.call(this),this.createInsOuts(2,1),this.a=this.input[0]=new t.Gain,this.b=this.input[1]=new t.Gain,this.fade=new t.Signal(t.defaultArg(e,.5),t.Type.NormalRange),this._equalPowerA=new t.EqualPowerGain,this._equalPowerB=new t.EqualPowerGain,this._one=this.context.getConstant(1),this._invert=new t.Subtract,this.a.connect(this.output),this.b.connect(this.output),this.fade.chain(this._equalPowerB,this.b.gain),this._one.connect(this._invert,0,0),this.fade.connect(this._invert,0,1),this._invert.chain(this._equalPowerA,this.a.gain),this._readOnly("fade")},t.extend(t.CrossFade,t.AudioNode),t.CrossFade.prototype.dispose=function(){return t.AudioNode.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._one=null,this.a.dispose(),this.a=null,this.b.dispose(),this.b=null,this},t.CrossFade}),t(function(t){return t.Filter=function(){var e=t.defaults(arguments,["frequency","type","rolloff"],t.Filter);t.AudioNode.call(this),this.createInsOuts(1,1),this._filters=[],this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(0,t.Type.Cents),this.gain=new t.Signal({value:e.gain,convert:!1}),this.Q=new t.Signal(e.Q),this._type=e.type,this._rolloff=e.rolloff,this.rolloff=e.rolloff,this._readOnly(["detune","frequency","gain","Q"])},t.extend(t.Filter,t.AudioNode),t.Filter.defaults={type:"lowpass",frequency:350,rolloff:-12,Q:1,gain:0},Object.defineProperty(t.Filter.prototype,"type",{get:function(){return this._type},set:function(t){if(-1===["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t))throw new TypeError("Tone.Filter: invalid type "+t);this._type=t;for(var e=0;e<this._filters.length;e++)this._filters[e].type=t}}),Object.defineProperty(t.Filter.prototype,"rolloff",{get:function(){return this._rolloff},set:function(e){e=parseInt(e,10);var i=[-12,-24,-48,-96],n=i.indexOf(e);if(-1===n)throw new RangeError("Tone.Filter: rolloff can only be -12, -24, -48 or -96");n+=1,this._rolloff=e,this.input.disconnect();for(var s=0;s<this._filters.length;s++)this._filters[s].disconnect(),this._filters[s]=null;this._filters=new Array(n);for(var o=0;o<n;o++){var r=this.context.createBiquadFilter();r.type=this._type,this.frequency.connect(r.frequency),this.detune.connect(r.detune),this.Q.connect(r.Q),this.gain.connect(r.gain),this._filters[o]=r}var a=[this.input].concat(this._filters).concat([this.output]);t.connectSeries.apply(t,a)}}),t.Filter.prototype.dispose=function(){t.AudioNode.prototype.dispose.call(this);for(var e=0;e<this._filters.length;e++)this._filters[e].disconnect(),this._filters[e]=null;return this._filters=null,this._writable(["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.frequency=null,this.Q=null,this.detune.dispose(),this.detune=null,this.gain.dispose(),this.gain=null,this},t.Filter}),t(function(t){return t.MultibandSplit=function(){var e=t.defaults(arguments,["lowFrequency","highFrequency"],t.MultibandSplit);t.AudioNode.call(this),this.input=new t.Gain,this.output=new Array(3),this.low=this.output[0]=new t.Filter(0,"lowpass"),this._lowMidFilter=new t.Filter(0,"highpass"),this.mid=this.output[1]=new t.Filter(0,"lowpass"),this.high=this.output[2]=new t.Filter(0,"highpass"),this.lowFrequency=new t.Signal(e.lowFrequency,t.Type.Frequency),this.highFrequency=new t.Signal(e.highFrequency,t.Type.Frequency),this.Q=new t.Signal(e.Q),this.input.fan(this.low,this.high),this.input.chain(this._lowMidFilter,this.mid),this.lowFrequency.connect(this.low.frequency),this.lowFrequency.connect(this._lowMidFilter.frequency),this.highFrequency.connect(this.mid.frequency),this.highFrequency.connect(this.high.frequency),this.Q.connect(this.low.Q),this.Q.connect(this._lowMidFilter.Q),this.Q.connect(this.mid.Q),this.Q.connect(this.high.Q),this._readOnly(["high","mid","low","highFrequency","lowFrequency"])},t.extend(t.MultibandSplit,t.AudioNode),t.MultibandSplit.defaults={lowFrequency:400,highFrequency:2500,Q:1},t.MultibandSplit.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._writable(["high","mid","low","highFrequency","lowFrequency"]),this.low.dispose(),this.low=null,this._lowMidFilter.dispose(),this._lowMidFilter=null,this.mid.dispose(),this.mid=null,this.high.dispose(),this.high=null,this.lowFrequency.dispose(),this.lowFrequency=null,this.highFrequency.dispose(),this.highFrequency=null,this.Q.dispose(),this.Q=null,this},t.MultibandSplit}),t(function(t){return t.EQ3=function(){var e=t.defaults(arguments,["low","mid","high"],t.EQ3);t.AudioNode.call(this),this.output=new t.Gain,this._multibandSplit=this.input=new t.MultibandSplit({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency}),this._lowGain=new t.Gain(e.low,t.Type.Decibels),this._midGain=new t.Gain(e.mid,t.Type.Decibels),this._highGain=new t.Gain(e.high,t.Type.Decibels),this.low=this._lowGain.gain,this.mid=this._midGain.gain,this.high=this._highGain.gain,this.Q=this._multibandSplit.Q,this.lowFrequency=this._multibandSplit.lowFrequency,this.highFrequency=this._multibandSplit.highFrequency,this._multibandSplit.low.chain(this._lowGain,this.output),this._multibandSplit.mid.chain(this._midGain,this.output),this._multibandSplit.high.chain(this._highGain,this.output),this._readOnly(["low","mid","high","lowFrequency","highFrequency"])},t.extend(t.EQ3,t.AudioNode),t.EQ3.defaults={low:0,mid:0,high:0,lowFrequency:400,highFrequency:2500},t.EQ3.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._writable(["low","mid","high","lowFrequency","highFrequency"]),this._multibandSplit.dispose(),this._multibandSplit=null,this.lowFrequency=null,this.highFrequency=null,this._lowGain.dispose(),this._lowGain=null,this._midGain.dispose(),this._midGain=null,this._highGain.dispose(),this._highGain=null,this.low=null,this.mid=null,this.high=null,this.Q=null,this},t.EQ3}),t(function(t){return t.Scale=function(e,i){t.SignalBase.call(this),this._outputMin=t.defaultArg(e,0),this._outputMax=t.defaultArg(i,1),this._scale=this.input=new t.Multiply(1),this._add=this.output=new t.Add(0),this._scale.connect(this._add),this._setRange()},t.extend(t.Scale,t.SignalBase),Object.defineProperty(t.Scale.prototype,"min",{get:function(){return this._outputMin},set:function(t){this._outputMin=t,this._setRange()}}),Object.defineProperty(t.Scale.prototype,"max",{get:function(){return this._outputMax},set:function(t){this._outputMax=t,this._setRange()}}),t.Scale.prototype._setRange=function(){this._add.value=this._outputMin,this._scale.value=this._outputMax-this._outputMin},t.Scale.prototype.dispose=function(){return t.SignalBase.prototype.dispose.call(this),this._add.dispose(),this._add=null,this._scale.dispose(),this._scale=null,this},t.Scale}),t(function(t){return t.ScaleExp=function(e,i,n){t.SignalBase.call(this),this._scale=this.output=new t.Scale(e,i),this._exp=this.input=new t.Pow(t.defaultArg(n,2)),this._exp.connect(this._scale)},t.extend(t.ScaleExp,t.SignalBase),Object.defineProperty(t.ScaleExp.prototype,"exponent",{get:function(){return this._exp.value},set:function(t){this._exp.value=t}}),Object.defineProperty(t.ScaleExp.prototype,"min",{get:function(){return this._scale.min},set:function(t){this._scale.min=t}}),Object.defineProperty(t.ScaleExp.prototype,"max",{get:function(){return this._scale.max},set:function(t){this._scale.max=t}}),t.ScaleExp.prototype.dispose=function(){return t.SignalBase.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._exp.dispose(),this._exp=null,this},t.ScaleExp}),t(function(t){return t.Delay=function(){var e=t.defaults(arguments,["delayTime","maxDelay"],t.Delay);t.AudioNode.call(this),this._maxDelay=Math.max(this.toSeconds(e.maxDelay),this.toSeconds(e.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(this._maxDelay),this.delayTime=new t.Param({param:this._delayNode.delayTime,units:t.Type.Time,value:e.delayTime}),this._readOnly("delayTime")},t.extend(t.Delay,t.AudioNode),t.Delay.defaults={maxDelay:1,delayTime:0},Object.defineProperty(t.Delay.prototype,"maxDelay",{get:function(){return this._maxDelay}}),t.Delay.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._delayNode.disconnect(),this._delayNode=null,this._writable("delayTime"),this.delayTime=null,this},t.Delay}),t(function(t){return t.FeedbackCombFilter=function(){var e=t.defaults(arguments,["delayTime","resonance"],t.FeedbackCombFilter);t.AudioNode.call(this),this._delay=this.input=this.output=new t.Delay(e.delayTime),this.delayTime=this._delay.delayTime,this._feedback=new t.Gain(e.resonance,t.Type.NormalRange),this.resonance=this._feedback.gain,this._delay.chain(this._feedback,this._delay),this._readOnly(["resonance","delayTime"])},t.extend(t.FeedbackCombFilter,t.AudioNode),t.FeedbackCombFilter.defaults={delayTime:.1,resonance:.5},t.FeedbackCombFilter.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._writable(["resonance","delayTime"]),this._delay.dispose(),this._delay=null,this.delayTime=null,this._feedback.dispose(),this._feedback=null,this.resonance=null,this},t.FeedbackCombFilter}),t(function(t){return t.FFT=function(){var e=t.defaults(arguments,["size"],t.FFT);e.type=t.Analyser.Type.FFT,t.AudioNode.call(this),this._analyser=this.input=this.output=new t.Analyser(e)},t.extend(t.FFT,t.AudioNode),t.FFT.defaults={size:1024},t.FFT.prototype.getValue=function(){return this._analyser.getValue()},Object.defineProperty(t.FFT.prototype,"size",{get:function(){return this._analyser.size},set:function(t){this._analyser.size=t}}),t.FFT.prototype.dispose=function(){t.AudioNode.prototype.dispose.call(this),this._analyser.dispose(),this._analyser=null},t.FFT}),t(function(t){return t.Abs=function(){t.SignalBase.call(this),this._abs=this.input=this.output=new t.WaveShaper(function(t){return Math.abs(t)<.001?0:Math.abs(t)},1024)},t.extend(t.Abs,t.SignalBase),t.Abs.prototype.dispose=function(){return t.SignalBase.prototype.dispose.call(this),this._abs.dispose(),this._abs=null,this},t.Abs}),t(function(t){return t.Follower=function(){var e=t.defaults(arguments,["attack","release"],t.Follower);t.AudioNode.call(this),this.createInsOuts(1,1),this._abs=new t.Abs,this._filter=this.context.createBiquadFilter(),this._filter.type="lowpass",this._filter.frequency.value=0,this._filter.Q.value=-100,this._frequencyValues=new t.WaveShaper,this._sub=new t.Subtract,this._delay=new t.Delay(this.blockTime),this._mult=new t.Multiply(1e4),this._attack=e.attack,this._release=e.release,this.input.chain(this._abs,this._filter,this.output),this._abs.connect(this._sub,0,1),this._filter.chain(this._delay,this._sub),this._sub.chain(this._mult,this._frequencyValues,this._filter.frequency),this._setAttackRelease(this._attack,this._release)},t.extend(t.Follower,t.AudioNode),t.Follower.defaults={attack:.05,release:.5},t.Follower.prototype._setAttackRelease=function(e,i){var n=this.blockTime;e=t.Time(e).toFrequency(),i=t.Time(i).toFrequency(),e=Math.max(e,n),i=Math.max(i,n),this._frequencyValues.setMap(function(t){return t<=0?e:i})},Object.defineProperty(t.Follower.prototype,"attack",{get:function(){return this._attack},set:function(t){this._attack=t,this._setAttackRelease(this._attack,this._release)}}),Object.defineProperty(t.Follower.prototype,"release",{get:function(){return this._release},set:function(t){this._release=t,this._setAttackRelease(this._attack,this._release)}}),t.Follower.prototype.connect=t.SignalBase.prototype.connect,t.Follower.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._filter.disconnect(),this._filter=null,this._frequencyValues.disconnect(),this._frequencyValues=null,this._delay.dispose(),this._delay=null,this._sub.disconnect(),this._sub=null,this._abs.dispose(),this._abs=null,this._mult.dispose(),this._mult=null,this._curve=null,this},t.Follower}),t(function(t){return t.ScaledEnvelope=function(){var e=t.defaults(arguments,["attack","decay","sustain","release"],t.Envelope);t.Envelope.call(this,e),e=t.defaultArg(e,t.ScaledEnvelope.defaults),this._exp=this.output=new t.Pow(e.exponent),this._scale=this.output=new t.Scale(e.min,e.max),this._sig.chain(this._exp,this._scale)},t.extend(t.ScaledEnvelope,t.Envelope),t.ScaledEnvelope.defaults={min:0,max:1,exponent:1},Object.defineProperty(t.ScaledEnvelope.prototype,"min",{get:function(){return this._scale.min},set:function(t){this._scale.min=t}}),Object.defineProperty(t.ScaledEnvelope.prototype,"max",{get:function(){return this._scale.max},set:function(t){this._scale.max=t}}),Object.defineProperty(t.ScaledEnvelope.prototype,"exponent",{get:function(){return this._exp.value},set:function(t){this._exp.value=t}}),t.ScaledEnvelope.prototype.dispose=function(){return t.Envelope.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._exp.dispose(),this._exp=null,this},t.ScaledEnvelope}),t(function(t){return t.FrequencyEnvelope=function(){var e=t.defaults(arguments,["attack","decay","sustain","release"],t.Envelope);t.ScaledEnvelope.call(this,e),e=t.defaultArg(e,t.FrequencyEnvelope.defaults),this._octaves=e.octaves,this.baseFrequency=e.baseFrequency,this.octaves=e.octaves},t.extend(t.FrequencyEnvelope,t.Envelope),t.FrequencyEnvelope.defaults={baseFrequency:200,octaves:4,exponent:2},Object.defineProperty(t.FrequencyEnvelope.prototype,"baseFrequency",{get:function(){return this._scale.min},set:function(t){this._scale.min=this.toFrequency(t),this.octaves=this._octaves}}),Object.defineProperty(t.FrequencyEnvelope.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._scale.max=this.baseFrequency*Math.pow(2,t)}}),Object.defineProperty(t.FrequencyEnvelope.prototype,"exponent",{get:function(){return this._exp.value},set:function(t){this._exp.value=t}}),t.FrequencyEnvelope.prototype.dispose=function(){return t.ScaledEnvelope.prototype.dispose.call(this),this},t.FrequencyEnvelope}),t(function(t){return t.GreaterThanZero=function(){t.SignalBase.call(this),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.SignalBase.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._thresh.dispose(),this._thresh=null,this},t.GreaterThanZero}),t(function(t){return t.GreaterThan=function(e){t.Signal.call(this),this.createInsOuts(2,0),this._param=this.input[0]=new t.Subtract(e),this.input[1]=this._param.input[1],this._gtz=this.output=new t.GreaterThanZero,this._param.connect(this._gtz)},t.extend(t.GreaterThan,t.Signal),t.GreaterThan.prototype.dispose=function(){return t.Signal.prototype.dispose.call(this),this._gtz.dispose(),this._gtz=null,this},t.GreaterThan}),t(function(t){return t.Gate=function(){var e=t.defaults(arguments,["threshold","attack","release"],t.Gate);t.AudioNode.call(this),this.createInsOuts(1,1),this._follower=new t.Follower(e.attack,e.release),this._gt=new t.GreaterThan(t.dbToGain(e.threshold)),this.input.connect(this.output),this.input.chain(this._gt,this._follower,this.output.gain)},t.extend(t.Gate,t.AudioNode),t.Gate.defaults={attack:.1,release:.1,threshold:-40},Object.defineProperty(t.Gate.prototype,"threshold",{get:function(){return t.gainToDb(this._gt.value)},set:function(e){this._gt.value=t.dbToGain(e)}}),Object.defineProperty(t.Gate.prototype,"attack",{get:function(){return this._follower.attack},set:function(t){this._follower.attack=t}}),Object.defineProperty(t.Gate.prototype,"release",{get:function(){return this._follower.release},set:function(t){this._follower.release=t}}),t.Gate.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._follower.dispose(),this._gt.dispose(),this._follower=null,this._gt=null,this},t.Gate}),t(function(t){function e(t){return function(e,i){i=this.toSeconds(i),t.apply(this,arguments);var n=this._events.get(i),s=this._events.previousEvent(n),o=this._getTicksUntilEvent(s,i);return n.ticks=Math.max(o,0),this}}return t.TickSignal=function(e){e=t.defaultArg(e,1),t.Signal.call(this,{units:t.Type.Ticks,value:e}),this._events.memory=1/0,this.cancelScheduledValues(0),this._events.add({type:t.Param.AutomationType.SetValue,time:0,value:e})},t.extend(t.TickSignal,t.Signal),t.TickSignal.prototype.setValueAtTime=e(t.Signal.prototype.setValueAtTime),t.TickSignal.prototype.linearRampToValueAtTime=e(t.Signal.prototype.linearRampToValueAtTime),t.TickSignal.prototype.setTargetAtTime=function(t,e,i){e=this.toSeconds(e),this.setRampPoint(e),t=this._fromUnits(t);for(var n=this._events.get(e),s=Math.round(Math.max(1/i,1)),o=0;o<=s;o++){var r=i*o+e,a=this._exponentialApproach(n.time,n.value,t,i,r);this.linearRampToValueAtTime(this._toUnits(a),r)}return this},t.TickSignal.prototype.exponentialRampToValueAtTime=function(t,e){e=this.toSeconds(e),t=this._fromUnits(t);var i=this._events.get(e);null===i&&(i={value:this._initialValue,time:0});for(var n=Math.round(Math.max(10*(e-i.time),1)),s=(e-i.time)/n,o=0;o<=n;o++){var r=s*o+i.time,a=this._exponentialInterpolate(i.time,i.value,e,t,r);this.linearRampToValueAtTime(this._toUnits(a),r)}return this},t.TickSignal.prototype._getTicksUntilEvent=function(e,i){if(null===e)e={ticks:0,time:0};else if(t.isUndef(e.ticks)){var n=this._events.previousEvent(e);e.ticks=this._getTicksUntilEvent(n,e.time)}var s=this.getValueAtTime(e.time),o=this.getValueAtTime(i);return this._events.get(i).time===i&&this._events.get(i).type===t.Param.AutomationType.SetValue&&(o=this.getValueAtTime(i-this.sampleTime)),.5*(i-e.time)*(s+o)+e.ticks},t.TickSignal.prototype.getTicksAtTime=function(t){t=this.toSeconds(t);var e=this._events.get(t);return Math.max(this._getTicksUntilEvent(e,t),0)},t.TickSignal.prototype.getDurationOfTicks=function(t,e){e=this.toSeconds(e);var i=this.getTicksAtTime(e);return this.getTimeOfTick(i+t)-e},t.TickSignal.prototype.getTimeOfTick=function(e){var i=this._events.get(e,"ticks"),n=this._events.getAfter(e,"ticks");if(i&&i.ticks===e)return i.time;if(i&&n&&n.type===t.Param.AutomationType.Linear&&i.value!==n.value){var s=this.getValueAtTime(i.time),o=this.getValueAtTime(n.time),r=(o-s)/(n.time-i.time),a=Math.sqrt(Math.pow(s,2)-2*r*(i.ticks-e)),h=(-s+a)/r,u=(-s-a)/r;return(h>0?h:u)+i.time}return i?0===i.value?1/0:i.time+(e-i.ticks)/i.value:e/this._initialValue},t.TickSignal.prototype.ticksToTime=function(e,i){return i=this.toSeconds(i),new t.Time(this.getDurationOfTicks(e,i))},t.TickSignal.prototype.timeToTicks=function(e,i){i=this.toSeconds(i),e=this.toSeconds(e);var n=this.getTicksAtTime(i),s=this.getTicksAtTime(i+e);return new t.Ticks(s-n)},t.TickSignal}),t(function(t){return t.TimelineState=function(e){t.Timeline.call(this),this._initial=e},t.extend(t.TimelineState,t.Timeline),t.TimelineState.prototype.getValueAtTime=function(t){var e=this.get(t);return null!==e?e.state:this._initial},t.TimelineState.prototype.setStateAtTime=function(t,e){return this.add({state:t,time:e}),this},t.TimelineState.prototype.getLastState=function(t,e){e=this.toSeconds(e);for(var i=this._search(e),n=i;n>=0;n--){var s=this._timeline[n];if(s.state===t)return s}},t.TimelineState.prototype.getNextState=function(t,e){e=this.toSeconds(e);var i=this._search(e);if(-1!==i)for(var n=i;n<this._timeline.length;n++){var s=this._timeline[n];if(s.state===t)return s}},t.TimelineState}),t(function(t){return t.TickSource=function(){var e=t.defaults(arguments,["frequency"],t.TickSource);this.frequency=new t.TickSignal(e.frequency,t.Type.Frequency),this._readOnly("frequency"),this._state=new t.TimelineState(t.State.Stopped),this._state.setStateAtTime(t.State.Stopped,0),this._tickOffset=new t.Timeline,this.setTicksAtTime(0,0)},t.extend(t.TickSource),t.TickSource.defaults={frequency:1},Object.defineProperty(t.TickSource.prototype,"state",{get:function(){return this._state.getValueAtTime(this.now())}}),t.TickSource.prototype.start=function(e,i){return e=this.toSeconds(e),this._state.getValueAtTime(e)!==t.State.Started&&(this._state.setStateAtTime(t.State.Started,e),t.isDefined(i)&&this.setTicksAtTime(i,e)),this},t.TickSource.prototype.stop=function(e){if(e=this.toSeconds(e),this._state.getValueAtTime(e)===t.State.Stopped){var i=this._state.get(e);i.time>0&&(this._tickOffset.cancel(i.time),this._state.cancel(i.time))}return this._state.cancel(e),this._state.setStateAtTime(t.State.Stopped,e),this.setTicksAtTime(0,e),this},t.TickSource.prototype.pause=function(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)===t.State.Started&&this._state.setStateAtTime(t.State.Paused,e),this},t.TickSource.prototype.cancel=function(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this},t.TickSource.prototype.getTicksAtTime=function(e){e=this.toSeconds(e);var i=this._state.getLastState(t.State.Stopped,e),n={state:t.State.Paused,time:e};this._state.add(n);var s=i,o=0;return this._state.forEachBetween(i.time,e+this.sampleTime,function(e){var i=s.time,n=this._tickOffset.get(e.time);n.time>=s.time&&(o=n.ticks,i=n.time),s.state===t.State.Started&&e.state!==t.State.Started&&(o+=this.frequency.getTicksAtTime(e.time)-this.frequency.getTicksAtTime(i)),s=e}.bind(this)),this._state.remove(n),o},Object.defineProperty(t.TickSource.prototype,"ticks",{get:function(){return this.getTicksAtTime(this.now())},set:function(t){this.setTicksAtTime(t,this.now())}}),Object.defineProperty(t.TickSource.prototype,"seconds",{get:function(){return this.getSecondsAtTime(this.now())},set:function(t){var e=this.now(),i=this.frequency.timeToTicks(t,e);this.setTicksAtTime(i,e)}}),t.TickSource.prototype.getSecondsAtTime=function(e){e=this.toSeconds(e);var i=this._state.getLastState(t.State.Stopped,e),n={state:t.State.Paused,time:e};this._state.add(n);var s=i,o=0;return this._state.forEachBetween(i.time,e+this.sampleTime,function(e){var i=s.time,n=this._tickOffset.get(e.time);n.time>=s.time&&(o=n.seconds,i=n.time),s.state===t.State.Started&&e.state!==t.State.Started&&(o+=e.time-i),s=e}.bind(this)),this._state.remove(n),o},t.TickSource.prototype.setTicksAtTime=function(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({time:e,ticks:t,seconds:this.frequency.getDurationOfTicks(t,e)}),this},t.TickSource.prototype.getStateAtTime=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)},t.TickSource.prototype.getTimeOfTick=function(e,i){i=t.defaultArg(i,this.now());var n=this._tickOffset.get(i),s=this._state.get(i),o=Math.max(n.time,s.time),r=this.frequency.getTicksAtTime(o)+e-n.ticks;return this.frequency.getTimeOfTick(r)},t.TickSource.prototype.forEachTickBetween=function(e,i,n){var s=this._state.get(e);if(this._state.forEachBetween(e,i,function(i){s.state===t.State.Started&&i.state!==t.State.Started&&this.forEachTickBetween(Math.max(s.time,e),i.time-this.sampleTime,n),s=i}.bind(this)),e=Math.max(s.time,e),s.state===t.State.Started&&this._state){var o=this.frequency.getTicksAtTime(e),r=this.frequency.getTicksAtTime(s.time),a=o-r,h=a%1;0!==h&&(h=1-h);for(var u=this.frequency.getTimeOfTick(o+h),l=null;u<i&&this._state;){try{n(u,Math.round(this.getTicksAtTime(u)))}catch(t){l=t;break}this._state&&(u+=this.frequency.getDurationOfTicks(1,u))}}if(l)throw l;return this},t.TickSource.prototype.dispose=function(){return t.Param.prototype.dispose.call(this),this._state.dispose(),this._state=null,this._tickOffset.dispose(),this._tickOffset=null,this._writable("frequency"),this.frequency.dispose(),this.frequency=null,this},t.TickSource}),t(function(t){return t.Clock=function(){var e=t.defaults(arguments,["callback","frequency"],t.Clock);t.Emitter.call(this),this.callback=e.callback,this._nextTick=0,this._tickSource=new t.TickSource(e.frequency),this._lastUpdate=0,this.frequency=this._tickSource.frequency,this._readOnly("frequency"),this._state=new t.TimelineState(t.State.Stopped),this._state.setStateAtTime(t.State.Stopped,0),this._boundLoop=this._loop.bind(this),this.context.on("tick",this._boundLoop)},t.extend(t.Clock,t.Emitter),t.Clock.defaults={callback:t.noOp,frequency:1},Object.defineProperty(t.Clock.prototype,"state",{get:function(){return this._state.getValueAtTime(this.now())}}),t.Clock.prototype.start=function(e,i){return e=this.toSeconds(e),this._state.getValueAtTime(e)!==t.State.Started&&(this._state.setStateAtTime(t.State.Started,e),this._tickSource.start(e,i),e<this._lastUpdate&&this.emit("start",e,i)),this},t.Clock.prototype.stop=function(e){return e=this.toSeconds(e),this._state.cancel(e),this._state.setStateAtTime(t.State.Stopped,e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this},t.Clock.prototype.pause=function(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)===t.State.Started&&(this._state.setStateAtTime(t.State.Paused,e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this},Object.defineProperty(t.Clock.prototype,"ticks",{get:function(){return Math.ceil(this.getTicksAtTime(this.now()))},set:function(t){this._tickSource.ticks=t}}),Object.defineProperty(t.Clock.prototype,"seconds",{get:function(){return this._tickSource.seconds},set:function(t){this._tickSource.seconds=t}}),t.Clock.prototype.getSecondsAtTime=function(t){return this._tickSource.getSecondsAtTime(t)},t.Clock.prototype.setTicksAtTime=function(t,e){return this._tickSource.setTicksAtTime(t,e),this},t.Clock.prototype.getTicksAtTime=function(t){return this._tickSource.getTicksAtTime(t)},t.Clock.prototype.nextTickTime=function(t,e){e=this.toSeconds(e);var i=this.getTicksAtTime(e);return this._tickSource.getTimeOfTick(i+t,e)},t.Clock.prototype._loop=function(){var e=this._lastUpdate,i=this.now();this._lastUpdate=i,e!==i&&(this._state.forEachBetween(e,i,function(e){switch(e.state){case t.State.Started:var i=this._tickSource.getTicksAtTime(e.time);this.emit("start",e.time,i);break;case t.State.Stopped:0!==e.time&&this.emit("stop",e.time);break;case t.State.Paused:this.emit("pause",e.time)}}.bind(this)),this._tickSource.forEachTickBetween(e,i,function(t,e){this.callback(t,e)}.bind(this)))},t.Clock.prototype.getStateAtTime=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)},t.Clock.prototype.dispose=function(){t.Emitter.prototype.dispose.call(this),this.context.off("tick",this._boundLoop),this._writable("frequency"),this._tickSource.dispose(),this._tickSource=null,this.frequency=null,this._boundLoop=null,this._nextTick=1/0,this.callback=null,this._state.dispose(),this._state=null},t.Clock}),t(function(t){t.IntervalTimeline=function(){t.call(this),this._root=null,this._length=0},t.extend(t.IntervalTimeline),t.IntervalTimeline.prototype.add=function(i){if(t.isUndef(i.time)||t.isUndef(i.duration))throw new Error("Tone.IntervalTimeline: events must have time and duration parameters");i.time=i.time.valueOf();var n=new e(i.time,i.time+i.duration,i);for(null===this._root?this._root=n:this._root.insert(n),this._length++;null!==n;)n.updateHeight(),n.updateMax(),this._rebalance(n),n=n.parent;return this},t.IntervalTimeline.prototype.remove=function(t){if(null!==this._root){var e=[];this._root.search(t.time,e);for(var i=0;i<e.length;i++){var n=e[i];if(n.event===t){this._removeNode(n),this._length--;break}}}return this},Object.defineProperty(t.IntervalTimeline.prototype,"length",{get:function(){return this._length}}),t.IntervalTimeline.prototype.cancel=function(t){return this.forEachFrom(t,function(t){this.remove(t)}.bind(this)),this},t.IntervalTimeline.prototype._setRoot=function(t){this._root=t,null!==this._root&&(this._root.parent=null)},t.IntervalTimeline.prototype._replaceNodeInParent=function(t,e){null!==t.parent?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)},t.IntervalTimeline.prototype._removeNode=function(t){if(null===t.left&&null===t.right)this._replaceNodeInParent(t,null);else if(null===t.right)this._replaceNodeInParent(t,t.left);else if(null===t.left)this._replaceNodeInParent(t,t.right);else{var e,i,n=t.getBalance();if(n>0)if(null===t.left.right)e=t.left,e.right=t.right,i=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent.right=e.left,i=e.parent,e.left=t.left,e.right=t.right}else if(null===t.right.left)e=t.right,e.left=t.left,i=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent=e.parent,e.parent.left=e.right,i=e.parent,e.left=t.left,e.right=t.right}null!==t.parent?t.isLeftChild()?t.parent.left=e:t.parent.right=e:this._setRoot(e),this._rebalance(i)}t.dispose()},t.IntervalTimeline.prototype._rotateLeft=function(t){var e=t.parent,i=t.isLeftChild(),n=t.right;t.right=n.left,n.left=t,null!==e?i?e.left=n:e.right=n:this._setRoot(n)},t.IntervalTimeline.prototype._rotateRight=function(t){var e=t.parent,i=t.isLeftChild(),n=t.left;t.left=n.right,n.right=t,null!==e?i?e.left=n:e.right=n:this._setRoot(n)},t.IntervalTimeline.prototype._rebalance=function(t){var e=t.getBalance();e>1?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))},t.IntervalTimeline.prototype.get=function(t){if(null!==this._root){var e=[];if(this._root.search(t,e),e.length>0){for(var i=e[0],n=1;n<e.length;n++)e[n].low>i.low&&(i=e[n]);return i.event}}return null},t.IntervalTimeline.prototype.forEach=function(t){if(null!==this._root){var e=[];this._root.traverse(function(t){e.push(t)});for(var i=0;i<e.length;i++){var n=e[i].event;n&&t(n)}}return this},t.IntervalTimeline.prototype.forEachAtTime=function(t,e){if(null!==this._root){var i=[];this._root.search(t,i);for(var n=i.length-1;n>=0;n--){var s=i[n].event;s&&e(s)}}return this},t.IntervalTimeline.prototype.forEachFrom=function(t,e){if(null!==this._root){var i=[];this._root.searchAfter(t,i);for(var n=i.length-1;n>=0;n--){e(i[n].event)}}return this},t.IntervalTimeline.prototype.dispose=function(){var t=[];null!==this._root&&this._root.traverse(function(e){t.push(e)});for(var e=0;e<t.length;e++)t[e].dispose();return t=null,this._root=null,this};var e=function(t,e,i){this.event=i,this.low=t,this.high=e,this.max=this.high,this._left=null,this._right=null,this.parent=null,this.height=0};return e.prototype.insert=function(t){t.low<=this.low?null===this.left?this.left=t:this.left.insert(t):null===this.right?this.right=t:this.right.insert(t)},e.prototype.search=function(t,e){t>this.max||(null!==this.left&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),this.low>t||null!==this.right&&this.right.search(t,e))},e.prototype.searchAfter=function(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)},e.prototype.traverse=function(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)},e.prototype.updateHeight=function(){null!==this.left&&null!==this.right?this.height=Math.max(this.left.height,this.right.height)+1:null!==this.right?this.height=this.right.height+1:null!==this.left?this.height=this.left.height+1:this.height=0},e.prototype.updateMax=function(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))},e.prototype.getBalance=function(){var t=0;return null!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t},e.prototype.isLeftChild=function(){return null!==this.parent&&this.parent.left===this},Object.defineProperty(e.prototype,"left",{get:function(){return this._left},set:function(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}}),Object.defineProperty(e.prototype,"right",{get:function(){return this._right},set:function(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}}),e.prototype.dispose=function(){this.parent=null,this._left=null,this._right=null,this.event=null},t.IntervalTimeline}),t(function(t){return t.Ticks=function(e,i){if(!(this instanceof t.Ticks))return new t.Ticks(e,i);t.TransportTime.call(this,e,i)},t.extend(t.Ticks,t.TransportTime),t.Ticks.prototype._defaultUnits="i",t.Ticks.prototype._now=function(){return t.Transport.ticks},t.Ticks.prototype._beatsToUnits=function(t){return this._getPPQ()*t},t.Ticks.prototype._secondsToUnits=function(t){return t/(60/this._getBpm())*this._getPPQ()},t.Ticks.prototype._ticksToUnits=function(t){return t},t.Ticks.prototype.toTicks=function(){return this.valueOf()},t.Ticks.prototype.toSeconds=function(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())},t.Ticks}),t(function(t){return t.TransportEvent=function(e,i){i=t.defaultArg(i,t.TransportEvent.defaults),t.call(this),this.Transport=e,this.id=t.TransportEvent._eventId++,this.time=t.Ticks(i.time),this.callback=i.callback,this._once=i.once},t.extend(t.TransportEvent),t.TransportEvent.defaults={once:!1,callback:t.noOp},t.TransportEvent._eventId=0,t.TransportEvent.prototype.invoke=function(t){this.callback&&(this.callback(t),this._once&&this.Transport&&this.Transport.clear(this.id))},t.TransportEvent.prototype.dispose=function(){return t.prototype.dispose.call(this),this.Transport=null,this.callback=null,this.time=null,this},t.TransportEvent}),t(function(t){return t.TransportRepeatEvent=function(e,i){t.TransportEvent.call(this,e,i),i=t.defaultArg(i,t.TransportRepeatEvent.defaults),this.duration=t.Ticks(i.duration),this._interval=t.Ticks(i.interval),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this),this.Transport.on("start loopStart",this._boundRestart),this._restart()},t.extend(t.TransportRepeatEvent,t.TransportEvent),t.TransportRepeatEvent.defaults={duration:1/0,interval:1},t.TransportRepeatEvent.prototype.invoke=function(e){this._createEvents(e),t.TransportEvent.prototype.invoke.call(this,e)},t.TransportRepeatEvent.prototype._createEvents=function(e){var i=this.Transport.getTicksAtTime(e);i>=this.time&&i>=this._nextTick&&this._nextTick+this._interval<this.time+this.duration&&(this._nextTick+=this._interval,this._currentId=this._nextId,this._nextId=this.Transport.scheduleOnce(this.invoke.bind(this),t.Ticks(this._nextTick)))},t.TransportRepeatEvent.prototype._restart=function(e){this.Transport.clear(this._currentId),this.Transport.clear(this._nextId),this._nextTick=this.time;var i=this.Transport.getTicksAtTime(e);i>this.time&&(this._nextTick=this.time+Math.ceil((i-this.time)/this._interval)*this._interval),this._currentId=this.Transport.scheduleOnce(this.invoke.bind(this),t.Ticks(this._nextTick)),this._nextTick+=this._interval,this._nextId=this.Transport.scheduleOnce(this.invoke.bind(this),t.Ticks(this._nextTick))},t.TransportRepeatEvent.prototype.dispose=function(){return this.Transport.clear(this._currentId),this.Transport.clear(this._nextId),this.Transport.off("start loopStart",this._boundRestart),this._boundCreateEvents=null,t.TransportEvent.prototype.dispose.call(this),this.duration=null,this._interval=null,this},t.TransportRepeatEvent}),t(function(t){t.Transport=function(){t.Emitter.call(this),t.getContext(function(){this.loop=!1,this._loopStart=0,this._loopEnd=0,this._ppq=e.defaults.PPQ,this._clock=new t.Clock({callback:this._processTick.bind(this),frequency:0}),this._bindClockEvents(),this.bpm=this._clock.frequency,this.bpm._toUnits=this._toUnits.bind(this),this.bpm._fromUnits=this._fromUnits.bind(this),this.bpm.units=t.Type.BPM,this.bpm.value=e.defaults.bpm,this._readOnly("bpm"),this._timeSignature=e.defaults.timeSignature,this._scheduledEvents={},this._timeline=new t.Timeline,this._repeatedEvents=new t.IntervalTimeline,this._syncedSignals=[],this._swingTicks=e.defaults.PPQ/2,this._swingAmount=0}.bind(this))},t.extend(t.Transport,t.Emitter),t.Transport.defaults={bpm:120,swing:0,swingSubdivision:"8n",timeSignature:4,loopStart:0,loopEnd:"4m",PPQ:192},t.Transport.prototype._processTick=function(e,i){if(this._swingAmount>0&&i%this._ppq!=0&&i%(2*this._swingTicks)!=0){var n=i%(2*this._swingTicks)/(2*this._swingTicks),s=Math.sin(n*Math.PI)*this._swingAmount;e+=t.Ticks(2*this._swingTicks/3).toSeconds()*s}this.loop&&i>=this._loopEnd&&(this.emit("loopEnd",e),this._clock.setTicksAtTime(this._loopStart,e),i=this._loopStart,this.emit("loopStart",e,this._clock.getSecondsAtTime(e)),this.emit("loop",e)),this._timeline.forEachAtTime(i,function(t){t.invoke(e)})},t.Transport.prototype.schedule=function(e,i){var n=new t.TransportEvent(this,{time:t.TransportTime(i),callback:e});return this._addEvent(n,this._timeline)},t.Transport.prototype.scheduleRepeat=function(e,i,n,s){var o=new t.TransportRepeatEvent(this,{callback:e,interval:t.Time(i),time:t.TransportTime(n),duration:t.Time(t.defaultArg(s,1/0))});return this._addEvent(o,this._repeatedEvents)},t.Transport.prototype.scheduleOnce=function(e,i){var n=new t.TransportEvent(this,{time:t.TransportTime(i),callback:e,once:!0});return this._addEvent(n,this._timeline)},t.Transport.prototype.clear=function(t){if(this._scheduledEvents.hasOwnProperty(t)){var e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this},t.Transport.prototype._addEvent=function(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id},t.Transport.prototype.cancel=function(e){return e=t.defaultArg(e,0),e=this.toTicks(e),this._timeline.forEachFrom(e,function(t){this.clear(t.id)}.bind(this)),this._repeatedEvents.forEachFrom(e,function(t){this.clear(t.id)}.bind(this)),this},t.Transport.prototype._bindClockEvents=function(){this._clock.on("start",function(e,i){i=t.Ticks(i).toSeconds(),this.emit("start",e,i)}.bind(this)),this._clock.on("stop",function(t){this.emit("stop",t)}.bind(this)),this._clock.on("pause",function(t){this.emit("pause",t)}.bind(this))},Object.defineProperty(t.Transport.prototype,"state",{get:function(){return this._clock.getStateAtTime(this.now())}}),t.Transport.prototype.start=function(e,i){return t.isDefined(i)&&(i=this.toTicks(i)),this._clock.start(e,i),this},t.Transport.prototype.stop=function(t){return this._clock.stop(t),this},t.Transport.prototype.pause=function(t){return this._clock.pause(t),this},t.Transport.prototype.toggle=function(e){return e=this.toSeconds(e),this._clock.getStateAtTime(e)!==t.State.Started?this.start(e):this.stop(e),this},Object.defineProperty(t.Transport.prototype,"timeSignature",{get:function(){return this._timeSignature},set:function(e){t.isArray(e)&&(e=e[0]/e[1]*4),this._timeSignature=e}}),Object.defineProperty(t.Transport.prototype,"loopStart",{get:function(){return t.Ticks(this._loopStart).toSeconds()},set:function(t){this._loopStart=this.toTicks(t)}}),Object.defineProperty(t.Transport.prototype,"loopEnd",{get:function(){return t.Ticks(this._loopEnd).toSeconds()},set:function(t){this._loopEnd=this.toTicks(t)}}),t.Transport.prototype.setLoopPoints=function(t,e){return this.loopStart=t,this.loopEnd=e,this},Object.defineProperty(t.Transport.prototype,"swing",{get:function(){return this._swingAmount},set:function(t){this._swingAmount=t}}),Object.defineProperty(t.Transport.prototype,"swingSubdivision",{get:function(){return t.Ticks(this._swingTicks).toNotation()},set:function(t){this._swingTicks=this.toTicks(t)}}),Object.defineProperty(t.Transport.prototype,"position",{get:function(){var e=this.now(),i=this._clock.getTicksAtTime(e);return t.Ticks(i).toBarsBeatsSixteenths()},set:function(t){var e=this.toTicks(t);this.ticks=e}}),Object.defineProperty(t.Transport.prototype,"seconds",{get:function(){return this._clock.seconds},set:function(t){var e=this.now(),i=this.bpm.timeToTicks(t,e);this.ticks=i}}),Object.defineProperty(t.Transport.prototype,"progress",{get:function(){if(this.loop){var t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}return 0}}),Object.defineProperty(t.Transport.prototype,"ticks",{get:function(){return this._clock.ticks},set:function(e){if(this._clock.ticks!==e){var i=this.now();this.state===t.State.Started?(this.emit("stop",i),this._clock.setTicksAtTime(e,i),this.emit("start",i,this.seconds)):this._clock.setTicksAtTime(e,i)}}}),t.Transport.prototype.getTicksAtTime=function(t){return Math.round(this._clock.getTicksAtTime(t))},t.Transport.prototype.getSecondsAtTime=function(t){return this._clock.getSecondsAtTime(t)},Object.defineProperty(t.Transport.prototype,"PPQ",{get:function(){return this._ppq},set:function(t){var e=this.bpm.value;this._ppq=t,this.bpm.value=e}}),t.Transport.prototype._fromUnits=function(t){return 1/(60/t/this.PPQ)},t.Transport.prototype._toUnits=function(t){return t/this.PPQ*60},t.Transport.prototype.nextSubdivision=function(e){if(e=this.toTicks(e),this.state!==t.State.Started)return 0;var i=this.now(),n=this.getTicksAtTime(i),s=e-n%e;return this._clock.nextTickTime(s,i)},t.Transport.prototype.syncSignal=function(e,i){if(!i){var n=this.now();i=0!==e.getValueAtTime(n)?e.getValueAtTime(n)/this.bpm.getValueAtTime(n):0}var s=new t.Gain(i);return this.bpm.chain(s,e._param),this._syncedSignals.push({ratio:s,signal:e,initial:e.value}),e.value=0,this},t.Transport.prototype.unsyncSignal=function(t){for(var e=this._syncedSignals.length-1;e>=0;e--){var i=this._syncedSignals[e];i.signal===t&&(i.ratio.dispose(),i.signal.value=i.initial,this._syncedSignals.splice(e,1))}return this},t.Transport.prototype.dispose=function(){return t.Emitter.prototype.dispose.call(this),this._clock.dispose(),this._clock=null,this._writable("bpm"),this.bpm=null,this._timeline.dispose(),this._timeline=null,this._repeatedEvents.dispose(),this._repeatedEvents=null,this};var e=t.Transport;return t.Transport=new e,t.Context.on("init",function(i){i.Transport instanceof e?t.Transport=i.Transport:t.Transport=new e,i.Transport=t.Transport}),t.Context.on("close",function(t){t.Transport instanceof e&&t.Transport.dispose()}),t.Transport}),t(function(t){return t.Volume=function(){var e=t.defaults(arguments,["volume"],t.Volume);t.AudioNode.call(this),this.output=this.input=new t.Gain(e.volume,t.Type.Decibels),this._unmutedVolume=e.volume,this.volume=this.output.gain,this._readOnly("volume"),this.mute=e.mute},t.extend(t.Volume,t.AudioNode),t.Volume.defaults={volume:0,mute:!1},Object.defineProperty(t.Volume.prototype,"mute",{get:function(){return this.volume.value===-1/0},set:function(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}}),t.Volume.prototype.dispose=function(){return this.input.dispose(),t.AudioNode.prototype.dispose.call(this),this._writable("volume"),this.volume.dispose(),this.volume=null,this},t.Volume}),t(function(t){t.Master=function(){t.AudioNode.call(this),t.getContext(function(){this.createInsOuts(1,0),this._volume=this.output=new t.Volume,this.volume=this._volume.volume,this._readOnly("volume"),this.input.chain(this.output,this.context.destination)}.bind(this))},t.extend(t.Master,t.AudioNode),t.Master.defaults={volume:0,mute:!1},Object.defineProperty(t.Master.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.Master.prototype.chain=function(){this.input.disconnect(),this.input.chain.apply(this.input,arguments),arguments[arguments.length-1].connect(this.output)},t.Master.prototype.dispose=function(){t.AudioNode.prototype.dispose.call(this),this._writable("volume"),this._volume.dispose(),this._volume=null,this.volume=null},t.AudioNode.prototype.toMaster=function(){return this.connect(t.Master),this},window.AudioNode&&(AudioNode.prototype.toMaster=function(){return this.connect(t.Master),this});var e=t.Master;return t.Master=new e,t.Context.on("init",function(i){i.Master instanceof e?t.Master=i.Master:t.Master=new e,i.Master=t.Master}),t.Context.on("close",function(t){t.Master instanceof e&&t.Master.dispose()}),t.Master}),t(function(t){return t.Source=function(e){e=t.defaultArg(e,t.Source.defaults),t.AudioNode.call(this),this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly("volume"),this._state=new t.TimelineState(t.State.Stopped),this._state.memory=100,this._synced=!1,this._scheduled=[],this._volume.output.output.channelCount=2,this._volume.output.output.channelCountMode="explicit",this.mute=e.mute},t.extend(t.Source,t.AudioNode),t.Source.defaults={volume:0,mute:!1},Object.defineProperty(t.Source.prototype,"state",{get:function(){return this._synced?t.Transport.state===t.State.Started?this._state.getValueAtTime(t.Transport.seconds):t.State.Stopped:this._state.getValueAtTime(this.now())}}),Object.defineProperty(t.Source.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.Source.prototype._start=t.noOp,t.Source.prototype.restart=t.noOp,t.Source.prototype._stop=t.noOp,t.Source.prototype.start=function(e,i,n){if(e=t.isUndef(e)&&this._synced?t.Transport.seconds:this.toSeconds(e),this._state.getValueAtTime(e)===t.State.Started)this._state.cancel(e),this._state.setStateAtTime(t.State.Started,e),this.restart(e,i,n);else if(this._state.setStateAtTime(t.State.Started,e),this._synced){var s=this._state.get(e);s.offset=t.defaultArg(i,0),s.duration=n;var o=t.Transport.schedule(function(t){this._start(t,i,n)}.bind(this),e);this._scheduled.push(o),t.Transport.state===t.State.Started&&this._syncedStart(this.now(),t.Transport.seconds)}else this._start.apply(this,arguments);return this},t.Source.prototype.stop=function(e){if(e=t.isUndef(e)&&this._synced?t.Transport.seconds:this.toSeconds(e),this._synced){var i=t.Transport.schedule(this._stop.bind(this),e);this._scheduled.push(i)}else this._stop.apply(this,arguments);return this._state.cancel(e),this._state.setStateAtTime(t.State.Stopped,e),this},t.Source.prototype.sync=function(){return this._synced=!0,this._syncedStart=function(e,i){if(i>0){var n=this._state.get(i);if(n&&n.state===t.State.Started&&n.time!==i){var s,o=i-this.toSeconds(n.time);n.duration&&(s=this.toSeconds(n.duration)-o),this._start(e,this.toSeconds(n.offset)+o,s)}}}.bind(this),this._syncedStop=function(e){var i=t.Transport.getSecondsAtTime(Math.max(e-this.sampleTime,0));this._state.getValueAtTime(i)===t.State.Started&&this._stop(e)}.bind(this),t.Transport.on("start loopStart",this._syncedStart),t.Transport.on("stop pause loopEnd",this._syncedStop),this},t.Source.prototype.unsync=function(){this._synced&&(t.Transport.off("stop pause loopEnd",this._syncedStop),t.Transport.off("start loopStart",this._syncedStart)),this._synced=!1;for(var e=0;e<this._scheduled.length;e++){var i=this._scheduled[e];t.Transport.clear(i)}return this._scheduled=[],this._state.cancel(0),this},t.Source.prototype.dispose=function(){t.AudioNode.prototype.dispose.call(this),this.unsync(),this._scheduled=null,this._writable("volume"),this._volume.dispose(),this._volume=null,this.volume=null,this._state.dispose(),this._state=null},t.Source}),t(function(t){t.supported&&(AudioBuffer.prototype.copyToChannel||(AudioBuffer.prototype.copyToChannel=function(t,e,i){var n=this.getChannelData(e);i=i||0;for(var s=0;s<n.length;s++)n[s+i]=t[s]},AudioBuffer.prototype.copyFromChannel=function(t,e,i){var n=this.getChannelData(e);i=i||0;for(var s=0;s<t.length;s++)t[s]=n[s+i]}))}),t(function(t){return t.Buffer=function(){var e=t.defaults(arguments,["url","onload","onerror"],t.Buffer);t.call(this),this._buffer=null,this._reversed=e.reverse,this._xhr=null,this._onload=t.noOp,e.url instanceof AudioBuffer||e.url instanceof t.Buffer?(this.set(e.url),e.onload&&(this.loaded?e.onload(this):this._onload=e.onload)):t.isString(e.url)&&this.load(e.url).then(e.onload).catch(e.onerror)},t.extend(t.Buffer),t.Buffer.defaults={url:void 0,reverse:!1,onload:t.noOp,onerror:t.noOp},t.Buffer.prototype.set=function(e){return e instanceof t.Buffer?e.loaded?this._buffer=e.get():e._onload=function(){this.set(e),this._onload(this)}.bind(this):this._buffer=e,this},t.Buffer.prototype.get=function(){return this._buffer},t.Buffer.prototype.load=function(e,i,n){return new Promise(function(s,o){this._xhr=t.Buffer.load(e,function(t){this._xhr=null,this.set(t),s(this),this._onload(this),i&&i(this)}.bind(this),function(t){this._xhr=null,o(t),n&&n(t)}.bind(this))}.bind(this))},t.Buffer.prototype.dispose=function(){return t.prototype.dispose.call(this),this._buffer=null,this._xhr&&(t.Buffer._removeFromDownloadQueue(this._xhr),this._xhr.abort(),this._xhr=null),this},Object.defineProperty(t.Buffer.prototype,"loaded",{get:function(){return this.length>0}}),Object.defineProperty(t.Buffer.prototype,"duration",{get:function(){return this._buffer?this._buffer.duration:0}}),Object.defineProperty(t.Buffer.prototype,"length",{get:function(){return this._buffer?this._buffer.length:0}}),Object.defineProperty(t.Buffer.prototype,"numberOfChannels",{get:function(){return this._buffer?this._buffer.numberOfChannels:0}}),t.Buffer.prototype.fromArray=function(t){var e=t[0].length>0,i=e?t.length:1,n=e?t[0].length:t.length,s=this.context.createBuffer(i,n,this.context.sampleRate);e||1!==i||(t=[t]);for(var o=0;o<i;o++)s.copyToChannel(t[o],o);return this._buffer=s,this},t.Buffer.prototype.toMono=function(e){if(t.isNumber(e))this.fromArray(this.toArray(e));else{for(var i=new Float32Array(this.length),n=this.numberOfChannels,s=0;s<n;s++)for(var o=this.toArray(s),r=0;r<o.length;r++)i[r]+=o[r];i=i.map(function(t){return t/n}),this.fromArray(i)}return this},t.Buffer.prototype.toArray=function(e){if(t.isNumber(e))return this.getChannelData(e);if(1===this.numberOfChannels)return this.toArray(0);for(var i=[],n=0;n<this.numberOfChannels;n++)i[n]=this.getChannelData(n);return i},t.Buffer.prototype.getChannelData=function(t){return this._buffer.getChannelData(t)},t.Buffer.prototype.slice=function(e,i){i=t.defaultArg(i,this.duration);for(var n=Math.floor(this.context.sampleRate*this.toSeconds(e)),s=Math.floor(this.context.sampleRate*this.toSeconds(i)),o=[],r=0;r<this.numberOfChannels;r++)o[r]=this.toArray(r).slice(n,s);return(new t.Buffer).fromArray(o)},t.Buffer.prototype._reverse=function(){if(this.loaded)for(var t=0;t<this.numberOfChannels;t++)Array.prototype.reverse.call(this.getChannelData(t));return this},Object.defineProperty(t.Buffer.prototype,"reverse",{get:function(){return this._reversed},set:function(t){this._reversed!==t&&(this._reversed=t,this._reverse())}}),t.Emitter.mixin(t.Buffer),t.Buffer._downloadQueue=[],t.Buffer.baseUrl="",t.Buffer.fromArray=function(e){return(new t.Buffer).fromArray(e)},t.Buffer.fromUrl=function(e){var i=new t.Buffer;return i.load(e).then(function(){return i})},t.Buffer._removeFromDownloadQueue=function(e){var i=t.Buffer._downloadQueue.indexOf(e);-1!==i&&t.Buffer._downloadQueue.splice(i,1)},t.Buffer.load=function(e,i,n){function s(e){if(t.Buffer._removeFromDownloadQueue(l),t.Buffer.emit("error",e),!n)throw e;n(e)}function o(){for(var e=0,i=0;i<t.Buffer._downloadQueue.length;i++)e+=t.Buffer._downloadQueue[i].progress;t.Buffer.emit("progress",e/t.Buffer._downloadQueue.length)}i=t.defaultArg(i,t.noOp);var r=e.match(/\[(.+\|?)+\]$/);if(r){for(var a=r[1].split("|"),h=a[0],u=0;u<a.length;u++)if(t.Buffer.supportsType(a[u])){h=a[u];break}e=e.replace(r[0],h)}var l=new XMLHttpRequest;return l.open("GET",t.Buffer.baseUrl+e,!0),l.responseType="arraybuffer",l.progress=0,t.Buffer._downloadQueue.push(l),l.addEventListener("load",function(){200===l.status?t.context.decodeAudioData(l.response).then(function(e){l.progress=1,o(),i(e),t.Buffer._removeFromDownloadQueue(l),0===t.Buffer._downloadQueue.length&&t.Buffer.emit("load")}).catch(function(){t.Buffer._removeFromDownloadQueue(l),s("Tone.Buffer: could not decode audio data: "+e)}):s("Tone.Buffer: could not locate file: "+e)}),l.addEventListener("error",s),l.addEventListener("progress",function(t){t.lengthComputable&&(l.progress=t.loaded/t.total*.95,o())}),l.send(),l},t.Buffer.cancelDownloads=function(){return t.Buffer._downloadQueue.slice().forEach(function(e){t.Buffer._removeFromDownloadQueue(e),e.abort()}),t.Buffer},t.Buffer.supportsType=function(t){var e=t.split(".");return e=e[e.length-1],""!==document.createElement("audio").canPlayType("audio/"+e)},t.loaded=function(){function e(){t.Buffer.off("load",i),t.Buffer.off("error",n)}var i,n;return new Promise(function(e,s){i=function(){e()},n=function(){s()},t.Buffer.on("load",i),t.Buffer.on("error",n)}).then(e).catch(function(t){throw e(),new Error(t)})},t.Buffer}),t(function(t){return t.OscillatorNode=function(){var e=t.defaults(arguments,["frequency","type"],t.OscillatorNode);t.AudioNode.call(this,e),this.onended=e.onended,this._startTime=-1,this._stopTime=-1,this._gainNode=this.output=new t.Gain,this._gainNode.gain.setValueAtTime(0,this.context.currentTime),this._oscillator=this.context.createOscillator(),this._oscillator.connect(this._gainNode),this.type=e.type,this.frequency=new t.Param(this._oscillator.frequency,t.Type.Frequency),this.frequency.value=e.frequency,this.detune=new t.Param(this._oscillator.detune,t.Type.Cents),this.detune.value=e.detune,this._gain=1},t.extend(t.OscillatorNode,t.AudioNode),t.OscillatorNode.defaults={frequency:440,detune:0,type:"sine",onended:t.noOp},Object.defineProperty(t.OscillatorNode.prototype,"state",{get:function(){return this.getStateAtTime(this.now())}}),t.OscillatorNode.prototype.getStateAtTime=function(e){return e=this.toSeconds(e),-1!==this._startTime&&e>=this._startTime&&(-1===this._stopTime||e<=this._stopTime)?t.State.Started:t.State.Stopped},t.OscillatorNode.prototype.start=function(t){if(-1!==this._startTime)throw new Error("cannot call OscillatorNode.start more than once");this._startTime=this.toSeconds(t),this._oscillator.start(this._startTime);var e=this.context.currentTime;return this._gainNode.gain.cancelScheduledValues(e),this._gainNode.gain.setValueAtTime(0,e),this._gainNode.gain.setValueAtTime(1,this._startTime),this},t.OscillatorNode.prototype.setPeriodicWave=function(t){return this._oscillator.setPeriodicWave(t),this},t.OscillatorNode.prototype.stop=function(t){return this.cancelStop(),this._stopTime=this.toSeconds(t),this._gainNode.gain.setValueAtTime(0,this._stopTime),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(function(){this._oscillator.stop(this.now()),this.onended()}.bind(this),this._stopTime-this.now()),this},t.OscillatorNode.prototype.cancelStop=function(){return-1!==this._startTime&&(this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this._gainNode.gain.setValueAtTime(1,Math.max(this.now(),this._startTime)),this.context.clearTimeout(this._timeout),this._stopTime=-1),this},Object.defineProperty(t.OscillatorNode.prototype,"type",{get:function(){return this._oscillator.type},set:function(t){this._oscillator.type=t}}),t.OscillatorNode.prototype.dispose=function(){return this.context.clearTimeout(this._timeout),t.AudioNode.prototype.dispose.call(this),this.onended=null,this._oscillator.disconnect(),this._oscillator=null,this._gainNode.dispose(),this._gainNode=null,this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this},t.OscillatorNode}),t(function(t){return t.Oscillator=function(){var e=t.defaults(arguments,["frequency","type"],t.Oscillator);t.Source.call(this,e),this._oscillator=null,this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this._wave=null,this._partials=t.defaultArg(e.partials,[1]),this._phase=e.phase,this._type=null,this.type=e.type,this.phase=this._phase,this._readOnly(["frequency","detune"])},t.extend(t.Oscillator,t.Source),t.Oscillator.defaults={type:"sine",frequency:440,detune:0,phase:0,partials:[]},t.Oscillator.Type={Sine:"sine",Triangle:"triangle",Sawtooth:"sawtooth",Square:"square",Custom:"custom"},t.Oscillator.prototype._start=function(e){this._oscillator=new t.OscillatorNode,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),e=this.toSeconds(e),this._oscillator.start(e)},t.Oscillator.prototype._stop=function(t){return this._oscillator&&(t=this.toSeconds(t),this._oscillator.stop(t)),this},t.Oscillator.prototype.restart=function(t){return this._oscillator.cancelStop(),this._state.cancel(this.toSeconds(t)),this},t.Oscillator.prototype.syncFrequency=function(){return t.Transport.syncSignal(this.frequency),this},t.Oscillator.prototype.unsyncFrequency=function(){return t.Transport.unsyncSignal(this.frequency),this},Object.defineProperty(t.Oscillator.prototype,"type",{get:function(){return this._type},set:function(e){var i=[t.Oscillator.Type.Sine,t.Oscillator.Type.Square,t.Oscillator.Type.Triangle,t.Oscillator.Type.Sawtooth].includes(e);if(0===this._phase&&i)this._wave=null,null!==this._oscillator&&this._oscillator.type;else{var n=this._getRealImaginary(e,this._phase),s=this.context.createPeriodicWave(n[0],n[1]);this._wave=s,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave)}this._type=e}}),t.Oscillator.prototype._getRealImaginary=function(e,i){var n=2048,s=new Float32Array(n),o=new Float32Array(n),r=1;if(e===t.Oscillator.Type.Custom)r=this._partials.length+1,n=r;else{var a=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);a&&(r=parseInt(a[2])+1,e=a[1],r=Math.max(r,2),n=r)}for(var h=1;h<n;++h){var u,l=2/(h*Math.PI);switch(e){case t.Oscillator.Type.Sine:u=h<=r?1:0;break;case t.Oscillator.Type.Square:u=1&h?2*l:0;break;case t.Oscillator.Type.Sawtooth:u=l*(1&h?1:-1);break;case t.Oscillator.Type.Triangle:u=1&h?l*l*2*(h-1>>1&1?-1:1):0;break;case t.Oscillator.Type.Custom:u=this._partials[h-1];break;default:throw new TypeError("Tone.Oscillator: invalid type: "+e)}0!==u?(s[h]=-u*Math.sin(i*h),o[h]=u*Math.cos(i*h)):(s[h]=0,o[h]=0)}return[s,o]},t.Oscillator.prototype._inverseFFT=function(t,e,i){for(var n=0,s=t.length,o=0;o<s;o++)n+=t[o]*Math.cos(o*i)+e[o]*Math.sin(o*i);return n},t.Oscillator.prototype._getInitialValue=function(){for(var t=this._getRealImaginary(this._type,0),e=t[0],i=t[1],n=0,s=2*Math.PI,o=0;o<8;o++)n=Math.max(this._inverseFFT(e,i,o/8*s),n);return-this._inverseFFT(e,i,this._phase)/n},Object.defineProperty(t.Oscillator.prototype,"partials",{get:function(){return this._type!==t.Oscillator.Type.Custom?[]:this._partials},set:function(e){this._partials=e,this.type=t.Oscillator.Type.Custom}}),Object.defineProperty(t.Oscillator.prototype,"phase",{get:function(){return this._phase*(180/Math.PI)},set:function(t){this._phase=t*Math.PI/180,this.type=this._type}}),t.Oscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),null!==this._oscillator&&(this._oscillator.dispose(),this._oscillator=null),this._wave=null,this._writable(["frequency","detune"]),this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this._partials=null,this},t.Oscillator}),t(function(t){return t.AudioToGain=function(){t.SignalBase.call(this),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.SignalBase.prototype.dispose.call(this),this._norm.dispose(),this._norm=null,this},t.AudioToGain}),t(function(t){return t.Zero=function(){t.SignalBase.call(this),this._gain=this.input=this.output=new t.Gain,this.context.getConstant(0).connect(this._gain)},t.extend(t.Zero,t.SignalBase),t.Zero.prototype.dispose=function(){return t.SignalBase.prototype.dispose.call(this),this._gain.dispose(),this._gain=null,this},t.Zero}),t(function(t){return t.LFO=function(){var e=t.defaults(arguments,["frequency","min","max"],t.LFO);t.AudioNode.call(this),this._oscillator=new t.Oscillator({frequency:e.frequency,type:e.type}),this.frequency=this._oscillator.frequency,this.amplitude=this._oscillator.volume,this.amplitude.units=t.Type.NormalRange,this.amplitude.value=e.amplitude,this._stoppedSignal=new t.Signal(0,t.Type.AudioRange),this._zeros=new t.Zero,this._stoppedValue=0,this._a2g=new t.AudioToGain,this._scaler=this.output=new t.Scale(e.min,e.max),this._units=t.Type.Default,this.units=e.units,this._oscillator.chain(this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),this._readOnly(["amplitude","frequency"]),this.phase=e.phase},t.extend(t.LFO,t.AudioNode),t.LFO.defaults={type:"sine",min:0,max:1,phase:0,frequency:"4n",amplitude:1,units:t.Type.Default},t.LFO.prototype.start=function(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(0,t),this._oscillator.start(t),this},t.LFO.prototype.stop=function(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(this._stoppedValue,t),this._oscillator.stop(t),this},t.LFO.prototype.sync=function(){return this._oscillator.sync(),this._oscillator.syncFrequency(),this},t.LFO.prototype.unsync=function(){return this._oscillator.unsync(),this._oscillator.unsyncFrequency(),this},Object.defineProperty(t.LFO.prototype,"min",{get:function(){return this._toUnits(this._scaler.min)},set:function(t){t=this._fromUnits(t),this._scaler.min=t}}),Object.defineProperty(t.LFO.prototype,"max",{get:function(){return this._toUnits(this._scaler.max)},set:function(t){t=this._fromUnits(t),this._scaler.max=t}}),Object.defineProperty(t.LFO.prototype,"type",{get:function(){return this._oscillator.type},set:function(t){this._oscillator.type=t,this._stoppedValue=this._oscillator._getInitialValue(),this._stoppedSignal.value=this._stoppedValue}}),Object.defineProperty(t.LFO.prototype,"phase",{get:function(){return this._oscillator.phase},set:function(t){this._oscillator.phase=t,this._stoppedValue=this._oscillator._getInitialValue(),this._stoppedSignal.value=this._stoppedValue}}),Object.defineProperty(t.LFO.prototype,"units",{get:function(){return this._units},set:function(t){var e=this.min,i=this.max;this._units=t,this.min=e,this.max=i}}),Object.defineProperty(t.LFO.prototype,"mute",{get:function(){return this._oscillator.mute},set:function(t){this._oscillator.mute=t}}),Object.defineProperty(t.LFO.prototype,"state",{get:function(){return this._oscillator.state}}),t.LFO.prototype.connect=function(e){return e.constructor!==t.Signal&&e.constructor!==t.Param||(this.convert=e.convert,this.units=e.units),t.SignalBase.prototype.connect.apply(this,arguments),this},t.LFO.prototype._fromUnits=t.Param.prototype._fromUnits,t.LFO.prototype._toUnits=t.Param.prototype._toUnits,t.LFO.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._writable(["amplitude","frequency"]),this._oscillator.dispose(),this._oscillator=null,this._stoppedSignal.dispose(),this._stoppedSignal=null,this._zeros.dispose(),this._zeros=null,this._scaler.dispose(),this._scaler=null,this._a2g.dispose(),this._a2g=null,this.frequency=null,this.amplitude=null,this},t.LFO}),t(function(t){return t.Limiter=function(){var e=t.defaults(arguments,["threshold"],t.Limiter);t.AudioNode.call(this),this._compressor=this.input=this.output=new t.Compressor({attack:.001,decay:.001,threshold:e.threshold}),this.threshold=this._compressor.threshold,this._readOnly("threshold")},t.extend(t.Limiter,t.AudioNode),t.Limiter.defaults={threshold:-12},t.Limiter.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._compressor.dispose(),this._compressor=null,this._writable("threshold"),this.threshold=null,this},t.Limiter}),t(function(t){return t.LowpassCombFilter=function(){var e=t.defaults(arguments,["delayTime","resonance","dampening"],t.LowpassCombFilter);t.AudioNode.call(this),this.createInsOuts(1,1),this._delay=this.input=new t.Delay(e.delayTime),this.delayTime=this._delay.delayTime,this._lowpass=this.output=this.context.createBiquadFilter(),this._lowpass.Q.value=-3.0102999566398125,this._lowpass.type="lowpass",this.dampening=new t.Param({param:this._lowpass.frequency,units:t.Type.Frequency,value:e.dampening}),this._feedback=new t.Gain(e.resonance,t.Type.NormalRange),this.resonance=this._feedback.gain,this._delay.chain(this._lowpass,this._feedback,this._delay),this._readOnly(["dampening","resonance","delayTime"])},t.extend(t.LowpassCombFilter,t.AudioNode),t.LowpassCombFilter.defaults={delayTime:.1,resonance:.5,dampening:3e3},t.LowpassCombFilter.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._writable(["dampening","resonance","delayTime"]),this.dampening.dispose(),this.dampening=null,this.resonance.dispose(),this.resonance=null,this._delay.dispose(),this._delay=null,this.delayTime=null,this._lowpass.disconnect(),this._lowpass=null,this._feedback.disconnect(),this._feedback=null,this},t.LowpassCombFilter}),t(function(t){return t.Merge=function(){t.AudioNode.call(this),this.createInsOuts(2,0),this.left=this.input[0]=new t.Gain,this.right=this.input[1]=new t.Gain,this._merger=this.output=this.context.createChannelMerger(2),this.left.connect(this._merger,0,0),this.right.connect(this._merger,0,1),this.left.channelCount=1,this.right.channelCount=1,this.left.channelCountMode="explicit",this.right.channelCountMode="explicit"},t.extend(t.Merge,t.AudioNode),t.Merge.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this.left.dispose(),this.left=null,this.right.dispose(),this.right=null,this._merger.disconnect(),this._merger=null,this},t.Merge}),t(function(t){return t.Meter=function(){var e=t.defaults(arguments,["smoothing"],t.Meter);t.AudioNode.call(this),this.input=this.output=this._analyser=new t.Analyser("waveform",1024),this.smoothing=e.smoothing},t.extend(t.Meter,t.AudioNode),t.Meter.defaults={smoothing:.8},t.Meter.prototype.getLevel=function(){this._analyser.type="fft";var t=this._analyser.getValue();return Math.max.apply(this,t)+28},t.Meter.prototype.getValue=function(){return this._analyser.type="waveform",this._analyser.getValue()[0]},Object.defineProperty(t.Meter.prototype,"smoothing",{get:function(){return this._analyser.smoothing},set:function(t){this._analyser.smoothing=t}}),t.Meter.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._analyser.dispose(),this._analyser=null,this},t.Meter}),t(function(t){return t.Split=function(){t.AudioNode.call(this),this.createInsOuts(0,2),this._splitter=this.input=this.context.createChannelSplitter(2),this._splitter.channelCount=2,this._splitter.channelCountMode="explicit",this.left=this.output[0]=new t.Gain,this.right=this.output[1]=new t.Gain,this._splitter.connect(this.left,0,0),this._splitter.connect(this.right,1,0)},t.extend(t.Split,t.AudioNode),t.Split.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._splitter.disconnect(),this.left.dispose(),this.left=null,this.right.dispose(),this.right=null,this._splitter=null,this},t.Split}),t(function(t){return t.MidSideSplit=function(){t.AudioNode.call(this),this.createInsOuts(0,2),this._split=this.input=new t.Split,this._midAdd=new t.Add,this.mid=this.output[0]=new t.Multiply(Math.SQRT1_2),this._sideSubtract=new t.Subtract,this.side=this.output[1]=new t.Multiply(Math.SQRT1_2),this._split.connect(this._midAdd,0,0),this._split.connect(this._midAdd,1,1),this._split.connect(this._sideSubtract,0,0),this._split.connect(this._sideSubtract,1,1),this._midAdd.connect(this.mid),this._sideSubtract.connect(this.side)},t.extend(t.MidSideSplit,t.AudioNode),t.MidSideSplit.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this.mid.dispose(),this.mid=null,this.side.dispose(),this.side=null,this._midAdd.dispose(),this._midAdd=null,this._sideSubtract.dispose(),this._sideSubtract=null,this._split.dispose(),this._split=null,this},t.MidSideSplit}),t(function(t){return t.MidSideMerge=function(){t.AudioNode.call(this),this.createInsOuts(2,0),this.mid=this.input[0]=new t.Gain,this._left=new t.Add,this._timesTwoLeft=new t.Multiply(Math.SQRT1_2),this.side=this.input[1]=new t.Gain,this._right=new t.Subtract,this._timesTwoRight=new t.Multiply(Math.SQRT1_2),this._merge=this.output=new t.Merge,this.mid.connect(this._left,0,0),this.side.connect(this._left,0,1),this.mid.connect(this._right,0,0),this.side.connect(this._right,0,1),this._left.connect(this._timesTwoLeft),this._right.connect(this._timesTwoRight),this._timesTwoLeft.connect(this._merge,0,0),this._timesTwoRight.connect(this._merge,0,1)},t.extend(t.MidSideMerge,t.AudioNode),t.MidSideMerge.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this.mid.dispose(),this.mid=null,this.side.dispose(),this.side=null,this._left.dispose(),this._left=null,this._timesTwoLeft.dispose(),this._timesTwoLeft=null,this._right.dispose(),this._right=null,this._timesTwoRight.dispose(),this._timesTwoRight=null,this._merge.dispose(),this._merge=null,this},t.MidSideMerge}),t(function(t){return t.MidSideCompressor=function(e){t.AudioNode.call(this),e=t.defaultArg(e,t.MidSideCompressor.defaults),this._midSideSplit=this.input=new t.MidSideSplit,this._midSideMerge=this.output=new t.MidSideMerge,this.mid=new t.Compressor(e.mid),this.side=new t.Compressor(e.side),this._midSideSplit.mid.chain(this.mid,this._midSideMerge.mid),this._midSideSplit.side.chain(this.side,this._midSideMerge.side),this._readOnly(["mid","side"])},t.extend(t.MidSideCompressor,t.AudioNode),t.MidSideCompressor.defaults={mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},side:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10}},t.MidSideCompressor.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._writable(["mid","side"]),this.mid.dispose(),this.mid=null,this.side.dispose(),this.side=null,this._midSideSplit.dispose(),this._midSideSplit=null,this._midSideMerge.dispose(),this._midSideMerge=null,this},t.MidSideCompressor}),t(function(t){return t.Mono=function(){t.AudioNode.call(this),this.createInsOuts(1,0),this._merge=this.output=new t.Merge,this.input.connect(this._merge,0,0),this.input.connect(this._merge,0,1)},t.extend(t.Mono,t.AudioNode),t.Mono.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._merge.dispose(),this._merge=null,this},t.Mono}),t(function(t){return t.MultibandCompressor=function(e){t.AudioNode.call(this),e=t.defaultArg(arguments,t.MultibandCompressor.defaults),this._splitter=this.input=new t.MultibandSplit({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency}),this.lowFrequency=this._splitter.lowFrequency,this.highFrequency=this._splitter.highFrequency,this.output=new t.Gain,this.low=new t.Compressor(e.low),this.mid=new t.Compressor(e.mid),this.high=new t.Compressor(e.high),this._splitter.low.chain(this.low,this.output),this._splitter.mid.chain(this.mid,this.output),this._splitter.high.chain(this.high,this.output),this._readOnly(["high","mid","low","highFrequency","lowFrequency"])},t.extend(t.MultibandCompressor,t.AudioNode),t.MultibandCompressor.defaults={low:t.Compressor.defaults,mid:t.Compressor.defaults,high:t.Compressor.defaults,lowFrequency:250,highFrequency:2e3},t.MultibandCompressor.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._splitter.dispose(),this._writable(["high","mid","low","highFrequency","lowFrequency"]),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this._splitter=null,this.low=null,this.mid=null,this.high=null,this.lowFrequency=null,this.highFrequency=null,this},t.MultibandCompressor}),t(function(t){if(t.supported&&!window.StereoPannerNode){var e=function(e){this.context=e,this.pan=new t.Signal(0,t.Type.AudioRange);var i=new t.WaveShaper(function(e){return t.equalPowerScale((e+1)/2)},4096),n=new t.WaveShaper(function(e){return t.equalPowerScale(1-(e+1)/2)},4096),s=new t.Gain,o=new t.Gain,r=this.input=new t.Split;(new t.Zero).fan(i,n);var a=this.output=new t.Merge;r.left.chain(s,a.left),r.right.chain(o,a.right),this.pan.chain(n,s.gain),this.pan.chain(i,o.gain)};e.prototype.disconnect=function(){this.output.disconnect.apply(this.output,arguments)},e.prototype.connect=function(){this.output.connect.apply(this.output,arguments)},AudioContext.prototype.createStereoPanner=function(){return new e(this)},t.Context.prototype.createStereoPanner=function(){return new e(this)}}}),t(function(t){return t.Panner=function(e){t.AudioNode.call(this),this._panner=this.input=this.output=this.context.createStereoPanner(),this.pan=this._panner.pan,this.pan.value=t.defaultArg(e,0),this._readOnly("pan")},t.extend(t.Panner,t.AudioNode),t.Panner.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._writable("pan"),this._panner.disconnect(),this._panner=null,this.pan=null,this},t.Panner}),t(function(t){return t.Panner3D=function(){var e=t.defaults(arguments,["positionX","positionY","positionZ"],t.Panner3D);t.AudioNode.call(this),this._panner=this.input=this.output=this.context.createPanner(),this._panner.panningModel=e.panningModel,this._panner.maxDistance=e.maxDistance,this._panner.distanceModel=e.distanceModel,this._panner.coneOuterGain=e.coneOuterGain,this._panner.coneOuterAngle=e.coneOuterAngle,this._panner.coneInnerAngle=e.coneInnerAngle,this._panner.refDistance=e.refDistance,this._panner.rolloffFactor=e.rolloffFactor,this._orientation=[e.orientationX,e.orientationY,e.orientationZ],this._position=[e.positionX,e.positionY,e.positionZ],this.orientationX=e.orientationX,this.orientationY=e.orientationY,this.orientationZ=e.orientationZ,this.positionX=e.positionX,this.positionY=e.positionY,this.positionZ=e.positionZ},t.extend(t.Panner3D,t.AudioNode),t.Panner3D.defaults={positionX:0,positionY:0,positionZ:0,orientationX:0,orientationY:0,orientationZ:0,panningModel:"equalpower",maxDistance:1e4,distanceModel:"inverse",coneOuterGain:0,coneOuterAngle:360,coneInnerAngle:360,refDistance:1,rolloffFactor:1},t.Panner3D.prototype._rampTimeConstant=.01,t.Panner3D.prototype.setPosition=function(t,e,i){if(this._panner.positionX){var n=this.now();this._panner.positionX.setTargetAtTime(t,n,this._rampTimeConstant),this._panner.positionY.setTargetAtTime(e,n,this._rampTimeConstant),this._panner.positionZ.setTargetAtTime(i,n,this._rampTimeConstant)}else this._panner.setPosition(t,e,i);return this._position=Array.prototype.slice.call(arguments),this},t.Panner3D.prototype.setOrientation=function(t,e,i){if(this._panner.orientationX){var n=this.now();this._panner.orientationX.setTargetAtTime(t,n,this._rampTimeConstant),this._panner.orientationY.setTargetAtTime(e,n,this._rampTimeConstant),this._panner.orientationZ.setTargetAtTime(i,n,this._rampTimeConstant)}else this._panner.setOrientation(t,e,i);return this._orientation=Array.prototype.slice.call(arguments),this},Object.defineProperty(t.Panner3D.prototype,"positionX",{set:function(t){this._position[0]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[0]}}),Object.defineProperty(t.Panner3D.prototype,"positionY",{set:function(t){this._position[1]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[1]}}),Object.defineProperty(t.Panner3D.prototype,"positionZ",{set:function(t){this._position[2]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[2]}}),Object.defineProperty(t.Panner3D.prototype,"orientationX",{set:function(t){this._orientation[0]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[0]}}),Object.defineProperty(t.Panner3D.prototype,"orientationY",{set:function(t){this._orientation[1]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[1]}}),Object.defineProperty(t.Panner3D.prototype,"orientationZ",{set:function(t){this._orientation[2]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[2]}}),t.Panner3D._aliasProperty=function(e){Object.defineProperty(t.Panner3D.prototype,e,{set:function(t){this._panner[e]=t},get:function(){return this._panner[e]}})},t.Panner3D._aliasProperty("panningModel"),t.Panner3D._aliasProperty("refDistance"),t.Panner3D._aliasProperty("rolloffFactor"),t.Panner3D._aliasProperty("distanceModel"),t.Panner3D._aliasProperty("coneInnerAngle"),t.Panner3D._aliasProperty("coneOuterAngle"),t.Panner3D._aliasProperty("coneOuterGain"),t.Panner3D._aliasProperty("maxDistance"),t.Panner3D.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._panner.disconnect(),this._panner=null,this._orientation=null,this._position=null,this},t.Panner3D}),t(function(t){return t.PanVol=function(){var e=t.defaults(arguments,["pan","volume"],t.PanVol);t.AudioNode.call(this),this._panner=this.input=new t.Panner(e.pan),this.pan=this._panner.pan,this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=e.mute,this._readOnly(["pan","volume"])},t.extend(t.PanVol,t.AudioNode),t.PanVol.defaults={pan:0,volume:0,mute:!1},Object.defineProperty(t.PanVol.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.PanVol.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._writable(["pan","volume"]),this._panner.dispose(),this._panner=null,this.pan=null,this._volume.dispose(),this._volume=null,this.volume=null,this},t.PanVol}),t(function(t){return t.Solo=function(){var e=t.defaults(arguments,["solo"],t.Solo);t.AudioNode.call(this),this.input=this.output=new t.Gain,this._soloBind=this._soloed.bind(this),this.context.on("solo",this._soloBind),this.solo=e.solo},t.extend(t.Solo,t.AudioNode),t.Solo.defaults={solo:!1},Object.defineProperty(t.Solo.prototype,"solo",{get:function(){return this._isSoloed()},set:function(t){t?this._addSolo():this._removeSolo(),this.context.emit("solo",this)}}),Object.defineProperty(t.Solo.prototype,"muted",{get:function(){return 0===this.input.gain.value}}),t.Solo.prototype._addSolo=function(){t.isArray(this.context._currentSolo)||(this.context._currentSolo=[]),this._isSoloed()||this.context._currentSolo.push(this)},t.Solo.prototype._removeSolo=function(){if(this._isSoloed()){var t=this.context._currentSolo.indexOf(this);this.context._currentSolo.splice(t,1)}},t.Solo.prototype._isSoloed=function(){return!!t.isArray(this.context._currentSolo)&&(0!==this.context._currentSolo.length&&-1!==this.context._currentSolo.indexOf(this))},t.Solo.prototype._noSolos=function(){return!t.isArray(this.context._currentSolo)||0===this.context._currentSolo.length},t.Solo.prototype._soloed=function(){this._isSoloed()?this.input.gain.value=1:this._noSolos()?this.input.gain.value=1:this.input.gain.value=0},t.Solo.prototype.dispose=function(){return this.context.off("solo",this._soloBind),this._removeSolo(),this._soloBind=null,t.AudioNode.prototype.dispose.call(this),this},t.Solo}),t(function(t){return t.Waveform=function(){var e=t.defaults(arguments,["size"],t.Waveform);e.type=t.Analyser.Type.Waveform,t.AudioNode.call(this),this._analyser=this.input=this.output=new t.Analyser(e)},t.extend(t.Waveform,t.AudioNode),t.Waveform.defaults={size:1024},t.Waveform.prototype.getValue=function(){return this._analyser.getValue()},Object.defineProperty(t.Waveform.prototype,"size",{get:function(){return this._analyser.size},set:function(t){this._analyser.size=t}}),t.Waveform.prototype.dispose=function(){t.AudioNode.prototype.dispose.call(this),this._analyser.dispose(),this._analyser=null},t.Waveform}),t(function(t){return t.CtrlInterpolate=function(){var e=t.defaults(arguments,["values","index"],t.CtrlInterpolate);t.call(this),this.values=e.values,this.index=e.index},t.extend(t.CtrlInterpolate),t.CtrlInterpolate.defaults={index:0,values:[]},Object.defineProperty(t.CtrlInterpolate.prototype,"value",{get:function(){var t=this.index;t=Math.min(t,this.values.length-1);var e=Math.floor(t),i=this.values[e],n=this.values[Math.ceil(t)];return this._interpolate(t-e,i,n)}}),t.CtrlInterpolate.prototype._interpolate=function(e,i,n){if(t.isArray(i)){for(var s=[],o=0;o<i.length;o++)s[o]=this._interpolate(e,i[o],n[o]);return s}if(t.isObject(i)){var r={};for(var a in i)r[a]=this._interpolate(e,i[a],n[a]);return r}return i=this._toNumber(i),n=this._toNumber(n),(1-e)*i+e*n},t.CtrlInterpolate.prototype._toNumber=function(e){return t.isNumber(e)?e:this.toSeconds(e)},t.CtrlInterpolate.prototype.dispose=function(){this.values=null},t.CtrlInterpolate}),t(function(t){return t.CtrlMarkov=function(e,i){t.call(this),this.values=t.defaultArg(e,{}),this.value=t.defaultArg(i,Object.keys(this.values)[0])},t.extend(t.CtrlMarkov),t.CtrlMarkov.prototype.next=function(){if(this.values.hasOwnProperty(this.value)){var e=this.values[this.value];if(t.isArray(e))for(var i=this._getProbDistribution(e),n=Math.random(),s=0,o=0;o<i.length;o++){var r=i[o];if(n>s&&n<s+r){var a=e[o];t.isObject(a)?this.value=a.value:this.value=a}s+=r}else this.value=e}return this.value},t.CtrlMarkov.prototype._getProbDistribution=function(e){for(var i=[],n=0,s=!1,o=0;o<e.length;o++){var r=e[o];t.isObject(r)?(s=!0,i[o]=r.probability):i[o]=1/e.length,n+=i[o]}if(s)for(var a=0;a<i.length;a++)i[a]=i[a]/n;return i},t.CtrlMarkov.prototype.dispose=function(){this.values=null},t.CtrlMarkov}),t(function(t){return t.CtrlPattern=function(){var e=t.defaults(arguments,["values","type"],t.CtrlPattern);t.call(this),this.values=e.values,this.index=0,this._type=null,this._shuffled=null,this._direction=null,this.type=e.type},t.extend(t.CtrlPattern),t.CtrlPattern.Type={Up:"up",Down:"down",UpDown:"upDown",DownUp:"downUp",AlternateUp:"alternateUp",AlternateDown:"alternateDown",Random:"random",RandomWalk:"randomWalk",RandomOnce:"randomOnce"},t.CtrlPattern.defaults={type:t.CtrlPattern.Type.Up,values:[]},Object.defineProperty(t.CtrlPattern.prototype,"value",{get:function(){if(0!==this.values.length){if(1===this.values.length)return this.values[0];this.index=Math.min(this.index,this.values.length-1);var e=this.values[this.index];return this.type===t.CtrlPattern.Type.RandomOnce&&(this.values.length!==this._shuffled.length&&this._shuffleValues(),e=this.values[this._shuffled[this.index]]),e}}}),Object.defineProperty(t.CtrlPattern.prototype,"type",{get:function(){return this._type},set:function(e){this._type=e,this._shuffled=null,this._type===t.CtrlPattern.Type.Up||this._type===t.CtrlPattern.Type.UpDown||this._type===t.CtrlPattern.Type.RandomOnce||this._type===t.CtrlPattern.Type.AlternateUp?this.index=0:this._type!==t.CtrlPattern.Type.Down&&this._type!==t.CtrlPattern.Type.DownUp&&this._type!==t.CtrlPattern.Type.AlternateDown||(this.index=this.values.length-1),this._type===t.CtrlPattern.Type.UpDown||this._type===t.CtrlPattern.Type.AlternateUp?this._direction=t.CtrlPattern.Type.Up:this._type!==t.CtrlPattern.Type.DownUp&&this._type!==t.CtrlPattern.Type.AlternateDown||(this._direction=t.CtrlPattern.Type.Down),this._type===t.CtrlPattern.Type.RandomOnce?this._shuffleValues():this._type===t.CtrlPattern.Random&&(this.index=Math.floor(Math.random()*this.values.length))}}),t.CtrlPattern.prototype.next=function(){var e=this.type;return e===t.CtrlPattern.Type.Up?++this.index>=this.values.length&&(this.index=0):e===t.CtrlPattern.Type.Down?--this.index<0&&(this.index=this.values.length-1):e===t.CtrlPattern.Type.UpDown||e===t.CtrlPattern.Type.DownUp?(this._direction===t.CtrlPattern.Type.Up?this.index++:this.index--,this.index<0?(this.index=1,this._direction=t.CtrlPattern.Type.Up):this.index>=this.values.length&&(this.index=this.values.length-2,this._direction=t.CtrlPattern.Type.Down)):e===t.CtrlPattern.Type.Random?this.index=Math.floor(Math.random()*this.values.length):e===t.CtrlPattern.Type.RandomWalk?Math.random()<.5?(this.index--,this.index=Math.max(this.index,0)):(this.index++,this.index=Math.min(this.index,this.values.length-1)):e===t.CtrlPattern.Type.RandomOnce?++this.index>=this.values.length&&(this.index=0,this._shuffleValues()):e===t.CtrlPattern.Type.AlternateUp?(this._direction===t.CtrlPattern.Type.Up?(this.index+=2,this._direction=t.CtrlPattern.Type.Down):(this.index-=1,this._direction=t.CtrlPattern.Type.Up),this.index>=this.values.length&&(this.index=0,this._direction=t.CtrlPattern.Type.Up)):e===t.CtrlPattern.Type.AlternateDown&&(this._direction===t.CtrlPattern.Type.Up?(this.index+=1,this._direction=t.CtrlPattern.Type.Down):(this.index-=2,this._direction=t.CtrlPattern.Type.Up),this.index<0&&(this.index=this.values.length-1,this._direction=t.CtrlPattern.Type.Down)),this.value},t.CtrlPattern.prototype._shuffleValues=function(){var t=[];this._shuffled=[];for(var e=0;e<this.values.length;e++)t[e]=e;for(;t.length>0;){var i=t.splice(Math.floor(t.length*Math.random()),1);this._shuffled.push(i[0])}},t.CtrlPattern.prototype.dispose=function(){this._shuffled=null,this.values=null},t.CtrlPattern}),t(function(t){return t.CtrlRandom=function(){var e=t.defaults(arguments,["min","max"],t.CtrlRandom);t.call(this),this.min=e.min,this.max=e.max,this.integer=e.integer},t.extend(t.CtrlRandom),t.CtrlRandom.defaults={min:0,max:1,integer:!1},Object.defineProperty(t.CtrlRandom.prototype,"value",{get:function(){var t=this.toSeconds(this.min),e=this.toSeconds(this.max),i=Math.random(),n=i*t+(1-i)*e;return this.integer&&(n=Math.floor(n)),n}}),t.CtrlRandom}),t(function(t){return t.Buffers=function(e){var i=Array.prototype.slice.call(arguments);i.shift();var n=t.defaults(i,["onload","baseUrl"],t.Buffers);t.call(this),this._buffers={},this.baseUrl=n.baseUrl,this._loadingCount=0;for(var s in e)this._loadingCount++,this.add(s,e[s],this._bufferLoaded.bind(this,n.onload))},t.extend(t.Buffers),t.Buffers.defaults={onload:t.noOp,baseUrl:""},t.Buffers.prototype.has=function(t){return this._buffers.hasOwnProperty(t)},t.Buffers.prototype.get=function(t){if(this.has(t))return this._buffers[t];throw new Error("Tone.Buffers: no buffer named "+t)},t.Buffers.prototype._bufferLoaded=function(t){0===--this._loadingCount&&t&&t(this)},Object.defineProperty(t.Buffers.prototype,"loaded",{get:function(){var t=!0;for(var e in this._buffers){var i=this.get(e);t=t&&i.loaded}return t}}),t.Buffers.prototype.add=function(e,i,n){return n=t.defaultArg(n,t.noOp),i instanceof t.Buffer?(this._buffers[e]=i,n(this)):i instanceof AudioBuffer?(this._buffers[e]=new t.Buffer(i),n(this)):t.isString(i)&&(this._buffers[e]=new t.Buffer(this.baseUrl+i,n)),this},t.Buffers.prototype.dispose=function(){t.prototype.dispose.call(this);for(var e in this._buffers)this._buffers[e].dispose();return this._buffers=null,this},t.Buffers}),t(function(t){var e={};return t.prototype.send=function(i,n){e.hasOwnProperty(i)||(e[i]=this.context.createGain()),n=t.defaultArg(n,0);var s=new t.Gain(n,t.Type.Decibels);return this.connect(s),s.connect(e[i]),s},t.prototype.receive=function(t,i){return e.hasOwnProperty(t)||(e[t]=this.context.createGain()),e[t].connect(this,0,i),this},t.Context.on("init",function(t){t.Buses?e=t.Buses:(e={},t.Buses=e)}),t}),t(function(t){return t.Draw=function(){t.call(this),this._events=new t.Timeline,this.expiration=.25,this.anticipation=.008,this._boundDrawLoop=this._drawLoop.bind(this)},t.extend(t.Draw),t.Draw.prototype.schedule=function(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),1===this._events.length&&requestAnimationFrame(this._boundDrawLoop),this},t.Draw.prototype.cancel=function(t){return this._events.cancel(this.toSeconds(t)),this},t.Draw.prototype._drawLoop=function(){for(var e=t.now();this._events.length&&this._events.peek().time-this.anticipation<=e;){var i=this._events.shift();e-i.time<=this.expiration&&i.callback()}this._events.length>0&&requestAnimationFrame(this._boundDrawLoop)},t.Draw=new t.Draw,t.Draw}),t(function(t){t.Listener=function(){t.call(this),this._orientation=[0,0,0,0,0,0],this._position=[0,0,0],t.getContext(function(){this.set(e.defaults)}.bind(this))},t.extend(t.Listener),t.Listener.defaults={positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:1,upX:0,upY:1,upZ:0},t.Listener.prototype._rampTimeConstant=.01,t.Listener.prototype.setPosition=function(t,e,i){if(this.context.listener.positionX){var n=this.now();this.context.listener.positionX.setTargetAtTime(t,n,this._rampTimeConstant),this.context.listener.positionY.setTargetAtTime(e,n,this._rampTimeConstant),this.context.listener.positionZ.setTargetAtTime(i,n,this._rampTimeConstant)}else this.context.listener.setPosition(t,e,i);return this._position=Array.prototype.slice.call(arguments),this},t.Listener.prototype.setOrientation=function(t,e,i,n,s,o){if(this.context.listener.forwardX){var r=this.now();this.context.listener.forwardX.setTargetAtTime(t,r,this._rampTimeConstant),this.context.listener.forwardY.setTargetAtTime(e,r,this._rampTimeConstant),this.context.listener.forwardZ.setTargetAtTime(i,r,this._rampTimeConstant),this.context.listener.upX.setTargetAtTime(n,r,this._rampTimeConstant),this.context.listener.upY.setTargetAtTime(s,r,this._rampTimeConstant),this.context.listener.upZ.setTargetAtTime(o,r,this._rampTimeConstant)}else this.context.listener.setOrientation(t,e,i,n,s,o);return this._orientation=Array.prototype.slice.call(arguments),this},Object.defineProperty(t.Listener.prototype,"positionX",{set:function(t){this._position[0]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[0]}}),Object.defineProperty(t.Listener.prototype,"positionY",{set:function(t){this._position[1]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[1]}}),Object.defineProperty(t.Listener.prototype,"positionZ",{set:function(t){this._position[2]=t,this.setPosition.apply(this,this._position)},get:function(){return this._position[2]}}),Object.defineProperty(t.Listener.prototype,"forwardX",{set:function(t){this._orientation[0]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[0]}}),Object.defineProperty(t.Listener.prototype,"forwardY",{set:function(t){this._orientation[1]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[1]}}),Object.defineProperty(t.Listener.prototype,"forwardZ",{set:function(t){this._orientation[2]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[2]}}),Object.defineProperty(t.Listener.prototype,"upX",{set:function(t){this._orientation[3]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[3]}}),Object.defineProperty(t.Listener.prototype,"upY",{set:function(t){this._orientation[4]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[4]}}),Object.defineProperty(t.Listener.prototype,"upZ",{set:function(t){this._orientation[5]=t,this.setOrientation.apply(this,this._orientation)},get:function(){return this._orientation[5]}}),t.Listener.prototype.dispose=function(){return this._orientation=null,this._position=null,this};var e=t.Listener;return t.Listener=new e,t.Context.on("init",function(i){i.Listener instanceof e?t.Listener=i.Listener:t.Listener=new e,i.Listener=t.Listener}),t.Listener}),t(function(t){function e(i,n,s,o){o=t.defaultArg(o,0);var r=new t.OfflineContext(2,n,s);t.context=r;var a=i(t.Transport);return r.currentTime>0&&o<1e3?e(i,n,s,++o):{response:a,context:r}}return t.Offline=function(i,n){var s,o=t.context.sampleRate,r=t.context,a=e(i,n,o),h=a.response,u=a.context;return s=h instanceof Promise?h.then(function(){return u.render()}):u.render(),t.context=r,s.then(function(e){return new t.Buffer(e)})},t.Offline}),t(function(t){return t.Effect=function(){var e=t.defaults(arguments,["wet"],t.Effect);t.AudioNode.call(this),this.createInsOuts(1,1),this._dryWet=new t.CrossFade(e.wet),this.wet=this._dryWet.fade,this.effectSend=new t.Gain,this.effectReturn=new t.Gain,this.input.connect(this._dryWet.a),this.input.connect(this.effectSend),this.effectReturn.connect(this._dryWet.b),this._dryWet.connect(this.output),this._readOnly(["wet"])},t.extend(t.Effect,t.AudioNode),t.Effect.defaults={wet:1},t.Effect.prototype.connectEffect=function(t){return this.effectSend.chain(t,this.effectReturn),this},t.Effect.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._dryWet.dispose(),this._dryWet=null,this.effectSend.dispose(),this.effectSend=null,this.effectReturn.dispose(),this.effectReturn=null,this._writable(["wet"]),this.wet=null,this},t.Effect}),t(function(t){return t.AutoFilter=function(){var e=t.defaults(arguments,["frequency","baseFrequency","octaves"],t.AutoFilter);t.Effect.call(this,e),this._lfo=new t.LFO({frequency:e.frequency,amplitude:e.depth}),this.depth=this._lfo.amplitude,this.frequency=this._lfo.frequency,this.filter=new t.Filter(e.filter),this._octaves=0,this.connectEffect(this.filter),this._lfo.connect(this.filter.frequency),this.type=e.type,this._readOnly(["frequency","depth"]),this.octaves=e.octaves,this.baseFrequency=e.baseFrequency},t.extend(t.AutoFilter,t.Effect),t.AutoFilter.defaults={frequency:1,type:"sine",depth:1,baseFrequency:200,octaves:2.6,filter:{type:"lowpass",rolloff:-12,Q:1}},t.AutoFilter.prototype.start=function(t){return this._lfo.start(t),this},t.AutoFilter.prototype.stop=function(t){return this._lfo.stop(t),this},t.AutoFilter.prototype.sync=function(t){return this._lfo.sync(t),this},t.AutoFilter.prototype.unsync=function(){return this._lfo.unsync(),this},Object.defineProperty(t.AutoFilter.prototype,"type",{get:function(){return this._lfo.type},set:function(t){this._lfo.type=t}}),Object.defineProperty(t.AutoFilter.prototype,"baseFrequency",{get:function(){return this._lfo.min},set:function(t){this._lfo.min=this.toFrequency(t),this.octaves=this._octaves}}),Object.defineProperty(t.AutoFilter.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._lfo.max=this.baseFrequency*Math.pow(2,t)}}),t.AutoFilter.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._lfo.dispose(),this._lfo=null,this.filter.dispose(),this.filter=null,this._writable(["frequency","depth"]),this.frequency=null,this.depth=null,this},t.AutoFilter}),t(function(t){return t.AutoPanner=function(){var e=t.defaults(arguments,["frequency"],t.AutoPanner);t.Effect.call(this,e),this._lfo=new t.LFO({frequency:e.frequency,amplitude:e.depth,min:-1,max:1}),this.depth=this._lfo.amplitude,this._panner=new t.Panner,this.frequency=this._lfo.frequency,this.connectEffect(this._panner),this._lfo.connect(this._panner.pan),this.type=e.type,this._readOnly(["depth","frequency"])},t.extend(t.AutoPanner,t.Effect),t.AutoPanner.defaults={frequency:1,type:"sine",depth:1},t.AutoPanner.prototype.start=function(t){return this._lfo.start(t),this},t.AutoPanner.prototype.stop=function(t){return this._lfo.stop(t),this},t.AutoPanner.prototype.sync=function(t){return this._lfo.sync(t),this},t.AutoPanner.prototype.unsync=function(){return this._lfo.unsync(),this},Object.defineProperty(t.AutoPanner.prototype,"type",{get:function(){return this._lfo.type},set:function(t){this._lfo.type=t}}),t.AutoPanner.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._lfo.dispose(),this._lfo=null,this._panner.dispose(),this._panner=null,this._writable(["depth","frequency"]),this.frequency=null,this.depth=null,this},t.AutoPanner}),t(function(t){return t.AutoWah=function(){var e=t.defaults(arguments,["baseFrequency","octaves","sensitivity"],t.AutoWah);t.Effect.call(this,e),this.follower=new t.Follower(e.follower),this._sweepRange=new t.ScaleExp(0,1,.5),this._baseFrequency=e.baseFrequency,this._octaves=e.octaves,this._inputBoost=new t.Gain,this._bandpass=new t.Filter({rolloff:-48,frequency:0,Q:e.Q}),this._peaking=new t.Filter(0,"peaking"),this._peaking.gain.value=e.gain,this.gain=this._peaking.gain,this.Q=this._bandpass.Q,this.effectSend.chain(this._inputBoost,this.follower,this._sweepRange),this._sweepRange.connect(this._bandpass.frequency),this._sweepRange.connect(this._peaking.frequency),this.effectSend.chain(this._bandpass,this._peaking,this.effectReturn),this._setSweepRange(),this.sensitivity=e.sensitivity,this._readOnly(["gain","Q"])},t.extend(t.AutoWah,t.Effect),t.AutoWah.defaults={baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:{attack:.3,release:.5}},Object.defineProperty(t.AutoWah.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._setSweepRange()}}),Object.defineProperty(t.AutoWah.prototype,"baseFrequency",{get:function(){return this._baseFrequency},set:function(t){this._baseFrequency=t,this._setSweepRange()}}),Object.defineProperty(t.AutoWah.prototype,"sensitivity",{get:function(){return t.gainToDb(1/this._inputBoost.gain.value)},set:function(e){this._inputBoost.gain.value=1/t.dbToGain(e)}}),t.AutoWah.prototype._setSweepRange=function(){this._sweepRange.min=this._baseFrequency,this._sweepRange.max=Math.min(this._baseFrequency*Math.pow(2,this._octaves),this.context.sampleRate/2)},t.AutoWah.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this.follower.dispose(),this.follower=null,this._sweepRange.dispose(),this._sweepRange=null,this._bandpass.dispose(),this._bandpass=null,this._peaking.dispose(),this._peaking=null,this._inputBoost.dispose(),this._inputBoost=null,this._writable(["gain","Q"]),this.gain=null,this.Q=null,this},t.AutoWah}),t(function(t){return t.Modulo=function(e){t.SignalBase.call(this),this.createInsOuts(1,0),this._shaper=new t.WaveShaper(Math.pow(2,16)),this._multiply=new t.Multiply,this._subtract=this.output=new t.Subtract,this._modSignal=new t.Signal(e),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(e)},t.extend(t.Modulo,t.SignalBase),t.Modulo.prototype._setWaveShaper=function(t){this._shaper.setMap(function(e){return Math.floor((e+1e-4)/t)})},Object.defineProperty(t.Modulo.prototype,"value",{get:function(){return this._modSignal.value},set:function(t){this._modSignal.value=t,this._setWaveShaper(t)}}),t.Modulo.prototype.dispose=function(){return t.SignalBase.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},t.Modulo}),t(function(t){return t.BitCrusher=function(){var e=t.defaults(arguments,["bits"],t.BitCrusher);t.Effect.call(this,e);var i=1/Math.pow(2,e.bits-1);this._subtract=new t.Subtract,this._modulo=new t.Modulo(i),this._bits=e.bits,this.effectSend.fan(this._subtract,this._modulo),this._modulo.connect(this._subtract,0,1),this._subtract.connect(this.effectReturn)},t.extend(t.BitCrusher,t.Effect),t.BitCrusher.defaults={bits:4},Object.defineProperty(t.BitCrusher.prototype,"bits",{get:function(){return this._bits},set:function(t){this._bits=t;var e=1/Math.pow(2,t-1);this._modulo.value=e}}),t.BitCrusher.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._subtract.dispose(),this._subtract=null,this._modulo.dispose(),this._modulo=null,this},t.BitCrusher}),t(function(t){return t.Chebyshev=function(){var e=t.defaults(arguments,["order"],t.Chebyshev);t.Effect.call(this,e),this._shaper=new t.WaveShaper(4096),this._order=e.order,this.connectEffect(this._shaper),this.order=e.order,this.oversample=e.oversample},t.extend(t.Chebyshev,t.Effect),t.Chebyshev.defaults={order:1,oversample:"none"},t.Chebyshev.prototype._getCoefficient=function(t,e,i){return i.hasOwnProperty(e)?i[e]:(i[e]=0===e?0:1===e?t:2*t*this._getCoefficient(t,e-1,i)-this._getCoefficient(t,e-2,i),i[e])},Object.defineProperty(t.Chebyshev.prototype,"order",{get:function(){return this._order},set:function(t){this._order=t;for(var e=new Array(4096),i=e.length,n=0;n<i;++n){var s=2*n/i-1;e[n]=0===s?0:this._getCoefficient(s,t,{})}this._shaper.curve=e}}),Object.defineProperty(t.Chebyshev.prototype,"oversample",{get:function(){return this._shaper.oversample},set:function(t){this._shaper.oversample=t}}),t.Chebyshev.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._shaper.dispose(),this._shaper=null,this},t.Chebyshev}),t(function(t){return t.StereoEffect=function(){t.AudioNode.call(this);var e=t.defaults(arguments,["wet"],t.Effect);this.createInsOuts(1,1),this._dryWet=new t.CrossFade(e.wet),this.wet=this._dryWet.fade,this._split=new t.Split,this.effectSendL=this._split.left,this.effectSendR=this._split.right,this._merge=new t.Merge,this.effectReturnL=this._merge.left,this.effectReturnR=this._merge.right,this.input.connect(this._split),this.input.connect(this._dryWet,0,0),this._merge.connect(this._dryWet,0,1),this._dryWet.connect(this.output),this._readOnly(["wet"])},t.extend(t.StereoEffect,t.Effect),t.StereoEffect.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._dryWet.dispose(),this._dryWet=null,this._split.dispose(),this._split=null,this._merge.dispose(),this._merge=null,this.effectSendL=null,this.effectSendR=null,this.effectReturnL=null,this.effectReturnR=null,this._writable(["wet"]),this.wet=null,this},t.StereoEffect}),t(function(t){return t.Chorus=function(){var e=t.defaults(arguments,["frequency","delayTime","depth"],t.Chorus);t.StereoEffect.call(this,e),this._depth=e.depth,this._delayTime=e.delayTime/1e3,this._lfoL=new t.LFO({frequency:e.frequency,min:0,max:1}),this._lfoR=new t.LFO({frequency:e.frequency,min:0,max:1,phase:180}),this._delayNodeL=new t.Delay,this._delayNodeR=new t.Delay,this.frequency=this._lfoL.frequency,this.effectSendL.chain(this._delayNodeL,this.effectReturnL),this.effectSendR.chain(this._delayNodeR,this.effectReturnR),this.effectSendL.connect(this.effectReturnL),this.effectSendR.connect(this.effectReturnR),this._lfoL.connect(this._delayNodeL.delayTime),this._lfoR.connect(this._delayNodeR.delayTime),this._lfoL.start(),this._lfoR.start(),this._lfoL.frequency.connect(this._lfoR.frequency),this.depth=this._depth,this.frequency.value=e.frequency,this.type=e.type,this._readOnly(["frequency"]),this.spread=e.spread},t.extend(t.Chorus,t.StereoEffect),t.Chorus.defaults={frequency:1.5,delayTime:3.5,depth:.7,type:"sine",spread:180},Object.defineProperty(t.Chorus.prototype,"depth",{get:function(){return this._depth},set:function(t){this._depth=t;var e=this._delayTime*t;this._lfoL.min=Math.max(this._delayTime-e,0),this._lfoL.max=this._delayTime+e,this._lfoR.min=Math.max(this._delayTime-e,0),this._lfoR.max=this._delayTime+e}}),Object.defineProperty(t.Chorus.prototype,"delayTime",{get:function(){return 1e3*this._delayTime},set:function(t){this._delayTime=t/1e3,this.depth=this._depth}}),Object.defineProperty(t.Chorus.prototype,"type",{get:function(){return this._lfoL.type},set:function(t){this._lfoL.type=t,this._lfoR.type=t}}),Object.defineProperty(t.Chorus.prototype,"spread",{get:function(){return this._lfoR.phase-this._lfoL.phase},set:function(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}}),t.Chorus.prototype.dispose=function(){return t.StereoEffect.prototype.dispose.call(this),this._lfoL.dispose(),this._lfoL=null,this._lfoR.dispose(),this._lfoR=null,this._delayNodeL.dispose(),this._delayNodeL=null,this._delayNodeR.dispose(),this._delayNodeR=null,this._writable("frequency"),this.frequency=null,this},t.Chorus}),t(function(t){return t.Convolver=function(){var e=t.defaults(arguments,["url","onload"],t.Convolver);t.Effect.call(this,e),this._convolver=this.context.createConvolver(),this._buffer=new t.Buffer(e.url,function(t){this._convolver.buffer=t.get(),e.onload()}.bind(this)),this.connectEffect(this._convolver)},t.extend(t.Convolver,t.Effect),t.Convolver.defaults={onload:t.noOp},Object.defineProperty(t.Convolver.prototype,"buffer",{get:function(){return this._buffer.get()},set:function(t){this._buffer.set(t),this._convolver.buffer=this._buffer.get()}}),t.Convolver.prototype.load=function(t,e){return this._buffer.load(t,function(t){this.buffer=t,e&&e()}.bind(this))},t.Convolver.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._convolver.disconnect(),this._convolver=null,this._buffer.dispose(),this._buffer=null,this},t.Convolver}),t(function(t){return t.Distortion=function(){var e=t.defaults(arguments,["distortion"],t.Distortion);t.Effect.call(this,e),this._shaper=new t.WaveShaper(4096),this._distortion=e.distortion,this.connectEffect(this._shaper),this.distortion=e.distortion,this.oversample=e.oversample},t.extend(t.Distortion,t.Effect),t.Distortion.defaults={distortion:.4,oversample:"none"},Object.defineProperty(t.Distortion.prototype,"distortion",{get:function(){return this._distortion},set:function(t){this._distortion=t;var e=100*t,i=Math.PI/180;this._shaper.setMap(function(t){return Math.abs(t)<.001?0:(3+e)*t*20*i/(Math.PI+e*Math.abs(t))})}}),Object.defineProperty(t.Distortion.prototype,"oversample",{get:function(){return this._shaper.oversample},set:function(t){this._shaper.oversample=t}}),t.Distortion.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._shaper.dispose(),this._shaper=null,this},t.Distortion}),t(function(t){return t.FeedbackEffect=function(){var e=t.defaults(arguments,["feedback"],t.FeedbackEffect);t.Effect.call(this,e),this._feedbackGain=new t.Gain(e.feedback,t.Type.NormalRange),this.feedback=this._feedbackGain.gain,this.effectReturn.chain(this._feedbackGain,this.effectSend),this._readOnly(["feedback"])},t.extend(t.FeedbackEffect,t.Effect),t.FeedbackEffect.defaults={feedback:.125},t.FeedbackEffect.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._writable(["feedback"]),this._feedbackGain.dispose(),this._feedbackGain=null,this.feedback=null,this},t.FeedbackEffect}),t(function(t){return t.FeedbackDelay=function(){var e=t.defaults(arguments,["delayTime","feedback"],t.FeedbackDelay);t.FeedbackEffect.call(this,e),this._delayNode=new t.Delay(e.delayTime,e.maxDelay),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),this._readOnly(["delayTime"])},t.extend(t.FeedbackDelay,t.FeedbackEffect),t.FeedbackDelay.defaults={delayTime:.25,maxDelay:1},t.FeedbackDelay.prototype.dispose=function(){return t.FeedbackEffect.prototype.dispose.call(this),this._delayNode.dispose(),this._delayNode=null,this._writable(["delayTime"]),this.delayTime=null,this},t.FeedbackDelay}),t(function(t){var e=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],i=[225,556,441,341];return t.Freeverb=function(){var n=t.defaults(arguments,["roomSize","dampening"],t.Freeverb);t.StereoEffect.call(this,n),this.roomSize=new t.Signal(n.roomSize,t.Type.NormalRange),this.dampening=new t.Signal(n.dampening,t.Type.Frequency),this._combFilters=[],this._allpassFiltersL=[],this._allpassFiltersR=[];for(var s=0;s<i.length;s++){var o=this.context.createBiquadFilter();o.type="allpass",o.frequency.value=i[s],this._allpassFiltersL.push(o)}for(var r=0;r<i.length;r++){var a=this.context.createBiquadFilter();a.type="allpass",a.frequency.value=i[r],this._allpassFiltersR.push(a)}for(var h=0;h<e.length;h++){var u=new t.LowpassCombFilter(e[h]);h<e.length/2?this.effectSendL.chain(u,this._allpassFiltersL[0]):this.effectSendR.chain(u,this._allpassFiltersR[0]),this.roomSize.connect(u.resonance),this.dampening.connect(u.dampening),this._combFilters.push(u)}t.connectSeries.apply(t,this._allpassFiltersL),t.connectSeries.apply(t,this._allpassFiltersR),this._allpassFiltersL[this._allpassFiltersL.length-1].connect(this.effectReturnL),this._allpassFiltersR[this._allpassFiltersR.length-1].connect(this.effectReturnR),this._readOnly(["roomSize","dampening"])},t.extend(t.Freeverb,t.StereoEffect),t.Freeverb.defaults={roomSize:.7,dampening:3e3},t.Freeverb.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this);for(var e=0;e<this._allpassFiltersL.length;e++)this._allpassFiltersL[e].disconnect(),this._allpassFiltersL[e]=null;this._allpassFiltersL=null;for(var i=0;i<this._allpassFiltersR.length;i++)this._allpassFiltersR[i].disconnect(),this._allpassFiltersR[i]=null;this._allpassFiltersR=null;for(var n=0;n<this._combFilters.length;n++)this._combFilters[n].dispose(),this._combFilters[n]=null;return this._combFilters=null,this._writable(["roomSize","dampening"]),this.roomSize.dispose(),this.roomSize=null,this.dampening.dispose(),this.dampening=null,this},t.Freeverb}),t(function(t){var e=[.06748,.06404,.08212,.09004],i=[.773,.802,.753,.733],n=[347,113,37];return t.JCReverb=function(){var s=t.defaults(arguments,["roomSize"],t.JCReverb);t.StereoEffect.call(this,s),this.roomSize=new t.Signal(s.roomSize,t.Type.NormalRange),this._scaleRoomSize=new t.Scale(-.733,.197),this._allpassFilters=[],this._feedbackCombFilters=[];for(var o=0;o<n.length;o++){var r=this.context.createBiquadFilter();r.type="allpass",r.frequency.value=n[o],this._allpassFilters.push(r)}for(var a=0;a<e.length;a++){var h=new t.FeedbackCombFilter(e[a],.1);this._scaleRoomSize.connect(h.resonance),h.resonance.value=i[a],this._allpassFilters[this._allpassFilters.length-1].connect(h),a<e.length/2?h.connect(this.effectReturnL):h.connect(this.effectReturnR),this._feedbackCombFilters.push(h)}this.roomSize.connect(this._scaleRoomSize),t.connectSeries.apply(t,this._allpassFilters),this.effectSendL.connect(this._allpassFilters[0]),this.effectSendR.connect(this._allpassFilters[0]),this._readOnly(["roomSize"])},t.extend(t.JCReverb,t.StereoEffect),t.JCReverb.defaults={roomSize:.5},t.JCReverb.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this);for(var e=0;e<this._allpassFilters.length;e++)this._allpassFilters[e].disconnect(),this._allpassFilters[e]=null;this._allpassFilters=null;for(var i=0;i<this._feedbackCombFilters.length;i++)this._feedbackCombFilters[i].dispose(),this._feedbackCombFilters[i]=null;return this._feedbackCombFilters=null,this._writable(["roomSize"]),this.roomSize.dispose(),this.roomSize=null,this._scaleRoomSize.dispose(),this._scaleRoomSize=null,this},t.JCReverb}),t(function(t){return t.MidSideEffect=function(){t.Effect.apply(this,arguments),this._midSideSplit=new t.MidSideSplit,this._midSideMerge=new t.MidSideMerge,this.midSend=this._midSideSplit.mid,this.sideSend=this._midSideSplit.side,this.midReturn=this._midSideMerge.mid,this.sideReturn=this._midSideMerge.side,this.effectSend.connect(this._midSideSplit),this._midSideMerge.connect(this.effectReturn)},t.extend(t.MidSideEffect,t.Effect),t.MidSideEffect.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._midSideSplit.dispose(),this._midSideSplit=null,this._midSideMerge.dispose(),this._midSideMerge=null,this.midSend=null,this.sideSend=null,this.midReturn=null,this.sideReturn=null,this},t.MidSideEffect}),t(function(t){return t.Phaser=function(){var e=t.defaults(arguments,["frequency","octaves","baseFrequency"],t.Phaser);t.StereoEffect.call(this,e),this._lfoL=new t.LFO(e.frequency,0,1),this._lfoR=new t.LFO(e.frequency,0,1),this._lfoR.phase=180,this._baseFrequency=e.baseFrequency,this._octaves=e.octaves,this.Q=new t.Signal(e.Q,t.Type.Positive),this._filtersL=this._makeFilters(e.stages,this._lfoL,this.Q),this._filtersR=this._makeFilters(e.stages,this._lfoR,this.Q),this.frequency=this._lfoL.frequency,this.frequency.value=e.frequency,this.effectSendL.connect(this._filtersL[0]),this.effectSendR.connect(this._filtersR[0]),this._filtersL[e.stages-1].connect(this.effectReturnL),this._filtersR[e.stages-1].connect(this.effectReturnR),this._lfoL.frequency.connect(this._lfoR.frequency),this.baseFrequency=e.baseFrequency,this.octaves=e.octaves,this._lfoL.start(),this._lfoR.start(),this._readOnly(["frequency","Q"])},t.extend(t.Phaser,t.StereoEffect),t.Phaser.defaults={frequency:.5,octaves:3,stages:10,Q:10,baseFrequency:350},t.Phaser.prototype._makeFilters=function(e,i,n){for(var s=new Array(e),o=0;o<e;o++){var r=this.context.createBiquadFilter();r.type="allpass",n.connect(r.Q),i.connect(r.frequency),s[o]=r}return t.connectSeries.apply(t,s),s},Object.defineProperty(t.Phaser.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t;var e=this._baseFrequency*Math.pow(2,t);this._lfoL.max=e,this._lfoR.max=e}}),Object.defineProperty(t.Phaser.prototype,"baseFrequency",{get:function(){return this._baseFrequency},set:function(t){this._baseFrequency=t,this._lfoL.min=t,this._lfoR.min=t,this.octaves=this._octaves}}),t.Phaser.prototype.dispose=function(){t.StereoEffect.prototype.dispose.call(this),this._writable(["frequency","Q"]),this.Q.dispose(),this.Q=null,this._lfoL.dispose(),this._lfoL=null,this._lfoR.dispose(),this._lfoR=null;for(var e=0;e<this._filtersL.length;e++)this._filtersL[e].disconnect(),this._filtersL[e]=null;this._filtersL=null;for(var i=0;i<this._filtersR.length;i++)this._filtersR[i].disconnect(),this._filtersR[i]=null;return this._filtersR=null,this.frequency=null,this},t.Phaser}),t(function(t){return t.StereoXFeedbackEffect=function(){var e=t.defaults(arguments,["feedback"],t.FeedbackEffect);t.StereoEffect.call(this,e),this.feedback=new t.Signal(e.feedback,t.Type.NormalRange),this._feedbackLR=new t.Gain,this._feedbackRL=new t.Gain,this.effectReturnL.chain(this._feedbackLR,this.effectSendR),this.effectReturnR.chain(this._feedbackRL,this.effectSendL),this.feedback.fan(this._feedbackLR.gain,this._feedbackRL.gain),this._readOnly(["feedback"])},t.extend(t.StereoXFeedbackEffect,t.StereoEffect),t.StereoXFeedbackEffect.prototype.dispose=function(){return t.StereoEffect.prototype.dispose.call(this),this._writable(["feedback"]),this.feedback.dispose(),this.feedback=null,this._feedbackLR.dispose(),this._feedbackLR=null,this._feedbackRL.dispose(),this._feedbackRL=null,this},t.StereoXFeedbackEffect}),t(function(t){return t.PingPongDelay=function(){var e=t.defaults(arguments,["delayTime","feedback"],t.PingPongDelay);t.StereoXFeedbackEffect.call(this,e),this._leftDelay=new t.Delay(0,e.maxDelayTime),this._rightDelay=new t.Delay(0,e.maxDelayTime),this._rightPreDelay=new t.Delay(0,e.maxDelayTime),this.delayTime=new t.Signal(e.delayTime,t.Type.Time),this.effectSendL.chain(this._leftDelay,this.effectReturnL),this.effectSendR.chain(this._rightPreDelay,this._rightDelay,this.effectReturnR),this.delayTime.fan(this._leftDelay.delayTime,this._rightDelay.delayTime,this._rightPreDelay.delayTime),this._feedbackLR.disconnect(),this._feedbackLR.connect(this._rightDelay),this._readOnly(["delayTime"])},t.extend(t.PingPongDelay,t.StereoXFeedbackEffect),t.PingPongDelay.defaults={delayTime:.25,maxDelayTime:1},t.PingPongDelay.prototype.dispose=function(){return t.StereoXFeedbackEffect.prototype.dispose.call(this),this._leftDelay.dispose(),this._leftDelay=null,this._rightDelay.dispose(),this._rightDelay=null,this._rightPreDelay.dispose(),this._rightPreDelay=null,this._writable(["delayTime"]),this.delayTime.dispose(),this.delayTime=null,this},t.PingPongDelay}),t(function(t){return t.PitchShift=function(){var e=t.defaults(arguments,["pitch"],t.PitchShift);t.FeedbackEffect.call(this,e),this._frequency=new t.Signal(0),this._delayA=new t.Delay(0,1),this._lfoA=new t.LFO({min:0,max:.1,type:"sawtooth"}).connect(this._delayA.delayTime),this._delayB=new t.Delay(0,1),this._lfoB=new t.LFO({min:0,max:.1,type:"sawtooth",phase:180}).connect(this._delayB.delayTime),this._crossFade=new t.CrossFade,this._crossFadeLFO=new t.LFO({min:0,max:1,type:"triangle",phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new t.Delay(e.delayTime),this.delayTime=this._feedbackDelay.delayTime,this._readOnly("delayTime"),this._pitch=e.pitch,this._windowSize=e.windowSize,this._delayA.connect(this._crossFade.a),this._delayB.connect(this._crossFade.b),this._frequency.fan(this._lfoA.frequency,this._lfoB.frequency,this._crossFadeLFO.frequency),this.effectSend.fan(this._delayA,this._delayB),this._crossFade.chain(this._feedbackDelay,this.effectReturn);var i=this.now();this._lfoA.start(i),this._lfoB.start(i),this._crossFadeLFO.start(i),this.windowSize=this._windowSize},t.extend(t.PitchShift,t.FeedbackEffect),t.PitchShift.defaults={pitch:0,windowSize:.1,delayTime:0,feedback:0},Object.defineProperty(t.PitchShift.prototype,"pitch",{get:function(){return this._pitch},set:function(e){this._pitch=e;var i=0;e<0?(this._lfoA.min=0,this._lfoA.max=this._windowSize,this._lfoB.min=0,this._lfoB.max=this._windowSize,i=t.intervalToFrequencyRatio(e-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,i=t.intervalToFrequencyRatio(e)-1),this._frequency.value=i*(1.2/this._windowSize)}}),Object.defineProperty(t.PitchShift.prototype,"windowSize",{get:function(){return this._windowSize},set:function(t){this._windowSize=this.toSeconds(t),this.pitch=this._pitch}}),t.PitchShift.prototype.dispose=function(){return t.FeedbackEffect.prototype.dispose.call(this),this._frequency.dispose(),this._frequency=null,this._delayA.disconnect(),this._delayA=null,this._delayB.disconnect(),this._delayB=null,this._lfoA.dispose(),this._lfoA=null,this._lfoB.dispose(),this._lfoB=null,this._crossFade.dispose(),this._crossFade=null,this._crossFadeLFO.dispose(),this._crossFadeLFO=null,this._writable("delayTime"),this._feedbackDelay.dispose(),this._feedbackDelay=null,this.delayTime=null,this},t.PitchShift}),t(function(t){return t.BufferSource=function(){var e=t.defaults(arguments,["buffer","onload"],t.BufferSource);t.AudioNode.call(this,e),this.onended=e.onended,this._startTime=-1,this._sourceStarted=!1,this._sourceStopped=!1,this._stopTime=-1,this._gainNode=this.output=new t.Gain,this._source=this.context.createBufferSource(),this._source.connect(this._gainNode),this._source.onended=this._onended.bind(this),this._buffer=new t.Buffer(e.buffer,e.onload),this.playbackRate=new t.Param(this._source.playbackRate,t.Type.Positive),this.fadeIn=e.fadeIn,this.fadeOut=e.fadeOut,this.curve=e.curve,this._gain=1,this._onendedTimeout=-1,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.playbackRate.value=e.playbackRate},t.extend(t.BufferSource,t.AudioNode),t.BufferSource.defaults={onended:t.noOp,onload:t.noOp,loop:!1,loopStart:0,loopEnd:0,fadeIn:0,fadeOut:0,curve:"linear",playbackRate:1},Object.defineProperty(t.BufferSource.prototype,"state",{get:function(){return this.getStateAtTime(this.now())}}),t.BufferSource.prototype.getStateAtTime=function(e){return e=this.toSeconds(e),-1!==this._startTime&&e>=this._startTime&&!this._sourceStopped?t.State.Started:t.State.Stopped},t.BufferSource.prototype.start=function(e,i,n,s,o){if(-1!==this._startTime)throw new Error("Tone.BufferSource can only be started once.");if(!this.buffer.loaded)throw new Error("Tone.BufferSource: buffer is either not set or not loaded.");e=this.toSeconds(e),i=this.loop?t.defaultArg(i,this.loopStart):t.defaultArg(i,0),i=this.toSeconds(i),s=t.defaultArg(s,1),this._gain=s,o=this.toSeconds(t.defaultArg(o,this.fadeIn)),this.fadeIn=o,o>0?(this._gainNode.gain.setValueAtTime(0,e),"linear"===this.curve?this._gainNode.gain.linearRampToValueAtTime(this._gain,e+o):this._gainNode.gain.exponentialApproachValueAtTime(this._gain,e,o)):this._gainNode.gain.setValueAtTime(s,e),this._startTime=e;var r=this.toSeconds(t.defaultArg(n,this.buffer.duration-i%this.buffer.duration));if(r=Math.max(r,0),t.isDefined(n)&&(this.loop||(r=Math.min(r,this.buffer.duration-i%this.buffer.duration)),this.stop(e+r,this.fadeOut)),this.loop){var a=this.loopEnd||this.buffer.duration,h=this.loopStart,u=a-h;i>=a&&(i=(i-h)%u+h)}return this._source.buffer=this.buffer.get(),this._source.loopEnd=this.loopEnd||this.buffer.duration,i<this.buffer.duration&&(this._sourceStarted=!0,this._source.start(e,i)),this},t.BufferSource.prototype.stop=function(e,i){if(!this.buffer.loaded)throw new Error("Tone.BufferSource: buffer is either not set or not loaded.");if(!this._sourceStopped){if(e=this.toSeconds(e),-1!==this._stopTime&&this.cancelStop(),e<=this._startTime)return this._gainNode.gain.cancelScheduledValues(e),this._gainNode.gain.value=0,this;e=Math.max(this._startTime+this.fadeIn+this.sampleTime,e),this._gainNode.gain.cancelScheduledValues(e),this._stopTime=e,i=this.toSeconds(t.defaultArg(i,this.fadeOut));var n=e-this._startTime-this.fadeIn-this.sampleTime;this.loop||(n=Math.min(n,this.buffer.duration)),i=Math.min(n,i);var s=e-i;return i>this.sampleTime?(this._gainNode.gain.setValueAtTime(this._gain,s),"linear"===this.curve?this._gainNode.gain.linearRampToValueAtTime(0,e):this._gainNode.gain.exponentialApproachValueAtTime(0,s,i)):this._gainNode.gain.setValueAtTime(0,e),t.context.clearTimeout(this._onendedTimeout),this._onendedTimeout=t.context.setTimeout(this._onended.bind(this),this._stopTime-this.now()),this}},t.BufferSource.prototype.cancelStop=function(){if(-1!==this._startTime&&!this._sourceStopped){var t=this.toSeconds(this.fadeIn);this._gainNode.gain.cancelScheduledValues(this._startTime+t+this.sampleTime),this._gainNode.gain.setValueAtTime(1,Math.max(this.now(),this._startTime+t+this.sampleTime)),this.context.clearTimeout(this._onendedTimeout),this._stopTime=-1}return this},t.BufferSource.prototype._onended=function(){if(!this._sourceStopped){this._sourceStopped=!0;var t="exponential"===this.curve?2*this.fadeOut:0;this._sourceStarted&&-1!==this._stopTime&&this._source.stop(this._stopTime+t),this.onended(this)}},Object.defineProperty(t.BufferSource.prototype,"loopStart",{get:function(){return this._source.loopStart},set:function(t){this._source.loopStart=this.toSeconds(t)}}),Object.defineProperty(t.BufferSource.prototype,"loopEnd",{get:function(){return this._source.loopEnd},set:function(t){this._source.loopEnd=this.toSeconds(t)}}),Object.defineProperty(t.BufferSource.prototype,"buffer",{get:function(){return this._buffer},set:function(t){this._buffer.set(t)}}),Object.defineProperty(t.BufferSource.prototype,"loop",{get:function(){return this._source.loop},set:function(t){this._source.loop=t,this.cancelStop()}}),t.BufferSource.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this.onended=null,this._source.onended=null,this._source.disconnect(),this._source=null,this._gainNode.dispose(),this._gainNode=null,this._buffer.dispose(),this._buffer=null,this._startTime=-1,this.playbackRate=null,t.context.clearTimeout(this._onendedTimeout),this},t.BufferSource}),t(function(t){function e(){for(var e in i)n[e]=(new t.Buffer).fromArray(i[e])}t.Noise=function(){var e=t.defaults(arguments,["type"],t.Noise);t.Source.call(this,e),this._source=null,this._type=e.type,this._playbackRate=e.playbackRate},t.extend(t.Noise,t.Source),t.Noise.defaults={type:"white",playbackRate:1},Object.defineProperty(t.Noise.prototype,"type",{get:function(){return this._type},set:function(e){if(this._type!==e){if(!(e in n))throw new TypeError("Tone.Noise: invalid type: "+e);if(this._type=e,this.state===t.State.Started){var i=this.now();this._stop(i),this._start(i)}}}}),Object.defineProperty(t.Noise.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}}),t.Noise.prototype._start=function(e){var i=n[this._type];this._source=new t.BufferSource(i).connect(this.output),this._source.loop=!0,this._source.playbackRate.value=this._playbackRate,this._source.start(this.toSeconds(e),Math.random()*(i.duration-.001))},t.Noise.prototype._stop=function(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)},t.Noise.prototype.restart=function(t){this._stop(t),this._start(t)},t.Noise.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),null!==this._source&&(this._source.disconnect(),this._source=null),this._buffer=null,this};var i={pink:function(){for(var t=[],e=0;e<2;e++){var i=new Float32Array(220500);t[e]=i;var n,s,o,r,a,h,u;n=s=o=r=a=h=u=0;for(var l=0;l<220500;l++){var c=2*Math.random()-1;n=.99886*n+.0555179*c,s=.99332*s+.0750759*c,o=.969*o+.153852*c,r=.8665*r+.3104856*c,a=.55*a+.5329522*c,h=-.7616*h-.016898*c,i[l]=n+s+o+r+a+h+u+.5362*c,i[l]*=.11,u=.115926*c}}return t}(),brown:function(){for(var t=[],e=0;e<2;e++){var i=new Float32Array(220500);t[e]=i;for(var n=0,s=0;s<220500;s++){var o=2*Math.random()-1;i[s]=(n+.02*o)/1.02,n=i[s],i[s]*=3.5}}return t}(),white:function(){for(var t=[],e=0;e<2;e++){var i=new Float32Array(220500);t[e]=i;for(var n=0;n<220500;n++)i[n]=2*Math.random()-1}return t}()},n={};return t.getContext(e),t.Context.on("init",e),t.Noise}),t(function(t){return t.Reverb=function(){var e=t.defaults(arguments,["decay"],t.Reverb);t.Effect.call(this,e),this._convolver=this.context.createConvolver(),this.decay=e.decay,this.preDelay=e.preDelay,this.connectEffect(this._convolver)},t.extend(t.Reverb,t.Effect),t.Reverb.defaults={decay:1.5,preDelay:.01},t.Reverb.prototype.generate=function(){return t.Offline(function(){var e=new t.Noise,i=new t.Noise,n=new t.Merge;e.connect(n.left),i.connect(n.right);var s=(new t.Gain).toMaster();n.connect(s),e.start(0),i.start(0),s.gain.setValueAtTime(0,0),s.gain.linearRampToValueAtTime(1,this.preDelay),s.gain.exponentialApproachValueAtTime(0,this.preDelay,this.decay-this.preDelay)}.bind(this),this.decay).then(function(t){return this._convolver.buffer=t.get(),this}.bind(this))},t.Reverb.prototype.dispose=function(){return t.Effect.prototype.dispose.call(this),this._convolver.disconnect(),this._convolver=null,this},t.Reverb}),t(function(t){return t.StereoFeedbackEffect=function(){var e=t.defaults(arguments,["feedback"],t.FeedbackEffect);t.StereoEffect.call(this,e),this.feedback=new t.Signal(e.feedback,t.Type.NormalRange),this._feedbackL=new t.Gain,this._feedbackR=new t.Gain,this.effectReturnL.chain(this._feedbackL,this.effectSendL),this.effectReturnR.chain(this._feedbackR,this.effectSendR),this.feedback.fan(this._feedbackL.gain,this._feedbackR.gain),this._readOnly(["feedback"])},t.extend(t.StereoFeedbackEffect,t.StereoEffect),t.StereoFeedbackEffect.prototype.dispose=function(){return t.StereoEffect.prototype.dispose.call(this),this._writable(["feedback"]),this.feedback.dispose(),this.feedback=null,this._feedbackL.dispose(),this._feedbackL=null,this._feedbackR.dispose(),this._feedbackR=null,this},t.StereoFeedbackEffect}),t(function(t){return t.StereoWidener=function(){var e=t.defaults(arguments,["width"],t.StereoWidener);t.MidSideEffect.call(this,e),this.width=new t.Signal(e.width,t.Type.NormalRange),this._readOnly(["width"]),this._twoTimesWidthMid=new t.Multiply(2),this._twoTimesWidthSide=new t.Multiply(2),this._midMult=new t.Multiply,this._twoTimesWidthMid.connect(this._midMult,0,1),this.midSend.chain(this._midMult,this.midReturn),this._oneMinusWidth=new t.Subtract,this._oneMinusWidth.connect(this._twoTimesWidthMid),this.context.getConstant(1).connect(this._oneMinusWidth,0,0),this.width.connect(this._oneMinusWidth,0,1),this._sideMult=new t.Multiply,this.width.connect(this._twoTimesWidthSide),this._twoTimesWidthSide.connect(this._sideMult,0,1),this.sideSend.chain(this._sideMult,this.sideReturn)},t.extend(t.StereoWidener,t.MidSideEffect),t.StereoWidener.defaults={width:.5},t.StereoWidener.prototype.dispose=function(){return t.MidSideEffect.prototype.dispose.call(this),this._writable(["width"]),this.width.dispose(),this.width=null,this._midMult.dispose(),this._midMult=null,this._sideMult.dispose(),this._sideMult=null,this._twoTimesWidthMid.dispose(),this._twoTimesWidthMid=null,this._twoTimesWidthSide.dispose(),this._twoTimesWidthSide=null,this._oneMinusWidth.dispose(),this._oneMinusWidth=null,this},t.StereoWidener}),t(function(t){return t.Tremolo=function(){var e=t.defaults(arguments,["frequency","depth"],t.Tremolo);t.StereoEffect.call(this,e),this._lfoL=new t.LFO({phase:e.spread,min:1,max:0}),this._lfoR=new t.LFO({phase:e.spread,min:1,max:0}),this._amplitudeL=new t.Gain,this._amplitudeR=new t.Gain,this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.depth=new t.Signal(e.depth,t.Type.NormalRange),this._readOnly(["frequency","depth"]),this.effectSendL.chain(this._amplitudeL,this.effectReturnL),this.effectSendR.chain(this._amplitudeR,this.effectReturnR),this._lfoL.connect(this._amplitudeL.gain),this._lfoR.connect(this._amplitudeR.gain),this.frequency.fan(this._lfoL.frequency,this._lfoR.frequency),this.depth.fan(this._lfoR.amplitude,this._lfoL.amplitude),this.type=e.type,this.spread=e.spread},t.extend(t.Tremolo,t.StereoEffect),t.Tremolo.defaults={frequency:10,type:"sine",depth:.5,spread:180},t.Tremolo.prototype.start=function(t){return this._lfoL.start(t),this._lfoR.start(t),this},t.Tremolo.prototype.stop=function(t){return this._lfoL.stop(t),this._lfoR.stop(t),this},t.Tremolo.prototype.sync=function(e){return this._lfoL.sync(e),this._lfoR.sync(e),t.Transport.syncSignal(this.frequency),this},t.Tremolo.prototype.unsync=function(){return this._lfoL.unsync(),this._lfoR.unsync(),t.Transport.unsyncSignal(this.frequency),this},Object.defineProperty(t.Tremolo.prototype,"type",{get:function(){return this._lfoL.type},set:function(t){this._lfoL.type=t,this._lfoR.type=t}}),Object.defineProperty(t.Tremolo.prototype,"spread",{get:function(){return this._lfoR.phase-this._lfoL.phase},set:function(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}}),t.Tremolo.prototype.dispose=function(){return t.StereoEffect.prototype.dispose.call(this),this._writable(["frequency","depth"]),this._lfoL.dispose(),this._lfoL=null,this._lfoR.dispose(),this._lfoR=null,this._amplitudeL.dispose(),this._amplitudeL=null,this._amplitudeR.dispose(),this._amplitudeR=null,this.frequency=null,this.depth=null,this},t.Tremolo}),t(function(t){return t.Vibrato=function(){var e=t.defaults(arguments,["frequency","depth"],t.Vibrato);t.Effect.call(this,e),this._delayNode=new t.Delay(0,e.maxDelay),this._lfo=new t.LFO({type:e.type,min:0,max:e.maxDelay,frequency:e.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=e.depth,this._readOnly(["frequency","depth"]),this.effectSend.chain(this._delayNode,this.effectReturn)},t.extend(t.Vibrato,t.Effect),t.Vibrato.defaults={maxDelay:.005,frequency:5,depth:.1,type:"sine"},Object.defineProperty(t.Vibrato.prototype,"type",{get:function(){return this._lfo.type},set:function(t){this._lfo.type=t}}),t.Vibrato.prototype.dispose=function(){t.Effect.prototype.dispose.call(this),this._delayNode.dispose(),this._delayNode=null,this._lfo.dispose(),this._lfo=null,this._writable(["frequency","depth"]),this.frequency=null,this.depth=null},t.Vibrato}),t(function(t){return t.Event=function(){var e=t.defaults(arguments,["callback","value"],t.Event);t.call(this),this._loop=e.loop,this.callback=e.callback,this.value=e.value,this._loopStart=this.toTicks(e.loopStart),this._loopEnd=this.toTicks(e.loopEnd),this._state=new t.TimelineState(t.State.Stopped),this._playbackRate=1,this._startOffset=0,this._probability=e.probability,this._humanize=e.humanize,this.mute=e.mute,this.playbackRate=e.playbackRate},t.extend(t.Event),t.Event.defaults={callback:t.noOp,loop:!1,loopEnd:"1m",loopStart:0,playbackRate:1,value:null,probability:1,mute:!1,humanize:!1},t.Event.prototype._rescheduleEvents=function(e){return e=t.defaultArg(e,-1),this._state.forEachFrom(e,function(e){var i;if(e.state===t.State.Started){t.isDefined(e.id)&&t.Transport.clear(e.id);var n=e.time+Math.round(this.startOffset/this._playbackRate);if(this._loop){i=1/0,t.isNumber(this._loop)&&(i=this._loop*this._getLoopDuration());var s=this._state.getAfter(n);null!==s&&(i=Math.min(i,s.time-n)),i!==1/0&&(this._state.setStateAtTime(t.State.Stopped,n+i+1),i=t.Ticks(i));var o=t.Ticks(this._getLoopDuration());e.id=t.Transport.scheduleRepeat(this._tick.bind(this),o,t.Ticks(n),i)}else e.id=t.Transport.schedule(this._tick.bind(this),t.Ticks(n))}}.bind(this)),this},Object.defineProperty(t.Event.prototype,"state",{get:function(){return this._state.getValueAtTime(t.Transport.ticks)}}),Object.defineProperty(t.Event.prototype,"startOffset",{get:function(){return this._startOffset},set:function(t){this._startOffset=t}}),Object.defineProperty(t.Event.prototype,"probability",{get:function(){return this._probability},set:function(t){this._probability=t}}),Object.defineProperty(t.Event.prototype,"humanize",{get:function(){return this._humanize},set:function(t){this._humanize=t}}),t.Event.prototype.start=function(e){return e=this.toTicks(e),this._state.getValueAtTime(e)===t.State.Stopped&&(this._state.add({state:t.State.Started,time:e,id:void 0}),this._rescheduleEvents(e)),this},t.Event.prototype.stop=function(e){if(this.cancel(e),e=this.toTicks(e),this._state.getValueAtTime(e)===t.State.Started){this._state.setStateAtTime(t.State.Stopped,e);var i=this._state.getBefore(e),n=e;null!==i&&(n=i.time),this._rescheduleEvents(n)}return this},t.Event.prototype.cancel=function(e){return e=t.defaultArg(e,-1/0),e=this.toTicks(e),this._state.forEachFrom(e,function(e){t.Transport.clear(e.id)}),this._state.cancel(e),this},t.Event.prototype._tick=function(e){var i=t.Transport.getTicksAtTime(e);if(!this.mute&&this._state.getValueAtTime(i)===t.State.Started){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){var n=.02;t.isBoolean(this.humanize)||(n=this.toSeconds(this.humanize)),e+=(2*Math.random()-1)*n}this.callback(e,this.value)}},t.Event.prototype._getLoopDuration=function(){return Math.round((this._loopEnd-this._loopStart)/this._playbackRate)},Object.defineProperty(t.Event.prototype,"loop",{get:function(){return this._loop},set:function(t){this._loop=t,this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,"loopEnd",{get:function(){return t.Ticks(this._loopEnd).toSeconds()},set:function(t){this._loopEnd=this.toTicks(t),this._loop&&this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,"loopStart",{get:function(){return t.Ticks(this._loopStart).toSeconds()},set:function(t){this._loopStart=this.toTicks(t),this._loop&&this._rescheduleEvents()}}),Object.defineProperty(t.Event.prototype,"progress",{get:function(){if(this._loop){var e=t.Transport.ticks,i=this._state.get(e);if(null!==i&&i.state===t.State.Started){var n=this._getLoopDuration();return(e-i.time)%n/n}return 0}return 0}}),t.Event.prototype.dispose=function(){this.cancel(),this._state.dispose(),this._state=null,this.callback=null,this.value=null},t.Event}),t(function(t){return t.Loop=function(){var e=t.defaults(arguments,["callback","interval"],t.Loop);t.call(this),this._event=new t.Event({callback:this._tick.bind(this),loop:!0,loopEnd:e.interval,playbackRate:e.playbackRate,probability:e.probability}),this.callback=e.callback,this.iterations=e.iterations},t.extend(t.Loop),t.Loop.defaults={interval:"4n",callback:t.noOp,playbackRate:1,iterations:1/0,probability:!0,mute:!1},t.Loop.prototype.start=function(t){return this._event.start(t),this},t.Loop.prototype.stop=function(t){return this._event.stop(t),this},t.Loop.prototype.cancel=function(t){return this._event.cancel(t),this},t.Loop.prototype._tick=function(t){this.callback(t)},Object.defineProperty(t.Loop.prototype,"state",{get:function(){return this._event.state}}),Object.defineProperty(t.Loop.prototype,"progress",{get:function(){return this._event.progress}}),Object.defineProperty(t.Loop.prototype,"interval",{get:function(){return this._event.loopEnd},set:function(t){this._event.loopEnd=t}}),Object.defineProperty(t.Loop.prototype,"playbackRate",{get:function(){return this._event.playbackRate},set:function(t){this._event.playbackRate=t}}),Object.defineProperty(t.Loop.prototype,"humanize",{get:function(){return this._event.humanize},set:function(t){this._event.humanize=t}}),Object.defineProperty(t.Loop.prototype,"probability",{get:function(){return this._event.probability},set:function(t){this._event.probability=t}}),Object.defineProperty(t.Loop.prototype,"mute",{get:function(){return this._event.mute},set:function(t){this._event.mute=t}}),Object.defineProperty(t.Loop.prototype,"iterations",{get:function(){return!0===this._event.loop?1/0:this._event.loop},set:function(t){this._event.loop=t===1/0||t}}),t.Loop.prototype.dispose=function(){this._event.dispose(),this._event=null,this.callback=null},t.Loop}),t(function(t){return t.Part=function(){var e=t.defaults(arguments,["callback","events"],t.Part);t.Event.call(this,e),this._events=[];for(var i=0;i<e.events.length;i++)Array.isArray(e.events[i])?this.add(e.events[i][0],e.events[i][1]):this.add(e.events[i])},t.extend(t.Part,t.Event),t.Part.defaults={callback:t.noOp,loop:!1,loopEnd:"1m",loopStart:0,playbackRate:1,probability:1,humanize:!1,mute:!1,events:[]},t.Part.prototype.start=function(e,i){var n=this.toTicks(e);return this._state.getValueAtTime(n)!==t.State.Started&&(i=this._loop?t.defaultArg(i,this._loopStart):t.defaultArg(i,0),i=this.toTicks(i),this._state.add({state:t.State.Started,time:n,offset:i}),this._forEach(function(t){this._startNote(t,n,i)})),this},t.Part.prototype._startNote=function(e,i,n){i-=n,this._loop?e.startOffset>=this._loopStart&&e.startOffset<this._loopEnd?(e.startOffset<n&&(i+=this._getLoopDuration()),e.start(t.Ticks(i))):e.startOffset<this._loopStart&&e.startOffset>=n&&(e.loop=!1,e.start(t.Ticks(i))):e.startOffset>=n&&e.start(t.Ticks(i))},Object.defineProperty(t.Part.prototype,"startOffset",{get:function(){return this._startOffset},set:function(t){this._startOffset=t,this._forEach(function(t){t.startOffset+=this._startOffset})}}),t.Part.prototype.stop=function(e){var i=this.toTicks(e);return this._state.cancel(i),this._state.setStateAtTime(t.State.Stopped,i),this._forEach(function(t){t.stop(e)}),this},t.Part.prototype.at=function(e,i){e=t.TransportTime(e);for(var n=t.Ticks(1).toSeconds(),s=0;s<this._events.length;s++){var o=this._events[s];if(Math.abs(e.toTicks()-o.startOffset)<n)return t.isDefined(i)&&(o.value=i),o}return t.isDefined(i)?(this.add(e,i),this._events[this._events.length-1]):null},t.Part.prototype.add=function(e,i){e.hasOwnProperty("time")&&(i=e,e=i.time),e=this.toTicks(e);var n;return i instanceof t.Event?(n=i,n.callback=this._tick.bind(this)):n=new t.Event({callback:this._tick.bind(this),value:i}),n.startOffset=e,n.set({loopEnd:this.loopEnd,loopStart:this.loopStart,loop:this.loop,humanize:this.humanize,playbackRate:this.playbackRate,probability:this.probability}),this._events.push(n),this._restartEvent(n),this},t.Part.prototype._restartEvent=function(e){this._state.forEach(function(i){i.state===t.State.Started?this._startNote(e,i.time,i.offset):e.stop(t.Ticks(i.time))}.bind(this))},t.Part.prototype.remove=function(e,i){e.hasOwnProperty("time")&&(i=e,e=i.time),e=this.toTicks(e);for(var n=this._events.length-1;n>=0;n--){var s=this._events[n];s instanceof t.Part?s.remove(e,i):s.startOffset===e&&(t.isUndef(i)||t.isDefined(i)&&s.value===i)&&(this._events.splice(n,1),s.dispose())}return this},t.Part.prototype.removeAll=function(){return this._forEach(function(t){t.dispose()}),this._events=[],this},t.Part.prototype.cancel=function(t){return this._forEach(function(e){e.cancel(t)}),this._state.cancel(this.toTicks(t)),this},t.Part.prototype._forEach=function(e,i){if(this._events){i=t.defaultArg(i,this);for(var n=this._events.length-1;n>=0;n--){var s=this._events[n];s instanceof t.Part?s._forEach(e,i):e.call(i,s)}}return this},t.Part.prototype._setAll=function(t,e){this._forEach(function(i){i[t]=e})},t.Part.prototype._tick=function(t,e){this.mute||this.callback(t,e)},t.Part.prototype._testLoopBoundries=function(e){e.startOffset<this._loopStart||e.startOffset>=this._loopEnd?e.cancel(0):e.state===t.State.Stopped&&this._restartEvent(e)},Object.defineProperty(t.Part.prototype,"probability",{get:function(){return this._probability},set:function(t){this._probability=t,this._setAll("probability",t)}}),Object.defineProperty(t.Part.prototype,"humanize",{get:function(){return this._humanize},set:function(t){this._humanize=t,this._setAll("humanize",t)}}),Object.defineProperty(t.Part.prototype,"loop",{get:function(){return this._loop},set:function(t){this._loop=t,this._forEach(function(e){e._loopStart=this._loopStart,e._loopEnd=this._loopEnd,e.loop=t,this._testLoopBoundries(e)})}}),Object.defineProperty(t.Part.prototype,"loopEnd",{get:function(){return t.Ticks(this._loopEnd).toSeconds()},set:function(t){this._loopEnd=this.toTicks(t),this._loop&&this._forEach(function(e){e.loopEnd=t,this._testLoopBoundries(e)})}}),Object.defineProperty(t.Part.prototype,"loopStart",{get:function(){return t.Ticks(this._loopStart).toSeconds()},set:function(t){this._loopStart=this.toTicks(t),this._loop&&this._forEach(function(t){t.loopStart=this.loopStart,this._testLoopBoundries(t)})}}),Object.defineProperty(t.Part.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._setAll("playbackRate",t)}}),Object.defineProperty(t.Part.prototype,"length",{get:function(){return this._events.length}}),t.Part.prototype.dispose=function(){return this.removeAll(),this._state.dispose(),this._state=null,this.callback=null,this._events=null,this},t.Part}),t(function(t){return t.Pattern=function(){var e=t.defaults(arguments,["callback","values","pattern"],t.Pattern);t.Loop.call(this,e),this._pattern=new t.CtrlPattern({values:e.values,type:e.pattern,index:e.index})},t.extend(t.Pattern,t.Loop),t.Pattern.defaults={pattern:t.CtrlPattern.Type.Up,callback:t.noOp,values:[]},t.Pattern.prototype._tick=function(t){this.callback(t,this._pattern.value),this._pattern.next()},Object.defineProperty(t.Pattern.prototype,"index",{get:function(){return this._pattern.index},set:function(t){this._pattern.index=t}}),Object.defineProperty(t.Pattern.prototype,"values",{get:function(){return this._pattern.values},set:function(t){this._pattern.values=t}}),Object.defineProperty(t.Pattern.prototype,"value",{get:function(){return this._pattern.value}}),Object.defineProperty(t.Pattern.prototype,"pattern",{get:function(){return this._pattern.type},set:function(t){this._pattern.type=t}}),t.Pattern.prototype.dispose=function(){t.Loop.prototype.dispose.call(this),this._pattern.dispose(),this._pattern=null},t.Pattern}),t(function(t){return t.Sequence=function(){var e=t.defaults(arguments,["callback","events","subdivision"],t.Sequence),i=e.events;if(delete e.events,t.Part.call(this,e),this._subdivision=this.toTicks(e.subdivision),t.isUndef(e.loopEnd)&&t.isDefined(i)&&(this._loopEnd=i.length*this._subdivision),this._loop=!0,t.isDefined(i))for(var n=0;n<i.length;n++)this.add(n,i[n])},t.extend(t.Sequence,t.Part),t.Sequence.defaults={subdivision:"4n"},Object.defineProperty(t.Sequence.prototype,"subdivision",{get:function(){return t.Ticks(this._subdivision).toSeconds()}}),t.Sequence.prototype.at=function(e,i){return t.isArray(i)&&this.remove(e),t.Part.prototype.at.call(this,this._indexTime(e),i)},t.Sequence.prototype.add=function(e,i){if(null===i)return this;if(t.isArray(i)){var n=Math.round(this._subdivision/i.length);i=new t.Sequence(this._tick.bind(this),i,t.Ticks(n))}return t.Part.prototype.add.call(this,this._indexTime(e),i),this},t.Sequence.prototype.remove=function(e,i){return t.Part.prototype.remove.call(this,this._indexTime(e),i),this},t.Sequence.prototype._indexTime=function(e){return e instanceof t.TransportTime?e:t.Ticks(e*this._subdivision+this.startOffset).toSeconds()},t.Sequence.prototype.dispose=function(){return t.Part.prototype.dispose.call(this),this},t.Sequence}),t(function(t){return t.PulseOscillator=function(){var e=t.defaults(arguments,["frequency","width"],t.Oscillator);t.Source.call(this,e),this.width=new t.Signal(e.width,t.Type.NormalRange),this._widthGate=new t.Gain,this._sawtooth=new t.Oscillator({frequency:e.frequency,detune:e.detune,type:"sawtooth",phase:e.phase}),this.frequency=this._sawtooth.frequency,this.detune=this._sawtooth.detune,this._thresh=new t.WaveShaper(function(t){return t<0?-1:1}),this._sawtooth.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),this._readOnly(["width","frequency","detune"])},t.extend(t.PulseOscillator,t.Source),t.PulseOscillator.defaults={frequency:440,detune:0,phase:0,width:.2},t.PulseOscillator.prototype._start=function(t){t=this.toSeconds(t),this._sawtooth.start(t),this._widthGate.gain.setValueAtTime(1,t)},t.PulseOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._sawtooth.stop(t),this._widthGate.gain.setValueAtTime(0,t)},t.PulseOscillator.prototype.restart=function(t){this._sawtooth.restart(t)},Object.defineProperty(t.PulseOscillator.prototype,"phase",{get:function(){return this._sawtooth.phase},set:function(t){this._sawtooth.phase=t}}),Object.defineProperty(t.PulseOscillator.prototype,"type",{get:function(){return"pulse"}}),Object.defineProperty(t.PulseOscillator.prototype,"partials",{get:function(){return[]}}),t.PulseOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._sawtooth.dispose(),this._sawtooth=null,this._writable(["width","frequency","detune"]),this.width.dispose(),this.width=null,this._widthGate.dispose(),this._widthGate=null,this._thresh.dispose(),this._thresh=null,this.frequency=null,this.detune=null,this},t.PulseOscillator}),t(function(t){return t.PWMOscillator=function(){var e=t.defaults(arguments,["frequency","modulationFrequency"],t.PWMOscillator);t.Source.call(this,e),this._pulse=new t.PulseOscillator(e.modulationFrequency),this._pulse._sawtooth.type="sine",this._modulator=new t.Oscillator({frequency:e.frequency,detune:e.detune,phase:e.phase}),this._scale=new t.Multiply(2),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this.modulationFrequency=this._pulse.frequency,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),this._readOnly(["modulationFrequency","frequency","detune"])},t.extend(t.PWMOscillator,t.Source),t.PWMOscillator.defaults={frequency:440,detune:0,phase:0,modulationFrequency:.4},t.PWMOscillator.prototype._start=function(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)},t.PWMOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)},t.PWMOscillator.prototype.restart=function(t){this._modulator.restart(t),this._pulse.restart(t)},Object.defineProperty(t.PWMOscillator.prototype,"type",{get:function(){return"pwm"}}),Object.defineProperty(t.PWMOscillator.prototype,"partials",{get:function(){return[]}}),Object.defineProperty(t.PWMOscillator.prototype,"phase",{get:function(){return this._modulator.phase},set:function(t){this._modulator.phase=t}}),t.PWMOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._pulse.dispose(),this._pulse=null,this._scale.dispose(),this._scale=null,this._modulator.dispose(),this._modulator=null,this._writable(["modulationFrequency","frequency","detune"]),this.frequency=null,this.detune=null,this.modulationFrequency=null,this},t.PWMOscillator}),t(function(t){return t.FMOscillator=function(){var e=t.defaults(arguments,["frequency","type","modulationType"],t.FMOscillator);t.Source.call(this,e),this._carrier=new t.Oscillator(e.frequency,e.type),this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=this._carrier.detune,this.detune.value=e.detune,this.modulationIndex=new t.Multiply(e.modulationIndex),this.modulationIndex.units=t.Type.Positive,this._modulator=new t.Oscillator(e.frequency,e.modulationType),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this._modulationNode=new t.Gain(0),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),this.phase=e.phase,this._readOnly(["modulationIndex","frequency","detune","harmonicity"])},t.extend(t.FMOscillator,t.Source),t.FMOscillator.defaults={frequency:440,detune:0,phase:0,modulationIndex:2,modulationType:"square",harmonicity:1},t.FMOscillator.prototype._start=function(t){this._modulator.start(t),this._carrier.start(t)},t.FMOscillator.prototype._stop=function(t){this._modulator.stop(t),this._carrier.stop(t)},t.FMOscillator.prototype.restart=function(t){this._modulator.restart(t),this._carrier.restart(t)},Object.defineProperty(t.FMOscillator.prototype,"type",{get:function(){return this._carrier.type},set:function(t){this._carrier.type=t}}),Object.defineProperty(t.FMOscillator.prototype,"modulationType",{get:function(){return this._modulator.type},set:function(t){this._modulator.type=t}}),Object.defineProperty(t.FMOscillator.prototype,"phase",{get:function(){return this._carrier.phase},set:function(t){this._carrier.phase=t,this._modulator.phase=t}}),Object.defineProperty(t.FMOscillator.prototype,"partials",{get:function(){return this._carrier.partials},set:function(t){this._carrier.partials=t}}),t.FMOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable(["modulationIndex","frequency","detune","harmonicity"]),this.frequency.dispose(),this.frequency=null,this.detune=null,this.harmonicity.dispose(),this.harmonicity=null,this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this._modulationNode.dispose(),this._modulationNode=null,this.modulationIndex.dispose(),this.modulationIndex=null,this},t.FMOscillator}),t(function(t){return t.AMOscillator=function(){var e=t.defaults(arguments,["frequency","type","modulationType"],t.AMOscillator);t.Source.call(this,e),this._carrier=new t.Oscillator(e.frequency,e.type),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this.detune.value=e.detune,this._modulator=new t.Oscillator(e.frequency,e.modulationType),this._modulationScale=new t.AudioToGain,this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this._modulationNode=new t.Gain(0),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.connect(this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),this.phase=e.phase,this._readOnly(["frequency","detune","harmonicity"])},t.extend(t.AMOscillator,t.Oscillator),t.AMOscillator.defaults={frequency:440,detune:0,phase:0,modulationType:"square",harmonicity:1},t.AMOscillator.prototype._start=function(t){this._modulator.start(t),this._carrier.start(t)},t.AMOscillator.prototype._stop=function(t){this._modulator.stop(t),this._carrier.stop(t)},t.AMOscillator.prototype.restart=function(t){this._modulator.restart(t),this._carrier.restart(t)},Object.defineProperty(t.AMOscillator.prototype,"type",{get:function(){return this._carrier.type},set:function(t){this._carrier.type=t}}),Object.defineProperty(t.AMOscillator.prototype,"modulationType",{get:function(){return this._modulator.type},set:function(t){this._modulator.type=t}}),Object.defineProperty(t.AMOscillator.prototype,"phase",{get:function(){return this._carrier.phase},set:function(t){this._carrier.phase=t,this._modulator.phase=t}}),Object.defineProperty(t.AMOscillator.prototype,"partials",{get:function(){return this._carrier.partials},set:function(t){this._carrier.partials=t}}),t.AMOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable(["frequency","detune","harmonicity"]),this.frequency=null,this.detune=null,this.harmonicity.dispose(),this.harmonicity=null,this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this._modulationNode.dispose(),this._modulationNode=null,this._modulationScale.dispose(),this._modulationScale=null,this},t.AMOscillator}),t(function(t){return t.FatOscillator=function(){var e=t.defaults(arguments,["frequency","type","spread"],t.FatOscillator);t.Source.call(this,e),this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this._oscillators=[],this._spread=e.spread,this._type=e.type,this._phase=e.phase,this._partials=t.defaultArg(e.partials,[]),this.count=e.count,this._readOnly(["frequency","detune"])},t.extend(t.FatOscillator,t.Source),t.FatOscillator.defaults={frequency:440,detune:0,phase:0,spread:20,count:3,type:"sawtooth"},t.FatOscillator.prototype._start=function(t){t=this.toSeconds(t),this._forEach(function(e){e.start(t)})},t.FatOscillator.prototype._stop=function(t){t=this.toSeconds(t),this._forEach(function(e){e.stop(t)})},t.FatOscillator.prototype.restart=function(t){t=this.toSeconds(t),this._forEach(function(e){e.restart(t)})},t.FatOscillator.prototype._forEach=function(t){for(var e=0;e<this._oscillators.length;e++)t.call(this,this._oscillators[e],e)},Object.defineProperty(t.FatOscillator.prototype,"type",{get:function(){return this._type},set:function(t){this._type=t,this._forEach(function(e){e.type=t})}}),Object.defineProperty(t.FatOscillator.prototype,"spread",{get:function(){return this._spread},set:function(t){if(this._spread=t,this._oscillators.length>1){var e=-t/2,i=t/(this._oscillators.length-1);this._forEach(function(t,n){t.detune.value=e+i*n})}}}),Object.defineProperty(t.FatOscillator.prototype,"count",{get:function(){return this._oscillators.length},set:function(e){if(e=Math.max(e,1),this._oscillators.length!==e){this._forEach(function(t){t.dispose()}),this._oscillators=[];for(var i=0;i<e;i++){var n=new t.Oscillator;this.type===t.Oscillator.Type.Custom?n.partials=this._partials:n.type=this._type,n.phase=this._phase,n.volume.value=-6-1.1*e,this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.connect(this.output),this._oscillators[i]=n}this.spread=this._spread,this.state===t.State.Started&&this._forEach(function(t){t.start()})}}}),Object.defineProperty(t.FatOscillator.prototype,"phase",{get:function(){return this._phase},set:function(t){this._phase=t,this._forEach(function(e){e.phase=t})}}),Object.defineProperty(t.FatOscillator.prototype,"partials",{get:function(){return this._partials},set:function(e){this._partials=e,this._type=t.Oscillator.Type.Custom,this._forEach(function(t){t.partials=e})}}),t.FatOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable(["frequency","detune"]),this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this._forEach(function(t){t.dispose()}),this._oscillators=null,this._partials=null,this},t.FatOscillator}),t(function(t){t.OmniOscillator=function(){var e=t.defaults(arguments,["frequency","type"],t.OmniOscillator);t.Source.call(this,e),this.frequency=new t.Signal(e.frequency,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this._sourceType=void 0,this._oscillator=null,this.type=e.type,this._readOnly(["frequency","detune"]),this.set(e)},t.extend(t.OmniOscillator,t.Source),t.OmniOscillator.defaults={frequency:440,detune:0,type:"sine",phase:0};var e={Pulse:"PulseOscillator",PWM:"PWMOscillator",Osc:"Oscillator",FM:"FMOscillator",AM:"AMOscillator",Fat:"FatOscillator"};return t.OmniOscillator.prototype._start=function(t){this._oscillator.start(t)},t.OmniOscillator.prototype._stop=function(t){this._oscillator.stop(t)},t.OmniOscillator.prototype.restart=function(t){this._oscillator.restart(t)},Object.defineProperty(t.OmniOscillator.prototype,"type",{get:function(){var t="";return this._sourceType===e.FM?t="fm":this._sourceType===e.AM?t="am":this._sourceType===e.Fat&&(t="fat"),t+this._oscillator.type},set:function(t){"fm"===t.substr(0,2)?(this._createNewOscillator(e.FM),this._oscillator.type=t.substr(2)):"am"===t.substr(0,2)?(this._createNewOscillator(e.AM),this._oscillator.type=t.substr(2)):"fat"===t.substr(0,3)?(this._createNewOscillator(e.Fat),this._oscillator.type=t.substr(3)):"pwm"===t?this._createNewOscillator(e.PWM):"pulse"===t?this._createNewOscillator(e.Pulse):(this._createNewOscillator(e.Osc),this._oscillator.type=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"partials",{get:function(){return this._oscillator.partials},set:function(t){this._oscillator.partials=t}}),t.OmniOscillator.prototype.set=function(e,i){return"type"===e?this.type=i:t.isObject(e)&&e.hasOwnProperty("type")&&(this.type=e.type),t.prototype.set.apply(this,arguments),this},t.OmniOscillator.prototype._createNewOscillator=function(e){if(e!==this._sourceType){this._sourceType=e;var i=t[e],n=this.now();if(null!==this._oscillator){var s=this._oscillator;s.stop(n),this.context.setTimeout(function(){s.dispose(),s=null},this.blockTime)}this._oscillator=new i,this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this.state===t.State.Started&&this._oscillator.start(n)}},Object.defineProperty(t.OmniOscillator.prototype,"phase",{get:function(){return this._oscillator.phase},set:function(t){this._oscillator.phase=t}}),Object.defineProperty(t.OmniOscillator.prototype,"width",{get:function(){if(this._sourceType===e.Pulse)return this._oscillator.width}}),Object.defineProperty(t.OmniOscillator.prototype,"count",{get:function(){if(this._sourceType===e.Fat)return this._oscillator.count},set:function(t){this._sourceType===e.Fat&&(this._oscillator.count=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"spread",{get:function(){if(this._sourceType===e.Fat)return this._oscillator.spread},set:function(t){this._sourceType===e.Fat&&(this._oscillator.spread=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationType",{get:function(){if(this._sourceType===e.FM||this._sourceType===e.AM)return this._oscillator.modulationType},set:function(t){this._sourceType!==e.FM&&this._sourceType!==e.AM||(this._oscillator.modulationType=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationIndex",{get:function(){if(this._sourceType===e.FM)return this._oscillator.modulationIndex}}),Object.defineProperty(t.OmniOscillator.prototype,"harmonicity",{get:function(){if(this._sourceType===e.FM||this._sourceType===e.AM)return this._oscillator.harmonicity}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationFrequency",{get:function(){if(this._sourceType===e.PWM)return this._oscillator.modulationFrequency}}),t.OmniOscillator.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this._writable(["frequency","detune"]),this.detune.dispose(),this.detune=null,this.frequency.dispose(),this.frequency=null,this._oscillator.dispose(),this._oscillator=null,this._sourceType=null,this},t.OmniOscillator}),t(function(t){return t.Instrument=function(e){e=t.defaultArg(e,t.Instrument.defaults),t.AudioNode.call(this),this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly("volume"),this._scheduledEvents=[]},t.extend(t.Instrument,t.AudioNode),t.Instrument.defaults={volume:0},t.Instrument.prototype.triggerAttack=t.noOp,t.Instrument.prototype.triggerRelease=t.noOp,t.Instrument.prototype.sync=function(){return this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0),this},t.Instrument.prototype._syncMethod=function(e,i){var n=this["_original_"+e]=this[e];this[e]=function(){var e=Array.prototype.slice.call(arguments),s=e[i],o=t.Transport.schedule(function(t){e[i]=t,n.apply(this,e)}.bind(this),s);this._scheduledEvents.push(o)}.bind(this)},t.Instrument.prototype.unsync=function(){return this._scheduledEvents.forEach(function(e){t.Transport.clear(e)}),this._scheduledEvents=[],this._original_triggerAttack&&(this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease),this},t.Instrument.prototype.triggerAttackRelease=function(t,e,i,n){return i=this.toSeconds(i),e=this.toSeconds(e),this.triggerAttack(t,i,n),this.triggerRelease(i+e),this},t.Instrument.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._volume.dispose(),this._volume=null,this._writable(["volume"]),this.volume=null,this.unsync(),this._scheduledEvents=null,this},t.Instrument}),t(function(t){return t.Monophonic=function(e){e=t.defaultArg(e,t.Monophonic.defaults),t.Instrument.call(this,e),this.portamento=e.portamento},t.extend(t.Monophonic,t.Instrument),t.Monophonic.defaults={portamento:0},t.Monophonic.prototype.triggerAttack=function(t,e,i){return e=this.toSeconds(e),this._triggerEnvelopeAttack(e,i),this.setNote(t,e),this},t.Monophonic.prototype.triggerRelease=function(t){return t=this.toSeconds(t),this._triggerEnvelopeRelease(t),this},t.Monophonic.prototype._triggerEnvelopeAttack=function(){},t.Monophonic.prototype._triggerEnvelopeRelease=function(){},t.Monophonic.prototype.getLevelAtTime=function(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)},t.Monophonic.prototype.setNote=function(t,e){if(e=this.toSeconds(e),this.portamento>0&&this.getLevelAtTime(e)>.05){var i=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(t,i,e)}else this.frequency.setValueAtTime(t,e);return this},t.Monophonic}),t(function(t){return t.Synth=function(e){e=t.defaultArg(e,t.Synth.defaults),t.Monophonic.call(this,e),this.oscillator=new t.OmniOscillator(e.oscillator),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new t.AmplitudeEnvelope(e.envelope),this.oscillator.chain(this.envelope,this.output),this._readOnly(["oscillator","frequency","detune","envelope"])},t.extend(t.Synth,t.Monophonic),t.Synth.defaults={oscillator:{type:"triangle"},envelope:{attack:.005,decay:.1,sustain:.3,release:1}},t.Synth.prototype._triggerEnvelopeAttack=function(t,e){return this.envelope.triggerAttack(t,e),this.oscillator.start(t),0===this.envelope.sustain&&this.oscillator.stop(t+this.envelope.attack+this.envelope.decay),this},t.Synth.prototype._triggerEnvelopeRelease=function(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this.oscillator.stop(t+this.envelope.release),this},t.Synth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable(["oscillator","frequency","detune","envelope"]),this.oscillator.dispose(),this.oscillator=null,this.envelope.dispose(),this.envelope=null,this.frequency=null,this.detune=null,this},t.Synth}),t(function(t){return t.AMSynth=function(e){e=t.defaultArg(e,t.AMSynth.defaults),t.Monophonic.call(this,e),this._carrier=new t.Synth,this._carrier.volume.value=-10,this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope.set(e.envelope),this._modulator=new t.Synth,this._modulator.volume.value=-10,this.modulation=this._modulator.oscillator.set(e.modulation),this.modulationEnvelope=this._modulator.envelope.set(e.modulationEnvelope),this.frequency=new t.Signal(440,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this._modulationScale=new t.AudioToGain,this._modulationNode=new t.Gain,this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),this._readOnly(["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"])},t.extend(t.AMSynth,t.Monophonic),t.AMSynth.defaults={harmonicity:3,detune:0,oscillator:{type:"sine"},envelope:{attack:.01,decay:.01,sustain:1,release:.5},modulation:{type:"square"},modulationEnvelope:{attack:.5,decay:0,sustain:1,release:.5}},t.AMSynth.prototype._triggerEnvelopeAttack=function(t,e){return t=this.toSeconds(t),this._carrier._triggerEnvelopeAttack(t,e),this._modulator._triggerEnvelopeAttack(t),this},t.AMSynth.prototype._triggerEnvelopeRelease=function(t){return this._carrier._triggerEnvelopeRelease(t),this._modulator._triggerEnvelopeRelease(t),this},t.AMSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable(["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"]),this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this.harmonicity.dispose(),this.harmonicity=null,this._modulationScale.dispose(),this._modulationScale=null,this._modulationNode.dispose(),this._modulationNode=null,this.oscillator=null,this.envelope=null,this.modulationEnvelope=null,this.modulation=null,this},t.AMSynth}),t(function(t){return t.MonoSynth=function(e){e=t.defaultArg(e,t.MonoSynth.defaults),t.Monophonic.call(this,e),this.oscillator=new t.OmniOscillator(e.oscillator),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new t.Filter(e.filter),this.filterEnvelope=new t.FrequencyEnvelope(e.filterEnvelope),this.envelope=new t.AmplitudeEnvelope(e.envelope),this.oscillator.chain(this.filter,this.envelope,this.output),this.filterEnvelope.connect(this.filter.frequency),this._readOnly(["oscillator","frequency","detune","filter","filterEnvelope","envelope"])},t.extend(t.MonoSynth,t.Monophonic),t.MonoSynth.defaults={frequency:"C4",detune:0,oscillator:{type:"square"},filter:{Q:6,type:"lowpass",rolloff:-24},envelope:{attack:.005,decay:.1,sustain:.9,release:1},filterEnvelope:{attack:.06,decay:.2,sustain:.5,release:2,baseFrequency:200,octaves:7,exponent:2}},t.MonoSynth.prototype._triggerEnvelopeAttack=function(t,e){return t=this.toSeconds(t),this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t),this.oscillator.start(t),0===this.envelope.sustain&&this.oscillator.stop(t+this.envelope.attack+this.envelope.decay),this},t.MonoSynth.prototype._triggerEnvelopeRelease=function(t){return this.envelope.triggerRelease(t),this.filterEnvelope.triggerRelease(t),this.oscillator.stop(t+this.envelope.release),this},t.MonoSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable(["oscillator","frequency","detune","filter","filterEnvelope","envelope"]),this.oscillator.dispose(),this.oscillator=null,this.envelope.dispose(),this.envelope=null,this.filterEnvelope.dispose(),this.filterEnvelope=null,this.filter.dispose(),this.filter=null,this.frequency=null,this.detune=null,this},t.MonoSynth}),t(function(t){return t.DuoSynth=function(e){e=t.defaultArg(e,t.DuoSynth.defaults),t.Monophonic.call(this,e),this.voice0=new t.MonoSynth(e.voice0),this.voice0.volume.value=-10,this.voice1=new t.MonoSynth(e.voice1),this.voice1.volume.value=-10,this._vibrato=new t.LFO(e.vibratoRate,-50,50),this._vibrato.start(),this.vibratoRate=this._vibrato.frequency,this._vibratoGain=new t.Gain(e.vibratoAmount,t.Type.Positive),this.vibratoAmount=this._vibratoGain.gain,this.frequency=new t.Signal(440,t.Type.Frequency),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this.frequency.connect(this.voice0.frequency),this.frequency.chain(this.harmonicity,this.voice1.frequency),this._vibrato.connect(this._vibratoGain),this._vibratoGain.fan(this.voice0.detune,this.voice1.detune),this.voice0.connect(this.output),this.voice1.connect(this.output),this._readOnly(["voice0","voice1","frequency","vibratoAmount","vibratoRate"])},t.extend(t.DuoSynth,t.Monophonic),t.DuoSynth.defaults={vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:{volume:-10,portamento:0,oscillator:{type:"sine"},filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}},voice1:{volume:-10,portamento:0,oscillator:{type:"sine"},filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}},t.DuoSynth.prototype._triggerEnvelopeAttack=function(t,e){return t=this.toSeconds(t),this.voice0._triggerEnvelopeAttack(t,e),this.voice1._triggerEnvelopeAttack(t,e),this},t.DuoSynth.prototype._triggerEnvelopeRelease=function(t){return this.voice0._triggerEnvelopeRelease(t),this.voice1._triggerEnvelopeRelease(t),this},t.DuoSynth.prototype.getLevelAtTime=function(t){return(this.voice0.getLevelAtTime(t)+this.voice1.getLevelAtTime(t))/2},t.DuoSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable(["voice0","voice1","frequency","vibratoAmount","vibratoRate"]),this.voice0.dispose(),this.voice0=null,this.voice1.dispose(),this.voice1=null,this.frequency.dispose(),this.frequency=null,this._vibratoGain.dispose(),this._vibratoGain=null,this._vibrato=null,this.harmonicity.dispose(),this.harmonicity=null,this.vibratoAmount.dispose(),this.vibratoAmount=null,this.vibratoRate=null,this},t.DuoSynth}),t(function(t){return t.FMSynth=function(e){e=t.defaultArg(e,t.FMSynth.defaults),t.Monophonic.call(this,e),this._carrier=new t.Synth(e.carrier),this._carrier.volume.value=-10,this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope.set(e.envelope),this._modulator=new t.Synth(e.modulator),this._modulator.volume.value=-10,this.modulation=this._modulator.oscillator.set(e.modulation),this.modulationEnvelope=this._modulator.envelope.set(e.modulationEnvelope),this.frequency=new t.Signal(440,t.Type.Frequency),this.detune=new t.Signal(e.detune,t.Type.Cents),this.harmonicity=new t.Multiply(e.harmonicity),this.harmonicity.units=t.Type.Positive,this.modulationIndex=new t.Multiply(e.modulationIndex),this.modulationIndex.units=t.Type.Positive,this._modulationNode=new t.Gain(0),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this._readOnly(["frequency","harmonicity","modulationIndex","oscillator","envelope","modulation","modulationEnvelope","detune"])},t.extend(t.FMSynth,t.Monophonic),t.FMSynth.defaults={harmonicity:3,modulationIndex:10,detune:0,oscillator:{type:"sine"},envelope:{attack:.01,decay:.01,sustain:1,release:.5},modulation:{type:"square"},modulationEnvelope:{attack:.5,decay:0,sustain:1,release:.5}},t.FMSynth.prototype._triggerEnvelopeAttack=function(t,e){return t=this.toSeconds(t),this._carrier._triggerEnvelopeAttack(t,e),this._modulator._triggerEnvelopeAttack(t),this},t.FMSynth.prototype._triggerEnvelopeRelease=function(t){return t=this.toSeconds(t),this._carrier._triggerEnvelopeRelease(t),this._modulator._triggerEnvelopeRelease(t),this},t.FMSynth.prototype.dispose=function(){return t.Monophonic.prototype.dispose.call(this),this._writable(["frequency","harmonicity","modulationIndex","oscillator","envelope","modulation","modulationEnvelope","detune"]),this._carrier.dispose(),this._carrier=null,this._modulator.dispose(),this._modulator=null,this.frequency.dispose(),this.frequency=null,this.detune.dispose(),this.detune=null,this.modulationIndex.dispose(),this.modulationIndex=null,this.harmonicity.dispose(),this.harmonicity=null,this._modulationNode.dispose(),this._modulationNode=null,this.oscillator=null,this.envelope=null,this.modulationEnvelope=null,this.modulation=null,this},t.FMSynth}),t(function(t){return t.MembraneSynth=function(e){e=t.defaultArg(e,t.MembraneSynth.defaults),t.Instrument.call(this,e),this.oscillator=new t.OmniOscillator(e.oscillator),this.envelope=new t.AmplitudeEnvelope(e.envelope),this.octaves=e.octaves,this.pitchDecay=e.pitchDecay,this.oscillator.chain(this.envelope,this.output),this._readOnly(["oscillator","envelope"])},t.extend(t.MembraneSynth,t.Instrument),t.MembraneSynth.defaults={pitchDecay:.05,octaves:10,oscillator:{type:"sine"},envelope:{attack:.001,decay:.4,sustain:.01,release:1.4,attackCurve:"exponential"}},t.MembraneSynth.prototype.triggerAttack=function(t,e,i){e=this.toSeconds(e),t=this.toFrequency(t);var n=t*this.octaves;return this.oscillator.frequency.setValueAtTime(n,e),this.oscillator.frequency.exponentialRampToValueAtTime(t,e+this.toSeconds(this.pitchDecay)),this.envelope.triggerAttack(e,i),this.oscillator.start(e),this},t.MembraneSynth.prototype.triggerRelease=function(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this.oscillator.stop(t+this.envelope.release),this},t.MembraneSynth.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._writable(["oscillator","envelope"]),this.oscillator.dispose(),this.oscillator=null,this.envelope.dispose(),this.envelope=null,this},t.MembraneSynth}),t(function(t){var e=[1,1.483,1.932,2.546,2.63,3.897];return t.MetalSynth=function(i){i=t.defaultArg(i,t.MetalSynth.defaults),t.Instrument.call(this,i),this.frequency=new t.Signal(i.frequency,t.Type.Frequency),this._oscillators=[],this._freqMultipliers=[],this._amplitue=new t.Gain(0).connect(this.output),this._highpass=new t.Filter({type:"highpass",Q:-3.0102999566398125}).connect(this._amplitue),this._octaves=i.octaves,this._filterFreqScaler=new t.Scale(i.resonance,7e3),this.envelope=new t.Envelope({attack:i.envelope.attack,attackCurve:"linear",decay:i.envelope.decay,sustain:0,release:i.envelope.release}).chain(this._filterFreqScaler,this._highpass.frequency),this.envelope.connect(this._amplitue.gain);for(var n=0;n<e.length;n++){var s=new t.FMOscillator({type:"square",modulationType:"square",harmonicity:i.harmonicity,modulationIndex:i.modulationIndex});s.connect(this._highpass),this._oscillators[n]=s;var o=new t.Multiply(e[n]);this._freqMultipliers[n]=o,this.frequency.chain(o,s.frequency)}this.octaves=i.octaves},t.extend(t.MetalSynth,t.Instrument),t.MetalSynth.defaults={frequency:200,envelope:{attack:.001,decay:1.4,release:.2},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5},t.MetalSynth.prototype.triggerAttack=function(e,i){return e=this.toSeconds(e),i=t.defaultArg(i,1),this.envelope.triggerAttack(e,i),this._oscillators.forEach(function(t){t.start(e)}),0===this.envelope.sustain&&this._oscillators.forEach(function(t){t.stop(e+this.envelope.attack+this.envelope.decay)}.bind(this)),this},t.MetalSynth.prototype.triggerRelease=function(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this._oscillators.forEach(function(e){e.stop(t+this.envelope.release)}.bind(this)),this},t.MetalSynth.prototype.sync=function(){return this._syncMethod("triggerAttack",0),this._syncMethod("triggerRelease",0),this},t.MetalSynth.prototype.triggerAttackRelease=function(t,e,i){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,i),this.triggerRelease(e+t),this},Object.defineProperty(t.MetalSynth.prototype,"modulationIndex",{get:function(){return this._oscillators[0].modulationIndex.value},set:function(t){for(var e=0;e<this._oscillators.length;e++)this._oscillators[e].modulationIndex.value=t}}),Object.defineProperty(t.MetalSynth.prototype,"harmonicity",{get:function(){return this._oscillators[0].harmonicity.value},set:function(t){for(var e=0;e<this._oscillators.length;e++)this._oscillators[e].harmonicity.value=t}}),Object.defineProperty(t.MetalSynth.prototype,"resonance",{get:function(){return this._filterFreqScaler.min},set:function(t){this._filterFreqScaler.min=t,this.octaves=this._octaves}}),Object.defineProperty(t.MetalSynth.prototype,"octaves",{get:function(){return this._octaves},set:function(t){this._octaves=t,this._filterFreqScaler.max=this._filterFreqScaler.min*Math.pow(2,t)}}),t.MetalSynth.prototype.dispose=function(){t.Instrument.prototype.dispose.call(this);for(var e=0;e<this._oscillators.length;e++)this._oscillators[e].dispose(),this._freqMultipliers[e].dispose();this._oscillators=null,this._freqMultipliers=null,this.frequency.dispose(),this.frequency=null,this._filterFreqScaler.dispose(),this._filterFreqScaler=null,this._amplitue.dispose(),this._amplitue=null,this.envelope.dispose(),this.envelope=null,this._highpass.dispose(),this._highpass=null},t.MetalSynth}),t(function(t){return t.NoiseSynth=function(e){e=t.defaultArg(e,t.NoiseSynth.defaults),t.Instrument.call(this,e),this.noise=new t.Noise,this.envelope=new t.AmplitudeEnvelope(e.envelope),this.noise.chain(this.envelope,this.output),this._readOnly(["noise","envelope"])},t.extend(t.NoiseSynth,t.Instrument),t.NoiseSynth.defaults={noise:{type:"white"},envelope:{attack:.005,decay:.1,sustain:0}},t.NoiseSynth.prototype.triggerAttack=function(t,e){return this.envelope.triggerAttack(t,e),this.noise.start(t),0===this.envelope.sustain&&this.noise.stop(t=this.envelope.attack+this.envelope.decay),this},t.NoiseSynth.prototype.triggerRelease=function(t){return this.envelope.triggerRelease(t),this.noise.stop(t+this.envelope.release),this},t.NoiseSynth.prototype.sync=function(){return this._syncMethod("triggerAttack",0),this._syncMethod("triggerRelease",0),this},t.NoiseSynth.prototype.triggerAttackRelease=function(t,e,i){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,i),this.triggerRelease(e+t),this},t.NoiseSynth.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._writable(["noise","envelope"]),this.noise.dispose(),this.noise=null,this.envelope.dispose(),this.envelope=null,this},t.NoiseSynth}),t(function(t){return t.PluckSynth=function(e){e=t.defaultArg(e,t.PluckSynth.defaults),t.Instrument.call(this,e),this._noise=new t.Noise("pink"),this.attackNoise=e.attackNoise,this._lfcf=new t.LowpassCombFilter({resonance:e.resonance,dampening:e.dampening}),this.resonance=this._lfcf.resonance,this.dampening=this._lfcf.dampening,this._noise.connect(this._lfcf),this._lfcf.connect(this.output),this._readOnly(["resonance","dampening"])},t.extend(t.PluckSynth,t.Instrument),t.PluckSynth.defaults={attackNoise:1,dampening:4e3,resonance:.7},t.PluckSynth.prototype.triggerAttack=function(t,e){t=this.toFrequency(t),e=this.toSeconds(e);var i=1/t;return this._lfcf.delayTime.setValueAtTime(i,e),this._noise.start(e),this._noise.stop(e+i*this.attackNoise),this},t.PluckSynth.prototype.dispose=function(){return t.Instrument.prototype.dispose.call(this),this._noise.dispose(),this._lfcf.dispose(),this._noise=null,this._lfcf=null,this._writable(["resonance","dampening"]),this.dampening=null,this.resonance=null,this},t.PluckSynth}),t(function(t){return t.PolySynth=function(){var e=t.defaults(arguments,["polyphony","voice"],t.PolySynth);t.Instrument.call(this,e),e=t.defaultArg(e,t.Instrument.defaults),e.polyphony=Math.min(t.PolySynth.MAX_POLYPHONY,e.polyphony),this.voices=new Array(e.polyphony),this._triggers=new Array(e.polyphony),this.detune=new t.Signal(e.detune,t.Type.Cents),this._readOnly("detune");for(var i=0;i<e.polyphony;i++){var n=new e.voice(arguments[2],arguments[3]);if(!(n instanceof t.Monophonic))throw new Error("Synth constructor must be instance of Tone.Monophonic");this.voices[i]=n,n.connect(this.output),n.hasOwnProperty("detune")&&this.detune.connect(n.detune),this._triggers[i]={release:-1,note:null,voice:n}}},t.extend(t.PolySynth,t.Instrument),t.PolySynth.defaults={polyphony:4,volume:0,detune:0,voice:t.Synth},t.PolySynth.prototype.triggerAttack=function(t,e,i){Array.isArray(t)||(t=[t]),e=this.toSeconds(e);for(var n=0;n<t.length;n++){for(var s=t[n],o=this._triggers[0],r=1;r<this._triggers.length;r++)this._triggers[r].release<o.release&&(o=this._triggers[r]);o.release=1/0,o.note=JSON.stringify(s),o.voice.triggerAttack(s,e,i)}return this},t.PolySynth.prototype.triggerAttackRelease=function(e,i,n,s){if(n=this.toSeconds(n),this.triggerAttack(e,n,s),t.isArray(i)&&t.isArray(e))for(var o=0;o<e.length;o++){var r=i[Math.min(o,i.length-1)];this.triggerRelease(e[o],n+this.toSeconds(r))}else this.triggerRelease(e,n+this.toSeconds(i));return this},t.PolySynth.prototype.triggerRelease=function(t,e){Array.isArray(t)||(t=[t]),e=this.toSeconds(e);for(var i=0;i<t.length;i++)for(var n=JSON.stringify(t[i]),s=0;s<this._triggers.length;s++){var o=this._triggers[s];o.note===n&&o.release>e&&(o.voice.triggerRelease(e),o.release=e)}return this},t.PolySynth.prototype.sync=function(){return this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1),this},t.PolySynth.prototype.set=function(t,e,i){for(var n=0;n<this.voices.length;n++)this.voices[n].set(t,e,i);return this},t.PolySynth.prototype.get=function(t){return this.voices[0].get(t)},t.PolySynth.prototype.releaseAll=function(t){t=this.toSeconds(t);for(var e=0;e<this._triggers.length;e++){var i=this._triggers[e];i.release>t&&(i.release=t,i.voice.triggerRelease(t))}return this},t.PolySynth.prototype.dispose=function(){t.Instrument.prototype.dispose.call(this);for(var e=0;e<this.voices.length;e++)this.voices[e].dispose(),this.voices[e]=null;return this._writable("detune"),this.detune.dispose(),this.detune=null,this.voices=null,this._triggers=null,this},t.PolySynth.MAX_POLYPHONY=20,t.PolySynth}),t(function(t){return t.Sampler=function(e){var i=Array.prototype.slice.call(arguments);i.shift();var n=t.defaults(i,["onload","baseUrl"],t.Sampler);t.Instrument.call(this,n);var s={};for(var o in e)if(t.isNote(o)){var r=t.Frequency(o).toMidi();s[r]=e[o]}else{if(isNaN(parseFloat(o)))throw new Error("Tone.Sampler: url keys must be the note's pitch");s[o]=e[o]}this._buffers=new t.Buffers(s,n.onload,n.baseUrl),this._activeSources={},this.attack=n.attack,this.release=n.release},t.extend(t.Sampler,t.Instrument),t.Sampler.defaults={attack:0,release:.1,onload:t.noOp,baseUrl:""},t.Sampler.prototype._findClosest=function(t){for(var e=0;e<96;){if(this._buffers.has(t+e))return-e;if(this._buffers.has(t-e))return e;e++}return null},t.Sampler.prototype.triggerAttack=function(e,i,n){var s=t.Frequency(e).toMidi(),o=this._findClosest(s);if(null!==o){var r=s-o,a=this._buffers.get(r),h=new t.BufferSource({buffer:a,playbackRate:t.intervalToFrequencyRatio(o),fadeIn:this.attack,fadeOut:this.release,curve:"exponential"}).connect(this.output);h.start(i,0,a.duration,n),t.isArray(this._activeSources[s])||(this._activeSources[s]=[]),this._activeSources[s].push({note:s,source:h})}return this},t.Sampler.prototype.triggerRelease=function(e,i){var n=t.Frequency(e).toMidi();if(this._activeSources[n]&&this._activeSources[n].length){var s=this._activeSources[n].shift().source;i=this.toSeconds(i),s.stop(i+this.release,this.release)}return this},t.Sampler.prototype.releaseAll=function(t){t=this.toSeconds(t);for(var e in this._activeSources)for(var i=this._activeSources[e];i.length;){var n=i.shift().source;n.stop(t+this.release,this.release)}return this},t.Sampler.prototype.sync=function(){return this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1),this},t.Sampler.prototype.triggerAttackRelease=function(t,e,i,n){return i=this.toSeconds(i),e=this.toSeconds(e),this.triggerAttack(t,i,n),this.triggerRelease(t,i+e),this},t.Sampler.prototype.add=function(e,i,n){if(t.isNote(e)){var s=t.Frequency(e).toMidi();this._buffers.add(s,i,n)}else{if(isNaN(parseFloat(e)))throw new Error("Tone.Sampler: note must be the note's pitch. Instead got "+e);this._buffers.add(e,i,n)}},Object.defineProperty(t.Sampler.prototype,"loaded",{get:function(){return this._buffers.loaded}}),t.Sampler.prototype.dispose=function(){t.Instrument.prototype.dispose.call(this),this._buffers.dispose(),this._buffers=null;for(var e in this._activeSources)this._activeSources[e].forEach(function(t){t.source.dispose()});return this._activeSources=null,this},t.Sampler}),t(function(t){t.supported&&(OscillatorNode.prototype.setPeriodicWave||(OscillatorNode.prototype.setPeriodicWave=OscillatorNode.prototype.setWaveTable),AudioContext.prototype.createPeriodicWave||(AudioContext.prototype.createPeriodicWave=AudioContext.prototype.createWaveTable))}),t(function(t){return t.GainToAudio=function(){t.SignalBase.call(this),this._norm=this.input=this.output=new t.WaveShaper(function(t){return 2*Math.abs(t)-1})},t.extend(t.GainToAudio,t.SignalBase),t.GainToAudio.prototype.dispose=function(){return t.SignalBase.prototype.dispose.call(this),this._norm.dispose(),this._norm=null,this},t.GainToAudio}),t(function(t){return t.Normalize=function(e,i){t.SignalBase.call(this),this._inputMin=t.defaultArg(e,0),this._inputMax=t.defaultArg(i,1),this._sub=this.input=new t.Add(0),this._div=this.output=new t.Multiply(1),this._sub.connect(this._div),this._setRange()},t.extend(t.Normalize,t.SignalBase),Object.defineProperty(t.Normalize.prototype,"min",{get:function(){return this._inputMin},set:function(t){this._inputMin=t,this._setRange()}}),Object.defineProperty(t.Normalize.prototype,"max",{get:function(){return this._inputMax},set:function(t){this._inputMax=t,this._setRange()}}),t.Normalize.prototype._setRange=function(){this._sub.value=-this._inputMin,this._div.value=1/(this._inputMax-this._inputMin)},t.Normalize.prototype.dispose=function(){return t.SignalBase.prototype.dispose.call(this),this._sub.dispose(),this._sub=null,this._div.dispose(),this._div=null,this},t.Normalize}),t(function(t){return t.TransportTimelineSignal=function(){t.Signal.apply(this,arguments),this.output=this._outputSig=new t.Signal(this._initialValue),this._lastVal=this.value,this._synced=t.Transport.scheduleRepeat(this._onTick.bind(this),"1i"),this._bindAnchorValue=this._anchorValue.bind(this),t.Transport.on("start stop pause",this._bindAnchorValue),this._events.memory=1/0},t.extend(t.TransportTimelineSignal,t.Signal),t.TransportTimelineSignal.prototype._onTick=function(e){var i=this.getValueAtTime(t.Transport.seconds);this._lastVal!==i&&(this._lastVal=i,this._outputSig.linearRampToValueAtTime(i,e))},t.TransportTimelineSignal.prototype._anchorValue=function(e){var i=this.getValueAtTime(t.Transport.seconds);return this._lastVal=i,this._outputSig.cancelScheduledValues(e),this._outputSig.setValueAtTime(i,e),this},t.TransportTimelineSignal.prototype.getValueAtTime=function(e){return e=t.TransportTime(e),t.Signal.prototype.getValueAtTime.call(this,e)},t.TransportTimelineSignal.prototype.setValueAtTime=function(e,i){return i=t.TransportTime(i),t.Signal.prototype.setValueAtTime.call(this,e,i),this},t.TransportTimelineSignal.prototype.linearRampToValueAtTime=function(e,i){return i=t.TransportTime(i),t.Signal.prototype.linearRampToValueAtTime.call(this,e,i),this},t.TransportTimelineSignal.prototype.exponentialRampToValueAtTime=function(e,i){return i=t.TransportTime(i),t.Signal.prototype.exponentialRampToValueAtTime.call(this,e,i),this},t.TransportTimelineSignal.prototype.setTargetAtTime=function(e,i,n){return i=t.TransportTime(i),t.Signal.prototype.setTargetAtTime.call(this,e,i,n),this},t.TransportTimelineSignal.prototype.cancelScheduledValues=function(e){return e=t.TransportTime(e),t.Signal.prototype.cancelScheduledValues.call(this,e),this},t.TransportTimelineSignal.prototype.setValueCurveAtTime=function(e,i,n,s){return i=t.TransportTime(i),n=t.TransportTime(n),t.Signal.prototype.setValueCurveAtTime.call(this,e,i,n,s),this},t.TransportTimelineSignal.prototype.cancelAndHoldAtTime=function(e){return t.Signal.prototype.cancelAndHoldAtTime.call(this,t.TransportTime(e))},t.TransportTimelineSignal.prototype.dispose=function(){t.Transport.clear(this._synced),t.Transport.off("start stop pause",this._syncedCallback),this._events.cancel(0),t.Signal.prototype.dispose.call(this),this._outputSig.dispose(),this._outputSig=null},t.TransportTimelineSignal}),t(function(t){return t.GrainPlayer=function(){var e=t.defaults(arguments,["url","onload"],t.GrainPlayer);t.Source.call(this,e),this.buffer=new t.Buffer(e.url,e.onload),this._clock=new t.Clock(this._tick.bind(this),e.grainSize),this._loopStart=0,this._loopEnd=0,this._activeSources=[],this._playbackRate=e.playbackRate,this._grainSize=e.grainSize,this._overlap=e.overlap,this.detune=e.detune,this.overlap=e.overlap,this.loop=e.loop,this.playbackRate=e.playbackRate,this.grainSize=e.grainSize,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.reverse=e.reverse,this._clock.on("stop",this._onstop.bind(this))},t.extend(t.GrainPlayer,t.Source),t.GrainPlayer.defaults={onload:t.noOp,overlap:.1,grainSize:.2,playbackRate:1,detune:0,loop:!1,loopStart:0,loopEnd:0,reverse:!1},t.GrainPlayer.prototype._start=function(e,i,n){i=t.defaultArg(i,0),i=this.toSeconds(i),e=this.toSeconds(e),this._offset=i,this._clock.start(e),n&&this.stop(e+this.toSeconds(n))},t.GrainPlayer.prototype._stop=function(t){this._clock.stop(t)},t.GrainPlayer.prototype._onstop=function(t){this._activeSources.forEach(function(e){e.stop(t,0)})},t.GrainPlayer.prototype._tick=function(e){var i=this._offset<this._overlap?0:this._overlap,n=new t.BufferSource({buffer:this.buffer,fadeIn:i,fadeOut:this._overlap,loop:this.loop,loopStart:this._loopStart,loopEnd:this._loopEnd,playbackRate:t.intervalToFrequencyRatio(this.detune/100)}).connect(this.output);n.start(e,this._offset),this._offset+=this.grainSize,n.stop(e+this.grainSize),this._activeSources.push(n),n.onended=function(){var t=this._activeSources.indexOf(n);-1!==t&&this._activeSources.splice(t,1)}.bind(this)},t.GrainPlayer.prototype.seek=function(t,e){return this._offset=this.toSeconds(t),this._tick(this.toSeconds(e)),this},Object.defineProperty(t.GrainPlayer.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this.grainSize=this._grainSize}}),Object.defineProperty(t.GrainPlayer.prototype,"loopStart",{get:function(){return this._loopStart},set:function(t){this._loopStart=this.toSeconds(t)}}),Object.defineProperty(t.GrainPlayer.prototype,"loopEnd",{get:function(){return this._loopEnd},set:function(t){this._loopEnd=this.toSeconds(t)}}),Object.defineProperty(t.GrainPlayer.prototype,"reverse",{get:function(){return this.buffer.reverse},set:function(t){this.buffer.reverse=t}}),Object.defineProperty(t.GrainPlayer.prototype,"grainSize",{get:function(){return this._grainSize},set:function(t){this._grainSize=this.toSeconds(t),this._clock.frequency.value=this._playbackRate/this._grainSize}}),Object.defineProperty(t.GrainPlayer.prototype,"overlap",{get:function(){return this._overlap},set:function(t){this._overlap=this.toSeconds(t)}}),t.GrainPlayer.prototype.dispose=function(){return t.Source.prototype.dispose.call(this),this.buffer.dispose(),this.buffer=null,this._clock.dispose(),this._clock=null,this._activeSources.forEach(function(t){t.dispose()}),this._activeSources=null,this},t.GrainPlayer}),t(function(t){return t.Player=function(e){var i;e instanceof t.Buffer&&e.loaded?(e=e.get(),i=t.Player.defaults):i=t.defaults(arguments,["url","onload"],t.Player),t.Source.call(this,i),this.autostart=i.autostart,this._buffer=new t.Buffer({url:i.url,onload:this._onload.bind(this,i.onload),reverse:i.reverse}),e instanceof AudioBuffer&&this._buffer.set(e),this._loop=i.loop,this._loopStart=i.loopStart,this._loopEnd=i.loopEnd,this._playbackRate=i.playbackRate,this._activeSources=[],this._elapsedTime=new t.TickSource(i.playbackRate),this.fadeIn=i.fadeIn,this.fadeOut=i.fadeOut},t.extend(t.Player,t.Source),t.Player.defaults={onload:t.noOp,playbackRate:1,loop:!1,autostart:!1,loopStart:0,loopEnd:0,retrigger:!1,reverse:!1,fadeIn:0,fadeOut:0},t.Player.prototype.load=function(t,e){return this._buffer.load(t,this._onload.bind(this,e))},t.Player.prototype._onload=function(e){e=t.defaultArg(e,t.noOp),e(this),this.autostart&&this.start()},t.Player.prototype._onSourceEnd=function(t){var e=this._activeSources.indexOf(t);this._activeSources.splice(e,1)},t.Player.prototype._start=function(e,i,n){i=this._loop?t.defaultArg(i,this._loopStart):t.defaultArg(i,0),i=this.toSeconds(i);var s=t.defaultArg(n,Math.max(this._buffer.duration-i,0));s=this.toSeconds(s),e=this.toSeconds(e),this._elapsedTime.start(e,i);var o=new t.BufferSource({buffer:this._buffer,loop:this._loop,loopStart:this._loopStart,loopEnd:this._loopEnd,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate,fadeIn:this.fadeIn,fadeOut:this.fadeOut}).connect(this.output);return this._loop||this._synced||this._state.setStateAtTime(t.State.Stopped,e+s/this._playbackRate),this._activeSources.push(o),this._loop&&t.isUndef(n)?o.start(e,i):o.start(e,i,s),this},t.Player.prototype._stop=function(t){return t=this.toSeconds(t),this._elapsedTime.stop(t),this._activeSources.forEach(function(e){e.stop(t)}),this},t.Player.prototype.restart=function(t,e,i){return this._stop(t),this._start(t,e,i),this},t.Player.prototype.seek=function(e,i){return i=this.toSeconds(i),this._state.getValueAtTime(i)===t.State.Started&&(e=this.toSeconds(e),this._stop(i),this._start(i,e)),this},t.Player.prototype.setLoopPoints=function(t,e){return this.loopStart=t,this.loopEnd=e,this},Object.defineProperty(t.Player.prototype,"loopStart",{get:function(){return this._loopStart},set:function(t){this._loopStart=t,this._activeSources.forEach(function(e){e.loopStart=t})}}),Object.defineProperty(t.Player.prototype,"loopEnd",{get:function(){return this._loopEnd},set:function(t){this._loopEnd=t,this._activeSources.forEach(function(e){e.loopEnd=t})}}),Object.defineProperty(t.Player.prototype,"buffer",{get:function(){return this._buffer},set:function(t){this._buffer.set(t)}}),Object.defineProperty(t.Player.prototype,"loop",{get:function(){return this._loop},set:function(e){if(this._loop!==e){this._loop=e;var i=this.now();if(e){var n=this._state.getNextState(t.State.Stopped,i);n&&(this._activeSources.forEach(function(t){t.loop=e}),this._state.cancel(n.time),this._elapsedTime.cancel(n.time))}else this._stopAtNextIteration(i)}}}),t.Player.prototype._stopAtNextIteration=function(e){if(this._state.getValueAtTime(e)===t.State.Started){var i=this._state.getNextState(t.State.Stopped,e),n=this._elapsedTime.getTicksAtTime(e),s=Math.max(Math.ceil(n/this.buffer.duration),1),o=this._elapsedTime.getTimeOfTick(s*this.buffer.duration,i?i.time-this.sampleTime:1/0);this.stop(o)}},Object.defineProperty(t.Player.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t;var e=this.now();this._elapsedTime.frequency.setValueAtTime(t,e),this._loop||this._stopAtNextIteration(e),this._activeSources.forEach(function(i){i.playbackRate.setValueAtTime(t,e)})}}),Object.defineProperty(t.Player.prototype,"position",{get:function(){var e=this.now();if(this._state.getValueAtTime(e)===t.State.Started&&this.loaded){var i=this.buffer.duration;return this._elapsedTime.getTicksAtTime(e)%i}return 0}}),Object.defineProperty(t.Player.prototype,"reverse",{get:function(){return this._buffer.reverse},set:function(t){this._buffer.reverse=t}}),Object.defineProperty(t.Player.prototype,"loaded",{get:function(){return this._buffer.loaded}}),t.Player.prototype.dispose=function(){return this._activeSources.forEach(function(t){t.dispose()}),this._activeSources=null,t.Source.prototype.dispose.call(this),this._buffer.dispose(),this._buffer=null,this._elapsedTime.dispose(),this._elapsedTime=null,this},t.Player}),t(function(t){return t.Players=function(e){var i=Array.prototype.slice.call(arguments);i.shift();var n=t.defaults(i,["onload"],t.Players);t.call(this),this._volume=this.output=new t.Volume(n.volume),this.volume=this._volume.volume,this._readOnly("volume"),this._volume.output.output.channelCount=2,this._volume.output.output.channelCountMode="explicit",this.mute=n.mute,this._players={},this._loadingCount=0,this._fadeIn=n.fadeIn,this._fadeOut=n.fadeOut;for(var s in e)this._loadingCount++,this.add(s,e[s],this._bufferLoaded.bind(this,n.onload))},t.extend(t.Players,t.AudioNode),t.Players.defaults={volume:0,mute:!1,onload:t.noOp,fadeIn:0,fadeOut:0},t.Players.prototype._bufferLoaded=function(t){0===--this._loadingCount&&t&&t(this)},Object.defineProperty(t.Players.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),Object.defineProperty(t.Players.prototype,"fadeIn",{get:function(){return this._fadeIn},set:function(t){this._fadeIn=t,this._forEach(function(e){e.fadeIn=t})}}),Object.defineProperty(t.Players.prototype,"fadeOut",{get:function(){return this._fadeOut},set:function(t){this._fadeOut=t,this._forEach(function(e){e.fadeOut=t})}}),Object.defineProperty(t.Players.prototype,"state",{get:function(){var e=!1;return this._forEach(function(i){e=e||i.state===t.State.Started}),e?t.State.Started:t.State.Stopped}}),t.Players.prototype.has=function(t){return this._players.hasOwnProperty(t)},t.Players.prototype.get=function(t){if(this.has(t))return this._players[t];throw new Error("Tone.Players: no player named "+t)},t.Players.prototype._forEach=function(t){for(var e in this._players)t(this._players[e],e);return this},Object.defineProperty(t.Players.prototype,"loaded",{get:function(){var t=!0;return this._forEach(function(e){t=t&&e.loaded}),t}}),t.Players.prototype.add=function(e,i,n){return this._players[e]=new t.Player(i,n).connect(this.output),this._players[e].fadeIn=this._fadeIn,this._players[e].fadeOut=this._fadeOut,this},t.Players.prototype.stopAll=function(t){this._forEach(function(e){e.stop(t)})},t.Players.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this._volume.dispose(),this._volume=null,this._writable("volume"),this.volume=null,this.output=null,this._forEach(function(t){t.dispose()}),this._players=null,this},t.Players}),t(function(t){return t.UserMedia=function(){var e=t.defaults(arguments,["volume"],t.UserMedia);t.AudioNode.call(this),this._mediaStream=null,this._stream=null,this._device=null,this._volume=this.output=new t.Volume(e.volume),this.volume=this._volume.volume,this._readOnly("volume"),this.mute=e.mute},t.extend(t.UserMedia,t.AudioNode),t.UserMedia.defaults={volume:0,mute:!1},t.UserMedia.prototype.open=function(e){return t.UserMedia.enumerateDevices().then(function(i){var n;if(t.isNumber(e))n=i[e];else if(!(n=i.find(function(t){return t.label===e||t.deviceId===e}))&&i.length>0)n=i[0];else if(!n&&t.isDefined(e))throw new Error("Tone.UserMedia: no matching device: "+e);this._device=n;var s={audio:{echoCancellation:!1,sampleRate:this.context.sampleRate}};return n&&(s.audio.deviceId=n.deviceId),navigator.mediaDevices.getUserMedia(s).then(function(t){return this._stream||(this._stream=t,this._mediaStream=this.context.createMediaStreamSource(t),this._mediaStream.connect(this.output)),this}.bind(this))}.bind(this))},t.UserMedia.prototype.close=function(){return this._stream&&(this._stream.getAudioTracks().forEach(function(t){t.stop()}),this._stream=null,this._mediaStream.disconnect(),this._mediaStream=null),this._device=null,this},t.UserMedia.enumerateDevices=function(){return navigator.mediaDevices.enumerateDevices().then(function(t){return t.filter(function(t){return"audioinput"===t.kind})})},Object.defineProperty(t.UserMedia.prototype,"state",{get:function(){return this._stream&&this._stream.active?t.State.Started:t.State.Stopped}}),Object.defineProperty(t.UserMedia.prototype,"deviceId",{get:function(){if(this._device)return this._device.deviceId}}),Object.defineProperty(t.UserMedia.prototype,"groupId",{get:function(){if(this._device)return this._device.groupId}}),Object.defineProperty(t.UserMedia.prototype,"label",{get:function(){if(this._device)return this._device.label}}),Object.defineProperty(t.UserMedia.prototype,"mute",{get:function(){return this._volume.mute},set:function(t){this._volume.mute=t}}),t.UserMedia.prototype.dispose=function(){return t.AudioNode.prototype.dispose.call(this),this.close(),this._writable("volume"),this._volume.dispose(),this._volume=null,this.volume=null,this},Object.defineProperty(t.UserMedia,"supported",{get:function(){return t.isDefined(navigator.mediaDevices)&&t.isFunction(navigator.mediaDevices.getUserMedia)}}),t.UserMedia}),t(function(t){return t.Midi=function(e,i){if(!(this instanceof t.Midi))return new t.Midi(e,i);t.Frequency.call(this,e,i)},t.extend(t.Midi,t.Frequency),t.Midi.prototype._defaultUnits="midi",t.Midi.prototype._frequencyToUnits=function(e){return t.Frequency.ftom(t.Frequency.prototype._frequencyToUnits.call(this,e))},t.Midi.prototype._ticksToUnits=function(e){return t.Frequency.ftom(t.Frequency.prototype._ticksToUnits.call(this,e))},t.Midi.prototype._beatsToUnits=function(e){return t.Frequency.ftom(t.Frequency.prototype._beatsToUnits.call(this,e))},t.Midi.prototype._secondsToUnits=function(e){return t.Frequency.ftom(t.Frequency.prototype._secondsToUnits.call(this,e))},t.Midi.prototype.toMidi=function(){return this.valueOf()},t.Midi.prototype.toFrequency=function(){return t.Frequency.mtof(this.toMidi())},t.Midi.prototype.transpose=function(t){return new this.constructor(this.toMidi()+t)},t.Midi}),e})},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function s(t){return t[Math.floor(Math.random()*t.length)]}function o(t,e){return t-e*Math.floor(t/e)}function r(t){if(_){var e=document.createElement("div"),i=document.createElement("div");i.innerHTML="Tap to start - please unmute your phone",Object.assign(e.style,{position:"absolute",width:"100%",height:"100%",zIndex:"10000",top:"0px",left:"0px",backgroundColor:"rgba(0, 0, 0, 0.8)"}),Object.assign(i.style,{position:"absolute",left:"50%",top:"50%",padding:"20px",backgroundColor:"#7F33ED",color:"white",fontFamily:"monospace",borderRadius:"3px",transform:"translate3D(-50%,-50%,0)",textAlign:"center",lineHeight:"1.5"}),e.appendChild(i),document.body.appendChild(e),d.default.setContext(p.default.context),d.default.on(i),d.default.onStarted(function(i){e.remove(),t()})}else t()}function a(t){for(var e=atob(t.split(",")[1]),i=t.split(",")[0].split(":")[1].split(";")[0],n=new ArrayBuffer(e.length),s=new Uint8Array(n),o=0;o<e.length;o++)s[o]=e.charCodeAt(o);return new Blob([n],{type:i})}function h(t){return 69+12*Math.log2(t/440)}function u(t){return 440*Math.pow(2,(t-69)/12)}function l(t){return function(e){b.isMobile?t():e.press&&t()}}Object.defineProperty(e,"__esModule",{value:!0}),e.dataURItoBlob=e.tap=e.mtof=e.ftom=e.requestAudioContext=e.browser=e.mod=e.choice=void 0;var c=i(0),p=n(c),f=i(12),d=n(f),y=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i),m=navigator.userAgent.match(/iPad/i),v=navigator.userAgent.match(/Android/i),_=y||m||v,g=!_;document.body.classList.add(_?"mobile":"desktop");var b={isIphone:y,isIpad:m,isMobile:_,isDesktop:g};e.choice=s,e.mod=o,e.browser=b,e.requestAudioContext=r,e.ftom=h,e.mtof=u,e.tap=l,e.dataURItoBlob=a},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=["housing-costs-and-income-inequality","income-inequality-over-time","shares-of-wealth","weekly-earnings","household-wealth"],s=n.map(function(t){return fetch("./data/"+t+".csv").then(function(t){return t.text()}).then(function(e){var i=e.split("\n").map(function(t){return t.split(",")}),n=i.shift();return{name:t.replace(/-/g," "),h:n,lines:i.filter(function(t){return!!t})}})}),o=Promise.all(s).then(function(t){return t.reduce(function(t,e){return t[e.name.replace(/-/g,"_")]=e,t},{})}),r=function(){return o};e.load=r},function(t,e,i){"use strict";function n(t){var e={sample:(0,r.choice)(u)};e.sample.index=(e.sample.index+1)%a;var i=e.sample.players[e.sample.index];i.playbackRate=t/e.sample.root,console.log(i),i.start()}Object.defineProperty(e,"__esModule",{value:!0});var s=i(0),o=function(t){return t&&t.__esModule?t:{default:t}}(s),r=i(1),a=2,h=new o.default.Compressor(-30,3).toMaster(),u=[{root:226,fn:"samples/380737__cabled-mess__sansula-01-a-raw.mp3"},{root:267,fn:"samples/380736__cabled-mess__sansula-02-c-raw.mp3"},{root:340,fn:"samples/380735__cabled-mess__sansula-03-e-raw.mp3"},{root:452,fn:"samples/380733__cabled-mess__sansula-06-a-02-raw.mp3"}];u.forEach(function(t){t.players=[],t.index=-1;for(var e=0;e<a;e++){var i=t.fn;window.location.href.match(/asdf.us/)&&(i="//asdf.us/kalimba/"+i);var n=new o.default.Player({url:i,retrigger:!0,playbackRate:1});n.connect(h),t.players.push(n)}}),e.default={play:n}},function(t,e,i){"use strict";function n(t){if(t.altKey||t.ctrlKey||t.metaKey)return void t.stopPropagation();if(document.activeElement instanceof HTMLInputElement&&t.keyCode in r)return void t.stopPropagation();if(t.keyCode in o){var e=o[t.keyCode];t.shiftKey&&(e+=a.length),e-=7,h(e)}}function s(t){h=t}Object.defineProperty(e,"__esModule",{value:!0});var o={},r={},a="zxcvbnmasdfghjklqwertyuiop",h=function(){};a.toUpperCase().split("").map(function(t,e){o[t.charCodeAt(0)]=e}),"1234567890".split("").map(function(t,e){o[t.charCodeAt(0)]=e+a.length,r[t.charCodeAt(0)]=!0}),window.addEventListener("keydown",n,!0),e.default={listen:s}},function(t,e,i){"use strict";function n(){c.forEach(function(t,e){t.heading=document.createElement("div"),t.heading.innerHTML=t.name,t.heading.classList.add("heading"),t.heading.addEventListener("click",function(){o(e)}),scale_list.appendChild(t.heading)}),o(0)}function s(t){c.forEach(function(e,i){var n=document.createElement("option");n.innerHTML=e.name,n.value=i,t.appendChild(n)}),t.addEventListener("input",function(t){o(t.target.value)}),o(0)}function o(t){p&&p.heading&&p.heading.classList.remove("selected"),p=c[t],p.heading&&p.heading.classList.add("selected"),f(p)}function r(){return p}function a(t){f=t}function h(){return c.map(function(t){return t.name})}Object.defineProperty(e,"__esModule",{value:!0});var u=i(11),l=function(t){return t&&t.__esModule?t:{default:t}}(u),c=[{intervals:"1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1",name:"harmonic scale"},{root:450,intervals:"1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1",name:"harmonic scale @ 450"},{tet:5},{tet:12},{tet:17},{intervals:"1/1 81/80 33/32 21/20 16/15 12/11 11/10 10/9 9/8 8/7 7/6 32/27 6/5 11/9 5/4 14/11 9/7 21/16 4/3 27/20 11/8 7/5 10/7 16/11 40/27 3/2 32/21 14/9 11/7 8/5 18/11 5/3 27/16 12/7 7/4 16/9 9/5 20/11 11/6 15/8 40/21 64/33 160/81 2/1",name:"harry partch scale"},{scl:"! young-lm_piano.scl\n!\nLaMonte Young's Well-Tempered Piano\n12\n!\n567/512\n9/8\n147/128\n21/16\n1323/1024\n189/128\n3/2\n49/32\n7/4\n441/256\n63/32\n2/1\n"},{scl:"! meanquar.scl\n!\n1/4-comma meantone scale. Pietro Aaron's temperament (1523)\n 12\n!\n 76.04900\n 193.15686\n 310.26471\n 5/4\n 503.42157\n 579.47057\n 696.57843\n 25/16\n 889.73529\n 1006.84314\n 1082.89214\n 2/1\n"},{scl:"! mavila12.scl\n!\nA 12-note mavila scale (for warping meantone-based music), 5-limit TOP\n 12\n!\n-30.99719\n 163.50770\n 358.01258\n 327.01540\n 521.52028\n 490.52310\n 685.02798\n 654.03080\n 848.53568\n 1043.04057\n 1012.04338\n 1206.54826\n"},{scl:"! carlos_alpha.scl\n!\nWendy Carlos' Alpha scale with perfect fifth divided in nine\n 18\n!\n 78.00000\n 156.00000\n 234.00000\n 312.00000\n 390.00000\n 468.00000\n 546.00000\n 624.00000\n 702.00000\n 780.00000\n 858.00000\n 936.00000\n 1014.00000\n 1092.00000\n 1170.00000\n 1248.00000\n 1326.00000\n 1404.00000\n"},{scl:"! colundi.scl\n!\nColundi scale\n10\n!\n9/8\n171/140\n137/112\n43/35\n3/2\n421/280\n213/140\n263/150\n66/35\n2/1\n"},{scl:"! shares.scl\n!\nA scale based on shares of wealth\n!\n1.\n5.\n15.\n32.\n52.\n78.\n116.\n182.\n521.\n1000.\n"},{scl:"! shares_sum.scl\n!\nA scale based on summing shares of wealth\n!\n1\n6.0\n21.0\n53.0\n105.0\n183.0\n299.0\n481.0\n1002.0\n2/1\n"},{scl:'! liu_major.scl\n!\nLinus Liu\'s Major Scale, see his 1978 book, "Intonation Theory"                 \n 7\n!\n 10/9\n 100/81\n 4/3\n 3/2\n 5/3\n 50/27\n 2/1\n'},{scl:"! LIU_MINor.scl\n!\nLinus Liu's Harmonic Minor                                                      \n 7\n!\n 10/9\n 6/5\n 4/3\n 40/27\n 8/5\n 50/27\n 2/1\n"},{scl:"! liu_mel.scl\n!\nLinus Liu's Melodic Minor, use 5 and 7 descending and 6 and 8 ascending         \n 9\n!\n 10/9\n 6/5\n 4/3\n 3/2\n 81/50\n 5/3\n 9/5\n 50/27\n 2/1\n"},{scl:'! liu_pent.scl\n!\nLinus Liu\'s "pentatonic scale"                                                  \n 7\n!\n 9/8\n 81/64\n 27/20\n 3/2\n 27/16\n 243/128\n 81/40\n'}].map(function(t){return new l.default(t)}),p=c[0],f=function(){};e.default={scales:c,current:r,build:n,build_options:s,pick:o,names:h,onChange:a}},function(t,e,i){var n,s=s||function(t){"use strict";if(!(void 0===t||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var e=t.document,i=function(){return t.URL||t.webkitURL||t},n=e.createElementNS("http://www.w3.org/1999/xhtml","a"),s="download"in n,o=function(t){var e=new MouseEvent("click");t.dispatchEvent(e)},r=/constructor/i.test(t.HTMLElement)||t.safari,a=/CriOS\/[\d]+/.test(navigator.userAgent),h=function(e){(t.setImmediate||t.setTimeout)(function(){throw e},0)},u=function(t){var e=function(){"string"==typeof t?i().revokeObjectURL(t):t.remove()};setTimeout(e,4e4)},l=function(t,e,i){e=[].concat(e);for(var n=e.length;n--;){var s=t["on"+e[n]];if("function"==typeof s)try{s.call(t,i||t)}catch(t){h(t)}}},c=function(t){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob([String.fromCharCode(65279),t],{type:t.type}):t},p=function(e,h,p){p||(e=c(e));var f,d=this,y=e.type,m="application/octet-stream"===y,v=function(){l(d,"writestart progress write writeend".split(" "))};if(d.readyState=d.INIT,s)return f=i().createObjectURL(e),void setTimeout(function(){n.href=f,n.download=h,o(n),v(),u(f),d.readyState=d.DONE});!function(){if((a||m&&r)&&t.FileReader){var n=new FileReader;return n.onloadend=function(){var e=a?n.result:n.result.replace(/^data:[^;]*;/,"data:attachment/file;");t.open(e,"_blank")||(t.location.href=e),e=void 0,d.readyState=d.DONE,v()},n.readAsDataURL(e),void(d.readyState=d.INIT)}if(f||(f=i().createObjectURL(e)),m)t.location.href=f;else{t.open(f,"_blank")||(t.location.href=f)}d.readyState=d.DONE,v(),u(f)}()},f=p.prototype,d=function(t,e,i){return new p(t,e||t.name||"download",i)};return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(t,e,i){return e=e||t.name||"download",i||(t=c(t)),navigator.msSaveOrOpenBlob(t,e)}:(f.abort=function(){},f.readyState=f.INIT=0,f.WRITING=1,f.DONE=2,f.error=f.onwritestart=f.onprogress=f.onwrite=f.onabort=f.onerror=f.onwriteend=null,d)}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);void 0!==t&&t.exports?t.exports.saveAs=s:null!==i(20)&&null!==i(21)&&void 0!==(n=function(){return s}.call(e,i,e,t))&&(t.exports=n)},function(t,e,i){"use strict";(function(t,n){function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.Writer=e.VexFlow=e.Utils=e.Track=e.ProgramChangeEvent=e.NoteOnEvent=e.NoteOffEvent=e.NoteEvent=e.MetaEvent=e.ControllerChangeEvent=e.Constants=e.Chunk=void 0;var o="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},r=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),a=i(19),h=function t(e){s(this,t),this.type=e.type,this.data=e.data,this.size=[0,0,0,e.data.length]};e.Chunk=h;var u={VERSION:"1.5.2",HEADER_CHUNK_TYPE:[77,84,104,100],HEADER_CHUNK_LENGTH:[0,0,0,6],HEADER_CHUNK_FORMAT0:[0,0],HEADER_CHUNK_FORMAT1:[0,1],HEADER_CHUNK_DIVISION:[0,128],TRACK_CHUNK_TYPE:[77,84,114,107],META_EVENT_ID:255,META_TEXT_ID:1,META_COPYRIGHT_ID:2,META_TRACK_NAME_ID:3,META_INSTRUMENT_NAME_ID:4,META_LYRIC_ID:5,META_MARKER_ID:6,META_CUE_POINT:7,META_TEMPO_ID:81,META_SMTPE_OFFSET:84,META_TIME_SIGNATURE_ID:88,META_KEY_SIGNATURE_ID:89,META_END_OF_TRACK_ID:[47,0],CONTROLLER_CHANGE_STATUS:176,PROGRAM_CHANGE_STATUS:192};e.Constants=u;var l=function t(e){s(this,t),this.type="controller",this.data=v.numberToVariableLength(0).concat(u.CONTROLLER_CHANGE_STATUS,e.controllerNumber,e.controllerValue)};e.ControllerChangeEvent=l;var c=function t(e){s(this,t),this.type="meta",this.data=v.numberToVariableLength(0),this.data=this.data.concat(u.META_EVENT_ID,e.data)};e.MetaEvent=c;var p=function(){function t(e){s(this,t),this.type="note",this.pitch=v.toArray(e.pitch),this.wait=e.wait||0,this.duration=e.duration,this.sequential=e.sequential||!1,this.velocity=e.velocity||50,this.channel=e.channel||1,this.repeat=e.repeat||1,this.velocity=this.convertVelocity(this.velocity),this.grace=e.grace,this.buildData()}return r(t,[{key:"buildData",value:function(){this.data=[];var e=this.getTickDuration(this.duration,"note"),i=this.getTickDuration(this.wait,"rest");if(this.grace){this.grace=v.toArray(this.grace),this.grace.forEach(function(i){var n=new t({pitch:this.grace,duration:"T1"});this.data=this.data.concat(n.data),e-=1},this)}var n,s;if(Array.isArray(this.pitch)){if(this.sequential)for(var o=0;o<this.repeat;o++)this.pitch.forEach(function(t,o){if(o>0&&(i=0),"8t"===this.duration&&o==this.pitch.length-1){var r=v.numberFromBytes(u.HEADER_CHUNK_DIVISION);e=r-2*e}n=new d({data:v.numberToVariableLength(i).concat([this.getNoteOnStatus(),v.getPitch(t),this.velocity])}),s=new f({data:v.numberToVariableLength(e).concat([this.getNoteOffStatus(),v.getPitch(t),this.velocity])}),this.data=this.data.concat(n.data,s.data)},this);else for(var o=0;o<this.repeat;o++)this.pitch.forEach(function(t,e){n=new d(0==e?{data:v.numberToVariableLength(i).concat(this.getNoteOnStatus(),v.getPitch(t),this.velocity)}:{data:[0,v.getPitch(t),this.velocity]}),this.data=this.data.concat(n.data)},this),this.pitch.forEach(function(t,i){s=new f(0==i?{data:v.numberToVariableLength(e).concat(this.getNoteOffStatus(),v.getPitch(t),this.velocity)}:{data:[0,v.getPitch(t),this.velocity]}),this.data=this.data.concat(s.data)},this);return this}throw"pitch must be an array."}},{key:"convertVelocity",value:function(t){return t=t>100?100:t,Math.round(t/100*127)}},{key:"getTickDuration",value:function(t,e){if(Array.isArray(t))return t.map(function(t){return this.getTickDuration(t,e)},this).reduce(function(t,e){return t+e},0);if(t=t.toString(),"t"===t.toLowerCase().charAt(0))return parseInt(t.substring(1));var i=v.numberFromBytes(u.HEADER_CHUNK_DIVISION);return Math.round(i*this.getDurationMultiplier(t,e))}},{key:"getDurationMultiplier",value:function(t,e){switch(t){case"0":return 0;case"1":return 4;case"2":return 2;case"d2":return 3;case"4":return 1;case"4t":return.666;case"d4":return 1.5;case"8":return.5;case"8t":return.33;case"d8":return.75;case"16":return.25;case"16t":return.166;case"32":return.125;case"64":return.0625}throw t+" is not a valid duration."}},{key:"getNoteOnStatus",value:function(){return 144+this.channel-1}},{key:"getNoteOffStatus",value:function(){return 128+this.channel-1}}]),t}();e.NoteEvent=p;var f=function t(e){s(this,t),this.data=e.data};e.NoteOffEvent=f;var d=function t(e){s(this,t),this.data=e.data};e.NoteOnEvent=d;var y=function t(e){s(this,t),this.type="program",this.data=v.numberToVariableLength(0).concat(u.PROGRAM_CHANGE_STATUS,e.instrument)};e.ProgramChangeEvent=y;var m=function(){function t(){s(this,t),this.type=u.TRACK_CHUNK_TYPE,this.data=[],this.size=[],this.events=[]}return r(t,[{key:"addEvent",value:function(t,e){return Array.isArray(t)?t.forEach(function(t,i){if("function"==typeof e&&"note"===t.type){var n=e(i,t);if("object"===(void 0===n?"undefined":o(n))){for(var s in n)switch(s){case"duration":t.duration=n[s];break;case"sequential":t.sequential=n[s];break;case"velocity":t.velocity=t.convertVelocity(n[s])}t.buildData()}}this.data=this.data.concat(t.data),this.size=v.numberToBytes(this.data.length,4),this.events.push(t)},this):(this.data=this.data.concat(t.data),this.size=v.numberToBytes(this.data.length,4),this.events.push(t)),this}},{key:"setTempo",value:function(t){var e=new c({data:[u.META_TEMPO_ID]});e.data.push(3);var i=Math.round(6e7/t);return e.data=e.data.concat(v.numberToBytes(i,3)),this.addEvent(e)}},{key:"setTimeSignature",value:function(t,e,i,n){i=i||24,n=n||8;var s=new c({data:[u.META_TIME_SIGNATURE_ID]});s.data.push(4),s.data=s.data.concat(v.numberToBytes(t,1));var o=Math.log2(e);return s.data=s.data.concat(v.numberToBytes(o,1)),s.data=s.data.concat(v.numberToBytes(i,1)),s.data=s.data.concat(v.numberToBytes(n,1)),this.addEvent(s)}},{key:"setKeySignature",value:function(t,e){var i=new c({data:[u.META_KEY_SIGNATURE_ID]});i.data.push(2);var n=e||0;if(t=t||0,void 0===e){var s=[["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"],["ab","eb","bb","f","c","g","d","a","e","b","f#","c#","g#","d#","a#"]],o=t.length,r=t||"C";if(t[0]===t[0].toLowerCase()&&(n=1),o>1)switch(t.charAt(o-1)){case"m":case"-":n=1,r=t.charAt(0).toLowerCase(),r=r.concat(t.substring(1,o-1));break;case"M":case"+":n=0,r=t.charAt(0).toUpperCase(),r=r.concat(t.substring(1,o-1))}var a=s[n].indexOf(r);t=-1===a?0:a-7}return i.data=i.data.concat(v.numberToBytes(t,1)),i.data=i.data.concat(v.numberToBytes(n,1)),this.addEvent(i)}},{key:"addText",value:function(t){var e=new c({data:[u.META_TEXT_ID]}),i=v.stringToBytes(t);return e.data=e.data.concat(v.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addCopyright",value:function(t){var e=new c({data:[u.META_COPYRIGHT_ID]}),i=v.stringToBytes(t);return e.data=e.data.concat(v.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addTrackName",value:function(t){var e=new c({data:[u.META_TRACK_NAME_ID]}),i=v.stringToBytes(t);return e.data=e.data.concat(v.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addInstrumentName",value:function(t){var e=new c({data:[u.META_INSTRUMENT_NAME_ID]}),i=v.stringToBytes(t);return e.data=e.data.concat(v.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addMarker",value:function(t){var e=new c({data:[u.META_MARKER_ID]}),i=v.stringToBytes(t);return e.data=e.data.concat(v.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addCuePoint",value:function(t){var e=new c({data:[u.META_CUE_POINT]}),i=v.stringToBytes(t);return e.data=e.data.concat(v.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addLyric",value:function(t){var e=new c({data:[u.META_LYRIC_ID]}),i=v.stringToBytes(t);return e.data=e.data.concat(v.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"polyModeOn",value:function(){var t=new d({data:[0,176,126,0]});return this.addEvent(t)}}]),t}();e.Track=m;var v=function(){function t(){s(this,t)}return r(t,null,[{key:"version",value:function(){return u.VERSION}},{key:"stringToBytes",value:function(t){return t.split("").map(function(t){return t.charCodeAt()})}},{key:"isNumeric",value:function(t){return!isNaN(parseFloat(t))&&isFinite(t)}},{key:"getPitch",value:function(t){return(0,a.toMidi)(t)}},{key:"numberToVariableLength",value:function(t){for(var e=127&t;t>>=7;)e<<=8,e|=127&t|128;for(var i=[];;){if(i.push(255&e),!(128&e))break;e>>=8}return i}},{key:"stringByteCount",value:function(t){return encodeURI(t).split(/%..|./).length-1}},{key:"numberFromBytes",value:function(t){var e,i="";return t.forEach(function(t){e=t.toString(16),1==e.length&&(e="0"+e),i+=e}),parseInt(i,16)}},{key:"numberToBytes",value:function(t,e){e=e||1;var i=t.toString(16);1&i.length&&(i="0"+i);var n=i.match(/.{2}/g);if(n=n.map(function(t){return parseInt(t,16)}),n.length<e)for(;e-n.length>0;)n.unshift(0);return n}},{key:"toArray",value:function(t){return Array.isArray(t)?t:[t]}}]),t}();e.Utils=v;var _=function(){function t(){s(this,t)}return r(t,[{key:"trackFromVoice",value:function(t){var e,i=new m,n=[];return t.tickables.forEach(function(t){if(n=[],"n"===t.noteType)t.keys.forEach(function(t){n.push(this.convertPitch(t))});else if("r"===t.noteType)return void(e=this.convertDuration(t));i.addEvent(new p({pitch:n,duration:this.convertDuration(t),wait:e})),e=0}),i}},{key:"convertPitch",value:function(t){return t.replace("/","")}},{key:"convertDuration",value:function(t){switch(t.duration){case"w":return"1";case"h":return t.isDotted()?"d2":"2";case"q":return t.isDotted()?"d4":"4";case"8":return t.isDotted()?"d8":"8"}return t.duration}}]),t}();e.VexFlow=_;var g=function(){function e(t){s(this,e),this.data=[];var i=t.length>1?u.HEADER_CHUNK_FORMAT1:u.HEADER_CHUNK_FORMAT0,n=v.numberToBytes(t.length,2);this.data.push(new h({type:u.HEADER_CHUNK_TYPE,data:i.concat(n,u.HEADER_CHUNK_DIVISION)})),t.forEach(function(t,e){t.addEvent(new c({data:u.META_END_OF_TRACK_ID})),this.data.push(t)},this)}return r(e,[{key:"buildFile",value:function(){var t=[];return this.data.forEach(function(e){return t=t.concat(e.type,e.size,e.data)}),new Uint8Array(t)}},{key:"base64",value:function(){return"function"==typeof btoa?btoa(String.fromCharCode.apply(null,this.buildFile())):new t(this.buildFile()).toString("base64")}},{key:"dataUri",value:function(){return"data:audio/midi;base64,"+this.base64()}},{key:"stdout",value:function(){return n.stdout.write(new t(this.buildFile()))}},{key:"saveMIDI",value:function(e){var i=new t(this.buildFile());fs.writeFile(e+".mid",i,function(t){if(t)return console.log(t)})}}]),e}();e.Writer=g}).call(e,i(14).Buffer,i(18))},function(t,e,i){!function(e,i){t.exports=i()}(0,function(){return function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={exports:{},id:n,loaded:!1};return t[n].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){"use strict";var n=function(t){return t&&t.__esModule?t.default:t}(i(1));t.exports=n},function(t,e,i){"use strict";function n(){return T.colors}function s(){return T.context}function o(){return T.clock}var r=function(t){return t&&t.__esModule?t.default:t},a=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),h=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};e.colors=n,e.context=s,e.clock=o,Object.defineProperty(e,"__esModule",{value:!0});var u=r(i(2)),l=r(i(5)),c=r(i(38)),p=r(i(40)),f=function(t){return t&&t.__esModule?t:{default:t}}(i(39)),d=i(28),y=i(41),m=i(27),v=i(26),_=i(25),g=r(i(42)),b=r(i(45)),w=function(){function t(e){h(this,t);for(var i in u)this[i]=u[i];for(var i in l)this[i]=l[i];var n={Rack:c},s={Counter:d,Radio:y,Drunk:m,Sequence:v,Matrix:_};for(var i in s)this[i]=s[i];for(var i in n)this[i]=n[i];var o=window.AudioContext||window.webkitAudioContext;this._context=e||new o,this.tune=new p,this.note=this.tune.note.bind(this.tune),this.clock=new g(this._context),this.clock.start(),this.Interval=b,this.colors={accent:"#2bb",fill:"#eee",light:"#fff",dark:"#333",mediumLight:"#ccc",mediumDark:"#666"},this.transform=f,this.add=f.add,this.Add={};for(var i in u)this.Add[i]=f.add.bind(this,i);var r=document.getElementsByTagName("style"),a=document.createElement("style");if(a.type="text/css",a.innerHTML="[nexus-ui]{height:5000px;width:5000px}",r.length>0){r[0].parentNode.insertBefore(a,r[0])}else document.write("<style>[nexus-ui]{height:5000px;width:5000px}</style>")}return a(t,{context:{get:function(){return this._context},set:function(t){this.clock.stop(),this._context=t,this.clock=new g(this.context),this.clock.start()}}}),t}(),T=new w;e.default=T},function(t,e,i){"use strict";t.exports={Position:i(3),Slider:i(14),Toggle:i(15),Button:i(16),TextButton:i(18),RadioButton:i(19),Number:i(20),Select:i(21),Dial:i(22),Piano:i(23),Sequencer:i(24),Pan2D:i(29),Tilt:i(30),Multislider:i(31),Pan:i(33),Envelope:i(34),Spectrogram:i(35),Meter:i(36),Oscilloscope:i(37)}},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(6),u=i(11),l=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),c=function(t){function e(){r(this,e);var t=["value"],i={size:[200,200],mode:"absolute",minX:0,maxX:1,stepX:0,x:.5,minY:0,maxY:1,stepY:0,y:.5};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this._x=new u(this.settings.minX,this.settings.maxX,this.settings.stepX,this.settings.x),this._y=new u(this.settings.minY,this.settings.maxY,this.settings.stepY,this.settings.y),this.position={x:new l.Handle(this.settings.mode,"horizontal",[0,this.width],[this.height,0]),y:new l.Handle(this.settings.mode,"vertical",[0,this.width],[this.height,0])},this.position.x.value=this._x.normalized,this.position.y.value=this._y.normalized,this.init(),this.render()}return o(e,t),n(e,{buildInterface:{value:function(){this.knob=a.create("circle"),this.element.appendChild(this.knob)}},sizeInterface:{value:function(){this.position.x.resize([0,this.width],[this.height,0]),this.position.y.resize([0,this.width],[this.height,0]),this._minDimension=Math.min(this.width,this.height),this.knobRadius={off:5*~~(this._minDimension/100)+5},this.knobRadius.on=2*this.knobRadius.off,this.knob.setAttribute("cx",this.width/2),this.knob.setAttribute("cy",this.height/2),this.knob.setAttribute("r",this.knobRadius.off)}},colorInterface:{value:function(){this.element.style.backgroundColor=this.colors.fill,this.knob.setAttribute("fill",this.colors.accent)}},render:{value:function(){this.clicked?this.knob.setAttribute("r",this.knobRadius.on):this.knob.setAttribute("r",this.knobRadius.off),this.knobCoordinates={x:this._x.normalized*this.width,y:this.height-this._y.normalized*this.height},this.knob.setAttribute("cx",this.knobCoordinates.x),this.knob.setAttribute("cy",this.knobCoordinates.y)}},click:{value:function(){this.position.x.anchor=this.mouse,this.position.y.anchor=this.mouse,this.move()}},move:{value:function(){this.clicked&&(this.position.x.update(this.mouse),this.position.y.update(this.mouse),this._x.updateNormal(this.position.x.value),this._y.updateNormal(this.position.y.value),this.emit("change",{x:this._x.value,y:this._y.value}),this.render())}},release:{value:function(){this.render()}},x:{get:function(){return this._x.value},set:function(t){this._x.update(t),this.emit("change",{x:this._x.value,y:this._y.value}),this.render()}},y:{get:function(){return this._y.value},set:function(t){this._y.update(t),this.emit("change",{x:this._x.value,y:this._y.value}),this.render()}},normalized:{get:function(){return{x:this._x.normalized,y:this._y.normalized}}},minX:{get:function(){return this._x.min},set:function(t){this._x.min=t,this.render()}},minY:{get:function(){return this._y.min},set:function(t){this._y.min=t,this.render()}},maxX:{get:function(){return this._x.max},set:function(t){this._x.max=t,this.render()}},maxY:{get:function(){return this._y.max},set:function(t){this._y.max=t,this.render()}},stepX:{get:function(){return this._x.step},set:function(t){this._x.step=t,this.render()}},stepY:{get:function(){return this._y.step},set:function(t){this._y.step=t,this.render()}},mode:{get:function(){return this.position.x.mode},set:function(t){this.position.x.mode=t,this.position.y.mode=t}}}),e}(h);t.exports=c},function(t,e,i){"use strict";var n=i(5);t.exports={create:function(t){return document.createElementNS("http://www.w3.org/2000/svg",t)},arc:function(t,e,i,s,o){var r=n.toCartesian(i,o),a=n.toCartesian(i,s),h=o-s<=180?"0":"1";return["M",r.x+t,r.y+e,"A",i,i,0,h,0,a.x+t,a.y+e].join(" ")},radialGradient:function(t,e){var i="gradient"+n.ri(1e11),s=[],o=document.createElementNS("http://www.w3.org/2000/svg","radialGradient");o.setAttribute("id",i),o.setAttribute("cx","50%"),o.setAttribute("cy","50%"),o.setAttribute("r","50%"),t.appendChild(o);for(var r=0;r<e;r++){var a=document.createElementNS("http://www.w3.org/2000/svg","stop");a.setAttribute("id","stop"+r),o.appendChild(a),s.push(a)}return{id:i,stops:s,element:o}}}},function(t,e){"use strict";e.clip=function(t,e,i){return Math.min(Math.max(t,e),i)},e.normalize=function(t,e,i){return(t-e)/(i-e)},e.scale=function(t,e,i,n,s){return e===i?n:(t-e)*(s-n)/(i-e)+n},e.toPolar=function(t,e){var i=Math.sqrt(t*t+e*e),n=Math.atan2(e,t);return n<0&&(n+=2*Math.PI),{radius:i,angle:n}},e.toCartesian=function(t,e){return{x:t*Math.cos(e),y:t*Math.sin(e)*-1}},e.prune=function(t,e){return parseFloat(t.toFixed(e))},e.invert=function(t){return e.scale(t,1,0,0,1)},e.mtof=function(t){return 440*Math.pow(2,(t-69)/12)},e.interp=function(t,e,i){return t*(i-e)+e},e.pick=function(){return arguments[~~(Math.random()*arguments.length)]},e.octave=function(t){return Math.pow(2,t)},e.ri=function(t,e){e||(e=t,t=0);var i=Math.min(t,e),n=Math.max(t,e);return Math.floor(Math.random()*(n-i)+i)},e.rf=function(t,e){e||(e=t,t=0);var i=Math.min(t,e),n=Math.max(t,e);return Math.random()*(n-i)+i},e.cycle=function(t,e,i){return t++,t>=i&&(t=e),t},e.average=function(t){for(var e=0,i=0;i<t.length;i++)e+=t[i];return e/t.length},e.distance=function(t,e,i,n){var s=t-i,o=e-n;return Math.sqrt(s*s+o*o)},e.gainToDB=function(t){return 20*Math.log10(t)},e.coin=function(){var t=void 0===arguments[0]?.5:arguments[0];return e.rf(0,1)<t?1:0}},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(7),u=i(8),l=i(9),c=i(10),p=i(1).colors,f=function(t){function e(t,i,n){r(this,e),s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this),this.type=this.constructor.name,this.settings=this.parseSettings(t,i,n),this.mouse={},this.wait=!1,this.colors={};var o=p();this.colors.accent=o.accent,this.colors.fill=o.fill,this.colors.light=o.light,this.colors.dark=o.dark,this.colors.mediumLight=o.mediumLight,this.colors.mediumDark=o.mediumDark}return o(e,t),n(e,{parseSettings:{value:function(t,e,i){e.unshift("target"),i.defaultSize=i.size.splice(0,2),i.size=!1;var n={target:document.body,colors:{},snapWithParent:!0,event:function(){},component:!1};for(var s in i)n[s]=i[s];for(var o=0;o<t.length;o++){var r=t[o];if(u.isObject(r))for(var s in r)n[s]=r[s];else if("function"==typeof r)n.event=r;else if(e.length>=1){var s=e.splice(0,1)[0];n[s]=r}}return this.parent=h.parseElement(n.target),this.parent&&this.parent instanceof HTMLElement&&!n.component&&(this.parent.hasAttribute("nexus-ui")||this.parent.setAttribute("nexus-ui","")),n.size&&Array.isArray(n.size)&&n.snapWithParent?(this.width=n.size[0],this.height=n.size[1],this.parent.style.width=this.width+"px",this.parent.style.height=this.height+"px"):n.snapWithParent&&!n.component?(this.width=parseFloat(window.getComputedStyle(this.parent,null).getPropertyValue("width").replace("px","")),this.height=parseFloat(window.getComputedStyle(this.parent,null).getPropertyValue("height").replace("px","")),5e3==this.width&&(this.width=n.defaultSize[0],this.parent.style.width=this.parent.width=this.width+"px"),5e3==this.height&&(this.height=n.defaultSize[1],this.parent.style.height=this.parent.height=this.height+"px")):(n.size=n.defaultSize,this.width=n.size[0],this.height=n.size[1]),n.event?this.event=this.on("change",n.event):this.event=!1,n}},init:{value:function(){this.buildFrame(),this.buildInterface(),this.sizeInterface(),this.attachListeners(),this.colorInterface(),this.finalTouches()}},buildFrame:{value:function(){this.element=a.create("svg"),this.element.setAttribute("width",this.width),this.element.setAttribute("height",this.height),this.parent.appendChild(this.element)}},buildInterface:{value:function(){}},sizeInterface:{value:function(){}},colorInterface:{value:function(){}},attachListeners:{value:function(){var t=this;this.interactionTarget=this.interactionTarget||this.element,l.exists&&(this.interactionTarget.addEventListener("touchstart",function(e){return t.preTouch(e)}),this.interactionTarget.addEventListener("touchmove",function(e){return t.preTouchMove(e)}),this.interactionTarget.addEventListener("touchend",function(e){return t.preTouchRelease(e)})),this.boundPreMove=function(e){return t.preMove(e)},this.boundPreRelease=function(e){return t.preRelease(e)},this.interactionTarget.addEventListener("mousedown",function(e){return t.preClick(e)})}},finalTouches:{value:function(){this.element.style.cursor="pointer"}},preClick:{value:function(t){this.element instanceof HTMLElement&&(this.width=window.getComputedStyle(this.element,null).getPropertyValue("width").replace("px","")),this.offset=h.findPosition(this.element),this.mouse=h.locateMouse(t,this.offset),this.clicked=!0,this.click(),this.moveEvent=document.addEventListener("mousemove",this.boundPreMove),this.releaseEvent=document.addEventListener("mouseup",this.boundPreRelease),this.emit("click"),t.preventDefault(),t.stopPropagation()}},preMove:{value:function(t){var e=this;this.wait||(this.mouse=h.locateMouse(t,this.offset),this.move(),this.wait=!0,setTimeout(function(){e.wait=!1},25)),t.preventDefault(),t.stopPropagation()}},preRelease:{value:function(t){this.mouse=h.locateMouse(t,this.offset),this.clicked=!1,this.release(),this.emit("release"),document.removeEventListener("mousemove",this.boundPreMove),document.removeEventListener("mouseup",this.boundPreRelease),t.preventDefault(),t.stopPropagation()}},click:{value:function(){}},move:{value:function(){}},release:{value:function(){}},preTouch:{value:function(t){this.element instanceof HTMLElement&&(this.width=window.getComputedStyle(this.element,null).getPropertyValue("width").replace("px","")),this.offset=h.findPosition(this.element),this.mouse=h.locateTouch(t,this.offset),this.clicked=!0,this.touch(t),this.emit("click"),t.preventDefault(),t.stopPropagation()}},preTouchMove:{value:function(t){this.clicked&&(this.mouse=h.locateTouch(t,this.offset),this.touchMove(),t.preventDefault(),t.stopPropagation())}},preTouchRelease:{value:function(t){this.mouse=h.locateTouch(t,this.offset),this.clicked=!1,this.touchRelease(),this.emit("release"),t.preventDefault(),t.stopPropagation()}},touch:{value:function(){this.click()}},touchMove:{value:function(){this.move()}},touchRelease:{value:function(){this.release()}},resize:{value:function(t,e){this.width=t,this.height=e,this.parent.style.width=this.width+"px",this.parent.style.height=this.height+"px",this.element.setAttribute("width",this.width),this.element.setAttribute("height",this.height),this.sizeInterface()}},empty:{value:function(){for(;this.element.lastChild;)this.element.removeChild(this.element.lastChild)}},destroy:{value:function(){this.empty(),this.parent.removeChild(this.element),this.removeAllListeners(),this.instrument&&delete this.instrument[this.id],this.customDestroy()}},customDestroy:{value:function(){}},colorize:{value:function(t,e){this.colors[t]=e,this.colorInterface()}}}),e}(c);t.exports=f},function(t,e){"use strict";e.findPosition=function(t){var e=t.getBoundingClientRect();return{top:e.top+window.scrollY,left:e.left+window.scrollX}},e.parseElement=function(t){return"string"==typeof t&&(t=document.getElementById(t.replace("#",""))),t instanceof HTMLElement||t instanceof SVGElement?t:"No valid parent argument"},e.locateMouse=function(t,e){return{x:t.pageX-e.left,y:t.pageY-e.top}},e.locateTouch=function(t,e){return{x:!!t.targetTouches.length&&t.targetTouches[0].pageX-e.left,y:!!t.targetTouches.length&&t.targetTouches[0].pageY-e.top}},e.SmartCanvas=function(t){var e=this;this.element=document.createElement("canvas"),this.context=this.element.getContext("2d"),t.appendChild(this.element),this.resize=function(t,i){e.element.width=2*t,e.element.height=2*i,e.element.style.width=t+"px",e.element.style.height=i+"px"}}},function(t,e){"use strict";e.isObject=function(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&t instanceof SVGElement==!1&&t instanceof HTMLElement==!1}},function(t,e){"use strict";e.exists="ontouchstart"in document.documentElement},function(t,e){function i(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function s(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function r(t){return void 0===t}t.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._maxListeners=void 0,i.defaultMaxListeners=10,i.prototype.setMaxListeners=function(t){if(!s(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},i.prototype.emit=function(t){var e,i,s,a,h,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var l=new Error('Uncaught, unspecified "error" event. ('+e+")");throw l.context=e,l}if(i=this._events[t],r(i))return!1;if(n(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),i.apply(this,a)}else if(o(i))for(a=Array.prototype.slice.call(arguments,1),u=i.slice(),s=u.length,h=0;h<s;h++)u[h].apply(this,a);return!0},i.prototype.addListener=function(t,e){var s;if(!n(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(s=r(this._maxListeners)?i.defaultMaxListeners:this._maxListeners)&&s>0&&this._events[t].length>s&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},i.prototype.on=i.prototype.addListener,i.prototype.once=function(t,e){function i(){this.removeListener(t,i),s||(s=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var s=!1;return i.listener=e,this.on(t,i),this},i.prototype.removeListener=function(t,e){var i,s,r,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(i=this._events[t],r=i.length,s=-1,i===e||n(i.listener)&&i.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(i)){for(a=r;a-- >0;)if(i[a]===e||i[a].listener&&i[a].listener===e){s=a;break}if(s<0)return this;1===i.length?(i.length=0,delete this._events[t]):i.splice(s,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},i.prototype.removeAllListeners=function(t){var e,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[t],n(i))this.removeListener(t,i);else if(i)for(;i.length;)this.removeListener(t,i[i.length-1]);return delete this._events[t],this},i.prototype.listeners=function(t){return this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},i.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(n(e))return 1;if(e)return e.length}return 0},i.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(5),r=function(){function t(){var e=void 0===arguments[0]?0:arguments[0],i=void 0===arguments[1]?1:arguments[1],n=void 0===arguments[2]?0:arguments[2],o=void 0===arguments[3]?0:arguments[3];s(this,t),this.min=e,this.max=i,this.step=n,this.value=o,this.changed=!1,this.oldValue=!1,this.update(this.value)}return n(t,{update:{value:function(t){return this.step?this.value=o.clip(Math.round((t-this.min)/this.step)*this.step+this.min,this.min,this.max):this.value=o.clip(t,this.min,this.max),this.oldValue!==this.value?(this.oldValue=this.value,this.changed=!0):this.changed=!1,this.value}},updateNormal:{value:function(t){return this.value=o.scale(t,0,1,this.min,this.max),this.update(this.value)}},normalized:{get:function(){return o.normalize(this.value,this.min,this.max)}}}),t}();t.exports=r},function(t,e,i){"use strict";var n=function(t){return t&&t.__esModule?t.default:t},s=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};Object.defineProperty(e,"__esModule",{value:!0});var r=n(i(5)),a=n(i(13));e.Handle=function(){function t(){var e=void 0===arguments[0]?"absolute":arguments[0],i=void 0===arguments[1]?"vertical":arguments[1],n=void 0===arguments[2]?[0,100]:arguments[2],s=void 0===arguments[3]?[0,100]:arguments[3];o(this,t),this.mode=e,this.direction=i,this.previous=0,this.value=0,this.sensitivity=1,this.resize(n,s)}return s(t,{resize:{value:function(t,e){this.boundary={min:{x:t[0],y:e[0]},max:{x:t[1],y:e[1]},center:{x:(t[1]-t[0])/2+t[0],y:(e[1]-e[0])/2+e[0]}}}},anchor:{set:function(t){this._anchor=this.convertPositionToValue(t)},get:function(){return this._anchor}},update:{value:function(t){if("relative"===this.mode){var e=this.convertPositionToValue(t)-this.anchor;Math.abs(e)>.5&&(e=0),this.anchor=t,this.value=this.value+e*this.sensitivity}else this.value=this.convertPositionToValue(t);this.value=r.clip(this.value,0,1)}},convertPositionToValue:{value:function(t){switch(this.direction){case"radial":var e=r.toPolar(t.x-this.boundary.center.x,t.y-this.boundary.center.y);return e=e.angle/(2*Math.PI),e=(e-.25+1)%1;case"vertical":return r.scale(t.y,this.boundary.min.y,this.boundary.max.y,0,1);case"horizontal":return r.scale(t.x,this.boundary.min.x,this.boundary.max.x,0,1)}}}}),t}(),e.Button=function(){function t(){var e=void 0===arguments[0]?"button":arguments[0];o(this,t),this.mode=e,this.state=new a,this.paintbrush=!1}return s(t,{click:{value:function(){switch(this.mode){case"impulse":this.state.on(),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(this.state.off.bind(this),30),this.emit("change",this.state);break;case"button":this.turnOn(),this.emit("change",this.state);break;case"aftertouch":this.position={x:r.clip(this.mouse.x/this.width,0,1),y:r.clip(1-this.mouse.y/this.height,0,1)},this.turnOn(),this.emit("change",{state:this.state,x:this.position.x,y:this.position.y});break;case"toggle":this.flip(),this.emit("change",this.state)}}},move:{value:function(){"aftertouch"===this.mode&&(this.position={x:r.clip(this.mouse.x/this.width,0,1),y:r.clip(1-this.mouse.y/this.height,0,1)},this.emit("change",{state:this.state,x:this.position.x,y:this.position.y}),this.render())}},release:{value:function(){switch(this.mode){case"button":this.turnOff(),this.emit("change",this.state);break;case"aftertouch":this.turnOff(),this.position={x:this.mouse.x/this.width,y:1-this.mouse.y/this.height},this.emit("change",{state:this.state,x:this.position.x,y:this.position.y})}}}}),t}()},function(t,e){"use strict";var i=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),n=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},s=function(){function t(e){n(this,t),this.state=e||!1}return i(t,{flip:{value:function(t){this.state=t||!1===t?t:!this.state}},on:{value:function(){this.state=!0}},off:{value:function(){this.state=!1}}}),t}();t.exports=s},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(6),u=i(11),l=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),c=function(t){function e(){r(this,e);var t=["min","max","value"],i={size:[120,20],mode:"relative",min:0,max:1,step:0,value:0};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.orientation="vertical",this._value=new u(this.settings.min,this.settings.max,this.settings.step,this.settings.value),this.position=new l.Handle(this.settings.mode,this.orientation,[0,this.width],[this.height,0]),this.position.value=this._value.normalized,this.init(),this.position.direction=this.orientation,this.emit("change",this.value)}return o(e,t),n(e,{buildInterface:{value:function(){this.bar=a.create("rect"),this.fillbar=a.create("rect"),this.knob=a.create("circle"),this.element.appendChild(this.bar),this.element.appendChild(this.fillbar),this.element.appendChild(this.knob)}},sizeInterface:{value:function(){this.width<this.height?this.orientation="vertical":this.orientation="horizontal",this.position&&this.position.resize([0,this.width],[this.height,0]);var t=void 0,e=void 0,i=void 0,n=void 0,s=void 0,o=void 0;this.knobData={level:0,r:0},"vertical"===this.orientation?(this.thickness=this.width/2,t=this.width/2,e=0,i=this.thickness,n=this.height,this.knobData.r=.8*this.thickness,this.knobData.level=n-this.knobData.r-this.normalized*(n-2*this.knobData.r),s="translate("+-1*this.thickness/2+",0)",o=i/2):(this.thickness=this.height/2,t=0,e=this.height/2,i=this.width,n=this.thickness,this.knobData.r=.8*this.thickness,this.knobData.level=this.normalized*(i-2*this.knobData.r)+this.knobData.r,s="translate(0,"+-1*this.thickness/2+")",o=n/2),this.bar.setAttribute("x",t),this.bar.setAttribute("y",e),this.bar.setAttribute("transform",s),this.bar.setAttribute("rx",o),this.bar.setAttribute("ry",o),this.bar.setAttribute("width",i),this.bar.setAttribute("height",n),"vertical"===this.orientation?(this.fillbar.setAttribute("x",t),this.fillbar.setAttribute("y",this.knobData.level),this.fillbar.setAttribute("width",i),this.fillbar.setAttribute("height",n-this.knobData.level)):(this.fillbar.setAttribute("x",0),this.fillbar.setAttribute("y",e),this.fillbar.setAttribute("width",this.knobData.level),this.fillbar.setAttribute("height",n)),this.fillbar.setAttribute("transform",s),this.fillbar.setAttribute("rx",o),this.fillbar.setAttribute("ry",o),"vertical"===this.orientation?(this.knob.setAttribute("cx",t),this.knob.setAttribute("cy",this.knobData.level)):(this.knob.setAttribute("cx",this.knobData.level),this.knob.setAttribute("cy",e)),this.knob.setAttribute("r",this.knobData.r)}},colorInterface:{value:function(){this.bar.setAttribute("fill",this.colors.fill),this.fillbar.setAttribute("fill",this.colors.accent),this.knob.setAttribute("fill",this.colors.accent)}},render:{value:function(){this.clicked||(this.knobData.r=.75*this.thickness),this.knob.setAttribute("r",this.knobData.r),"vertical"===this.orientation?(this.knobData.level=this.knobData.r+this._value.normalized*(this.height-2*this.knobData.r),this.knob.setAttribute("cy",this.height-this.knobData.level),this.fillbar.setAttribute("y",this.height-this.knobData.level),this.fillbar.setAttribute("height",this.knobData.level)):(this.knobData.level=this._value.normalized*(this.width-2*this.knobData.r)+this.knobData.r,this.knob.setAttribute("cx",this.knobData.level),this.fillbar.setAttribute("x",0),this.fillbar.setAttribute("width",this.knobData.level))}},click:{value:function(){this.knobData.r=.9*this.thickness,this.position.anchor=this.mouse,this.move()}},move:{value:function(){this.clicked&&(this.position.update(this.mouse),this._value.updateNormal(this.position.value),this.emit("change",this._value.value),this.render())}},release:{value:function(){this.render()}},normalized:{get:function(){return this._value.normalized}},value:{get:function(){return this._value.value},set:function(t){this._value.update(t),this.position.value=this._value.normalized,this.emit("change",this._value.value),this.render()}},min:{get:function(){return this._value.min},set:function(t){this._value.min=t}},max:{get:function(){return this._value.max},set:function(t){this._value.max=t}},step:{get:function(){return this._value.step},set:function(t){this._value.step=t}},mode:{get:function(){return this.position.mode},set:function(t){this.position.mode=t}}}),e}(h);t.exports=c},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(13),u=i(6),l=function(t){function e(){r(this,e);var t=["value"],i={size:[40,20],target:!1,state:!1};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this._state=new h(this.settings.state),this.init()}return o(e,t),n(e,{buildInterface:{value:function(){this.bar=a.create("rect"),this.knob=a.create("circle"),this.element.appendChild(this.bar),this.element.appendChild(this.knob)}},sizeInterface:{value:function(){this.height<this.width/2?this.knobSize=this.height/2:this.knobSize=this.width/4,this.bar.setAttribute("x",this.width/2-1.5*this.knobSize),this.bar.setAttribute("y",this.height/2-this.knobSize/2),this.bar.setAttribute("rx",this.knobSize/2),this.bar.setAttribute("ry",this.knobSize/2),this.bar.setAttribute("width",3*this.knobSize),this.bar.setAttribute("height",this.knobSize),this.knob.setAttribute("cx",this.width/2-this.knobSize),this.knob.setAttribute("cy",this.height/2),this.knob.setAttribute("r",this.knobSize)}},colorInterface:{value:function(){this.knob.setAttribute("fill",this.colors.accent),this.render()}},render:{value:function(){this.state?(this.knob.setAttribute("cx",this.width/2+this.knobSize),this.bar.setAttribute("fill",this.colors.accent)):(this.knob.setAttribute("cx",this.width/2-this.knobSize),this.bar.setAttribute("fill",this.colors.fill))}},click:{value:function(){this.flip(),this.render(),this.emit("change",this.state)}},state:{get:function(){return this._state.state},set:function(t){this._state.flip(t),this.emit("change",this.state),this.render()}},flip:{value:function(){this._state.flip(),this.render()}}}),e}(u);t.exports=l},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(17),u=function(t){function e(){r(this,e);var t=["mode"],i={size:[80,80],mode:"aftertouch",state:!1};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.mode=this.settings.mode,this.init(),this.render()}return o(e,t),n(e,{buildInterface:{value:function(){this.pad=a.create("circle"),this.element.appendChild(this.pad),this.interactionTarget=this.pad,this.defs=a.create("defs"),this.element.appendChild(this.defs),this.gradient=a.radialGradient(this.defs,2),this.gradient.stops[0].setAttribute("offset","30%"),this.gradient.stops[1].setAttribute("offset","100%")}},sizeInterface:{value:function(){this.pad.setAttribute("cx",this.width/2),this.pad.setAttribute("cy",this.height/2),this.pad.setAttribute("r",Math.min(this.width,this.height)/2-this.width/40),this.pad.setAttribute("stroke-width",this.width/20)}},colorInterface:{value:function(){this.gradient.stops[0].setAttribute("stop-color",this.colors.accent),this.gradient.stops[1].setAttribute("stop-color",this.colors.fill),this.render()}},render:{value:function(){this.state?("aftertouch"===this.mode?(this.pad.setAttribute("stroke","url(#"+this.gradient.id+")"),this.gradient.element.setAttribute("cx",100*this.position.x+"%"),this.gradient.element.setAttribute("cy",100*(1-this.position.y)+"%")):this.pad.setAttribute("stroke",this.colors.accent),this.pad.setAttribute("fill",this.colors.accent)):(this.pad.setAttribute("fill",this.colors.fill),this.pad.setAttribute("stroke",this.colors.mediumLight))}}}),e}(h);t.exports=u},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(5),u=i(13),l=i(6),c=function(t){function e(t,i,n){r(this,e),s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,t,i,n),this.mode=this.settings.mode||"button",this.position={x:0,y:0},this._state=new u(this.settings.state)}return o(e,t),n(e,{buildInterface:{value:function(){this.pad=a.create("circle"),this.pad.setAttribute("fill","#d18"),this.pad.setAttribute("stroke","#d18"),this.pad.setAttribute("stroke-width",4),this.element.appendChild(this.pad),this.interactionTarget=this.pad,this.sizeInterface()}},sizeInterface:{value:function(){this.pad.setAttribute("cx",this.width/2),this.pad.setAttribute("cy",this.height/2),this.pad.setAttribute("r",Math.min(this.width,this.height)/2-2)}},render:{value:function(){this.state?(this.pad.setAttribute("fill",this.colors.accent),this.pad.setAttribute("stroke",this.colors.accent)):(this.pad.setAttribute("fill",this.colors.fill),this.pad.setAttribute("stroke",this.colors.mediumLight))}},down:{value:function(t){switch(this.mode){case"impulse":this.turnOn(),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(this.turnOff.bind(this),30);break;case"button":this.turnOn();break;case"aftertouch":this.position={x:h.clip(this.mouse.x/this.width,0,1),y:h.clip(1-this.mouse.y/this.height,0,1)},this.turnOn();break;case"toggle":this.flip(t)}}},bend:{value:function(t){"aftertouch"===this.mode&&(this.mouse=t||this.mouse,this.position={x:h.clip(this.mouse.x/this.width,0,1),y:h.clip(1-this.mouse.y/this.height,0,1)},this.emit("change",{state:this.state,x:this.position.x,y:this.position.y}),this.render())}},up:{value:function(){switch(this.mode){case"button":this.turnOff();break;case"aftertouch":this.turnOff(),this.position={x:h.clip(this.mouse.x/this.width,0,1),y:h.clip(1-this.mouse.y/this.height,0,1)}}}},click:{value:function(){this.down()}},move:{value:function(){this.bend()}},release:{value:function(){this.up()}},state:{get:function(){return this._state.state},set:function(t){this._state.flip(t),"aftertouch"===this.mode?this.emit("change",{state:this.state,x:this.position.x,y:this.position.y}):this.emit("change",this.state),this.render()}},flip:{value:function(t){this._state.flip(t),"aftertouch"===this.mode?this.emit("change",{state:this.state,x:this.position.x,y:this.position.y}):this.emit("change",this.state),this.render()}},turnOn:{value:function(t){this._state.on(),!1!==t&&("aftertouch"===this.mode?this.emit("change",{state:this.state,x:this.position.x,y:this.position.y}):this.emit("change",this.state)),this.render()}},turnOff:{value:function(t){this._state.off(),!1!==t&&("aftertouch"===this.mode?this.emit("change",{state:this.state,x:this.position.x,y:this.position.y}):this.emit("change",this.state)),this.render()}}}),e}(l);t.exports=c},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(17),h=function(t){function e(){r(this,e);var t=["value"],i={size:[150,50],state:!1,text:"Play"};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this._text=this.settings.text,this.settings.alternate&&(this.settings.alternateText=this.settings.alternate,console.warn("'alternate' initiator is deprecated. Use 'alternateText' instead.")),this._alternateText=this.settings.alternateText,this.mode=this.settings.alternateText?"toggle":"button",this.init(),this.render(),this.state=this.settings.state}return o(e,t),n(e,{buildFrame:{value:function(){this.element=document.createElement("div"),this.parent.appendChild(this.element),this.textElement=document.createElement("div"),this.textElement.innerHTML=this._text,this.element.appendChild(this.textElement)}},buildInterface:{value:function(){}},colorInterface:{value:function(){this.element.style.color=this.colors.dark,this.render()}},sizeInterface:{value:function(){var t=this.height/3,e=this.width/(this._text.length+2);if(t=Math.min(t,e),this.alternateText){var i=this.width/(this.alternateText.length+2);t=Math.min(t,i)}var n="width: "+this.width+"px;";n+="height: "+this.height+"px;",n+="padding: "+(this.height-t)/2+"px 0px;",n+="box-sizing: border-box;",n+="text-align: center;",n+="font-family: inherit;",n+="font-weight: 700;",n+="opacity: 1;",n+="font-size:"+t+"px;",this.textElement.style.cssText=n,this.render()}},render:{value:function(){this.state?(this.element.style.backgroundColor=this.colors.accent,this.textElement.style.color=this.colors.fill,this.alternateText?this.textElement.innerHTML=this._alternateText:this.textElement.innerHTML=this._text):(this.element.style.backgroundColor=this.colors.fill,this.textElement.style.color=this.colors.dark,this.textElement.innerHTML=this._text)}},alternateText:{get:function(){return this._alternateText},set:function(t){this.mode=t?"toggle":"button",this._alternateText=t,this.render()}},text:{get:function(){return this._text},set:function(t){this._text=t,this.sizeInterface(),this.render()}}}),e}(a);t.exports=h},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(6),h=i(16),u=function(t){function e(){r(this,e);var t=["value"],i={size:[120,25],numberOfButtons:4,active:-1};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.buttons=[],this._numberOfButtons=this.settings.numberOfButtons,this.active=this.settings.active,this.init(),this.render()}return o(e,t),n(e,{buildFrame:{value:function(){this.element=document.createElement("div"),this.parent.appendChild(this.element)}},buildInterface:{value:function(){for(var t=0;t<this._numberOfButtons;t++){var e=document.createElement("span"),i=new h(e,{mode:"toggle",component:!0},this.update.bind(this,t));this.buttons.push(i),this.element.appendChild(e)}}},sizeInterface:{value:function(){for(var t=this.width/this._numberOfButtons,e=this.height,i=0;i<this._numberOfButtons;i++)this.buttons[i].resize(t,e)}},colorInterface:{value:function(){for(var t=0;t<this._numberOfButtons;t++)this.buttons[t].colors=this.colors,this.buttons[t].render()}},update:{value:function(t){this.buttons[t].state?this.select(t):this.deselect()}},render:{value:function(){for(var t=0;t<this.buttons.length;t++)t===this.active?this.buttons[t].turnOn(!1):this.buttons[t].turnOff(!1)}},select:{value:function(t){t>=0&&t<this.buttons.length&&(this.active=t,this.emit("change",this.active),this.render())}},deselect:{value:function(){this.active=-1,this.emit("change",this.active),this.render()}},numberOfButtons:{get:function(){return this._numberOfButtons},set:function(t){this._numberOfButtons=t;for(var e=0;e<this.buttons.length;e++)this.buttons[e].destroy();this.buttons=[],this.empty(),this.buildInterface()}}}),e}(a);t.exports=u},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(6),h=i(11),u=i(5),l=function(t){function e(){r(this,e);var t=["value"],i={size:[60,30],value:0,min:0,max:2e4,step:1};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this._value=new h(this.settings.min,this.settings.max,this.settings.step,this.settings.value),this.decimalPlaces=2,this.actual=0,this.max=this._value.max,this.min=this._value.min,this.step=this._value.step,this.init(),this.render()}return o(e,t),n(e,{buildFrame:{value:function(){this.element=document.createElement("input"),this.element.type="text",this.element.addEventListener("blur",function(){this.element.style.backgroundColor=this.colors.fill,this.element.style.color=this.colors.dark,this.element.value!==this.value&&(this.value=parseFloat(this.element.value),this.render())}.bind(this)),this.element.addEventListener("keydown",function(t){(t.which<48||t.which>57)&&189!==t.which&&190!==t.which&&8!==t.which&&t.preventDefault(),13===t.which&&(this.element.blur(),this.value=this.element.value,this.emit("change",this.value),this.render())}.bind(this)),this.parent.appendChild(this.element)}},sizeInterface:{value:function(){this._minDimension=Math.min(this.width,this.height);var t="width: "+this.width+"px;";t+="height: "+this.height+"px;",t+="background-color: #e7e7e7;",t+="color: #333;",t+="font-family: arial;",t+="font-weight: 500;",t+="font-size:"+this._minDimension/2+"px;",t+="border: none;",t+="outline: none;",t+="padding: "+this._minDimension/4+"px "+this._minDimension/4+"px;",t+="box-sizing: border-box;",t+="userSelect: text;",t+="mozUserSelect: text;",t+="webkitUserSelect: text;",this.element.style.cssText+=t,this.element.value=this.value}},colorInterface:{value:function(){this.element.style.backgroundColor=this.colors.fill,this.element.style.color=this.colors.dark}},render:{value:function(){this.element.value=u.prune(this.value,this.decimalPlaces)}},click:{value:function(){this.hasMoved=!1,this.element.readOnly=!0,this.actual=this.value,this.initial={y:this.mouse.y},this.changeFactor=u.invert(this.mouse.x/this.width),console.log(this.changeFactor)}},move:{value:function(){if(this.hasMoved=!0,this.clicked){var t=this.actual-(this.mouse.y-this.initial.y)*(u.clip(this.max-this.min,0,1e3)/200)*Math.pow(this.changeFactor,2);this.value=t,this.render(),this._value.changed&&this.emit("change",this.value)}}},release:{value:function(){this.hasMoved?document.body.focus():(this.element.readOnly=!1,this.element.focus(),this.element.setSelectionRange(0,this.element.value.length),this.element.style.backgroundColor=this.colors.accent,this.element.style.color=this.colors.light)}},link:{value:function(t){var e=this;this.min=t.min,this.max=t.max,this.step=t.step,t.on("change",function(t){e.passiveUpdate(t)}),this.on("change",function(e){t.value=e}),this.value=t.value}},passiveUpdate:{value:function(t){this._value.update(t),this.render()}},value:{get:function(){return this._value.value},set:function(t){this._value.update(t),this.emit("change",this.value),this.render()}},min:{get:function(){return this._value.min},set:function(t){this._value.min=t}},max:{get:function(){return this._value.max},set:function(t){this._value.max=t}},step:{get:function(){return this._value.step},set:function(t){this._value.step=t}}}),e}(a);t.exports=l},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(6),h=function(t){function e(){r(this,e);var t=["value"],i={size:[100,30],options:["default","options"]};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this._selectedIndex=-1,this._value=!1,this._options=this.settings.options,this.init(),this.render()}return o(e,t),n(e,{buildFrame:{value:function(){this.element=document.createElement("select"),this.element.style.fontSize=this.height/2+"px",this.element.style.outline="none",this.element.style.highlight="none",this.element.style.width=this.width+"px",this.element.style.height=this.height+"px",this.boundRender=this.render.bind(this),this.element.addEventListener("change",this.boundRender),this.parent.appendChild(this.element)}},attachListeners:{value:function(){}},buildInterface:{value:function(){this.defineOptions()}},colorInterface:{value:function(){this.element.style.backgroundColor=this.colors.fill,this.element.style.color=this.colors.dark,this.element.style.border="solid 0px "+this.colors.mediumLight}},render:{value:function(){this._value=this.element.options[this.element.selectedIndex].text,this._selectedIndex=this.element.selectedIndex,this.emit("change",{value:this._value,index:this._selectedIndex})}},click:{value:function(){}},move:{value:function(){}},release:{value:function(){}},defineOptions:{value:function(t){t&&(this._options=t);for(var e=this.element.options.length-1;e>=0;e--)this.element.remove(e);for(var e=0;e<this._options.length;e++)this.element.options.add(new Option(this._options[e],e))}},value:{get:function(){return this._value},set:function(t){this._value=t;for(var e=0;e<this.element.options.length;e++)if(t===this.element.options[e].text){this.selectedIndex=e;break}}},selectedIndex:{get:function(){return this._selectedIndex},set:function(t){this._selectedIndex=t,this.element.selectedIndex=t,this.render()}},customDestroy:{value:function(){this.element.removeEventListener("change",this.boundRender)}}}),e}(a);t.exports=h},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(5),u=i(6),l=i(11),c=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),p=function(t){function e(){r(this,e);var t=["min","max","value"],i={size:[75,75],interaction:"radial",mode:"relative",min:0,max:1,step:0,value:0};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.interaction=this.settings.interaction,this._value=new l(this.settings.min,this.settings.max,this.settings.step,this.settings.value),this.position=new c.Handle(this.settings.mode,this.interaction,[0,this.width],[this.height,0]),this.init(),this.value=this._value.value,this.position.value=this._value.normalized,this.previousAngle=!1,this.emit("change",this.value)}return o(e,t),n(e,{buildInterface:{value:function(){this.background=a.create("circle"),this.screw=a.create("circle"),this.handle=a.create("path"),this.handle2=a.create("path"),this.handleFill=a.create("path"),this.handle2Fill=a.create("path"),this.handleLine=a.create("path"),this.element.appendChild(this.background),this.element.appendChild(this.handle),this.element.appendChild(this.handle2),this.element.appendChild(this.handleFill),this.element.appendChild(this.handle2Fill),this.element.appendChild(this.handleLine),this.element.appendChild(this.screw)}},sizeInterface:{value:function(){this.position.resize([0,this.width],[this.height,0]);var t={x:this.width/2,y:this.height/2},e=Math.min(this.width,this.height);this.background.setAttribute("cx",t.x),this.background.setAttribute("cy",t.y),this.background.setAttribute("r",e/2-e/40),this.screw.setAttribute("cx",t.x),this.screw.setAttribute("cy",t.y),this.screw.setAttribute("r",e/12);var i=this.value,n={start:1.5*Math.PI,end:h.clip(h.scale(i,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},s={start:2.5*Math.PI,end:h.clip(h.scale(i,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},o=a.arc(t.x,t.y,e/2-e/40,n.start,n.end),r=a.arc(t.x,t.y,e/2-e/40,s.start,s.end);this.handle.setAttribute("d",o),this.handle.setAttribute("stroke-width",e/20),this.handle.setAttribute("fill","none"),this.handle2.setAttribute("d",r),this.handle2.setAttribute("stroke-width",e/20),this.handle2.setAttribute("fill","none"),o+=" L "+t.x+" "+t.y,this.handleFill.setAttribute("d",o),this.handleFill.setAttribute("fill-opacity","0.3"),r+=" L "+t.x+" "+t.y,this.handle2Fill.setAttribute("d",r),this.handle2Fill.setAttribute("fill-opacity","0.3");var u=void 0;u=i<.5?n.end:s.end;var l=t.x+Math.cos(u)*(e/2),c=t.y+Math.sin(u)*(e/2)*-1;this.handleLine.setAttribute("d","M "+t.x+" "+t.y+" L "+l+" "+c),this.handleLine.setAttribute("stroke-width",e/20)}},colorInterface:{value:function(){this.background.setAttribute("fill",this.colors.fill),this.screw.setAttribute("fill",this.colors.accent),this.handle.setAttribute("stroke",this.colors.accent),this.handle2.setAttribute("stroke",this.colors.accent),this.handleFill.setAttribute("fill",this.colors.accent),this.handle2Fill.setAttribute("fill",this.colors.accent),this.handleLine.setAttribute("stroke",this.colors.accent)}},render:{value:function(){var t=this._value.normalized,e={x:this.width/2,y:this.height/2},i=Math.min(this.width,this.height),n={start:1.5*Math.PI,end:h.clip(h.scale(t,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},s={start:2.5*Math.PI,end:h.clip(h.scale(t,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},o=a.arc(e.x,e.y,i/2-i/40,n.start,n.end),r=a.arc(e.x,e.y,i/2-i/40,s.start,s.end);this.handle.setAttribute("d",o),this.handle2.setAttribute("d",r),o+=" L "+e.x+" "+e.y,this.handleFill.setAttribute("d",o),r+=" L "+e.x+" "+e.y,this.handle2Fill.setAttribute("d",r);var u=void 0;u=t<=.5?n.end:s.end;var l=e.x+Math.cos(u)*(i/2),c=e.y+Math.sin(u)*(i/2)*-1;this.handleLine.setAttribute("d","M "+e.x+" "+e.y+" L "+l+" "+c)}},click:{value:function(){"relative"===this.mode&&(this.previousAngle=!1),this.position.anchor=this.mouse,this.position.value=this._value.normalized,this.move()}},move:{value:function(){if(this.clicked){this.position.update(this.mouse);var t=this.position.value*Math.PI*2;t<0&&(t+=2*Math.PI),"relative"===this.mode&&!1!==this.previousAngle&&Math.abs(this.previousAngle-t)>2&&(t=this.previousAngle>3?2*Math.PI:0),this.previousAngle=t;var e=t/(2*Math.PI);this.value=this._value.updateNormal(e),"relative"===this.mode&&(this.position.value=e),this.emit("change",this._value.value),this.render()}}},release:{value:function(){}},value:{get:function(){return this._value.value},set:function(t){this._value.update(t),this.position.value=this._value.normalized,this.emit("change",this._value.value),this.render()}},min:{get:function(){return this._value.min},set:function(t){this._value.min=t}},max:{get:function(){return this._value.max},set:function(t){this._value.max=t}},step:{get:function(){return this._value.step},set:function(t){this._value.step=t}},mode:{get:function(){return this.position.mode},set:function(t){this.position.mode=t}},normalized:{get:function(){return this._value.normalized},set:function(t){this._value.updateNormal(t),this.emit("change",this.value)}}}),e}(u);t.exports=p},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(6),u=i(17),l=i(9),c=function(t){function e(){r(this,e);var t=["value","note","color"],i={size:[80,80],target:!1,mode:"button",value:0};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.note=this.settings.note,this.color=this.settings.color,this.colors={w:"#fff",b:"#666"},this.init(),this.render()}return o(e,t),n(e,{buildFrame:{value:function(){this.element=a.create("svg"),this.element.setAttribute("width",this.width),this.element.setAttribute("height",this.height),this.parent.appendChild(this.element)}},buildInterface:{value:function(){var t=this;this.pad=a.create("rect"),this.element.appendChild(this.pad),this.interactionTarget=this.pad,l.exists||(this.click=function(){t.piano.interacting=!0,t.piano.paintbrush=!t.state,t.down(t.piano.paintbrush)},this.pad.addEventListener("mouseover",function(){t.piano.interacting&&t.down(t.piano.paintbrush)}),this.move=function(){t.piano.interacting&&t.bend()},this.release=function(){t.piano.interacting=!1},this.pad.addEventListener("mouseup",function(){t.piano.interacting&&t.up()}),this.pad.addEventListener("mouseout",function(){t.piano.interacting&&t.up()}))}},sizeInterface:{value:function(){this.pad.setAttribute("x",.5),this.pad.setAttribute("y",.5),this.width>2?this.pad.setAttribute("width",this.width-1):this.pad.setAttribute("width",this.width),this.height,this.pad.setAttribute("height",this.height),this.pad.setAttribute("rx",0),this.pad.setAttribute("ry",0)}},render:{value:function(){this.state?this.pad.setAttribute("fill",this.colors.accent):this.pad.setAttribute("fill",this.colors[this.color])}}}),e}(u),p=function(t){function e(){r(this,e);var t=["value"],i={size:[500,125],lowNote:24,highNote:60,mode:"button"};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.keyPattern=["w","b","w","b","w","w","b","w","b","w","b","w"],this.paintbrush=!1,this.mode=this.settings.mode,this.range={low:this.settings.lowNote,high:this.settings.highNote},this.range.size=this.range.high-this.range.low,this.keys=[],this.toggleTo=!1,this.init(),this.render()}return o(e,t),n(e,{buildFrame:{value:function(){this.element=document.createElement("div"),this.element.style.position="relative",this.element.style.borderRadius="0px",this.element.style.display="block",this.element.style.width="100%",this.element.style.height="100%",this.parent.appendChild(this.element)}},buildInterface:{value:function(){this.keys=[];for(var t=0;t<this.range.high-this.range.low;t++){var e=document.createElement("span"),i=(t+this.range.low)%this.keyPattern.length,n=new c(e,{component:!0,note:t+this.range.low,color:this.keyPattern[i],mode:this.mode},this.keyChange.bind(this,t+this.range.low));n.piano=this,l.exists&&(n.pad.index=t,n.preClick=n.preMove=n.preRelease=function(){},n.click=n.move=n.release=function(){},n.preTouch=n.preTouchMove=n.preTouchRelease=function(){},n.touch=n.touchMove=n.touchRelease=function(){}),this.keys.push(n),this.element.appendChild(e)}l.exists&&this.addTouchListeners()}},sizeInterface:{value:function(){for(var t=0,e=[],i=0;i<this.range.high-this.range.low;i++){e.push(t);var n=(i+this.range.low)%this.keyPattern.length,s=(i+1+this.range.low)%this.keyPattern.length;i+1+this.range.low>=this.range.high?t+=1:"w"===this.keyPattern[n]&&"w"===this.keyPattern[s]?t+=1:t+=.5}for(var o=t,r=(this.width-2)/o,a=(this.height-2)/2,i=0;i<this.keys.length;i++){var h=this.keys[i].parent;h.style.position="absolute",h.style.left=e[i]*r+1+"px","w"===this.keys[i].color?(h.style.top="1px",this.keys[i].resize(r,2*a)):(h.style.zIndex=1,h.style.top="1px",this.keys[i].resize(r,1.1*a))}}},colorInterface:{value:function(){this.element.style.backgroundColor=this.colors.mediumLight;for(var t=0;t<this.keys.length;t++)this.keys[t].colors={w:this.colors.light,b:this.colors.dark,accent:this.colors.accent,border:this.colors.mediumLight},this.keys[t].colorInterface(),this.keys[t].render()}},keyChange:{value:function(t,e){var i={note:t};i.state="object"==typeof e?e.state:e,this.emit("change",i)}},render:{value:function(){}},addTouchListeners:{value:function(){var t=this;this.preClick=this.preMove=this.preRelease=function(){},this.click=this.move=this.release=function(){},this.preTouch=this.preTouchMove=this.preTouchRelease=function(){},this.touch=this.touchMove=this.touchRelease=function(){},this.currentElement=!1,this.element.addEventListener("touchstart",function(e){console.log("touchstart");var i=document.elementFromPoint(e.targetTouches[0].clientX,e.targetTouches[0].clientY),n=t.keys[i.index];t.paintbrush=!n.state,n.down(t.paintbrush),t.currentElement=i.index,e.preventDefault(),e.stopPropagation()}),this.element.addEventListener("touchmove",function(e){var i=document.elementFromPoint(e.targetTouches[0].clientX,e.targetTouches[0].clientY),n=t.keys[i.index];if(i.index!==t.currentElement){if(t.currentElement){t.keys[t.currentElement].up()}n.down(t.paintbrush)}else n.bend();t.currentElement=i.index,e.preventDefault(),e.stopPropagation()}),this.element.addEventListener("touchend",function(e){t.keys[t.currentElement].up(),t.interacting=!1,t.currentElement=!1,e.preventDefault(),e.stopPropagation()})}},setRange:{value:function(t,e){this.range.low=t,this.range.high=e,this.empty(),this.buildInterface()}},toggleKey:{value:function(t,e){this.keys[t-this.range.low].flip(e)}},toggleIndex:{value:function(t,e){this.keys[t].flip(e)}}}),e}(h);t.exports=p},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(7),u=i(6),l=i(17),c=i(25),p=i(28),f=i(9),d=function(t){function e(){r(this,e);var t=["value"],i={size:[80,80],target:!1,mode:"toggle",value:0};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.index=this.settings.index,this.row=this.settings.row,this.column=this.settings.column,this.matrix=this.settings.matrix,this.interacting=!1,this.paintbrush=!1,this.init(),this.render()}return o(e,t),n(e,{buildFrame:{value:function(){this.element=a.create("svg"),this.element.setAttribute("width",this.width),this.element.setAttribute("height",this.height),this.element.style.top="0px",this.element.style.left="0px",this.element.style.position="absolute",this.parent.appendChild(this.element)}},buildInterface:{value:function(){var t=this;this.pad=a.create("rect"),this.element.appendChild(this.pad),this.interactionTarget=this.pad,f.exists||(this.click=function(){t.matrix.interacting=!0,t.matrix.paintbrush=!t.state,t.down(t.matrix.paintbrush)},this.pad.addEventListener("mouseover",function(){t.matrix.interacting&&t.down(t.matrix.paintbrush)}),this.move=function(){},this.pad.addEventListener("mousemove",function(e){t.matrix.interacting&&(t.offset||(t.offset=h.findPosition(t.element)),t.mouse=h.locateMouse(e,t.offset),t.bend())}),this.release=function(){t.matrix.interacting=!1},this.pad.addEventListener("mouseup",function(){t.matrix.interacting&&t.up()}),this.pad.addEventListener("mouseout",function(){t.matrix.interacting&&t.up()}))}},sizeInterface:{value:function(){this.pad.setAttribute("x",1),this.pad.setAttribute("y",1),this.width>2?this.pad.setAttribute("width",this.width-2):this.pad.setAttribute("width",this.width),this.height>2?this.pad.setAttribute("height",this.height-2):this.pad.setAttribute("height",this.height),this.pad.setAttribute("fill",this.matrix.colors.fill)}},render:{value:function(){this.state?this.pad.setAttribute("fill",this.matrix.colors.accent):this.pad.setAttribute("fill",this.matrix.colors.fill)}}}),e}(l),y=function(t){function e(){r(this,e);var t=["value"],i={size:[400,200],mode:"toggle",rows:5,columns:10};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.active=-1,this.mode=this.settings.mode,this.interval=new Nexus.Interval(200,function(){},!1),this.matrix=new c(this.settings.rows,this.settings.columns),this.matrix.ui=this,this.stepper=new p(0,this.columns),this.init()}return o(e,t),n(e,{buildFrame:{value:function(){this.element=document.createElement("div"),this.element.style.position="relative",this.element.style.display="block",this.element.style.width="100%",this.element.style.height="100%",this.parent.appendChild(this.element),f.exists&&this.addTouchListeners()}},buildInterface:{value:function(){this.cells=[];for(var t=0;t<this.matrix.length;t++){var e=this.matrix.locate(t),i=document.createElement("span");i.style.position="absolute";var n=new d(i,{component:!0,index:t,row:e.row,column:e.column,mode:this.mode,matrix:this},this.keyChange.bind(this,t));f.exists&&(n.pad.index=t,n.preClick=n.preMove=n.preRelease=function(){},n.click=n.move=n.release=function(){},n.preTouch=n.preTouchMove=n.preTouchRelease=function(){},n.touch=n.touchMove=n.touchRelease=function(){}),this.cells.push(n),this.element.appendChild(i)}this.sizeInterface()}},sizeInterface:{value:function(){for(var t=this.width/this.columns,e=this.height/this.rows,i=0;i<this.cells.length;i++){var n=this.cells[i].parent;n.style.left=this.cells[i].column*t+"px",n.style.top=this.cells[i].row*e+"px",this.cells[i].resize(t,e)}}},colorInterface:{value:function(){for(var t=0;t<this.cells.length;t++)this.cells[t].render()}},update:{value:function(){var t=this;this.matrix.iterate(function(e,i,n){t.matrix.pattern[e][i]!==t.cells[n].state&&(t.matrix.pattern[e][i]>0?t.cells[n].turnOn():t.cells[n].turnOff())})}},keyChange:{value:function(t,e){var i=this.matrix.locate(t);this.matrix.pattern[i.row][i.column]=e;var n={row:i.row,column:i.column,state:e};this.emit("change",n)}},render:{value:function(){var t=this;this.stepper.value>=0&&this.matrix.iterate(function(e,i,n){i===t.stepper.value?(t.cells[n].pad.setAttribute("stroke",t.colors.mediumLight),t.cells[n].pad.setAttribute("stroke-width","1"),t.cells[n].pad.setAttribute("stroke-opacity","1")):t.cells[n].pad.setAttribute("stroke","none")})}},start:{value:function(t){this.interval.event=this.next.bind(this),t&&this.interval.ms(t),this.interval.start()}},stop:{value:function(){this.interval.stop()}},next:{value:function(){this.stepper.next(),this.emit("step",this.matrix.column(this.stepper.value).reverse()),this.render()}},addTouchListeners:{value:function(){var t=this;this.preClick=this.preMove=this.preRelease=function(){},this.click=this.move=this.release=function(){},this.preTouch=this.preTouchMove=this.preTouchRelease=function(){},this.touch=this.touchMove=this.touchRelease=function(){},this.currentElement=!1,this.element.addEventListener("touchstart",function(e){var i=document.elementFromPoint(e.targetTouches[0].clientX,e.targetTouches[0].clientY),n=t.cells[i.index];t.paintbrush=!n.state,n.down(t.paintbrush),t.currentElement=i.index,e.preventDefault(),e.stopPropagation()}),this.element.addEventListener("touchmove",function(e){var i=document.elementFromPoint(e.targetTouches[0].clientX,e.targetTouches[0].clientY),n=t.cells[i.index];if(i.index!==t.currentElement){if(t.currentElement>=0){t.cells[t.currentElement].up()}n.down(t.paintbrush)}else n.bend();t.currentElement=i.index,e.preventDefault(),e.stopPropagation()}),this.element.addEventListener("touchend",function(e){t.cells[t.currentElement].up(),t.interacting=!1,t.currentElement=!1,e.preventDefault(),e.stopPropagation()})}},rows:{get:function(){return this.matrix.rows},set:function(t){this.matrix.rows=t,this.empty(),this.buildInterface(),this.update()}},columns:{get:function(){return this.matrix.columns},set:function(t){this.matrix.columns=t,this.stepper.max=t,this.empty(),this.buildInterface(),this.update()}}}),e}(u);t.exports=y},function(t,e,i){"use strict";var n=function(t){return t&&t.__esModule?t.default:t},s=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},r=n(i(5)),a=n(i(26)),h=function(){function t(e,i){var n=this;o(this,t),this.pattern=[],this.create(e,i),this.toggle={cell:function(t,e){return n.pattern[e][t]=!n.pattern[e][t],n.ui&&n.ui.update(),n.pattern[e][t]},all:function(){n.iterate(function(t,e){n.toggle.cell(e,t)}),n.ui&&n.ui.update()},row:function(t){for(var e=0;e<n.columns;e++)n.toggle.cell(e,t);n.ui&&n.ui.update()},column:function(t){for(var e=0;e<n.rows;e++)n.toggle.cell(t,e);n.ui&&n.ui.update()}},this.set={cell:function(t,e,i){n.pattern[e][t]=i,n.ui&&n.ui.update()},all:function(t){n.pattern=t,n.ui&&n.ui.update()},row:function(t,e){n.pattern[t]=e,n.ui&&n.ui.update()},column:function(t,e){n.pattern.forEach(function(i,s){n.pattern[s][t]=e[s]}),n.ui&&n.ui.update()}},this.rotate={all:function(t){t||0===t||(t=1),(t%=n.pattern[0].length)<0&&(t=n.pattern[0].length+t);for(var e=0;e<n.rows;e++){var i=n.pattern[e].splice(n.pattern[e].length-t,t);n.pattern[e]=i.concat(n.pattern[e])}n.ui&&n.ui.update()},row:function(t,e){e||0===e||(e=1),(e%=n.pattern[0].length)<0&&(e=n.pattern[0].length+e);var i=n.pattern[t].splice(n.pattern[t].length-e,e);n.pattern[t]=i.concat(n.pattern[t]),n.ui&&n.ui.update()},column:function(t,e){e||0===e||(e=1),(e%=n.pattern.length)<0&&(e=n.pattern.length+e);var i=[];n.pattern.forEach(function(e){i.push(e[t])});var s=i.splice(i.length-e,e);i=s.concat(i),n.pattern.forEach(function(e,n){e[t]=i[n]}),n.ui&&n.ui.update()}},this.populate={all:function(t){var e=new a(t);n.iterate(function(t,i){n.pattern[t][i]=r.coin(e.next())}),n.ui&&n.ui.update()},row:function(){var t=void 0===arguments[0]?0:arguments[0],e=void 0===arguments[1]?1:arguments[1],i=new a(e);n.pattern[t].forEach(function(e,s){n.pattern[t][s]=r.coin(i.next())}),n.ui&&n.ui.update()},column:function(){var t=void 0===arguments[0]?0:arguments[0],e=void 0===arguments[1]?1:arguments[1],i=new a(e);n.pattern.forEach(function(e,s){n.pattern[s][t]=r.coin(i.next())}),n.ui&&n.ui.update()}},this.erase={all:function(){n.set.all(0)},row:function(t){n.set.row(t,0)},column:function(t){n.set.column(t,0)}}}return s(t,{create:{value:function(t,e){var i=this;this.pattern=[];for(var n=0;n<t;n++){var s=new Array(e);this.pattern.push(s)}this.iterate(function(t,e){i.pattern[t][e]=!1})}},iterate:{value:function(t,e){for(var i=0,n=0;n<this.rows;n++){e&&e(n);for(var s=0;s<this.columns;s++)t(n,s,i),i++}}},formatAsText:{value:function(){var t=this,e="";return this.iterate(function(i,n){e+=(t.pattern[i][n]?1:0)+" "},function(){e+="\n"}),e}},log:{value:function(){console.log(this.formatAsText())}},update:{value:function(t){this.pattern=t||this.pattern}},length:{get:function(){return this.rows*this.columns}},locate:{value:function(t){return{row:~~(t/this.columns),column:t%this.columns}}},indexOf:{value:function(t,e){return e+t*this.columns}},row:{value:function(t){var e=function(e){return t.apply(this,arguments)};return e.toString=function(){return t.toString()},e}(function(t){for(var e=[],i=0;i<this.columns;i++)e.push(this.pattern[t]?1:0);return e})},column:{value:function(t){var e=function(e){return t.apply(this,arguments)};return e.toString=function(){return t.toString()},e}(function(t){for(var e=[],i=0;i<this.rows;i++)e.push(this.pattern[i][t]?1:0);return e})},rows:{get:function(){return this.pattern.length},set:function(t){var e=this,i=this.pattern.slice(0);this.create(t,this.columns),this.iterate(function(t,n){i[t]&&i[t][n]&&(e.pattern[t][n]=i[t][n])})}},columns:{get:function(){return this.pattern[0].length},set:function(t){var e=this,i=this.pattern.slice(0);this.create(this.rows,t),this.iterate(function(t,n){i[t]&&i[t][n]&&(e.pattern[t][n]=i[t][n])})}}}),t}();t.exports=h},function(t,e,i){"use strict";var n=function(t){return t&&t.__esModule?t.default:t},s=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},r=n(i(5)),a=n(i(27)),h=function(){function t(){var e=void 0===arguments[0]?[0,10,20,30]:arguments[0],i=void 0===arguments[1]?"up":arguments[1],n=void 0!==arguments[2]&&arguments[2];o(this,t),this.values=e,Array.isArray(this.values)||(this.values=[this.values]),this._mode=i,this.position=n,this.drunkWalk=new a(0,this.values.length-1),this.startValues={up:0,down:this.values.length-1,drunk:~~(this.values.length/2),random:r.ri(this.values.length)},!1!==this.position?this.next=this[this._mode]:this.next=this.first}return s(t,{mode:{get:function(){return this._mode},set:function(t){if("up"!==t&&"down"!==t&&"random"!==t&&"drunk"!==t)return void console.error("The only modes currently allowed are: up, down, random, drunk");this._mode=t,this.position&&(this.next=this[this._mode])}},value:{get:function(){return this.values[this.position]},set:function(t){this.position=this.values.indexOf(t)}},first:{value:function(){return!1!==this.position?(this.next=this[this._mode],this.next()):(this.position=this.startValues[this._mode],this.next=this[this._mode],this.value)}},up:{value:function(){return this.position++,this.position%=this.values.length,this.value}},down:{value:function(){return this.position--,this.position<0&&(this.position=(this.position+this.values.length)%this.values.length),this.value}},random:{value:function(){return this.position=r.ri(0,this.values.length),this.value}},drunk:{value:function(){return this.drunkWalk.max=this.values.length,this.drunkWalk.value=this.position,this.position=this.drunkWalk.next(),this.value}}}),t}();t.exports=h},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=function(t){return t&&t.__esModule?t.default:t}(i(5)),r=function(){function t(){var e=void 0===arguments[0]?0:arguments[0],i=void 0===arguments[1]?9:arguments[1],n=void 0===arguments[2]?0:arguments[2],o=void 0===arguments[3]?1:arguments[3],r=void 0!==arguments[4]&&arguments[4];s(this,t),this.min=e,this.max=i,this.value=n,this.increment=o,this.loop=r}return n(t,{next:{value:function(){return this.value+=o.pick(-1*this.increment,this.increment),this.value>this.max&&(this.loop?this.value=this.min:this.value=this.max-this.increment),this.value<this.min&&(this.loop?this.value=this.max:this.value=this.min+this.increment),this.value}}}),t}();t.exports=r},function(t,e,i){"use strict";var n=function(t){return t&&t.__esModule?t.default:t},s=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},r=n(i(5)),a=n(i(27)),h=function(){function t(){var e=void 0===arguments[0]?0:arguments[0],i=void 0===arguments[1]?10:arguments[1],n=void 0===arguments[2]?"up":arguments[2],s=void 0!==arguments[3]&&arguments[3];o(this,t),this.min=e,this.max=i,this.value=s,this.mode=n,this.drunkWalk=new a(this.min,this.max),!1!==this.value?this.next=this[this._mode]:this.next=this.first}return s(t,{mode:{set:function(t){if("up"!==t&&"down"!==t&&"random"!==t&&"drunk"!==t)return void console.error("The only modes currently allowed are: up, down, random, drunk");this._mode=t,this.value&&(this.next=this[this._mode])},get:function(){return this._mode}},first:{value:function(){return!1!==this.value?(this.next=this[this._mode],this.next()):(this.startValues={up:this.min,down:this.max,drunk:~~r.average(this.min,this.max),random:r.ri(this.min,this.max)},this.value=this.startValues[this._mode],this.next=this[this._mode],this.value)}},up:{value:function(){return this.value++,this.value>=this.max&&(this.value=this.min),this.value}},down:{value:function(){return this.value--,this.value<this.min&&(this.value=this.max),this.value}},random:{value:function(){return this.value=r.ri(this.min,this.max),this.value}},drunk:{value:function(){return this.drunkWalk.min=this.min,this.drunkWalk.max=this.max,this.drunkWalk.value=this.value,this.value=this.drunkWalk.next(),this.value}}}),t}();t.exports=h},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(5),u=i(6),l=i(11),c=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),p=function(t){function e(){r(this,e);var t=["range"],i={size:[200,200],range:.5,mode:"absolute",speakers:[[.5,.2],[.75,.25],[.8,.5],[.75,.75],[.5,.8],[.25,.75],[.2,.5],[.25,.25]]};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.value={x:new l(0,1,0,.5),y:new l(0,1,0,.5)},this.mode=this.settings.mode,this.position={x:new c.Handle(this.mode,"horizontal",[0,this.width],[this.height,0]),y:new c.Handle(this.mode,"vertical",[0,this.width],[this.height,0])},this.position.x.value=this.value.x.normalized,this.position.y.value=this.value.y.normalized,this.speakers=this.settings.speakers,this.range=this.settings.range,this.levels=[],this.init(),this.calculateLevels(),this.render()}return o(e,t),n(e,{buildInterface:{value:function(){this.knob=a.create("circle"),this.element.appendChild(this.knob),this.speakerElements=[];for(var t=0;t<this.speakers.length;t++){var e=a.create("circle");this.element.appendChild(e),this.speakerElements.push(e)}}},sizeInterface:{value:function(){this._minDimension=Math.min(this.width,this.height),this.knobRadius={off:3*~~(this._minDimension/100)+5},this.knobRadius.on=2*this.knobRadius.off,this.knob.setAttribute("cx",this.width/2),this.knob.setAttribute("cy",this.height/2),this.knob.setAttribute("r",this.knobRadius.off);for(var t=0;t<this.speakers.length;t++){var e=this.speakerElements[t],i=this.speakers[t];e.setAttribute("cx",i[0]*this.width),e.setAttribute("cy",i[1]*this.height),e.setAttribute("r",this._minDimension/20+5),e.setAttribute("fill-opacity","0")}this.position.x.resize([0,this.width],[this.height,0]),this.position.y.resize([0,this.width],[this.height,0]),this.calculateLevels(),this.render()}},colorInterface:{value:function(){this.element.style.backgroundColor=this.colors.fill,this.knob.setAttribute("fill",this.colors.mediumLight);for(var t=0;t<this.speakers.length;t++){var e=this.speakerElements[t];e.setAttribute("fill",this.colors.accent),e.setAttribute("stroke",this.colors.accent)}}},render:{value:function(){this.knobCoordinates={x:this.value.x.normalized*this.width,y:this.height-this.value.y.normalized*this.height},this.knob.setAttribute("cx",this.knobCoordinates.x),this.knob.setAttribute("cy",this.knobCoordinates.y)}},click:{value:function(){this.position.x.anchor=this.mouse,this.position.y.anchor=this.mouse,this.move()}},move:{value:function(){this.clicked&&(this.position.x.update(this.mouse),this.position.y.update(this.mouse),this.calculateLevels(),this.emit("change",this.levels),this.render())}},release:{value:function(){this.render()}},normalized:{get:function(){return{x:this.value.x.normalized,y:this.value.y.normalized}}},calculateLevels:{value:function(){var t=this;this.value.x.updateNormal(this.position.x.value),this.value.y.updateNormal(this.position.y.value),this.levels=[],this.speakers.forEach(function(e,i){var n=h.distance(e[0]*t.width,e[1]*t.height,t.position.x.value*t.width,(1-t.position.y.value)*t.height),s=h.clip(1-n/(t.range*t.width),0,1);t.levels.push(s),t.speakerElements[i].setAttribute("fill-opacity",s)})}},moveSource:{value:function(t,e){var i={x:t*this.width,y:e*this.height};this.position.x.update(i),this.position.y.update(i),this.calculateLevels(),this.emit("change",this.levels),this.render()}},moveSpeaker:{value:function(t,e,i){this.speakers[t]=[e,i],this.speakerElements[t].setAttribute("cx",e*this.width),this.speakerElements[t].setAttribute("cy",i*this.height),this.calculateLevels(),this.emit("change",this.levels),this.render()}}}),e}(u);t.exports=p},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(5),h=i(4),u=i(6),l=function(t){function e(){r(this,e);var t=["value"],i={size:[80,80]};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this._active=!0,this.init(),this.boundUpdate=this.update.bind(this),window.DeviceOrientationEvent?this.orientationListener=window.addEventListener("deviceorientation",this.boundUpdate,!1):(this._active=!1,this.colorInterface())}return o(e,t),n(e,{buildInterface:{value:function(){this.title=h.create("text"),this.circleX=h.create("circle"),this.circleY=h.create("circle"),this.circleZ=h.create("circle"),this.barX=h.create("path"),this.barY=h.create("path"),this.barZ=h.create("path"),this.barX2=h.create("path"),this.barY2=h.create("path"),this.barZ2=h.create("path"),this.barX.setAttribute("opacity","0.8"),this.barY.setAttribute("opacity","0.8"),this.barZ.setAttribute("opacity","0.8"),this.barX2.setAttribute("opacity","0.8"),this.barY2.setAttribute("opacity","0.8"),this.barZ2.setAttribute("opacity","0.8"),this.circleX.setAttribute("cx",3*this.width/12),this.circleX.setAttribute("cy",3*this.height/4),this.circleX.setAttribute("r",this.height/10),this.circleX.setAttribute("opacity","0.4"),this.circleY.setAttribute("cx",6*this.width/12),this.circleY.setAttribute("cy",3*this.height/4),this.circleY.setAttribute("r",this.height/10),this.circleY.setAttribute("opacity","0.4"),this.circleZ.setAttribute("cx",9*this.width/12),this.circleZ.setAttribute("cy",3*this.height/4),this.circleZ.setAttribute("r",this.height/10),this.circleZ.setAttribute("opacity","0.4"),this.barX.setAttribute("stroke-width",Math.round(this.height/30)),this.barY.setAttribute("stroke-width",Math.round(this.height/30)),this.barZ.setAttribute("stroke-width",Math.round(this.height/30)),this.barX.setAttribute("fill","none"),this.barY.setAttribute("fill","none"),this.barZ.setAttribute("fill","none"),this.barX2.setAttribute("stroke-width",Math.round(this.height/30)),this.barY2.setAttribute("stroke-width",Math.round(this.height/30)),this.barZ2.setAttribute("stroke-width",Math.round(this.height/30)),this.barX2.setAttribute("fill","none"),this.barY2.setAttribute("fill","none"),this.barZ2.setAttribute("fill","none"),this.title.setAttribute("x",this.width/2),this.title.setAttribute("y",this.height/3+7),this.title.setAttribute("font-size","15px"),this.title.setAttribute("font-weight","bold"),this.title.setAttribute("letter-spacing","2px"),this.title.setAttribute("opacity","0.7"),this.title.setAttribute("text-anchor","middle"),this.title.textContent="TILT",this.element.appendChild(this.circleX),this.element.appendChild(this.circleY),this.element.appendChild(this.circleZ),this.element.appendChild(this.barX),this.element.appendChild(this.barY),this.element.appendChild(this.barZ),this.element.appendChild(this.barX2),this.element.appendChild(this.barY2),this.element.appendChild(this.barZ2),this.element.appendChild(this.title)}},colorInterface:{value:function(){this._active?(this.element.style.backgroundColor=this.colors.accent,this.circleX.setAttribute("fill",this.colors.light),this.circleY.setAttribute("fill",this.colors.light),this.circleZ.setAttribute("fill",this.colors.light),this.circleX.setAttribute("stroke",this.colors.light),this.circleY.setAttribute("stroke",this.colors.light),this.circleZ.setAttribute("stroke",this.colors.light),this.barX.setAttribute("stroke",this.colors.light),this.barY.setAttribute("stroke",this.colors.light),this.barZ.setAttribute("stroke",this.colors.light),this.barX2.setAttribute("stroke",this.colors.light),this.barY2.setAttribute("stroke",this.colors.light),this.barZ2.setAttribute("stroke",this.colors.light),this.title.setAttribute("fill",this.colors.light)):(this.element.style.backgroundColor=this.colors.fill,this.circleX.setAttribute("fill",this.colors.mediumLight),this.circleY.setAttribute("fill",this.colors.mediumLight),this.circleZ.setAttribute("fill",this.colors.mediumLight),this.circleX.setAttribute("stroke",this.colors.mediumLight),this.circleY.setAttribute("stroke",this.colors.mediumLight),this.circleZ.setAttribute("stroke",this.colors.mediumLight),this.barX.setAttribute("stroke",this.colors.mediumLight),this.barY.setAttribute("stroke",this.colors.mediumLight),this.barZ.setAttribute("stroke",this.colors.mediumLight),this.barX2.setAttribute("stroke",this.colors.mediumLight),this.barY2.setAttribute("stroke",this.colors.mediumLight),this.barZ2.setAttribute("stroke",this.colors.mediumLight),this.title.setAttribute("fill",this.colors.mediumLight))}},update:{value:function(t){if(this._active){var e=t.beta,i=t.gamma,n=t.alpha;i=a.scale(i,-90,90,0,1),e=a.scale(e,-90,90,0,1),n=a.scale(n,0,360,0,1);var s={start:1.5*Math.PI,end:a.clip(a.scale(i,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},o={start:2.5*Math.PI,end:a.clip(a.scale(i,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},r=h.arc(this.circleX.cx.baseVal.value,this.circleX.cy.baseVal.value,this.circleX.r.baseVal.value,s.start,s.end),u=h.arc(this.circleX.cx.baseVal.value,this.circleX.cy.baseVal.value,this.circleX.r.baseVal.value,o.start,o.end);this.barX.setAttribute("d",r),this.barX2.setAttribute("d",u),s={start:1.5*Math.PI,end:a.clip(a.scale(e,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},o={start:2.5*Math.PI,end:a.clip(a.scale(e,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},r=h.arc(this.circleY.cx.baseVal.value,this.circleY.cy.baseVal.value,this.circleY.r.baseVal.value,s.start,s.end),u=h.arc(this.circleY.cx.baseVal.value,this.circleY.cy.baseVal.value,this.circleY.r.baseVal.value,o.start,o.end),this.barY.setAttribute("d",r),this.barY2.setAttribute("d",u),s={start:1.5*Math.PI,end:a.clip(a.scale(n,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},o={start:2.5*Math.PI,end:a.clip(a.scale(n,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},r=h.arc(this.circleZ.cx.baseVal.value,this.circleZ.cy.baseVal.value,this.circleZ.r.baseVal.value,s.start,s.end),u=h.arc(this.circleZ.cx.baseVal.value,this.circleZ.cy.baseVal.value,this.circleZ.r.baseVal.value,o.start,o.end),this.barZ.setAttribute("d",r),this.barZ2.setAttribute("d",u),this.emit("change",{x:i,y:e,z:n})}}},click:{value:function(){window.DeviceOrientationEvent&&(this.active=!this.active)}},active:{get:function(){return this._active},set:function(t){this._active=t,this.colorInterface()}},customDestroy:{value:function(){window.removeEventListener("deviceorientation",this.boundUpdate,!1)}}}),e}(u);t.exports=l},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(7),h=i(5),u=i(6),l=i(32),c=i(9),p=function(t){function e(){var t=this;r(this,e);var i=["scale","value"],n={size:[120,20],orientation:"vertical",mode:"absolute",scale:[0,1],step:0,value:0,hasKnob:!0};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,i,n),c.exists||(this.click=function(){t.multislider.interacting=!0,t.multislider.interpolation={index:t.index,value:t.value},t.down(),t.multislider.values[t.index]=t.value},this.element.addEventListener("mouseover",function(e){if(t.multislider.interacting){if(t.offset||(t.offset=a.findPosition(t.element)),t.mouse=a.locateMouse(e,t.offset),t.down(),t.multislider.values[t.index]=t.value,t.multislider.interpolation){var i=Math.abs(t.multislider.interpolation.index-t.index);if(i>1)for(var n=Math.min(t.multislider.interpolation.index,t.index),s=Math.max(t.multislider.interpolation.index,t.index),o=t.multislider.sliders[n].value,r=t.multislider.sliders[s].value,u=n;u<s;u++){t.multislider.sliders[u].value=h.interp((u-n)/i,o,r);var l=t.multislider.sliders[u].value;t.multislider.values[u]=l,t.multislider.update(u,l)}}t.multislider.interpolation={index:t.index,value:t.value}}}),this.move=function(){},this.element.addEventListener("mousemove",function(e){t.multislider.interacting&&(t.offset||(t.offset=a.findPosition(t.element)),t.mouse=a.locateMouse(e,t.offset),t.slide(),t.multislider.values[t.index]=t.value)}),this.release=function(){t.multislider.interacting=!1,t.multislider.interpolation=!1},this.element.addEventListener("mouseup",function(){t.multislider.interacting&&(t.up(),t.multislider.interpolation=!1,t.multislider.values[t.index]=t.value)}),this.element.addEventListener("mouseout",function(){t.multislider.interacting&&(t.up(),t.multislider.values[t.index]=t.value)})),this.customStyle()}return o(e,t),n(e,{customStyle:{value:function(){this.bar.setAttribute("x",0),this.bar.setAttribute("transform","translate(0,0)"),this.bar.setAttribute("rx",0),this.bar.setAttribute("ry",0),this.bar.setAttribute("width",this.width),this.bar.setAttribute("height",this.height),this.fillbar.setAttribute("x",0),this.fillbar.setAttribute("transform","translate(0,0)"),this.fillbar.setAttribute("rx",0),this.fillbar.setAttribute("ry",0),this.fillbar.setAttribute("width",this.width),this.fillbar.setAttribute("height",this.height)}}}),e}(l),f=function(t){function e(){r(this,e);var t=["value"],i={size:[200,100],numberOfSliders:5,min:0,max:1,step:0,values:[.7,.7,.7,.7,.7]};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this._numberOfSliders=this.settings.numberOfSliders,this.values=this.settings.values,this.sliders=[],this.interacting=!1,this.init()}return o(e,t),n(e,{buildFrame:{value:function(){this.element=document.createElement("div"),this.parent.appendChild(this.element)}},buildInterface:{value:function(){var t=this.settings.min,e=this.settings.max,i=this.settings.step;this.sliders.length&&(t=this.sliders[0].min,e=this.sliders[0].max,i=this.sliders[0].step),this.sliders=[];for(var n=0;n<this._numberOfSliders;n++){var s=document.createElement("span"),o=new p(s,{scale:[t,e],step:i,mode:"absolute",orientation:"vertical",value:this.values[n],hasKnob:!1,component:!0},this.update.bind(this,n));o.multislider=this,o.index=n,c.exists&&(o.bar.index=n,o.fillbar.index=n,o.preClick=o.preMove=o.preRelease=function(){},o.click=o.move=o.release=function(){},o.preTouch=o.preTouchMove=o.preTouchRelease=function(){},o.touch=o.touchMove=o.touchRelease=function(){}),this.sliders.push(o),this.element.appendChild(s)}c.exists&&this.addTouchListeners()}},colorInterface:{value:function(){for(var t=0;t<this.sliders.length;t++)this.sliders[t].colors=this.colors,this.sliders[t].colorInterface()}},sizeInterface:{value:function(){for(var t=this.width/this.sliders.length,e=this.height,i=0;i<this.sliders.length;i++)this.sliders[i].resize(t,e),this.sliders[i].customStyle()}},update:{value:function(t,e){this.emit("change",{index:t,value:e})}},addTouchListeners:{value:function(){var t=this;this.preClick=this.preMove=this.preRelease=function(){},this.click=this.move=this.release=function(){},this.preTouch=this.preTouchMove=this.preTouchRelease=function(){},this.touch=this.touchMove=this.touchRelease=function(){},this.currentElement=!1,this.element.addEventListener("touchstart",function(e){var i=document.elementFromPoint(e.targetTouches[0].clientX,e.targetTouches[0].clientY),n=t.sliders[i.index];n.offset||(n.offset=a.findPosition(n.element)),n.mouse=a.locateMouse(e,n.offset),n.down(),t.currentElement=i.index,e.preventDefault(),e.stopPropagation()}),this.element.addEventListener("touchmove",function(e){var i=document.elementFromPoint(e.targetTouches[0].clientX,e.targetTouches[0].clientY),n=t.sliders[i.index];if(n.offset||(n.offset=a.findPosition(n.element)),n.mouse=a.locateMouse(e,n.offset),i.index!==t.currentElement){if(t.currentElement>=0){t.sliders[t.currentElement].up()}n.down()}else n.slide();t.currentElement=i.index,e.preventDefault(),e.stopPropagation()}),this.element.addEventListener("touchend",function(e){t.sliders[t.currentElement].up(),t.interacting=!1,t.currentElement=!1,e.preventDefault(),e.stopPropagation()})}},numberOfSliders:{get:function(){return this.sliders.length},set:function(t){t!==this.sliders.length&&(this.sliders.forEach(function(t){t.destroy()}),this.empty(),this._numberOfSliders=t,this.buildInterface())}},min:{get:function(){return this.sliders[0].min},set:function(t){this.sliders.forEach(function(e){e.min=t})}},max:{get:function(){return this.sliders[0].max},set:function(t){this.sliders.forEach(function(e){e.max=t})}},step:{get:function(){return this.sliders[0].step},set:function(t){this.sliders.forEach(function(e){e.step=t})}},setSlider:{value:function(t,e){this.sliders[t].value=e,this.emit("change",{index:t,value:e})}},setAllSliders:{value:function(t){var e=this;this.values=t,this.sliders.forEach(function(i,n){i.value=t[n%t.length],e.emit("change",{index:n,value:i.value})})}}}),e}(u);t.exports=f},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(6),u=i(11),l=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),c=function(t){function e(t,i,n){r(this,e),s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,t,i,n),this.orientation=this.settings.orientation,this.hasKnob=this.settings.hasKnob,this._value=new u(this.settings.scale[0],this.settings.scale[1],this.settings.step,this.settings.value),this.init(),this.position=new l.Handle(this.settings.mode,this.orientation,[0,this.width],[this.height,0]),this.position.value=this._value.normalized,this.value=this._value.value,this.emit("change",this.value)}return o(e,t),n(e,{buildInterface:{value:function(){this.bar=a.create("rect"),this.fillbar=a.create("rect"),this.knob=a.create("circle"),this.element.appendChild(this.bar),this.element.appendChild(this.fillbar),this.element.appendChild(this.knob),this.sizeInterface()}},sizeInterface:{value:function(){this.settings.orientation||(this.width<this.height?this.orientation="vertical":this.orientation="horizontal");var t=void 0,e=void 0,i=void 0,n=void 0,s=void 0,o=void 0;this.knobData={level:0,r:0},"vertical"===this.orientation?(this.thickness=this.width/2,t=this.width/2,e=0,i=this.thickness,n=this.height,this.knobData.r=.8*this.thickness,this.knobData.level=n-this.normalized*n,s="translate("+-1*this.thickness/2+",0)",o=i/2):(this.thickness=this.height/2,t=0,e=this.height/2,i=this.width,n=this.thickness,this.knobData.r=.8*this.thickness,this.knobData.level=this.normalized*i,s="translate(0,"+-1*this.thickness/2+")",o=n/2),this.bar.setAttribute("x",t),this.bar.setAttribute("y",e),this.bar.setAttribute("transform",s),this.bar.setAttribute("rx",o),this.bar.setAttribute("ry",o),this.bar.setAttribute("width",i),this.bar.setAttribute("height",n),"vertical"===this.orientation?(this.fillbar.setAttribute("x",t),this.fillbar.setAttribute("y",this.knobData.level),this.fillbar.setAttribute("width",i),this.fillbar.setAttribute("height",n-this.knobData.level)):(this.fillbar.setAttribute("x",0),this.fillbar.setAttribute("y",e),this.fillbar.setAttribute("width",this.knobData.level),this.fillbar.setAttribute("height",n)),this.fillbar.setAttribute("transform",s),this.fillbar.setAttribute("rx",o),this.fillbar.setAttribute("ry",o),"vertical"===this.orientation?(this.knob.setAttribute("cx",t),this.knob.setAttribute("cy",this.knobData.level)):(this.knob.setAttribute("cx",this.knobData.level),this.knob.setAttribute("cy",e)),this.knob.setAttribute("r",this.knobData.r),this.position&&this.position.resize([0,this.width],[this.height,0])}},colorInterface:{value:function(){this.bar.setAttribute("fill",this.colors.fill),this.fillbar.setAttribute("fill",this.colors.accent),this.knob.setAttribute("fill",this.colors.accent),this.hasKnob||this.knob.setAttribute("fill","none")}},render:{value:function(){this.clicked||(this.knobData.r=.75*this.thickness),this.knob.setAttribute("r",this.knobData.r),"vertical"===this.orientation?(this.knobData.level=this._value.normalized*this.height,this.knob.setAttribute("cy",this.height-this.knobData.level),this.fillbar.setAttribute("y",this.height-this.knobData.level),this.fillbar.setAttribute("height",this.knobData.level)):(this.knobData.level=this._value.normalized*this.width,this.knob.setAttribute("cx",this.knobData.level),this.fillbar.setAttribute("x",0),this.fillbar.setAttribute("width",this.knobData.level))}},down:{value:function(){this.clicked=!0,this.knobData.r=.9*this.thickness,this.position.anchor=this.mouse,this.slide()}},slide:{value:function(){this.clicked&&(this.position.update(this.mouse),this.value=this._value.updateNormal(this.position.value),this.emit("change",this.value))}},up:{value:function(){this.clicked=!1,this.render()}},normalized:{get:function(){return this._value.normalized}},value:{get:function(){return this._value.value},set:function(t){this._value.update(t),this.position.value=this._value.normalized,this.render()}},min:{get:function(){return this._value.min},set:function(t){this._value.min=t}},max:{get:function(){return this._value.max},set:function(t){this._value.max=t}},step:{get:function(){return this._value.step},set:function(t){this._value.step=t}},mode:{get:function(){return this.position.mode},set:function(t){this.position.mode=t}}}),e}(h);t.exports=c},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),h=i(5),u=i(6),l=i(11),c=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),p=function(t){function e(){r(this,e);var t=["scale","value"],i={size:[120,20],orientation:"horizontal",mode:"relative",scale:[-1,1],step:0,value:0,hasKnob:!0};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.orientation=this.settings.orientation,this.mode=this.settings.mode,this.hasKnob=this.settings.hasKnob,this.step=this.settings.step,this._value=new l(this.settings.scale[0],this.settings.scale[1],this.settings.step,this.settings.value),this.init(),this.position=new c.Handle(this.mode,this.orientation,[0,this.width],[this.height,0]),this.position.value=this._value.normalized,this.value=this._value.value,this.emit("change",this.value)}return o(e,t),n(e,{buildInterface:{value:function(){this.bar=a.create("rect"),this.knob=a.create("circle"),this.element.appendChild(this.bar),this.element.appendChild(this.knob)}},sizeInterface:{value:function(){this.position&&this.position.resize([0,this.width],[this.height,0]),this.width<this.height?this.orientation="vertical":this.orientation="horizontal";var t=void 0,e=void 0,i=void 0,n=void 0,s=void 0,o=void 0;this.knobData={level:0,r:0},"vertical"===this.orientation?(this.thickness=this.width/2,t=this.width/2,e=0,i=this.thickness,n=this.height,this.knobData.r=.8*this.thickness,this.knobData.level=n-this.knobData.r-this.normalized*(n-2*this.knobData.r),s="translate("+-1*this.thickness/2+",0)",o=i/2):(this.thickness=this.height/2,t=0,e=this.height/2,i=this.width,n=this.thickness,this.knobData.r=.8*this.thickness,this.knobData.level=this.normalized*(i-2*this.knobData.r)+this.knobData.r,s="translate(0,"+-1*this.thickness/2+")",o=n/2),this.bar.setAttribute("x",t),this.bar.setAttribute("y",e),this.bar.setAttribute("transform",s),this.bar.setAttribute("rx",o),this.bar.setAttribute("ry",o),this.bar.setAttribute("width",i),this.bar.setAttribute("height",n),"vertical"===this.orientation?(this.knob.setAttribute("cx",t),this.knob.setAttribute("cy",this.knobData.level)):(this.knob.setAttribute("cx",this.knobData.level),this.knob.setAttribute("cy",e)),this.knob.setAttribute("r",this.knobData.r)}},colorInterface:{value:function(){this.bar.setAttribute("fill",this.colors.fill),this.knob.setAttribute("fill",this.colors.accent),this.hasKnob||this.knob.setAttribute("fill","transparent")}},render:{value:function(){this.clicked||(this.knobData.r=.75*this.thickness),this.knob.setAttribute("r",this.knobData.r),"vertical"===this.orientation?(this.knobData.level=this.knobData.r+this._value.normalized*(this.height-2*this.knobData.r),this.knob.setAttribute("cy",this.height-this.knobData.level)):(this.knobData.level=this._value.normalized*(this.width-2*this.knobData.r)+this.knobData.r,this.knob.setAttribute("cx",this.knobData.level))}},click:{value:function(){this.knobData.r=.9*this.thickness,this.position.anchor=this.mouse,this.move()}},move:{value:function(){this.clicked&&(this.position.update(this.mouse),this.value=this._value.updateNormal(this.position.value),this.emit("change",{value:this.value,L:Math.pow(h.scale(this.value,-1,1,1,0),2),R:Math.pow(h.scale(this.value,-1,1,0,1),2)}))}},release:{value:function(){this.render()}},value:{get:function(){return this._value.value},set:function(t){this._value.update(t),this.position.value=this._value.normalized,this.emit("change",{value:this.value,L:Math.pow(h.scale(this.value,-1,1,1,0),2),R:Math.pow(h.scale(this.value,-1,1,0,1),2)}),this.render()}},normalized:{get:function(){return this._value.normalized}}}),e}(u);t.exports=p},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(5),h=i(4),u=i(6),l=function(t,e){this.x=t.x,this.y=t.y,this.envelope=e,this.element=h.create("circle"),this.element.setAttribute("fill",this.envelope.colors.accent),this.envelope.element.appendChild(this.element),this.resize=function(){var t=2+~~(Math.min(this.envelope.width,this.envelope.height)/50);this.element.setAttribute("r",t)},this.move=function(t,e){if(this.x=t||0===t?t:this.x,this.y=e||0===e?e:this.y,this.envelope.nodes.indexOf(this)>=0){var i=this.envelope.nodes.indexOf(this)-1,n=this.envelope.nodes.indexOf(this)+1,s=this.envelope.nodes[i],o=this.envelope.nodes[n],r=i>=0?s.x:0,a=n<this.envelope.nodes.length?o.x:1;this.x<r&&(this.x=r),this.x>a&&(this.x=a)}this.location=this.getCoordinates(),this.element.setAttribute("cx",this.location.x),this.element.setAttribute("cy",this.location.y)},this.getCoordinates=function(){return{x:this.x*this.envelope.width,y:(1-this.y)*this.envelope.height}},this.move(this.x,this.y,!0),this.resize(),this.destroy=function(){this.envelope.element.removeChild(this.element),this.envelope.nodes.splice(this.envelope.nodes.indexOf(this),1)}},c=function(t){function e(){r(this,e);var t=["value"],i={size:[300,150],points:[{x:.1,y:.4},{x:.35,y:.6},{x:.65,y:.2},{x:.9,y:.4}]};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.points=this.settings.points,this.nodes=[],this.selected=!1,this.init()}return o(e,t),n(e,{buildInterface:{value:function(){var t=this;this.points.forEach(function(e){var i=new l(e,t);t.nodes.push(i)}),this.sortPoints(),this.line=h.create("polyline"),this.line.setAttribute("stroke-width",2),this.line.setAttribute("fill","none"),this.element.appendChild(this.line),this.fill=h.create("polyline"),this.fill.setAttribute("fill-opacity","0.2"),this.element.appendChild(this.fill)}},sizeInterface:{value:function(){for(var t=0;t<this.nodes.length;t++)this.nodes[t].resize(),this.nodes[t].move();this.render()}},colorInterface:{value:function(){var t=this;this.element.style.backgroundColor=this.colors.fill,this.line.setAttribute("stroke",this.colors.accent),this.fill.setAttribute("fill",this.colors.accent),this.nodes.forEach(function(e){e.element.setAttribute("fill",t.colors.accent)})}},render:{value:function(){this.calculatePath()}},calculatePoints:{value:function(){var t=this;this.points=[],this.nodes.forEach(function(e){t.points.push({x:e.x,y:e.y})})}},calculatePath:{value:function(){var t="0 "+this.nodes[0].location.y+", ";this.nodes.forEach(function(e){t+=e.location.x+" "+e.location.y+", "}),t+=this.width+" "+this.nodes[this.nodes.length-1].location.y,this.line.setAttribute("points",t),t+=", "+this.width+" "+this.height+", ",t+="0 "+this.height,this.fill.setAttribute("points",t)}},click:{value:function(){this.hasMoved=!1,this.selected=this.findNearestNode(),this.nodes[this.selected].move(this.mouse.x/this.width,1-this.mouse.y/this.height),this.scaleNode(this.selected),this.calculatePoints(),this.emit("change",this.points),this.render()}},move:{value:function(){this.clicked&&(this.mouse.x=a.clip(this.mouse.x,0,this.width),this.hasMoved=!0,this.nodes[this.selected].move(this.mouse.x/this.width,1-this.mouse.y/this.height),this.scaleNode(this.selected),this.calculatePoints(),this.emit("change",this.points),this.render())}},release:{value:function(){this.hasMoved||this.nodes[this.selected].destroy(),this.calculatePoints(),this.emit("change",this.points),this.render(),this.selected=null}},findNearestNode:{value:function(){for(var t=null,e=1e4,i=this.mouse.x/this.width,n=1-this.mouse.y/this.height,s=this.nodes,o=0;o<s.length;o++){var r=Math.sqrt(Math.pow(s[o].x-i,2)+Math.pow(s[o].y-n,2));r<e&&(e=r,t=o,i>s[o].x)}return e>.07&&(t=this.getIndexFromX(this.mouse.x/this.width),this.nodes.splice(t,0,new l({x:this.mouse.x/this.width,y:1-this.mouse.y/this.height},this)),this.hasMoved=!0),t}},getIndexFromX:{value:function(t){var e=this,i=0;return this.nodes.forEach(function(n,s){e.nodes[s].x<=t&&(i=s+1)}),i}},scaleNode:{value:function(t){var e=a.clip(this.nodes[t].x,0,1),i=a.clip(this.nodes[t].y,0,1);this.nodes[t].move(e,i)}},sortPoints:{value:function(){this.nodes.sort(function(t,e){return t.x>e.x})}},addPoint:{value:function(t,e){var i=this.nodes.length;this.sortPoints();for(var n=0;n<this.nodes.length;n++)if(t<this.nodes[n].x){i=n;break}this.nodes.splice(i,0,new l({x:t,y:e},this)),this.scaleNode(i),this.calculatePoints(),this.emit("change",this.points),this.render()}},scan:{value:function(t){var e=this.getIndexFromX(t),i=e-1;i<0&&(i=0),e>=this.nodes.length&&(e=this.nodes.length-1);var n=this.nodes[i],s=this.nodes[e],o=a.scale(t,n.x,s.x,0,1),r=a.interp(o,n.y,s.y);return this.emit("scan",r),r}},movePoint:{value:function(t,e,i){this.nodes[t].move(e,i),this.scaleNode(t),this.calculatePoints(),this.emit("change",this.points),this.render()}},adjustPoint:{value:function(t,e,i){this.nodes[t].move(this.nodes[t].x+e,this.nodes[t].y+i),this.scaleNode(t),this.calculatePoints(),this.emit("change",this.points),this.render()}},destroyPoint:{value:function(t){this.nodes[t].destroy(),this.calculatePoints(),this.emit("change",this.points),this.render()}},setPoints:{value:function(t){for(var e=this;this.nodes.length;)this.nodes[0].destroy();t.forEach(function(t){e.addPoint(t.x,t.y)}),this.calculatePoints(),this.emit("change",this.points),this.render()}}}),e}(u);t.exports=c},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(7),h=i(6),u=i(1).context,l=function(t){function e(){r(this,e);var t=["scale","value"],i={size:[300,150]};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.context=u(),this.analyser=this.context.createAnalyser(),this.analyser.fftSize=2048,this.bufferLength=this.analyser.frequencyBinCount,this.dataArray=new Uint8Array(this.bufferLength),this.active=!0,this.source=!1,this.init()}return o(e,t),n(e,{buildFrame:{value:function(){this.canvas=new a.SmartCanvas(this.parent),this.element=this.canvas.element}},sizeInterface:{value:function(){this.canvas.resize(this.width,this.height)}},colorInterface:{value:function(){this.canvas.element.style.backgroundColor=this.colors.fill}},render:{value:function(){if(this.active&&requestAnimationFrame(this.render.bind(this)),this.analyser.getByteFrequencyData(this.dataArray),this.canvas.context.fillStyle=this.colors.fill,this.canvas.context.fillRect(0,0,this.canvas.element.width,this.canvas.element.height),this.source&&this.dataArray)for(var t=this.canvas.element.width/this.bufferLength,e=void 0,i=0,n=this.canvas.element.width/50,s=0;s<this.bufferLength;s+=n)e=Math.max.apply(null,this.dataArray.subarray(s,s+n)),e/=255,e*=this.canvas.element.height,this.canvas.context.fillStyle=this.colors.accent,this.canvas.context.fillRect(i,this.canvas.element.height-e,t*n,e),i+=t*n}},connect:{value:function(t){this.source&&this.disconnect(),this.source=t,this.source.connect(this.analyser),this.render()}},disconnect:{value:function(){this.source.disconnect(this.analyser),this.source=null}},click:{value:function(){this.active=!this.active,this.render()}},customDestroy:{value:function(){this.active=!1}}}),e}(h);t.exports=l},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(7),h=i(5),u=i(6),l=i(1).context,c=function(t){function e(){r(this,e);var t=["scale","value"],i={size:[30,100]};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.context=l(),this.channels=2,this.splitter=this.context.createChannelSplitter(this.channels),this.analysers=[];for(var n=0;n<this.channels;n++){var o=this.context.createAnalyser();this.splitter.connect(o,n),o.fftSize=1024,o.smoothingTimeConstant=1,this.analysers.push(o)}this.bufferLength=this.analysers[0].frequencyBinCount,this.dataArray=new Float32Array(this.bufferLength),this.active=!0,this.db=-1/0,this.init(),this.meterWidth=this.canvas.element.width/this.channels,this.render()}return o(e,t),n(e,{buildFrame:{value:function(){this.canvas=new a.SmartCanvas(this.parent),this.element=this.canvas.element}},sizeInterface:{value:function(){this.canvas.resize(this.width,this.height)}},colorInterface:{value:function(){this.canvas.element.style.backgroundColor=this.colors.fill}},render:{value:function(){this.active&&requestAnimationFrame(this.render.bind(this)),this.canvas.context.fillStyle=this.colors.fill,this.canvas.context.fillRect(0,0,this.canvas.element.width,this.canvas.element.height);for(var t=0;t<this.analysers.length;t++){if(this.source){this.analysers[t].getFloatTimeDomainData(this.dataArray);for(var e=0,i=0;i<this.dataArray.length;i++)e+=this.dataArray[i]*this.dataArray[i];e=Math.sqrt(e/this.dataArray.length),this.db=20*Math.log10(e)}else this.db>-200&&this.db!==-1/0?this.db-=1:this.db=-1/0;if(this.db>-70){var n=h.normalize(this.db,-70,5),s=n*n,o=h.scale(s,0,1,this.element.height,0);this.canvas.context.fillStyle=this.colors.accent,this.canvas.context.fillRect(this.meterWidth*t,o,this.meterWidth,this.canvas.element.height-o)}}}},connect:{value:function(t,e){this.source&&this.disconnect(),e?this.channels=e:t.channelCount?this.channels=t.channelCount:this.channels=2,this.meterWidth=this.canvas.element.width/this.channels,this.source=t,this.source.connect(this.splitter)}},disconnect:{value:function(){this.source.disconnect(this.splitter),this.source=!1,this.meterWidth=this.canvas.element.width/this.channels}},click:{value:function(){this.active=!this.active,this.render()}},customDestroy:{value:function(){this.active=!1}}}),e}(u);t.exports=c},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function t(e,i,n){var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s&&s.writable)return s.value;var r=s.get;if(void 0!==r)return r.call(n)},o=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(7),h=i(6),u=i(1).context,l=function(t){function e(){r(this,e);var t=["scale","value"],i={size:[300,150]};s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,t,i),this.context=u(),this.analyser=this.context.createAnalyser(),this.analyser.fftSize=2048,this.bufferLength=this.analyser.frequencyBinCount,this.dataArray=new Uint8Array(this.bufferLength),this.analyser.getByteTimeDomainData(this.dataArray),this.active=!0,this.source=!1,this.init(),this.render()}return o(e,t),n(e,{buildFrame:{value:function(){this.canvas=new a.SmartCanvas(this.parent),this.element=this.canvas.element}},sizeInterface:{value:function(){this.canvas.resize(this.width,this.height)}},colorInterface:{value:function(){this.canvas.element.style.backgroundColor=this.colors.fill}},render:{value:function(){if(this.active&&requestAnimationFrame(this.render.bind(this)),this.analyser.getByteTimeDomainData(this.dataArray),this.canvas.context.fillStyle=this.colors.fill,this.canvas.context.fillRect(0,0,this.canvas.element.width,this.canvas.element.height),this.canvas.context.lineWidth=~~(this.height/100+2),this.canvas.context.strokeStyle=this.colors.accent,this.canvas.context.beginPath(),this.source)for(var t=1*this.canvas.element.width/this.bufferLength,e=0,i=0;i<this.bufferLength;i++){var n=this.dataArray[i]/128,s=n*this.canvas.element.height/2;0===i?this.canvas.context.moveTo(e,s):this.canvas.context.lineTo(e,s),e+=t}else this.canvas.context.moveTo(0,this.canvas.element.height/2),this.canvas.context.lineTo(this.canvas.element.width,this.canvas.element.height/2);this.canvas.context.stroke()}},connect:{value:function(t){this.source&&this.disconnect(),this.source=t,this.source.connect(this.analyser),this.render()}},disconnect:{value:function(){this.source&&(this.source.disconnect(this.analyser),this.source=null)}},click:{value:function(){this.active=!this.active,this.render()}},customDestroy:{value:function(){this.active=!1}}}),e}(h);t.exports=l},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=function(t){return t&&t.__esModule?t:{default:t}}(i(39)),r=function(t){return t&&t.__esModule?t.default:t}(i(7)),a=i(1).colors,h=function(){function t(e,i){s(this,t),this.meta={},this.meta.target=e,this.meta.parent=r.parseElement(e),this.meta.colors={},i?(this.meta.attribute=i.attribute||"nexus-ui",this.meta.title=i.name||!1,this.meta.open=i.open||!1):(this.meta.attribute="nexus-ui",this.meta.title=!1,this.meta.open=!1);var n=a();this.meta.colors.accent=n.accent,this.meta.colors.fill=n.fill,this.meta.colors.light=n.light,this.meta.colors.dark=n.dark,this.meta.colors.mediumLight=n.mediumLight,this.meta.colors.mediumDark=n.mediumDark,this.buildInterface(),this.colorInterface()}return n(t,{buildInterface:{value:function(){var t=this;for(this.meta.parent.style.boxSizing="border-box",this.meta.parent.style.userSelect="none",this.meta.parent.style.mozUserSelect="none",this.meta.parent.style.webkitUserSelect="none",this.meta.contents=document.createElement("div");this.meta.parent.childNodes.length>0;)this.meta.contents.appendChild(this.meta.parent.childNodes[0]);this.meta.contents.style.padding="0px",this.meta.contents.style.boxSizing="border-box",this.meta.title&&(this.meta.titleBar=document.createElement("div"),this.meta.titleBar.innerHTML=this.meta.title,this.meta.titleBar.style.fontFamily="arial",this.meta.titleBar.style.position="relative",this.meta.titleBar.style.color="#888",this.meta.titleBar.style.padding="7px",this.meta.titleBar.style.fontSize="12px",this.meta.button=document.createElement("div"),this.meta.button.style.position="absolute",this.meta.button.style.top="5px",this.meta.button.style.right="5px",this.meta.button.innerHTML="-",this.meta.button.style.padding="0px 5px 2px",this.meta.button.style.lineHeight="12px",this.meta.button.style.fontSize="15px",this.meta.button.style.cursor="pointer",this.meta.button.addEventListener("mouseover",function(){t.meta.button.style.backgroundColor=t.meta.colors.mediumDark}),this.meta.button.addEventListener("mouseleave",function(){t.meta.button.style.backgroundColor=t.meta.colors.mediumLight}),this.meta.button.addEventListener("click",function(){t.meta.open?t.hide():t.show()}),this.meta.titleBar.appendChild(this.meta.button),this.meta.parent.appendChild(this.meta.titleBar)),this.meta.parent.appendChild(this.meta.contents);var e=o.section(this.meta.target,this.meta.attribute);for(var i in e)this[i]=e[i]}},colorInterface:{value:function(){this.meta.title&&(this.meta.button.style.backgroundColor=this.meta.colors.mediumLight,this.meta.button.style.border="solid 0px "+this.meta.colors.fill,this.meta.parent.style.border="solid 1px "+this.meta.colors.mediumLight,this.meta.parent.style.backgroundColor=this.meta.colors.light,this.meta.titleBar.style.backgroundColor=this.meta.colors.fill)}},show:{value:function(){this.meta.contents.style.display="block",this.meta.open=!0}},hide:{value:function(){this.meta.contents.style.display="none",this.meta.open=!1}},colorize:{value:function(t,e){for(var i in this)this[i].colorize&&this[i].colorize(t,e);this.meta.colors[t]=e,this.colorInterface()}},empty:{value:function(){for(var t in this)this[t].destroy&&this[t].destroy()}}}),t}();t.exports=h},function(t,e,i){"use strict";var n=function(t){return t&&t.__esModule?t.default:t};Object.defineProperty(e,"__esModule",{value:!0});var s=n(i(7)),o=n(i(2)),r=function(t,e){var i=t.type;return e[i]?e[i]++:e[i]=1,i+e[i]},a=function(t,e,i){i=i||{};for(var n=0;n<t.attributes.length;n++){var s=t.attributes[n];i[s.nodeName]=s.nodeValue}e=e[0].toUpperCase()+e.slice(1);var r=new o[e](t,i);return r.id=t.id,r},h=function(t,e){e=e||"nexus-ui";for(var i={},n=s.parseElement(t),h={},u=n.getElementsByTagName("*"),l=[],c=0;c<u.length;c++)l.push(u[c]);for(var c=0;c<l.length;c++){var p=l[c].getAttribute(e);if(p){var f=!1;for(var d in o)p.toLowerCase()===d.toLowerCase()&&(f=d);console.log(f);var y=a(l[c],f);if(y.id)h[y.id]=y;else{h[r(y,i)]=y}}}return h},u=function(t,e,i){var n=document.createElement("div");return i=i||{},e=e?s.parseElement(e):document.body,e.appendChild(n),i.target=n,i.size&&(n.style.width=i.size[0]+"px",n.style.height=i.size[1]+"px"),a(n,t,i)};e.element=a,e.section=h,e.add=u},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=function(t){return t&&t.__esModule?t.default:t}(i(5)),r=function(){function t(){s(this,t),this.scale=[],this.mode={output:"frequency",input:"step"},this.etmajor=[261.62558,293.664764,329.627563,349.228241,391.995422,440,493.883301,523.25116],this.root=o.mtof(60),this.createScale(0,2,4,5,7,9,11)}return n(t,{note:{value:function(t,e){return"frequency"===this.mode.output?this.frequency(t,e):"ratio"===this.mode.output?this.ratio(t,e):"MIDI"===this.mode.output?this.MIDI(t,e):this.frequency(t,e)}},frequency:{value:function(t,e){"midi"!==this.mode.input&&"MIDI"!==this.mode.input||(this.stepIn+=60);var i=Math.floor(t/this.scale.length);e&&(i+=e);for(var n=t%this.scale.length;n<0;)n+=this.scale.length;var s=this.scale[n],o=this.root*s;return o*=Math.pow(2,i),o=Math.floor(1e11*o)/1e11}},ratio:{value:function(t,e){"midi"!==this.mode.input&&"MIDI"!==this.mode.input||(this.stepIn+=60);var i=Math.floor(t/this.scale.length);e&&(i+=e);var n=t%this.scale.length,s=Math.pow(2,i)*this.scale[n];return s=Math.floor(1e11*s)/1e11,s}},MIDI:{value:function(t,e){var i=this.frequency(t,e),n=69+12*Math.log(i/440)/Math.log(2);return n=Math.floor(1e9*n)/1e9}},createScale:{value:function(){for(var t=[],e=0;e<arguments.length;e++)t.push(o.mtof(60+arguments[e]));this.loadScaleFromFrequencies(t)}},createJIScale:{value:function(){this.scale=[];for(var t=0;t<arguments.length;t++)this.scale.push(arguments[t])}},loadScaleFromFrequencies:{value:function(t){this.scale=[];for(var e=0;e<t.length-1;e++)this.scale.push(t[e]/t[0])}},loadScale:{value:function(t){var e=this.scales[t].frequencies;this.loadScaleFromFrequencies(e)}},search:{value:function(t){var e=[];for(var i in this.scales)-1!==i.toLowerCase().indexOf(t.toLowerCase())&&e.push(i);return e}},chord:{value:function(t){for(var e=[],i=0;i<t.length;i++)e.push(this.note(t[i]));return e}}}),t}();t.exports=r},function(t,e){"use strict";var i=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),n=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},s=function(){function t(){for(var e=arguments.length,i=Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];var o=void 0===arguments[0]?3:arguments[0];n(this,t),o<0&&(o=1),this.length=o,this.onVals=i,this.array=new Array(o).fill(0),i.length>0&&this.on.apply(this,i)}return i(t,{select:{value:function(t){return this.array.fill(0),this.array[t]=1,this.array}},flip:{value:function(){for(var t=arguments.length,e=Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=this.array;return e.length>0?e.forEach(function(t){t>n.length-1?console.warn("Warning: AnonRadio["+t+"] does not exist"):n[t]=n[t]?0:1}):n.forEach(function(t,e,i){i[e]=t?0:1}),n}},on:{value:function(){for(var t=arguments.length,e=Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=this.array;return e.length>0?e.forEach(function(t){t>n.length-1?console.warn("Warning: AnonRadio["+t+"] exceeds size of object"):(1===n[t]&&console.warn("Warning: AnonRadio["+t+"] was already on."),n[t]=1)}):n.fill(1),n}},off:{value:function(){for(var t=arguments.length,e=Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=this.array;return e.length>0?e.forEach(function(t){n[t]=0}):n.fill(0),n}}}),t}();t.exports=s},function(t,e,i){var n=i(43);t.exports=n,"undefined"!=typeof window&&(window.WAAClock=n)},function(t,e,i){(function(e){var i={toleranceLate:.1,toleranceEarly:.001},n=function(t,e,i){this.clock=t,this.func=i,this._cleared=!1,this.toleranceLate=t.toleranceLate,this.toleranceEarly=t.toleranceEarly,this._latestTime=null,this._earliestTime=null,this.deadline=null,this.repeatTime=null,this.schedule(e)};n.prototype.clear=function(){return this.clock._removeEvent(this),this._cleared=!0,this},n.prototype.repeat=function(t){if(0===t)throw new Error("delay cannot be 0");return this.repeatTime=t,this.clock._hasEvent(this)||this.schedule(this.deadline+this.repeatTime),this},n.prototype.tolerance=function(t){return"number"==typeof t.late&&(this.toleranceLate=t.late),"number"==typeof t.early&&(this.toleranceEarly=t.early),this._refreshEarlyLateDates(),this.clock._hasEvent(this)&&(this.clock._removeEvent(this),this.clock._insertEvent(this)),this},n.prototype.isRepeated=function(){return null!==this.repeatTime},n.prototype.schedule=function(t){this._cleared=!1,this.deadline=t,this._refreshEarlyLateDates(),this.clock.context.currentTime>=this._earliestTime?this._execute():this.clock._hasEvent(this)?(this.clock._removeEvent(this),this.clock._insertEvent(this)):this.clock._insertEvent(this)},n.prototype.timeStretch=function(t,e){this.isRepeated()&&(this.repeatTime=this.repeatTime*e);var i=t+e*(this.deadline-t);if(this.isRepeated())for(;this.clock.context.currentTime>=i-this.toleranceEarly;)i+=this.repeatTime;this.schedule(i)},n.prototype._execute=function(){!1!==this.clock._started&&(this.clock._removeEvent(this),this.clock.context.currentTime<this._latestTime?this.func(this):(this.onexpired&&this.onexpired(this),console.warn("event expired")),this.clock._hasEvent(this)||!this.isRepeated()||this._cleared||this.schedule(this.deadline+this.repeatTime))},n.prototype._refreshEarlyLateDates=function(){this._latestTime=this.deadline+this.toleranceLate,this._earliestTime=this.deadline-this.toleranceEarly};var s=t.exports=function(t,e){e=e||{},this.tickMethod=e.tickMethod||"ScriptProcessorNode",this.toleranceEarly=e.toleranceEarly||i.toleranceEarly,this.toleranceLate=e.toleranceLate||i.toleranceLate,this.context=t,this._events=[],this._started=!1};s.prototype.setTimeout=function(t,e){return this._createEvent(t,this._absTime(e))},s.prototype.callbackAtTime=function(t,e){return this._createEvent(t,e)},s.prototype.timeStretch=function(t,e,i){return e.forEach(function(e){e.timeStretch(t,i)}),e},s.prototype.start=function(){if(!1===this._started){var t=this;if(this._started=!0,this._events=[],"ScriptProcessorNode"===this.tickMethod){this._clockNode=this.context.createScriptProcessor(256,1,1),this._clockNode.connect(this.context.destination),this._clockNode.onaudioprocess=function(){e.nextTick(function(){t._tick()})}}else if("manual"!==this.tickMethod)throw new Error("invalid tickMethod "+this.tickMethod)}},s.prototype.stop=function(){!0===this._started&&(this._started=!1,this._clockNode.disconnect())},s.prototype._tick=function(){for(var t=this._events.shift();t&&t._earliestTime<=this.context.currentTime;)t._execute(),t=this._events.shift();t&&this._events.unshift(t)},s.prototype._createEvent=function(t,e){return new n(this,e,t)},s.prototype._insertEvent=function(t){this._events.splice(this._indexByTime(t._earliestTime),0,t)},s.prototype._removeEvent=function(t){var e=this._events.indexOf(t);-1!==e&&this._events.splice(e,1)},s.prototype._hasEvent=function(t){return-1!==this._events.indexOf(t)},s.prototype._indexByTime=function(t){for(var e,i=0,n=this._events.length;i<n;)e=Math.floor((i+n)/2),this._events[e]._earliestTime<t?i=e+1:n=e;return i},s.prototype._absTime=function(t){return t+this.context.currentTime},s.prototype._relTime=function(t){return t-this.context.currentTime}}).call(e,i(44))},function(t,e){function i(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function s(t){if(l===setTimeout)return setTimeout(t,0);if((l===i||!l)&&setTimeout)return l=setTimeout,setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function o(t){if(c===clearTimeout)return clearTimeout(t);if((c===n||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(t);try{return c(t)}catch(e){try{return c.call(null,t)}catch(e){return c.call(this,t)}}}function r(){y&&f&&(y=!1,f.length?d=f.concat(d):m=-1,d.length&&a())}function a(){if(!y){var t=s(r);y=!0;for(var e=d.length;e;){for(f=d,d=[];++m<e;)f&&f[m].run();m=-1,e=d.length}f=null,y=!1,o(t)}}function h(t,e){this.fun=t,this.array=e}function u(){}var l,c,p=t.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:i}catch(t){l=i}try{c="function"==typeof clearTimeout?clearTimeout:n}catch(t){c=n}}();var f,d=[],y=!1,m=-1;p.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];d.push(new h(t,e)),1!==d.length||y||s(a)},h.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=u,p.addListener=u,p.once=u,p.off=u,p.removeListener=u,p.removeAllListeners=u,p.emit=u,p.prependListener=u,p.prependOnceListener=u,p.listeners=function(t){return[]},p.binding=function(t){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(t){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(1).clock,r=function(){function t(e,i,n){s(this,t),this.rate=e,this.on=n,this.clock=o(),this.pattern=[1],this.index=0,this.event=i||function(){},this.on&&this.start()}return n(t,{_event:{value:function(t){this.event(t),this.index++}},stop:{value:function(){this.on=!1,this.interval.clear()}},start:{value:function(){this.on=!0,this.interval=this.clock.callbackAtTime(this._event.bind(this),this.clock.context.currentTime).repeat(this.rate/1e3).tolerance({early:.1,late:1})}},ms:{value:function(t){if(this.on){var e=t/this.rate;this.rate=t,this.clock.timeStretch(this.clock.context.currentTime,[this.interval],e)}else this.rate=t}}}),t}();t.exports=r}])})},function(t,e,i){var n,s;!function(i){"use strict";function o(){if(o.prototype._singleton)throw new Error("WebMidi is a singleton, it cannot be instantiated directly.");o.prototype._singleton=this,this._inputs=[],this._outputs=[],this._userHandlers={},this._stateChangeQueue=[],this._processingStateChange=!1,this._midiInterfaceEvents=["connected","disconnected"],this._notes=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],this._semitones={C:0,D:2,E:4,F:5,G:7,A:9,B:11},Object.defineProperties(this,{MIDI_SYSTEM_MESSAGES:{value:{sysex:240,timecode:241,songposition:242,songselect:243,tuningrequest:246,sysexend:247,clock:248,start:250,continue:251,stop:252,activesensing:254,reset:255,midimessage:0,unknownsystemmessage:-1},writable:!1,enumerable:!0,configurable:!1},MIDI_CHANNEL_MESSAGES:{value:{noteoff:8,noteon:9,keyaftertouch:10,controlchange:11,channelmode:11,programchange:12,channelaftertouch:13,pitchbend:14},writable:!1,enumerable:!0,configurable:!1},MIDI_REGISTERED_PARAMETER:{value:{pitchbendrange:[0,0],channelfinetuning:[0,1],channelcoarsetuning:[0,2],tuningprogram:[0,3],tuningbank:[0,4],modulationrange:[0,5],azimuthangle:[61,0],elevationangle:[61,1],gain:[61,2],distanceratio:[61,3],maximumdistance:[61,4],maximumdistancegain:[61,5],referencedistanceratio:[61,6],panspreadangle:[61,7],rollangle:[61,8]},writable:!1,enumerable:!0,configurable:!1},MIDI_CONTROL_CHANGE_MESSAGES:{value:{bankselectcoarse:0,modulationwheelcoarse:1,breathcontrollercoarse:2,footcontrollercoarse:4,portamentotimecoarse:5,dataentrycoarse:6,volumecoarse:7,balancecoarse:8,pancoarse:10,expressioncoarse:11,effectcontrol1coarse:12,effectcontrol2coarse:13,generalpurposeslider1:16,generalpurposeslider2:17,generalpurposeslider3:18,generalpurposeslider4:19,bankselectfine:32,modulationwheelfine:33,breathcontrollerfine:34,footcontrollerfine:36,portamentotimefine:37,dataentryfine:38,volumefine:39,balancefine:40,panfine:42,expressionfine:43,effectcontrol1fine:44,effectcontrol2fine:45,holdpedal:64,portamento:65,sustenutopedal:66,softpedal:67,legatopedal:68,hold2pedal:69,soundvariation:70,resonance:71,soundreleasetime:72,soundattacktime:73,brightness:74,soundcontrol6:75,soundcontrol7:76,soundcontrol8:77,soundcontrol9:78,soundcontrol10:79,generalpurposebutton1:80,generalpurposebutton2:81,generalpurposebutton3:82,generalpurposebutton4:83,reverblevel:91,tremololevel:92,choruslevel:93,celestelevel:94,phaserlevel:95,databuttonincrement:96,databuttondecrement:97,nonregisteredparametercoarse:98,nonregisteredparameterfine:99,registeredparametercoarse:100,registeredparameterfine:101},writable:!1,enumerable:!0,configurable:!1},MIDI_CHANNEL_MODE_MESSAGES:{value:{allsoundoff:120,resetallcontrollers:121,localcontrol:122,allnotesoff:123,omnimodeoff:124,omnimodeon:125,monomodeon:126,polymodeon:127},writable:!1,enumerable:!0,configurable:!1},octaveOffset:{value:0,writable:!0,enumerable:!0,configurable:!1}}),Object.defineProperties(this,{supported:{enumerable:!0,get:function(){return"requestMIDIAccess"in navigator}},enabled:{enumerable:!0,get:function(){return void 0!==this.interface}.bind(this)},inputs:{enumerable:!0,get:function(){return this._inputs}.bind(this)},outputs:{enumerable:!0,get:function(){return this._outputs}.bind(this)},sysexEnabled:{enumerable:!0,get:function(){return!(!this.interface||!this.interface.sysexEnabled)}.bind(this)},time:{enumerable:!0,get:function(){return performance.now()}}})}function r(t){var e=this;this._userHandlers={channel:{},system:{}},this._midiInput=t,Object.defineProperties(this,{connection:{enumerable:!0,get:function(){return e._midiInput.connection}},id:{enumerable:!0,get:function(){return e._midiInput.id}},manufacturer:{enumerable:!0,get:function(){return e._midiInput.manufacturer}},name:{enumerable:!0,get:function(){return e._midiInput.name}},state:{enumerable:!0,get:function(){return e._midiInput.state}},type:{enumerable:!0,get:function(){return e._midiInput.type}}}),this._initializeUserHandlers(),this._midiInput.onmidimessage=this._onMidiMessage.bind(this)}function a(t){var e=this;this._midiOutput=t,Object.defineProperties(this,{connection:{enumerable:!0,get:function(){return e._midiOutput.connection}},id:{enumerable:!0,get:function(){return e._midiOutput.id}},manufacturer:{enumerable:!0,get:function(){return e._midiOutput.manufacturer}},name:{enumerable:!0,get:function(){return e._midiOutput.name}},state:{enumerable:!0,get:function(){return e._midiOutput.state}},type:{enumerable:!0,get:function(){return e._midiOutput.type}}})}var h=new o;o.prototype.enable=function(t,e){return this.enabled?void 0:this.supported?void navigator.requestMIDIAccess({sysex:e}).then(function(e){function i(){clearTimeout(n),this._updateInputsAndOutputs(),this.interface.onstatechange=this._onInterfaceStateChange.bind(this),"function"==typeof t&&t.call(this),s.forEach(function(t){this._onInterfaceStateChange(t)}.bind(this))}var n,s=[],o=[];this.interface=e,this._resetInterfaceUserHandlers(),this.interface.onstatechange=function(t){s.push(t)};for(var r=e.inputs.values(),a=r.next();a&&!a.done;a=r.next())o.push(a.value.open());for(var h=e.outputs.values(),u=h.next();u&&!u.done;u=h.next())o.push(u.value.open());n=setTimeout(i.bind(this),200),Promise&&Promise.all(o).catch(function(t){}).then(i.bind(this))}.bind(this),function(e){"function"==typeof t&&t.call(this,e)}.bind(this)):void("function"==typeof t&&t(new Error("The Web MIDI API is not supported by your browser.")))},o.prototype.disable=function(){if(!this.supported)throw new Error("The Web MIDI API is not supported by your browser.");this.interface&&(this.interface.onstatechange=void 0),this.interface=void 0,this._inputs=[],this._outputs=[],this._resetInterfaceUserHandlers()},o.prototype.addListener=function(t,e){if(!this.enabled)throw new Error("WebMidi must be enabled before adding event listeners.");if("function"!=typeof e)throw new TypeError("The 'listener' parameter must be a function.");if(!(this._midiInterfaceEvents.indexOf(t)>=0))throw new TypeError("The specified event type is not supported.");return this._userHandlers[t].push(e),this},o.prototype.hasListener=function(t,e){if(!this.enabled)throw new Error("WebMidi must be enabled before checking event listeners.");if("function"!=typeof e)throw new TypeError("The 'listener' parameter must be a function.");if(!(this._midiInterfaceEvents.indexOf(t)>=0))throw new TypeError("The specified event type is not supported.");for(var i=0;i<this._userHandlers[t].length;i++)if(this._userHandlers[t][i]===e)return!0;return!1},o.prototype.removeListener=function(t,e){if(!this.enabled)throw new Error("WebMidi must be enabled before removing event listeners.");if(void 0!==e&&"function"!=typeof e)throw new TypeError("The 'listener' parameter must be a function.");if(this._midiInterfaceEvents.indexOf(t)>=0)if(e)for(var i=0;i<this._userHandlers[t].length;i++)this._userHandlers[t][i]===e&&this._userHandlers[t].splice(i,1);else this._userHandlers[t]=[];else{if(void 0!==t)throw new TypeError("The specified event type is not supported.");this._resetInterfaceUserHandlers()}return this},o.prototype.toMIDIChannels=function(t){var e;return e="all"===t||void 0===t?["all"]:Array.isArray(t)?t:[t],e.indexOf("all")>-1&&(e=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),e.map(function(t){return parseInt(t)}).filter(function(t){return t>=1&&16>=t})},o.prototype.getInputById=function(t){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var e=0;e<this.inputs.length;e++)if(this.inputs[e].id===t)return this.inputs[e];return!1},o.prototype.getOutputById=function(t){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var e=0;e<this.outputs.length;e++)if(this.outputs[e].id===t)return this.outputs[e];return!1},o.prototype.getInputByName=function(t){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var e=0;e<this.inputs.length;e++)if(~this.inputs[e].name.indexOf(t))return this.inputs[e];return!1},o.prototype.getOctave=function(t){return null!=t&&t>=0&&127>=t?Math.floor(Math.floor(t)/12-1)+Math.floor(h.octaveOffset):void 0},o.prototype.getOutputByName=function(t){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var e=0;e<this.outputs.length;e++)if(~this.outputs[e].name.indexOf(t))return this.outputs[e];return!1},o.prototype.guessNoteNumber=function(t){var e=!1;if(t&&t.toFixed&&t>=0&&127>=t?e=Math.round(t):parseInt(t)>=0&&parseInt(t)<=127?e=parseInt(t):("string"==typeof t||t instanceof String)&&(e=this.noteNameToNumber(t)),!1===e)throw new Error("Invalid input value ("+t+").");return e},o.prototype.noteNameToNumber=function(t){"string"!=typeof t&&(t="");var e=t.match(/([CDEFGAB])(#{0,2}|b{0,2})(-?\d+)/i);if(!e)throw new RangeError("Invalid note name.");var i=h._semitones[e[1].toUpperCase()],n=parseInt(e[3]),s=12*(n+1-Math.floor(h.octaveOffset))+i;if(e[2].toLowerCase().indexOf("b")>-1?s-=e[2].length:e[2].toLowerCase().indexOf("#")>-1&&(s+=e[2].length),0>s||s>127)throw new RangeError("Invalid note name or note outside valid range.");return s},o.prototype._updateInputsAndOutputs=function(){this._updateInputs(),this._updateOutputs()},o.prototype._updateInputs=function(){for(var t=0;t<this._inputs.length;t++){for(var e=!0,i=this.interface.inputs.values(),n=i.next();n&&!n.done;n=i.next())if(this._inputs[t]._midiInput===n.value){e=!1;break}e&&this._inputs.splice(t,1)}this.interface&&this.interface.inputs.forEach(function(t){for(var e=!0,i=0;i<this._inputs.length;i++)this._inputs[i]._midiInput===t&&(e=!1);e&&this._inputs.push(new r(t))}.bind(this))},o.prototype._updateOutputs=function(){for(var t=0;t<this._outputs.length;t++){for(var e=!0,i=this.interface.outputs.values(),n=i.next();n&&!n.done;n=i.next())if(this._outputs[t]._midiOutput===n.value){e=!1;break}e&&this._outputs.splice(t,1)}this.interface&&this.interface.outputs.forEach(function(t){for(var e=!0,i=0;i<this._outputs.length;i++)this._outputs[i]._midiOutput===t&&(e=!1);e&&this._outputs.push(new a(t))}.bind(this))},o.prototype._onInterfaceStateChange=function(t){this._updateInputsAndOutputs();var e={timestamp:t.timeStamp,type:t.port.state};this.interface&&"connected"===t.port.state?"output"===t.port.type?e.port=this.getOutputById(t.port.id):"input"===t.port.type&&(e.port=this.getInputById(t.port.id)):e.port={connection:"closed",id:t.port.id,manufacturer:t.port.manufacturer,name:t.port.name,state:t.port.state,type:t.port.type},this._userHandlers[t.port.state].forEach(function(t){t(e)})},o.prototype._resetInterfaceUserHandlers=function(){for(var t=0;t<this._midiInterfaceEvents.length;t++)this._userHandlers[this._midiInterfaceEvents[t]]=[]},r.prototype.addListener=function(t,e,i){var n=this;if(void 0===e&&(e="all"),Array.isArray(e)||(e=[e]),e.forEach(function(t){if("all"!==t&&!(t>=1&&16>=t))throw new RangeError("The 'channel' parameter is invalid.")}),"function"!=typeof i)throw new TypeError("The 'listener' parameter must be a function.");if(void 0!==h.MIDI_SYSTEM_MESSAGES[t])this._userHandlers.system[t]||(this._userHandlers.system[t]=[]),this._userHandlers.system[t].push(i);else{if(void 0===h.MIDI_CHANNEL_MESSAGES[t])throw new TypeError("The specified event type is not supported.");if(e.indexOf("all")>-1){e=[];for(var s=1;16>=s;s++)e.push(s)}this._userHandlers.channel[t]||(this._userHandlers.channel[t]=[]),e.forEach(function(e){n._userHandlers.channel[t][e]||(n._userHandlers.channel[t][e]=[]),n._userHandlers.channel[t][e].push(i)})}return this},r.prototype.on=r.prototype.addListener,r.prototype.hasListener=function(t,e,i){var n=this;if("function"!=typeof i)throw new TypeError("The 'listener' parameter must be a function.");if(void 0===e&&(e="all"),e.constructor!==Array&&(e=[e]),void 0!==h.MIDI_SYSTEM_MESSAGES[t]){for(var s=0;s<this._userHandlers.system[t].length;s++)if(this._userHandlers.system[t][s]===i)return!0}else if(void 0!==h.MIDI_CHANNEL_MESSAGES[t]){if(e.indexOf("all")>-1){e=[];for(var o=1;16>=o;o++)e.push(o)}return!!this._userHandlers.channel[t]&&e.every(function(e){var s=n._userHandlers.channel[t][e];return s&&s.indexOf(i)>-1})}return!1},r.prototype.removeListener=function(t,e,i){var n=this;if(void 0!==i&&"function"!=typeof i)throw new TypeError("The 'listener' parameter must be a function.");if(void 0===e&&(e="all"),e.constructor!==Array&&(e=[e]),void 0!==h.MIDI_SYSTEM_MESSAGES[t])if(void 0===i)this._userHandlers.system[t]=[];else for(var s=0;s<this._userHandlers.system[t].length;s++)this._userHandlers.system[t][s]===i&&this._userHandlers.system[t].splice(s,1);else if(void 0!==h.MIDI_CHANNEL_MESSAGES[t]){if(e.indexOf("all")>-1){e=[];for(var o=1;16>=o;o++)e.push(o)}if(!this._userHandlers.channel[t])return this;e.forEach(function(e){var s=n._userHandlers.channel[t][e];if(s)if(void 0===i)n._userHandlers.channel[t][e]=[];else for(var o=0;o<s.length;o++)s[o]===i&&s.splice(o,1)})}else{if(void 0!==t)throw new TypeError("The specified event type is not supported.");this._initializeUserHandlers()}return this},r.prototype._initializeUserHandlers=function(){for(var t in h.MIDI_CHANNEL_MESSAGES)h.MIDI_CHANNEL_MESSAGES.hasOwnProperty(t)&&(this._userHandlers.channel[t]={});for(var e in h.MIDI_SYSTEM_MESSAGES)h.MIDI_SYSTEM_MESSAGES.hasOwnProperty(e)&&(this._userHandlers.system[e]=[])},r.prototype._onMidiMessage=function(t){if(this._userHandlers.system.midimessage.length>0){var e={target:this,data:t.data,timestamp:t.timeStamp,type:"midimessage"};this._userHandlers.system.midimessage.forEach(function(t){t(e)})}t.data[0]<240?this._parseChannelEvent(t):t.data[0]<=255&&this._parseSystemEvent(t)},r.prototype._parseChannelEvent=function(t){var e,i,n=t.data[0]>>4,s=1+(15&t.data[0]);t.data.length>1&&(e=t.data[1],i=t.data.length>2?t.data[2]:void 0);var o={target:this,data:t.data,timestamp:t.timeStamp,channel:s};n===h.MIDI_CHANNEL_MESSAGES.noteoff||n===h.MIDI_CHANNEL_MESSAGES.noteon&&0===i?(o.type="noteoff",o.note={number:e,name:h._notes[e%12],octave:h.getOctave(e)},o.velocity=i/127,o.rawVelocity=i):n===h.MIDI_CHANNEL_MESSAGES.noteon?(o.type="noteon",o.note={number:e,name:h._notes[e%12],octave:h.getOctave(e)},o.velocity=i/127,o.rawVelocity=i):n===h.MIDI_CHANNEL_MESSAGES.keyaftertouch?(o.type="keyaftertouch",o.note={number:e,name:h._notes[e%12],octave:h.getOctave(e)},o.value=i/127):n===h.MIDI_CHANNEL_MESSAGES.controlchange&&e>=0&&119>=e?(o.type="controlchange",o.controller={number:e,name:this.getCcNameByNumber(e)},o.value=i):n===h.MIDI_CHANNEL_MESSAGES.channelmode&&e>=120&&127>=e?(o.type="channelmode",o.controller={number:e,name:this.getChannelModeByNumber(e)},o.value=i):n===h.MIDI_CHANNEL_MESSAGES.programchange?(o.type="programchange",o.value=e):n===h.MIDI_CHANNEL_MESSAGES.channelaftertouch?(o.type="channelaftertouch",o.value=e/127):n===h.MIDI_CHANNEL_MESSAGES.pitchbend?(o.type="pitchbend",o.value=((i<<7)+e-8192)/8192):o.type="unknownchannelmessage",this._userHandlers.channel[o.type]&&this._userHandlers.channel[o.type][s]&&this._userHandlers.channel[o.type][s].forEach(function(t){t(o)})},r.prototype.getCcNameByNumber=function(t){if(!((t=Math.floor(t))>=0&&119>=t))throw new RangeError("The control change number must be between 0 and 119.");for(var e in h.MIDI_CONTROL_CHANGE_MESSAGES)if(h.MIDI_CONTROL_CHANGE_MESSAGES.hasOwnProperty(e)&&t===h.MIDI_CONTROL_CHANGE_MESSAGES[e])return e},r.prototype.getChannelModeByNumber=function(t){if(!((t=Math.floor(t))>=120&&status<=127))throw new RangeError("The control change number must be between 120 and 127.");for(var e in h.MIDI_CHANNEL_MODE_MESSAGES)if(h.MIDI_CHANNEL_MODE_MESSAGES.hasOwnProperty(e)&&t===h.MIDI_CHANNEL_MODE_MESSAGES[e])return e},r.prototype._parseSystemEvent=function(t){var e=t.data[0],i={target:this,data:t.data,timestamp:t.timeStamp};e===h.MIDI_SYSTEM_MESSAGES.sysex?i.type="sysex":e===h.MIDI_SYSTEM_MESSAGES.timecode?i.type="timecode":e===h.MIDI_SYSTEM_MESSAGES.songposition?i.type="songposition":e===h.MIDI_SYSTEM_MESSAGES.songselect?(i.type="songselect",i.song=t.data[1]):e===h.MIDI_SYSTEM_MESSAGES.tuningrequest?i.type="tuningrequest":e===h.MIDI_SYSTEM_MESSAGES.clock?i.type="clock":e===h.MIDI_SYSTEM_MESSAGES.start?i.type="start":e===h.MIDI_SYSTEM_MESSAGES.continue?i.type="continue":e===h.MIDI_SYSTEM_MESSAGES.stop?i.type="stop":e===h.MIDI_SYSTEM_MESSAGES.activesensing?i.type="activesensing":e===h.MIDI_SYSTEM_MESSAGES.reset?i.type="reset":i.type="unknownsystemmessage",this._userHandlers.system[i.type]&&this._userHandlers.system[i.type].forEach(function(t){t(i)})},a.prototype.send=function(t,e,i){if(!(t>=128&&255>=t))throw new RangeError("The status byte must be an integer between 128 (0x80) and 255 (0xFF).");void 0===e&&(e=[]),Array.isArray(e)||(e=[e]);var n=[];return e.forEach(function(t,e){var i=Math.floor(t);if(!(i>=0&&255>=i))throw new RangeError("Data bytes must be integers between 0 (0x00) and 255 (0xFF).");n.push(i)}),this._midiOutput.send([t].concat(n),parseFloat(i)||0),this},a.prototype.sendSysex=function(t,e,i){if(!h.sysexEnabled)throw new Error("Sysex message support must first be activated.");return i=i||{},t=[].concat(t),e.forEach(function(t){if(0>t||t>127)throw new RangeError("The data bytes of a sysex message must be integers between 0 (0x00) and 127 (0x7F).")}),e=t.concat(e,h.MIDI_SYSTEM_MESSAGES.sysexend),this.send(h.MIDI_SYSTEM_MESSAGES.sysex,e,this._parseTimeParameter(i.time)),this},a.prototype.sendTimecodeQuarterFrame=function(t,e){return e=e||{},this.send(h.MIDI_SYSTEM_MESSAGES.timecode,t,this._parseTimeParameter(e.time)),this},a.prototype.sendSongPosition=function(t,e){t=Math.floor(t)||0,e=e||{};var i=t>>7&127,n=127&t;return this.send(h.MIDI_SYSTEM_MESSAGES.songposition,[i,n],this._parseTimeParameter(e.time)),this},a.prototype.sendSongSelect=function(t,e){if(t=Math.floor(t),e=e||{},!(t>=0&&127>=t))throw new RangeError("The song number must be between 0 and 127.");return this.send(h.MIDI_SYSTEM_MESSAGES.songselect,[t],this._parseTimeParameter(e.time)),this},a.prototype.sendTuningRequest=function(t){return t=t||{},this.send(h.MIDI_SYSTEM_MESSAGES.tuningrequest,void 0,this._parseTimeParameter(t.time)),this},a.prototype.sendClock=function(t){return t=t||{},this.send(h.MIDI_SYSTEM_MESSAGES.clock,void 0,this._parseTimeParameter(t.time)),this},a.prototype.sendStart=function(t){return t=t||{},this.send(h.MIDI_SYSTEM_MESSAGES.start,void 0,this._parseTimeParameter(t.time)),this},a.prototype.sendContinue=function(t){return t=t||{},this.send(h.MIDI_SYSTEM_MESSAGES.continue,void 0,this._parseTimeParameter(t.time)),this},a.prototype.sendStop=function(t){return t=t||{},this.send(h.MIDI_SYSTEM_MESSAGES.stop,void 0,this._parseTimeParameter(t.time)),this},a.prototype.sendActiveSensing=function(t){return t=t||{},this.send(h.MIDI_SYSTEM_MESSAGES.activesensing,[],this._parseTimeParameter(t.time)),this},a.prototype.sendReset=function(t){return t=t||{},this.send(h.MIDI_SYSTEM_MESSAGES.reset,void 0,this._parseTimeParameter(t.time)),this},a.prototype.stopNote=function(t,e,i){if("all"===t)return this.sendChannelMode("allnotesoff",0,e,i);var n=64;return i=i||{},i.rawVelocity?!isNaN(i.velocity)&&i.velocity>=0&&i.velocity<=127&&(n=i.velocity):!isNaN(i.velocity)&&i.velocity>=0&&i.velocity<=1&&(n=127*i.velocity),this._convertNoteToArray(t).forEach(function(t){h.toMIDIChannels(e).forEach(function(e){this.send((h.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(e-1),[t,Math.round(n)],this._parseTimeParameter(i.time))}.bind(this))}.bind(this)),this},a.prototype.playNote=function(t,e,i){var n=64;if(i=i||{},i.rawVelocity?!isNaN(i.velocity)&&i.velocity>=0&&i.velocity<=127&&(n=i.velocity):!isNaN(i.velocity)&&i.velocity>=0&&i.velocity<=1&&(n=127*i.velocity),i.time=this._parseTimeParameter(i.time),this._convertNoteToArray(t).forEach(function(t){h.toMIDIChannels(e).forEach(function(e){this.send((h.MIDI_CHANNEL_MESSAGES.noteon<<4)+(e-1),[t,Math.round(n)],i.time)}.bind(this))}.bind(this)),!isNaN(i.duration)){i.duration<=0&&(i.duration=0);var s=64;i.rawVelocity?!isNaN(i.release)&&i.release>=0&&i.release<=127&&(s=i.release):!isNaN(i.release)&&i.release>=0&&i.release<=1&&(s=127*i.release),this._convertNoteToArray(t).forEach(function(t){h.toMIDIChannels(e).forEach(function(e){this.send((h.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(e-1),[t,Math.round(s)],(i.time||h.time)+i.duration)}.bind(this))}.bind(this))}return this},a.prototype.sendKeyAftertouch=function(t,e,i,n){var s=this;if(n=n||{},1>e||e>16)throw new RangeError("The channel must be between 1 and 16.");(isNaN(i)||0>i||i>1)&&(i=.5);var o=Math.round(127*i);return this._convertNoteToArray(t).forEach(function(t){h.toMIDIChannels(e).forEach(function(e){s.send((h.MIDI_CHANNEL_MESSAGES.keyaftertouch<<4)+(e-1),[t,o],s._parseTimeParameter(n.time))})}),this},a.prototype.sendControlChange=function(t,e,i,n){if(n=n||{},"string"==typeof t){if(!(t=h.MIDI_CONTROL_CHANGE_MESSAGES[t]))throw new TypeError("Invalid controller name.")}else if(!((t=Math.floor(t))>=0&&119>=t))throw new RangeError("Controller numbers must be between 0 and 119.");if(!((e=Math.floor(e)||0)>=0&&127>=e))throw new RangeError("Controller value must be between 0 and 127.");return h.toMIDIChannels(i).forEach(function(i){this.send((h.MIDI_CHANNEL_MESSAGES.controlchange<<4)+(i-1),[t,e],this._parseTimeParameter(n.time))}.bind(this)),this},a.prototype._selectRegisteredParameter=function(t,e,i){var n=this;if(t[0]=Math.floor(t[0]),!(t[0]>=0&&t[0]<=127))throw new RangeError("The control65 value must be between 0 and 127");if(t[1]=Math.floor(t[1]),!(t[1]>=0&&t[1]<=127))throw new RangeError("The control64 value must be between 0 and 127");return h.toMIDIChannels(e).forEach(function(s){n.sendControlChange(101,t[0],e,{time:i}),n.sendControlChange(100,t[1],e,{time:i})}),this},a.prototype._selectNonRegisteredParameter=function(t,e,i){var n=this;if(t[0]=Math.floor(t[0]),!(t[0]>=0&&t[0]<=127))throw new RangeError("The control63 value must be between 0 and 127");if(t[1]=Math.floor(t[1]),!(t[1]>=0&&t[1]<=127))throw new RangeError("The control62 value must be between 0 and 127");return h.toMIDIChannels(e).forEach(function(s){n.sendControlChange(99,t[0],e,{time:i}),n.sendControlChange(98,t[1],e,{time:i})}),this},a.prototype._setCurrentRegisteredParameter=function(t,e,i){var n=this;if(t=[].concat(t),t[0]=Math.floor(t[0]),!(t[0]>=0&&t[0]<=127))throw new RangeError("The msb value must be between 0 and 127");return h.toMIDIChannels(e).forEach(function(s){n.sendControlChange(6,t[0],e,{time:i})}),t[1]=Math.floor(t[1]),t[1]>=0&&t[1]<=127&&h.toMIDIChannels(e).forEach(function(s){n.sendControlChange(38,t[1],e,{time:i})}),this},a.prototype._deselectRegisteredParameter=function(t,e){var i=this;return h.toMIDIChannels(t).forEach(function(n){i.sendControlChange(101,127,t,{time:e}),i.sendControlChange(100,127,t,{time:e})}),this},a.prototype.setRegisteredParameter=function(t,e,i,n){var s=this;if(n=n||{},!Array.isArray(t)){if(!h.MIDI_REGISTERED_PARAMETER[t])throw new Error("The specified parameter is not available.");t=h.MIDI_REGISTERED_PARAMETER[t]}return h.toMIDIChannels(i).forEach(function(o){s._selectRegisteredParameter(t,i,n.time),s._setCurrentRegisteredParameter(e,i,n.time),s._deselectRegisteredParameter(i,n.time)}),this},a.prototype.setNonRegisteredParameter=function(t,e,i,n){var s=this;if(n=n||{},!(t[0]>=0&&t[0]<=127&&t[1]>=0&&t[1]<=127))throw new Error("Position 0 and 1 of the 2-position parameter array must both be between 0 and 127.");return e=[].concat(e),h.toMIDIChannels(i).forEach(function(o){s._selectNonRegisteredParameter(t,i,n.time),s._setCurrentRegisteredParameter(e,i,n.time),s._deselectRegisteredParameter(i,n.time)}),this},a.prototype.incrementRegisteredParameter=function(t,e,i){var n=this;if(i=i||{},!Array.isArray(t)){if(!h.MIDI_REGISTERED_PARAMETER[t])throw new Error("The specified parameter is not available.");t=h.MIDI_REGISTERED_PARAMETER[t]}return h.toMIDIChannels(e).forEach(function(s){n._selectRegisteredParameter(t,e,i.time),n.sendControlChange(96,0,e,{time:i.time}),n._deselectRegisteredParameter(e,i.time)}),this},a.prototype.decrementRegisteredParameter=function(t,e,i){if(i=i||{},!Array.isArray(t)){if(!h.MIDI_REGISTERED_PARAMETER[t])throw new TypeError("The specified parameter is not available.");t=h.MIDI_REGISTERED_PARAMETER[t]}return h.toMIDIChannels(e).forEach(function(n){this._selectRegisteredParameter(t,e,i.time),this.sendControlChange(97,0,e,{time:i.time}),this._deselectRegisteredParameter(e,i.time)}.bind(this)),this},a.prototype.setPitchBendRange=function(t,e,i,n){var s=this;if(n=n||{},!((t=Math.floor(t)||0)>=0&&127>=t))throw new RangeError("The semitones value must be between 0 and 127");if(!((e=Math.floor(e)||0)>=0&&127>=e))throw new RangeError("The cents value must be between 0 and 127");return h.toMIDIChannels(i).forEach(function(o){s.setRegisteredParameter("pitchbendrange",[t,e],i,{time:n.time})}),this},a.prototype.setModulationRange=function(t,e,i,n){var s=this;if(n=n||{},!((t=Math.floor(t)||0)>=0&&127>=t))throw new RangeError("The semitones value must be between 0 and 127");if(!((e=Math.floor(e)||0)>=0&&127>=e))throw new RangeError("The cents value must be between 0 and 127");return h.toMIDIChannels(i).forEach(function(o){s.setRegisteredParameter("modulationrange",[t,e],i,{time:n.time})}),this},a.prototype.setMasterTuning=function(t,e,i){var n=this;if(i=i||{},-65>=(t=parseFloat(t)||0)||t>=64)throw new RangeError("The value must be a decimal number larger than -65 and smaller than 64.");var s=Math.floor(t)+64,o=t-Math.floor(t);o=Math.round((o+1)/2*16383);var r=o>>7&127,a=127&o;return h.toMIDIChannels(e).forEach(function(t){n.setRegisteredParameter("channelcoarsetuning",s,e,{time:i.time}),n.setRegisteredParameter("channelfinetuning",[r,a],e,{time:i.time})}),this},a.prototype.setTuningProgram=function(t,e,i){var n=this;if(i=i||{},!((t=Math.floor(t))>=0&&127>=t))throw new RangeError("The program value must be between 0 and 127");return h.toMIDIChannels(e).forEach(function(s){n.setRegisteredParameter("tuningprogram",t,e,{time:i.time})}),this},a.prototype.setTuningBank=function(t,e,i){var n=this;if(i=i||{},!((t=Math.floor(t)||0)>=0&&127>=t))throw new RangeError("The bank value must be between 0 and 127");return h.toMIDIChannels(e).forEach(function(s){n.setRegisteredParameter("tuningbank",t,e,{time:i.time})}),this},a.prototype.sendChannelMode=function(t,e,i,n){if(n=n||{},"string"==typeof t){if(!(t=h.MIDI_CHANNEL_MODE_MESSAGES[t]))throw new TypeError("Invalid channel mode message name.")}else if(!((t=Math.floor(t))>=120&&127>=t))throw new RangeError("Channel mode numerical identifiers must be between 120 and 127.");if(0>(e=Math.floor(e)||0)||e>127)throw new RangeError("Value must be an integer between 0 and 127.");return h.toMIDIChannels(i).forEach(function(i){this.send((h.MIDI_CHANNEL_MESSAGES.channelmode<<4)+(i-1),[t,e],this._parseTimeParameter(n.time))}.bind(this)),this},a.prototype.sendProgramChange=function(t,e,i){var n=this;if(i=i||{},t=Math.floor(t),isNaN(t)||0>t||t>127)throw new RangeError("Program numbers must be between 0 and 127.");return h.toMIDIChannels(e).forEach(function(e){n.send((h.MIDI_CHANNEL_MESSAGES.programchange<<4)+(e-1),[t],n._parseTimeParameter(i.time))}),this},a.prototype.sendChannelAftertouch=function(t,e,i){var n=this;i=i||{},t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=.5);var s=Math.round(127*t);return h.toMIDIChannels(e).forEach(function(t){n.send((h.MIDI_CHANNEL_MESSAGES.channelaftertouch<<4)+(t-1),[s],n._parseTimeParameter(i.time))}),this},a.prototype.sendPitchBend=function(t,e,i){var n=this;if(i=i||{},isNaN(t)||-1>t||t>1)throw new RangeError("Pitch bend value must be between -1 and 1.");var s=Math.round((t+1)/2*16383),o=s>>7&127,r=127&s;return h.toMIDIChannels(e).forEach(function(t){n.send((h.MIDI_CHANNEL_MESSAGES.pitchbend<<4)+(t-1),[r,o],n._parseTimeParameter(i.time))}),this},a.prototype._parseTimeParameter=function(t){var e,i;return"string"==typeof t&&"+"===t.substring(0,1)?(e=parseFloat(t))&&e>0&&(i=h.time+e):(e=parseFloat(t))>h.time&&(i=e),i},a.prototype._convertNoteToArray=function(t){var e=[];return Array.isArray(t)||(t=[t]),t.forEach(function(t){e.push(h.guessNoteNumber(t))}),e},n=[],void 0!==(s=function(){return h}.apply(e,n))&&(t.exports=s)}()},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function s(t){if(t)return void console.error("webmidi failed to initialize");if(!S.default.outputs.length)return void console.error("no MIDI output found");if(console.log(S.default.inputs),console.log(S.default.outputs),S.default.outputs.length>1){var e=S.default.outputs.filter(function(t){return t.name.match(/prodipe/i)});e.length&&(B=e[0])}B=B||S.default.outputs[0],console.log(B.name)}function o(t){console.log("pick dataset:",t),G=0,W=H[t],Y=p(W),X=c(Y.rows)}function r(t){Q=Z[t].fn}function a(){var t=12e4/w.default.Transport.bpm.value*V[L.timing.active][0]*L.duration.value;setTimeout(a,t);var e=Q(G,t),i=g(e,2),n=i[0],s=i[1];if(G=n,z){var o=V[L.timing.active][2];o.length&&(o=o[G%o.length]),U.addEvent(new N.NoteEvent({pitch:s,duration:"t"+o}))}}function h(t,e){var i=Y,n=i.rows,s=i.min,o=i.max,r=n.length*n[0].length;t>=r&&(t=0);var a=Math.floor(t/n[0].length),h=t%n[0].length;h||console.log(a);var u=n[a][h];return t+=1,t>=r&&(t=0),[t,[f(l(u,s,o)*L.multiply.value,e)]]}function u(t,e){var i=Y,n=i.rows,s=i.min,o=i.max,r=n.length;t>=r&&(t=0);var a=t%r,h=n[a];if(!h)return void(t=0);var u=Math.min.apply(Math,h),c=l(u,s,o),p=c*L.multiply.value,d=h.map(function(t){f(p+l(t-u,X.min,X.max)*L.interval.value,e)});return t+=1,[t,d]}function l(t,e,i){return(t-e)/(i-e)}function c(t){var e=t.map(function(t){var e=Math.min.apply(Math,t);return Math.max.apply(Math,t)-e});return{min:Math.min.apply(Math,e),max:Math.max.apply(Math,e)}}function p(t){var e=t.lines;return e.forEach(function(t){return t.shift()}),e=e.map(function(t){return t.map(function(t){return parseFloat(t)})}),{rows:e,max:e.reduce(function(t,e){return e.reduce(function(t,e){return Math.max(t,e)},t)},-1/0),min:e.reduce(function(t,e){return e.reduce(function(t,e){return Math.min(t,e)},t)},1/0)}}function f(t,e){var i=C.default.current(),n=i.index(t+Math.round(L.offset.value),L.octave.value),s=(0,I.ftom)(n),o=s%1;if(o>.5&&(s+=1,o-=1),o*=2,s=Math.floor(s),(B||j)&&s>127)return 0;var r=w.default.Frequency(Math.floor(s),"midi").toNote();return j||B?(e=e||6e4/w.default.Transport.bpm.value,j||(B.playNote(r,"all",{duration:e}),B.sendPitchBend(o,"all"))):O.default.play(n),r}function d(t,e,i,n){var s=document.querySelector(e+" + .val"),o=function(t){s.innerHTML=i?parseInt(t):t.toFixed(2),n&&n(t)};t.on("change",o),o(t.value),t.update=o}function y(t,e,i,n){var s=t.active,o=document.querySelector(e+" + .val"),r=function(e){-1===e?e=t.active=s:s=e,o.innerHTML=i[e][1],n&&n(e)};t.on("change",r),r(t.active),t.update=r}function m(t,e,i){Object.keys(e).forEach(function(i){var n=e[i],s=document.createElement("option");s.innerHTML=n.name,s.value=i,t.appendChild(s)}),t.addEventListener("input",function(t){i(t.target.value)})}function v(){C.default.build_options(document.querySelector("#scale")),m(document.querySelector("#dataset"),H,o),m(document.querySelector("#behavior"),Z,r),w.default.Transport.bpm.value=q,L.tempo=new x.default.Dial("#tempo",{min:10,max:300,step:1,value:q}),d(L.tempo,"#tempo",!0,function(t){return w.default.Transport.bpm.value=t}),L.timing=new x.default.RadioButton("#timing",{size:[400,25],numberOfButtons:V.length,active:6}),y(L.timing,"#timing",V),L.duration=new x.default.Dial("#duration",{min:0,max:2,step:.01,value:.8}),d(L.duration,"#duration",!1),L.offset=new x.default.Dial("#offset",{min:-24,max:24,step:1,value:0}),d(L.offset,"#offset",!0),L.octave=new x.default.Dial("#octave",{min:-4,max:4,step:1,value:0}),d(L.octave,"#octave",!0),L.multiply=new x.default.Dial("#multiply",{min:-64,max:64,step:1,value:7}),d(L.multiply,"#multiply",!0),L.interval=new x.default.Dial("#interval",{min:-64,max:64,step:1,value:10}),d(L.interval,"#interval",!0),document.querySelector("#export_midi").addEventListener("click",_);var t=document.querySelector("#record_midi");t.addEventListener("click",function(){if(z){t.innerHTML="Record MIDI",document.body.classList.remove("recording"),z=!1;var e=new N.Writer([U]),i=(0,I.dataURItoBlob)(e.dataUri());(0,R.saveAs)(i,"Recording - "+W.name+".mid")}else t.innerHTML="Save Recording",document.body.classList.add("recording"),z=!0,U=new N.Track,U.setTempo(L.tempo.value)}),document.querySelector(".loading").classList.remove("loading"),a()}function _(){var t=document.querySelector("#behavior").value,e=Y,i=e.rows,n="sequence"===t?i[0].length*i.length:i.length,s=void 0,o=void 0,r=V[L.timing.active][2];j=!0;var a=new N.Track;a.setTempo(L.tempo.value);for(var h=0,u=n;h<u;h++)s=Q(h)[1],o=r.length?r[h%r.length]:r,a.addEvent(new N.NoteEvent({pitch:s,duration:"t"+o}));var l=new N.Writer([a]),c=(0,I.dataURItoBlob)(l.dataUri());(0,R.saveAs)(c,"Recording - "+W.name+".mid"),j=!1}var g=function(){function t(t,e){var i=[],n=!0,s=!1,o=void 0;try{for(var r,a=t[Symbol.iterator]();!(n=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);n=!0);}catch(t){s=!0,o=t}finally{try{!n&&a.return&&a.return()}finally{if(s)throw o}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),b=i(0),w=n(b),T=i(9),S=n(T),A=i(8),x=n(A),k=i(4),E=n(k),P=i(3),O=n(P),M=i(5),C=n(M),I=i(1),R=i(6),F=i(2),D=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e.default=t,e}(F),N=i(7),q=60,L=window.nx={},B=void 0,j=!1,z=!1,U=null,V=[[8,"8 measures",4096],[4,"4 measures",2048],[2,"2 measures",1024],[1,"whole note",512],[.5,"half note",256],[1/3,"third note",[170,170,171]],[.25,"quarter note",128],[.2,"fifth note",[51,51,51,51,52]],[1/6,"sixth note",[85,85,86,85,85,86]],[1/8,"eighth note",64],[.1,"tenth note",[25,26,26,25,26,25,26,26,25,26]],[1/12,"twelfth note",[21,21,22,21,21,22,21,21,22,21,21,22]],[1/16,"sixteenth note",32],[1/32,"thirtysecond note",16]];S.default.enable(s);var G=0,H={},W={},Y={},X=[],Q=h;D.load().then(function(t){console.log(t),H=t,o("housing costs and income inequality"),(0,I.requestAudioContext)(v)});var Z={sequence:{name:"Sequence",fn:h},interval:{name:"Intervals",fn:u}};E.default.listen(function(t){L.offset.value=t,L.offset.update(t)})},function(t,e,i){"use strict";t.exports=function(){function t(t,e,i){return(t-e)/(i-e)}function e(t,e){return t-e*Math.floor(t/e)}var i=function(t){t=this.opt=Object.assign({name:"",root:440,octave:0,interval:2,tet:0,intervals:null},t||{}),this.generate()};i.prototype.generate=function(t){t=Object.assign(this.opt,t||{}),t.scl?this.generate_scl():t.tet?this.generate_tet():t.intervals&&this.generate_intervals()},i.prototype.generate_intervals=function(){var t=(this.opt.root,this.opt.intervals);"string"==typeof t&&(t=t.split(" ")),this.name=this.opt.name||"interval list",this.intervals=t,this.interval=this.opt.interval=n.call(this,t.pop()),this.scale=t.map(s.bind(this)).filter(function(t){return!!t})},i.prototype.generate_tet=function(){var t=this.scale=[],e=this.opt.root,i=this.opt.tet,n=this.interval=this.opt.interval,s=Math.pow(n,1/i),o=e;t.push(o);for(var r=0;r<i-1;r++)o*=s,t.push(o);this.name=this.opt.name||i+"-tone equal temperament",this.intervals=null},i.prototype.generate_scl=function(){var t=this.opt.root,e=this.parse_scl(this.opt.scl);this.intervals=e.notes,this.interval=e.notes.pop(),this.name=this.opt.name||e.description,this.scale=e.notes.map(function(e){return e*t})},i.prototype.parse_scl=function(t){var e={};return e.comments=[],e.notes=[],t.trim().split("\n").forEach(function(t){if(-1!==t.indexOf("!"))e.comments.push(t);else if("description"in e)if(e.notes.length){var i=t.replace(/^[^-\.0-9]+/,"").replace(/[^-\/\.0-9]+$/,"");i=-1!==i.indexOf(".")?Math.pow(2,parseFloat(i)/1200):n(i),i&&e.notes.push(i)}else e.notes.push(1);else e.description=t}),e},i.prototype.index=function(i,n){n=n||this.opt.octave;var s=this.scale[0|e(i,this.scale.length)],o=Math.floor(t(i,0,this.scale.length))+n;return s*=Math.pow(this.interval,o)},i.prototype.range=function(t,e){for(var i=[],n=t;n<e;n++)i.push(this.index(n));return i},i.prototype.set_root=function(t){this.opt.root=t,this.generate()},i.prototype.quantize_frequency=function(t){if(0==t)return 0;for(var e=t,i=0,n=this.interval,s=this.scale;e<root;)e*=n,i-=1;for(;e>root*n;)e/=n,i+=1;for(var o=0;o<s.length;o++)if(!(e>s[o])){e=s[o];break}return e*=Math.pow(2,i)},i.prototype.quantize_index=function(t){return 0|e(index-1,this.scale.length)};var n=i.prototype.parse_interval=function(t){if("number"==typeof t)return t;if(-1==!t.indexOf("/"))return parseInt(t);var e=t.split("/"),i=parseInt(e[0]),n=parseInt(e[1]);return isNaN(i)?1:isNaN(n)||0==n?i:i==n?1:i/n},s=i.prototype.parse_interval_string=function(t){return-1!==t.indexOf("/")?n(t)*this.opt.root:(t.indexOf("f"),parseFloat(t))};return i}()},function(t,e,i){"use strict";var n,s,o;"function"==typeof Symbol&&Symbol.iterator;/**
 *  StartAudioContext.js
 *  @author Yotam Mann
 *  @license http://opensource.org/licenses/MIT MIT License
 *  @copyright 2016 Yotam Mann
 */
!function(i,r){s=[],n=r,void 0!==(o="function"==typeof n?n.apply(e,s):n)&&(t.exports=o)}(0,function(){function t(){if(e.context&&!e.isStarted()){var t=e.context.createOscillator(),i=e.context.createGain();i.gain.value=0,t.connect(i),i.connect(e.context.destination);var n=e.context.currentTime;t.start(n),t.stop(n+.5)}if(e._tapListeners){for(var s=0;s<e._tapListeners.length;s++)e._tapListeners[s].dispose();e._tapListeners=null}if(e._onStarted){for(var o=0;o<e._onStarted.length;o++)e._onStarted[o]();e._onStarted=null}}var e={context:null,_tapListeners:[],_onStarted:[]};e.setContext=function(t){return e.context=t,e},e.on=function(n){if(Array.isArray(n)||NodeList&&n instanceof NodeList)for(var s=0;s<n.length;s++)e.on(n[s]);else if("string"==typeof n)e.on(document.querySelectorAll(n));else if(n.jquery&&"function"==typeof n.toArray)e.on(n.toArray());else if(Element&&n instanceof Element){var o=new i(n,t);e._tapListeners.push(o)}return e},e.onStarted=function(t){return e.isStarted()?t():e._onStarted.push(t),e},e.isStarted=function(){return null!==e.context&&"running"===e.context.state};var i=function(t){this._dragged=!1,this._element=t,this._bindedMove=this._moved.bind(this),this._bindedEnd=this._ended.bind(this),t.addEventListener("touchmove",this._bindedMove),t.addEventListener("touchend",this._bindedEnd),t.addEventListener("mouseup",this._bindedEnd)};return i.prototype._moved=function(t){this._dragged=!0},i.prototype._ended=function(e){this._dragged||t(),this._dragged=!1},i.prototype.dispose=function(){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},e})},function(t,e,i){"use strict";function n(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function s(t){return 3*t.length/4-n(t)}function o(t){var e,i,s,o,r,a,h=t.length;r=n(t),a=new c(3*h/4-r),s=r>0?h-4:h;var u=0;for(e=0,i=0;e<s;e+=4,i+=3)o=l[t.charCodeAt(e)]<<18|l[t.charCodeAt(e+1)]<<12|l[t.charCodeAt(e+2)]<<6|l[t.charCodeAt(e+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=255&o;return 2===r?(o=l[t.charCodeAt(e)]<<2|l[t.charCodeAt(e+1)]>>4,a[u++]=255&o):1===r&&(o=l[t.charCodeAt(e)]<<10|l[t.charCodeAt(e+1)]<<4|l[t.charCodeAt(e+2)]>>2,a[u++]=o>>8&255,a[u++]=255&o),a}function r(t){return u[t>>18&63]+u[t>>12&63]+u[t>>6&63]+u[63&t]}function a(t,e,i){for(var n,s=[],o=e;o<i;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],s.push(r(n));return s.join("")}function h(t){for(var e,i=t.length,n=i%3,s="",o=[],r=0,h=i-n;r<h;r+=16383)o.push(a(t,r,r+16383>h?h:r+16383));return 1===n?(e=t[i-1],s+=u[e>>2],s+=u[e<<4&63],s+="=="):2===n&&(e=(t[i-2]<<8)+t[i-1],s+=u[e>>10],s+=u[e>>4&63],s+=u[e<<2&63],s+="="),o.push(s),o.join("")}e.byteLength=s,e.toByteArray=o,e.fromByteArray=h;for(var u=[],l=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,d=p.length;f<d;++f)u[f]=p[f],l[p.charCodeAt(f)]=f;l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},function(t,e,i){"use strict";(function(t){function n(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,e){if(n()<e)throw new RangeError("Invalid typed array length");return o.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=o.prototype):(null===t&&(t=new o(e)),t.length=e),t}function o(t,e,i){if(!(o.TYPED_ARRAY_SUPPORT||this instanceof o))return new o(t,e,i);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return u(this,t)}return r(this,t,e,i)}function r(t,e,i,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?p(t,e,i,n):"string"==typeof e?l(t,e,i):f(t,e)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function h(t,e,i,n){return a(e),e<=0?s(t,e):void 0!==i?"string"==typeof n?s(t,e).fill(i,n):s(t,e).fill(i):s(t,e)}function u(t,e){if(a(e),t=s(t,e<0?0:0|d(e)),!o.TYPED_ARRAY_SUPPORT)for(var i=0;i<e;++i)t[i]=0;return t}function l(t,e,i){if("string"==typeof i&&""!==i||(i="utf8"),!o.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var n=0|m(e,i);t=s(t,n);var r=t.write(e,i);return r!==n&&(t=t.slice(0,r)),t}function c(t,e){var i=e.length<0?0:0|d(e.length);t=s(t,i);for(var n=0;n<i;n+=1)t[n]=255&e[n];return t}function p(t,e,i,n){if(e.byteLength,i<0||e.byteLength<i)throw new RangeError("'offset' is out of bounds");if(e.byteLength<i+(n||0))throw new RangeError("'length' is out of bounds");return e=void 0===i&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,i):new Uint8Array(e,i,n),o.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=o.prototype):t=c(t,e),t}function f(t,e){if(o.isBuffer(e)){var i=0|d(e.length);return t=s(t,i),0===t.length?t:(e.copy(t,0,0,i),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||Q(e.length)?s(t,0):c(t,e);if("Buffer"===e.type&&$(e.data))return c(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function d(t){if(t>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|t}function y(t){return+t!=t&&(t=0),o.alloc(+t)}function m(t,e){if(o.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return G(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return Y(t).length;default:if(n)return G(t).length;e=(""+e).toLowerCase(),n=!0}}function v(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if(i>>>=0,e>>>=0,i<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,i);case"utf8":case"utf-8":return P(this,e,i);case"ascii":return M(this,e,i);case"latin1":case"binary":return C(this,e,i);case"base64":return E(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function _(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function g(t,e,i,n,s){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=s?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(s)return-1;i=t.length-1}else if(i<0){if(!s)return-1;i=0}if("string"==typeof e&&(e=o.from(e,n)),o.isBuffer(e))return 0===e.length?-1:b(t,e,i,n,s);if("number"==typeof e)return e&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):b(t,[e],i,n,s);throw new TypeError("val must be string, number or Buffer")}function b(t,e,i,n,s){function o(t,e){return 1===r?t[e]:t.readUInt16BE(e*r)}var r=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;r=2,a/=2,h/=2,i/=2}var u;if(s){var l=-1;for(u=i;u<a;u++)if(o(t,u)===o(e,-1===l?0:u-l)){if(-1===l&&(l=u),u-l+1===h)return l*r}else-1!==l&&(u-=u-l),l=-1}else for(i+h>a&&(i=a-h),u=i;u>=0;u--){for(var c=!0,p=0;p<h;p++)if(o(t,u+p)!==o(e,p)){c=!1;break}if(c)return u}return-1}function w(t,e,i,n){i=Number(i)||0;var s=t.length-i;n?(n=Number(n))>s&&(n=s):n=s;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var r=0;r<n;++r){var a=parseInt(e.substr(2*r,2),16);if(isNaN(a))return r;t[i+r]=a}return r}function T(t,e,i,n){return X(G(e,t.length-i),t,i,n)}function S(t,e,i,n){return X(H(e),t,i,n)}function A(t,e,i,n){return S(t,e,i,n)}function x(t,e,i,n){return X(Y(e),t,i,n)}function k(t,e,i,n){return X(W(e,t.length-i),t,i,n)}function E(t,e,i){return 0===e&&i===t.length?Z.fromByteArray(t):Z.fromByteArray(t.slice(e,i))}function P(t,e,i){i=Math.min(t.length,i);for(var n=[],s=e;s<i;){var o=t[s],r=null,a=o>239?4:o>223?3:o>191?2:1;if(s+a<=i){var h,u,l,c;switch(a){case 1:o<128&&(r=o);break;case 2:h=t[s+1],128==(192&h)&&(c=(31&o)<<6|63&h)>127&&(r=c);break;case 3:h=t[s+1],u=t[s+2],128==(192&h)&&128==(192&u)&&(c=(15&o)<<12|(63&h)<<6|63&u)>2047&&(c<55296||c>57343)&&(r=c);break;case 4:h=t[s+1],u=t[s+2],l=t[s+3],128==(192&h)&&128==(192&u)&&128==(192&l)&&(c=(15&o)<<18|(63&h)<<12|(63&u)<<6|63&l)>65535&&c<1114112&&(r=c)}}null===r?(r=65533,a=1):r>65535&&(r-=65536,n.push(r>>>10&1023|55296),r=56320|1023&r),n.push(r),s+=a}return O(n)}function O(t){var e=t.length;if(e<=J)return String.fromCharCode.apply(String,t);for(var i="",n=0;n<e;)i+=String.fromCharCode.apply(String,t.slice(n,n+=J));return i}function M(t,e,i){var n="";i=Math.min(t.length,i);for(var s=e;s<i;++s)n+=String.fromCharCode(127&t[s]);return n}function C(t,e,i){var n="";i=Math.min(t.length,i);for(var s=e;s<i;++s)n+=String.fromCharCode(t[s]);return n}function I(t,e,i){var n=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>n)&&(i=n);for(var s="",o=e;o<i;++o)s+=V(t[o]);return s}function R(t,e,i){for(var n=t.slice(e,i),s="",o=0;o<n.length;o+=2)s+=String.fromCharCode(n[o]+256*n[o+1]);return s}function F(t,e,i){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>i)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,i,n,s,r){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||e<r)throw new RangeError('"value" argument is out of bounds');if(i+n>t.length)throw new RangeError("Index out of range")}function N(t,e,i,n){e<0&&(e=65535+e+1);for(var s=0,o=Math.min(t.length-i,2);s<o;++s)t[i+s]=(e&255<<8*(n?s:1-s))>>>8*(n?s:1-s)}function q(t,e,i,n){e<0&&(e=4294967295+e+1);for(var s=0,o=Math.min(t.length-i,4);s<o;++s)t[i+s]=e>>>8*(n?s:3-s)&255}function L(t,e,i,n,s,o){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function B(t,e,i,n,s){return s||L(t,e,i,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,e,i,n,23,4),i+4}function j(t,e,i,n,s){return s||L(t,e,i,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,e,i,n,52,8),i+8}function z(t){if(t=U(t).replace(tt,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function U(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function V(t){return t<16?"0"+t.toString(16):t.toString(16)}function G(t,e){e=e||1/0;for(var i,n=t.length,s=null,o=[],r=0;r<n;++r){if((i=t.charCodeAt(r))>55295&&i<57344){if(!s){if(i>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(r+1===n){(e-=3)>-1&&o.push(239,191,189);continue}s=i;continue}if(i<56320){(e-=3)>-1&&o.push(239,191,189),s=i;continue}i=65536+(s-55296<<10|i-56320)}else s&&(e-=3)>-1&&o.push(239,191,189);if(s=null,i<128){if((e-=1)<0)break;o.push(i)}else if(i<2048){if((e-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;o.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function H(t){for(var e=[],i=0;i<t.length;++i)e.push(255&t.charCodeAt(i));return e}function W(t,e){for(var i,n,s,o=[],r=0;r<t.length&&!((e-=2)<0);++r)i=t.charCodeAt(r),n=i>>8,s=i%256,o.push(s),o.push(n);return o}function Y(t){return Z.toByteArray(z(t))}function X(t,e,i,n){for(var s=0;s<n&&!(s+i>=e.length||s>=t.length);++s)e[s+i]=t[s];return s}function Q(t){return t!==t}/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
 * @license  MIT
 */
var Z=i(13),K=i(15),$=i(16);e.Buffer=o,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=n(),o.poolSize=8192,o._augment=function(t){return t.__proto__=o.prototype,t},o.from=function(t,e,i){return r(null,t,e,i)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(t,e,i){return h(null,t,e,i)},o.allocUnsafe=function(t){return u(null,t)},o.allocUnsafeSlow=function(t){return u(null,t)},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.compare=function(t,e){if(!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var i=t.length,n=e.length,s=0,r=Math.min(i,n);s<r;++s)if(t[s]!==e[s]){i=t[s],n=e[s];break}return i<n?-1:n<i?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!$(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);var i;if(void 0===e)for(e=0,i=0;i<t.length;++i)e+=t[i].length;var n=o.allocUnsafe(e),s=0;for(i=0;i<t.length;++i){var r=t[i];if(!o.isBuffer(r))throw new TypeError('"list" argument must be an Array of Buffers');r.copy(n,s),s+=r.length}return n},o.byteLength=m,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)_(this,e,e+1);return this},o.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)_(this,e,e+3),_(this,e+1,e+2);return this},o.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)_(this,e,e+7),_(this,e+1,e+6),_(this,e+2,e+5),_(this,e+3,e+4);return this},o.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?P(this,0,t):v.apply(this,arguments)},o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){var t="",i=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),"<Buffer "+t+">"},o.prototype.compare=function(t,e,i,n,s){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),e<0||i>t.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&e>=i)return 0;if(n>=s)return-1;if(e>=i)return 1;if(e>>>=0,i>>>=0,n>>>=0,s>>>=0,this===t)return 0;for(var r=s-n,a=i-e,h=Math.min(r,a),u=this.slice(n,s),l=t.slice(e,i),c=0;c<h;++c)if(u[c]!==l[c]){r=u[c],a=l[c];break}return r<a?-1:a<r?1:0},o.prototype.includes=function(t,e,i){return-1!==this.indexOf(t,e,i)},o.prototype.indexOf=function(t,e,i){return g(this,t,e,i,!0)},o.prototype.lastIndexOf=function(t,e,i){return g(this,t,e,i,!1)},o.prototype.write=function(t,e,i,n){if(void 0===e)n="utf8",i=this.length,e=0;else if(void 0===i&&"string"==typeof e)n=e,i=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(i)?(i|=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}var s=this.length-e;if((void 0===i||i>s)&&(i=s),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return w(this,t,e,i);case"utf8":case"utf-8":return T(this,t,e,i);case"ascii":return S(this,t,e,i);case"latin1":case"binary":return A(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,i);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var J=4096;o.prototype.slice=function(t,e){var i=this.length;t=~~t,e=void 0===e?i:~~e,t<0?(t+=i)<0&&(t=0):t>i&&(t=i),e<0?(e+=i)<0&&(e=0):e>i&&(e=i),e<t&&(e=t);var n;if(o.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=o.prototype;else{var s=e-t;n=new o(s,void 0);for(var r=0;r<s;++r)n[r]=this[r+t]}return n},o.prototype.readUIntLE=function(t,e,i){t|=0,e|=0,i||F(t,e,this.length);for(var n=this[t],s=1,o=0;++o<e&&(s*=256);)n+=this[t+o]*s;return n},o.prototype.readUIntBE=function(t,e,i){t|=0,e|=0,i||F(t,e,this.length);for(var n=this[t+--e],s=1;e>0&&(s*=256);)n+=this[t+--e]*s;return n},o.prototype.readUInt8=function(t,e){return e||F(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,e){return e||F(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,e){return e||F(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,e){return e||F(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUInt32BE=function(t,e){return e||F(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||F(t,e,this.length);for(var n=this[t],s=1,o=0;++o<e&&(s*=256);)n+=this[t+o]*s;return s*=128,n>=s&&(n-=Math.pow(2,8*e)),n},o.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||F(t,e,this.length);for(var n=e,s=1,o=this[t+--n];n>0&&(s*=256);)o+=this[t+--n]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o},o.prototype.readInt8=function(t,e){return e||F(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){e||F(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},o.prototype.readInt16BE=function(t,e){e||F(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},o.prototype.readInt32LE=function(t,e){return e||F(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return e||F(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return e||F(t,4,this.length),K.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return e||F(t,4,this.length),K.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return e||F(t,8,this.length),K.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return e||F(t,8,this.length),K.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,e,i,n){if(t=+t,e|=0,i|=0,!n){D(this,t,e,i,Math.pow(2,8*i)-1,0)}var s=1,o=0;for(this[e]=255&t;++o<i&&(s*=256);)this[e+o]=t/s&255;return e+i},o.prototype.writeUIntBE=function(t,e,i,n){if(t=+t,e|=0,i|=0,!n){D(this,t,e,i,Math.pow(2,8*i)-1,0)}var s=i-1,o=1;for(this[e+s]=255&t;--s>=0&&(o*=256);)this[e+s]=t/o&255;return e+i},o.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,1,255,0),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},o.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},o.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},o.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):q(this,t,e,!0),e+4},o.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):q(this,t,e,!1),e+4},o.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var s=Math.pow(2,8*i-1);D(this,t,e,i,s-1,-s)}var o=0,r=1,a=0;for(this[e]=255&t;++o<i&&(r*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/r>>0)-a&255;return e+i},o.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var s=Math.pow(2,8*i-1);D(this,t,e,i,s-1,-s)}var o=i-1,r=1,a=0;for(this[e+o]=255&t;--o>=0&&(r*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/r>>0)-a&255;return e+i},o.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,1,127,-128),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},o.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},o.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):q(this,t,e,!0),e+4},o.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):q(this,t,e,!1),e+4},o.prototype.writeFloatLE=function(t,e,i){return B(this,t,e,!0,i)},o.prototype.writeFloatBE=function(t,e,i){return B(this,t,e,!1,i)},o.prototype.writeDoubleLE=function(t,e,i){return j(this,t,e,!0,i)},o.prototype.writeDoubleBE=function(t,e,i){return j(this,t,e,!1,i)},o.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<i&&(n=i),n===i)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-i&&(n=t.length-e+i);var s,r=n-i;if(this===t&&i<e&&e<n)for(s=r-1;s>=0;--s)t[s+e]=this[s+i];else if(r<1e3||!o.TYPED_ARRAY_SUPPORT)for(s=0;s<r;++s)t[s+e]=this[s+i];else Uint8Array.prototype.set.call(t,this.subarray(i,i+r),e);return r},o.prototype.fill=function(t,e,i,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),1===t.length){var s=t.charCodeAt(0);s<256&&(t=s)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<i)throw new RangeError("Out of range index");if(i<=e)return this;e>>>=0,i=void 0===i?this.length:i>>>0,t||(t=0);var r;if("number"==typeof t)for(r=e;r<i;++r)this[r]=t;else{var a=o.isBuffer(t)?t:G(new o(t,n).toString()),h=a.length;for(r=0;r<i-e;++r)this[r+e]=a[r%h]}return this};var tt=/[^+\/0-9A-Za-z-_]/g}).call(e,i(22))},function(t,e){e.read=function(t,e,i,n,s){var o,r,a=8*s-n-1,h=(1<<a)-1,u=h>>1,l=-7,c=i?s-1:0,p=i?-1:1,f=t[e+c];for(c+=p,o=f&(1<<-l)-1,f>>=-l,l+=a;l>0;o=256*o+t[e+c],c+=p,l-=8);for(r=o&(1<<-l)-1,o>>=-l,l+=n;l>0;r=256*r+t[e+c],c+=p,l-=8);if(0===o)o=1-u;else{if(o===h)return r?NaN:1/0*(f?-1:1);r+=Math.pow(2,n),o-=u}return(f?-1:1)*r*Math.pow(2,o-n)},e.write=function(t,e,i,n,s,o){var r,a,h,u=8*o-s-1,l=(1<<u)-1,c=l>>1,p=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,r=l):(r=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-r))<1&&(r--,h*=2),e+=r+c>=1?p/h:p*Math.pow(2,1-c),e*h>=2&&(r++,h/=2),r+c>=l?(a=0,r=l):r+c>=1?(a=(e*h-1)*Math.pow(2,s),r+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,s),r=0));s>=8;t[i+f]=255&a,f+=d,a/=256,s-=8);for(r=r<<s|a,u+=s;u>0;t[i+f]=255&r,f+=d,r/=256,u-=8);t[i+f-d]|=128*y}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e,i){"use strict";function n(t){return"number"==typeof t}function s(t){return"string"==typeof t}function o(t){return void 0!==t}function r(t,e){return Math.pow(2,(t-69)/12)*(e||440)}function a(t,e,i){if("string"!=typeof t)return null;var n=u.exec(t);if(!n||!e&&n[4])return null;var s={letter:n[1].toUpperCase(),acc:n[2].replace(/x/g,"##")};s.pc=s.letter+s.acc,s.step=(s.letter.charCodeAt(0)+3)%7,s.alt="b"===s.acc[0]?-s.acc.length:s.acc.length;var o=l[s.step]+s.alt;return s.chroma=o<0?12+o:o%12,n[3]&&(s.oct=+n[3],s.midi=o+12*(s.oct+1),s.freq=r(s.midi,i)),e&&(s.tonicOf=n[4]),s}function h(t){if((n(t)||s(t))&&t>=0&&t<128)return+t;var e=a(t);return e&&o(e.midi)?e.midi:null}e.a=h;var u=/^([a-gA-G])(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)\s*$/,l=[0,2,4,5,7,9,11]},function(t,e){function i(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function s(t){if(l===setTimeout)return setTimeout(t,0);if((l===i||!l)&&setTimeout)return l=setTimeout,setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function o(t){if(c===clearTimeout)return clearTimeout(t);if((c===n||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(t);try{return c(t)}catch(e){try{return c.call(null,t)}catch(e){return c.call(this,t)}}}function r(){y&&f&&(y=!1,f.length?d=f.concat(d):m=-1,d.length&&a())}function a(){if(!y){var t=s(r);y=!0;for(var e=d.length;e;){for(f=d,d=[];++m<e;)f&&f[m].run();m=-1,e=d.length}f=null,y=!1,o(t)}}function h(t,e){this.fun=t,this.array=e}function u(){}var l,c,p=t.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:i}catch(t){l=i}try{c="function"==typeof clearTimeout?clearTimeout:n}catch(t){c=n}}();var f,d=[],y=!1,m=-1;p.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];d.push(new h(t,e)),1!==d.length||y||s(a)},h.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=u,p.addListener=u,p.once=u,p.off=u,p.removeListener=u,p.removeAllListeners=u,p.emit=u,p.binding=function(t){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(t){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(t,e,i){"use strict";function n(t){return Array.isArray(t)&&2===t.length?7*t[0]+12*t[1]+12:i.i(o.a)(t)}function s(t,e){return!0===t||!1===t?function(e){return s(e,t)}:(t=Math.round(t),(!0===e?a:r)[t%12]+(Math.floor(t/12)-1))}Object.defineProperty(e,"__esModule",{value:!0});var o=i(17);e.toMidi=n,e.note=s;var r="C Db D Eb E F Gb G Ab A Bb B".split(" "),a="C C# D D# E F F# G G# A A# B".split(" ")},function(t,e){t.exports=function(){throw new Error("define cannot be used indirect")}},function(t,e){(function(e){t.exports=e}).call(e,{})},function(t,e){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(i=window)}t.exports=i}]);
//# sourceMappingURL=bundle.js.map