summaryrefslogtreecommitdiff
path: root/dist/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'dist/index.js')
-rw-r--r--dist/index.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/dist/index.js b/dist/index.js
index 1ef6bb0..565efec 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,28 +1,28 @@
-!function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=76)}([function(t,e){var i=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=i)},function(t,e,i){var n=i(39)("wks"),s=i(25),r=i(2).Symbol,o="function"==typeof r;(t.exports=function(t){return n[t]||(n[t]=o&&r[t]||(o?r:s)("Symbol."+t))}).store=n},function(t,e){var i=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=i)},function(t,e,i){var n=i(4),s=i(53),r=i(36),o=Object.defineProperty;e.f=i(8)?Object.defineProperty:function(t,e,i){if(n(t),e=r(e,!0),n(i),s)try{return o(t,e,i)}catch(t){}if("get"in i||"set"in i)throw TypeError("Accessors not supported!");return"value"in i&&(t[e]=i.value),t}},function(t,e,i){var n=i(20);t.exports=function(t){if(!n(t))throw TypeError(t+" is not an object!");return t}},function(t,e,i){"use strict";(function(t){
+!function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=76)}([function(t,e){var i=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=i)},function(t,e,i){var n=i(39)("wks"),s=i(25),r=i(2).Symbol,o="function"==typeof r;(t.exports=function(t){return n[t]||(n[t]=o&&r[t]||(o?r:s)("Symbol."+t))}).store=n},function(t,e){var i=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=i)},function(t,e,i){var n=i(2),s=i(0),r=i(19),o=i(7),a=function(t,e,i){var u,h,l,c=t&a.F,p=t&a.G,f=t&a.S,d=t&a.P,m=t&a.B,y=t&a.W,v=p?s:s[e]||(s[e]={}),_=v.prototype,g=p?n:f?n[e]:(n[e]||{}).prototype;for(u in p&&(i=e),i)(h=!c&&g&&void 0!==g[u])&&u in v||(l=h?g[u]:i[u],v[u]=p&&"function"!=typeof g[u]?i[u]:m&&h?r(l,n):y&&g[u]==l?function(t){var e=function(e,i,n){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,i)}return new t(e,i,n)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(l):d&&"function"==typeof l?r(Function.call,l):l,d&&((v.virtual||(v.virtual={}))[u]=l,t&a.R&&_&&!_[u]&&o(_,u,l)))};a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,t.exports=a},function(t,e,i){var n=i(5),s=i(53),r=i(36),o=Object.defineProperty;e.f=i(8)?Object.defineProperty:function(t,e,i){if(n(t),e=r(e,!0),n(i),s)try{return o(t,e,i)}catch(t){}if("get"in i||"set"in i)throw TypeError("Accessors not supported!");return"value"in i&&(t[e]=i.value),t}},function(t,e,i){var n=i(20);t.exports=function(t){if(!n(t))throw TypeError(t+" is not an object!");return t}},function(t,e,i){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
-var n=i(130),s=i(131),r=i(70);function o(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,i){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(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 c(this,t)}return h(this,t,e,i)}function h(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?function(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");e=void 0===i&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,i):new Uint8Array(e,i,n);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=p(t,e);return t}(t,e,i,n):"string"==typeof e?function(t,e,i){"string"==typeof i&&""!==i||(i="utf8");if(!u.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,i),s=(t=a(t,n)).write(e,i);s!==n&&(t=t.slice(0,s));return t}(t,e,i):function(t,e){if(u.isBuffer(e)){var i=0|f(e.length);return 0===(t=a(t,i)).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||function(t){return t!=t}(e.length)?a(t,0):p(t,e);if("Buffer"===e.type&&r(e.data))return p(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function l(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 c(t,e){if(l(e),t=a(t,e<0?0:0|f(e)),!u.TYPED_ARRAY_SUPPORT)for(var i=0;i<e;++i)t[i]=0;return t}function p(t,e){var i=e.length<0?0:0|f(e.length);t=a(t,i);for(var n=0;n<i;n+=1)t[n]=255&e[n];return t}function f(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function d(t,e){if(u.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 B(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return z(t).length;default:if(n)return B(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function y(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=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:v(t,e,i,n,s);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):v(t,[e],i,n,s);throw new TypeError("val must be string, number or Buffer")}function v(t,e,i,n,s){var r,o=1,a=t.length,u=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;o=2,a/=2,u/=2,i/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(s){var l=-1;for(r=i;r<a;r++)if(h(t,r)===h(e,-1===l?0:r-l)){if(-1===l&&(l=r),r-l+1===u)return l*o}else-1!==l&&(r-=r-l),l=-1}else for(i+u>a&&(i=a-u),r=i;r>=0;r--){for(var c=!0,p=0;p<u;p++)if(h(t,r+p)!==h(e,p)){c=!1;break}if(c)return r}return-1}function _(t,e,i,n){i=Number(i)||0;var s=t.length-i;n?(n=Number(n))>s&&(n=s):n=s;var r=e.length;if(r%2!=0)throw new TypeError("Invalid hex string");n>r/2&&(n=r/2);for(var o=0;o<n;++o){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))return o;t[i+o]=a}return o}function g(t,e,i,n){return U(B(e,t.length-i),t,i,n)}function b(t,e,i,n){return U(function(t){for(var e=[],i=0;i<t.length;++i)e.push(255&t.charCodeAt(i));return e}(e),t,i,n)}function w(t,e,i,n){return b(t,e,i,n)}function S(t,e,i,n){return U(z(e),t,i,n)}function T(t,e,i,n){return U(function(t,e){for(var i,n,s,r=[],o=0;o<t.length&&!((e-=2)<0);++o)i=t.charCodeAt(o),n=i>>8,s=i%256,r.push(s),r.push(n);return r}(e,t.length-i),t,i,n)}function x(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function A(t,e,i){i=Math.min(t.length,i);for(var n=[],s=e;s<i;){var r,o,a,u,h=t[s],l=null,c=h>239?4:h>223?3:h>191?2:1;if(s+c<=i)switch(c){case 1:h<128&&(l=h);break;case 2:128==(192&(r=t[s+1]))&&(u=(31&h)<<6|63&r)>127&&(l=u);break;case 3:r=t[s+1],o=t[s+2],128==(192&r)&&128==(192&o)&&(u=(15&h)<<12|(63&r)<<6|63&o)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:r=t[s+1],o=t[s+2],a=t[s+3],128==(192&r)&&128==(192&o)&&128==(192&a)&&(u=(15&h)<<18|(63&r)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,c=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),s+=c}return function(t){var e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n<e;)i+=String.fromCharCode.apply(String,t.slice(n,n+=k));return i}(n)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.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=o(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,i){return h(null,t,e,i)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,i){return function(t,e,i,n){return l(e),e<=0?a(t,e):void 0!==i?"string"==typeof n?a(t,e).fill(i,n):a(t,e).fill(i):a(t,e)}(null,t,e,i)},u.allocUnsafe=function(t){return c(null,t)},u.allocUnsafeSlow=function(t){return c(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.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},u.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}},u.concat=function(t,e){if(!r(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var i;if(void 0===e)for(e=0,i=0;i<t.length;++i)e+=t[i].length;var n=u.allocUnsafe(e),s=0;for(i=0;i<t.length;++i){var o=t[i];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=o.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.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)m(this,e,e+1);return this},u.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)m(this,e,e+3),m(this,e+1,e+2);return this},u.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)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):function(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))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,i);case"utf8":case"utf-8":return A(this,e,i);case"ascii":return E(this,e,i);case"latin1":case"binary":return O(this,e,i);case"base64":return x(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.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+">"},u.prototype.compare=function(t,e,i,n,s){if(!u.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,o=i-e,a=Math.min(r,o),h=this.slice(n,s),l=t.slice(e,i),c=0;c<a;++c)if(h[c]!==l[c]){r=h[c],o=l[c];break}return r<o?-1:o<r?1:0},u.prototype.includes=function(t,e,i){return-1!==this.indexOf(t,e,i)},u.prototype.indexOf=function(t,e,i){return y(this,t,e,i,!0)},u.prototype.lastIndexOf=function(t,e,i){return y(this,t,e,i,!1)},u.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 r=!1;;)switch(n){case"hex":return _(this,t,e,i);case"utf8":case"utf-8":return g(this,t,e,i);case"ascii":return b(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return S(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,i);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),r=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function E(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 O(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 M(t,e,i){var n=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>n)&&(i=n);for(var s="",r=e;r<i;++r)s+=j(t[r]);return s}function P(t,e,i){for(var n=t.slice(e,i),s="",r=0;r<n.length;r+=2)s+=String.fromCharCode(n[r]+256*n[r+1]);return s}function C(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 I(t,e,i,n,s,r){if(!u.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 R(t,e,i,n){e<0&&(e=65535+e+1);for(var s=0,r=Math.min(t.length-i,2);s<r;++s)t[i+s]=(e&255<<8*(n?s:1-s))>>>8*(n?s:1-s)}function F(t,e,i,n){e<0&&(e=4294967295+e+1);for(var s=0,r=Math.min(t.length-i,4);s<r;++s)t[i+s]=e>>>8*(n?s:3-s)&255}function D(t,e,i,n,s,r){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function N(t,e,i,n,r){return r||D(t,0,i,4),s.write(t,e,i,n,23,4),i+4}function q(t,e,i,n,r){return r||D(t,0,i,8),s.write(t,e,i,n,52,8),i+8}u.prototype.slice=function(t,e){var i,n=this.length;if(t=~~t,e=void 0===e?n:~~e,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),e<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(i=this.subarray(t,e)).__proto__=u.prototype;else{var s=e-t;i=new u(s,void 0);for(var r=0;r<s;++r)i[r]=this[r+t]}return i},u.prototype.readUIntLE=function(t,e,i){t|=0,e|=0,i||C(t,e,this.length);for(var n=this[t],s=1,r=0;++r<e&&(s*=256);)n+=this[t+r]*s;return n},u.prototype.readUIntBE=function(t,e,i){t|=0,e|=0,i||C(t,e,this.length);for(var n=this[t+--e],s=1;e>0&&(s*=256);)n+=this[t+--e]*s;return n},u.prototype.readUInt8=function(t,e){return e||C(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||C(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||C(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||C(t,e,this.length);for(var n=this[t],s=1,r=0;++r<e&&(s*=256);)n+=this[t+r]*s;return n>=(s*=128)&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||C(t,e,this.length);for(var n=e,s=1,r=this[t+--n];n>0&&(s*=256);)r+=this[t+--n]*s;return r>=(s*=128)&&(r-=Math.pow(2,8*e)),r},u.prototype.readInt8=function(t,e){return e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||C(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},u.prototype.readInt16BE=function(t,e){e||C(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},u.prototype.readInt32LE=function(t,e){return e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||C(t,4,this.length),s.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||C(t,4,this.length),s.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||C(t,8,this.length),s.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||C(t,8,this.length),s.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||I(this,t,e,i,Math.pow(2,8*i)-1,0);var s=1,r=0;for(this[e]=255&t;++r<i&&(s*=256);)this[e+r]=t/s&255;return e+i},u.prototype.writeUIntBE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||I(this,t,e,i,Math.pow(2,8*i)-1,0);var s=i-1,r=1;for(this[e+s]=255&t;--s>=0&&(r*=256);)this[e+s]=t/r&255;return e+i},u.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):R(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):R(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):F(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var s=Math.pow(2,8*i-1);I(this,t,e,i,s-1,-s)}var r=0,o=1,a=0;for(this[e]=255&t;++r<i&&(o*=256);)t<0&&0===a&&0!==this[e+r-1]&&(a=1),this[e+r]=(t/o>>0)-a&255;return e+i},u.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var s=Math.pow(2,8*i-1);I(this,t,e,i,s-1,-s)}var r=i-1,o=1,a=0;for(this[e+r]=255&t;--r>=0&&(o*=256);)t<0&&0===a&&0!==this[e+r+1]&&(a=1),this[e+r]=(t/o>>0)-a&255;return e+i},u.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):R(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):R(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):F(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,i){return N(this,t,e,!0,i)},u.prototype.writeFloatBE=function(t,e,i){return N(this,t,e,!1,i)},u.prototype.writeDoubleLE=function(t,e,i){return q(this,t,e,!0,i)},u.prototype.writeDoubleBE=function(t,e,i){return q(this,t,e,!1,i)},u.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||!u.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},u.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&&!u.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;var r;if(e>>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(r=e;r<i;++r)this[r]=t;else{var o=u.isBuffer(t)?t:B(new u(t,n).toString()),a=o.length;for(r=0;r<i-e;++r)this[r+e]=o[r%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function j(t){return t<16?"0"+t.toString(16):t.toString(16)}function B(t,e){var i;e=e||1/0;for(var n=t.length,s=null,r=[],o=0;o<n;++o){if((i=t.charCodeAt(o))>55295&&i<57344){if(!s){if(i>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&r.push(239,191,189);continue}s=i;continue}if(i<56320){(e-=3)>-1&&r.push(239,191,189),s=i;continue}i=65536+(s-55296<<10|i-56320)}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,i<128){if((e-=1)<0)break;r.push(i)}else if(i<2048){if((e-=2)<0)break;r.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;r.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;r.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return r}function z(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(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}}).call(e,i(17))},function(t,e,i){var n=i(2),s=i(0),r=i(19),o=i(7),a=function(t,e,i){var u,h,l,c=t&a.F,p=t&a.G,f=t&a.S,d=t&a.P,m=t&a.B,y=t&a.W,v=p?s:s[e]||(s[e]={}),_=v.prototype,g=p?n:f?n[e]:(n[e]||{}).prototype;for(u in p&&(i=e),i)(h=!c&&g&&void 0!==g[u])&&u in v||(l=h?g[u]:i[u],v[u]=p&&"function"!=typeof g[u]?i[u]:m&&h?r(l,n):y&&g[u]==l?function(t){var e=function(e,i,n){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,i)}return new t(e,i,n)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(l):d&&"function"==typeof l?r(Function.call,l):l,d&&((v.virtual||(v.virtual={}))[u]=l,t&a.R&&_&&!_[u]&&o(_,u,l)))};a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,t.exports=a},function(t,e,i){var n=i(3),s=i(21);t.exports=i(8)?function(t,e,i){return n.f(t,e,s(1,i))}:function(t,e,i){return t[e]=i,t}},function(t,e,i){t.exports=!i(14)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){var i={}.hasOwnProperty;t.exports=function(t,e){return i.call(t,e)}},function(t,e,i){var n=i(57),s=i(33);t.exports=function(t){return n(s(t))}},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var u,h=[],l=!1,c=-1;function p(){l&&u&&(l=!1,u.length?h=u.concat(h):c=-1,h.length&&f())}function f(){if(!l){var t=a(p);l=!0;for(var e=h.length;e;){for(u=h,h=[];++c<e;)u&&u[c].run();c=-1,e=h.length}u=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function m(){}s.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];h.push(new d(t,e)),1!==h.length||l||a(f)},d.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(t){return[]},s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}},function(t,e,i){"use strict";var n=Object.keys||function(t){var e=[];for(var i in t)e.push(i);return e};t.exports=c;var s=i(49),r=i(23);r.inherits=i(12);var o=i(73),a=i(50);r.inherits(c,o);for(var u=n(a.prototype),h=0;h<u.length;h++){var l=u[h];c.prototype[l]||(c.prototype[l]=a.prototype[l])}function c(t){if(!(this instanceof c))return new c(t);o.call(this,t),a.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",p)}function p(){this.allowHalfOpen||this._writableState.ended||s(f,this)}function f(t){t.end()}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){t.exports={}},function(t,e,i){var n=i(56),s=i(40);t.exports=Object.keys||function(t){return n(t,s)}},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},function(t,e,i){"use strict";var n=i(80)(!0);i(52)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,i=this._i;return i>=e.length?{value:void 0,done:!0}:(t=n(e,i),this._i+=t.length,{value:t,done:!1})})},function(t,e,i){var n=i(34);t.exports=function(t,e,i){if(n(t),void 0===e)return t;switch(i){case 1:return function(i){return t.call(e,i)};case 2:return function(i,n){return t.call(e,i,n)};case 3:return function(i,n,s){return t.call(e,i,n,s)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e){var i={}.toString;t.exports=function(t){return i.call(t).slice(8,-1)}},function(t,e,i){(function(t){function i(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===i(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===i(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===i(t)},e.isError=function(t){return"[object Error]"===i(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=t.isBuffer}).call(e,i(5).Buffer)},function(t,e){t.exports=!0},function(t,e){var i=0,n=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++i+n).toString(36))}},function(t,e,i){var n=i(3).f,s=i(9),r=i(1)("toStringTag");t.exports=function(t,e,i){t&&!s(t=i?t:t.prototype,r)&&n(t,r,{configurable:!0,value:e})}},function(t,e,i){var n=i(33);t.exports=function(t){return Object(n(t))}},function(t,e,i){i(90);for(var n=i(2),s=i(7),r=i(15),o=i(1)("toStringTag"),a=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var h=a[u],l=n[h],c=l&&l.prototype;c&&!c[o]&&s(c,o,h),r[h]=r.Array}},function(t,e,i){var n;!function(s,r){void 0===(n=function(){return r()}.call(e,i,e,t))||(t.exports=n)}(0,function(){"use strict";var t;function e(e){e(t)}
+var n=i(133),s=i(134),r=i(70);function o(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,i){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(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 c(this,t)}return h(this,t,e,i)}function h(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?function(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");e=void 0===i&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,i):new Uint8Array(e,i,n);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=p(t,e);return t}(t,e,i,n):"string"==typeof e?function(t,e,i){"string"==typeof i&&""!==i||(i="utf8");if(!u.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,i),s=(t=a(t,n)).write(e,i);s!==n&&(t=t.slice(0,s));return t}(t,e,i):function(t,e){if(u.isBuffer(e)){var i=0|f(e.length);return 0===(t=a(t,i)).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||function(t){return t!=t}(e.length)?a(t,0):p(t,e);if("Buffer"===e.type&&r(e.data))return p(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function l(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 c(t,e){if(l(e),t=a(t,e<0?0:0|f(e)),!u.TYPED_ARRAY_SUPPORT)for(var i=0;i<e;++i)t[i]=0;return t}function p(t,e){var i=e.length<0?0:0|f(e.length);t=a(t,i);for(var n=0;n<i;n+=1)t[n]=255&e[n];return t}function f(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function d(t,e){if(u.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 B(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return z(t).length;default:if(n)return B(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function y(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=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:v(t,e,i,n,s);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):v(t,[e],i,n,s);throw new TypeError("val must be string, number or Buffer")}function v(t,e,i,n,s){var r,o=1,a=t.length,u=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;o=2,a/=2,u/=2,i/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(s){var l=-1;for(r=i;r<a;r++)if(h(t,r)===h(e,-1===l?0:r-l)){if(-1===l&&(l=r),r-l+1===u)return l*o}else-1!==l&&(r-=r-l),l=-1}else for(i+u>a&&(i=a-u),r=i;r>=0;r--){for(var c=!0,p=0;p<u;p++)if(h(t,r+p)!==h(e,p)){c=!1;break}if(c)return r}return-1}function _(t,e,i,n){i=Number(i)||0;var s=t.length-i;n?(n=Number(n))>s&&(n=s):n=s;var r=e.length;if(r%2!=0)throw new TypeError("Invalid hex string");n>r/2&&(n=r/2);for(var o=0;o<n;++o){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))return o;t[i+o]=a}return o}function g(t,e,i,n){return U(B(e,t.length-i),t,i,n)}function b(t,e,i,n){return U(function(t){for(var e=[],i=0;i<t.length;++i)e.push(255&t.charCodeAt(i));return e}(e),t,i,n)}function w(t,e,i,n){return b(t,e,i,n)}function S(t,e,i,n){return U(z(e),t,i,n)}function T(t,e,i,n){return U(function(t,e){for(var i,n,s,r=[],o=0;o<t.length&&!((e-=2)<0);++o)i=t.charCodeAt(o),n=i>>8,s=i%256,r.push(s),r.push(n);return r}(e,t.length-i),t,i,n)}function x(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function A(t,e,i){i=Math.min(t.length,i);for(var n=[],s=e;s<i;){var r,o,a,u,h=t[s],l=null,c=h>239?4:h>223?3:h>191?2:1;if(s+c<=i)switch(c){case 1:h<128&&(l=h);break;case 2:128==(192&(r=t[s+1]))&&(u=(31&h)<<6|63&r)>127&&(l=u);break;case 3:r=t[s+1],o=t[s+2],128==(192&r)&&128==(192&o)&&(u=(15&h)<<12|(63&r)<<6|63&o)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:r=t[s+1],o=t[s+2],a=t[s+3],128==(192&r)&&128==(192&o)&&128==(192&a)&&(u=(15&h)<<18|(63&r)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,c=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),s+=c}return function(t){var e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n<e;)i+=String.fromCharCode.apply(String,t.slice(n,n+=k));return i}(n)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.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=o(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,i){return h(null,t,e,i)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,i){return function(t,e,i,n){return l(e),e<=0?a(t,e):void 0!==i?"string"==typeof n?a(t,e).fill(i,n):a(t,e).fill(i):a(t,e)}(null,t,e,i)},u.allocUnsafe=function(t){return c(null,t)},u.allocUnsafeSlow=function(t){return c(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.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},u.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}},u.concat=function(t,e){if(!r(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var i;if(void 0===e)for(e=0,i=0;i<t.length;++i)e+=t[i].length;var n=u.allocUnsafe(e),s=0;for(i=0;i<t.length;++i){var o=t[i];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=o.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.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)m(this,e,e+1);return this},u.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)m(this,e,e+3),m(this,e+1,e+2);return this},u.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)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):function(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))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,i);case"utf8":case"utf-8":return A(this,e,i);case"ascii":return E(this,e,i);case"latin1":case"binary":return O(this,e,i);case"base64":return x(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.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+">"},u.prototype.compare=function(t,e,i,n,s){if(!u.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,o=i-e,a=Math.min(r,o),h=this.slice(n,s),l=t.slice(e,i),c=0;c<a;++c)if(h[c]!==l[c]){r=h[c],o=l[c];break}return r<o?-1:o<r?1:0},u.prototype.includes=function(t,e,i){return-1!==this.indexOf(t,e,i)},u.prototype.indexOf=function(t,e,i){return y(this,t,e,i,!0)},u.prototype.lastIndexOf=function(t,e,i){return y(this,t,e,i,!1)},u.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 r=!1;;)switch(n){case"hex":return _(this,t,e,i);case"utf8":case"utf-8":return g(this,t,e,i);case"ascii":return b(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return S(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,i);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),r=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function E(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 O(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 M(t,e,i){var n=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>n)&&(i=n);for(var s="",r=e;r<i;++r)s+=j(t[r]);return s}function P(t,e,i){for(var n=t.slice(e,i),s="",r=0;r<n.length;r+=2)s+=String.fromCharCode(n[r]+256*n[r+1]);return s}function C(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 I(t,e,i,n,s,r){if(!u.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 R(t,e,i,n){e<0&&(e=65535+e+1);for(var s=0,r=Math.min(t.length-i,2);s<r;++s)t[i+s]=(e&255<<8*(n?s:1-s))>>>8*(n?s:1-s)}function F(t,e,i,n){e<0&&(e=4294967295+e+1);for(var s=0,r=Math.min(t.length-i,4);s<r;++s)t[i+s]=e>>>8*(n?s:3-s)&255}function N(t,e,i,n,s,r){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function D(t,e,i,n,r){return r||N(t,0,i,4),s.write(t,e,i,n,23,4),i+4}function q(t,e,i,n,r){return r||N(t,0,i,8),s.write(t,e,i,n,52,8),i+8}u.prototype.slice=function(t,e){var i,n=this.length;if(t=~~t,e=void 0===e?n:~~e,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),e<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(i=this.subarray(t,e)).__proto__=u.prototype;else{var s=e-t;i=new u(s,void 0);for(var r=0;r<s;++r)i[r]=this[r+t]}return i},u.prototype.readUIntLE=function(t,e,i){t|=0,e|=0,i||C(t,e,this.length);for(var n=this[t],s=1,r=0;++r<e&&(s*=256);)n+=this[t+r]*s;return n},u.prototype.readUIntBE=function(t,e,i){t|=0,e|=0,i||C(t,e,this.length);for(var n=this[t+--e],s=1;e>0&&(s*=256);)n+=this[t+--e]*s;return n},u.prototype.readUInt8=function(t,e){return e||C(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||C(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||C(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||C(t,e,this.length);for(var n=this[t],s=1,r=0;++r<e&&(s*=256);)n+=this[t+r]*s;return n>=(s*=128)&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||C(t,e,this.length);for(var n=e,s=1,r=this[t+--n];n>0&&(s*=256);)r+=this[t+--n]*s;return r>=(s*=128)&&(r-=Math.pow(2,8*e)),r},u.prototype.readInt8=function(t,e){return e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||C(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},u.prototype.readInt16BE=function(t,e){e||C(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},u.prototype.readInt32LE=function(t,e){return e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||C(t,4,this.length),s.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||C(t,4,this.length),s.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||C(t,8,this.length),s.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||C(t,8,this.length),s.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||I(this,t,e,i,Math.pow(2,8*i)-1,0);var s=1,r=0;for(this[e]=255&t;++r<i&&(s*=256);)this[e+r]=t/s&255;return e+i},u.prototype.writeUIntBE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||I(this,t,e,i,Math.pow(2,8*i)-1,0);var s=i-1,r=1;for(this[e+s]=255&t;--s>=0&&(r*=256);)this[e+s]=t/r&255;return e+i},u.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):R(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):R(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):F(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var s=Math.pow(2,8*i-1);I(this,t,e,i,s-1,-s)}var r=0,o=1,a=0;for(this[e]=255&t;++r<i&&(o*=256);)t<0&&0===a&&0!==this[e+r-1]&&(a=1),this[e+r]=(t/o>>0)-a&255;return e+i},u.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var s=Math.pow(2,8*i-1);I(this,t,e,i,s-1,-s)}var r=i-1,o=1,a=0;for(this[e+r]=255&t;--r>=0&&(o*=256);)t<0&&0===a&&0!==this[e+r+1]&&(a=1),this[e+r]=(t/o>>0)-a&255;return e+i},u.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):R(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):R(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):F(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,i){return D(this,t,e,!0,i)},u.prototype.writeFloatBE=function(t,e,i){return D(this,t,e,!1,i)},u.prototype.writeDoubleLE=function(t,e,i){return q(this,t,e,!0,i)},u.prototype.writeDoubleBE=function(t,e,i){return q(this,t,e,!1,i)},u.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||!u.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},u.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&&!u.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;var r;if(e>>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(r=e;r<i;++r)this[r]=t;else{var o=u.isBuffer(t)?t:B(new u(t,n).toString()),a=o.length;for(r=0;r<i-e;++r)this[r+e]=o[r%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function j(t){return t<16?"0"+t.toString(16):t.toString(16)}function B(t,e){var i;e=e||1/0;for(var n=t.length,s=null,r=[],o=0;o<n;++o){if((i=t.charCodeAt(o))>55295&&i<57344){if(!s){if(i>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&r.push(239,191,189);continue}s=i;continue}if(i<56320){(e-=3)>-1&&r.push(239,191,189),s=i;continue}i=65536+(s-55296<<10|i-56320)}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,i<128){if((e-=1)<0)break;r.push(i)}else if(i<2048){if((e-=2)<0)break;r.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;r.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;r.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return r}function z(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(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}}).call(e,i(17))},function(t,e,i){var n=i(4),s=i(21);t.exports=i(8)?function(t,e,i){return n.f(t,e,s(1,i))}:function(t,e,i){return t[e]=i,t}},function(t,e,i){t.exports=!i(14)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){var i={}.hasOwnProperty;t.exports=function(t,e){return i.call(t,e)}},function(t,e,i){var n=i(57),s=i(33);t.exports=function(t){return n(s(t))}},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var u,h=[],l=!1,c=-1;function p(){l&&u&&(l=!1,u.length?h=u.concat(h):c=-1,h.length&&f())}function f(){if(!l){var t=a(p);l=!0;for(var e=h.length;e;){for(u=h,h=[];++c<e;)u&&u[c].run();c=-1,e=h.length}u=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function m(){}s.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];h.push(new d(t,e)),1!==h.length||l||a(f)},d.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(t){return[]},s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}},function(t,e,i){"use strict";var n=Object.keys||function(t){var e=[];for(var i in t)e.push(i);return e};t.exports=c;var s=i(49),r=i(23);r.inherits=i(12);var o=i(73),a=i(50);r.inherits(c,o);for(var u=n(a.prototype),h=0;h<u.length;h++){var l=u[h];c.prototype[l]||(c.prototype[l]=a.prototype[l])}function c(t){if(!(this instanceof c))return new c(t);o.call(this,t),a.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",p)}function p(){this.allowHalfOpen||this._writableState.ended||s(f,this)}function f(t){t.end()}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){t.exports={}},function(t,e,i){var n=i(56),s=i(40);t.exports=Object.keys||function(t){return n(t,s)}},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},function(t,e,i){"use strict";var n=i(80)(!0);i(52)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,i=this._i;return i>=e.length?{value:void 0,done:!0}:(t=n(e,i),this._i+=t.length,{value:t,done:!1})})},function(t,e,i){var n=i(34);t.exports=function(t,e,i){if(n(t),void 0===e)return t;switch(i){case 1:return function(i){return t.call(e,i)};case 2:return function(i,n){return t.call(e,i,n)};case 3:return function(i,n,s){return t.call(e,i,n,s)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e){var i={}.toString;t.exports=function(t){return i.call(t).slice(8,-1)}},function(t,e,i){(function(t){function i(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===i(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===i(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===i(t)},e.isError=function(t){return"[object Error]"===i(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=t.isBuffer}).call(e,i(6).Buffer)},function(t,e){t.exports=!0},function(t,e){var i=0,n=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++i+n).toString(36))}},function(t,e,i){var n=i(4).f,s=i(9),r=i(1)("toStringTag");t.exports=function(t,e,i){t&&!s(t=i?t:t.prototype,r)&&n(t,r,{configurable:!0,value:e})}},function(t,e,i){var n=i(33);t.exports=function(t){return Object(n(t))}},function(t,e,i){i(90);for(var n=i(2),s=i(7),r=i(15),o=i(1)("toStringTag"),a=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var h=a[u],l=n[h],c=l&&l.prototype;c&&!c[o]&&s(c,o,h),r[h]=r.Array}},function(t,e,i){var n;!function(s,r){void 0===(n=function(){return r()}.call(e,i,e,t))||(t.exports=n)}(0,function(){"use strict";var t;function e(e){e(t)}
/**
* Tone.js
* @author Yotam Mann
* @license http://opensource.org/licenses/MIT MIT License
* @copyright 2014-2018 Yotam Mann
- */return function(e){t=e()}(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 r in e){i=e[r];var o=this;if(-1!==r.indexOf(".")){for(var a=r.split("."),u=0;u<a.length-1;u++)if((o=o[a[u]])instanceof t){a.splice(0,u+1);var h=a.join(".");o.set(h,i);continue t}r=a[a.length-1]}var l=o[r];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?o[r]=i:l instanceof t?l.set(i):l!==i&&(o[r]=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],r=this,o=i;if(-1!==s.indexOf(".")){for(var a=s.split("."),u=0;u<a.length-1;u++){var h=a[u];o[h]=o[h]||{},o=o[h],r=r[h]}s=a[a.length-1]}var l=r[s];t.isObject(e[s])?o[s]=l.get():t.Signal&&l instanceof t.Signal?o[s]=l.value:t.Param&&l instanceof t.Param?o[s]=l.value:l instanceof AudioParam?o[s]=l.value:l instanceof t?o[s]=l.get():!t.isFunction(l)&&t.isDefined(l)&&(o[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 r=0;r<i.length;r++)s[i[r]]=e[r];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 r in i)n[r]=t.defaultArg(e[r],i[r]);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}),e(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 r=this._events[e],o=0;o<r.length;o++)r[o]===i&&r.splice(o,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],r=t.Emitter.prototype[s];e[s]=r}return t.Emitter},t.Emitter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._events=null,this},t.Emitter}),e(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,r=s;if(s>0&&this._timeline[s-1][i]<=e)return s-1;for(;n<r;){var o=Math.floor(n+(r-n)/2),a=this._timeline[o],u=this._timeline[o+1];if(a[i]===e){for(var h=o;h<this._timeline.length;h++){this._timeline[h][i]===e&&(o=h)}return o}if(a[i]<e&&u[i]>e)return o;a[i]>e?r=o:n=o+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}),e(function(t){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))}))}),e(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))})}}),e(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.");for(var n in this._context=i.context,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(){for(var e in t.Emitter.prototype.dispose.call(this),this._ticker.dispose(),this._ticker=null,this._timeouts.dispose(),this._timeouts=null,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(){var e=AudioNode.prototype.connect,i=AudioNode.prototype.disconnect;function n(i,n,s){if(i.input)return s=t.defaultArg(s,0),t.isArray(i.input)?this.connect(i.input[s]):this.connect(i.input,n,s);try{return i instanceof AudioNode?(e.call(this,i,n,s),i):(e.call(this,i,n),i)}catch(t){throw new Error("error connecting to node: "+i+"\n"+t)}}AudioNode.prototype.connect!==n&&(AudioNode.prototype.connect=n,AudioNode.prototype.disconnect=function(e,n,s){if(e&&e.input&&t.isArray(e.input))s=t.defaultArg(s,0),this.disconnect(e.input[s],n,0);else if(e&&e.input)this.disconnect(e.input,n,s);else try{i.apply(this,arguments)}catch(t){throw new Error("error disconnecting node: "+e+"\n"+t)}})}),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}),e(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}),e(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}),e(function(t){if(t.supported){var e=navigator.userAgent.toLowerCase();if(e.includes("safari")&&!e.includes("chrome")){var i=function(t){for(var e in this._internalNode=this.input=this.output=t._native_createWaveShaper(),this._curve=null,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)}}}}),e(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}),e(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}),e(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()]+12*(parseInt(n)+1);return"midi"===this._defaultUnits?s:t.Frequency.mtof(s)}},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,r=Math.floor(s/12);return r<0&&(s+=-12*r),i[s%12]+r.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}),e(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 r=i[0],o=t.Time(i[0]).toSeconds();return i.forEach(function(i){var n=t.Time(i).toSeconds();Math.abs(n-e)<Math.abs(o-e)&&(r=i,o=n)}),r},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()).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}),e(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}),e(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}),e(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),r=s;if(null===n)r=s;else if(n.type===t.Param.AutomationType.Target){var o,a=this._events.getBefore(n.time);o=null===a?s:a.value,r=this._exponentialApproach(n.time,o,n.value,n.constant,e)}else r=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 r},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 r=n/(e.length-1),o=1;o<e.length;o++)this.linearRampToValueAtTime(e[o]*s,i+o*r);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}),e(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}),e(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})}}),e(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}),e(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)}}}),e(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}),e(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}),e(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,r=this.toSeconds(this.decay);i=t.defaultArg(i,1);var o=this.getValueAtTime(e);o>0&&(s=(1-o)/(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 u=1-s/n,h=Math.floor(u*this._attackCurve.length);(a=this._attackCurve.slice(h))[0]=o}this._sig.setValueCurveAtTime(a,e,s,i)}return r&&this._sig.targetRampTo(i*this.sustain,r,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(){var e,i,n=[];for(e=0;e<128;e++)n[e]=Math.sin(e/127*(Math.PI/2));var s=[];for(e=0;e<127;e++){i=e/127;var r=Math.sin(i*(2*Math.PI)*6.4-Math.PI/2)+1;s[e]=r/10+.83*i}s[127]=1;var o=[];for(e=0;e<128;e++)o[e]=Math.ceil(e/127*5)/5;var a=[];for(e=0;e<128;e++)i=e/127,a[e]=.5*(1-Math.cos(Math.PI*i));var u=[];for(e=0;e<128;e++){i=e/127;var h=4*Math.pow(i,3)+.2,l=Math.cos(h*Math.PI*2*i);u[e]=Math.abs(l*(1-i))}function c(t){for(var e=new Array(t.length),i=0;i<t.length;i++)e[i]=1-t[i];return e}t.Envelope.Type={linear:"linear",exponential:"exponential",bounce:{In:c(u),Out:u},cosine:{In:n,Out:function(t){return t.slice(0).reverse()}(n)},step:{In:o,Out:c(o)},ripple:{In:s,Out:c(s)},sine:{In:a,Out:c(a)}}}(),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}),e(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}),e(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}))}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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].indexOf(e);if(-1===i)throw new RangeError("Tone.Filter: rolloff can only be -12, -24, -48 or -96");i+=1,this._rolloff=e,this.input.disconnect();for(var n=0;n<this._filters.length;n++)this._filters[n].disconnect(),this._filters[n]=null;this._filters=new Array(i);for(var s=0;s<i;s++){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[s]=r}var o=[this.input].concat(this._filters).concat([this.output]);t.connectSeries.apply(t,o)}}),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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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),r=this._getTicksUntilEvent(s,i);return n.ticks=Math.max(r,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)),r=0;r<=s;r++){var o=i*r+e,a=this._exponentialApproach(n.time,n.value,t,i,o);this.linearRampToValueAtTime(this._toUnits(a),o)}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,r=0;r<=n;r++){var o=s*r+i.time,a=this._exponentialInterpolate(i.time,i.value,e,t,o);this.linearRampToValueAtTime(this._toUnits(a),o)}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),r=this.getValueAtTime(i);return this._events.get(i).time===i&&this._events.get(i).type===t.Param.AutomationType.SetValue&&(r=this.getValueAtTime(i-this.sampleTime)),.5*(i-e.time)*(s+r)+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),r=(this.getValueAtTime(n.time)-s)/(n.time-i.time),o=Math.sqrt(Math.pow(s,2)-2*r*(i.ticks-e)),a=(-s+o)/r;return(a>0?a:(-s-o)/r)+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}),e(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);i>=0;i--){var n=this._timeline[i];if(n.state===t)return n}},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}),e(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,r=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&&(r=n.ticks,i=n.time),s.state===t.State.Started&&e.state!==t.State.Started&&(r+=this.frequency.getTicksAtTime(e.time)-this.frequency.getTicksAtTime(i)),s=e}.bind(this)),this._state.remove(n),r},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,r=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&&(r=n.seconds,i=n.time),s.state===t.State.Started&&e.state!==t.State.Started&&(r+=e.time-i),s=e}.bind(this)),this._state.remove(n),r},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),r=Math.max(n.time,s.time),o=this.frequency.getTicksAtTime(r)+e-n.ticks;return this.frequency.getTimeOfTick(o)},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 r=this.frequency.getTicksAtTime(e),o=(r-this.frequency.getTicksAtTime(s.time))%1;0!==o&&(o=1-o);for(var a=this.frequency.getTimeOfTick(r+o),u=null;a<i&&this._state;){try{n(a,Math.round(this.getTicksAtTime(a)))}catch(t){u=t;break}this._state&&(a+=this.frequency.getDurationOfTicks(1,a))}}if(u)throw u;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}),e(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}),e(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;if(t.getBalance()>0)if(null===t.left.right)(e=t.left).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).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}),e(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}),e(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}),e(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}),e(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 r=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(r,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=e-this.getTicksAtTime(i)%e;return this._clock.nextTickTime(n,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}),e(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}),e(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}),e(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 r=t.Transport.schedule(function(t){this._start(t,i,n)}.bind(this),e);this._scheduled.push(r),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,r=i-this.toSeconds(n.time);n.duration&&(s=this.toSeconds(n.duration)-r),this._start(e,this.toSeconds(n.offset)+r,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}),e(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]}))}),e(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,r){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,r(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 r=0;r<i;r++)s.copyToChannel(t[r],r);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 r=this.toArray(s),o=0;o<r.length;o++)i[o]+=r[o];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)),r=[],o=0;o<this.numberOfChannels;o++)r[o]=this.toArray(o).slice(n,s);return(new t.Buffer).fromArray(r)},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){i=t.defaultArg(i,t.noOp);var s=e.match(/\[(.+\|?)+\]$/);if(s){for(var r=s[1].split("|"),o=r[0],a=0;a<r.length;a++)if(t.Buffer.supportsType(r[a])){o=r[a];break}e=e.replace(s[0],o)}function u(e){if(t.Buffer._removeFromDownloadQueue(l),t.Buffer.emit("error",e),!n)throw e;n(e)}function h(){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)}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,h(),i(e),t.Buffer._removeFromDownloadQueue(l),0===t.Buffer._downloadQueue.length&&t.Buffer.emit("load")}).catch(function(){t.Buffer._removeFromDownloadQueue(l),u("Tone.Buffer: could not decode audio data: "+e)}):u("Tone.Buffer: could not locate file: "+e)}),l.addEventListener("error",u),l.addEventListener("progress",function(t){t.lengthComputable&&(l.progress=t.loaded/t.total*.95,h())}),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(){var e,i;function n(){t.Buffer.off("load",e),t.Buffer.off("error",i)}return new Promise(function(n,s){e=function(){n()},i=function(){s()},t.Buffer.on("load",e),t.Buffer.on("error",i)}).then(n).catch(function(t){throw n(),new Error(t)})},t.Buffer}),e(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}),e(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),r=new Float32Array(n),o=1;if(e===t.Oscillator.Type.Custom)n=o=this._partials.length+1;else{var a=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);a&&(o=parseInt(a[2])+1,e=a[1],n=o=Math.max(o,2))}for(var u=1;u<n;++u){var h,l=2/(u*Math.PI);switch(e){case t.Oscillator.Type.Sine:h=u<=o?1:0;break;case t.Oscillator.Type.Square:h=1&u?2*l:0;break;case t.Oscillator.Type.Sawtooth:h=l*(1&u?1:-1);break;case t.Oscillator.Type.Triangle:h=1&u?l*l*2*(u-1>>1&1?-1:1):0;break;case t.Oscillator.Type.Custom:h=this._partials[u-1];break;default:throw new TypeError("Tone.Oscillator: invalid type: "+e)}0!==h?(s[u]=-h*Math.sin(i*u),r[u]=h*Math.cos(i*u)):(s[u]=0,r[u]=0)}return[s,r]},t.Oscillator.prototype._inverseFFT=function(t,e,i){for(var n=0,s=t.length,r=0;r<s;r++)n+=t[r]*Math.cos(r*i)+e[r]*Math.sin(r*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,r=0;r<8;r++)n=Math.max(this._inverseFFT(e,i,r/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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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,r=new t.Gain,o=this.input=new t.Split;(new t.Zero).fan(i,n);var a=this.output=new t.Merge;o.left.chain(s,a.left),o.right.chain(r,a.right),this.pan.chain(n,s.gain),this.pan.chain(i,r.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)}}}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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=[],r=0;r<i.length;r++)s[r]=this._interpolate(e,i[r],n[r]);return s}if(t.isObject(i)){var o={};for(var a in i)o[a]=this._interpolate(e,i[a],n[a]);return o}return(1-e)*(i=this._toNumber(i))+e*(n=this._toNumber(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}),e(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,r=0;r<i.length;r++){var o=i[r];if(n>s&&n<s+o){var a=e[r];t.isObject(a)?this.value=a.value:this.value=a}s+=o}else this.value=e}return this.value},t.CtrlMarkov.prototype._getProbDistribution=function(e){for(var i=[],n=0,s=!1,r=0;r<e.length;r++){var o=e[r];t.isObject(o)?(s=!0,i[r]=o.probability):i[r]=1/e.length,n+=i[r]}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}),e(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.index>=this.values.length&&(this.index=0)):e===t.CtrlPattern.Type.Down?(this.index--,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.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}),e(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}),e(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);for(var s in t.call(this),this._buffers={},this.baseUrl=n.baseUrl,this._loadingCount=0,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){this._loadingCount--,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(){for(var e in t.prototype.dispose.call(this),this._buffers)this._buffers[e].dispose();return this._buffers=null,this},t.Buffers}),e(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}),e(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}),e(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,r){if(this.context.listener.forwardX){var o=this.now();this.context.listener.forwardX.setTargetAtTime(t,o,this._rampTimeConstant),this.context.listener.forwardY.setTargetAtTime(e,o,this._rampTimeConstant),this.context.listener.forwardZ.setTargetAtTime(i,o,this._rampTimeConstant),this.context.listener.upX.setTargetAtTime(n,o,this._rampTimeConstant),this.context.listener.upY.setTargetAtTime(s,o,this._rampTimeConstant),this.context.listener.upZ.setTargetAtTime(r,o,this._rampTimeConstant)}else this.context.listener.setOrientation(t,e,i,n,s,r);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}),e(function(t){return t.Offline=function(e,i){var n,s=t.context.sampleRate,r=t.context,o=function e(i,n,s,r){r=t.defaultArg(r,0);var o=new t.OfflineContext(2,n,s);t.context=o;var a=i(t.Transport);return o.currentTime>0&&r<1e3?e(i,n,s,++r):{response:a,context:o}}(e,i,s),a=o.response,u=o.context;return n=a instanceof Promise?a.then(function(){return u.render()}):u.render(),t.context=r,n.then(function(e){return new t.Buffer(e)})},t.Offline}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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 r=this.context.createBiquadFilter();r.type="allpass",r.frequency.value=i[s],this._allpassFiltersL.push(r)}for(var o=0;o<i.length;o++){var a=this.context.createBiquadFilter();a.type="allpass",a.frequency.value=i[o],this._allpassFiltersR.push(a)}for(var u=0;u<e.length;u++){var h=new t.LowpassCombFilter(e[u]);u<e.length/2?this.effectSendL.chain(h,this._allpassFiltersL[0]):this.effectSendR.chain(h,this._allpassFiltersR[0]),this.roomSize.connect(h.resonance),this.dampening.connect(h.dampening),this._combFilters.push(h)}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}),e(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 r=0;r<n.length;r++){var o=this.context.createBiquadFilter();o.type="allpass",o.frequency.value=n[r],this._allpassFilters.push(o)}for(var a=0;a<e.length;a++){var u=new t.FeedbackCombFilter(e[a],.1);this._scaleRoomSize.connect(u.resonance),u.resonance.value=i[a],this._allpassFilters[this._allpassFilters.length-1].connect(u),a<e.length/2?u.connect(this.effectReturnL):u.connect(this.effectReturnR),this._feedbackCombFilters.push(u)}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}),e(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}),e(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),r=0;r<e;r++){var o=this.context.createBiquadFilter();o.type="allpass",n.connect(o.Q),i.connect(o.frequency),s[r]=o}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}),e(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}),e(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}),e(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}),e(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,r){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,r=this.toSeconds(t.defaultArg(r,this.fadeIn)),this.fadeIn=r,r>0?(this._gainNode.gain.setValueAtTime(0,e),"linear"===this.curve?this._gainNode.gain.linearRampToValueAtTime(this._gain,e+r):this._gainNode.gain.exponentialApproachValueAtTime(this._gain,e,r)):this._gainNode.gain.setValueAtTime(s,e),this._startTime=e;var o=this.toSeconds(t.defaultArg(n,this.buffer.duration-i%this.buffer.duration));if(o=Math.max(o,0),t.isDefined(n)&&(this.loop||(o=Math.min(o,this.buffer.duration-i%this.buffer.duration)),this.stop(e+o,this.fadeOut)),this.loop){var a=this.loopEnd||this.buffer.duration,u=this.loopStart;i>=a&&(i=(i-u)%(a-u)+u)}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));var s=e-(i=Math.min(n,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}),e(function(t){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 i))throw new TypeError("Tone.Noise: invalid type: "+e);if(this._type=e,this.state===t.State.Started){var n=this.now();this._stop(n),this._start(n)}}}}),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 n=i[this._type];this._source=new t.BufferSource(n).connect(this.output),this._source.loop=!0,this._source.playbackRate.value=this._playbackRate,this._source.start(this.toSeconds(e),Math.random()*(n.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 e={pink:function(){for(var t=[],e=0;e<2;e++){var i,n,s,r,o,a,u,h=new Float32Array(220500);t[e]=h,i=n=s=r=o=a=u=0;for(var l=0;l<220500;l++){var c=2*Math.random()-1;i=.99886*i+.0555179*c,n=.99332*n+.0750759*c,s=.969*s+.153852*c,r=.8665*r+.3104856*c,o=.55*o+.5329522*c,a=-.7616*a-.016898*c,h[l]=i+n+s+r+o+a+u+.5362*c,h[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 r=2*Math.random()-1;i[s]=(n+.02*r)/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}()},i={};function n(){for(var n in e)i[n]=(new t.Buffer).fromArray(e[n])}return t.getContext(n),t.Context.on("init",n),t.Noise}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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 r=t.Ticks(this._getLoopDuration());e.id=t.Transport.scheduleRepeat(this._tick.bind(this),r,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}),e(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}),e(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 r=this._events[s];if(Math.abs(e.toTicks()-r.startOffset)<n)return t.isDefined(i)&&(r.value=i),r}return t.isDefined(i)?(this.add(e,i),this._events[this._events.length-1]):null},t.Part.prototype.add=function(e,i){var n;return e.hasOwnProperty("time")&&(e=(i=e).time),e=this.toTicks(e),i instanceof t.Event?(n=i).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")&&(e=(i=e).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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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="PulseOscillator",i="PWMOscillator",n="Oscillator",s="FMOscillator",r="AMOscillator",o="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===s?t="fm":this._sourceType===r?t="am":this._sourceType===o&&(t="fat"),t+this._oscillator.type},set:function(t){"fm"===t.substr(0,2)?(this._createNewOscillator(s),this._oscillator.type=t.substr(2)):"am"===t.substr(0,2)?(this._createNewOscillator(r),this._oscillator.type=t.substr(2)):"fat"===t.substr(0,3)?(this._createNewOscillator(o),this._oscillator.type=t.substr(3)):"pwm"===t?this._createNewOscillator(i):"pulse"===t?this._createNewOscillator(e):(this._createNewOscillator(n),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)return this._oscillator.width}}),Object.defineProperty(t.OmniOscillator.prototype,"count",{get:function(){if(this._sourceType===o)return this._oscillator.count},set:function(t){this._sourceType===o&&(this._oscillator.count=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"spread",{get:function(){if(this._sourceType===o)return this._oscillator.spread},set:function(t){this._sourceType===o&&(this._oscillator.spread=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationType",{get:function(){if(this._sourceType===s||this._sourceType===r)return this._oscillator.modulationType},set:function(t){this._sourceType!==s&&this._sourceType!==r||(this._oscillator.modulationType=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationIndex",{get:function(){if(this._sourceType===s)return this._oscillator.modulationIndex}}),Object.defineProperty(t.OmniOscillator.prototype,"harmonicity",{get:function(){if(this._sourceType===s||this._sourceType===r)return this._oscillator.harmonicity}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationFrequency",{get:function(){if(this._sourceType===i)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}),e(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],r=t.Transport.schedule(function(t){e[i]=t,n.apply(this,e)}.bind(this),s);this._scheduledEvents.push(r)}.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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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);var n=(t=this.toFrequency(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}),e(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 r=new t.Multiply(e[n]);this._freqMultipliers[n]=r,this.frequency.chain(r,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}),e(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}),e(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}),e(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)).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],r=this._triggers[0],o=1;o<this._triggers.length;o++)this._triggers[o].release<r.release&&(r=this._triggers[o]);r.release=1/0,r.note=JSON.stringify(s),r.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 r=0;r<e.length;r++){var o=i[Math.min(r,i.length-1)];this.triggerRelease(e[r],n+this.toSeconds(o))}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 r=this._triggers[s];r.note===n&&r.release>e&&(r.voice.triggerRelease(e),r.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}),e(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 r in e)if(t.isNote(r)){s[t.Frequency(r).toMidi()]=e[r]}else{if(isNaN(parseFloat(r)))throw new Error("Tone.Sampler: url keys must be the note's pitch");s[r]=e[r]}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(),r=this._findClosest(s);if(null!==r){var o=s-r,a=this._buffers.get(o),u=new t.BufferSource({buffer:a,playbackRate:t.intervalToFrequencyRatio(r),fadeIn:this.attack,fadeOut:this.release,curve:"exponential"}).connect(this.output);u.start(i,0,a.duration,n),t.isArray(this._activeSources[s])||(this._activeSources[s]=[]),this._activeSources[s].push({note:s,source:u})}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){for(var e in t=this.toSeconds(t),this._activeSources)for(var i=this._activeSources[e];i.length;){i.shift().source.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(){for(var e in t.Instrument.prototype.dispose.call(this),this._buffers.dispose(),this._buffers=null,this._activeSources)this._activeSources[e].forEach(function(t){t.source.dispose()});return this._activeSources=null,this},t.Sampler}),e(function(t){t.supported&&(OscillatorNode.prototype.setPeriodicWave||(OscillatorNode.prototype.setPeriodicWave=OscillatorNode.prototype.setWaveTable),AudioContext.prototype.createPeriodicWave||(AudioContext.prototype.createPeriodicWave=AudioContext.prototype.createWaveTable))}),e(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}),e(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}),e(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}),e(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}),e(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))(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 r=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(r),this._loop&&t.isUndef(n)?r.start(e,i):r.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),r=this._elapsedTime.getTimeOfTick(s*this.buffer.duration,i?i.time-this.sampleTime:1/0);this.stop(r)}},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}),e(function(t){return t.Players=function(e){var i=Array.prototype.slice.call(arguments);i.shift();var n=t.defaults(i,["onload"],t.Players);for(var s in 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,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){this._loadingCount--,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}),e(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}),e(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}),t})},function(t,e){e.f={}.propertyIsEnumerable},function(t,e,i){"use strict";(function(t){var n=i(5),s=n.Buffer,r=n.SlowBuffer,o=n.kMaxLength||2147483647;e.alloc=function(t,e,i){if("function"==typeof s.alloc)return s.alloc(t,e,i);if("number"==typeof i)throw new TypeError("encoding must not be number");if("number"!=typeof t)throw new TypeError("size must be a number");if(t>o)throw new RangeError("size is too large");var n=i,r=e;void 0===r&&(n=void 0,r=0);var a=new s(t);if("string"==typeof r)for(var u=new s(r,n),h=u.length,l=-1;++l<t;)a[l]=u[l%h];else a.fill(r);return a},e.allocUnsafe=function(t){if("function"==typeof s.allocUnsafe)return s.allocUnsafe(t);if("number"!=typeof t)throw new TypeError("size must be a number");if(t>o)throw new RangeError("size is too large");return new s(t)},e.from=function(e,i,n){if("function"==typeof s.from&&(!t.Uint8Array||Uint8Array.from!==s.from))return s.from(e,i,n);if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("string"==typeof e)return new s(e,i);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var r=i;if(1===arguments.length)return new s(e);void 0===r&&(r=0);var o=n;if(void 0===o&&(o=e.byteLength-r),r>=e.byteLength)throw new RangeError("'offset' is out of bounds");if(o>e.byteLength-r)throw new RangeError("'length' is out of bounds");return new s(e.slice(r,r+o))}if(s.isBuffer(e)){var a=new s(e.length);return e.copy(a,0,0,e.length),a}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new s(e);if("Buffer"===e.type&&Array.isArray(e.data))return new s(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},e.allocUnsafeSlow=function(t){if("function"==typeof s.allocUnsafeSlow)return s.allocUnsafeSlow(t);if("number"!=typeof t)throw new TypeError("size must be a number");if(t>=o)throw new RangeError("size is too large");return new r(t)}}).call(e,i(17))},function(t,e){var i=Math.ceil,n=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?n:i)(t)}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,i){var n=i(20),s=i(2).document,r=n(s)&&n(s.createElement);t.exports=function(t){return r?s.createElement(t):{}}},function(t,e,i){var n=i(20);t.exports=function(t,e){if(!n(t))return t;var i,s;if(e&&"function"==typeof(i=t.toString)&&!n(s=i.call(t)))return s;if("function"==typeof(i=t.valueOf)&&!n(s=i.call(t)))return s;if(!e&&"function"==typeof(i=t.toString)&&!n(s=i.call(t)))return s;throw TypeError("Can't convert object to primitive value")}},function(t,e,i){var n=i(32),s=Math.min;t.exports=function(t){return t>0?s(n(t),9007199254740991):0}},function(t,e,i){var n=i(39)("keys"),s=i(25);t.exports=function(t){return n[t]||(n[t]=s(t))}},function(t,e,i){var n=i(2),s=n["__core-js_shared__"]||(n["__core-js_shared__"]={});t.exports=function(t){return s[t]||(s[t]={})}},function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,e,i){var n=i(42),s=i(1)("iterator"),r=i(15);t.exports=i(0).getIteratorMethod=function(t){if(void 0!=t)return t[s]||t["@@iterator"]||r[n(t)]}},function(t,e,i){var n=i(22),s=i(1)("toStringTag"),r="Arguments"==n(function(){return arguments}());t.exports=function(t){var e,i,o;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),s))?i:r?n(e):"Object"==(o=n(e))&&"function"==typeof e.callee?"Arguments":o}},function(t,e){e.f=Object.getOwnPropertySymbols},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.browser=e.isDesktop=e.isMobile=e.isAndroid=e.isIpad=e.isIphone=void 0;var n=a(i(102)),s=a(i(65));e.choice=function(t){return t[Math.floor(Math.random()*t.length)]},e.mod=function(t,e){return t-e*Math.floor(t/e)},e.norm=function(t,e,i){return(t-e)/(i-e)},e.requestAudioContext=function(t){if(c){var e=document.createElement("div"),i=document.createElement("div");i.innerHTML="Tap to start - please unmute your phone",(0,s.default)(e.style,{position:"absolute",width:"100%",height:"100%",zIndex:"10000",top:"0px",left:"0px",backgroundColor:"rgba(0, 0, 0, 0.8)"}),(0,s.default)(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),o.default.setContext(r.default.context),o.default.on(i),o.default.onStarted(function(i){e.remove(),t()})}else t()},e.dataURItoBlob=function(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),r=0;r<e.length;r++)s[r]=e.charCodeAt(r);return new Blob([n],{type:i})},e.ftom=function(t){return 69+12*(0,n.default)(t/440)},e.mtof=function(t){return 440*Math.pow(2,(t-69)/12)},e.tap=function(t){return function(e){f.isMobile?t():e.press&&t()}},e.get_diff_bounds=function(t){var e=t.map(function(t){var e=Math.min.apply(Math,t),i=Math.max.apply(Math,t);return i-e}),i=Math.min.apply(Math,e),n=Math.max.apply(Math,e);return{min:i,max:n}},e.get_bounds=function(t){var e=t.lines,i=(e=e.map(function(t){return t.map(function(t){return parseFloat(t)})})).reduce(function(t,e){return e.reduce(function(t,e){return Math.max(t,e)},t)},-1/0),n=e.reduce(function(t,e){return e.reduce(function(t,e){return Math.min(t,e)},t)},1/0);return{rows:e,max:i,min:n}},e.transpose=function(t){for(var e=t[0].length,i=t.length,n=new Array(e),s=0;s<e;s++){n[s]=new Array(i);for(var r=0;r<i;r++)n[s][r]=t[r][s]}return n};var r=a(i(29)),o=a(i(105));function a(t){return t&&t.__esModule?t:{default:t}}var u=e.isIphone=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i),h=e.isIpad=navigator.userAgent.match(/iPad/i),l=e.isAndroid=navigator.userAgent.match(/Android/i),c=e.isMobile=u||h||l,p=e.isDesktop=!c;document.body.classList.add(c?"mobile":"desktop");var f=e.browser={isIphone:u,isIpad:h,isMobile:c,isDesktop:p}},function(t,e,i){e.f=i(1)},function(t,e,i){var n=i(2),s=i(0),r=i(24),o=i(45),a=i(3).f;t.exports=function(t){var e=s.Symbol||(s.Symbol=r?{}:n.Symbol||{});"_"==t.charAt(0)||t in e||a(e,t,{value:o.f(t)})}},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"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(!function(t){return"number"==typeof t}(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,o,a,u,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||s(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(r(i=this._events[t]))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(s(i))for(a=Array.prototype.slice.call(arguments,1),o=(h=i.slice()).length,u=0;u<o;u++)h[u].apply(this,a);return!0},i.prototype.addListener=function(t,e){var o;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]?s(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,s(this._events[t])&&!this._events[t].warned&&(o=r(this._maxListeners)?i.defaultMaxListeners:this._maxListeners)&&o>0&&this._events[t].length>o&&(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){if(!n(e))throw TypeError("listener must be a function");var i=!1;function s(){this.removeListener(t,s),i||(i=!0,e.apply(this,arguments))}return s.listener=e,this.on(t,s),this},i.prototype.removeListener=function(t,e){var i,r,o,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(o=(i=this._events[t]).length,r=-1,i===e||n(i.listener)&&i.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(s(i)){for(a=o;a-- >0;)if(i[a]===e||i[a].listener&&i[a].listener===e){r=a;break}if(r<0)return this;1===i.length?(i.length=0,delete this._events[t]):i.splice(r,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(n(i=this._events[t]))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){(e=t.exports=i(73)).Stream=e,e.Readable=e,e.Writable=i(50),e.Duplex=i(13),e.Transform=i(75),e.PassThrough=i(151)},function(t,e,i){"use strict";(function(e){!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports=function(t,i,n,s){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var r,o,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,i)});case 3:return e.nextTick(function(){t.call(null,i,n)});case 4:return e.nextTick(function(){t.call(null,i,n,s)});default:for(r=new Array(a-1),o=0;o<r.length;)r[o++]=arguments[o];return e.nextTick(function(){t.apply(null,r)})}}:t.exports=e.nextTick}).call(e,i(11))},function(t,e,i){"use strict";(function(e,n){t.exports=m;var s,r=i(49),o=!e.browser&&["v0.10","v0.9."].indexOf(e.version.slice(0,5))>-1?n:r;m.WritableState=d;var a=i(23);a.inherits=i(12);var u,h={deprecate:i(150)},l=i(74),c=i(5).Buffer,p=i(31);function f(){}function d(t,e){s=s||i(13),t=t||{},this.objectMode=!!t.objectMode,e instanceof s&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var n=t.highWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:a,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var u=!1===t.decodeStrings;this.decodeStrings=!u,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var i=t._writableState,n=i.sync,s=i.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(i),e)!function(t,e,i,n,s){--e.pendingcb,i?r(s,n):s(n);t._writableState.errorEmitted=!0,t.emit("error",n)}(t,i,n,e,s);else{var a=g(i);a||i.corked||i.bufferProcessing||!i.bufferedRequest||_(t,i),n?o(v,t,i,a,s):v(t,i,a,s)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new S(this)}function m(t){if(s=s||i(13),!(u.call(m,this)||this instanceof s))return new m(t);this._writableState=new d(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev)),l.call(this)}function y(t,e,i,n,s,r,o){e.writelen=n,e.writecb=o,e.writing=!0,e.sync=!0,i?t._writev(s,e.onwrite):t._write(s,r,e.onwrite),e.sync=!1}function v(t,e,i,n){i||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),w(t,e)}function _(t,e){e.bufferProcessing=!0;var i=e.bufferedRequest;if(t._writev&&i&&i.next){var n=e.bufferedRequestCount,s=new Array(n),r=e.corkedRequestsFree;r.entry=i;for(var o=0;i;)s[o]=i,i=i.next,o+=1;y(t,e,!0,e.length,s,"",r.finish),e.pendingcb++,e.lastBufferedRequest=null,r.next?(e.corkedRequestsFree=r.next,r.next=null):e.corkedRequestsFree=new S(e)}else{for(;i;){var a=i.chunk,u=i.encoding,h=i.callback;if(y(t,e,!1,e.objectMode?1:a.length,a,u,h),i=i.next,e.writing)break}null===i&&(e.lastBufferedRequest=null)}e.bufferedRequestCount=0,e.bufferedRequest=i,e.bufferProcessing=!1}function g(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function b(t,e){e.prefinished||(e.prefinished=!0,t.emit("prefinish"))}function w(t,e){var i=g(e);return i&&(0===e.pendingcb?(b(t,e),e.finished=!0,t.emit("finish")):b(t,e)),i}function S(t){var e=this;this.next=null,this.entry=null,this.finish=function(i){var n=e.entry;for(e.entry=null;n;){var s=n.callback;t.pendingcb--,s(i),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}}a.inherits(m,l),d.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(d.prototype,"buffer",{get:h.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(u=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(t){return!!u.call(this,t)||t&&t._writableState instanceof d}})):u=function(t){return t instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(t,e,i){var n=this._writableState,s=!1,o=c.isBuffer(t);return"function"==typeof e&&(i=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),"function"!=typeof i&&(i=f),n.ended?function(t,e){var i=new Error("write after end");t.emit("error",i),r(e,i)}(this,i):(o||function(t,e,i,n){var s=!0,o=!1;return null===i?o=new TypeError("May not write null values to stream"):"string"==typeof i||void 0===i||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),r(n,o),s=!1),s}(this,n,t,i))&&(n.pendingcb++,s=function(t,e,i,n,s,r){i||(n=function(t,e,i){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=p.from(e,i));return e}(e,n,s),c.isBuffer(n)&&(s="buffer"));var o=e.objectMode?1:n.length;e.length+=o;var a=e.length<e.highWaterMark;a||(e.needDrain=!0);if(e.writing||e.corked){var u=e.lastBufferedRequest;e.lastBufferedRequest=new function(t,e,i){this.chunk=t,this.encoding=e,this.callback=i,this.next=null}(n,s,r),u?u.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else y(t,e,!1,o,n,s,r);return a}(this,n,o,t,e,i)),s},m.prototype.cork=function(){this._writableState.corked++},m.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.finished||t.bufferProcessing||!t.bufferedRequest||_(this,t))},m.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},m.prototype._write=function(t,e,i){i(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(t,e,i){var n=this._writableState;"function"==typeof t?(i=t,t=null,e=null):"function"==typeof e&&(i=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,i){e.ending=!0,w(t,e),i&&(e.finished?r(i):t.once("finish",i));e.ended=!0,t.writable=!1}(this,n,i)}}).call(e,i(11),i(72).setImmediate)},function(t,e,i){"use strict";var n=i(5).Buffer,s=i(31),r=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===r||!r(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=h,this.end=l,e=4;break;case"utf8":this.fillLast=u,e=4;break;case"base64":this.text=c,this.end=p,e=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=s.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function u(t){var e=this.lastTotal-this.lastNeed,i=function(t,e,i){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(i);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(i+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(i+2)}}(this,t,e);return void 0!==i?i:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var i=t.toString("utf16le",e);if(i){var n=i.charCodeAt(i.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function l(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,i)}return e}function c(t,e){var i=(t.length-e)%3;return 0===i?t.toString("base64",e):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-i))}function p(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,i;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<t.length?e?e+this.text(t,i):this.text(t,i):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�".repeat(this.lastTotal-this.lastNeed):e},o.prototype.text=function(t,e){var i=function(t,e,i){var n=e.length-1;if(n<i)return 0;var s=a(e[n]);if(s>=0)return s>0&&(t.lastNeed=s-1),s;if(--n<i)return 0;if((s=a(e[n]))>=0)return s>0&&(t.lastNeed=s-2),s;if(--n<i)return 0;if((s=a(e[n]))>=0)return s>0&&(2===s?s=0:t.lastNeed=s-3),s;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=i;var n=t.length-(i-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,i){"use strict";var n=i(24),s=i(6),r=i(54),o=i(7),a=i(9),u=i(15),h=i(81),l=i(26),c=i(85),p=i(1)("iterator"),f=!([].keys&&"next"in[].keys()),d=function(){return this};t.exports=function(t,e,i,m,y,v,_){h(i,e,m);var g,b,w,S=function(t){if(!f&&t in k)return k[t];switch(t){case"keys":case"values":return function(){return new i(this,t)}}return function(){return new i(this,t)}},T=e+" Iterator",x="values"==y,A=!1,k=t.prototype,E=k[p]||k["@@iterator"]||y&&k[y],O=E||S(y),M=y?x?S("entries"):O:void 0,P="Array"==e&&k.entries||E;if(P&&(w=c(P.call(new t)))!==Object.prototype&&(l(w,T,!0),n||a(w,p)||o(w,p,d)),x&&E&&"values"!==E.name&&(A=!0,O=function(){return E.call(this)}),n&&!_||!f&&!A&&k[p]||o(k,p,O),u[e]=O,u[T]=d,y)if(g={values:x?O:S("values"),keys:v?O:S("keys"),entries:M},_)for(b in g)b in k||r(k,b,g[b]);else s(s.P+s.F*(f||A),e,g);return g}},function(t,e,i){t.exports=!i(8)&&!i(14)(function(){return 7!=Object.defineProperty(i(35)("div"),"a",{get:function(){return 7}}).a})},function(t,e,i){t.exports=i(7)},function(t,e,i){var n=i(4),s=i(82),r=i(40),o=i(38)("IE_PROTO"),a=function(){},u=function(){var t,e=i(35)("iframe"),n=r.length;for(e.style.display="none",i(58).appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),u=t.F;n--;)delete u.prototype[r[n]];return u()};t.exports=Object.create||function(t,e){var i;return null!==t?(a.prototype=n(t),i=new a,a.prototype=null,i[o]=t):i=u(),void 0===e?i:s(i,e)}},function(t,e,i){var n=i(9),s=i(10),r=i(83)(!1),o=i(38)("IE_PROTO");t.exports=function(t,e){var i,a=s(t),u=0,h=[];for(i in a)i!=o&&n(a,i)&&h.push(i);for(;e.length>u;)n(a,i=e[u++])&&(~r(h,i)||h.push(i));return h}},function(t,e,i){var n=i(22);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==n(t)?t.split(""):Object(t)}},function(t,e,i){t.exports=i(2).document&&document.documentElement},function(t,e,i){var n=i(4);t.exports=function(t,e,i,s){try{return s?e(n(i)[0],i[1]):e(i)}catch(e){var r=t.return;throw void 0!==r&&n(r.call(t)),e}}},function(t,e,i){var n=i(15),s=i(1)("iterator"),r=Array.prototype;t.exports=function(t){return void 0!==t&&(n.Array===t||r[s]===t)}},function(t,e,i){var n=i(1)("iterator"),s=!1;try{var r=[7][n]();r.return=function(){s=!0},Array.from(r,function(){throw 2})}catch(t){}t.exports=function(t,e){if(!e&&!s)return!1;var i=!1;try{var r=[7],o=r[n]();o.next=function(){return{done:i=!0}},r[n]=function(){return o},t(r)}catch(t){}return i}},function(t,e,i){"use strict";e.__esModule=!0;var n=r(i(88)),s=r(i(94));function r(t){return t&&t.__esModule?t:{default:t}}e.default=function(){return function(t,e){if(Array.isArray(t))return t;if((0,n.default)(Object(t)))return function(t,e){var i=[],n=!0,r=!1,o=void 0;try{for(var a,u=(0,s.default)(t);!(n=(a=u.next()).done)&&(i.push(a.value),!e||i.length!==e);n=!0);}catch(t){r=!0,o=t}finally{try{!n&&u.return&&u.return()}finally{if(r)throw o}}return i}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}()},function(t,e,i){!function(e,i){t.exports=i()}(0,function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={exports:{},id:n,loaded:!1};return t[n].call(s.exports,s,s.exports,i),s.loaded=!0,s.exports}return i.m=t,i.c=e,i.p="",i(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";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}}(),r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};e.colors=function(){return _.colors},e.context=function(){return _.context},e.clock=function(){return _.clock},Object.defineProperty(e,"__esModule",{value:!0});var o=n(i(2)),a=n(i(5)),u=n(i(38)),h=n(i(40)),l=function(t){return t&&t.__esModule?t:{default:t}}(i(39)),c=i(28),p=i(41),f=i(27),d=i(26),m=i(25),y=n(i(42)),v=n(i(45)),_=new(function(){function t(e){for(var i in r(this,t),o)this[i]=o[i];for(var i in a)this[i]=a[i];var n={Rack:u},s={Counter:c,Radio:p,Drunk:f,Sequence:d,Matrix:m};for(var i in s)this[i]=s[i];for(var i in n)this[i]=n[i];var _=window.AudioContext||window.webkitAudioContext;for(var i in this._context=e||new _,this.tune=new h,this.note=this.tune.note.bind(this.tune),this.clock=new y(this._context),this.clock.start(),this.Interval=v,this.colors={accent:"#2bb",fill:"#eee",light:"#fff",dark:"#333",mediumLight:"#ccc",mediumDark:"#666"},this.transform=l,this.add=l.add,this.Add={},o)this.Add[i]=l.add.bind(this,i);var g=document.getElementsByTagName("style"),b=document.createElement("style");(b.type="text/css",b.innerHTML="[nexus-ui]{height:5000px;width:5000px}",g.length>0)?g[0].parentNode.insertBefore(b,g[0]):document.write("<style>[nexus-ui]{height:5000px;width:5000px}</style>")}return s(t,{context:{get:function(){return this._context},set:function(t){this.clock.stop(),this._context=t,this.clock=new y(this.context),this.clock.start()}}}),t}());e.default=_},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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(6),u=i(11),h=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),l=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[200,200],mode:"absolute",minX:0,maxX:1,stepX:0,x:.5,minY:0,maxY:1,stepY:0,y:.5}),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 h.Handle(this.settings.mode,"horizontal",[0,this.width],[this.height,0]),y:new h.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 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)}(e,a),n(e,{buildInterface:{value:function(){this.knob=o.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}();t.exports=l},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,r){var o=n.toCartesian(i,r),a=n.toCartesian(i,s),u=r-s<=180?"0":"1";return["M",o.x+t,o.y+e,"A",i,i,0,u,0,a.x+t,a.y+e].join(" ")},radialGradient:function(t,e){var i="gradient"+n.ri(1e11),s=[],r=document.createElementNS("http://www.w3.org/2000/svg","radialGradient");r.setAttribute("id",i),r.setAttribute("cx","50%"),r.setAttribute("cy","50%"),r.setAttribute("r","50%"),t.appendChild(r);for(var o=0;o<e;o++){var a=document.createElementNS("http://www.w3.org/2000/svg","stop");a.setAttribute("id","stop"+o),r.appendChild(a),s.push(a)}return{id:i,stops:s,element:r}}}},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>=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,r=e-n;return Math.sqrt(s*s+r*r)},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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(7),u=i(8),h=i(9),l=i(10),c=i(1).colors,p=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=c();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 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)}(e,l),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 r=0;r<t.length;r++){var o=t[r];if(u.isObject(o))for(var s in o)n[s]=o[s];else if("function"==typeof o)n.event=o;else if(e.length>=1){n[s=e.splice(0,1)[0]]=o}}return this.parent=a.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=o.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,h.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=a.findPosition(this.element),this.mouse=a.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=a.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=a.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=a.findPosition(this.element),this.mouse=a.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=a.locateTouch(t,this.offset),this.touchMove(),t.preventDefault(),t.stopPropagation())}},preTouchRelease:{value:function(t){this.mouse=a.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}();t.exports=p},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"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(!function(t){return"number"==typeof t}(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,o,a,u,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||s(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(r(i=this._events[t]))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(s(i))for(a=Array.prototype.slice.call(arguments,1),o=(h=i.slice()).length,u=0;u<o;u++)h[u].apply(this,a);return!0},i.prototype.addListener=function(t,e){var o;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]?s(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,s(this._events[t])&&!this._events[t].warned&&(o=r(this._maxListeners)?i.defaultMaxListeners:this._maxListeners)&&o>0&&this._events[t].length>o&&(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){if(!n(e))throw TypeError("listener must be a function");var i=!1;function s(){this.removeListener(t,s),i||(i=!0,e.apply(this,arguments))}return s.listener=e,this.on(t,s),this},i.prototype.removeListener=function(t,e){var i,r,o,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(o=(i=this._events[t]).length,r=-1,i===e||n(i.listener)&&i.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(s(i)){for(a=o;a-- >0;)if(i[a]===e||i[a].listener&&i[a].listener===e){r=a;break}if(r<0)return this;1===i.length?(i.length=0,delete this._events[t]):i.splice(r,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(n(i=this._events[t]))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")},r=i(5),o=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],r=void 0===arguments[3]?0:arguments[3];s(this,t),this.min=e,this.max=i,this.step=n,this.value=r,this.changed=!1,this.oldValue=!1,this.update(this.value)}return n(t,{update:{value:function(t){return this.step?this.value=r.clip(Math.round((t-this.min)/this.step)*this.step+this.min,this.min,this.max):this.value=r.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=r.scale(t,0,1,this.min,this.max),this.update(this.value)}},normalized:{get:function(){return r.normalize(this.value,this.min,this.max)}}}),t}();t.exports=o},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}}(),r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};Object.defineProperty(e,"__esModule",{value:!0});var o=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];r(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=o.clip(this.value,0,1)}},convertPositionToValue:{value:function(t){switch(this.direction){case"radial":var e=o.toPolar(t.x-this.boundary.center.x,t.y-this.boundary.center.y);return e=((e=e.angle/(2*Math.PI))-.25+1)%1;case"vertical":return o.scale(t.y,this.boundary.min.y,this.boundary.max.y,0,1);case"horizontal":return o.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];r(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:o.clip(this.mouse.x/this.width,0,1),y:o.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:o.clip(this.mouse.x/this.width,0,1),y:o.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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(6),u=i(11),h=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),l=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["min","max","value"],{size:[120,20],mode:"relative",min:0,max:1,step:0,value:0}),this.orientation="vertical",this._value=new u(this.settings.min,this.settings.max,this.settings.step,this.settings.value),this.position=new h.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 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)}(e,a),n(e,{buildInterface:{value:function(){this.bar=o.create("rect"),this.fillbar=o.create("rect"),this.knob=o.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,r=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)",r=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+")",r=n/2),this.bar.setAttribute("x",t),this.bar.setAttribute("y",e),this.bar.setAttribute("transform",s),this.bar.setAttribute("rx",r),this.bar.setAttribute("ry",r),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",r),this.fillbar.setAttribute("ry",r),"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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(13),u=i(6),h=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[40,20],target:!1,state:!1}),this._state=new a(this.settings.state),this.init()}return 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)}(e,u),n(e,{buildInterface:{value:function(){this.bar=o.create("rect"),this.knob=o.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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(17),u=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["mode"],{size:[80,80],mode:"aftertouch",state:!1}),this.mode=this.settings.mode,this.init(),this.render()}return 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)}(e,a),n(e,{buildInterface:{value:function(){this.pad=o.create("circle"),this.element.appendChild(this.pad),this.interactionTarget=this.pad,this.defs=o.create("defs"),this.element.appendChild(this.defs),this.gradient=o.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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(5),u=i(13),h=i(6),l=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 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)}(e,h),n(e,{buildInterface:{value:function(){this.pad=o.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:a.clip(this.mouse.x/this.width,0,1),y:a.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:a.clip(this.mouse.x/this.width,0,1),y:a.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:a.clip(this.mouse.x/this.width,0,1),y:a.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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(17),a=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[150,50],state:!1,text:"Play"}),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 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)}(e,o),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}();t.exports=a},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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(6),a=i(16),u=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[120,25],numberOfButtons:4,active:-1}),this.buttons=[],this._numberOfButtons=this.settings.numberOfButtons,this.active=this.settings.active,this.init(),this.render()}return 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)}(e,o),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 a(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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(6),a=i(11),u=i(5),h=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[60,30],value:0,min:0,max:2e4,step:1}),this._value=new a(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 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)}(e,o),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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(6),a=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[100,30],options:["default","options"]}),this._selectedIndex=-1,this._value=!1,this._options=this.settings.options,this.init(),this.render()}return 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)}(e,o),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(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}();t.exports=a},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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(5),u=i(6),h=i(11),l=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),c=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["min","max","value"],{size:[75,75],interaction:"radial",mode:"relative",min:0,max:1,step:0,value:0}),this.interaction=this.settings.interaction,this._value=new h(this.settings.min,this.settings.max,this.settings.step,this.settings.value),this.position=new l.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 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)}(e,u),n(e,{buildInterface:{value:function(){this.background=o.create("circle"),this.screw=o.create("circle"),this.handle=o.create("path"),this.handle2=o.create("path"),this.handleFill=o.create("path"),this.handle2Fill=o.create("path"),this.handleLine=o.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:a.clip(a.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:a.clip(a.scale(i,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},r=o.arc(t.x,t.y,e/2-e/40,n.start,n.end),u=o.arc(t.x,t.y,e/2-e/40,s.start,s.end);this.handle.setAttribute("d",r),this.handle.setAttribute("stroke-width",e/20),this.handle.setAttribute("fill","none"),this.handle2.setAttribute("d",u),this.handle2.setAttribute("stroke-width",e/20),this.handle2.setAttribute("fill","none"),r+=" L "+t.x+" "+t.y,this.handleFill.setAttribute("d",r),this.handleFill.setAttribute("fill-opacity","0.3"),u+=" L "+t.x+" "+t.y,this.handle2Fill.setAttribute("d",u),this.handle2Fill.setAttribute("fill-opacity","0.3");var h=void 0;h=i<.5?n.end:s.end;var l=t.x+Math.cos(h)*(e/2),c=t.y+Math.sin(h)*(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:a.clip(a.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:a.clip(a.scale(t,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},r=o.arc(e.x,e.y,i/2-i/40,n.start,n.end),u=o.arc(e.x,e.y,i/2-i/40,s.start,s.end);this.handle.setAttribute("d",r),this.handle2.setAttribute("d",u),r+=" L "+e.x+" "+e.y,this.handleFill.setAttribute("d",r),u+=" L "+e.x+" "+e.y,this.handle2Fill.setAttribute("d",u);var h=void 0;h=t<=.5?n.end:s.end;var l=e.x+Math.cos(h)*(i/2),c=e.y+Math.sin(h)*(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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=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)},o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),u=i(6),h=i(17),l=i(9),c=function(t){function e(){o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value","note","color"],{size:[80,80],target:!1,mode:"button",value:0}),this.note=this.settings.note,this.color=this.settings.color,this.colors={w:"#fff",b:"#666"},this.init(),this.render()}return r(e,h),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}(),p=function(t){function e(){o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[500,125],lowNote:24,highNote:60,mode:"button"}),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 r(e,u),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}var r=t,o=(this.width-2)/r,a=(this.height-2)/2;for(i=0;i<this.keys.length;i++){var u=this.keys[i].parent;u.style.position="absolute",u.style.left=e[i]*o+1+"px","w"===this.keys[i].color?(u.style.top="1px",this.keys[i].resize(o,2*a)):(u.style.zIndex=1,u.style.top="1px",this.keys[i].resize(o,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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=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)},o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),u=i(7),h=i(6),l=i(17),c=i(25),p=i(28),f=i(9),d=function(t){function e(){o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[80,80],target:!1,mode:"toggle",value:0}),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 r(e,l),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=u.findPosition(t.element)),t.mouse=u.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}(),m=function(t){function e(){o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[400,200],mode:"toggle",rows:5,columns:10}),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 r(e,h),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}();t.exports=m},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}}(),r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=n(i(5)),a=n(i(26)),u=function(){function t(e,i){var n=this;r(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]=o.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]=o.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]=o.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=u},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}}(),r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=n(i(5)),a=n(i(27)),u=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];r(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:o.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){"up"===t||"down"===t||"random"===t||"drunk"===t?(this._mode=t,this.position&&(this.next=this[this._mode])):console.error("The only modes currently allowed are: up, down, random, drunk")}},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=o.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=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")},r=function(t){return t&&t.__esModule?t.default:t}(i(5)),o=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],r=void 0===arguments[3]?1:arguments[3],o=void 0!==arguments[4]&&arguments[4];s(this,t),this.min=e,this.max=i,this.value=n,this.increment=r,this.loop=o}return n(t,{next:{value:function(){return this.value+=r.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=o},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}}(),r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=n(i(5)),a=n(i(27)),u=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];r(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){"up"===t||"down"===t||"random"===t||"drunk"===t?(this._mode=t,this.value&&(this.next=this[this._mode])):console.error("The only modes currently allowed are: up, down, random, drunk")},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:~~o.average(this.min,this.max),random:o.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=o.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=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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(5),u=i(6),h=i(11),l=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),c=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["range"],{size:[200,200],range:.5,mode:"absolute",speakers:[[.5,.2],[.75,.25],[.8,.5],[.75,.75],[.5,.8],[.25,.75],[.2,.5],[.25,.25]]}),this.value={x:new h(0,1,0,.5),y:new h(0,1,0,.5)},this.mode=this.settings.mode,this.position={x:new l.Handle(this.mode,"horizontal",[0,this.width],[this.height,0]),y:new l.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 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)}(e,u),n(e,{buildInterface:{value:function(){this.knob=o.create("circle"),this.element.appendChild(this.knob),this.speakerElements=[];for(var t=0;t<this.speakers.length;t++){var e=o.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=a.distance(e[0]*t.width,e[1]*t.height,t.position.x.value*t.width,(1-t.position.y.value)*t.height),s=a.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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(5),a=i(4),u=i(6),h=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[80,80]}),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 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)}(e,u),n(e,{buildInterface:{value:function(){this.title=a.create("text"),this.circleX=a.create("circle"),this.circleY=a.create("circle"),this.circleZ=a.create("circle"),this.barX=a.create("path"),this.barY=a.create("path"),this.barZ=a.create("path"),this.barX2=a.create("path"),this.barY2=a.create("path"),this.barZ2=a.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=o.scale(i,-90,90,0,1),e=o.scale(e,-90,90,0,1),n=o.scale(n,0,360,0,1);var s={start:1.5*Math.PI,end:o.clip(o.scale(i,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},r={start:2.5*Math.PI,end:o.clip(o.scale(i,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},u=a.arc(this.circleX.cx.baseVal.value,this.circleX.cy.baseVal.value,this.circleX.r.baseVal.value,s.start,s.end),h=a.arc(this.circleX.cx.baseVal.value,this.circleX.cy.baseVal.value,this.circleX.r.baseVal.value,r.start,r.end);this.barX.setAttribute("d",u),this.barX2.setAttribute("d",h),s={start:1.5*Math.PI,end:o.clip(o.scale(e,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},r={start:2.5*Math.PI,end:o.clip(o.scale(e,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},u=a.arc(this.circleY.cx.baseVal.value,this.circleY.cy.baseVal.value,this.circleY.r.baseVal.value,s.start,s.end),h=a.arc(this.circleY.cx.baseVal.value,this.circleY.cy.baseVal.value,this.circleY.r.baseVal.value,r.start,r.end),this.barY.setAttribute("d",u),this.barY2.setAttribute("d",h),s={start:1.5*Math.PI,end:o.clip(o.scale(n,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},r={start:2.5*Math.PI,end:o.clip(o.scale(n,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},u=a.arc(this.circleZ.cx.baseVal.value,this.circleZ.cy.baseVal.value,this.circleZ.r.baseVal.value,s.start,s.end),h=a.arc(this.circleZ.cx.baseVal.value,this.circleZ.cy.baseVal.value,this.circleZ.r.baseVal.value,r.start,r.end),this.barZ.setAttribute("d",u),this.barZ2.setAttribute("d",h),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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=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)},o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(7),u=i(5),h=i(6),l=i(32),c=i(9),p=function(t){function e(){var t=this;o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["scale","value"],{size:[120,20],orientation:"vertical",mode:"absolute",scale:[0,1],step:0,value:0,hasKnob:!0}),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),r=t.multislider.sliders[n].value,o=t.multislider.sliders[s].value,h=n;h<s;h++){t.multislider.sliders[h].value=u.interp((h-n)/i,r,o);var l=t.multislider.sliders[h].value;t.multislider.values[h]=l,t.multislider.update(h,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 r(e,l),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}(),f=function(t){function e(){o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[200,100],numberOfSliders:5,min:0,max:1,step:0,values:[.7,.7,.7,.7,.7]}),this._numberOfSliders=this.settings.numberOfSliders,this.values=this.settings.values,this.sliders=[],this.interacting=!1,this.init()}return r(e,h),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"),r=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));r.multislider=this,r.index=n,c.exists&&(r.bar.index=n,r.fillbar.index=n,r.preClick=r.preMove=r.preRelease=function(){},r.click=r.move=r.release=function(){},r.preTouch=r.preTouchMove=r.preTouchRelease=function(){},r.touch=r.touchMove=r.touchRelease=function(){}),this.sliders.push(r),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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(6),u=i(11),h=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),l=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 h.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 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)}(e,a),n(e,{buildInterface:{value:function(){this.bar=o.create("rect"),this.fillbar=o.create("rect"),this.knob=o.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,r=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)",r=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+")",r=n/2),this.bar.setAttribute("x",t),this.bar.setAttribute("y",e),this.bar.setAttribute("transform",s),this.bar.setAttribute("rx",r),this.bar.setAttribute("ry",r),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",r),this.fillbar.setAttribute("ry",r),"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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(5),u=i(6),h=i(11),l=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),c=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["scale","value"],{size:[120,20],orientation:"horizontal",mode:"relative",scale:[-1,1],step:0,value:0,hasKnob:!0}),this.orientation=this.settings.orientation,this.mode=this.settings.mode,this.hasKnob=this.settings.hasKnob,this.step=this.settings.step,this._value=new h(this.settings.scale[0],this.settings.scale[1],this.settings.step,this.settings.value),this.init(),this.position=new l.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 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)}(e,u),n(e,{buildInterface:{value:function(){this.bar=o.create("rect"),this.knob=o.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,r=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)",r=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+")",r=n/2),this.bar.setAttribute("x",t),this.bar.setAttribute("y",e),this.bar.setAttribute("transform",s),this.bar.setAttribute("rx",r),this.bar.setAttribute("ry",r),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(a.scale(this.value,-1,1,1,0),2),R:Math.pow(a.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(a.scale(this.value,-1,1,1,0),2),R:Math.pow(a.scale(this.value,-1,1,0,1),2)}),this.render()}},normalized:{get:function(){return this._value.normalized}}}),e}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(5),a=i(4),u=i(6),h=function(t,e){this.x=t.x,this.y=t.y,this.envelope=e,this.element=a.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],r=this.envelope.nodes[n],o=i>=0?s.x:0,a=n<this.envelope.nodes.length?r.x:1;this.x<o&&(this.x=o),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)}},l=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[300,150],points:[{x:.1,y:.4},{x:.35,y:.6},{x:.65,y:.2},{x:.9,y:.4}]}),this.points=this.settings.points,this.nodes=[],this.selected=!1,this.init()}return 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)}(e,u),n(e,{buildInterface:{value:function(){var t=this;this.points.forEach(function(e){var i=new h(e,t);t.nodes.push(i)}),this.sortPoints(),this.line=a.create("polyline"),this.line.setAttribute("stroke-width",2),this.line.setAttribute("fill","none"),this.element.appendChild(this.line),this.fill=a.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=o.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,r=0;r<s.length;r++){var o=Math.sqrt(Math.pow(s[r].x-i,2)+Math.pow(s[r].y-n,2));o<e&&(e=o,t=r,i>s[r].x)}return e>.07&&(t=this.getIndexFromX(this.mouse.x/this.width),this.nodes.splice(t,0,new h({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=o.clip(this.nodes[t].x,0,1),i=o.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 h({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],r=o.scale(t,n.x,s.x,0,1),a=o.interp(r,n.y,s.y);return this.emit("scan",a),a}},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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(7),a=i(6),u=i(1).context,h=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["scale","value"],{size:[300,150]}),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 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)}(e,a),n(e,{buildFrame:{value:function(){this.canvas=new o.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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(7),a=i(5),u=i(6),h=i(1).context,l=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["scale","value"],{size:[30,100]}),this.context=h(),this.channels=2,this.splitter=this.context.createChannelSplitter(this.channels),this.analysers=[];for(var t=0;t<this.channels;t++){var i=this.context.createAnalyser();this.splitter.connect(i,t),i.fftSize=1024,i.smoothingTimeConstant=1,this.analysers.push(i)}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 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)}(e,u),n(e,{buildFrame:{value:function(){this.canvas=new o.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=a.normalize(this.db,-70,5),s=n*n,r=a.scale(s,0,1,this.element.height,0);this.canvas.context.fillStyle=this.colors.accent,this.canvas.context.fillRect(this.meterWidth*t,r,this.meterWidth,this.canvas.element.height-r)}}}},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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(7),a=i(6),u=i(1).context,h=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["scale","value"],{size:[300,150]}),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 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)}(e,a),n(e,{buildFrame:{value:function(){this.canvas=new o.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*this.canvas.element.height/2;0===i?this.canvas.context.moveTo(e,n):this.canvas.context.lineTo(e,n),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}();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")},r=function(t){return t&&t.__esModule?t:{default:t}}(i(39)),o=function(t){return t&&t.__esModule?t.default:t}(i(7)),a=i(1).colors,u=function(){function t(e,i){s(this,t),this.meta={},this.meta.target=e,this.meta.parent=o.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=r.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=u},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)),r=n(i(2)),o=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 o=new r[e](t,i);return o.id=t.id,o};e.element=a,e.section=function(t,e){e=e||"nexus-ui";for(var i={},n={},u=s.parseElement(t).getElementsByTagName("*"),h=[],l=0;l<u.length;l++)h.push(u[l]);for(l=0;l<h.length;l++){var c=h[l].getAttribute(e);if(c){var p=!1;for(var f in r)c.toLowerCase()===f.toLowerCase()&&(p=f);console.log(p);var d=a(h[l],p);d.id?n[d.id]=d:n[o(d,i)]=d}}return n},e.add=function(t,e,i){var n=document.createElement("div");return i=i||{},(e=e?s.parseElement(e):document.body).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)}},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")},r=function(t){return t&&t.__esModule?t.default:t}(i(5)),o=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=r.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],r=this.root*s;return r*=Math.pow(2,i),r=Math.floor(1e11*r)/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(r.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=o},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 r=void 0===arguments[0]?3:arguments[0];n(this,t),r<0&&(r=1),this.length=r,this.onVals=i,this.array=new Array(r).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=.1,n=.001,s=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)};s.prototype.clear=function(){return this.clock._removeEvent(this),this._cleared=!0,this},s.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},s.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},s.prototype.isRepeated=function(){return null!==this.repeatTime},s.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)},s.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)},s.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))},s.prototype._refreshEarlyLateDates=function(){this._latestTime=this.deadline+this.toleranceLate,this._earliestTime=this.deadline-this.toleranceEarly};var r=t.exports=function(t,e){e=e||{},this.tickMethod=e.tickMethod||"ScriptProcessorNode",this.toleranceEarly=e.toleranceEarly||n,this.toleranceLate=e.toleranceLate||i,this.context=t,this._events=[],this._started=!1};r.prototype.setTimeout=function(t,e){return this._createEvent(t,this._absTime(e))},r.prototype.callbackAtTime=function(t,e){return this._createEvent(t,e)},r.prototype.timeStretch=function(t,e,i){return e.forEach(function(e){e.timeStretch(t,i)}),e},r.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)}},r.prototype.stop=function(){!0===this._started&&(this._started=!1,this._clockNode.disconnect())},r.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)},r.prototype._createEvent=function(t,e){return new s(this,e,t)},r.prototype._insertEvent=function(t){this._events.splice(this._indexByTime(t._earliestTime),0,t)},r.prototype._removeEvent=function(t){var e=this._events.indexOf(t);-1!==e&&this._events.splice(e,1)},r.prototype._hasEvent=function(t){return-1!==this._events.indexOf(t)},r.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},r.prototype._absTime=function(t){return t+this.context.currentTime},r.prototype._relTime=function(t){return t-this.context.currentTime}}).call(e,i(44))},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var u,h=[],l=!1,c=-1;function p(){l&&u&&(l=!1,u.length?h=u.concat(h):c=-1,h.length&&f())}function f(){if(!l){var t=a(p);l=!0;for(var e=h.length;e;){for(u=h,h=[];++c<e;)u&&u[c].run();c=-1,e=h.length}u=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function m(){}s.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];h.push(new d(t,e)),1!==h.length||l||a(f)},d.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(t){return[]},s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.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")},r=i(1).clock,o=function(){function t(e,i,n){s(this,t),this.rate=e,this.on=n,this.clock=r(),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=o}])})},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(i(98));var s=[{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 n.default(t)}),r=s[0],o=function(){};function a(t){r&&r.heading&&r.heading.classList.remove("selected"),(r=s[t]).heading&&r.heading.classList.add("selected"),o(r)}e.default={scales:s,current:function(){return r},build:function(){s.forEach(function(t,e){t.heading=document.createElement("div"),t.heading.innerHTML=t.name,t.heading.classList.add("heading"),t.heading.addEventListener("click",function(){a(e)}),scale_list.appendChild(t.heading)}),a(0)},build_options:function(t){s.forEach(function(e,i){var n=document.createElement("option");n.innerHTML=e.name,n.value=i,t.appendChild(n)}),t.addEventListener("input",function(t){a(t.target.value)}),a(0)},pick:a,names:function(){return s.map(function(t){return t.name})},onChange:function(t){o=t}}},function(t,e,i){t.exports={default:i(99),__esModule:!0}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(i(29));i(44);var s=2,r=0,o=new n.default.Compressor(-30,3).toMaster(),a=[{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"}];a.forEach(function(t){t.players=[],t.index=-1;for(var e=0;e<s;e++){var i=t.fn;window.location.href.match(/asdf.us/)&&(i="//asdf.us/kalimba/"+i);var r=new n.default.Player({url:i,retrigger:!0,playbackRate:1});r.connect(o),t.players.push(r)}}),e.default={play:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i={sample:a[r]};r=(r+1)%a.length,i.sample.index=(i.sample.index+1)%s;var n=i.sample.players[i.sample.index];n.playbackRate=t/i.sample.root,n.volume.value=e,setTimeout(function(){n.start()},0)}}},function(t,e,i){var n=i(56),s=i(40).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return n(t,s)}},function(t,e){},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.nx=void 0;var n=s(i(125));e.update_value_on_change=function(t,e,i,n){var s=document.querySelector(e+" + .val"),r=function(t){s.innerHTML=i?parseInt(t):t.toFixed(2),n&&n(t)};t.on("change",r),r(t.value),t.update=r},e.update_radio_value_on_change=function(t,e,i,n){var s=t.active,r=document.querySelector(e+" + .val"),o=function(e){-1===e?e=t.active=s:s=e,r.innerHTML=i[e][1],n&&n(e)};t.on("change",o),o(t.active),t.update=o},e.build_options=function(t,e,i){(0,n.default)(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)})};s(i(63));function s(t){return t&&t.__esModule?t:{default:t}}e.nx=window.nx={}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e,i){var n,s,r,o=i(19),a=i(141),u=i(58),h=i(35),l=i(2),c=l.process,p=l.setImmediate,f=l.clearImmediate,d=l.MessageChannel,m=0,y={},v=function(){var t=+this;if(y.hasOwnProperty(t)){var e=y[t];delete y[t],e()}},_=function(t){v.call(t.data)};p&&f||(p=function(t){for(var e=[],i=1;arguments.length>i;)e.push(arguments[i++]);return y[++m]=function(){a("function"==typeof t?t:Function(t),e)},n(m),m},f=function(t){delete y[t]},"process"==i(22)(c)?n=function(t){c.nextTick(o(v,t,1))}:d?(r=(s=new d).port2,s.port1.onmessage=_,n=o(r.postMessage,r,1)):l.addEventListener&&"function"==typeof postMessage&&!l.importScripts?(n=function(t){l.postMessage(t+"","*")},l.addEventListener("message",_,!1)):n="onreadystatechange"in h("script")?function(t){u.appendChild(h("script")).onreadystatechange=function(){u.removeChild(this),v.call(t)}}:function(t){setTimeout(o(v,t,1),0)}),t.exports={set:p,clear:f}},function(t,e,i){(function(t){var n=void 0!==t&&t||"undefined"!=typeof self&&self||window,s=Function.prototype.apply;function r(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new r(s.call(setTimeout,n,arguments),clearTimeout)},e.setInterval=function(){return new r(s.call(setInterval,n,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(n,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},i(146),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(e,i(17))},function(t,e,i){"use strict";(function(e){t.exports=v;var n,s=i(49),r=i(70);v.ReadableState=y;i(47).EventEmitter;var o=function(t,e){return t.listeners(e).length},a=i(74),u=i(5).Buffer,h=i(31),l=i(23);l.inherits=i(12);var c=i(148),p=void 0;p=c&&c.debuglog?c.debuglog("stream"):function(){};var f,d=i(149);l.inherits(v,a);var m=["error","close","destroy","pause","resume"];function y(t,e){n=n||i(13),t=t||{},this.objectMode=!!t.objectMode,e instanceof n&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var s=t.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=s||0===s?s:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=i(51).StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function v(t){if(n=n||i(13),!(this instanceof v))return new v(t);this._readableState=new y(t,this),this.readable=!0,t&&"function"==typeof t.read&&(this._read=t.read),a.call(this)}function _(t,e,i,n,r){var o=function(t,e){var i=null;u.isBuffer(e)||"string"==typeof e||null===e||void 0===e||t.objectMode||(i=new TypeError("Invalid non-string/buffer chunk"));return i}(e,i);if(o)t.emit("error",o);else if(null===i)e.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,w(t)}(t,e);else if(e.objectMode||i&&i.length>0)if(e.ended&&!r){var a=new Error("stream.push() after EOF");t.emit("error",a)}else if(e.endEmitted&&r){var h=new Error("stream.unshift() after end event");t.emit("error",h)}else{var l;!e.decoder||r||n||(i=e.decoder.write(i),l=!e.objectMode&&0===i.length),r||(e.reading=!1),l||(e.flowing&&0===e.length&&!e.sync?(t.emit("data",i),t.read(0)):(e.length+=e.objectMode?1:i.length,r?e.buffer.unshift(i):e.buffer.push(i),e.needReadable&&w(t))),function(t,e){e.readingMore||(e.readingMore=!0,s(T,t,e))}(t,e)}else r||(e.reading=!1);return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(e)}v.prototype.push=function(t,e){var i=this._readableState;return i.objectMode||"string"!=typeof t||(e=e||i.defaultEncoding)!==i.encoding&&(t=h.from(t,e),e=""),_(this,i,t,e,!1)},v.prototype.unshift=function(t){return _(this,this._readableState,t,"",!0)},v.prototype.isPaused=function(){return!1===this._readableState.flowing},v.prototype.setEncoding=function(t){return f||(f=i(51).StringDecoder),this._readableState.decoder=new f(t),this._readableState.encoding=t,this};var g=8388608;function b(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=g?t=g:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function w(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?s(S,t):S(t))}function S(t){p("emit readable"),t.emit("readable"),k(t)}function T(t,e){for(var i=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(p("maybeReadMore read 0"),t.read(0),i!==e.length);)i=e.length;e.readingMore=!1}function x(t){p("readable nexttick read 0"),t.read(0)}function A(t,e){e.reading||(p("resume read 0"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit("resume"),k(t),e.flowing&&!e.reading&&t.read(0)}function k(t){var e=t._readableState;for(p("flow",e.flowing);e.flowing&&null!==t.read(););}function E(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):i=function(t,e,i){var n;t<e.head.data.length?(n=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):n=t===e.head.data.length?e.shift():i?function(t,e){var i=e.head,n=1,s=i.data;t-=s.length;for(;i=i.next;){var r=i.data,o=t>r.length?r.length:t;if(o===r.length?s+=r:s+=r.slice(0,t),0===(t-=o)){o===r.length?(++n,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=r.slice(o));break}++n}return e.length-=n,s}(t,e):function(t,e){var i=h.allocUnsafe(t),n=e.head,s=1;n.data.copy(i),t-=n.data.length;for(;n=n.next;){var r=n.data,o=t>r.length?r.length:t;if(r.copy(i,i.length-t,0,o),0===(t-=o)){o===r.length?(++s,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=r.slice(o));break}++s}return e.length-=s,i}(t,e);return n}(t,e.buffer,e.decoder),i);var i}function O(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,s(M,e,t))}function M(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function P(t,e){for(var i=0,n=t.length;i<n;i++)if(t[i]===e)return i;return-1}v.prototype.read=function(t){p("read",t),t=parseInt(t,10);var e=this._readableState,i=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?O(this):w(this),null;if(0===(t=b(t,e))&&e.ended)return 0===e.length&&O(this),null;var n,s=e.needReadable;return p("need readable",s),(0===e.length||e.length-t<e.highWaterMark)&&p("length less than watermark",s=!0),e.ended||e.reading?p("reading or ended",s=!1):s&&(p("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=b(i,e))),null===(n=t>0?E(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&O(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,i){var n=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=t;break;case 1:a.pipes=[a.pipes,t];break;default:a.pipes.push(t)}a.pipesCount+=1,p("pipe count=%d opts=%j",a.pipesCount,i);var u=(!i||!1!==i.end)&&t!==e.stdout&&t!==e.stderr?l:d;function h(t){p("onunpipe"),t===n&&d()}function l(){p("onend"),t.end()}a.endEmitted?s(u):n.once("end",u),t.on("unpipe",h);var c=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,k(t))}}(n);t.on("drain",c);var f=!1;function d(){p("cleanup"),t.removeListener("close",_),t.removeListener("finish",g),t.removeListener("drain",c),t.removeListener("error",v),t.removeListener("unpipe",h),n.removeListener("end",l),n.removeListener("end",d),n.removeListener("data",y),f=!0,!a.awaitDrain||t._writableState&&!t._writableState.needDrain||c()}var m=!1;function y(e){p("ondata"),m=!1,!1!==t.write(e)||m||((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==P(a.pipes,t))&&!f&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,m=!0),n.pause())}function v(e){p("onerror",e),b(),t.removeListener("error",v),0===o(t,"error")&&t.emit("error",e)}function _(){t.removeListener("finish",g),b()}function g(){p("onfinish"),t.removeListener("close",_),b()}function b(){p("unpipe"),n.unpipe(t)}return n.on("data",y),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener(e,i);t._events&&t._events[e]?r(t._events[e])?t._events[e].unshift(i):t._events[e]=[i,t._events[e]]:t.on(e,i)}(t,"error",v),t.once("close",_),t.once("finish",g),t.emit("pipe",n),a.flowing||(p("pipe resume"),n.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s<n;s++)i[s].emit("unpipe",this);return this}var r=P(e.pipes,t);return-1===r?this:(e.pipes.splice(r,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this),this)},v.prototype.on=function(t,e){var i=a.prototype.on.call(this,t,e);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var n=this._readableState;n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&w(this):s(x,this))}return i},v.prototype.addListener=v.prototype.on,v.prototype.resume=function(){var t=this._readableState;return t.flowing||(p("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,s(A,t,e))}(this,t)),this},v.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this},v.prototype.wrap=function(t){var e=this._readableState,i=!1,n=this;for(var s in t.on("end",function(){if(p("wrapped end"),e.decoder&&!e.ended){var t=e.decoder.end();t&&t.length&&n.push(t)}n.push(null)}),t.on("data",function(s){(p("wrapped data"),e.decoder&&(s=e.decoder.write(s)),!e.objectMode||null!==s&&void 0!==s)&&((e.objectMode||s&&s.length)&&(n.push(s)||(i=!0,t.pause())))}),t)void 0===this[s]&&"function"==typeof t[s]&&(this[s]=function(e){return function(){return t[e].apply(t,arguments)}}(s));for(var r=0;r<m.length;r++)t.on(m[r],n.emit.bind(n,m[r]));return n._read=function(e){p("wrapped _read",e),i&&(i=!1,t.resume())},n},v._fromList=E}).call(e,i(11))},function(t,e,i){t.exports=i(47).EventEmitter},function(t,e,i){"use strict";t.exports=o;var n=i(13),s=i(23);function r(t){this.afterTransform=function(e,i){return function(t,e,i){var n=t._transformState;n.transforming=!1;var s=n.writecb;if(!s)return t.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,null!==i&&void 0!==i&&t.push(i);s(e);var r=t._readableState;r.reading=!1,(r.needReadable||r.length<r.highWaterMark)&&t._read(r.highWaterMark)}(t,e,i)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function o(t){if(!(this instanceof o))return new o(t);n.call(this,t),this._transformState=new r(this);var e=this;this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.once("prefinish",function(){"function"==typeof this._flush?this._flush(function(t,i){a(e,t,i)}):a(e)})}function a(t,e,i){if(e)return t.emit("error",e);null!==i&&void 0!==i&&t.push(i);var n=t._writableState,s=t._transformState;if(n.length)throw new Error("Calling transform done when ws.length != 0");if(s.transforming)throw new Error("Calling transform done when still transforming");return t.push(null)}s.inherits=i(12),s.inherits(o,n),o.prototype.push=function(t,e){return this._transformState.needTransform=!1,n.prototype.push.call(this,t,e)},o.prototype._transform=function(t,e,i){throw new Error("_transform() is not implemented")},o.prototype._write=function(t,e,i){var n=this._transformState;if(n.writecb=i,n.writechunk=t,n.writeencoding=e,!n.transforming){var s=this._readableState;(n.needTransform||s.needReadable||s.length<s.highWaterMark)&&this._read(s.highWaterMark)}},o.prototype._read=function(t){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0}},function(t,e,i){"use strict";var n=d(i(77)),s=d(i(62)),r=d(i(29)),o=d(i(63)),a=d(i(97)),u=d(i(64)),h=d(i(66)),l=i(120),c=i(44),p=i(69),f=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}(i(134));function d(t){return t&&t.__esModule?t:{default:t}}var m=60,y=null,v=!1,_=!1,g=void 0;(0,l.midi_init)();var b=["date","timestamp","fatalities","injured","total_victims","age","case","weapon_type","weapon_details"].reduce(function(t,e,i){return t[e]=i,t},{}),w=["incident_id","date","state","city_or_county","address","n_killed","n_injured","incident_url","source_url","incident_url_fields_missing","congressional_district","gun_stolen","gun_type","incident_characteristics","latitude","location_description","longitude","n_guns_involved","notes","participant_age","participant_age_group","participant_gender","participant_name","participant_relationship","participant_status","participant_type","sources","state_house_district","state_senate_district"].reduce(function(t,e,i){return t[e]=i,t},{}),S=[31,28,31,30,31,30,31,31,30,31,30,31,0].reduce(function(t,e,i){return 0===i?[e]:t.concat(t[i-1]+e)},[]),T=0,x=0,A=0,k={},E={},O={},M=[],P=l.play_sequence;function C(t,e,i,n){for(var s,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"all",a=arguments[5],f=e.min,d=e.max,m=E.dates.length,y=[],v=[],_=[],g=void 0,w=Math.floor((t+8)/4)%4;t>=E.dates[A]&&A<m;)y.push(E.lines[0][A]),E.isMass?_.push(E.data[A][b.date]+" "+E.data[A][b.case]+", "+E.data[A][b.fatalities]+" dead, "+E.data[A][b.injured]+" injured"):_.push(E.labels[A]),A+=1;switch(y.length){default:case 0:break;case 1:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,128,o,a,0)),g=[128];break;case 2:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,64,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,64,o,a,64)),g=[64,64];break;case 3:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,43,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,43,o,a,43)),v.push((0,l.play_note)((0,c.norm)(y[2],f,d)*p.nx.multiply.value,42,o,a,85)),g=[43,43,42];break;case 4:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,32,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,32,o,a,32)),v.push((0,l.play_note)((0,c.norm)(y[2],f,d)*p.nx.multiply.value,32,o,a,64)),v.push((0,l.play_note)((0,c.norm)(y[3],f,d)*p.nx.multiply.value,32,o,a,96)),g=[32,32,32,32];break;case 5:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,22,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,21,o,a,22)),v.push((0,l.play_note)((0,c.norm)(y[2],f,d)*p.nx.multiply.value,21,o,a,43)),v.push((0,l.play_note)((0,c.norm)(y[3],f,d)*p.nx.multiply.value,32,o,a,64)),v.push((0,l.play_note)((0,c.norm)(y[4],f,d)*p.nx.multiply.value,32,o,a,96)),g=[22,21,21,32,32];break;case 6:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,22,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,21,o,a,22)),v.push((0,l.play_note)((0,c.norm)(y[2],f,d)*p.nx.multiply.value,21,o,a,43)),v.push((0,l.play_note)((0,c.norm)(y[3],f,d)*p.nx.multiply.value,22,o,a,64)),v.push((0,l.play_note)((0,c.norm)(y[4],f,d)*p.nx.multiply.value,21,o,a,86)),v.push((0,l.play_note)((0,c.norm)(y[5],f,d)*p.nx.multiply.value,21,o,a,107)),g=[22,21,21,22,21,21];break;case 7:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,16,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,16,o,a,16)),v.push((0,l.play_note)((0,c.norm)(y[2],f,d)*p.nx.multiply.value,16,o,a,32)),v.push((0,l.play_note)((0,c.norm)(y[3],f,d)*p.nx.multiply.value,16,o,a,48)),v.push((0,l.play_note)((0,c.norm)(y[4],f,d)*p.nx.multiply.value,22,o,a,64)),v.push((0,l.play_note)((0,c.norm)(y[5],f,d)*p.nx.multiply.value,21,o,a,86)),v.push((0,l.play_note)((0,c.norm)(y[6],f,d)*p.nx.multiply.value,21,o,a,107)),g=[16,16,16,16,22,21,21];break;case 8:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,16,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,16,o,a,16)),v.push((0,l.play_note)((0,c.norm)(y[2],f,d)*p.nx.multiply.value,16,o,a,32)),v.push((0,l.play_note)((0,c.norm)(y[3],f,d)*p.nx.multiply.value,16,o,a,48)),v.push((0,l.play_note)((0,c.norm)(y[4],f,d)*p.nx.multiply.value,16,o,a,64)),v.push((0,l.play_note)((0,c.norm)(y[5],f,d)*p.nx.multiply.value,16,o,a,80)),v.push((0,l.play_note)((0,c.norm)(y[6],f,d)*p.nx.multiply.value,16,o,a,96)),v.push((0,l.play_note)((0,c.norm)(y[7],f,d)*p.nx.multiply.value,16,o,a,112)),g=[16,16,16,16,16,16,16,16];break;case 9:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,11,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,11,o,a,11)),v.push((0,l.play_note)((0,c.norm)(y[2],f,d)*p.nx.multiply.value,10,o,a,22)),v.push((0,l.play_note)((0,c.norm)(y[3],f,d)*p.nx.multiply.value,16,o,a,32)),v.push((0,l.play_note)((0,c.norm)(y[4],f,d)*p.nx.multiply.value,16,o,a,48)),v.push((0,l.play_note)((0,c.norm)(y[5],f,d)*p.nx.multiply.value,16,o,a,64)),v.push((0,l.play_note)((0,c.norm)(y[6],f,d)*p.nx.multiply.value,16,o,a,80)),v.push((0,l.play_note)((0,c.norm)(y[7],f,d)*p.nx.multiply.value,16,o,a,96)),v.push((0,l.play_note)((0,c.norm)(y[8],f,d)*p.nx.multiply.value,16,o,a,112)),g=[11,11,10,16,16,16,16,16,16];break;case 10:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,11,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,11,o,a,11)),v.push((0,l.play_note)((0,c.norm)(y[2],f,d)*p.nx.multiply.value,10,o,a,22)),v.push((0,l.play_note)((0,c.norm)(y[3],f,d)*p.nx.multiply.value,11,o,a,32)),v.push((0,l.play_note)((0,c.norm)(y[4],f,d)*p.nx.multiply.value,11,o,a,43)),v.push((0,l.play_note)((0,c.norm)(y[5],f,d)*p.nx.multiply.value,10,o,a,54)),v.push((0,l.play_note)((0,c.norm)(y[6],f,d)*p.nx.multiply.value,16,o,a,64)),v.push((0,l.play_note)((0,c.norm)(y[7],f,d)*p.nx.multiply.value,16,o,a,80)),v.push((0,l.play_note)((0,c.norm)(y[8],f,d)*p.nx.multiply.value,16,o,a,96)),v.push((0,l.play_note)((0,c.norm)(y[9],f,d)*p.nx.multiply.value,16,o,a,112)),g=[11,11,10,11,11,10,16,16,16,16];break;case 11:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,11,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,11,o,a,11)),v.push((0,l.play_note)((0,c.norm)(y[2],f,d)*p.nx.multiply.value,10,o,a,22)),v.push((0,l.play_note)((0,c.norm)(y[3],f,d)*p.nx.multiply.value,11,o,a,32)),v.push((0,l.play_note)((0,c.norm)(y[4],f,d)*p.nx.multiply.value,11,o,a,43)),v.push((0,l.play_note)((0,c.norm)(y[5],f,d)*p.nx.multiply.value,10,o,a,54)),v.push((0,l.play_note)((0,c.norm)(y[6],f,d)*p.nx.multiply.value,11,o,a,64)),v.push((0,l.play_note)((0,c.norm)(y[7],f,d)*p.nx.multiply.value,11,o,a,75)),v.push((0,l.play_note)((0,c.norm)(y[8],f,d)*p.nx.multiply.value,10,o,a,86)),v.push((0,l.play_note)((0,c.norm)(y[9],f,d)*p.nx.multiply.value,16,o,a,96)),v.push((0,l.play_note)((0,c.norm)(y[10],f,d)*p.nx.multiply.value,16,o,a,112)),g=[11,11,10,11,11,10,11,11,10,16,16];break;case 12:v.push((0,l.play_note)((0,c.norm)(y[0],f,d)*p.nx.multiply.value,11,o,a,0)),v.push((0,l.play_note)((0,c.norm)(y[1],f,d)*p.nx.multiply.value,11,o,a,11)),v.push((0,l.play_note)((0,c.norm)(y[2],f,d)*p.nx.multiply.value,10,o,a,22)),v.push((0,l.play_note)((0,c.norm)(y[3],f,d)*p.nx.multiply.value,11,o,a,32)),v.push((0,l.play_note)((0,c.norm)(y[4],f,d)*p.nx.multiply.value,11,o,a,43)),v.push((0,l.play_note)((0,c.norm)(y[5],f,d)*p.nx.multiply.value,10,o,a,54)),v.push((0,l.play_note)((0,c.norm)(y[6],f,d)*p.nx.multiply.value,11,o,a,64)),v.push((0,l.play_note)((0,c.norm)(y[7],f,d)*p.nx.multiply.value,11,o,a,75)),v.push((0,l.play_note)((0,c.norm)(y[8],f,d)*p.nx.multiply.value,10,o,a,86)),v.push((0,l.play_note)((0,c.norm)(y[9],f,d)*p.nx.multiply.value,11,o,a,96)),v.push((0,l.play_note)((0,c.norm)(y[10],f,d)*p.nx.multiply.value,11,o,a,107)),v.push((0,l.play_note)((0,c.norm)(y[11],f,d)*p.nx.multiply.value,10,o,a,118)),g=[11,11,10,11,11,10,11,11,10,11,11,10]}var S=u.default.current().index(p.nx.pedal_tone.value+w,p.nx.octave.value);return s=function(t){var e=(0,c.ftom)(t),i=e%1;i>.5&&(e+=1,i-=1);return i*=2,(e=Math.floor(e))>127?0:r.default.Frequency(Math.floor(e),"midi").toNote()}(S),a||(h.default.play(S,-12),_.length&&(document.querySelector("#cases").innerHTML=_.join("<br>"))),m<=A?(A=0,t=0):t+=1,y.length?[t,v,g,s]:[t,[],[],s]}function I(){if(!_){var t=12e4/r.default.Transport.bpm.value*l.note_values[p.nx.timing.active][0];clearTimeout(g),g=setTimeout(I,t);var e=P(T,O,M,t),i=(0,s.default)(e,3),n=i[0],o=i[1];i[2];if(E.labels,T=n,v){var a=l.note_values[p.nx.timing.active][2];a.length&&(a=a[T%a.length]),y.addEvent(new l.MidiWriter.NoteEvent({pitch:o,duration:"t"+a}))}}}function R(t){console.log("pick dataset:",t,k[t]),T=0,A=0,window.location.hash=t,E=k[t],O=(0,c.get_bounds)(E),M=(0,c.get_diff_bounds)(O.rows),P=E.play_fn,x=E.max_i||O.rows.length*O.rows[0].length}function F(){u.default.build_options(document.querySelector("#scale")),(0,p.build_options)(document.querySelector("#dataset"),k,R);var t=[50,50];r.default.Transport.bpm.value=m,p.nx.tempo=new o.default.Dial("#tempo",{size:t,min:10,max:300,step:1,value:m}),(0,p.update_value_on_change)(p.nx.tempo,"#tempo",!0,function(t){return r.default.Transport.bpm.value=t}),p.nx.timing=new o.default.RadioButton("#timing",{size:[400,25],numberOfButtons:l.note_values.length,active:6}),(0,p.update_radio_value_on_change)(p.nx.timing,"#timing",l.note_values),p.nx.duration=new o.default.Dial("#duration",{size:t,min:0,max:2,step:.01,value:.8}),(0,p.update_value_on_change)(p.nx.duration,"#duration",!1),p.nx.offset=new o.default.Dial("#offset",{size:t,min:-24,max:24,step:1,value:-5}),(0,p.update_value_on_change)(p.nx.offset,"#offset",!0),p.nx.octave=new o.default.Dial("#octave",{size:t,min:-4,max:4,step:1,value:0}),(0,p.update_value_on_change)(p.nx.octave,"#octave",!0),p.nx.multiply=new o.default.Dial("#multiply",{size:t,min:-64,max:64,step:1,value:19}),(0,p.update_value_on_change)(p.nx.multiply,"#multiply",!0),p.nx.interval=new o.default.Dial("#interval",{size:t,min:-64,max:64,step:1,value:10}),(0,p.update_value_on_change)(p.nx.interval,"#interval",!0),p.nx.pedal_tone=new o.default.Dial("#pedal_tone",{size:t,min:-24,max:24,step:1,value:-7}),(0,p.update_value_on_change)(p.nx.pedal_tone,"#pedal_tone",!0),document.querySelector("#play").addEventListener("click",function(){T=0,A=0,_=!1,I()}),document.querySelector("#pause").addEventListener("click",function(){_=!0}),document.querySelector("#export_midi").addEventListener("click",function(){(0,l.export_pattern_as_midi)(E,O,M,p.nx.tempo.value,p.nx.timing.active,P,x)});var e=document.querySelector("#record_midi");e.addEventListener("click",function(){if(v){e.innerHTML="Record MIDI",document.body.classList.remove("recording"),v=!1;var t=new l.MidiWriter.Writer([y]),i=(0,c.dataURItoBlob)(t.dataUri());saveAs(i,"Recording - "+E.name+".mid")}else e.innerHTML="Save Recording",document.body.classList.add("recording"),v=!0,(y=new l.MidiWriter.Track).setTempo(p.nx.tempo.value)}),document.querySelector(".loading").classList.remove("loading");var i=decodeURIComponent(window.location.hash.substr(1))||"Mass Shootings";document.querySelector("#dataset").value=i,R(i),document.querySelector("#scale").value="14",u.default.pick(14)}f.load().then(function(t){console.log(t);var e=t.ar_15_2016_18;k["AR-15 2016-18"]={},k["AR-15 2016-18"].name="AR-15 (2016-18)",k["AR-15 2016-18"].pedal=!0,k["AR-15 2016-18"].play_fn=C;var i=e.lines.map(function(t){if(t[w.incident_characteristics].match("Shots Fired - No Injuries"))return null;if(t[w.n_killed]+t[w.n_injured]<4)return null;var e=t[w.date].split("-"),i=(0,s.default)(e,3),n=i[0],r=i[1],o=i[2];if(parseInt(n)>2017)return null;var a=365*(parseInt(n)-2016),u=S[parseInt(r)],h=Math.floor(parseInt(o))+14,l=Math.floor((a+u+h)/7);console.log(l,n,r,o);var c=t[w.n_killed]+t[w.n_injured];return 0===t[w.n_killed]&&(c=-t[w.n_injured]),[l,Math.log(Math.log(c+10)+1),"** !!, $$, {} killed, [] injured".replace("**",t[w.date]).replace("!!",t[w.city_or_county]).replace("$$",t[w.state]).replace("{}",t[w.n_killed]).replace("[]",t[w.n_injured]),t[w.n_killed],t[w.n_injured]]}).filter(function(t){return!!t});k["AR-15 2016-18"].dates=i.map(function(t){return t[0]}),k["AR-15 2016-18"].dates.push(i.length),k["AR-15 2016-18"].lines=[i.map(function(t){return t[1]})],k["AR-15 2016-18"].labels=i.map(function(t){return t[2]}),console.log(i.length);var r=t.firearms_manufactured;k["Firearms Manufactured"]={},k["Firearms Manufactured"].name="Firearms Manufactured",k["Firearms Manufactured"].play_fn=l.play_sequence,k["Firearms Manufactured"].h=r.h.slice(1,5),k["Firearms Manufactured"].labels=r.lines.map(function(t){return t.slice(0,1)}),k["Firearms Manufactured"].lines=r.lines.map(function(t){return t.slice(1,5)}),(0,c.transpose)(t.gun_violence_by_month.lines).forEach(function(e,i){var n=t.gun_violence_by_month.h[i];"Date"!==n&&(k[n]={name:n,h:[n],lines:[e.map(function(t){return parseInt(t)})],play_fn:l.play_sequence})}),k["Mass Shootings"]=t.mass_shootings_from_columbine,k["Mass Shootings"].name="Mass Shootings",k["Mass Shootings"].pedal=!0,k["Mass Shootings"].isMass=!0,k["Mass Shootings"].play_fn=C;var o=k["Mass Shootings"].lines.reverse(),a=o[0][b.date].split("/"),u=(0,n.default)(a),h=u[0],p=(u.slice(1),o[o.length-1][b.date].split("/")),f=(0,n.default)(p),d=f[0];f.slice(1);k["Mass Shootings"].dates=o.map(function(t){var e=t[b.date].split("/"),i=(0,s.default)(e,3),n=i[0],r=i[1];i[2];return 12*(parseInt(n)-parseInt(h))+parseInt(r)}),k["Mass Shootings"].max_i=12*(parseInt(d)-parseInt(h))+parseInt(12),k["Mass Shootings"].data=o,k["Mass Shootings"].lines=[o.map(function(t){return t[b.total_victims]})],(0,c.requestAudioContext)(F)}),a.default.listen(function(t){p.nx.offset.value=t,p.nx.offset.update(t)})},function(t,e,i){"use strict";e.__esModule=!0;var n=function(t){return t&&t.__esModule?t:{default:t}}(i(78));e.default=function(t){return Array.isArray(t)?t:(0,n.default)(t)}},function(t,e,i){t.exports={default:i(79),__esModule:!0}},function(t,e,i){i(18),i(86),t.exports=i(0).Array.from},function(t,e,i){var n=i(32),s=i(33);t.exports=function(t){return function(e,i){var r,o,a=String(s(e)),u=n(i),h=a.length;return u<0||u>=h?t?"":void 0:(r=a.charCodeAt(u))<55296||r>56319||u+1===h||(o=a.charCodeAt(u+1))<56320||o>57343?t?a.charAt(u):r:t?a.slice(u,u+2):o-56320+(r-55296<<10)+65536}}},function(t,e,i){"use strict";var n=i(55),s=i(21),r=i(26),o={};i(7)(o,i(1)("iterator"),function(){return this}),t.exports=function(t,e,i){t.prototype=n(o,{next:s(1,i)}),r(t,e+" Iterator")}},function(t,e,i){var n=i(3),s=i(4),r=i(16);t.exports=i(8)?Object.defineProperties:function(t,e){s(t);for(var i,o=r(e),a=o.length,u=0;a>u;)n.f(t,i=o[u++],e[i]);return t}},function(t,e,i){var n=i(10),s=i(37),r=i(84);t.exports=function(t){return function(e,i,o){var a,u=n(e),h=s(u.length),l=r(o,h);if(t&&i!=i){for(;h>l;)if((a=u[l++])!=a)return!0}else for(;h>l;l++)if((t||l in u)&&u[l]===i)return t||l||0;return!t&&-1}}},function(t,e,i){var n=i(32),s=Math.max,r=Math.min;t.exports=function(t,e){return(t=n(t))<0?s(t+e,0):r(t,e)}},function(t,e,i){var n=i(9),s=i(27),r=i(38)("IE_PROTO"),o=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=s(t),n(t,r)?t[r]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?o:null}},function(t,e,i){"use strict";var n=i(19),s=i(6),r=i(27),o=i(59),a=i(60),u=i(37),h=i(87),l=i(41);s(s.S+s.F*!i(61)(function(t){Array.from(t)}),"Array",{from:function(t){var e,i,s,c,p=r(t),f="function"==typeof this?this:Array,d=arguments.length,m=d>1?arguments[1]:void 0,y=void 0!==m,v=0,_=l(p);if(y&&(m=n(m,d>2?arguments[2]:void 0,2)),void 0==_||f==Array&&a(_))for(i=new f(e=u(p.length));e>v;v++)h(i,v,y?m(p[v],v):p[v]);else for(c=_.call(p),i=new f;!(s=c.next()).done;v++)h(i,v,y?o(c,m,[s.value,v],!0):s.value);return i.length=v,i}})},function(t,e,i){"use strict";var n=i(3),s=i(21);t.exports=function(t,e,i){e in t?n.f(t,e,s(0,i)):t[e]=i}},function(t,e,i){t.exports={default:i(89),__esModule:!0}},function(t,e,i){i(28),i(18),t.exports=i(93)},function(t,e,i){"use strict";var n=i(91),s=i(92),r=i(15),o=i(10);t.exports=i(52)(Array,"Array",function(t,e){this._t=o(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,i=this._i++;return!t||i>=t.length?(this._t=void 0,s(1)):s(0,"keys"==e?i:"values"==e?t[i]:[i,t[i]])},"values"),r.Arguments=r.Array,n("keys"),n("values"),n("entries")},function(t,e){t.exports=function(){}},function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},function(t,e,i){var n=i(42),s=i(1)("iterator"),r=i(15);t.exports=i(0).isIterable=function(t){var e=Object(t);return void 0!==e[s]||"@@iterator"in e||r.hasOwnProperty(n(e))}},function(t,e,i){t.exports={default:i(95),__esModule:!0}},function(t,e,i){i(28),i(18),t.exports=i(96)},function(t,e,i){var n=i(4),s=i(41);t.exports=i(0).getIterator=function(t){var e=s(t);if("function"!=typeof e)throw TypeError(t+" is not iterable!");return n(e.call(t))}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n={},s={},r="zxcvbnmasdfghjklqwertyuiop",o=function(){};r.toUpperCase().split("").map(function(t,e){n[t.charCodeAt(0)]=e}),"1234567890".split("").map(function(t,e){n[t.charCodeAt(0)]=e+r.length,s[t.charCodeAt(0)]=!0}),window.addEventListener("keydown",function(t){if(t.altKey||t.ctrlKey||t.metaKey)return void t.stopPropagation();if(document.activeElement instanceof HTMLInputElement&&t.keyCode in s)return void t.stopPropagation();if(!(t.keyCode in n))return;var e=n[t.keyCode];t.shiftKey&&(e+=r.length);o(e-=7)},!0),e.default={listen:function(t){o=t}}},function(t,e,i){"use strict";var n=function(t){return t&&t.__esModule?t:{default:t}}(i(65));t.exports=function(){var t=function(t){t=this.opt=(0,n.default)({name:"",root:440,octave:0,interval:2,tet:0,intervals:null},t||{}),this.generate()};t.prototype.generate=function(t){(t=(0,n.default)(this.opt,t||{})).scl?this.generate_scl():t.tet?this.generate_tet():t.intervals&&this.generate_intervals()},t.prototype.generate_intervals=function(){this.opt.root;var t=this.opt.intervals;"string"==typeof t&&(t=t.split(" ")),this.name=this.opt.name||"interval list",this.intervals=t,this.interval=this.opt.interval=e.call(this,t.pop()),this.scale=t.map(i.bind(this)).filter(function(t){return!!t})},t.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),r=e;t.push(r);for(var o=0;o<i-1;o++)r*=s,t.push(r);this.name=this.opt.name||i+"-tone equal temperament",this.intervals=null},t.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})},t.prototype.parse_scl=function(t){var i={comments:[],notes:[]};return t.trim().split("\n").forEach(function(t){if(-1!==t.indexOf("!"))i.comments.push(t);else if("description"in i)if(i.notes.length){var n=t.replace(/^[^-\.0-9]+/,"").replace(/[^-\/\.0-9]+$/,"");(n=-1!==n.indexOf(".")?Math.pow(2,parseFloat(n)/1200):e(n))&&i.notes.push(n)}else i.notes.push(1);else i.description=t}),i},t.prototype.index=function(t,e){e=e||this.opt.octave;var i=this.scale[0|s(t,this.scale.length)],n=Math.floor(function(t,e,i){return(t-e)/(i-e)}(t,0,this.scale.length))+e;return i*=Math.pow(this.interval,n)},t.prototype.range=function(t,e){for(var i=[],n=t;n<e;n++)i.push(this.index(n));return i},t.prototype.set_root=function(t){this.opt.root=t,this.generate()},t.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 r=0;r<s.length;r++)if(!(e>s[r])){e=s[r];break}return e*=Math.pow(2,i)},t.prototype.quantize_index=function(t){return 0|s(index-1,this.scale.length)};var e=t.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},i=t.prototype.parse_interval_string=function(t){return-1!==t.indexOf("/")?e(t)*this.opt.root:(t.indexOf("f"),parseFloat(t))};function s(t,e){return t-e*Math.floor(t/e)}return t}()},function(t,e,i){i(100),t.exports=i(0).Object.assign},function(t,e,i){var n=i(6);n(n.S+n.F,"Object",{assign:i(101)})},function(t,e,i){"use strict";var n=i(16),s=i(43),r=i(30),o=i(27),a=i(57),u=Object.assign;t.exports=!u||i(14)(function(){var t={},e={},i=Symbol(),n="abcdefghijklmnopqrst";return t[i]=7,n.split("").forEach(function(t){e[t]=t}),7!=u({},t)[i]||Object.keys(u({},e)).join("")!=n})?function(t,e){for(var i=o(t),u=arguments.length,h=1,l=s.f,c=r.f;u>h;)for(var p,f=a(arguments[h++]),d=l?n(f).concat(l(f)):n(f),m=d.length,y=0;m>y;)c.call(f,p=d[y++])&&(i[p]=f[p]);return i}:u},function(t,e,i){t.exports={default:i(103),__esModule:!0}},function(t,e,i){i(104),t.exports=i(0).Math.log2},function(t,e,i){var n=i(6);n(n.S,"Math",{log2:function(t){return Math.log(t)/Math.LN2}})},function(t,e,i){"use strict";var n,s,r;!function(t){t&&t.__esModule}
+ */return function(e){t=e()}(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 r in e){i=e[r];var o=this;if(-1!==r.indexOf(".")){for(var a=r.split("."),u=0;u<a.length-1;u++)if((o=o[a[u]])instanceof t){a.splice(0,u+1);var h=a.join(".");o.set(h,i);continue t}r=a[a.length-1]}var l=o[r];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?o[r]=i:l instanceof t?l.set(i):l!==i&&(o[r]=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],r=this,o=i;if(-1!==s.indexOf(".")){for(var a=s.split("."),u=0;u<a.length-1;u++){var h=a[u];o[h]=o[h]||{},o=o[h],r=r[h]}s=a[a.length-1]}var l=r[s];t.isObject(e[s])?o[s]=l.get():t.Signal&&l instanceof t.Signal?o[s]=l.value:t.Param&&l instanceof t.Param?o[s]=l.value:l instanceof AudioParam?o[s]=l.value:l instanceof t?o[s]=l.get():!t.isFunction(l)&&t.isDefined(l)&&(o[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 r=0;r<i.length;r++)s[i[r]]=e[r];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 r in i)n[r]=t.defaultArg(e[r],i[r]);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}),e(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 r=this._events[e],o=0;o<r.length;o++)r[o]===i&&r.splice(o,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],r=t.Emitter.prototype[s];e[s]=r}return t.Emitter},t.Emitter.prototype.dispose=function(){return t.prototype.dispose.call(this),this._events=null,this},t.Emitter}),e(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,r=s;if(s>0&&this._timeline[s-1][i]<=e)return s-1;for(;n<r;){var o=Math.floor(n+(r-n)/2),a=this._timeline[o],u=this._timeline[o+1];if(a[i]===e){for(var h=o;h<this._timeline.length;h++){this._timeline[h][i]===e&&(o=h)}return o}if(a[i]<e&&u[i]>e)return o;a[i]>e?r=o:n=o+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}),e(function(t){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))}))}),e(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))})}}),e(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.");for(var n in this._context=i.context,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(){for(var e in t.Emitter.prototype.dispose.call(this),this._ticker.dispose(),this._ticker=null,this._timeouts.dispose(),this._timeouts=null,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(){var e=AudioNode.prototype.connect,i=AudioNode.prototype.disconnect;function n(i,n,s){if(i.input)return s=t.defaultArg(s,0),t.isArray(i.input)?this.connect(i.input[s]):this.connect(i.input,n,s);try{return i instanceof AudioNode?(e.call(this,i,n,s),i):(e.call(this,i,n),i)}catch(t){throw new Error("error connecting to node: "+i+"\n"+t)}}AudioNode.prototype.connect!==n&&(AudioNode.prototype.connect=n,AudioNode.prototype.disconnect=function(e,n,s){if(e&&e.input&&t.isArray(e.input))s=t.defaultArg(s,0),this.disconnect(e.input[s],n,0);else if(e&&e.input)this.disconnect(e.input,n,s);else try{i.apply(this,arguments)}catch(t){throw new Error("error disconnecting node: "+e+"\n"+t)}})}),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}),e(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}),e(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}),e(function(t){if(t.supported){var e=navigator.userAgent.toLowerCase();if(e.includes("safari")&&!e.includes("chrome")){var i=function(t){for(var e in this._internalNode=this.input=this.output=t._native_createWaveShaper(),this._curve=null,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)}}}}),e(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}),e(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}),e(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()]+12*(parseInt(n)+1);return"midi"===this._defaultUnits?s:t.Frequency.mtof(s)}},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,r=Math.floor(s/12);return r<0&&(s+=-12*r),i[s%12]+r.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}),e(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 r=i[0],o=t.Time(i[0]).toSeconds();return i.forEach(function(i){var n=t.Time(i).toSeconds();Math.abs(n-e)<Math.abs(o-e)&&(r=i,o=n)}),r},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()).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}),e(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}),e(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}),e(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),r=s;if(null===n)r=s;else if(n.type===t.Param.AutomationType.Target){var o,a=this._events.getBefore(n.time);o=null===a?s:a.value,r=this._exponentialApproach(n.time,o,n.value,n.constant,e)}else r=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 r},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 r=n/(e.length-1),o=1;o<e.length;o++)this.linearRampToValueAtTime(e[o]*s,i+o*r);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}),e(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}),e(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})}}),e(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}),e(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)}}}),e(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}),e(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}),e(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,r=this.toSeconds(this.decay);i=t.defaultArg(i,1);var o=this.getValueAtTime(e);o>0&&(s=(1-o)/(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 u=1-s/n,h=Math.floor(u*this._attackCurve.length);(a=this._attackCurve.slice(h))[0]=o}this._sig.setValueCurveAtTime(a,e,s,i)}return r&&this._sig.targetRampTo(i*this.sustain,r,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(){var e,i,n=[];for(e=0;e<128;e++)n[e]=Math.sin(e/127*(Math.PI/2));var s=[];for(e=0;e<127;e++){i=e/127;var r=Math.sin(i*(2*Math.PI)*6.4-Math.PI/2)+1;s[e]=r/10+.83*i}s[127]=1;var o=[];for(e=0;e<128;e++)o[e]=Math.ceil(e/127*5)/5;var a=[];for(e=0;e<128;e++)i=e/127,a[e]=.5*(1-Math.cos(Math.PI*i));var u=[];for(e=0;e<128;e++){i=e/127;var h=4*Math.pow(i,3)+.2,l=Math.cos(h*Math.PI*2*i);u[e]=Math.abs(l*(1-i))}function c(t){for(var e=new Array(t.length),i=0;i<t.length;i++)e[i]=1-t[i];return e}t.Envelope.Type={linear:"linear",exponential:"exponential",bounce:{In:c(u),Out:u},cosine:{In:n,Out:function(t){return t.slice(0).reverse()}(n)},step:{In:o,Out:c(o)},ripple:{In:s,Out:c(s)},sine:{In:a,Out:c(a)}}}(),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}),e(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}),e(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}))}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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].indexOf(e);if(-1===i)throw new RangeError("Tone.Filter: rolloff can only be -12, -24, -48 or -96");i+=1,this._rolloff=e,this.input.disconnect();for(var n=0;n<this._filters.length;n++)this._filters[n].disconnect(),this._filters[n]=null;this._filters=new Array(i);for(var s=0;s<i;s++){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[s]=r}var o=[this.input].concat(this._filters).concat([this.output]);t.connectSeries.apply(t,o)}}),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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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),r=this._getTicksUntilEvent(s,i);return n.ticks=Math.max(r,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)),r=0;r<=s;r++){var o=i*r+e,a=this._exponentialApproach(n.time,n.value,t,i,o);this.linearRampToValueAtTime(this._toUnits(a),o)}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,r=0;r<=n;r++){var o=s*r+i.time,a=this._exponentialInterpolate(i.time,i.value,e,t,o);this.linearRampToValueAtTime(this._toUnits(a),o)}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),r=this.getValueAtTime(i);return this._events.get(i).time===i&&this._events.get(i).type===t.Param.AutomationType.SetValue&&(r=this.getValueAtTime(i-this.sampleTime)),.5*(i-e.time)*(s+r)+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),r=(this.getValueAtTime(n.time)-s)/(n.time-i.time),o=Math.sqrt(Math.pow(s,2)-2*r*(i.ticks-e)),a=(-s+o)/r;return(a>0?a:(-s-o)/r)+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}),e(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);i>=0;i--){var n=this._timeline[i];if(n.state===t)return n}},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}),e(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,r=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&&(r=n.ticks,i=n.time),s.state===t.State.Started&&e.state!==t.State.Started&&(r+=this.frequency.getTicksAtTime(e.time)-this.frequency.getTicksAtTime(i)),s=e}.bind(this)),this._state.remove(n),r},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,r=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&&(r=n.seconds,i=n.time),s.state===t.State.Started&&e.state!==t.State.Started&&(r+=e.time-i),s=e}.bind(this)),this._state.remove(n),r},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),r=Math.max(n.time,s.time),o=this.frequency.getTicksAtTime(r)+e-n.ticks;return this.frequency.getTimeOfTick(o)},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 r=this.frequency.getTicksAtTime(e),o=(r-this.frequency.getTicksAtTime(s.time))%1;0!==o&&(o=1-o);for(var a=this.frequency.getTimeOfTick(r+o),u=null;a<i&&this._state;){try{n(a,Math.round(this.getTicksAtTime(a)))}catch(t){u=t;break}this._state&&(a+=this.frequency.getDurationOfTicks(1,a))}}if(u)throw u;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}),e(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}),e(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;if(t.getBalance()>0)if(null===t.left.right)(e=t.left).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).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}),e(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}),e(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}),e(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}),e(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 r=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(r,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=e-this.getTicksAtTime(i)%e;return this._clock.nextTickTime(n,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}),e(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}),e(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}),e(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 r=t.Transport.schedule(function(t){this._start(t,i,n)}.bind(this),e);this._scheduled.push(r),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,r=i-this.toSeconds(n.time);n.duration&&(s=this.toSeconds(n.duration)-r),this._start(e,this.toSeconds(n.offset)+r,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}),e(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]}))}),e(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,r){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,r(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 r=0;r<i;r++)s.copyToChannel(t[r],r);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 r=this.toArray(s),o=0;o<r.length;o++)i[o]+=r[o];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)),r=[],o=0;o<this.numberOfChannels;o++)r[o]=this.toArray(o).slice(n,s);return(new t.Buffer).fromArray(r)},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){i=t.defaultArg(i,t.noOp);var s=e.match(/\[(.+\|?)+\]$/);if(s){for(var r=s[1].split("|"),o=r[0],a=0;a<r.length;a++)if(t.Buffer.supportsType(r[a])){o=r[a];break}e=e.replace(s[0],o)}function u(e){if(t.Buffer._removeFromDownloadQueue(l),t.Buffer.emit("error",e),!n)throw e;n(e)}function h(){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)}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,h(),i(e),t.Buffer._removeFromDownloadQueue(l),0===t.Buffer._downloadQueue.length&&t.Buffer.emit("load")}).catch(function(){t.Buffer._removeFromDownloadQueue(l),u("Tone.Buffer: could not decode audio data: "+e)}):u("Tone.Buffer: could not locate file: "+e)}),l.addEventListener("error",u),l.addEventListener("progress",function(t){t.lengthComputable&&(l.progress=t.loaded/t.total*.95,h())}),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(){var e,i;function n(){t.Buffer.off("load",e),t.Buffer.off("error",i)}return new Promise(function(n,s){e=function(){n()},i=function(){s()},t.Buffer.on("load",e),t.Buffer.on("error",i)}).then(n).catch(function(t){throw n(),new Error(t)})},t.Buffer}),e(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}),e(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),r=new Float32Array(n),o=1;if(e===t.Oscillator.Type.Custom)n=o=this._partials.length+1;else{var a=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);a&&(o=parseInt(a[2])+1,e=a[1],n=o=Math.max(o,2))}for(var u=1;u<n;++u){var h,l=2/(u*Math.PI);switch(e){case t.Oscillator.Type.Sine:h=u<=o?1:0;break;case t.Oscillator.Type.Square:h=1&u?2*l:0;break;case t.Oscillator.Type.Sawtooth:h=l*(1&u?1:-1);break;case t.Oscillator.Type.Triangle:h=1&u?l*l*2*(u-1>>1&1?-1:1):0;break;case t.Oscillator.Type.Custom:h=this._partials[u-1];break;default:throw new TypeError("Tone.Oscillator: invalid type: "+e)}0!==h?(s[u]=-h*Math.sin(i*u),r[u]=h*Math.cos(i*u)):(s[u]=0,r[u]=0)}return[s,r]},t.Oscillator.prototype._inverseFFT=function(t,e,i){for(var n=0,s=t.length,r=0;r<s;r++)n+=t[r]*Math.cos(r*i)+e[r]*Math.sin(r*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,r=0;r<8;r++)n=Math.max(this._inverseFFT(e,i,r/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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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,r=new t.Gain,o=this.input=new t.Split;(new t.Zero).fan(i,n);var a=this.output=new t.Merge;o.left.chain(s,a.left),o.right.chain(r,a.right),this.pan.chain(n,s.gain),this.pan.chain(i,r.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)}}}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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=[],r=0;r<i.length;r++)s[r]=this._interpolate(e,i[r],n[r]);return s}if(t.isObject(i)){var o={};for(var a in i)o[a]=this._interpolate(e,i[a],n[a]);return o}return(1-e)*(i=this._toNumber(i))+e*(n=this._toNumber(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}),e(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,r=0;r<i.length;r++){var o=i[r];if(n>s&&n<s+o){var a=e[r];t.isObject(a)?this.value=a.value:this.value=a}s+=o}else this.value=e}return this.value},t.CtrlMarkov.prototype._getProbDistribution=function(e){for(var i=[],n=0,s=!1,r=0;r<e.length;r++){var o=e[r];t.isObject(o)?(s=!0,i[r]=o.probability):i[r]=1/e.length,n+=i[r]}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}),e(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.index>=this.values.length&&(this.index=0)):e===t.CtrlPattern.Type.Down?(this.index--,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.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}),e(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}),e(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);for(var s in t.call(this),this._buffers={},this.baseUrl=n.baseUrl,this._loadingCount=0,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){this._loadingCount--,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(){for(var e in t.prototype.dispose.call(this),this._buffers)this._buffers[e].dispose();return this._buffers=null,this},t.Buffers}),e(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}),e(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}),e(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,r){if(this.context.listener.forwardX){var o=this.now();this.context.listener.forwardX.setTargetAtTime(t,o,this._rampTimeConstant),this.context.listener.forwardY.setTargetAtTime(e,o,this._rampTimeConstant),this.context.listener.forwardZ.setTargetAtTime(i,o,this._rampTimeConstant),this.context.listener.upX.setTargetAtTime(n,o,this._rampTimeConstant),this.context.listener.upY.setTargetAtTime(s,o,this._rampTimeConstant),this.context.listener.upZ.setTargetAtTime(r,o,this._rampTimeConstant)}else this.context.listener.setOrientation(t,e,i,n,s,r);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}),e(function(t){return t.Offline=function(e,i){var n,s=t.context.sampleRate,r=t.context,o=function e(i,n,s,r){r=t.defaultArg(r,0);var o=new t.OfflineContext(2,n,s);t.context=o;var a=i(t.Transport);return o.currentTime>0&&r<1e3?e(i,n,s,++r):{response:a,context:o}}(e,i,s),a=o.response,u=o.context;return n=a instanceof Promise?a.then(function(){return u.render()}):u.render(),t.context=r,n.then(function(e){return new t.Buffer(e)})},t.Offline}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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 r=this.context.createBiquadFilter();r.type="allpass",r.frequency.value=i[s],this._allpassFiltersL.push(r)}for(var o=0;o<i.length;o++){var a=this.context.createBiquadFilter();a.type="allpass",a.frequency.value=i[o],this._allpassFiltersR.push(a)}for(var u=0;u<e.length;u++){var h=new t.LowpassCombFilter(e[u]);u<e.length/2?this.effectSendL.chain(h,this._allpassFiltersL[0]):this.effectSendR.chain(h,this._allpassFiltersR[0]),this.roomSize.connect(h.resonance),this.dampening.connect(h.dampening),this._combFilters.push(h)}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}),e(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 r=0;r<n.length;r++){var o=this.context.createBiquadFilter();o.type="allpass",o.frequency.value=n[r],this._allpassFilters.push(o)}for(var a=0;a<e.length;a++){var u=new t.FeedbackCombFilter(e[a],.1);this._scaleRoomSize.connect(u.resonance),u.resonance.value=i[a],this._allpassFilters[this._allpassFilters.length-1].connect(u),a<e.length/2?u.connect(this.effectReturnL):u.connect(this.effectReturnR),this._feedbackCombFilters.push(u)}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}),e(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}),e(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),r=0;r<e;r++){var o=this.context.createBiquadFilter();o.type="allpass",n.connect(o.Q),i.connect(o.frequency),s[r]=o}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}),e(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}),e(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}),e(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}),e(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,r){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,r=this.toSeconds(t.defaultArg(r,this.fadeIn)),this.fadeIn=r,r>0?(this._gainNode.gain.setValueAtTime(0,e),"linear"===this.curve?this._gainNode.gain.linearRampToValueAtTime(this._gain,e+r):this._gainNode.gain.exponentialApproachValueAtTime(this._gain,e,r)):this._gainNode.gain.setValueAtTime(s,e),this._startTime=e;var o=this.toSeconds(t.defaultArg(n,this.buffer.duration-i%this.buffer.duration));if(o=Math.max(o,0),t.isDefined(n)&&(this.loop||(o=Math.min(o,this.buffer.duration-i%this.buffer.duration)),this.stop(e+o,this.fadeOut)),this.loop){var a=this.loopEnd||this.buffer.duration,u=this.loopStart;i>=a&&(i=(i-u)%(a-u)+u)}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));var s=e-(i=Math.min(n,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}),e(function(t){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 i))throw new TypeError("Tone.Noise: invalid type: "+e);if(this._type=e,this.state===t.State.Started){var n=this.now();this._stop(n),this._start(n)}}}}),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 n=i[this._type];this._source=new t.BufferSource(n).connect(this.output),this._source.loop=!0,this._source.playbackRate.value=this._playbackRate,this._source.start(this.toSeconds(e),Math.random()*(n.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 e={pink:function(){for(var t=[],e=0;e<2;e++){var i,n,s,r,o,a,u,h=new Float32Array(220500);t[e]=h,i=n=s=r=o=a=u=0;for(var l=0;l<220500;l++){var c=2*Math.random()-1;i=.99886*i+.0555179*c,n=.99332*n+.0750759*c,s=.969*s+.153852*c,r=.8665*r+.3104856*c,o=.55*o+.5329522*c,a=-.7616*a-.016898*c,h[l]=i+n+s+r+o+a+u+.5362*c,h[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 r=2*Math.random()-1;i[s]=(n+.02*r)/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}()},i={};function n(){for(var n in e)i[n]=(new t.Buffer).fromArray(e[n])}return t.getContext(n),t.Context.on("init",n),t.Noise}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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 r=t.Ticks(this._getLoopDuration());e.id=t.Transport.scheduleRepeat(this._tick.bind(this),r,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}),e(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}),e(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 r=this._events[s];if(Math.abs(e.toTicks()-r.startOffset)<n)return t.isDefined(i)&&(r.value=i),r}return t.isDefined(i)?(this.add(e,i),this._events[this._events.length-1]):null},t.Part.prototype.add=function(e,i){var n;return e.hasOwnProperty("time")&&(e=(i=e).time),e=this.toTicks(e),i instanceof t.Event?(n=i).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")&&(e=(i=e).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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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="PulseOscillator",i="PWMOscillator",n="Oscillator",s="FMOscillator",r="AMOscillator",o="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===s?t="fm":this._sourceType===r?t="am":this._sourceType===o&&(t="fat"),t+this._oscillator.type},set:function(t){"fm"===t.substr(0,2)?(this._createNewOscillator(s),this._oscillator.type=t.substr(2)):"am"===t.substr(0,2)?(this._createNewOscillator(r),this._oscillator.type=t.substr(2)):"fat"===t.substr(0,3)?(this._createNewOscillator(o),this._oscillator.type=t.substr(3)):"pwm"===t?this._createNewOscillator(i):"pulse"===t?this._createNewOscillator(e):(this._createNewOscillator(n),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)return this._oscillator.width}}),Object.defineProperty(t.OmniOscillator.prototype,"count",{get:function(){if(this._sourceType===o)return this._oscillator.count},set:function(t){this._sourceType===o&&(this._oscillator.count=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"spread",{get:function(){if(this._sourceType===o)return this._oscillator.spread},set:function(t){this._sourceType===o&&(this._oscillator.spread=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationType",{get:function(){if(this._sourceType===s||this._sourceType===r)return this._oscillator.modulationType},set:function(t){this._sourceType!==s&&this._sourceType!==r||(this._oscillator.modulationType=t)}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationIndex",{get:function(){if(this._sourceType===s)return this._oscillator.modulationIndex}}),Object.defineProperty(t.OmniOscillator.prototype,"harmonicity",{get:function(){if(this._sourceType===s||this._sourceType===r)return this._oscillator.harmonicity}}),Object.defineProperty(t.OmniOscillator.prototype,"modulationFrequency",{get:function(){if(this._sourceType===i)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}),e(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],r=t.Transport.schedule(function(t){e[i]=t,n.apply(this,e)}.bind(this),s);this._scheduledEvents.push(r)}.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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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}),e(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);var n=(t=this.toFrequency(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}),e(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 r=new t.Multiply(e[n]);this._freqMultipliers[n]=r,this.frequency.chain(r,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}),e(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}),e(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}),e(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)).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],r=this._triggers[0],o=1;o<this._triggers.length;o++)this._triggers[o].release<r.release&&(r=this._triggers[o]);r.release=1/0,r.note=JSON.stringify(s),r.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 r=0;r<e.length;r++){var o=i[Math.min(r,i.length-1)];this.triggerRelease(e[r],n+this.toSeconds(o))}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 r=this._triggers[s];r.note===n&&r.release>e&&(r.voice.triggerRelease(e),r.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}),e(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 r in e)if(t.isNote(r)){s[t.Frequency(r).toMidi()]=e[r]}else{if(isNaN(parseFloat(r)))throw new Error("Tone.Sampler: url keys must be the note's pitch");s[r]=e[r]}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(),r=this._findClosest(s);if(null!==r){var o=s-r,a=this._buffers.get(o),u=new t.BufferSource({buffer:a,playbackRate:t.intervalToFrequencyRatio(r),fadeIn:this.attack,fadeOut:this.release,curve:"exponential"}).connect(this.output);u.start(i,0,a.duration,n),t.isArray(this._activeSources[s])||(this._activeSources[s]=[]),this._activeSources[s].push({note:s,source:u})}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){for(var e in t=this.toSeconds(t),this._activeSources)for(var i=this._activeSources[e];i.length;){i.shift().source.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(){for(var e in t.Instrument.prototype.dispose.call(this),this._buffers.dispose(),this._buffers=null,this._activeSources)this._activeSources[e].forEach(function(t){t.source.dispose()});return this._activeSources=null,this},t.Sampler}),e(function(t){t.supported&&(OscillatorNode.prototype.setPeriodicWave||(OscillatorNode.prototype.setPeriodicWave=OscillatorNode.prototype.setWaveTable),AudioContext.prototype.createPeriodicWave||(AudioContext.prototype.createPeriodicWave=AudioContext.prototype.createWaveTable))}),e(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}),e(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}),e(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}),e(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}),e(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))(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 r=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(r),this._loop&&t.isUndef(n)?r.start(e,i):r.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),r=this._elapsedTime.getTimeOfTick(s*this.buffer.duration,i?i.time-this.sampleTime:1/0);this.stop(r)}},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}),e(function(t){return t.Players=function(e){var i=Array.prototype.slice.call(arguments);i.shift();var n=t.defaults(i,["onload"],t.Players);for(var s in 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,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){this._loadingCount--,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}),e(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}),e(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}),t})},function(t,e){e.f={}.propertyIsEnumerable},function(t,e,i){"use strict";(function(t){var n=i(6),s=n.Buffer,r=n.SlowBuffer,o=n.kMaxLength||2147483647;e.alloc=function(t,e,i){if("function"==typeof s.alloc)return s.alloc(t,e,i);if("number"==typeof i)throw new TypeError("encoding must not be number");if("number"!=typeof t)throw new TypeError("size must be a number");if(t>o)throw new RangeError("size is too large");var n=i,r=e;void 0===r&&(n=void 0,r=0);var a=new s(t);if("string"==typeof r)for(var u=new s(r,n),h=u.length,l=-1;++l<t;)a[l]=u[l%h];else a.fill(r);return a},e.allocUnsafe=function(t){if("function"==typeof s.allocUnsafe)return s.allocUnsafe(t);if("number"!=typeof t)throw new TypeError("size must be a number");if(t>o)throw new RangeError("size is too large");return new s(t)},e.from=function(e,i,n){if("function"==typeof s.from&&(!t.Uint8Array||Uint8Array.from!==s.from))return s.from(e,i,n);if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("string"==typeof e)return new s(e,i);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var r=i;if(1===arguments.length)return new s(e);void 0===r&&(r=0);var o=n;if(void 0===o&&(o=e.byteLength-r),r>=e.byteLength)throw new RangeError("'offset' is out of bounds");if(o>e.byteLength-r)throw new RangeError("'length' is out of bounds");return new s(e.slice(r,r+o))}if(s.isBuffer(e)){var a=new s(e.length);return e.copy(a,0,0,e.length),a}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new s(e);if("Buffer"===e.type&&Array.isArray(e.data))return new s(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},e.allocUnsafeSlow=function(t){if("function"==typeof s.allocUnsafeSlow)return s.allocUnsafeSlow(t);if("number"!=typeof t)throw new TypeError("size must be a number");if(t>=o)throw new RangeError("size is too large");return new r(t)}}).call(e,i(17))},function(t,e){var i=Math.ceil,n=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?n:i)(t)}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,i){var n=i(20),s=i(2).document,r=n(s)&&n(s.createElement);t.exports=function(t){return r?s.createElement(t):{}}},function(t,e,i){var n=i(20);t.exports=function(t,e){if(!n(t))return t;var i,s;if(e&&"function"==typeof(i=t.toString)&&!n(s=i.call(t)))return s;if("function"==typeof(i=t.valueOf)&&!n(s=i.call(t)))return s;if(!e&&"function"==typeof(i=t.toString)&&!n(s=i.call(t)))return s;throw TypeError("Can't convert object to primitive value")}},function(t,e,i){var n=i(32),s=Math.min;t.exports=function(t){return t>0?s(n(t),9007199254740991):0}},function(t,e,i){var n=i(39)("keys"),s=i(25);t.exports=function(t){return n[t]||(n[t]=s(t))}},function(t,e,i){var n=i(2),s=n["__core-js_shared__"]||(n["__core-js_shared__"]={});t.exports=function(t){return s[t]||(s[t]={})}},function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,e,i){var n=i(42),s=i(1)("iterator"),r=i(15);t.exports=i(0).getIteratorMethod=function(t){if(void 0!=t)return t[s]||t["@@iterator"]||r[n(t)]}},function(t,e,i){var n=i(22),s=i(1)("toStringTag"),r="Arguments"==n(function(){return arguments}());t.exports=function(t){var e,i,o;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),s))?i:r?n(e):"Object"==(o=n(e))&&"function"==typeof e.callee?"Arguments":o}},function(t,e){e.f=Object.getOwnPropertySymbols},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.browser=e.isDesktop=e.isMobile=e.isAndroid=e.isIpad=e.isIphone=void 0;var n=a(i(105)),s=a(i(65));e.choice=function(t){return t[Math.floor(Math.random()*t.length)]},e.mod=function(t,e){return t-e*Math.floor(t/e)},e.norm=function(t,e,i){return(t-e)/(i-e)},e.requestAudioContext=function(t){if(c){var e=document.createElement("div"),i=document.createElement("div");i.innerHTML="Tap to start - please unmute your phone",(0,s.default)(e.style,{position:"absolute",width:"100%",height:"100%",zIndex:"10000",top:"0px",left:"0px",backgroundColor:"rgba(0, 0, 0, 0.8)"}),(0,s.default)(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),o.default.setContext(r.default.context),o.default.on(i),o.default.onStarted(function(i){e.remove(),t()})}else t()},e.dataURItoBlob=function(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),r=0;r<e.length;r++)s[r]=e.charCodeAt(r);return new Blob([n],{type:i})},e.ftom=function(t){return 69+12*(0,n.default)(t/440)},e.mtof=function(t){return 440*Math.pow(2,(t-69)/12)},e.tap=function(t){return function(e){f.isMobile?t():e.press&&t()}},e.get_diff_bounds=function(t){var e=t.map(function(t){var e=Math.min.apply(Math,t),i=Math.max.apply(Math,t);return i-e}),i=Math.min.apply(Math,e),n=Math.max.apply(Math,e);return{min:i,max:n}},e.get_bounds=function(t){var e=t.lines,i=(e=e.map(function(t){return t.map(function(t){return parseFloat(t)})})).reduce(function(t,e){return e.reduce(function(t,e){return Math.max(t,e)},t)},-1/0),n=e.reduce(function(t,e){return e.reduce(function(t,e){return Math.min(t,e)},t)},1/0);return{rows:e,max:i,min:n}},e.transpose=function(t){for(var e=t[0].length,i=t.length,n=new Array(e),s=0;s<e;s++){n[s]=new Array(i);for(var r=0;r<i;r++)n[s][r]=t[r][s]}return n};var r=a(i(29)),o=a(i(108));function a(t){return t&&t.__esModule?t:{default:t}}var u=e.isIphone=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i),h=e.isIpad=navigator.userAgent.match(/iPad/i),l=e.isAndroid=navigator.userAgent.match(/Android/i),c=e.isMobile=u||h||l,p=e.isDesktop=!c;document.body.classList.add(c?"mobile":"desktop");var f=e.browser={isIphone:u,isIpad:h,isMobile:c,isDesktop:p}},function(t,e,i){e.f=i(1)},function(t,e,i){var n=i(2),s=i(0),r=i(24),o=i(45),a=i(4).f;t.exports=function(t){var e=s.Symbol||(s.Symbol=r?{}:n.Symbol||{});"_"==t.charAt(0)||t in e||a(e,t,{value:o.f(t)})}},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"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(!function(t){return"number"==typeof t}(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,o,a,u,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||s(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(r(i=this._events[t]))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(s(i))for(a=Array.prototype.slice.call(arguments,1),o=(h=i.slice()).length,u=0;u<o;u++)h[u].apply(this,a);return!0},i.prototype.addListener=function(t,e){var o;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]?s(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,s(this._events[t])&&!this._events[t].warned&&(o=r(this._maxListeners)?i.defaultMaxListeners:this._maxListeners)&&o>0&&this._events[t].length>o&&(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){if(!n(e))throw TypeError("listener must be a function");var i=!1;function s(){this.removeListener(t,s),i||(i=!0,e.apply(this,arguments))}return s.listener=e,this.on(t,s),this},i.prototype.removeListener=function(t,e){var i,r,o,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(o=(i=this._events[t]).length,r=-1,i===e||n(i.listener)&&i.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(s(i)){for(a=o;a-- >0;)if(i[a]===e||i[a].listener&&i[a].listener===e){r=a;break}if(r<0)return this;1===i.length?(i.length=0,delete this._events[t]):i.splice(r,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(n(i=this._events[t]))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){(e=t.exports=i(73)).Stream=e,e.Readable=e,e.Writable=i(50),e.Duplex=i(13),e.Transform=i(75),e.PassThrough=i(154)},function(t,e,i){"use strict";(function(e){!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports=function(t,i,n,s){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var r,o,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,i)});case 3:return e.nextTick(function(){t.call(null,i,n)});case 4:return e.nextTick(function(){t.call(null,i,n,s)});default:for(r=new Array(a-1),o=0;o<r.length;)r[o++]=arguments[o];return e.nextTick(function(){t.apply(null,r)})}}:t.exports=e.nextTick}).call(e,i(11))},function(t,e,i){"use strict";(function(e,n){t.exports=m;var s,r=i(49),o=!e.browser&&["v0.10","v0.9."].indexOf(e.version.slice(0,5))>-1?n:r;m.WritableState=d;var a=i(23);a.inherits=i(12);var u,h={deprecate:i(153)},l=i(74),c=i(6).Buffer,p=i(31);function f(){}function d(t,e){s=s||i(13),t=t||{},this.objectMode=!!t.objectMode,e instanceof s&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var n=t.highWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:a,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var u=!1===t.decodeStrings;this.decodeStrings=!u,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var i=t._writableState,n=i.sync,s=i.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(i),e)!function(t,e,i,n,s){--e.pendingcb,i?r(s,n):s(n);t._writableState.errorEmitted=!0,t.emit("error",n)}(t,i,n,e,s);else{var a=g(i);a||i.corked||i.bufferProcessing||!i.bufferedRequest||_(t,i),n?o(v,t,i,a,s):v(t,i,a,s)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new S(this)}function m(t){if(s=s||i(13),!(u.call(m,this)||this instanceof s))return new m(t);this._writableState=new d(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev)),l.call(this)}function y(t,e,i,n,s,r,o){e.writelen=n,e.writecb=o,e.writing=!0,e.sync=!0,i?t._writev(s,e.onwrite):t._write(s,r,e.onwrite),e.sync=!1}function v(t,e,i,n){i||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),w(t,e)}function _(t,e){e.bufferProcessing=!0;var i=e.bufferedRequest;if(t._writev&&i&&i.next){var n=e.bufferedRequestCount,s=new Array(n),r=e.corkedRequestsFree;r.entry=i;for(var o=0;i;)s[o]=i,i=i.next,o+=1;y(t,e,!0,e.length,s,"",r.finish),e.pendingcb++,e.lastBufferedRequest=null,r.next?(e.corkedRequestsFree=r.next,r.next=null):e.corkedRequestsFree=new S(e)}else{for(;i;){var a=i.chunk,u=i.encoding,h=i.callback;if(y(t,e,!1,e.objectMode?1:a.length,a,u,h),i=i.next,e.writing)break}null===i&&(e.lastBufferedRequest=null)}e.bufferedRequestCount=0,e.bufferedRequest=i,e.bufferProcessing=!1}function g(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function b(t,e){e.prefinished||(e.prefinished=!0,t.emit("prefinish"))}function w(t,e){var i=g(e);return i&&(0===e.pendingcb?(b(t,e),e.finished=!0,t.emit("finish")):b(t,e)),i}function S(t){var e=this;this.next=null,this.entry=null,this.finish=function(i){var n=e.entry;for(e.entry=null;n;){var s=n.callback;t.pendingcb--,s(i),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}}a.inherits(m,l),d.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(d.prototype,"buffer",{get:h.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(u=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(t){return!!u.call(this,t)||t&&t._writableState instanceof d}})):u=function(t){return t instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(t,e,i){var n=this._writableState,s=!1,o=c.isBuffer(t);return"function"==typeof e&&(i=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),"function"!=typeof i&&(i=f),n.ended?function(t,e){var i=new Error("write after end");t.emit("error",i),r(e,i)}(this,i):(o||function(t,e,i,n){var s=!0,o=!1;return null===i?o=new TypeError("May not write null values to stream"):"string"==typeof i||void 0===i||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),r(n,o),s=!1),s}(this,n,t,i))&&(n.pendingcb++,s=function(t,e,i,n,s,r){i||(n=function(t,e,i){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=p.from(e,i));return e}(e,n,s),c.isBuffer(n)&&(s="buffer"));var o=e.objectMode?1:n.length;e.length+=o;var a=e.length<e.highWaterMark;a||(e.needDrain=!0);if(e.writing||e.corked){var u=e.lastBufferedRequest;e.lastBufferedRequest=new function(t,e,i){this.chunk=t,this.encoding=e,this.callback=i,this.next=null}(n,s,r),u?u.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else y(t,e,!1,o,n,s,r);return a}(this,n,o,t,e,i)),s},m.prototype.cork=function(){this._writableState.corked++},m.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.finished||t.bufferProcessing||!t.bufferedRequest||_(this,t))},m.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},m.prototype._write=function(t,e,i){i(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(t,e,i){var n=this._writableState;"function"==typeof t?(i=t,t=null,e=null):"function"==typeof e&&(i=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,i){e.ending=!0,w(t,e),i&&(e.finished?r(i):t.once("finish",i));e.ended=!0,t.writable=!1}(this,n,i)}}).call(e,i(11),i(72).setImmediate)},function(t,e,i){"use strict";var n=i(6).Buffer,s=i(31),r=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===r||!r(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=h,this.end=l,e=4;break;case"utf8":this.fillLast=u,e=4;break;case"base64":this.text=c,this.end=p,e=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=s.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function u(t){var e=this.lastTotal-this.lastNeed,i=function(t,e,i){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(i);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(i+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(i+2)}}(this,t,e);return void 0!==i?i:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var i=t.toString("utf16le",e);if(i){var n=i.charCodeAt(i.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function l(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,i)}return e}function c(t,e){var i=(t.length-e)%3;return 0===i?t.toString("base64",e):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-i))}function p(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,i;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<t.length?e?e+this.text(t,i):this.text(t,i):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�".repeat(this.lastTotal-this.lastNeed):e},o.prototype.text=function(t,e){var i=function(t,e,i){var n=e.length-1;if(n<i)return 0;var s=a(e[n]);if(s>=0)return s>0&&(t.lastNeed=s-1),s;if(--n<i)return 0;if((s=a(e[n]))>=0)return s>0&&(t.lastNeed=s-2),s;if(--n<i)return 0;if((s=a(e[n]))>=0)return s>0&&(2===s?s=0:t.lastNeed=s-3),s;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=i;var n=t.length-(i-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,i){"use strict";var n=i(24),s=i(3),r=i(54),o=i(7),a=i(9),u=i(15),h=i(81),l=i(26),c=i(85),p=i(1)("iterator"),f=!([].keys&&"next"in[].keys()),d=function(){return this};t.exports=function(t,e,i,m,y,v,_){h(i,e,m);var g,b,w,S=function(t){if(!f&&t in k)return k[t];switch(t){case"keys":case"values":return function(){return new i(this,t)}}return function(){return new i(this,t)}},T=e+" Iterator",x="values"==y,A=!1,k=t.prototype,E=k[p]||k["@@iterator"]||y&&k[y],O=E||S(y),M=y?x?S("entries"):O:void 0,P="Array"==e&&k.entries||E;if(P&&(w=c(P.call(new t)))!==Object.prototype&&(l(w,T,!0),n||a(w,p)||o(w,p,d)),x&&E&&"values"!==E.name&&(A=!0,O=function(){return E.call(this)}),n&&!_||!f&&!A&&k[p]||o(k,p,O),u[e]=O,u[T]=d,y)if(g={values:x?O:S("values"),keys:v?O:S("keys"),entries:M},_)for(b in g)b in k||r(k,b,g[b]);else s(s.P+s.F*(f||A),e,g);return g}},function(t,e,i){t.exports=!i(8)&&!i(14)(function(){return 7!=Object.defineProperty(i(35)("div"),"a",{get:function(){return 7}}).a})},function(t,e,i){t.exports=i(7)},function(t,e,i){var n=i(5),s=i(82),r=i(40),o=i(38)("IE_PROTO"),a=function(){},u=function(){var t,e=i(35)("iframe"),n=r.length;for(e.style.display="none",i(58).appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),u=t.F;n--;)delete u.prototype[r[n]];return u()};t.exports=Object.create||function(t,e){var i;return null!==t?(a.prototype=n(t),i=new a,a.prototype=null,i[o]=t):i=u(),void 0===e?i:s(i,e)}},function(t,e,i){var n=i(9),s=i(10),r=i(83)(!1),o=i(38)("IE_PROTO");t.exports=function(t,e){var i,a=s(t),u=0,h=[];for(i in a)i!=o&&n(a,i)&&h.push(i);for(;e.length>u;)n(a,i=e[u++])&&(~r(h,i)||h.push(i));return h}},function(t,e,i){var n=i(22);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==n(t)?t.split(""):Object(t)}},function(t,e,i){t.exports=i(2).document&&document.documentElement},function(t,e,i){var n=i(5);t.exports=function(t,e,i,s){try{return s?e(n(i)[0],i[1]):e(i)}catch(e){var r=t.return;throw void 0!==r&&n(r.call(t)),e}}},function(t,e,i){var n=i(15),s=i(1)("iterator"),r=Array.prototype;t.exports=function(t){return void 0!==t&&(n.Array===t||r[s]===t)}},function(t,e,i){var n=i(1)("iterator"),s=!1;try{var r=[7][n]();r.return=function(){s=!0},Array.from(r,function(){throw 2})}catch(t){}t.exports=function(t,e){if(!e&&!s)return!1;var i=!1;try{var r=[7],o=r[n]();o.next=function(){return{done:i=!0}},r[n]=function(){return o},t(r)}catch(t){}return i}},function(t,e,i){"use strict";e.__esModule=!0;var n=r(i(88)),s=r(i(94));function r(t){return t&&t.__esModule?t:{default:t}}e.default=function(){return function(t,e){if(Array.isArray(t))return t;if((0,n.default)(Object(t)))return function(t,e){var i=[],n=!0,r=!1,o=void 0;try{for(var a,u=(0,s.default)(t);!(n=(a=u.next()).done)&&(i.push(a.value),!e||i.length!==e);n=!0);}catch(t){r=!0,o=t}finally{try{!n&&u.return&&u.return()}finally{if(r)throw o}}return i}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}()},function(t,e,i){!function(e,i){t.exports=i()}(0,function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={exports:{},id:n,loaded:!1};return t[n].call(s.exports,s,s.exports,i),s.loaded=!0,s.exports}return i.m=t,i.c=e,i.p="",i(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";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}}(),r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};e.colors=function(){return _.colors},e.context=function(){return _.context},e.clock=function(){return _.clock},Object.defineProperty(e,"__esModule",{value:!0});var o=n(i(2)),a=n(i(5)),u=n(i(38)),h=n(i(40)),l=function(t){return t&&t.__esModule?t:{default:t}}(i(39)),c=i(28),p=i(41),f=i(27),d=i(26),m=i(25),y=n(i(42)),v=n(i(45)),_=new(function(){function t(e){for(var i in r(this,t),o)this[i]=o[i];for(var i in a)this[i]=a[i];var n={Rack:u},s={Counter:c,Radio:p,Drunk:f,Sequence:d,Matrix:m};for(var i in s)this[i]=s[i];for(var i in n)this[i]=n[i];var _=window.AudioContext||window.webkitAudioContext;for(var i in this._context=e||new _,this.tune=new h,this.note=this.tune.note.bind(this.tune),this.clock=new y(this._context),this.clock.start(),this.Interval=v,this.colors={accent:"#2bb",fill:"#eee",light:"#fff",dark:"#333",mediumLight:"#ccc",mediumDark:"#666"},this.transform=l,this.add=l.add,this.Add={},o)this.Add[i]=l.add.bind(this,i);var g=document.getElementsByTagName("style"),b=document.createElement("style");(b.type="text/css",b.innerHTML="[nexus-ui]{height:5000px;width:5000px}",g.length>0)?g[0].parentNode.insertBefore(b,g[0]):document.write("<style>[nexus-ui]{height:5000px;width:5000px}</style>")}return s(t,{context:{get:function(){return this._context},set:function(t){this.clock.stop(),this._context=t,this.clock=new y(this.context),this.clock.start()}}}),t}());e.default=_},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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(6),u=i(11),h=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),l=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[200,200],mode:"absolute",minX:0,maxX:1,stepX:0,x:.5,minY:0,maxY:1,stepY:0,y:.5}),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 h.Handle(this.settings.mode,"horizontal",[0,this.width],[this.height,0]),y:new h.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 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)}(e,a),n(e,{buildInterface:{value:function(){this.knob=o.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}();t.exports=l},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,r){var o=n.toCartesian(i,r),a=n.toCartesian(i,s),u=r-s<=180?"0":"1";return["M",o.x+t,o.y+e,"A",i,i,0,u,0,a.x+t,a.y+e].join(" ")},radialGradient:function(t,e){var i="gradient"+n.ri(1e11),s=[],r=document.createElementNS("http://www.w3.org/2000/svg","radialGradient");r.setAttribute("id",i),r.setAttribute("cx","50%"),r.setAttribute("cy","50%"),r.setAttribute("r","50%"),t.appendChild(r);for(var o=0;o<e;o++){var a=document.createElementNS("http://www.w3.org/2000/svg","stop");a.setAttribute("id","stop"+o),r.appendChild(a),s.push(a)}return{id:i,stops:s,element:r}}}},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>=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,r=e-n;return Math.sqrt(s*s+r*r)},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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(7),u=i(8),h=i(9),l=i(10),c=i(1).colors,p=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=c();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 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)}(e,l),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 r=0;r<t.length;r++){var o=t[r];if(u.isObject(o))for(var s in o)n[s]=o[s];else if("function"==typeof o)n.event=o;else if(e.length>=1){n[s=e.splice(0,1)[0]]=o}}return this.parent=a.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=o.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,h.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=a.findPosition(this.element),this.mouse=a.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=a.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=a.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=a.findPosition(this.element),this.mouse=a.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=a.locateTouch(t,this.offset),this.touchMove(),t.preventDefault(),t.stopPropagation())}},preTouchRelease:{value:function(t){this.mouse=a.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}();t.exports=p},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"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(!function(t){return"number"==typeof t}(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,o,a,u,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||s(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(r(i=this._events[t]))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(s(i))for(a=Array.prototype.slice.call(arguments,1),o=(h=i.slice()).length,u=0;u<o;u++)h[u].apply(this,a);return!0},i.prototype.addListener=function(t,e){var o;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]?s(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,s(this._events[t])&&!this._events[t].warned&&(o=r(this._maxListeners)?i.defaultMaxListeners:this._maxListeners)&&o>0&&this._events[t].length>o&&(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){if(!n(e))throw TypeError("listener must be a function");var i=!1;function s(){this.removeListener(t,s),i||(i=!0,e.apply(this,arguments))}return s.listener=e,this.on(t,s),this},i.prototype.removeListener=function(t,e){var i,r,o,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(o=(i=this._events[t]).length,r=-1,i===e||n(i.listener)&&i.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(s(i)){for(a=o;a-- >0;)if(i[a]===e||i[a].listener&&i[a].listener===e){r=a;break}if(r<0)return this;1===i.length?(i.length=0,delete this._events[t]):i.splice(r,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(n(i=this._events[t]))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")},r=i(5),o=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],r=void 0===arguments[3]?0:arguments[3];s(this,t),this.min=e,this.max=i,this.step=n,this.value=r,this.changed=!1,this.oldValue=!1,this.update(this.value)}return n(t,{update:{value:function(t){return this.step?this.value=r.clip(Math.round((t-this.min)/this.step)*this.step+this.min,this.min,this.max):this.value=r.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=r.scale(t,0,1,this.min,this.max),this.update(this.value)}},normalized:{get:function(){return r.normalize(this.value,this.min,this.max)}}}),t}();t.exports=o},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}}(),r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};Object.defineProperty(e,"__esModule",{value:!0});var o=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];r(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=o.clip(this.value,0,1)}},convertPositionToValue:{value:function(t){switch(this.direction){case"radial":var e=o.toPolar(t.x-this.boundary.center.x,t.y-this.boundary.center.y);return e=((e=e.angle/(2*Math.PI))-.25+1)%1;case"vertical":return o.scale(t.y,this.boundary.min.y,this.boundary.max.y,0,1);case"horizontal":return o.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];r(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:o.clip(this.mouse.x/this.width,0,1),y:o.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:o.clip(this.mouse.x/this.width,0,1),y:o.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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(6),u=i(11),h=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),l=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["min","max","value"],{size:[120,20],mode:"relative",min:0,max:1,step:0,value:0}),this.orientation="vertical",this._value=new u(this.settings.min,this.settings.max,this.settings.step,this.settings.value),this.position=new h.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 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)}(e,a),n(e,{buildInterface:{value:function(){this.bar=o.create("rect"),this.fillbar=o.create("rect"),this.knob=o.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,r=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)",r=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+")",r=n/2),this.bar.setAttribute("x",t),this.bar.setAttribute("y",e),this.bar.setAttribute("transform",s),this.bar.setAttribute("rx",r),this.bar.setAttribute("ry",r),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",r),this.fillbar.setAttribute("ry",r),"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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(13),u=i(6),h=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[40,20],target:!1,state:!1}),this._state=new a(this.settings.state),this.init()}return 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)}(e,u),n(e,{buildInterface:{value:function(){this.bar=o.create("rect"),this.knob=o.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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(17),u=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["mode"],{size:[80,80],mode:"aftertouch",state:!1}),this.mode=this.settings.mode,this.init(),this.render()}return 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)}(e,a),n(e,{buildInterface:{value:function(){this.pad=o.create("circle"),this.element.appendChild(this.pad),this.interactionTarget=this.pad,this.defs=o.create("defs"),this.element.appendChild(this.defs),this.gradient=o.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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(5),u=i(13),h=i(6),l=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 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)}(e,h),n(e,{buildInterface:{value:function(){this.pad=o.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:a.clip(this.mouse.x/this.width,0,1),y:a.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:a.clip(this.mouse.x/this.width,0,1),y:a.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:a.clip(this.mouse.x/this.width,0,1),y:a.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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(17),a=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[150,50],state:!1,text:"Play"}),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 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)}(e,o),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}();t.exports=a},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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(6),a=i(16),u=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[120,25],numberOfButtons:4,active:-1}),this.buttons=[],this._numberOfButtons=this.settings.numberOfButtons,this.active=this.settings.active,this.init(),this.render()}return 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)}(e,o),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 a(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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(6),a=i(11),u=i(5),h=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[60,30],value:0,min:0,max:2e4,step:1}),this._value=new a(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 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)}(e,o),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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(6),a=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[100,30],options:["default","options"]}),this._selectedIndex=-1,this._value=!1,this._options=this.settings.options,this.init(),this.render()}return 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)}(e,o),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(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}();t.exports=a},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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(5),u=i(6),h=i(11),l=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),c=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["min","max","value"],{size:[75,75],interaction:"radial",mode:"relative",min:0,max:1,step:0,value:0}),this.interaction=this.settings.interaction,this._value=new h(this.settings.min,this.settings.max,this.settings.step,this.settings.value),this.position=new l.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 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)}(e,u),n(e,{buildInterface:{value:function(){this.background=o.create("circle"),this.screw=o.create("circle"),this.handle=o.create("path"),this.handle2=o.create("path"),this.handleFill=o.create("path"),this.handle2Fill=o.create("path"),this.handleLine=o.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:a.clip(a.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:a.clip(a.scale(i,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},r=o.arc(t.x,t.y,e/2-e/40,n.start,n.end),u=o.arc(t.x,t.y,e/2-e/40,s.start,s.end);this.handle.setAttribute("d",r),this.handle.setAttribute("stroke-width",e/20),this.handle.setAttribute("fill","none"),this.handle2.setAttribute("d",u),this.handle2.setAttribute("stroke-width",e/20),this.handle2.setAttribute("fill","none"),r+=" L "+t.x+" "+t.y,this.handleFill.setAttribute("d",r),this.handleFill.setAttribute("fill-opacity","0.3"),u+=" L "+t.x+" "+t.y,this.handle2Fill.setAttribute("d",u),this.handle2Fill.setAttribute("fill-opacity","0.3");var h=void 0;h=i<.5?n.end:s.end;var l=t.x+Math.cos(h)*(e/2),c=t.y+Math.sin(h)*(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:a.clip(a.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:a.clip(a.scale(t,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},r=o.arc(e.x,e.y,i/2-i/40,n.start,n.end),u=o.arc(e.x,e.y,i/2-i/40,s.start,s.end);this.handle.setAttribute("d",r),this.handle2.setAttribute("d",u),r+=" L "+e.x+" "+e.y,this.handleFill.setAttribute("d",r),u+=" L "+e.x+" "+e.y,this.handle2Fill.setAttribute("d",u);var h=void 0;h=t<=.5?n.end:s.end;var l=e.x+Math.cos(h)*(i/2),c=e.y+Math.sin(h)*(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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=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)},o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),u=i(6),h=i(17),l=i(9),c=function(t){function e(){o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value","note","color"],{size:[80,80],target:!1,mode:"button",value:0}),this.note=this.settings.note,this.color=this.settings.color,this.colors={w:"#fff",b:"#666"},this.init(),this.render()}return r(e,h),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}(),p=function(t){function e(){o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[500,125],lowNote:24,highNote:60,mode:"button"}),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 r(e,u),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}var r=t,o=(this.width-2)/r,a=(this.height-2)/2;for(i=0;i<this.keys.length;i++){var u=this.keys[i].parent;u.style.position="absolute",u.style.left=e[i]*o+1+"px","w"===this.keys[i].color?(u.style.top="1px",this.keys[i].resize(o,2*a)):(u.style.zIndex=1,u.style.top="1px",this.keys[i].resize(o,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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=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)},o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(4),u=i(7),h=i(6),l=i(17),c=i(25),p=i(28),f=i(9),d=function(t){function e(){o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[80,80],target:!1,mode:"toggle",value:0}),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 r(e,l),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=u.findPosition(t.element)),t.mouse=u.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}(),m=function(t){function e(){o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[400,200],mode:"toggle",rows:5,columns:10}),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 r(e,h),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}();t.exports=m},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}}(),r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=n(i(5)),a=n(i(26)),u=function(){function t(e,i){var n=this;r(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]=o.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]=o.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]=o.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=u},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}}(),r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=n(i(5)),a=n(i(27)),u=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];r(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:o.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){"up"===t||"down"===t||"random"===t||"drunk"===t?(this._mode=t,this.position&&(this.next=this[this._mode])):console.error("The only modes currently allowed are: up, down, random, drunk")}},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=o.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=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")},r=function(t){return t&&t.__esModule?t.default:t}(i(5)),o=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],r=void 0===arguments[3]?1:arguments[3],o=void 0!==arguments[4]&&arguments[4];s(this,t),this.min=e,this.max=i,this.value=n,this.increment=r,this.loop=o}return n(t,{next:{value:function(){return this.value+=r.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=o},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}}(),r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=n(i(5)),a=n(i(27)),u=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];r(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){"up"===t||"down"===t||"random"===t||"drunk"===t?(this._mode=t,this.value&&(this.next=this[this._mode])):console.error("The only modes currently allowed are: up, down, random, drunk")},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:~~o.average(this.min,this.max),random:o.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=o.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=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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(5),u=i(6),h=i(11),l=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),c=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["range"],{size:[200,200],range:.5,mode:"absolute",speakers:[[.5,.2],[.75,.25],[.8,.5],[.75,.75],[.5,.8],[.25,.75],[.2,.5],[.25,.25]]}),this.value={x:new h(0,1,0,.5),y:new h(0,1,0,.5)},this.mode=this.settings.mode,this.position={x:new l.Handle(this.mode,"horizontal",[0,this.width],[this.height,0]),y:new l.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 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)}(e,u),n(e,{buildInterface:{value:function(){this.knob=o.create("circle"),this.element.appendChild(this.knob),this.speakerElements=[];for(var t=0;t<this.speakers.length;t++){var e=o.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=a.distance(e[0]*t.width,e[1]*t.height,t.position.x.value*t.width,(1-t.position.y.value)*t.height),s=a.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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(5),a=i(4),u=i(6),h=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[80,80]}),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 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)}(e,u),n(e,{buildInterface:{value:function(){this.title=a.create("text"),this.circleX=a.create("circle"),this.circleY=a.create("circle"),this.circleZ=a.create("circle"),this.barX=a.create("path"),this.barY=a.create("path"),this.barZ=a.create("path"),this.barX2=a.create("path"),this.barY2=a.create("path"),this.barZ2=a.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=o.scale(i,-90,90,0,1),e=o.scale(e,-90,90,0,1),n=o.scale(n,0,360,0,1);var s={start:1.5*Math.PI,end:o.clip(o.scale(i,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},r={start:2.5*Math.PI,end:o.clip(o.scale(i,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},u=a.arc(this.circleX.cx.baseVal.value,this.circleX.cy.baseVal.value,this.circleX.r.baseVal.value,s.start,s.end),h=a.arc(this.circleX.cx.baseVal.value,this.circleX.cy.baseVal.value,this.circleX.r.baseVal.value,r.start,r.end);this.barX.setAttribute("d",u),this.barX2.setAttribute("d",h),s={start:1.5*Math.PI,end:o.clip(o.scale(e,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},r={start:2.5*Math.PI,end:o.clip(o.scale(e,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},u=a.arc(this.circleY.cx.baseVal.value,this.circleY.cy.baseVal.value,this.circleY.r.baseVal.value,s.start,s.end),h=a.arc(this.circleY.cx.baseVal.value,this.circleY.cy.baseVal.value,this.circleY.r.baseVal.value,r.start,r.end),this.barY.setAttribute("d",u),this.barY2.setAttribute("d",h),s={start:1.5*Math.PI,end:o.clip(o.scale(n,0,.5,1.5*Math.PI,.5*Math.PI),.5*Math.PI,1.5*Math.PI)},r={start:2.5*Math.PI,end:o.clip(o.scale(n,.5,1,2.5*Math.PI,1.5*Math.PI),1.5*Math.PI,2.5*Math.PI)},u=a.arc(this.circleZ.cx.baseVal.value,this.circleZ.cy.baseVal.value,this.circleZ.r.baseVal.value,s.start,s.end),h=a.arc(this.circleZ.cx.baseVal.value,this.circleZ.cy.baseVal.value,this.circleZ.r.baseVal.value,r.start,r.end),this.barZ.setAttribute("d",u),this.barZ2.setAttribute("d",h),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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=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)},o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=i(7),u=i(5),h=i(6),l=i(32),c=i(9),p=function(t){function e(){var t=this;o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["scale","value"],{size:[120,20],orientation:"vertical",mode:"absolute",scale:[0,1],step:0,value:0,hasKnob:!0}),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),r=t.multislider.sliders[n].value,o=t.multislider.sliders[s].value,h=n;h<s;h++){t.multislider.sliders[h].value=u.interp((h-n)/i,r,o);var l=t.multislider.sliders[h].value;t.multislider.values[h]=l,t.multislider.update(h,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 r(e,l),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}(),f=function(t){function e(){o(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[200,100],numberOfSliders:5,min:0,max:1,step:0,values:[.7,.7,.7,.7,.7]}),this._numberOfSliders=this.settings.numberOfSliders,this.values=this.settings.values,this.sliders=[],this.interacting=!1,this.init()}return r(e,h),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"),r=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));r.multislider=this,r.index=n,c.exists&&(r.bar.index=n,r.fillbar.index=n,r.preClick=r.preMove=r.preRelease=function(){},r.click=r.move=r.release=function(){},r.preTouch=r.preTouchMove=r.preTouchRelease=function(){},r.touch=r.touchMove=r.touchRelease=function(){}),this.sliders.push(r),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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(6),u=i(11),h=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),l=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 h.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 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)}(e,a),n(e,{buildInterface:{value:function(){this.bar=o.create("rect"),this.fillbar=o.create("rect"),this.knob=o.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,r=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)",r=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+")",r=n/2),this.bar.setAttribute("x",t),this.bar.setAttribute("y",e),this.bar.setAttribute("transform",s),this.bar.setAttribute("rx",r),this.bar.setAttribute("ry",r),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",r),this.fillbar.setAttribute("ry",r),"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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(4),a=i(5),u=i(6),h=i(11),l=function(t){return t&&t.__esModule?t:{default:t}}(i(12)),c=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["scale","value"],{size:[120,20],orientation:"horizontal",mode:"relative",scale:[-1,1],step:0,value:0,hasKnob:!0}),this.orientation=this.settings.orientation,this.mode=this.settings.mode,this.hasKnob=this.settings.hasKnob,this.step=this.settings.step,this._value=new h(this.settings.scale[0],this.settings.scale[1],this.settings.step,this.settings.value),this.init(),this.position=new l.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 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)}(e,u),n(e,{buildInterface:{value:function(){this.bar=o.create("rect"),this.knob=o.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,r=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)",r=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+")",r=n/2),this.bar.setAttribute("x",t),this.bar.setAttribute("y",e),this.bar.setAttribute("transform",s),this.bar.setAttribute("rx",r),this.bar.setAttribute("ry",r),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(a.scale(this.value,-1,1,1,0),2),R:Math.pow(a.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(a.scale(this.value,-1,1,1,0),2),R:Math.pow(a.scale(this.value,-1,1,0,1),2)}),this.render()}},normalized:{get:function(){return this._value.normalized}}}),e}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(5),a=i(4),u=i(6),h=function(t,e){this.x=t.x,this.y=t.y,this.envelope=e,this.element=a.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],r=this.envelope.nodes[n],o=i>=0?s.x:0,a=n<this.envelope.nodes.length?r.x:1;this.x<o&&(this.x=o),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)}},l=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["value"],{size:[300,150],points:[{x:.1,y:.4},{x:.35,y:.6},{x:.65,y:.2},{x:.9,y:.4}]}),this.points=this.settings.points,this.nodes=[],this.selected=!1,this.init()}return 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)}(e,u),n(e,{buildInterface:{value:function(){var t=this;this.points.forEach(function(e){var i=new h(e,t);t.nodes.push(i)}),this.sortPoints(),this.line=a.create("polyline"),this.line.setAttribute("stroke-width",2),this.line.setAttribute("fill","none"),this.element.appendChild(this.line),this.fill=a.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=o.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,r=0;r<s.length;r++){var o=Math.sqrt(Math.pow(s[r].x-i,2)+Math.pow(s[r].y-n,2));o<e&&(e=o,t=r,i>s[r].x)}return e>.07&&(t=this.getIndexFromX(this.mouse.x/this.width),this.nodes.splice(t,0,new h({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=o.clip(this.nodes[t].x,0,1),i=o.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 h({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],r=o.scale(t,n.x,s.x,0,1),a=o.interp(r,n.y,s.y);return this.emit("scan",a),a}},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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(7),a=i(6),u=i(1).context,h=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["scale","value"],{size:[300,150]}),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 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)}(e,a),n(e,{buildFrame:{value:function(){this.canvas=new o.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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(7),a=i(5),u=i(6),h=i(1).context,l=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["scale","value"],{size:[30,100]}),this.context=h(),this.channels=2,this.splitter=this.context.createChannelSplitter(this.channels),this.analysers=[];for(var t=0;t<this.channels;t++){var i=this.context.createAnalyser();this.splitter.connect(i,t),i.fftSize=1024,i.smoothingTimeConstant=1,this.analysers.push(i)}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 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)}(e,u),n(e,{buildFrame:{value:function(){this.canvas=new o.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=a.normalize(this.db,-70,5),s=n*n,r=a.scale(s,0,1,this.element.height,0);this.canvas.context.fillStyle=this.colors.accent,this.canvas.context.fillRect(this.meterWidth*t,r,this.meterWidth,this.canvas.element.height-r)}}}},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}();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 r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in s&&s.writable)return s.value;var o=s.get;return void 0!==o?o.call(n):void 0},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o=i(7),a=i(6),u=i(1).context,h=function(t){function e(){r(this,e);s(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,arguments,["scale","value"],{size:[300,150]}),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 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)}(e,a),n(e,{buildFrame:{value:function(){this.canvas=new o.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*this.canvas.element.height/2;0===i?this.canvas.context.moveTo(e,n):this.canvas.context.lineTo(e,n),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}();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")},r=function(t){return t&&t.__esModule?t:{default:t}}(i(39)),o=function(t){return t&&t.__esModule?t.default:t}(i(7)),a=i(1).colors,u=function(){function t(e,i){s(this,t),this.meta={},this.meta.target=e,this.meta.parent=o.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=r.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=u},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)),r=n(i(2)),o=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 o=new r[e](t,i);return o.id=t.id,o};e.element=a,e.section=function(t,e){e=e||"nexus-ui";for(var i={},n={},u=s.parseElement(t).getElementsByTagName("*"),h=[],l=0;l<u.length;l++)h.push(u[l]);for(l=0;l<h.length;l++){var c=h[l].getAttribute(e);if(c){var p=!1;for(var f in r)c.toLowerCase()===f.toLowerCase()&&(p=f);console.log(p);var d=a(h[l],p);d.id?n[d.id]=d:n[o(d,i)]=d}}return n},e.add=function(t,e,i){var n=document.createElement("div");return i=i||{},(e=e?s.parseElement(e):document.body).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)}},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")},r=function(t){return t&&t.__esModule?t.default:t}(i(5)),o=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=r.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],r=this.root*s;return r*=Math.pow(2,i),r=Math.floor(1e11*r)/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(r.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=o},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 r=void 0===arguments[0]?3:arguments[0];n(this,t),r<0&&(r=1),this.length=r,this.onVals=i,this.array=new Array(r).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=.1,n=.001,s=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)};s.prototype.clear=function(){return this.clock._removeEvent(this),this._cleared=!0,this},s.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},s.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},s.prototype.isRepeated=function(){return null!==this.repeatTime},s.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)},s.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)},s.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))},s.prototype._refreshEarlyLateDates=function(){this._latestTime=this.deadline+this.toleranceLate,this._earliestTime=this.deadline-this.toleranceEarly};var r=t.exports=function(t,e){e=e||{},this.tickMethod=e.tickMethod||"ScriptProcessorNode",this.toleranceEarly=e.toleranceEarly||n,this.toleranceLate=e.toleranceLate||i,this.context=t,this._events=[],this._started=!1};r.prototype.setTimeout=function(t,e){return this._createEvent(t,this._absTime(e))},r.prototype.callbackAtTime=function(t,e){return this._createEvent(t,e)},r.prototype.timeStretch=function(t,e,i){return e.forEach(function(e){e.timeStretch(t,i)}),e},r.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)}},r.prototype.stop=function(){!0===this._started&&(this._started=!1,this._clockNode.disconnect())},r.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)},r.prototype._createEvent=function(t,e){return new s(this,e,t)},r.prototype._insertEvent=function(t){this._events.splice(this._indexByTime(t._earliestTime),0,t)},r.prototype._removeEvent=function(t){var e=this._events.indexOf(t);-1!==e&&this._events.splice(e,1)},r.prototype._hasEvent=function(t){return-1!==this._events.indexOf(t)},r.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},r.prototype._absTime=function(t){return t+this.context.currentTime},r.prototype._relTime=function(t){return t-this.context.currentTime}}).call(e,i(44))},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var u,h=[],l=!1,c=-1;function p(){l&&u&&(l=!1,u.length?h=u.concat(h):c=-1,h.length&&f())}function f(){if(!l){var t=a(p);l=!0;for(var e=h.length;e;){for(u=h,h=[];++c<e;)u&&u[c].run();c=-1,e=h.length}u=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function m(){}s.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];h.push(new d(t,e)),1!==h.length||l||a(f)},d.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(t){return[]},s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.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")},r=i(1).clock,o=function(){function t(e,i,n){s(this,t),this.rate=e,this.on=n,this.clock=r(),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=o}])})},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(i(101));var s=[{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 n.default(t)}),r=s[0],o=function(){};function a(t){r&&r.heading&&r.heading.classList.remove("selected"),(r=s[t]).heading&&r.heading.classList.add("selected"),o(r)}e.default={scales:s,current:function(){return r},build:function(){s.forEach(function(t,e){t.heading=document.createElement("div"),t.heading.innerHTML=t.name,t.heading.classList.add("heading"),t.heading.addEventListener("click",function(){a(e)}),scale_list.appendChild(t.heading)}),a(0)},build_options:function(t){s.forEach(function(e,i){var n=document.createElement("option");n.innerHTML=e.name,n.value=i,t.appendChild(n)}),t.addEventListener("input",function(t){a(t.target.value)}),a(0)},pick:a,names:function(){return s.map(function(t){return t.name})},onChange:function(t){o=t}}},function(t,e,i){t.exports={default:i(102),__esModule:!0}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return t&&t.__esModule?t:{default:t}}(i(29));i(44);var s=2,r=0,o=new n.default.Compressor(-30,3).toMaster(),a=[{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"}];a.forEach(function(t){t.players=[],t.index=-1;for(var e=0;e<s;e++){var i=t.fn;window.location.href.match(/asdf.us/)&&(i="//asdf.us/kalimba/"+i);var r=new n.default.Player({url:i,retrigger:!0,playbackRate:1});r.connect(o),t.players.push(r)}}),e.default={play:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i={sample:a[r]};r=(r+1)%a.length,i.sample.index=(i.sample.index+1)%s;var n=i.sample.players[i.sample.index];n.playbackRate=t/i.sample.root,n.volume.value=e,setTimeout(function(){n.start()},0)}}},function(t,e,i){var n=i(56),s=i(40).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return n(t,s)}},function(t,e){},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.nx=void 0;var n=s(i(128));e.update_value_on_change=function(t,e,i,n){var s=document.querySelector(e+" + .val"),r=function(t){s.innerHTML=i?parseInt(t):t.toFixed(2),n&&n(t)};t.on("change",r),r(t.value),t.update=r},e.update_radio_value_on_change=function(t,e,i,n){var s=t.active,r=document.querySelector(e+" + .val"),o=function(e){-1===e?e=t.active=s:s=e,r.innerHTML=i[e][1],n&&n(e)};t.on("change",o),o(t.active),t.update=o},e.build_options=function(t,e,i){(0,n.default)(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)})};s(i(63));function s(t){return t&&t.__esModule?t:{default:t}}e.nx=window.nx={}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e,i){var n,s,r,o=i(19),a=i(144),u=i(58),h=i(35),l=i(2),c=l.process,p=l.setImmediate,f=l.clearImmediate,d=l.MessageChannel,m=0,y={},v=function(){var t=+this;if(y.hasOwnProperty(t)){var e=y[t];delete y[t],e()}},_=function(t){v.call(t.data)};p&&f||(p=function(t){for(var e=[],i=1;arguments.length>i;)e.push(arguments[i++]);return y[++m]=function(){a("function"==typeof t?t:Function(t),e)},n(m),m},f=function(t){delete y[t]},"process"==i(22)(c)?n=function(t){c.nextTick(o(v,t,1))}:d?(r=(s=new d).port2,s.port1.onmessage=_,n=o(r.postMessage,r,1)):l.addEventListener&&"function"==typeof postMessage&&!l.importScripts?(n=function(t){l.postMessage(t+"","*")},l.addEventListener("message",_,!1)):n="onreadystatechange"in h("script")?function(t){u.appendChild(h("script")).onreadystatechange=function(){u.removeChild(this),v.call(t)}}:function(t){setTimeout(o(v,t,1),0)}),t.exports={set:p,clear:f}},function(t,e,i){(function(t){var n=void 0!==t&&t||"undefined"!=typeof self&&self||window,s=Function.prototype.apply;function r(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new r(s.call(setTimeout,n,arguments),clearTimeout)},e.setInterval=function(){return new r(s.call(setInterval,n,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(n,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},i(149),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(e,i(17))},function(t,e,i){"use strict";(function(e){t.exports=v;var n,s=i(49),r=i(70);v.ReadableState=y;i(47).EventEmitter;var o=function(t,e){return t.listeners(e).length},a=i(74),u=i(6).Buffer,h=i(31),l=i(23);l.inherits=i(12);var c=i(151),p=void 0;p=c&&c.debuglog?c.debuglog("stream"):function(){};var f,d=i(152);l.inherits(v,a);var m=["error","close","destroy","pause","resume"];function y(t,e){n=n||i(13),t=t||{},this.objectMode=!!t.objectMode,e instanceof n&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var s=t.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=s||0===s?s:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=i(51).StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function v(t){if(n=n||i(13),!(this instanceof v))return new v(t);this._readableState=new y(t,this),this.readable=!0,t&&"function"==typeof t.read&&(this._read=t.read),a.call(this)}function _(t,e,i,n,r){var o=function(t,e){var i=null;u.isBuffer(e)||"string"==typeof e||null===e||void 0===e||t.objectMode||(i=new TypeError("Invalid non-string/buffer chunk"));return i}(e,i);if(o)t.emit("error",o);else if(null===i)e.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,w(t)}(t,e);else if(e.objectMode||i&&i.length>0)if(e.ended&&!r){var a=new Error("stream.push() after EOF");t.emit("error",a)}else if(e.endEmitted&&r){var h=new Error("stream.unshift() after end event");t.emit("error",h)}else{var l;!e.decoder||r||n||(i=e.decoder.write(i),l=!e.objectMode&&0===i.length),r||(e.reading=!1),l||(e.flowing&&0===e.length&&!e.sync?(t.emit("data",i),t.read(0)):(e.length+=e.objectMode?1:i.length,r?e.buffer.unshift(i):e.buffer.push(i),e.needReadable&&w(t))),function(t,e){e.readingMore||(e.readingMore=!0,s(T,t,e))}(t,e)}else r||(e.reading=!1);return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(e)}v.prototype.push=function(t,e){var i=this._readableState;return i.objectMode||"string"!=typeof t||(e=e||i.defaultEncoding)!==i.encoding&&(t=h.from(t,e),e=""),_(this,i,t,e,!1)},v.prototype.unshift=function(t){return _(this,this._readableState,t,"",!0)},v.prototype.isPaused=function(){return!1===this._readableState.flowing},v.prototype.setEncoding=function(t){return f||(f=i(51).StringDecoder),this._readableState.decoder=new f(t),this._readableState.encoding=t,this};var g=8388608;function b(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=g?t=g:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function w(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?s(S,t):S(t))}function S(t){p("emit readable"),t.emit("readable"),k(t)}function T(t,e){for(var i=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(p("maybeReadMore read 0"),t.read(0),i!==e.length);)i=e.length;e.readingMore=!1}function x(t){p("readable nexttick read 0"),t.read(0)}function A(t,e){e.reading||(p("resume read 0"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit("resume"),k(t),e.flowing&&!e.reading&&t.read(0)}function k(t){var e=t._readableState;for(p("flow",e.flowing);e.flowing&&null!==t.read(););}function E(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):i=function(t,e,i){var n;t<e.head.data.length?(n=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):n=t===e.head.data.length?e.shift():i?function(t,e){var i=e.head,n=1,s=i.data;t-=s.length;for(;i=i.next;){var r=i.data,o=t>r.length?r.length:t;if(o===r.length?s+=r:s+=r.slice(0,t),0===(t-=o)){o===r.length?(++n,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=r.slice(o));break}++n}return e.length-=n,s}(t,e):function(t,e){var i=h.allocUnsafe(t),n=e.head,s=1;n.data.copy(i),t-=n.data.length;for(;n=n.next;){var r=n.data,o=t>r.length?r.length:t;if(r.copy(i,i.length-t,0,o),0===(t-=o)){o===r.length?(++s,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=r.slice(o));break}++s}return e.length-=s,i}(t,e);return n}(t,e.buffer,e.decoder),i);var i}function O(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,s(M,e,t))}function M(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function P(t,e){for(var i=0,n=t.length;i<n;i++)if(t[i]===e)return i;return-1}v.prototype.read=function(t){p("read",t),t=parseInt(t,10);var e=this._readableState,i=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?O(this):w(this),null;if(0===(t=b(t,e))&&e.ended)return 0===e.length&&O(this),null;var n,s=e.needReadable;return p("need readable",s),(0===e.length||e.length-t<e.highWaterMark)&&p("length less than watermark",s=!0),e.ended||e.reading?p("reading or ended",s=!1):s&&(p("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=b(i,e))),null===(n=t>0?E(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&O(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,i){var n=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=t;break;case 1:a.pipes=[a.pipes,t];break;default:a.pipes.push(t)}a.pipesCount+=1,p("pipe count=%d opts=%j",a.pipesCount,i);var u=(!i||!1!==i.end)&&t!==e.stdout&&t!==e.stderr?l:d;function h(t){p("onunpipe"),t===n&&d()}function l(){p("onend"),t.end()}a.endEmitted?s(u):n.once("end",u),t.on("unpipe",h);var c=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,k(t))}}(n);t.on("drain",c);var f=!1;function d(){p("cleanup"),t.removeListener("close",_),t.removeListener("finish",g),t.removeListener("drain",c),t.removeListener("error",v),t.removeListener("unpipe",h),n.removeListener("end",l),n.removeListener("end",d),n.removeListener("data",y),f=!0,!a.awaitDrain||t._writableState&&!t._writableState.needDrain||c()}var m=!1;function y(e){p("ondata"),m=!1,!1!==t.write(e)||m||((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==P(a.pipes,t))&&!f&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,m=!0),n.pause())}function v(e){p("onerror",e),b(),t.removeListener("error",v),0===o(t,"error")&&t.emit("error",e)}function _(){t.removeListener("finish",g),b()}function g(){p("onfinish"),t.removeListener("close",_),b()}function b(){p("unpipe"),n.unpipe(t)}return n.on("data",y),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener(e,i);t._events&&t._events[e]?r(t._events[e])?t._events[e].unshift(i):t._events[e]=[i,t._events[e]]:t.on(e,i)}(t,"error",v),t.once("close",_),t.once("finish",g),t.emit("pipe",n),a.flowing||(p("pipe resume"),n.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s<n;s++)i[s].emit("unpipe",this);return this}var r=P(e.pipes,t);return-1===r?this:(e.pipes.splice(r,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this),this)},v.prototype.on=function(t,e){var i=a.prototype.on.call(this,t,e);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var n=this._readableState;n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&w(this):s(x,this))}return i},v.prototype.addListener=v.prototype.on,v.prototype.resume=function(){var t=this._readableState;return t.flowing||(p("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,s(A,t,e))}(this,t)),this},v.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this},v.prototype.wrap=function(t){var e=this._readableState,i=!1,n=this;for(var s in t.on("end",function(){if(p("wrapped end"),e.decoder&&!e.ended){var t=e.decoder.end();t&&t.length&&n.push(t)}n.push(null)}),t.on("data",function(s){(p("wrapped data"),e.decoder&&(s=e.decoder.write(s)),!e.objectMode||null!==s&&void 0!==s)&&((e.objectMode||s&&s.length)&&(n.push(s)||(i=!0,t.pause())))}),t)void 0===this[s]&&"function"==typeof t[s]&&(this[s]=function(e){return function(){return t[e].apply(t,arguments)}}(s));for(var r=0;r<m.length;r++)t.on(m[r],n.emit.bind(n,m[r]));return n._read=function(e){p("wrapped _read",e),i&&(i=!1,t.resume())},n},v._fromList=E}).call(e,i(11))},function(t,e,i){t.exports=i(47).EventEmitter},function(t,e,i){"use strict";t.exports=o;var n=i(13),s=i(23);function r(t){this.afterTransform=function(e,i){return function(t,e,i){var n=t._transformState;n.transforming=!1;var s=n.writecb;if(!s)return t.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,null!==i&&void 0!==i&&t.push(i);s(e);var r=t._readableState;r.reading=!1,(r.needReadable||r.length<r.highWaterMark)&&t._read(r.highWaterMark)}(t,e,i)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function o(t){if(!(this instanceof o))return new o(t);n.call(this,t),this._transformState=new r(this);var e=this;this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.once("prefinish",function(){"function"==typeof this._flush?this._flush(function(t,i){a(e,t,i)}):a(e)})}function a(t,e,i){if(e)return t.emit("error",e);null!==i&&void 0!==i&&t.push(i);var n=t._writableState,s=t._transformState;if(n.length)throw new Error("Calling transform done when ws.length != 0");if(s.transforming)throw new Error("Calling transform done when still transforming");return t.push(null)}s.inherits=i(12),s.inherits(o,n),o.prototype.push=function(t,e){return this._transformState.needTransform=!1,n.prototype.push.call(this,t,e)},o.prototype._transform=function(t,e,i){throw new Error("_transform() is not implemented")},o.prototype._write=function(t,e,i){var n=this._transformState;if(n.writecb=i,n.writechunk=t,n.writeencoding=e,!n.transforming){var s=this._readableState;(n.needTransform||s.needReadable||s.length<s.highWaterMark)&&this._read(s.highWaterMark)}},o.prototype._read=function(t){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0}},function(t,e,i){"use strict";var n=m(i(77)),s=m(i(62)),r=m(i(97)),o=m(i(29)),a=m(i(63)),u=m(i(100)),h=m(i(64)),l=m(i(66)),c=i(123),p=i(44),f=i(69),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}(i(137));function m(t){return t&&t.__esModule?t:{default:t}}var y=60,v=null,_=!1,g=!1,b=void 0;(0,c.midi_init)();var w=["date","timestamp","fatalities","injured","total_victims","age","case","weapon_type","weapon_details"].reduce(function(t,e,i){return t[e]=i,t},{}),S=["incident_id","date","state","city_or_county","address","n_killed","n_injured","incident_url","source_url","incident_url_fields_missing","congressional_district","gun_stolen","gun_type","incident_characteristics","latitude","location_description","longitude","n_guns_involved","notes","participant_age","participant_age_group","participant_gender","participant_name","participant_relationship","participant_status","participant_type","sources","state_house_district","state_senate_district"].reduce(function(t,e,i){return t[e]=i,t},{}),T=[31,28,31,30,31,30,31,31,30,31,30,31,0].reduce(function(t,e,i){return 0===i?[e]:t.concat(t[i-1]+e)},[]),x=0,A=0,k=0,E={},O={},M={},P=[],C=c.play_sequence;function I(t,e,i,n){var s,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"all",a=arguments[5],u=e.min,d=e.max,m=O.dates.length,y=[],v=[],_=[],g=void 0,b=Math.floor(t/4)%4,S=Math.floor((t-48)/48);console.log(S);var T=-S;S>0&&(S+=1);for(var x=0;t>=O.dates[k]&&k<m&&(y.push(O.lines[0][k]),O.isMass?_.push(O.data[k][w.date]+" "+O.data[k][w.case]+", "+O.data[k][w.fatalities]+" dead, "+O.data[k][w.injured]+" injured"):_.push(O.labels[k]),k+=1,!((x+=1)>=4)););switch(y.length){default:case 0:break;case 1:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value+T,128,r,a,0)),g=[128];break;case 2:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value+T,64,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value+T,64,r,a,64)),g=[64,64];break;case 3:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value+T,43,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value+T,43,r,a,43)),v.push((0,c.play_note)((0,p.norm)(y[2],u,d)*f.nx.multiply.value+T,42,r,a,85)),g=[43,43,42];break;case 4:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value+T,32,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value+T,32,r,a,32)),v.push((0,c.play_note)((0,p.norm)(y[2],u,d)*f.nx.multiply.value+T,32,r,a,64)),v.push((0,c.play_note)((0,p.norm)(y[3],u,d)*f.nx.multiply.value+T,32,r,a,96)),g=[32,32,32,32];break;case 5:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value+T,22,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value+T,21,r,a,22)),v.push((0,c.play_note)((0,p.norm)(y[2],u,d)*f.nx.multiply.value+T,21,r,a,43)),v.push((0,c.play_note)((0,p.norm)(y[3],u,d)*f.nx.multiply.value+T,32,r,a,64)),v.push((0,c.play_note)((0,p.norm)(y[4],u,d)*f.nx.multiply.value+T,32,r,a,96)),g=[22,21,21,32,32];break;case 6:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value+T,22,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value+T,21,r,a,22)),v.push((0,c.play_note)((0,p.norm)(y[2],u,d)*f.nx.multiply.value+T,21,r,a,43)),v.push((0,c.play_note)((0,p.norm)(y[3],u,d)*f.nx.multiply.value+T,22,r,a,64)),v.push((0,c.play_note)((0,p.norm)(y[4],u,d)*f.nx.multiply.value+T,21,r,a,86)),v.push((0,c.play_note)((0,p.norm)(y[5],u,d)*f.nx.multiply.value+T,21,r,a,107)),g=[22,21,21,22,21,21];break;case 7:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value,16,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value,16,r,a,16)),v.push((0,c.play_note)((0,p.norm)(y[2],u,d)*f.nx.multiply.value,16,r,a,32)),v.push((0,c.play_note)((0,p.norm)(y[3],u,d)*f.nx.multiply.value,16,r,a,48)),v.push((0,c.play_note)((0,p.norm)(y[4],u,d)*f.nx.multiply.value,22,r,a,64)),v.push((0,c.play_note)((0,p.norm)(y[5],u,d)*f.nx.multiply.value,21,r,a,86)),v.push((0,c.play_note)((0,p.norm)(y[6],u,d)*f.nx.multiply.value,21,r,a,107)),g=[16,16,16,16,22,21,21];break;case 8:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value,16,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value,16,r,a,16)),v.push((0,c.play_note)((0,p.norm)(y[2],u,d)*f.nx.multiply.value,16,r,a,32)),v.push((0,c.play_note)((0,p.norm)(y[3],u,d)*f.nx.multiply.value,16,r,a,48)),v.push((0,c.play_note)((0,p.norm)(y[4],u,d)*f.nx.multiply.value,16,r,a,64)),v.push((0,c.play_note)((0,p.norm)(y[5],u,d)*f.nx.multiply.value,16,r,a,80)),v.push((0,c.play_note)((0,p.norm)(y[6],u,d)*f.nx.multiply.value,16,r,a,96)),v.push((0,c.play_note)((0,p.norm)(y[7],u,d)*f.nx.multiply.value,16,r,a,112)),g=[16,16,16,16,16,16,16,16];break;case 9:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value,11,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value,11,r,a,11)),v.push((0,c.play_note)((0,p.norm)(y[2],u,d)*f.nx.multiply.value,10,r,a,22)),v.push((0,c.play_note)((0,p.norm)(y[3],u,d)*f.nx.multiply.value,16,r,a,32)),v.push((0,c.play_note)((0,p.norm)(y[4],u,d)*f.nx.multiply.value,16,r,a,48)),v.push((0,c.play_note)((0,p.norm)(y[5],u,d)*f.nx.multiply.value,16,r,a,64)),v.push((0,c.play_note)((0,p.norm)(y[6],u,d)*f.nx.multiply.value,16,r,a,80)),v.push((0,c.play_note)((0,p.norm)(y[7],u,d)*f.nx.multiply.value,16,r,a,96)),v.push((0,c.play_note)((0,p.norm)(y[8],u,d)*f.nx.multiply.value,16,r,a,112)),g=[11,11,10,16,16,16,16,16,16];break;case 10:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value,11,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value,11,r,a,11)),v.push((0,c.play_note)((0,p.norm)(y[2],u,d)*f.nx.multiply.value,10,r,a,22)),v.push((0,c.play_note)((0,p.norm)(y[3],u,d)*f.nx.multiply.value,11,r,a,32)),v.push((0,c.play_note)((0,p.norm)(y[4],u,d)*f.nx.multiply.value,11,r,a,43)),v.push((0,c.play_note)((0,p.norm)(y[5],u,d)*f.nx.multiply.value,10,r,a,54)),v.push((0,c.play_note)((0,p.norm)(y[6],u,d)*f.nx.multiply.value,16,r,a,64)),v.push((0,c.play_note)((0,p.norm)(y[7],u,d)*f.nx.multiply.value,16,r,a,80)),v.push((0,c.play_note)((0,p.norm)(y[8],u,d)*f.nx.multiply.value,16,r,a,96)),v.push((0,c.play_note)((0,p.norm)(y[9],u,d)*f.nx.multiply.value,16,r,a,112)),g=[11,11,10,11,11,10,16,16,16,16];break;case 11:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value,11,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value,11,r,a,11)),v.push((0,c.play_note)((0,p.norm)(y[2],u,d)*f.nx.multiply.value,10,r,a,22)),v.push((0,c.play_note)((0,p.norm)(y[3],u,d)*f.nx.multiply.value,11,r,a,32)),v.push((0,c.play_note)((0,p.norm)(y[4],u,d)*f.nx.multiply.value,11,r,a,43)),v.push((0,c.play_note)((0,p.norm)(y[5],u,d)*f.nx.multiply.value,10,r,a,54)),v.push((0,c.play_note)((0,p.norm)(y[6],u,d)*f.nx.multiply.value,11,r,a,64)),v.push((0,c.play_note)((0,p.norm)(y[7],u,d)*f.nx.multiply.value,11,r,a,75)),v.push((0,c.play_note)((0,p.norm)(y[8],u,d)*f.nx.multiply.value,10,r,a,86)),v.push((0,c.play_note)((0,p.norm)(y[9],u,d)*f.nx.multiply.value,16,r,a,96)),v.push((0,c.play_note)((0,p.norm)(y[10],u,d)*f.nx.multiply.value,16,r,a,112)),g=[11,11,10,11,11,10,11,11,10,16,16];break;case 12:v.push((0,c.play_note)((0,p.norm)(y[0],u,d)*f.nx.multiply.value,11,r,a,0)),v.push((0,c.play_note)((0,p.norm)(y[1],u,d)*f.nx.multiply.value,11,r,a,11)),v.push((0,c.play_note)((0,p.norm)(y[2],u,d)*f.nx.multiply.value,10,r,a,22)),v.push((0,c.play_note)((0,p.norm)(y[3],u,d)*f.nx.multiply.value,11,r,a,32)),v.push((0,c.play_note)((0,p.norm)(y[4],u,d)*f.nx.multiply.value,11,r,a,43)),v.push((0,c.play_note)((0,p.norm)(y[5],u,d)*f.nx.multiply.value,10,r,a,54)),v.push((0,c.play_note)((0,p.norm)(y[6],u,d)*f.nx.multiply.value,11,r,a,64)),v.push((0,c.play_note)((0,p.norm)(y[7],u,d)*f.nx.multiply.value,11,r,a,75)),v.push((0,c.play_note)((0,p.norm)(y[8],u,d)*f.nx.multiply.value,10,r,a,86)),v.push((0,c.play_note)((0,p.norm)(y[9],u,d)*f.nx.multiply.value,11,r,a,96)),v.push((0,c.play_note)((0,p.norm)(y[10],u,d)*f.nx.multiply.value,11,r,a,107)),v.push((0,c.play_note)((0,p.norm)(y[11],u,d)*f.nx.multiply.value,10,r,a,118)),g=[11,11,10,11,11,10,11,11,10,11,11,10]}var A=h.default.current().index(f.nx.pedal_tone.value-b+4-S,f.nx.octave.value);return s=function(t){var e=(0,p.ftom)(t),i=e%1;i>.5&&(e+=1,i-=1);return i*=2,(e=Math.floor(e))>127?0:o.default.Frequency(Math.floor(e),"midi").toNote()}(A),a||(l.default.play(A,-12),_.length&&(document.querySelector("#cases").innerHTML=_.join("<br>"))),m<=k?(k=0,t=0):t+=1,y.length?[t,v,g,s]:[t,[],[],s]}function R(){if(!g){var t=12e4/o.default.Transport.bpm.value*c.note_values[f.nx.timing.active][0];clearTimeout(b),b=setTimeout(R,t);var e=C(x,M,P,t),i=(0,s.default)(e,3),n=i[0],r=i[1];i[2];if(O.labels,x=n,_){var a=c.note_values[f.nx.timing.active][2];a.length&&(a=a[x%a.length]),v.addEvent(new c.MidiWriter.NoteEvent({pitch:r,duration:"t"+a}))}}}function F(t){console.log("pick dataset:",t,E[t]),x=0,k=0,window.location.hash=t,O=E[t],M=(0,p.get_bounds)(O),P=(0,p.get_diff_bounds)(M.rows),C=O.play_fn,A=O.max_i||M.rows.length*M.rows[0].length,O.onPick&&O.onPick()}function N(){h.default.build_options(document.querySelector("#scale")),(0,f.build_options)(document.querySelector("#dataset"),E,F);var t=[50,50];o.default.Transport.bpm.value=y,f.nx.tempo=new a.default.Dial("#tempo",{size:t,min:10,max:300,step:1,value:y}),(0,f.update_value_on_change)(f.nx.tempo,"#tempo",!0,function(t){return o.default.Transport.bpm.value=t}),f.nx.timing=new a.default.RadioButton("#timing",{size:[400,25],numberOfButtons:c.note_values.length,active:6}),(0,f.update_radio_value_on_change)(f.nx.timing,"#timing",c.note_values),f.nx.duration=new a.default.Dial("#duration",{size:t,min:0,max:2,step:.01,value:.8}),(0,f.update_value_on_change)(f.nx.duration,"#duration",!1),f.nx.offset=new a.default.Dial("#offset",{size:t,min:-24,max:24,step:1,value:-5}),(0,f.update_value_on_change)(f.nx.offset,"#offset",!0),f.nx.octave=new a.default.Dial("#octave",{size:t,min:-4,max:4,step:1,value:0}),(0,f.update_value_on_change)(f.nx.octave,"#octave",!0),f.nx.multiply=new a.default.Dial("#multiply",{size:t,min:-64,max:64,step:1,value:19}),(0,f.update_value_on_change)(f.nx.multiply,"#multiply",!0),f.nx.interval=new a.default.Dial("#interval",{size:t,min:-64,max:64,step:1,value:10}),(0,f.update_value_on_change)(f.nx.interval,"#interval",!0),f.nx.pedal_tone=new a.default.Dial("#pedal_tone",{size:t,min:-24,max:24,step:1,value:-7}),(0,f.update_value_on_change)(f.nx.pedal_tone,"#pedal_tone",!0),document.querySelector("#play").addEventListener("click",function(){x=0,k=0,g=!1,R()}),document.querySelector("#pause").addEventListener("click",function(){g=!0}),document.querySelector("#export_midi").addEventListener("click",function(){(0,c.export_pattern_as_midi)(O,M,P,f.nx.tempo.value,f.nx.timing.active,C,A)});var e=document.querySelector("#record_midi");e.addEventListener("click",function(){if(_){e.innerHTML="Record MIDI",document.body.classList.remove("recording"),_=!1;var t=new c.MidiWriter.Writer([v]),i=(0,p.dataURItoBlob)(t.dataUri());saveAs(i,"Recording - "+O.name+".mid")}else e.innerHTML="Save Recording",document.body.classList.add("recording"),_=!0,(v=new c.MidiWriter.Track).setTempo(f.nx.tempo.value)}),document.querySelector(".loading").classList.remove("loading"),document.querySelector("#scale").value="14",h.default.pick(14);var i=decodeURIComponent(window.location.hash.substr(1))||"Mass Shootings";document.querySelector("#dataset").value=i,F(i)}d.load().then(function(t){console.log(t);for(var e=t.media,i=[],o=0;o<e.lines.length;o++)i.push(e.lines[o]);E.Media={},E.Media.name="Media after Parkland",E.Media.play_fn=c.play_sequence,E.Media.h=e.h.slice(1,5),E.Media.labels=i.map(function(t){return t.slice(0,1).map(function(t){return(t/7).toFixed(1)})}),E.Media.lines=i.map(function(t){return t.slice(1,3).map(function(t){return(0,r.default)(t+1)})}),E.Media.onPick=function(){f.nx.offset.value=-13,f.nx.multiply.value=20,document.querySelector("#scale").value="0",h.default.pick(0)};var a=t.ar_15_2016_18;E["AR-15 2016-18"]={},E["AR-15 2016-18"].name="AR-15 (2016-18)",E["AR-15 2016-18"].pedal=!0,E["AR-15 2016-18"].play_fn=I;var u=a.lines.map(function(t){if(t[S.incident_characteristics].match("Shots Fired - No Injuries"))return null;if(t[S.n_killed]+t[S.n_injured]<4)return null;var e=t[S.date].split("-"),i=(0,s.default)(e,3),n=i[0],r=i[1],o=i[2];if(parseInt(n)>2017)return null;var a=365*(parseInt(n)-2016),u=T[parseInt(r)],h=Math.floor(parseInt(o))+14,l=Math.floor((a+u+h)/7),c=t[S.n_killed]+t[S.n_injured];return 0===t[S.n_killed]&&(c=-t[S.n_injured]),[l,Math.log(Math.log(c+10)+1),"** !!, $$, {} killed, [] injured".replace("**",t[S.date]).replace("!!",t[S.city_or_county]).replace("$$",t[S.state]).replace("{}",t[S.n_killed]).replace("[]",t[S.n_injured]),t[S.n_killed],t[S.n_injured]]}).filter(function(t){return!!t});E["AR-15 2016-18"].dates=u.map(function(t){return t[0]}),E["AR-15 2016-18"].dates.push(u.length),E["AR-15 2016-18"].lines=[u.map(function(t){return t[1]})],E["AR-15 2016-18"].labels=u.map(function(t){return t[2]});var l=t.school_shootings;E["School Shootings 2015-18"]={},E["School Shootings 2015-18"].name="School Shootings (2015-18)",E["School Shootings 2015-18"].pedal=!0,E["School Shootings 2015-18"].play_fn=I,E["School Shootings 2015-18"].onPick=function(){f.nx.offset.value=-2,f.nx.multiply.value=11,f.nx.pedal_tone.value=-8,document.querySelector("#scale").value="0",h.default.pick(0)};var d=l.lines.map(function(t){if(t[S.incident_characteristics].match("Shots Fired - No Injuries"))return null;if(t[S.n_killed]+t[S.n_injured]<4)return null;var e=t[S.date].split("-"),i=(0,s.default)(e,3),n=i[0],r=i[1],o=i[2];if(parseInt(n)>2018)return null;if(parseInt(n)<2015)return null;var a=365*(parseInt(n)-2015),u=T[parseInt(r)],h=Math.floor(parseInt(o))+14,l=Math.floor((a+u+h)/7),c=t[S.n_killed]+t[S.n_injured];return 0===t[S.n_killed]&&(c=t[S.n_injured]-4),[l,Math.log(Math.log(c+10)+1),"** !!, $$, {} killed, [] injured".replace("**",t[S.date]).replace("!!",t[S.city_or_county]).replace("$$",t[S.state]).replace("{}",t[S.n_killed]).replace("[]",t[S.n_injured]),t[S.n_killed],t[S.n_injured]]}).filter(function(t){return!!t});E["School Shootings 2015-18"].dates=d.map(function(t){return t[0]}),E["School Shootings 2015-18"].dates.push(d.length),E["School Shootings 2015-18"].lines=[d.map(function(t){return t[1]})],E["School Shootings 2015-18"].labels=d.map(function(t){return t[2]});var m=t.firearms_manufactured;E["Firearms Manufactured"]={},E["Firearms Manufactured"].name="Firearms Manufactured",E["Firearms Manufactured"].play_fn=c.play_sequence,E["Firearms Manufactured"].h=m.h.slice(1,5),E["Firearms Manufactured"].labels=m.lines.map(function(t){return t.slice(0,1)}),E["Firearms Manufactured"].lines=m.lines.map(function(t){return t.slice(1,5)}),(0,p.transpose)(t.gun_violence_by_month.lines).forEach(function(e,i){var n=t.gun_violence_by_month.h[i];"Date"!==n&&(E[n]={name:n,h:[n],lines:[e.map(function(t){return parseInt(t)})],play_fn:c.play_sequence})}),E["Mass Shootings"]=t.mass_shootings_from_columbine,E["Mass Shootings"].name="Mass Shootings",E["Mass Shootings"].pedal=!0,E["Mass Shootings"].isMass=!0,E["Mass Shootings"].play_fn=I;var y=E["Mass Shootings"].lines.reverse(),v=y[0][w.date].split("/"),_=(0,n.default)(v),g=_[0],b=(_.slice(1),y[y.length-1][w.date].split("/")),x=(0,n.default)(b),A=x[0];x.slice(1);E["Mass Shootings"].dates=y.map(function(t){var e=t[w.date].split("/"),i=(0,s.default)(e,3),n=i[0],r=i[1];i[2];return 12*(parseInt(n)-parseInt(g))+parseInt(r)}),E["Mass Shootings"].max_i=12*(parseInt(A)-parseInt(g))+parseInt(12),E["Mass Shootings"].data=y,E["Mass Shootings"].lines=[y.map(function(t){return t[w.total_victims]})],(0,p.requestAudioContext)(N)}),u.default.listen(function(t){f.nx.offset.value=t,f.nx.offset.update(t)})},function(t,e,i){"use strict";e.__esModule=!0;var n=function(t){return t&&t.__esModule?t:{default:t}}(i(78));e.default=function(t){return Array.isArray(t)?t:(0,n.default)(t)}},function(t,e,i){t.exports={default:i(79),__esModule:!0}},function(t,e,i){i(18),i(86),t.exports=i(0).Array.from},function(t,e,i){var n=i(32),s=i(33);t.exports=function(t){return function(e,i){var r,o,a=String(s(e)),u=n(i),h=a.length;return u<0||u>=h?t?"":void 0:(r=a.charCodeAt(u))<55296||r>56319||u+1===h||(o=a.charCodeAt(u+1))<56320||o>57343?t?a.charAt(u):r:t?a.slice(u,u+2):o-56320+(r-55296<<10)+65536}}},function(t,e,i){"use strict";var n=i(55),s=i(21),r=i(26),o={};i(7)(o,i(1)("iterator"),function(){return this}),t.exports=function(t,e,i){t.prototype=n(o,{next:s(1,i)}),r(t,e+" Iterator")}},function(t,e,i){var n=i(4),s=i(5),r=i(16);t.exports=i(8)?Object.defineProperties:function(t,e){s(t);for(var i,o=r(e),a=o.length,u=0;a>u;)n.f(t,i=o[u++],e[i]);return t}},function(t,e,i){var n=i(10),s=i(37),r=i(84);t.exports=function(t){return function(e,i,o){var a,u=n(e),h=s(u.length),l=r(o,h);if(t&&i!=i){for(;h>l;)if((a=u[l++])!=a)return!0}else for(;h>l;l++)if((t||l in u)&&u[l]===i)return t||l||0;return!t&&-1}}},function(t,e,i){var n=i(32),s=Math.max,r=Math.min;t.exports=function(t,e){return(t=n(t))<0?s(t+e,0):r(t,e)}},function(t,e,i){var n=i(9),s=i(27),r=i(38)("IE_PROTO"),o=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=s(t),n(t,r)?t[r]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?o:null}},function(t,e,i){"use strict";var n=i(19),s=i(3),r=i(27),o=i(59),a=i(60),u=i(37),h=i(87),l=i(41);s(s.S+s.F*!i(61)(function(t){Array.from(t)}),"Array",{from:function(t){var e,i,s,c,p=r(t),f="function"==typeof this?this:Array,d=arguments.length,m=d>1?arguments[1]:void 0,y=void 0!==m,v=0,_=l(p);if(y&&(m=n(m,d>2?arguments[2]:void 0,2)),void 0==_||f==Array&&a(_))for(i=new f(e=u(p.length));e>v;v++)h(i,v,y?m(p[v],v):p[v]);else for(c=_.call(p),i=new f;!(s=c.next()).done;v++)h(i,v,y?o(c,m,[s.value,v],!0):s.value);return i.length=v,i}})},function(t,e,i){"use strict";var n=i(4),s=i(21);t.exports=function(t,e,i){e in t?n.f(t,e,s(0,i)):t[e]=i}},function(t,e,i){t.exports={default:i(89),__esModule:!0}},function(t,e,i){i(28),i(18),t.exports=i(93)},function(t,e,i){"use strict";var n=i(91),s=i(92),r=i(15),o=i(10);t.exports=i(52)(Array,"Array",function(t,e){this._t=o(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,i=this._i++;return!t||i>=t.length?(this._t=void 0,s(1)):s(0,"keys"==e?i:"values"==e?t[i]:[i,t[i]])},"values"),r.Arguments=r.Array,n("keys"),n("values"),n("entries")},function(t,e){t.exports=function(){}},function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},function(t,e,i){var n=i(42),s=i(1)("iterator"),r=i(15);t.exports=i(0).isIterable=function(t){var e=Object(t);return void 0!==e[s]||"@@iterator"in e||r.hasOwnProperty(n(e))}},function(t,e,i){t.exports={default:i(95),__esModule:!0}},function(t,e,i){i(28),i(18),t.exports=i(96)},function(t,e,i){var n=i(5),s=i(41);t.exports=i(0).getIterator=function(t){var e=s(t);if("function"!=typeof e)throw TypeError(t+" is not iterable!");return n(e.call(t))}},function(t,e,i){t.exports={default:i(98),__esModule:!0}},function(t,e,i){i(99),t.exports=i(0).Math.log10},function(t,e,i){var n=i(3);n(n.S,"Math",{log10:function(t){return Math.log(t)/Math.LN10}})},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n={},s={},r="zxcvbnmasdfghjklqwertyuiop",o=function(){};r.toUpperCase().split("").map(function(t,e){n[t.charCodeAt(0)]=e}),"1234567890".split("").map(function(t,e){n[t.charCodeAt(0)]=e+r.length,s[t.charCodeAt(0)]=!0}),window.addEventListener("keydown",function(t){if(t.altKey||t.ctrlKey||t.metaKey)return void t.stopPropagation();if(document.activeElement instanceof HTMLInputElement&&t.keyCode in s)return void t.stopPropagation();if(!(t.keyCode in n))return;var e=n[t.keyCode];t.shiftKey&&(e+=r.length);o(e-=7)},!0),e.default={listen:function(t){o=t}}},function(t,e,i){"use strict";var n=function(t){return t&&t.__esModule?t:{default:t}}(i(65));t.exports=function(){var t=function(t){t=this.opt=(0,n.default)({name:"",root:466.164,octave:0,interval:2,tet:0,intervals:null},t||{}),this.generate()};t.prototype.generate=function(t){(t=(0,n.default)(this.opt,t||{})).scl?this.generate_scl():t.tet?this.generate_tet():t.intervals&&this.generate_intervals()},t.prototype.generate_intervals=function(){this.opt.root;var t=this.opt.intervals;"string"==typeof t&&(t=t.split(" ")),this.name=this.opt.name||"interval list",this.intervals=t,this.interval=this.opt.interval=e.call(this,t.pop()),this.scale=t.map(i.bind(this)).filter(function(t){return!!t})},t.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),r=e;t.push(r);for(var o=0;o<i-1;o++)r*=s,t.push(r);this.name=this.opt.name||i+"-tone equal temperament",this.intervals=null},t.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})},t.prototype.parse_scl=function(t){var i={comments:[],notes:[]};return t.trim().split("\n").forEach(function(t){if(-1!==t.indexOf("!"))i.comments.push(t);else if("description"in i)if(i.notes.length){var n=t.replace(/^[^-\.0-9]+/,"").replace(/[^-\/\.0-9]+$/,"");(n=-1!==n.indexOf(".")?Math.pow(2,parseFloat(n)/1200):e(n))&&i.notes.push(n)}else i.notes.push(1);else i.description=t}),i},t.prototype.index=function(t,e){e=e||this.opt.octave;var i=this.scale[0|s(t,this.scale.length)],n=Math.floor(function(t,e,i){return(t-e)/(i-e)}(t,0,this.scale.length))+e;return i*=Math.pow(this.interval,n)},t.prototype.range=function(t,e){for(var i=[],n=t;n<e;n++)i.push(this.index(n));return i},t.prototype.set_root=function(t){this.opt.root=t,this.generate()},t.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 r=0;r<s.length;r++)if(!(e>s[r])){e=s[r];break}return e*=Math.pow(2,i)},t.prototype.quantize_index=function(t){return 0|s(index-1,this.scale.length)};var e=t.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},i=t.prototype.parse_interval_string=function(t){return-1!==t.indexOf("/")?e(t)*this.opt.root:(t.indexOf("f"),parseFloat(t))};function s(t,e){return t-e*Math.floor(t/e)}return t}()},function(t,e,i){i(103),t.exports=i(0).Object.assign},function(t,e,i){var n=i(3);n(n.S+n.F,"Object",{assign:i(104)})},function(t,e,i){"use strict";var n=i(16),s=i(43),r=i(30),o=i(27),a=i(57),u=Object.assign;t.exports=!u||i(14)(function(){var t={},e={},i=Symbol(),n="abcdefghijklmnopqrst";return t[i]=7,n.split("").forEach(function(t){e[t]=t}),7!=u({},t)[i]||Object.keys(u({},e)).join("")!=n})?function(t,e){for(var i=o(t),u=arguments.length,h=1,l=s.f,c=r.f;u>h;)for(var p,f=a(arguments[h++]),d=l?n(f).concat(l(f)):n(f),m=d.length,y=0;m>y;)c.call(f,p=d[y++])&&(i[p]=f[p]);return i}:u},function(t,e,i){t.exports={default:i(106),__esModule:!0}},function(t,e,i){i(107),t.exports=i(0).Math.log2},function(t,e,i){var n=i(3);n(n.S,"Math",{log2:function(t){return Math.log(t)/Math.LN2}})},function(t,e,i){"use strict";var n,s,r;!function(t){t&&t.__esModule}
/**
* StartAudioContext.js
* @author Yotam Mann
* @license http://opensource.org/licenses/MIT MIT License
* @copyright 2016 Yotam Mann
- */(i(106));
+ */(i(109));
/**
* StartAudioContext.js
* @author Yotam Mann
* @license http://opensource.org/licenses/MIT MIT License
* @copyright 2016 Yotam Mann
*/
-!function(i,o){s=[],void 0===(r="function"==typeof(n=o)?n.apply(e,s):n)||(t.exports=r)}(0,function(){var t={context:null,_tapListeners:[],_onStarted:[],setContext:function(e){return t.context=e,t},on:function(n){if(Array.isArray(n)||NodeList&&n instanceof NodeList)for(var s=0;s<n.length;s++)t.on(n[s]);else if("string"==typeof n)t.on(document.querySelectorAll(n));else if(n.jquery&&"function"==typeof n.toArray)t.on(n.toArray());else if(Element&&n instanceof Element){var r=new e(n,i);t._tapListeners.push(r)}return t},onStarted:function(e){return t.isStarted()?e():t._onStarted.push(e),t},isStarted:function(){return null!==t.context&&"running"===t.context.state}},e=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)};function i(){if(t.context&&!t.isStarted()){var e=t.context.createOscillator(),i=t.context.createGain();i.gain.value=0,e.connect(i),i.connect(t.context.destination);var n=t.context.currentTime;e.start(n),e.stop(n+.5)}if(t._tapListeners){for(var s=0;s<t._tapListeners.length;s++)t._tapListeners[s].dispose();t._tapListeners=null}if(t._onStarted){for(var r=0;r<t._onStarted.length;r++)t._onStarted[r]();t._onStarted=null}}return e.prototype._moved=function(t){this._dragged=!0},e.prototype._ended=function(t){this._dragged||i(),this._dragged=!1},e.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},t})},function(t,e,i){"use strict";e.__esModule=!0;var n=o(i(107)),s=o(i(109)),r="function"==typeof s.default&&"symbol"==typeof n.default?function(t){return typeof t}:function(t){return t&&"function"==typeof s.default&&t.constructor===s.default&&t!==s.default.prototype?"symbol":typeof t};function o(t){return t&&t.__esModule?t:{default:t}}e.default="function"==typeof s.default&&"symbol"===r(n.default)?function(t){return void 0===t?"undefined":r(t)}:function(t){return t&&"function"==typeof s.default&&t.constructor===s.default&&t!==s.default.prototype?"symbol":void 0===t?"undefined":r(t)}},function(t,e,i){t.exports={default:i(108),__esModule:!0}},function(t,e,i){i(18),i(28),t.exports=i(45).f("iterator")},function(t,e,i){t.exports={default:i(110),__esModule:!0}},function(t,e,i){i(111),i(68),i(118),i(119),t.exports=i(0).Symbol},function(t,e,i){"use strict";var n=i(2),s=i(9),r=i(8),o=i(6),a=i(54),u=i(112).KEY,h=i(14),l=i(39),c=i(26),p=i(25),f=i(1),d=i(45),m=i(46),y=i(113),v=i(114),_=i(115),g=i(4),b=i(10),w=i(36),S=i(21),T=i(55),x=i(116),A=i(117),k=i(3),E=i(16),O=A.f,M=k.f,P=x.f,C=n.Symbol,I=n.JSON,R=I&&I.stringify,F=f("_hidden"),D=f("toPrimitive"),N={}.propertyIsEnumerable,q=l("symbol-registry"),L=l("symbols"),j=l("op-symbols"),B=Object.prototype,z="function"==typeof C,U=n.QObject,V=!U||!U.prototype||!U.prototype.findChild,G=r&&h(function(){return 7!=T(M({},"a",{get:function(){return M(this,"a",{value:7}).a}})).a})?function(t,e,i){var n=O(B,e);n&&delete B[e],M(t,e,i),n&&t!==B&&M(B,e,n)}:M,W=function(t){var e=L[t]=T(C.prototype);return e._k=t,e},H=z&&"symbol"==typeof C.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof C},Y=function(t,e,i){return t===B&&Y(j,e,i),g(t),e=w(e,!0),g(i),s(L,e)?(i.enumerable?(s(t,F)&&t[F][e]&&(t[F][e]=!1),i=T(i,{enumerable:S(0,!1)})):(s(t,F)||M(t,F,S(1,{})),t[F][e]=!0),G(t,e,i)):M(t,e,i)},Q=function(t,e){g(t);for(var i,n=v(e=b(e)),s=0,r=n.length;r>s;)Y(t,i=n[s++],e[i]);return t},X=function(t){var e=N.call(this,t=w(t,!0));return!(this===B&&s(L,t)&&!s(j,t))&&(!(e||!s(this,t)||!s(L,t)||s(this,F)&&this[F][t])||e)},Z=function(t,e){if(t=b(t),e=w(e,!0),t!==B||!s(L,e)||s(j,e)){var i=O(t,e);return!i||!s(L,e)||s(t,F)&&t[F][e]||(i.enumerable=!0),i}},K=function(t){for(var e,i=P(b(t)),n=[],r=0;i.length>r;)s(L,e=i[r++])||e==F||e==u||n.push(e);return n},$=function(t){for(var e,i=t===B,n=P(i?j:b(t)),r=[],o=0;n.length>o;)!s(L,e=n[o++])||i&&!s(B,e)||r.push(L[e]);return r};z||(a((C=function(){if(this instanceof C)throw TypeError("Symbol is not a constructor!");var t=p(arguments.length>0?arguments[0]:void 0),e=function(i){this===B&&e.call(j,i),s(this,F)&&s(this[F],t)&&(this[F][t]=!1),G(this,t,S(1,i))};return r&&V&&G(B,t,{configurable:!0,set:e}),W(t)}).prototype,"toString",function(){return this._k}),A.f=Z,k.f=Y,i(67).f=x.f=K,i(30).f=X,i(43).f=$,r&&!i(24)&&a(B,"propertyIsEnumerable",X,!0),d.f=function(t){return W(f(t))}),o(o.G+o.W+o.F*!z,{Symbol:C});for(var J="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),tt=0;J.length>tt;)f(J[tt++]);for(J=E(f.store),tt=0;J.length>tt;)m(J[tt++]);o(o.S+o.F*!z,"Symbol",{for:function(t){return s(q,t+="")?q[t]:q[t]=C(t)},keyFor:function(t){if(H(t))return y(q,t);throw TypeError(t+" is not a symbol!")},useSetter:function(){V=!0},useSimple:function(){V=!1}}),o(o.S+o.F*!z,"Object",{create:function(t,e){return void 0===e?T(t):Q(T(t),e)},defineProperty:Y,defineProperties:Q,getOwnPropertyDescriptor:Z,getOwnPropertyNames:K,getOwnPropertySymbols:$}),I&&o(o.S+o.F*(!z||h(function(){var t=C();return"[null]"!=R([t])||"{}"!=R({a:t})||"{}"!=R(Object(t))})),"JSON",{stringify:function(t){if(void 0!==t&&!H(t)){for(var e,i,n=[t],s=1;arguments.length>s;)n.push(arguments[s++]);return"function"==typeof(e=n[1])&&(i=e),!i&&_(e)||(e=function(t,e){if(i&&(e=i.call(this,t,e)),!H(e))return e}),n[1]=e,R.apply(I,n)}}}),C.prototype[D]||i(7)(C.prototype,D,C.prototype.valueOf),c(C,"Symbol"),c(Math,"Math",!0),c(n.JSON,"JSON",!0)},function(t,e,i){var n=i(25)("meta"),s=i(20),r=i(9),o=i(3).f,a=0,u=Object.isExtensible||function(){return!0},h=!i(14)(function(){return u(Object.preventExtensions({}))}),l=function(t){o(t,n,{value:{i:"O"+ ++a,w:{}}})},c=t.exports={KEY:n,NEED:!1,fastKey:function(t,e){if(!s(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!r(t,n)){if(!u(t))return"F";if(!e)return"E";l(t)}return t[n].i},getWeak:function(t,e){if(!r(t,n)){if(!u(t))return!0;if(!e)return!1;l(t)}return t[n].w},onFreeze:function(t){return h&&c.NEED&&u(t)&&!r(t,n)&&l(t),t}}},function(t,e,i){var n=i(16),s=i(10);t.exports=function(t,e){for(var i,r=s(t),o=n(r),a=o.length,u=0;a>u;)if(r[i=o[u++]]===e)return i}},function(t,e,i){var n=i(16),s=i(43),r=i(30);t.exports=function(t){var e=n(t),i=s.f;if(i)for(var o,a=i(t),u=r.f,h=0;a.length>h;)u.call(t,o=a[h++])&&e.push(o);return e}},function(t,e,i){var n=i(22);t.exports=Array.isArray||function(t){return"Array"==n(t)}},function(t,e,i){var n=i(10),s=i(67).f,r={}.toString,o="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(t){return o&&"[object Window]"==r.call(t)?function(t){try{return s(t)}catch(t){return o.slice()}}(t):s(n(t))}},function(t,e,i){var n=i(30),s=i(21),r=i(10),o=i(36),a=i(9),u=i(53),h=Object.getOwnPropertyDescriptor;e.f=i(8)?h:function(t,e){if(t=r(t),e=o(e,!0),u)try{return h(t,e)}catch(t){}if(a(t,e))return s(!n.f.call(t,e),t[e])}},function(t,e,i){i(46)("asyncIterator")},function(t,e,i){i(46)("observable")},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.note_values=e.MidiWriter=void 0;var n=c(i(62));e.midi_init=function(){r.default.enable(function(t){if(t)return void console.error("webmidi failed to initialize");if(!r.default.outputs.length)return void console.error("no MIDI output found");if(console.log(r.default.inputs),console.log(r.default.outputs),r.default.outputs.length>1){var e=r.default.outputs.filter(function(t){return t.name.match(/prodipe/i)});e.length}})},e.play_note=m,e.play_midi_note=y,e.play_sequence=function(t,e,i,n){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"all",r=arguments[5],o=e.rows,u=e.min,h=e.max,c=o.length*o[0].length;t>=c&&(t=0);var p=Math.floor(t/o[0].length),f=t%o[0].length,d=o[p][f];(t+=1)>=c&&(t=0);var y=m((0,a.norm)(d,u,h)*l.nx.multiply.value,n,s,r);return[t,[y],[128]]},e.play_interval_sequence=function(t,e,i,n){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"all",r=arguments[5],o=e.rows,u=e.min,h=e.max,c=o.length;t>=c&&(t=0);var p=o[t%c];if(!p)return void(t=0);var f=Math.min.apply(Math,p),d=(0,a.norm)(f,u,h)*l.nx.multiply.value,y=p.map(function(t){var e=d+(0,a.norm)(t-f,i.min,i.max)*l.nx.interval.value;m(e,n,s,r)});return[t+=1,y]},e.export_pattern_as_midi=function(t,e,i,s,r,o,u){var l=e.rows;u=u||l[0].length;var c=void 0,p=void 0,f=void 0,m=void 0,y=0,v=new d.Track;v.setTempo(s),t.pedal&&(m=new d.Track).setTempo(s);for(var _=0,g=u;_<g;_++){var b=o(_,e,i,void 0,"all",!0),w=(0,n.default)(b,4);w[0],c=w[1],p=w[2],f=w[3],c.length||(y+=128);for(var S=0;S<c.length;S++){console.log(_,S,c[S],p[S],y,f);var T={pitch:c[S],duration:"t"+p[S],velocity:50};y&&(T.wait="t"+y),v.addEvent(new d.NoteEvent(T)),y=0}t.pedal&&m.addEvent(new d.NoteEvent({pitch:f,duration:"t128",velocity:25}))}var x=t.pedal?[v,m]:[v],A=new d.Writer(x),k=(0,a.dataURItoBlob)(A.dataUri());(0,h.saveAs)(k,"Recording - "+t.name+".mid")};var s=c(i(29)),r=c(i(121)),o=c(i(64)),a=i(44),u=c(i(66)),h=i(122),l=i(69);function c(t){return t&&t.__esModule?t:{default:t}}var p=void 0,f=!1,d=e.MidiWriter=i(129);e.note_values=[[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]];function m(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=o.default.current().index(t+Math.round(l.nx.offset.value),l.nx.octave.value),c=(0,a.ftom)(h),f=c%1;if(f>.5&&(c+=1,f-=1),f*=2,c=Math.floor(c),(p||n)&&c>127)return 0;var d=s.default.Frequency(Math.floor(c),"midi").toNote(),m=3e4/s.default.Transport.bpm.value*r/128;return n?d:(console.log("defer",r,m),p?(e=e||6e4/s.default.Transport.bpm.value,n||(r?setTimeout(function(){y(d,f,i,e)},r):y(d,f,i,e))):r?setTimeout(function(){u.default.play(h)},m):u.default.play(h),d)}function y(t,e,i,n){p.playNote(t,i,{duration:n}),f&&p.sendPitchBend(e,i)}},function(t,e,i){var n;!function(i){"use strict";function s(){if(s.prototype._singleton)throw new Error("WebMidi is a singleton, it cannot be instantiated directly.");s.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 o(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 a=new s;s.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=[],r=[];this.interface=e,this._resetInterfaceUserHandlers(),this.interface.onstatechange=function(t){s.push(t)};for(var o=e.inputs.values(),a=o.next();a&&!a.done;a=o.next())r.push(a.value.open());for(var u=e.outputs.values(),h=u.next();h&&!h.done;h=u.next())r.push(h.value.open());n=setTimeout(i.bind(this),200),Promise&&Promise.all(r).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.")))},s.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()},s.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},s.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},s.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},s.prototype.toMIDIChannels=function(t){var e;return(e="all"===t||void 0===t?["all"]:Array.isArray(t)?t:[t]).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})},s.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},s.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},s.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},s.prototype.getOctave=function(t){return null!=t&&t>=0&&127>=t?Math.floor(Math.floor(t)/12-1)+Math.floor(a.octaveOffset):void 0},s.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},s.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},s.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=a._semitones[e[1].toUpperCase()],n=12*(parseInt(e[3])+1-Math.floor(a.octaveOffset))+i;if(e[2].toLowerCase().indexOf("b")>-1?n-=e[2].length:e[2].toLowerCase().indexOf("#")>-1&&(n+=e[2].length),0>n||n>127)throw new RangeError("Invalid note name or note outside valid range.");return n},s.prototype._updateInputsAndOutputs=function(){this._updateInputs(),this._updateOutputs()},s.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))},s.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 o(t))}.bind(this))},s.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)})},s.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!==a.MIDI_SYSTEM_MESSAGES[t])this._userHandlers.system[t]||(this._userHandlers.system[t]=[]),this._userHandlers.system[t].push(i);else{if(void 0===a.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!==a.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!==a.MIDI_CHANNEL_MESSAGES[t]){if(e.indexOf("all")>-1){e=[];for(var r=1;16>=r;r++)e.push(r)}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!==a.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!==a.MIDI_CHANNEL_MESSAGES[t]){if(e.indexOf("all")>-1){e=[];for(var r=1;16>=r;r++)e.push(r)}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 r=0;r<s.length;r++)s[r]===i&&s.splice(r,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 a.MIDI_CHANNEL_MESSAGES)a.MIDI_CHANNEL_MESSAGES.hasOwnProperty(t)&&(this._userHandlers.channel[t]={});for(var e in a.MIDI_SYSTEM_MESSAGES)a.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 r={target:this,data:t.data,timestamp:t.timeStamp,channel:s};n===a.MIDI_CHANNEL_MESSAGES.noteoff||n===a.MIDI_CHANNEL_MESSAGES.noteon&&0===i?(r.type="noteoff",r.note={number:e,name:a._notes[e%12],octave:a.getOctave(e)},r.velocity=i/127,r.rawVelocity=i):n===a.MIDI_CHANNEL_MESSAGES.noteon?(r.type="noteon",r.note={number:e,name:a._notes[e%12],octave:a.getOctave(e)},r.velocity=i/127,r.rawVelocity=i):n===a.MIDI_CHANNEL_MESSAGES.keyaftertouch?(r.type="keyaftertouch",r.note={number:e,name:a._notes[e%12],octave:a.getOctave(e)},r.value=i/127):n===a.MIDI_CHANNEL_MESSAGES.controlchange&&e>=0&&119>=e?(r.type="controlchange",r.controller={number:e,name:this.getCcNameByNumber(e)},r.value=i):n===a.MIDI_CHANNEL_MESSAGES.channelmode&&e>=120&&127>=e?(r.type="channelmode",r.controller={number:e,name:this.getChannelModeByNumber(e)},r.value=i):n===a.MIDI_CHANNEL_MESSAGES.programchange?(r.type="programchange",r.value=e):n===a.MIDI_CHANNEL_MESSAGES.channelaftertouch?(r.type="channelaftertouch",r.value=e/127):n===a.MIDI_CHANNEL_MESSAGES.pitchbend?(r.type="pitchbend",r.value=((i<<7)+e-8192)/8192):r.type="unknownchannelmessage",this._userHandlers.channel[r.type]&&this._userHandlers.channel[r.type][s]&&this._userHandlers.channel[r.type][s].forEach(function(t){t(r)})},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 a.MIDI_CONTROL_CHANGE_MESSAGES)if(a.MIDI_CONTROL_CHANGE_MESSAGES.hasOwnProperty(e)&&t===a.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 a.MIDI_CHANNEL_MODE_MESSAGES)if(a.MIDI_CHANNEL_MODE_MESSAGES.hasOwnProperty(e)&&t===a.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===a.MIDI_SYSTEM_MESSAGES.sysex?i.type="sysex":e===a.MIDI_SYSTEM_MESSAGES.timecode?i.type="timecode":e===a.MIDI_SYSTEM_MESSAGES.songposition?i.type="songposition":e===a.MIDI_SYSTEM_MESSAGES.songselect?(i.type="songselect",i.song=t.data[1]):e===a.MIDI_SYSTEM_MESSAGES.tuningrequest?i.type="tuningrequest":e===a.MIDI_SYSTEM_MESSAGES.clock?i.type="clock":e===a.MIDI_SYSTEM_MESSAGES.start?i.type="start":e===a.MIDI_SYSTEM_MESSAGES.continue?i.type="continue":e===a.MIDI_SYSTEM_MESSAGES.stop?i.type="stop":e===a.MIDI_SYSTEM_MESSAGES.activesensing?i.type="activesensing":e===a.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)})},o.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},o.prototype.sendSysex=function(t,e,i){if(!a.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,a.MIDI_SYSTEM_MESSAGES.sysexend),this.send(a.MIDI_SYSTEM_MESSAGES.sysex,e,this._parseTimeParameter(i.time)),this},o.prototype.sendTimecodeQuarterFrame=function(t,e){return e=e||{},this.send(a.MIDI_SYSTEM_MESSAGES.timecode,t,this._parseTimeParameter(e.time)),this},o.prototype.sendSongPosition=function(t,e){t=Math.floor(t)||0,e=e||{};var i=t>>7&127,n=127&t;return this.send(a.MIDI_SYSTEM_MESSAGES.songposition,[i,n],this._parseTimeParameter(e.time)),this},o.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(a.MIDI_SYSTEM_MESSAGES.songselect,[t],this._parseTimeParameter(e.time)),this},o.prototype.sendTuningRequest=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.tuningrequest,void 0,this._parseTimeParameter(t.time)),this},o.prototype.sendClock=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.clock,void 0,this._parseTimeParameter(t.time)),this},o.prototype.sendStart=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.start,void 0,this._parseTimeParameter(t.time)),this},o.prototype.sendContinue=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.continue,void 0,this._parseTimeParameter(t.time)),this},o.prototype.sendStop=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.stop,void 0,this._parseTimeParameter(t.time)),this},o.prototype.sendActiveSensing=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.activesensing,[],this._parseTimeParameter(t.time)),this},o.prototype.sendReset=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.reset,void 0,this._parseTimeParameter(t.time)),this},o.prototype.stopNote=function(t,e,i){if("all"===t)return this.sendChannelMode("allnotesoff",0,e,i);var n=64;return(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){a.toMIDIChannels(e).forEach(function(e){this.send((a.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(e-1),[t,Math.round(n)],this._parseTimeParameter(i.time))}.bind(this))}.bind(this)),this},o.prototype.playNote=function(t,e,i){var n=64;if((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){a.toMIDIChannels(e).forEach(function(e){this.send((a.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){a.toMIDIChannels(e).forEach(function(e){this.send((a.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(e-1),[t,Math.round(s)],(i.time||a.time)+i.duration)}.bind(this))}.bind(this))}return this},o.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 r=Math.round(127*i);return this._convertNoteToArray(t).forEach(function(t){a.toMIDIChannels(e).forEach(function(e){s.send((a.MIDI_CHANNEL_MESSAGES.keyaftertouch<<4)+(e-1),[t,r],s._parseTimeParameter(n.time))})}),this},o.prototype.sendControlChange=function(t,e,i,n){if(n=n||{},"string"==typeof t){if(!(t=a.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 a.toMIDIChannels(i).forEach(function(i){this.send((a.MIDI_CHANNEL_MESSAGES.controlchange<<4)+(i-1),[t,e],this._parseTimeParameter(n.time))}.bind(this)),this},o.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 a.toMIDIChannels(e).forEach(function(s){n.sendControlChange(101,t[0],e,{time:i}),n.sendControlChange(100,t[1],e,{time:i})}),this},o.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 a.toMIDIChannels(e).forEach(function(s){n.sendControlChange(99,t[0],e,{time:i}),n.sendControlChange(98,t[1],e,{time:i})}),this},o.prototype._setCurrentRegisteredParameter=function(t,e,i){var n=this;if((t=[].concat(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 a.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&&a.toMIDIChannels(e).forEach(function(s){n.sendControlChange(38,t[1],e,{time:i})}),this},o.prototype._deselectRegisteredParameter=function(t,e){var i=this;return a.toMIDIChannels(t).forEach(function(n){i.sendControlChange(101,127,t,{time:e}),i.sendControlChange(100,127,t,{time:e})}),this},o.prototype.setRegisteredParameter=function(t,e,i,n){var s=this;if(n=n||{},!Array.isArray(t)){if(!a.MIDI_REGISTERED_PARAMETER[t])throw new Error("The specified parameter is not available.");t=a.MIDI_REGISTERED_PARAMETER[t]}return a.toMIDIChannels(i).forEach(function(r){s._selectRegisteredParameter(t,i,n.time),s._setCurrentRegisteredParameter(e,i,n.time),s._deselectRegisteredParameter(i,n.time)}),this},o.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),a.toMIDIChannels(i).forEach(function(r){s._selectNonRegisteredParameter(t,i,n.time),s._setCurrentRegisteredParameter(e,i,n.time),s._deselectRegisteredParameter(i,n.time)}),this},o.prototype.incrementRegisteredParameter=function(t,e,i){var n=this;if(i=i||{},!Array.isArray(t)){if(!a.MIDI_REGISTERED_PARAMETER[t])throw new Error("The specified parameter is not available.");t=a.MIDI_REGISTERED_PARAMETER[t]}return a.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},o.prototype.decrementRegisteredParameter=function(t,e,i){if(i=i||{},!Array.isArray(t)){if(!a.MIDI_REGISTERED_PARAMETER[t])throw new TypeError("The specified parameter is not available.");t=a.MIDI_REGISTERED_PARAMETER[t]}return a.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},o.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 a.toMIDIChannels(i).forEach(function(r){s.setRegisteredParameter("pitchbendrange",[t,e],i,{time:n.time})}),this},o.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 a.toMIDIChannels(i).forEach(function(r){s.setRegisteredParameter("modulationrange",[t,e],i,{time:n.time})}),this},o.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,r=t-Math.floor(t),o=(r=Math.round((r+1)/2*16383))>>7&127,u=127&r;return a.toMIDIChannels(e).forEach(function(t){n.setRegisteredParameter("channelcoarsetuning",s,e,{time:i.time}),n.setRegisteredParameter("channelfinetuning",[o,u],e,{time:i.time})}),this},o.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 a.toMIDIChannels(e).forEach(function(s){n.setRegisteredParameter("tuningprogram",t,e,{time:i.time})}),this},o.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 a.toMIDIChannels(e).forEach(function(s){n.setRegisteredParameter("tuningbank",t,e,{time:i.time})}),this},o.prototype.sendChannelMode=function(t,e,i,n){if(n=n||{},"string"==typeof t){if(!(t=a.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 a.toMIDIChannels(i).forEach(function(i){this.send((a.MIDI_CHANNEL_MESSAGES.channelmode<<4)+(i-1),[t,e],this._parseTimeParameter(n.time))}.bind(this)),this},o.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 a.toMIDIChannels(e).forEach(function(e){n.send((a.MIDI_CHANNEL_MESSAGES.programchange<<4)+(e-1),[t],n._parseTimeParameter(i.time))}),this},o.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 a.toMIDIChannels(e).forEach(function(t){n.send((a.MIDI_CHANNEL_MESSAGES.channelaftertouch<<4)+(t-1),[s],n._parseTimeParameter(i.time))}),this},o.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),r=s>>7&127,o=127&s;return a.toMIDIChannels(e).forEach(function(t){n.send((a.MIDI_CHANNEL_MESSAGES.pitchbend<<4)+(t-1),[o,r],n._parseTimeParameter(i.time))}),this},o.prototype._parseTimeParameter=function(t){var e,i;return"string"==typeof t&&"+"===t.substring(0,1)?(e=parseFloat(t))&&e>0&&(i=a.time+e):(e=parseFloat(t))>a.time&&(i=e),i},o.prototype._convertNoteToArray=function(t){var e=[];return Array.isArray(t)||(t=[t]),t.forEach(function(t){e.push(a.guessNoteNumber(t))}),e},void 0===(n=function(){return a}.apply(e,[]))||(t.exports=n)}()},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=function(){return t.URL||t.webkitURL||t},i=t.document.createElementNS("http://www.w3.org/1999/xhtml","a"),n="download"in i,s=/constructor/i.test(t.HTMLElement)||t.safari,r=/CriOS\/[\d]+/.test(navigator.userAgent),o=function(e){(t.setImmediate||t.setTimeout)(function(){throw e},0)},a=function(t){setTimeout(function(){"string"==typeof t?e().revokeObjectURL(t):t.remove()},4e4)},u=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},h=function(h,l,c){c||(h=u(h));var p,f=this,d="application/octet-stream"===h.type,m=function(){!function(t,e,i){for(var n=(e=[].concat(e)).length;n--;){var s=t["on"+e[n]];if("function"==typeof s)try{s.call(t,i||t)}catch(t){o(t)}}}(f,"writestart progress write writeend".split(" "))};if(f.readyState=f.INIT,n)return p=e().createObjectURL(h),void setTimeout(function(){i.href=p,i.download=l,function(t){var e=new MouseEvent("click");t.dispatchEvent(e)}(i),m(),a(p),f.readyState=f.DONE});!function(){if((r||d&&s)&&t.FileReader){var i=new FileReader;return i.onloadend=function(){var e=r?i.result:i.result.replace(/^data:[^;]*;/,"data:attachment/file;");t.open(e,"_blank")||(t.location.href=e),e=void 0,f.readyState=f.DONE,m()},i.readAsDataURL(h),void(f.readyState=f.INIT)}p||(p=e().createObjectURL(h)),d?t.location.href=p:t.open(p,"_blank")||(t.location.href=p);f.readyState=f.DONE,m(),a(p)}()},l=h.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(t,e,i){return e=e||t.name||"download",i||(t=u(t)),navigator.msSaveOrOpenBlob(t,e)}:(l.abort=function(){},l.readyState=l.INIT=0,l.WRITING=1,l.DONE=2,l.error=l.onwritestart=l.onprogress=l.onwrite=l.onabort=l.onerror=l.onwriteend=null,function(t,e,i){return new h(t,e||t.name||"download",i)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);
-/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */void 0!==t&&t.exports?t.exports.saveAs=s:null!==i(123)&&null!==i(124)&&(void 0===(n=function(){return s}.call(e,i,e,t))||(t.exports=n))},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,i){t.exports={default:i(126),__esModule:!0}},function(t,e,i){i(127),t.exports=i(0).Object.keys},function(t,e,i){var n=i(27),s=i(16);i(128)("keys",function(){return function(t){return s(n(t))}})},function(t,e,i){var n=i(6),s=i(0),r=i(14);t.exports=function(t,e){var i=(s.Object||{})[t]||Object[t],o={};o[t]=e(i),n(n.S+n.F*r(function(){i(1)}),"Object",o)}},function(t,e,i){"use strict";(function(t,n){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 s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},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}}(),o=i(132);function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var u=function t(e){a(this,t),this.type=e.type,this.data=e.data,this.size=[0,0,0,e.data.length]};e.Chunk=u;var h={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=h;e.ControllerChangeEvent=function t(e){a(this,t),this.type="controller",this.data=m.numberToVariableLength(0).concat(h.CONTROLLER_CHANGE_STATUS,e.controllerNumber,e.controllerValue)};var l=function t(e){a(this,t),this.type="meta",this.data=m.numberToVariableLength(0),this.data=this.data.concat(h.META_EVENT_ID,e.data)};e.MetaEvent=l;var c=function(){function t(e){a(this,t),this.type="note",this.pitch=m.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,i,n=this.getTickDuration(this.duration,"note"),s=this.getTickDuration(this.wait,"rest");if(this.grace){this.grace=m.toArray(this.grace),this.grace.forEach(function(e){var i=new t({pitch:this.grace,duration:"T1"});this.data=this.data.concat(i.data),n-=1},this)}if(Array.isArray(this.pitch)){if(this.sequential)for(r=0;r<this.repeat;r++)this.pitch.forEach(function(t,r){if(r>0&&(s=0),"8t"===this.duration&&r==this.pitch.length-1){var o=m.numberFromBytes(h.HEADER_CHUNK_DIVISION);n=o-2*n}e=new f({data:m.numberToVariableLength(s).concat([this.getNoteOnStatus(),m.getPitch(t),this.velocity])}),i=new p({data:m.numberToVariableLength(n).concat([this.getNoteOffStatus(),m.getPitch(t),this.velocity])}),this.data=this.data.concat(e.data,i.data)},this);else for(var r=0;r<this.repeat;r++)this.pitch.forEach(function(t,i){e=new f(0==i?{data:m.numberToVariableLength(s).concat(this.getNoteOnStatus(),m.getPitch(t),this.velocity)}:{data:[0,m.getPitch(t),this.velocity]}),this.data=this.data.concat(e.data)},this),this.pitch.forEach(function(t,e){i=new p(0==e?{data:m.numberToVariableLength(n).concat(this.getNoteOffStatus(),m.getPitch(t),this.velocity)}:{data:[0,m.getPitch(t),this.velocity]}),this.data=this.data.concat(i.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=t.toString()).toLowerCase().charAt(0))return parseInt(t.substring(1));var i=m.numberFromBytes(h.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=c;var p=function t(e){a(this,t),this.data=e.data};e.NoteOffEvent=p;var f=function t(e){a(this,t),this.data=e.data};e.NoteOnEvent=f;e.ProgramChangeEvent=function t(e){a(this,t),this.type="program",this.data=m.numberToVariableLength(0).concat(h.PROGRAM_CHANGE_STATUS,e.instrument)};var d=function(){function t(){a(this,t),this.type=h.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":s(n))){for(var r in n)switch(r){case"duration":t.duration=n[r];break;case"sequential":t.sequential=n[r];break;case"velocity":t.velocity=t.convertVelocity(n[r])}t.buildData()}}this.data=this.data.concat(t.data),this.size=m.numberToBytes(this.data.length,4),this.events.push(t)},this):(this.data=this.data.concat(t.data),this.size=m.numberToBytes(this.data.length,4),this.events.push(t)),this}},{key:"setTempo",value:function(t){var e=new l({data:[h.META_TEMPO_ID]});e.data.push(3);var i=Math.round(6e7/t);return e.data=e.data.concat(m.numberToBytes(i,3)),this.addEvent(e)}},{key:"setTimeSignature",value:function(t,e,i,n){i=i||24,n=n||8;var s=new l({data:[h.META_TIME_SIGNATURE_ID]});s.data.push(4),s.data=s.data.concat(m.numberToBytes(t,1));var r=Math.log2(e);return s.data=s.data.concat(m.numberToBytes(r,1)),s.data=s.data.concat(m.numberToBytes(i,1)),s.data=s.data.concat(m.numberToBytes(n,1)),this.addEvent(s)}},{key:"setKeySignature",value:function(t,e){var i=new l({data:[h.META_KEY_SIGNATURE_ID]});i.data.push(2);var n=e||0;if(t=t||0,void 0===e){var s=t.length,r=t||"C";if(t[0]===t[0].toLowerCase()&&(n=1),s>1)switch(t.charAt(s-1)){case"m":case"-":n=1,r=(r=t.charAt(0).toLowerCase()).concat(t.substring(1,s-1));break;case"M":case"+":n=0,r=(r=t.charAt(0).toUpperCase()).concat(t.substring(1,s-1))}var o=[["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#"]][n].indexOf(r);t=-1===o?0:o-7}return i.data=i.data.concat(m.numberToBytes(t,1)),i.data=i.data.concat(m.numberToBytes(n,1)),this.addEvent(i)}},{key:"addText",value:function(t){var e=new l({data:[h.META_TEXT_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addCopyright",value:function(t){var e=new l({data:[h.META_COPYRIGHT_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addTrackName",value:function(t){var e=new l({data:[h.META_TRACK_NAME_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addInstrumentName",value:function(t){var e=new l({data:[h.META_INSTRUMENT_NAME_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addMarker",value:function(t){var e=new l({data:[h.META_MARKER_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addCuePoint",value:function(t){var e=new l({data:[h.META_CUE_POINT]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addLyric",value:function(t){var e=new l({data:[h.META_LYRIC_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"polyModeOn",value:function(){var t=new f({data:[0,176,126,0]});return this.addEvent(t)}}]),t}();e.Track=d;var m=function(){function t(){a(this,t)}return r(t,null,[{key:"version",value:function(){return h.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,o.toMidi)(t)}},{key:"numberToVariableLength",value:function(t){for(var e=127&t;t>>=7;)e<<=8,e|=127&t|128;for(var i=[];i.push(255&e),128&e;)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){1==(e=t.toString(16)).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)})).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=m;var y=function(){function t(){a(this,t)}return r(t,[{key:"trackFromVoice",value:function(t){var e,i=new d,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 c({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=y;var v=function(){function e(t){a(this,e),this.data=[];var i=t.length>1?h.HEADER_CHUNK_FORMAT1:h.HEADER_CHUNK_FORMAT0,n=m.numberToBytes(t.length,2);this.data.push(new u({type:h.HEADER_CHUNK_TYPE,data:i.concat(n,h.HEADER_CHUNK_DIVISION)})),t.forEach(function(t,e){t.addEvent(new l({data:h.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=v}).call(e,i(5).Buffer,i(11))},function(t,e,i){"use strict";e.byteLength=function(t){var e=h(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){for(var e,i=h(t),n=i[0],o=i[1],a=new r(function(t,e,i){return 3*(e+i)/4-i}(0,n,o)),u=0,l=o>0?n-4:n,c=0;c<l;c+=4)e=s[t.charCodeAt(c)]<<18|s[t.charCodeAt(c+1)]<<12|s[t.charCodeAt(c+2)]<<6|s[t.charCodeAt(c+3)],a[u++]=e>>16&255,a[u++]=e>>8&255,a[u++]=255&e;2===o&&(e=s[t.charCodeAt(c)]<<2|s[t.charCodeAt(c+1)]>>4,a[u++]=255&e);1===o&&(e=s[t.charCodeAt(c)]<<10|s[t.charCodeAt(c+1)]<<4|s[t.charCodeAt(c+2)]>>2,a[u++]=e>>8&255,a[u++]=255&e);return a},e.fromByteArray=function(t){for(var e,i=t.length,s=i%3,r=[],o=0,a=i-s;o<a;o+=16383)r.push(c(t,o,o+16383>a?a:o+16383));1===s?(e=t[i-1],r.push(n[e>>2]+n[e<<4&63]+"==")):2===s&&(e=(t[i-2]<<8)+t[i-1],r.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return r.join("")};for(var n=[],s=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=o.length;a<u;++a)n[a]=o[a],s[o.charCodeAt(a)]=a;function h(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function l(t){return n[t>>18&63]+n[t>>12&63]+n[t>>6&63]+n[63&t]}function c(t,e,i){for(var n,s=[],r=e;r<i;r+=3)n=(t[r]<<16&16711680)+(t[r+1]<<8&65280)+(255&t[r+2]),s.push(l(n));return s.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,s){var r,o,a=8*s-n-1,u=(1<<a)-1,h=u>>1,l=-7,c=i?s-1:0,p=i?-1:1,f=t[e+c];for(c+=p,r=f&(1<<-l)-1,f>>=-l,l+=a;l>0;r=256*r+t[e+c],c+=p,l-=8);for(o=r&(1<<-l)-1,r>>=-l,l+=n;l>0;o=256*o+t[e+c],c+=p,l-=8);if(0===r)r=1-h;else{if(r===u)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),r-=h}return(f?-1:1)*o*Math.pow(2,r-n)},e.write=function(t,e,i,n,s,r){var o,a,u,h=8*r-s-1,l=(1<<h)-1,c=l>>1,p=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:r-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+c>=1?p/u:p*Math.pow(2,1-c))*u>=2&&(o++,u/=2),o+c>=l?(a=0,o=l):o+c>=1?(a=(e*u-1)*Math.pow(2,s),o+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,s),o=0));s>=8;t[i+f]=255&a,f+=d,a/=256,s-=8);for(o=o<<s|a,h+=s;h>0;t[i+f]=255&o,f+=d,o/=256,h-=8);t[i+f-d]|=128*m}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toMidi=function(t){return Array.isArray(t)&&2===t.length?7*t[0]+12*t[1]+12:Object(n.a)(t)},e.note=function t(e,i){if(!0===e||!1===e)return function(i){return t(i,e)};e=Math.round(e);var n=!0===i?r:s;var o=n[e%12];var a=Math.floor(e/12)-1;return o+a};var n=i(133);var s="C Db D Eb E F Gb G Ab A Bb B".split(" "),r="C C# D D# E F F# G G# A A# B".split(" ")},function(t,e,i){"use strict";function n(t){return"number"==typeof t}function s(t,e){return Math.pow(2,(t-69)/12)*(e||440)}e.a=u;var r=/^([a-gA-G])(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)\s*$/;var o=[0,2,4,5,7,9,11];function a(t,e,i){if("string"!=typeof t)return null;var n=r.exec(t);if(!n||!e&&n[4])return null;var a={letter:n[1].toUpperCase(),acc:n[2].replace(/x/g,"##")};a.pc=a.letter+a.acc,a.step=(a.letter.charCodeAt(0)+3)%7,a.alt="b"===a.acc[0]?-a.acc.length:a.acc.length;var u=o[a.step]+a.alt;return a.chroma=u<0?12+u:u%12,n[3]&&(a.oct=+n[3],a.midi=u+12*(a.oct+1),a.freq=s(a.midi,i)),e&&(a.tonicOf=n[4]),a}function u(t){if((n(t)||function(t){return"string"==typeof t}(t))&&t>=0&&t<128)return+t;var e=a(t);return e&&function(t){return void 0!==t}(e.midi)?e.midi:null}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.load=void 0;var n=function(t){return t&&t.__esModule?t:{default:t}}(i(135));var s=i(145),r=["mass_shootings_from_columbine","gun_violence_by_month","firearms_manufactured","ar_15_2016_18"].map(function(t){return fetch("./data/"+t+".csv").then(function(t){return t.text()}).then(function(t){return new n.default(function(e,i){s(t,{},function(t,i){return e(i)})})}).then(function(e){var i=e.shift();return{name:t,h:i,lines:e.filter(function(t){return!!t})}})}),o=n.default.all(r).then(function(t){return t.reduce(function(t,e){return t[e.name]=e,t},{})});e.load=function(){return o}},function(t,e,i){t.exports={default:i(136),__esModule:!0}},function(t,e,i){i(68),i(18),i(28),i(137),t.exports=i(0).Promise},function(t,e,i){"use strict";var n,s,r,o=i(24),a=i(2),u=i(19),h=i(42),l=i(6),c=i(20),p=i(34),f=i(138),d=i(139),m=i(140),y=i(71).set,v=i(142)(),_=a.TypeError,g=a.process,b=a.Promise,w="process"==h(g=a.process),S=function(){},T=!!function(){try{var t=b.resolve(1),e=(t.constructor={})[i(1)("species")]=function(t){t(S,S)};return(w||"function"==typeof PromiseRejectionEvent)&&t.then(S)instanceof e}catch(t){}}(),x=function(t,e){return t===e||t===b&&e===r},A=function(t){var e;return!(!c(t)||"function"!=typeof(e=t.then))&&e},k=function(t){return x(b,t)?new E(t):new s(t)},E=s=function(t){var e,i;this.promise=new t(function(t,n){if(void 0!==e||void 0!==i)throw _("Bad Promise constructor");e=t,i=n}),this.resolve=p(e),this.reject=p(i)},O=function(t){try{t()}catch(t){return{error:t}}},M=function(t,e){if(!t._n){t._n=!0;var i=t._c;v(function(){for(var n=t._v,s=1==t._s,r=0,o=function(e){var i,r,o=s?e.ok:e.fail,a=e.resolve,u=e.reject,h=e.domain;try{o?(s||(2==t._h&&I(t),t._h=1),!0===o?i=n:(h&&h.enter(),i=o(n),h&&h.exit()),i===e.promise?u(_("Promise-chain cycle")):(r=A(i))?r.call(i,a,u):a(i)):u(n)}catch(t){u(t)}};i.length>r;)o(i[r++]);t._c=[],t._n=!1,e&&!t._h&&P(t)})}},P=function(t){y.call(a,function(){var e,i,n,s=t._v;if(C(t)&&(e=O(function(){w?g.emit("unhandledRejection",s,t):(i=a.onunhandledrejection)?i({promise:t,reason:s}):(n=a.console)&&n.error&&n.error("Unhandled promise rejection",s)}),t._h=w||C(t)?2:1),t._a=void 0,e)throw e.error})},C=function(t){if(1==t._h)return!1;for(var e,i=t._a||t._c,n=0;i.length>n;)if((e=i[n++]).fail||!C(e.promise))return!1;return!0},I=function(t){y.call(a,function(){var e;w?g.emit("rejectionHandled",t):(e=a.onrejectionhandled)&&e({promise:t,reason:t._v})})},R=function(t){var e=this;e._d||(e._d=!0,(e=e._w||e)._v=t,e._s=2,e._a||(e._a=e._c.slice()),M(e,!0))},F=function(t){var e,i=this;if(!i._d){i._d=!0,i=i._w||i;try{if(i===t)throw _("Promise can't be resolved itself");(e=A(t))?v(function(){var n={_w:i,_d:!1};try{e.call(t,u(F,n,1),u(R,n,1))}catch(t){R.call(n,t)}}):(i._v=t,i._s=1,M(i,!1))}catch(t){R.call({_w:i,_d:!1},t)}}};T||(b=function(t){f(this,b,"Promise","_h"),p(t),n.call(this);try{t(u(F,this,1),u(R,this,1))}catch(t){R.call(this,t)}},(n=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=i(143)(b.prototype,{then:function(t,e){var i=k(m(this,b));return i.ok="function"!=typeof t||t,i.fail="function"==typeof e&&e,i.domain=w?g.domain:void 0,this._c.push(i),this._a&&this._a.push(i),this._s&&M(this,!1),i.promise},catch:function(t){return this.then(void 0,t)}}),E=function(){var t=new n;this.promise=t,this.resolve=u(F,t,1),this.reject=u(R,t,1)}),l(l.G+l.W+l.F*!T,{Promise:b}),i(26)(b,"Promise"),i(144)("Promise"),r=i(0).Promise,l(l.S+l.F*!T,"Promise",{reject:function(t){var e=k(this);return(0,e.reject)(t),e.promise}}),l(l.S+l.F*(o||!T),"Promise",{resolve:function(t){if(t instanceof b&&x(t.constructor,this))return t;var e=k(this);return(0,e.resolve)(t),e.promise}}),l(l.S+l.F*!(T&&i(61)(function(t){b.all(t).catch(S)})),"Promise",{all:function(t){var e=this,i=k(e),n=i.resolve,s=i.reject,r=O(function(){var i=[],r=0,o=1;d(t,!1,function(t){var a=r++,u=!1;i.push(void 0),o++,e.resolve(t).then(function(t){u||(u=!0,i[a]=t,--o||n(i))},s)}),--o||n(i)});return r&&s(r.error),i.promise},race:function(t){var e=this,i=k(e),n=i.reject,s=O(function(){d(t,!1,function(t){e.resolve(t).then(i.resolve,n)})});return s&&n(s.error),i.promise}})},function(t,e){t.exports=function(t,e,i,n){if(!(t instanceof e)||void 0!==n&&n in t)throw TypeError(i+": incorrect invocation!");return t}},function(t,e,i){var n=i(19),s=i(59),r=i(60),o=i(4),a=i(37),u=i(41),h={},l={};(e=t.exports=function(t,e,i,c,p){var f,d,m,y,v=p?function(){return t}:u(t),_=n(i,c,e?2:1),g=0;if("function"!=typeof v)throw TypeError(t+" is not iterable!");if(r(v)){for(f=a(t.length);f>g;g++)if((y=e?_(o(d=t[g])[0],d[1]):_(t[g]))===h||y===l)return y}else for(m=v.call(t);!(d=m.next()).done;)if((y=s(m,_,d.value,e))===h||y===l)return y}).BREAK=h,e.RETURN=l},function(t,e,i){var n=i(4),s=i(34),r=i(1)("species");t.exports=function(t,e){var i,o=n(t).constructor;return void 0===o||void 0==(i=n(o)[r])?e:s(i)}},function(t,e){t.exports=function(t,e,i){var n=void 0===i;switch(e.length){case 0:return n?t():t.call(i);case 1:return n?t(e[0]):t.call(i,e[0]);case 2:return n?t(e[0],e[1]):t.call(i,e[0],e[1]);case 3:return n?t(e[0],e[1],e[2]):t.call(i,e[0],e[1],e[2]);case 4:return n?t(e[0],e[1],e[2],e[3]):t.call(i,e[0],e[1],e[2],e[3])}return t.apply(i,e)}},function(t,e,i){var n=i(2),s=i(71).set,r=n.MutationObserver||n.WebKitMutationObserver,o=n.process,a=n.Promise,u="process"==i(22)(o);t.exports=function(){var t,e,i,h=function(){var n,s;for(u&&(n=o.domain)&&n.exit();t;){s=t.fn,t=t.next;try{s()}catch(n){throw t?i():e=void 0,n}}e=void 0,n&&n.enter()};if(u)i=function(){o.nextTick(h)};else if(r){var l=!0,c=document.createTextNode("");new r(h).observe(c,{characterData:!0}),i=function(){c.data=l=!l}}else if(a&&a.resolve){var p=a.resolve();i=function(){p.then(h)}}else i=function(){s.call(n,h)};return function(n){var s={fn:n,next:void 0};e&&(e.next=s),t||(t=s,i()),e=s}}},function(t,e,i){var n=i(7);t.exports=function(t,e,i){for(var s in e)i&&t[s]?t[s]=e[s]:n(t,s,e[s]);return t}},function(t,e,i){"use strict";var n=i(2),s=i(0),r=i(3),o=i(8),a=i(1)("species");t.exports=function(t){var e="function"==typeof s[t]?s[t]:n[t];o&&e&&!e[a]&&r.f(e,a,{configurable:!0,get:function(){return this}})}},function(t,e,i){(function(e,n,s){var r,o,a,u,h;u=i(147),h=i(156),o=i(51).StringDecoder,t.exports=function(){var t,i,s,o,u,h,l;if(3===arguments.length){if(o=arguments[0],h=arguments[1],"function"!=typeof(t=arguments[2]))throw Error(`Invalid callback argument: ${JSON.stringify(t)}`);if("string"!=typeof o&&!e.isBuffer(arguments[0]))return t(Error(`Invalid data argument: ${JSON.stringify(o)}`))}else if(2===arguments.length){if("string"==typeof arguments[0]||e.isBuffer(arguments[0])?o=arguments[0]:a(arguments[0])?h=arguments[0]:u=`Invalid first argument: ${JSON.stringify(arguments[0])}`,"function"==typeof arguments[1]?t=arguments[1]:a(arguments[1])?h?u="Invalid arguments: got options twice as first and second arguments":h=arguments[1]:u=`Invalid first argument: ${JSON.stringify(arguments[1])}`,u){if(t)return t(Error(u));throw Error(u)}}else 1===arguments.length&&("function"==typeof arguments[0]?t=arguments[0]:h=arguments[0]);return null==h&&(h={}),l=new r(h),null!=o&&n.nextTick(function(){return l.write(o),l.end()}),t&&(i=!1,s=h.objname?{}:[],l.on("readable",function(){var t,e;for(e=[];t=l.read();)h.objname?e.push(s[t[0]]=t[1]):e.push(s.push(t));return e}),l.on("error",function(e){return i=!0,t(e)}),l.on("end",function(){if(!i)return t(null,s)})),l},r=function(t={}){var e,i,n,s,r,a,h,l,c,p,f,d,m,y,v,_,g,b,w,S;for(w in this.options={},t)S=t[w],this.options[w]=S;return this.options.objectMode=!0,u.Transform.call(this,this.options),null==(e=this.options).rowDelimiter&&(e.rowDelimiter=null),"string"==typeof this.options.rowDelimiter&&(this.options.rowDelimiter=[this.options.rowDelimiter]),null==(i=this.options).delimiter&&(i.delimiter=","),void 0===this.options.quote||this.options.quote||(this.options.quote=""),null==(f=this.options).quote&&(f.quote='"'),null==(d=this.options).escape&&(d.escape='"'),null==(m=this.options).columns&&(m.columns=null),null==(y=this.options).comment&&(y.comment=""),null==(v=this.options).objname&&(v.objname=!1),null==(_=this.options).trim&&(_.trim=!1),null==(g=this.options).ltrim&&(g.ltrim=!1),null==(b=this.options).rtrim&&(b.rtrim=!1),null!=this.options.auto_parse&&(this.options.cast=this.options.auto_parse),null==(n=this.options).cast&&(n.cast=!1),null!=this.options.auto_parse_date&&(this.options.cast_date=this.options.auto_parse_date),null==(s=this.options).cast_date&&(s.cast_date=!1),!0===this.options.cast_date&&(this.options.cast_date=function(t){var e;return e=Date.parse(t),isNaN(e)||(t=new Date(e)),t}),null==(r=this.options).relax&&(r.relax=!1),null==(a=this.options).relax_column_count&&(a.relax_column_count=!1),null==(h=this.options).skip_empty_lines&&(h.skip_empty_lines=!1),null==(l=this.options).max_limit_on_data_read&&(l.max_limit_on_data_read=128e3),null==(c=this.options).skip_lines_with_empty_values&&(c.skip_lines_with_empty_values=!1),null==(p=this.options).skip_lines_with_error&&(p.skip_lines_with_error=!1),this.lines=0,this.count=0,this.skipped_line_count=0,this.empty_line_count=0,this.is_int=/^(\-|\+)?([1-9]+[0-9]*)$/,this.is_float=function(t){return t-parseFloat(t)+1>=0},this._={decoder:new o,quoting:!1,commenting:!1,field:null,nextChar:null,closingQuote:0,line:[],chunks:[],rawBuf:"",buf:"",rowDelimiterLength:this.options.rowDelimiter?Math.max(...this.options.rowDelimiter.map(function(t){return t.length})):void 0,lineHasError:!1,isEnded:!1},this},h.inherits(r,u.Transform),t.exports.Parser=r,r.prototype._transform=function(t,i,n){return s(()=>{var i;return t instanceof e&&(t=this._.decoder.write(t)),(i=this.__write(t,!1))?this.emit("error",i):n()})},r.prototype._flush=function(t){return t(this.__flush())},r.prototype.__flush=function(){return this.__write(this._.decoder.end(),!0)||(this._.quoting?this.error(`Quoted field not terminated at line ${this.lines+1}`):this._.line.length>0?this.__push(this._.line):void 0)},r.prototype.__push=function(t){var e,i,n,s,r,o,a,u,h;if(!(this._.isEnded||this.options.skip_lines_with_empty_values&&""===t.join("").trim()))if(h=null,!0!==this.options.columns){if("function"==typeof this.options.columns)return e=function(t,e){try{return[null,t.call(null,e)]}catch(t){return[t]}},[n,i]=e(this.options.columns,t),n||void(this.options.columns=i);if(!this._.line_length&&t.length>0&&(this._.line_length=this.options.columns?this.options.columns.length:t.length),1===t.length&&""===t[0])this.empty_line_count++;else if(t.length!==this._.line_length){if(!this.options.relax_column_count)return n=null!=this.options.columns?this.error(`Number of columns on line ${this.lines} does not match header`):this.error(`Number of columns is inconsistent on line ${this.lines}`);this.count++,this.skipped_line_count++}else this.count++;if(null!=this.options.columns){for(u={},r=o=0,a=t.length;o<a;r=++o)s=t[r],!1!==this.options.columns[r]&&(u[this.options.columns[r]]=s);h=this.options.objname?[u[this.options.objname],u]:u}else h=t;if(!(this.count<this.options.from))return this.options.raw?(this.push({raw:this._.rawBuf,row:h}),this._.rawBuf=""):this.push(h),this.listenerCount("record")&&this.emit("record",h),this.count>=this.options.to?(this._.isEnded=!0,this.push(null)):null}else this.options.columns=t},r.prototype.__write=function(t,e){var i,n,s,r,o,a,u,h,l,c,p,f,d,m,y,v,_,g,b,w,S,T,x,A,k,E,O,M,P,C;for(v=(t=>"function"==typeof this.is_int?this.is_int(t):this.is_int.test(t)),y=(t=>"function"==typeof this.is_float?this.is_float(t):this.is_float.test(t)),s=((t,e={})=>this.options.cast?(null==e.quoting&&(e.quoting=!!this._.closingQuote),null==e.lines&&(e.lines=this.lines),null==e.count&&(e.count=this.count),null==e.index&&(e.index=this._.line.length),null==e.header&&(e.header=!0===this.options.columns),null==e.column&&(e.column=Array.isArray(this.options.columns)?this.options.columns[e.index]:e.index),"function"==typeof this.options.cast?this.options.cast(t,e):(v(t)?t=parseInt(t):y(t)?t=parseFloat(t):this.options.cast_date&&(t=this.options.cast_date(t,e)),t)):t),g=this.options.trim||this.options.ltrim,P=this.options.trim||this.options.rtrim,t=this._.buf+t,_=t.length,u=0,0===this.lines&&65279===t.charCodeAt(0)&&u++;u<_&&(e||(O=t.substr(u,_-u),!(!this.options.rowDelimiter&&u+3>_||!this._.commenting&&_-u<this.options.comment.length&&this.options.comment.substr(0,_-u)===O||this.options.rowDelimiter&&_-u<this._.rowDelimiterLength&&this.options.rowDelimiter.some(function(t){return t.substr(0,_-u)===O})||this.options.rowDelimiter&&this._.quoting&&_-u<this.options.quote.length+this._.rowDelimiterLength&&this.options.rowDelimiter.some(t=>(this.options.quote+t).substr(0,_-u)===O)||_-u<=this.options.delimiter.length&&this.options.delimiter.substr(0,_-u)===O||_-u<=this.options.escape.length&&this.options.escape.substr(0,_-u)===O)));)if(r=this._.nextChar?this._.nextChar:t.charAt(u),this._.nextChar=_>u+1?t.charAt(u+1):null,this.options.raw&&(this._.rawBuf+=r),null==this.options.rowDelimiter&&(b=u,M=null,this._.quoting||"\n"!==r&&"\r"!==r?!this._.quoting||r!==this.options.quote||"\n"!==(w=this._.nextChar)&&"\r"!==w||(M=this._.nextChar,b+=2):(M=r,b+=1),M&&("\r"===M&&"\n"===t.charAt(b)&&(M+="\n"),this.options.rowDelimiter=[M],this._.rowDelimiterLength=M.length)),this._.commenting||r!==this.options.escape||(a=this.options.escape===this.options.quote,l=this._.nextChar===this.options.escape,f=this._.nextChar===this.options.quote,a&&!this._.field&&!this._.quoting||!l&&!f)){if(!this._.commenting&&r===this.options.quote){if(this._.acceptOnlyEmptyChars&&" "!==r&&"\t"!==r)return this.error("Only trimable characters are accepted after quotes");if(this._.quoting){if(p=P&&(" "===(S=this._.nextChar)||"\t"===S),n=this.options.rowDelimiter&&this.options.rowDelimiter.some(function(e){return t.substr(u+1,e.length)===e}),i=t.substr(u+1,this.options.delimiter.length)===this.options.delimiter,c=this._.nextChar===this.options.comment,null==this._.nextChar||p||n||i||c){if(null!=this._.nextChar&&p){u++,this._.quoting=!1,this._.closingQuote=this.options.quote.length,this._.acceptOnlyEmptyChars=!0;continue}u++,this._.quoting=!1,this._.closingQuote=this.options.quote.length,e&&u===_&&(this._.line.push(s(this._.field||"")),this._.field=null);continue}if(this.options.relax)this._.quoting=!1,this._.field&&(this._.field=`${this.options.quote}${this._.field}`);else if(o=this.error(`Invalid closing quote at line ${this.lines+1}; found ${JSON.stringify(this._.nextChar)} instead of delimiter ${JSON.stringify(this.options.delimiter)}`))return o}else{if(!this._.field){this._.quoting=!0,u++;continue}if(null!=this._.field&&!this.options.relax&&(o=this.error(`Invalid opening quote at line ${this.lines+1}`)))return o}}if(((d=this.options.rowDelimiter&&this.options.rowDelimiter.some(function(e){return t.substr(u,e.length)===e}))||e&&u===_-1)&&this.lines++,C=!1,this._.commenting||this._.quoting||!this.options.comment||t.substr(u,this.options.comment.length)!==this.options.comment?this._.commenting&&d&&(C=!0,this._.commenting=!1):this._.commenting=!0,h=t.substr(u,this.options.delimiter.length)===this.options.delimiter,this._.acceptOnlyEmptyChars){if(!h&&!d){if(" "===r||"\t"===r){u++;continue}return this.error("Only trimable characters are accepted after quotes")}this._.acceptOnlyEmptyChars=!1}if(this._.commenting||this._.quoting||!h&&!d)this._.commenting||this._.quoting||" "!==r&&"\t"!==r?this._.commenting?u++:(null==this._.field&&(this._.field=""),this._.field+=r,u++):(null==this._.field&&(this._.field=""),g&&!this._.field||(this._.field+=r),u++);else{if(d&&(m=this.options.rowDelimiter.filter(function(e){return t.substr(u,e.length)===e})[0].length),d&&0===this._.line.length&&null==this._.field&&(C||this.options.skip_empty_lines)){u+=m,this._.nextChar=t.charAt(u);continue}if(P&&(this._.closingQuote||(this._.field=null!=(T=this._.field)?T.trimRight():void 0)),this._.line.push(s(this._.field||"")),this._.closingQuote=0,this._.field=null,h&&(u+=this.options.delimiter.length,this._.nextChar=t.charAt(u),e&&!this._.nextChar&&(d=!0,this._.line.push(""))),d){if(!this._.lineHasError&&(o=this.__push(this._.line)))return o;this._.lineHasError&&(this._.lineHasError=!1),this._.line=[],u+=m,this._.nextChar=t.charAt(u);continue}}if(!this._.commenting&&(null!=(x=this._.field)?x.length:void 0)>this.options.max_limit_on_data_read)return Error(`Field exceeds max_limit_on_data_read setting (${this.options.max_limit_on_data_read}) ${JSON.stringify(this.options.delimiter)}`);if(!this._.commenting&&(null!=(A=this._.line)?A.length:void 0)>this.options.max_limit_on_data_read)return Error(`Row delimiter not found in the file ${JSON.stringify(this.options.rowDelimiter)}`)}else u++,r=this._.nextChar,this._.nextChar=t.charAt(u+1),null==this._.field&&(this._.field=""),this._.field+=r,this.options.raw&&(this._.rawBuf+=r),u++;if(e){if(0===_&&this.lines++,null!=this._.field&&(P&&(this._.closingQuote||(this._.field=null!=(k=this._.field)?k.trimRight():void 0)),this._.line.push(s(this._.field||"")),this._.field=null),(null!=(E=this._.field)?E.length:void 0)>this.options.max_limit_on_data_read)return Error(`Delimiter not found in the file ${JSON.stringify(this.options.delimiter)}`);if(this._.line.length>this.options.max_limit_on_data_read)return Error(`Row delimiter not found in the file ${JSON.stringify(this.options.rowDelimiter)}`)}return this._.buf=t.substr(u),null},r.prototype.error=function(t){var e;return e=Error(t),this.options.skip_lines_with_error?(this._.lineHasError||(this._.lineHasError=!0,this.emit("skip",e)),null):e},a=function(t){var e;return e=t,"object"==typeof t&&null!==t&&!Array.isArray(t)&&function(){for(;null!==Object.getPrototypeOf(e=Object.getPrototypeOf(e)););return Object.getPrototypeOf(t===e)}()}}).call(e,i(5).Buffer,i(11),i(72).setImmediate)},function(t,e,i){(function(t,e){!function(t,i){"use strict";if(!t.setImmediate){var n,s=1,r={},o=!1,a=t.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(t);u=u&&u.setTimeout?u:t,"[object process]"==={}.toString.call(t.process)?n=function(t){e.nextTick(function(){l(t)})}:function(){if(t.postMessage&&!t.importScripts){var e=!0,i=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=i,e}}()?function(){var e="setImmediate$"+Math.random()+"$",i=function(i){i.source===t&&"string"==typeof i.data&&0===i.data.indexOf(e)&&l(+i.data.slice(e.length))};t.addEventListener?t.addEventListener("message",i,!1):t.attachEvent("onmessage",i),n=function(i){t.postMessage(e+i,"*")}}():t.MessageChannel?function(){var t=new MessageChannel;t.port1.onmessage=function(t){l(t.data)},n=function(e){t.port2.postMessage(e)}}():a&&"onreadystatechange"in a.createElement("script")?function(){var t=a.documentElement;n=function(e){var i=a.createElement("script");i.onreadystatechange=function(){l(e),i.onreadystatechange=null,t.removeChild(i),i=null},t.appendChild(i)}}():n=function(t){setTimeout(l,0,t)},u.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),i=0;i<e.length;i++)e[i]=arguments[i+1];var o={callback:t,args:e};return r[s]=o,n(s),s++},u.clearImmediate=h}function h(t){delete r[t]}function l(t){if(o)setTimeout(l,0,t);else{var e=r[t];if(e){o=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(i,n)}}(e)}finally{h(t),o=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(e,i(17),i(11))},function(t,e,i){t.exports=s;var n=i(47).EventEmitter;function s(){n.call(this)}i(12)(s,n),s.Readable=i(48),s.Writable=i(152),s.Duplex=i(153),s.Transform=i(154),s.PassThrough=i(155),s.Stream=s,s.prototype.pipe=function(t,e){var i=this;function s(e){t.writable&&!1===t.write(e)&&i.pause&&i.pause()}function r(){i.readable&&i.resume&&i.resume()}i.on("data",s),t.on("drain",r),t._isStdio||e&&!1===e.end||(i.on("end",a),i.on("close",u));var o=!1;function a(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function h(t){if(l(),0===n.listenerCount(this,"error"))throw t}function l(){i.removeListener("data",s),t.removeListener("drain",r),i.removeListener("end",a),i.removeListener("close",u),i.removeListener("error",h),t.removeListener("error",h),i.removeListener("end",l),i.removeListener("close",l),t.removeListener("close",l)}return i.on("error",h),t.on("error",h),i.on("end",l),i.on("close",l),t.on("close",l),t.emit("pipe",i),t}},function(t,e){},function(t,e,i){"use strict";i(5).Buffer;var n=i(31);function s(){this.head=null,this.tail=null,this.length=0}t.exports=s,s.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},s.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},s.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},s.prototype.clear=function(){this.head=this.tail=null,this.length=0},s.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i},s.prototype.concat=function(t){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var e=n.allocUnsafe(t>>>0),i=this.head,s=0;i;)i.data.copy(e,s),s+=i.data.length,i=i.next;return e}},function(t,e,i){(function(e){function i(t){try{if(!e.localStorage)return!1}catch(t){return!1}var i=e.localStorage[t];return null!=i&&"true"===String(i).toLowerCase()}t.exports=function(t,e){if(i("noDeprecation"))return t;var n=!1;return function(){if(!n){if(i("throwDeprecation"))throw new Error(e);i("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(e,i(17))},function(t,e,i){"use strict";t.exports=r;var n=i(75),s=i(23);function r(t){if(!(this instanceof r))return new r(t);n.call(this,t)}s.inherits=i(12),s.inherits(r,n),r.prototype._transform=function(t,e,i){i(null,t)}},function(t,e,i){t.exports=i(50)},function(t,e,i){t.exports=i(13)},function(t,e,i){t.exports=i(48).Transform},function(t,e,i){t.exports=i(48).PassThrough},function(t,e,i){(function(t,n){var s=/%[sdj%]/g;e.format=function(t){if(!v(t)){for(var e=[],i=0;i<arguments.length;i++)e.push(a(arguments[i]));return e.join(" ")}i=1;for(var n=arguments,r=n.length,o=String(t).replace(s,function(t){if("%%"===t)return"%";if(i>=r)return t;switch(t){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch(t){return"[Circular]"}default:return t}}),u=n[i];i<r;u=n[++i])m(u)||!b(u)?o+=" "+u:o+=" "+a(u);return o},e.deprecate=function(i,s){if(_(t.process))return function(){return e.deprecate(i,s).apply(this,arguments)};if(!0===n.noDeprecation)return i;var r=!1;return function(){if(!r){if(n.throwDeprecation)throw new Error(s);n.traceDeprecation?console.trace(s):console.error(s),r=!0}return i.apply(this,arguments)}};var r,o={};function a(t,i){var n={seen:[],stylize:h};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(i)?n.showHidden=i:i&&e._extend(n,i),_(n.showHidden)&&(n.showHidden=!1),_(n.depth)&&(n.depth=2),_(n.colors)&&(n.colors=!1),_(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),l(n,t,n.depth)}function u(t,e){var i=a.styles[e];return i?"["+a.colors[i][0]+"m"+t+"["+a.colors[i][1]+"m":t}function h(t,e){return t}function l(t,i,n){if(t.customInspect&&i&&T(i.inspect)&&i.inspect!==e.inspect&&(!i.constructor||i.constructor.prototype!==i)){var s=i.inspect(n,t);return v(s)||(s=l(t,s,n)),s}var r=function(t,e){if(_(e))return t.stylize("undefined","undefined");if(v(e)){var i="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(i,"string")}if(y(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(m(e))return t.stylize("null","null")}(t,i);if(r)return r;var o=Object.keys(i),a=function(t){var e={};return t.forEach(function(t,i){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(i)),S(i)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return c(i);if(0===o.length){if(T(i)){var u=i.name?": "+i.name:"";return t.stylize("[Function"+u+"]","special")}if(g(i))return t.stylize(RegExp.prototype.toString.call(i),"regexp");if(w(i))return t.stylize(Date.prototype.toString.call(i),"date");if(S(i))return c(i)}var h,b="",x=!1,A=["{","}"];(f(i)&&(x=!0,A=["[","]"]),T(i))&&(b=" [Function"+(i.name?": "+i.name:"")+"]");return g(i)&&(b=" "+RegExp.prototype.toString.call(i)),w(i)&&(b=" "+Date.prototype.toUTCString.call(i)),S(i)&&(b=" "+c(i)),0!==o.length||x&&0!=i.length?n<0?g(i)?t.stylize(RegExp.prototype.toString.call(i),"regexp"):t.stylize("[Object]","special"):(t.seen.push(i),h=x?function(t,e,i,n,s){for(var r=[],o=0,a=e.length;o<a;++o)E(e,String(o))?r.push(p(t,e,i,n,String(o),!0)):r.push("");return s.forEach(function(s){s.match(/^\d+$/)||r.push(p(t,e,i,n,s,!0))}),r}(t,i,n,a,o):o.map(function(e){return p(t,i,n,a,e,x)}),t.seen.pop(),function(t,e,i){if(t.reduce(function(t,e){return 0,e.indexOf("\n")>=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return i[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+i[1];return i[0]+e+" "+t.join(", ")+" "+i[1]}(h,b,A)):A[0]+b+A[1]}function c(t){return"["+Error.prototype.toString.call(t)+"]"}function p(t,e,i,n,s,r){var o,a,u;if((u=Object.getOwnPropertyDescriptor(e,s)||{value:e[s]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),E(n,s)||(o="["+s+"]"),a||(t.seen.indexOf(u.value)<0?(a=m(i)?l(t,u.value,null):l(t,u.value,i-1)).indexOf("\n")>-1&&(a=r?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),_(o)){if(r&&s.match(/^\d+$/))return a;(o=JSON.stringify(""+s)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function f(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function m(t){return null===t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function _(t){return void 0===t}function g(t){return b(t)&&"[object RegExp]"===x(t)}function b(t){return"object"==typeof t&&null!==t}function w(t){return b(t)&&"[object Date]"===x(t)}function S(t){return b(t)&&("[object Error]"===x(t)||t instanceof Error)}function T(t){return"function"==typeof t}function x(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(_(r)&&(r=n.env.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(r)){var i=n.pid;o[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,i,n)}}else o[t]=function(){};return o[t]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=f,e.isBoolean=d,e.isNull=m,e.isNullOrUndefined=function(t){return null==t},e.isNumber=y,e.isString=v,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=_,e.isRegExp=g,e.isObject=b,e.isDate=w,e.isError=S,e.isFunction=T,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=i(157);var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function E(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",function(){var t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":");return[t.getDate(),k[t.getMonth()],e].join(" ")}(),e.format.apply(e,arguments))},e.inherits=i(12),e._extend=function(t,e){if(!e||!b(e))return t;for(var i=Object.keys(e),n=i.length;n--;)t[i[n]]=e[i[n]];return t}}).call(e,i(17),i(11))},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}}]); \ No newline at end of file
+!function(i,o){s=[],void 0===(r="function"==typeof(n=o)?n.apply(e,s):n)||(t.exports=r)}(0,function(){var t={context:null,_tapListeners:[],_onStarted:[],setContext:function(e){return t.context=e,t},on:function(n){if(Array.isArray(n)||NodeList&&n instanceof NodeList)for(var s=0;s<n.length;s++)t.on(n[s]);else if("string"==typeof n)t.on(document.querySelectorAll(n));else if(n.jquery&&"function"==typeof n.toArray)t.on(n.toArray());else if(Element&&n instanceof Element){var r=new e(n,i);t._tapListeners.push(r)}return t},onStarted:function(e){return t.isStarted()?e():t._onStarted.push(e),t},isStarted:function(){return null!==t.context&&"running"===t.context.state}},e=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)};function i(){if(t.context&&!t.isStarted()){var e=t.context.createOscillator(),i=t.context.createGain();i.gain.value=0,e.connect(i),i.connect(t.context.destination);var n=t.context.currentTime;e.start(n),e.stop(n+.5)}if(t._tapListeners){for(var s=0;s<t._tapListeners.length;s++)t._tapListeners[s].dispose();t._tapListeners=null}if(t._onStarted){for(var r=0;r<t._onStarted.length;r++)t._onStarted[r]();t._onStarted=null}}return e.prototype._moved=function(t){this._dragged=!0},e.prototype._ended=function(t){this._dragged||i(),this._dragged=!1},e.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},t})},function(t,e,i){"use strict";e.__esModule=!0;var n=o(i(110)),s=o(i(112)),r="function"==typeof s.default&&"symbol"==typeof n.default?function(t){return typeof t}:function(t){return t&&"function"==typeof s.default&&t.constructor===s.default&&t!==s.default.prototype?"symbol":typeof t};function o(t){return t&&t.__esModule?t:{default:t}}e.default="function"==typeof s.default&&"symbol"===r(n.default)?function(t){return void 0===t?"undefined":r(t)}:function(t){return t&&"function"==typeof s.default&&t.constructor===s.default&&t!==s.default.prototype?"symbol":void 0===t?"undefined":r(t)}},function(t,e,i){t.exports={default:i(111),__esModule:!0}},function(t,e,i){i(18),i(28),t.exports=i(45).f("iterator")},function(t,e,i){t.exports={default:i(113),__esModule:!0}},function(t,e,i){i(114),i(68),i(121),i(122),t.exports=i(0).Symbol},function(t,e,i){"use strict";var n=i(2),s=i(9),r=i(8),o=i(3),a=i(54),u=i(115).KEY,h=i(14),l=i(39),c=i(26),p=i(25),f=i(1),d=i(45),m=i(46),y=i(116),v=i(117),_=i(118),g=i(5),b=i(10),w=i(36),S=i(21),T=i(55),x=i(119),A=i(120),k=i(4),E=i(16),O=A.f,M=k.f,P=x.f,C=n.Symbol,I=n.JSON,R=I&&I.stringify,F=f("_hidden"),N=f("toPrimitive"),D={}.propertyIsEnumerable,q=l("symbol-registry"),L=l("symbols"),j=l("op-symbols"),B=Object.prototype,z="function"==typeof C,U=n.QObject,V=!U||!U.prototype||!U.prototype.findChild,G=r&&h(function(){return 7!=T(M({},"a",{get:function(){return M(this,"a",{value:7}).a}})).a})?function(t,e,i){var n=O(B,e);n&&delete B[e],M(t,e,i),n&&t!==B&&M(B,e,n)}:M,W=function(t){var e=L[t]=T(C.prototype);return e._k=t,e},H=z&&"symbol"==typeof C.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof C},Y=function(t,e,i){return t===B&&Y(j,e,i),g(t),e=w(e,!0),g(i),s(L,e)?(i.enumerable?(s(t,F)&&t[F][e]&&(t[F][e]=!1),i=T(i,{enumerable:S(0,!1)})):(s(t,F)||M(t,F,S(1,{})),t[F][e]=!0),G(t,e,i)):M(t,e,i)},Q=function(t,e){g(t);for(var i,n=v(e=b(e)),s=0,r=n.length;r>s;)Y(t,i=n[s++],e[i]);return t},X=function(t){var e=D.call(this,t=w(t,!0));return!(this===B&&s(L,t)&&!s(j,t))&&(!(e||!s(this,t)||!s(L,t)||s(this,F)&&this[F][t])||e)},Z=function(t,e){if(t=b(t),e=w(e,!0),t!==B||!s(L,e)||s(j,e)){var i=O(t,e);return!i||!s(L,e)||s(t,F)&&t[F][e]||(i.enumerable=!0),i}},$=function(t){for(var e,i=P(b(t)),n=[],r=0;i.length>r;)s(L,e=i[r++])||e==F||e==u||n.push(e);return n},K=function(t){for(var e,i=t===B,n=P(i?j:b(t)),r=[],o=0;n.length>o;)!s(L,e=n[o++])||i&&!s(B,e)||r.push(L[e]);return r};z||(a((C=function(){if(this instanceof C)throw TypeError("Symbol is not a constructor!");var t=p(arguments.length>0?arguments[0]:void 0),e=function(i){this===B&&e.call(j,i),s(this,F)&&s(this[F],t)&&(this[F][t]=!1),G(this,t,S(1,i))};return r&&V&&G(B,t,{configurable:!0,set:e}),W(t)}).prototype,"toString",function(){return this._k}),A.f=Z,k.f=Y,i(67).f=x.f=$,i(30).f=X,i(43).f=K,r&&!i(24)&&a(B,"propertyIsEnumerable",X,!0),d.f=function(t){return W(f(t))}),o(o.G+o.W+o.F*!z,{Symbol:C});for(var J="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),tt=0;J.length>tt;)f(J[tt++]);for(J=E(f.store),tt=0;J.length>tt;)m(J[tt++]);o(o.S+o.F*!z,"Symbol",{for:function(t){return s(q,t+="")?q[t]:q[t]=C(t)},keyFor:function(t){if(H(t))return y(q,t);throw TypeError(t+" is not a symbol!")},useSetter:function(){V=!0},useSimple:function(){V=!1}}),o(o.S+o.F*!z,"Object",{create:function(t,e){return void 0===e?T(t):Q(T(t),e)},defineProperty:Y,defineProperties:Q,getOwnPropertyDescriptor:Z,getOwnPropertyNames:$,getOwnPropertySymbols:K}),I&&o(o.S+o.F*(!z||h(function(){var t=C();return"[null]"!=R([t])||"{}"!=R({a:t})||"{}"!=R(Object(t))})),"JSON",{stringify:function(t){if(void 0!==t&&!H(t)){for(var e,i,n=[t],s=1;arguments.length>s;)n.push(arguments[s++]);return"function"==typeof(e=n[1])&&(i=e),!i&&_(e)||(e=function(t,e){if(i&&(e=i.call(this,t,e)),!H(e))return e}),n[1]=e,R.apply(I,n)}}}),C.prototype[N]||i(7)(C.prototype,N,C.prototype.valueOf),c(C,"Symbol"),c(Math,"Math",!0),c(n.JSON,"JSON",!0)},function(t,e,i){var n=i(25)("meta"),s=i(20),r=i(9),o=i(4).f,a=0,u=Object.isExtensible||function(){return!0},h=!i(14)(function(){return u(Object.preventExtensions({}))}),l=function(t){o(t,n,{value:{i:"O"+ ++a,w:{}}})},c=t.exports={KEY:n,NEED:!1,fastKey:function(t,e){if(!s(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!r(t,n)){if(!u(t))return"F";if(!e)return"E";l(t)}return t[n].i},getWeak:function(t,e){if(!r(t,n)){if(!u(t))return!0;if(!e)return!1;l(t)}return t[n].w},onFreeze:function(t){return h&&c.NEED&&u(t)&&!r(t,n)&&l(t),t}}},function(t,e,i){var n=i(16),s=i(10);t.exports=function(t,e){for(var i,r=s(t),o=n(r),a=o.length,u=0;a>u;)if(r[i=o[u++]]===e)return i}},function(t,e,i){var n=i(16),s=i(43),r=i(30);t.exports=function(t){var e=n(t),i=s.f;if(i)for(var o,a=i(t),u=r.f,h=0;a.length>h;)u.call(t,o=a[h++])&&e.push(o);return e}},function(t,e,i){var n=i(22);t.exports=Array.isArray||function(t){return"Array"==n(t)}},function(t,e,i){var n=i(10),s=i(67).f,r={}.toString,o="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(t){return o&&"[object Window]"==r.call(t)?function(t){try{return s(t)}catch(t){return o.slice()}}(t):s(n(t))}},function(t,e,i){var n=i(30),s=i(21),r=i(10),o=i(36),a=i(9),u=i(53),h=Object.getOwnPropertyDescriptor;e.f=i(8)?h:function(t,e){if(t=r(t),e=o(e,!0),u)try{return h(t,e)}catch(t){}if(a(t,e))return s(!n.f.call(t,e),t[e])}},function(t,e,i){i(46)("asyncIterator")},function(t,e,i){i(46)("observable")},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.note_values=e.MidiWriter=void 0;var n=c(i(62));e.midi_init=function(){r.default.enable(function(t){if(t)return void console.error("webmidi failed to initialize");if(!r.default.outputs.length)return void console.error("no MIDI output found");if(console.log(r.default.inputs),console.log(r.default.outputs),r.default.outputs.length>1){var e=r.default.outputs.filter(function(t){return t.name.match(/prodipe/i)});e.length}})},e.play_note=m,e.play_midi_note=y,e.play_sequence=function(t,e,i,n){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"all",r=arguments[5],o=e.rows,u=e.min,h=e.max,c=o.length*o[0].length;t>=c&&(t=0);var p=Math.floor(t/o[0].length),f=t%o[0].length,d=o[p][f];(t+=1)>=c&&(t=0);var y=m((0,a.norm)(d,u,h)*l.nx.multiply.value,n,s,r);return[t,[y],[128]]},e.play_interval_sequence=function(t,e,i,n){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"all",r=arguments[5],o=e.rows,u=e.min,h=e.max,c=o.length;t>=c&&(t=0);var p=o[t%c];if(!p)return void(t=0);var f=Math.min.apply(Math,p),d=(0,a.norm)(f,u,h)*l.nx.multiply.value,y=p.map(function(t){var e=d+(0,a.norm)(t-f,i.min,i.max)*l.nx.interval.value;m(e,n,s,r)});return[t+=1,y]},e.export_pattern_as_midi=function(t,e,i,s,r,o,u){var l=e.rows;u=u||l[0].length;var c=void 0,p=void 0,f=void 0,m=void 0,y=0,v=new d.Track;v.setTempo(s),t.pedal&&(m=new d.Track).setTempo(s);for(var _=0,g=u;_<g;_++){var b=o(_,e,i,void 0,"all",!0),w=(0,n.default)(b,4);w[0],c=w[1],p=w[2],f=w[3],c.length||(y+=128);for(var S=0;S<c.length;S++){console.log(_,S,c[S],p[S],y,f);var T={pitch:c[S],duration:"t"+p[S],velocity:50};y&&(T.wait="t"+y),v.addEvent(new d.NoteEvent(T)),y=0}t.pedal&&m.addEvent(new d.NoteEvent({pitch:f,duration:"t128",velocity:25}))}var x=t.pedal?[v,m]:[v],A=new d.Writer(x),k=(0,a.dataURItoBlob)(A.dataUri());(0,h.saveAs)(k,"Recording - "+t.name+".mid")};var s=c(i(29)),r=c(i(124)),o=c(i(64)),a=i(44),u=c(i(66)),h=i(125),l=i(69);function c(t){return t&&t.__esModule?t:{default:t}}var p=void 0,f=!1,d=e.MidiWriter=i(132);e.note_values=[[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]];function m(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=o.default.current().index(t+Math.round(l.nx.offset.value),l.nx.octave.value),c=(0,a.ftom)(h),f=c%1;if(f>.5&&(c+=1,f-=1),f*=2,c=Math.floor(c),(p||n)&&c>127)return 0;var d=s.default.Frequency(Math.floor(c),"midi").toNote(),m=3e4/s.default.Transport.bpm.value*r/128;return n?d:(p?(e=e||6e4/s.default.Transport.bpm.value,n||(r?setTimeout(function(){y(d,f,i,e)},r):y(d,f,i,e))):r?setTimeout(function(){u.default.play(h)},m):u.default.play(h),d)}function y(t,e,i,n){p.playNote(t,i,{duration:n}),f&&p.sendPitchBend(e,i)}},function(t,e,i){var n;!function(i){"use strict";function s(){if(s.prototype._singleton)throw new Error("WebMidi is a singleton, it cannot be instantiated directly.");s.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 o(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 a=new s;s.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=[],r=[];this.interface=e,this._resetInterfaceUserHandlers(),this.interface.onstatechange=function(t){s.push(t)};for(var o=e.inputs.values(),a=o.next();a&&!a.done;a=o.next())r.push(a.value.open());for(var u=e.outputs.values(),h=u.next();h&&!h.done;h=u.next())r.push(h.value.open());n=setTimeout(i.bind(this),200),Promise&&Promise.all(r).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.")))},s.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()},s.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},s.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},s.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},s.prototype.toMIDIChannels=function(t){var e;return(e="all"===t||void 0===t?["all"]:Array.isArray(t)?t:[t]).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})},s.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},s.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},s.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},s.prototype.getOctave=function(t){return null!=t&&t>=0&&127>=t?Math.floor(Math.floor(t)/12-1)+Math.floor(a.octaveOffset):void 0},s.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},s.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},s.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=a._semitones[e[1].toUpperCase()],n=12*(parseInt(e[3])+1-Math.floor(a.octaveOffset))+i;if(e[2].toLowerCase().indexOf("b")>-1?n-=e[2].length:e[2].toLowerCase().indexOf("#")>-1&&(n+=e[2].length),0>n||n>127)throw new RangeError("Invalid note name or note outside valid range.");return n},s.prototype._updateInputsAndOutputs=function(){this._updateInputs(),this._updateOutputs()},s.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))},s.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 o(t))}.bind(this))},s.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)})},s.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!==a.MIDI_SYSTEM_MESSAGES[t])this._userHandlers.system[t]||(this._userHandlers.system[t]=[]),this._userHandlers.system[t].push(i);else{if(void 0===a.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!==a.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!==a.MIDI_CHANNEL_MESSAGES[t]){if(e.indexOf("all")>-1){e=[];for(var r=1;16>=r;r++)e.push(r)}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!==a.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!==a.MIDI_CHANNEL_MESSAGES[t]){if(e.indexOf("all")>-1){e=[];for(var r=1;16>=r;r++)e.push(r)}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 r=0;r<s.length;r++)s[r]===i&&s.splice(r,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 a.MIDI_CHANNEL_MESSAGES)a.MIDI_CHANNEL_MESSAGES.hasOwnProperty(t)&&(this._userHandlers.channel[t]={});for(var e in a.MIDI_SYSTEM_MESSAGES)a.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 r={target:this,data:t.data,timestamp:t.timeStamp,channel:s};n===a.MIDI_CHANNEL_MESSAGES.noteoff||n===a.MIDI_CHANNEL_MESSAGES.noteon&&0===i?(r.type="noteoff",r.note={number:e,name:a._notes[e%12],octave:a.getOctave(e)},r.velocity=i/127,r.rawVelocity=i):n===a.MIDI_CHANNEL_MESSAGES.noteon?(r.type="noteon",r.note={number:e,name:a._notes[e%12],octave:a.getOctave(e)},r.velocity=i/127,r.rawVelocity=i):n===a.MIDI_CHANNEL_MESSAGES.keyaftertouch?(r.type="keyaftertouch",r.note={number:e,name:a._notes[e%12],octave:a.getOctave(e)},r.value=i/127):n===a.MIDI_CHANNEL_MESSAGES.controlchange&&e>=0&&119>=e?(r.type="controlchange",r.controller={number:e,name:this.getCcNameByNumber(e)},r.value=i):n===a.MIDI_CHANNEL_MESSAGES.channelmode&&e>=120&&127>=e?(r.type="channelmode",r.controller={number:e,name:this.getChannelModeByNumber(e)},r.value=i):n===a.MIDI_CHANNEL_MESSAGES.programchange?(r.type="programchange",r.value=e):n===a.MIDI_CHANNEL_MESSAGES.channelaftertouch?(r.type="channelaftertouch",r.value=e/127):n===a.MIDI_CHANNEL_MESSAGES.pitchbend?(r.type="pitchbend",r.value=((i<<7)+e-8192)/8192):r.type="unknownchannelmessage",this._userHandlers.channel[r.type]&&this._userHandlers.channel[r.type][s]&&this._userHandlers.channel[r.type][s].forEach(function(t){t(r)})},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 a.MIDI_CONTROL_CHANGE_MESSAGES)if(a.MIDI_CONTROL_CHANGE_MESSAGES.hasOwnProperty(e)&&t===a.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 a.MIDI_CHANNEL_MODE_MESSAGES)if(a.MIDI_CHANNEL_MODE_MESSAGES.hasOwnProperty(e)&&t===a.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===a.MIDI_SYSTEM_MESSAGES.sysex?i.type="sysex":e===a.MIDI_SYSTEM_MESSAGES.timecode?i.type="timecode":e===a.MIDI_SYSTEM_MESSAGES.songposition?i.type="songposition":e===a.MIDI_SYSTEM_MESSAGES.songselect?(i.type="songselect",i.song=t.data[1]):e===a.MIDI_SYSTEM_MESSAGES.tuningrequest?i.type="tuningrequest":e===a.MIDI_SYSTEM_MESSAGES.clock?i.type="clock":e===a.MIDI_SYSTEM_MESSAGES.start?i.type="start":e===a.MIDI_SYSTEM_MESSAGES.continue?i.type="continue":e===a.MIDI_SYSTEM_MESSAGES.stop?i.type="stop":e===a.MIDI_SYSTEM_MESSAGES.activesensing?i.type="activesensing":e===a.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)})},o.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},o.prototype.sendSysex=function(t,e,i){if(!a.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,a.MIDI_SYSTEM_MESSAGES.sysexend),this.send(a.MIDI_SYSTEM_MESSAGES.sysex,e,this._parseTimeParameter(i.time)),this},o.prototype.sendTimecodeQuarterFrame=function(t,e){return e=e||{},this.send(a.MIDI_SYSTEM_MESSAGES.timecode,t,this._parseTimeParameter(e.time)),this},o.prototype.sendSongPosition=function(t,e){t=Math.floor(t)||0,e=e||{};var i=t>>7&127,n=127&t;return this.send(a.MIDI_SYSTEM_MESSAGES.songposition,[i,n],this._parseTimeParameter(e.time)),this},o.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(a.MIDI_SYSTEM_MESSAGES.songselect,[t],this._parseTimeParameter(e.time)),this},o.prototype.sendTuningRequest=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.tuningrequest,void 0,this._parseTimeParameter(t.time)),this},o.prototype.sendClock=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.clock,void 0,this._parseTimeParameter(t.time)),this},o.prototype.sendStart=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.start,void 0,this._parseTimeParameter(t.time)),this},o.prototype.sendContinue=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.continue,void 0,this._parseTimeParameter(t.time)),this},o.prototype.sendStop=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.stop,void 0,this._parseTimeParameter(t.time)),this},o.prototype.sendActiveSensing=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.activesensing,[],this._parseTimeParameter(t.time)),this},o.prototype.sendReset=function(t){return t=t||{},this.send(a.MIDI_SYSTEM_MESSAGES.reset,void 0,this._parseTimeParameter(t.time)),this},o.prototype.stopNote=function(t,e,i){if("all"===t)return this.sendChannelMode("allnotesoff",0,e,i);var n=64;return(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){a.toMIDIChannels(e).forEach(function(e){this.send((a.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(e-1),[t,Math.round(n)],this._parseTimeParameter(i.time))}.bind(this))}.bind(this)),this},o.prototype.playNote=function(t,e,i){var n=64;if((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){a.toMIDIChannels(e).forEach(function(e){this.send((a.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){a.toMIDIChannels(e).forEach(function(e){this.send((a.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(e-1),[t,Math.round(s)],(i.time||a.time)+i.duration)}.bind(this))}.bind(this))}return this},o.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 r=Math.round(127*i);return this._convertNoteToArray(t).forEach(function(t){a.toMIDIChannels(e).forEach(function(e){s.send((a.MIDI_CHANNEL_MESSAGES.keyaftertouch<<4)+(e-1),[t,r],s._parseTimeParameter(n.time))})}),this},o.prototype.sendControlChange=function(t,e,i,n){if(n=n||{},"string"==typeof t){if(!(t=a.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 a.toMIDIChannels(i).forEach(function(i){this.send((a.MIDI_CHANNEL_MESSAGES.controlchange<<4)+(i-1),[t,e],this._parseTimeParameter(n.time))}.bind(this)),this},o.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 a.toMIDIChannels(e).forEach(function(s){n.sendControlChange(101,t[0],e,{time:i}),n.sendControlChange(100,t[1],e,{time:i})}),this},o.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 a.toMIDIChannels(e).forEach(function(s){n.sendControlChange(99,t[0],e,{time:i}),n.sendControlChange(98,t[1],e,{time:i})}),this},o.prototype._setCurrentRegisteredParameter=function(t,e,i){var n=this;if((t=[].concat(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 a.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&&a.toMIDIChannels(e).forEach(function(s){n.sendControlChange(38,t[1],e,{time:i})}),this},o.prototype._deselectRegisteredParameter=function(t,e){var i=this;return a.toMIDIChannels(t).forEach(function(n){i.sendControlChange(101,127,t,{time:e}),i.sendControlChange(100,127,t,{time:e})}),this},o.prototype.setRegisteredParameter=function(t,e,i,n){var s=this;if(n=n||{},!Array.isArray(t)){if(!a.MIDI_REGISTERED_PARAMETER[t])throw new Error("The specified parameter is not available.");t=a.MIDI_REGISTERED_PARAMETER[t]}return a.toMIDIChannels(i).forEach(function(r){s._selectRegisteredParameter(t,i,n.time),s._setCurrentRegisteredParameter(e,i,n.time),s._deselectRegisteredParameter(i,n.time)}),this},o.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),a.toMIDIChannels(i).forEach(function(r){s._selectNonRegisteredParameter(t,i,n.time),s._setCurrentRegisteredParameter(e,i,n.time),s._deselectRegisteredParameter(i,n.time)}),this},o.prototype.incrementRegisteredParameter=function(t,e,i){var n=this;if(i=i||{},!Array.isArray(t)){if(!a.MIDI_REGISTERED_PARAMETER[t])throw new Error("The specified parameter is not available.");t=a.MIDI_REGISTERED_PARAMETER[t]}return a.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},o.prototype.decrementRegisteredParameter=function(t,e,i){if(i=i||{},!Array.isArray(t)){if(!a.MIDI_REGISTERED_PARAMETER[t])throw new TypeError("The specified parameter is not available.");t=a.MIDI_REGISTERED_PARAMETER[t]}return a.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},o.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 a.toMIDIChannels(i).forEach(function(r){s.setRegisteredParameter("pitchbendrange",[t,e],i,{time:n.time})}),this},o.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 a.toMIDIChannels(i).forEach(function(r){s.setRegisteredParameter("modulationrange",[t,e],i,{time:n.time})}),this},o.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,r=t-Math.floor(t),o=(r=Math.round((r+1)/2*16383))>>7&127,u=127&r;return a.toMIDIChannels(e).forEach(function(t){n.setRegisteredParameter("channelcoarsetuning",s,e,{time:i.time}),n.setRegisteredParameter("channelfinetuning",[o,u],e,{time:i.time})}),this},o.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 a.toMIDIChannels(e).forEach(function(s){n.setRegisteredParameter("tuningprogram",t,e,{time:i.time})}),this},o.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 a.toMIDIChannels(e).forEach(function(s){n.setRegisteredParameter("tuningbank",t,e,{time:i.time})}),this},o.prototype.sendChannelMode=function(t,e,i,n){if(n=n||{},"string"==typeof t){if(!(t=a.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 a.toMIDIChannels(i).forEach(function(i){this.send((a.MIDI_CHANNEL_MESSAGES.channelmode<<4)+(i-1),[t,e],this._parseTimeParameter(n.time))}.bind(this)),this},o.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 a.toMIDIChannels(e).forEach(function(e){n.send((a.MIDI_CHANNEL_MESSAGES.programchange<<4)+(e-1),[t],n._parseTimeParameter(i.time))}),this},o.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 a.toMIDIChannels(e).forEach(function(t){n.send((a.MIDI_CHANNEL_MESSAGES.channelaftertouch<<4)+(t-1),[s],n._parseTimeParameter(i.time))}),this},o.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),r=s>>7&127,o=127&s;return a.toMIDIChannels(e).forEach(function(t){n.send((a.MIDI_CHANNEL_MESSAGES.pitchbend<<4)+(t-1),[o,r],n._parseTimeParameter(i.time))}),this},o.prototype._parseTimeParameter=function(t){var e,i;return"string"==typeof t&&"+"===t.substring(0,1)?(e=parseFloat(t))&&e>0&&(i=a.time+e):(e=parseFloat(t))>a.time&&(i=e),i},o.prototype._convertNoteToArray=function(t){var e=[];return Array.isArray(t)||(t=[t]),t.forEach(function(t){e.push(a.guessNoteNumber(t))}),e},void 0===(n=function(){return a}.apply(e,[]))||(t.exports=n)}()},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=function(){return t.URL||t.webkitURL||t},i=t.document.createElementNS("http://www.w3.org/1999/xhtml","a"),n="download"in i,s=/constructor/i.test(t.HTMLElement)||t.safari,r=/CriOS\/[\d]+/.test(navigator.userAgent),o=function(e){(t.setImmediate||t.setTimeout)(function(){throw e},0)},a=function(t){setTimeout(function(){"string"==typeof t?e().revokeObjectURL(t):t.remove()},4e4)},u=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},h=function(h,l,c){c||(h=u(h));var p,f=this,d="application/octet-stream"===h.type,m=function(){!function(t,e,i){for(var n=(e=[].concat(e)).length;n--;){var s=t["on"+e[n]];if("function"==typeof s)try{s.call(t,i||t)}catch(t){o(t)}}}(f,"writestart progress write writeend".split(" "))};if(f.readyState=f.INIT,n)return p=e().createObjectURL(h),void setTimeout(function(){i.href=p,i.download=l,function(t){var e=new MouseEvent("click");t.dispatchEvent(e)}(i),m(),a(p),f.readyState=f.DONE});!function(){if((r||d&&s)&&t.FileReader){var i=new FileReader;return i.onloadend=function(){var e=r?i.result:i.result.replace(/^data:[^;]*;/,"data:attachment/file;");t.open(e,"_blank")||(t.location.href=e),e=void 0,f.readyState=f.DONE,m()},i.readAsDataURL(h),void(f.readyState=f.INIT)}p||(p=e().createObjectURL(h)),d?t.location.href=p:t.open(p,"_blank")||(t.location.href=p);f.readyState=f.DONE,m(),a(p)}()},l=h.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(t,e,i){return e=e||t.name||"download",i||(t=u(t)),navigator.msSaveOrOpenBlob(t,e)}:(l.abort=function(){},l.readyState=l.INIT=0,l.WRITING=1,l.DONE=2,l.error=l.onwritestart=l.onprogress=l.onwrite=l.onabort=l.onerror=l.onwriteend=null,function(t,e,i){return new h(t,e||t.name||"download",i)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);
+/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */void 0!==t&&t.exports?t.exports.saveAs=s:null!==i(126)&&null!==i(127)&&(void 0===(n=function(){return s}.call(e,i,e,t))||(t.exports=n))},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,i){t.exports={default:i(129),__esModule:!0}},function(t,e,i){i(130),t.exports=i(0).Object.keys},function(t,e,i){var n=i(27),s=i(16);i(131)("keys",function(){return function(t){return s(n(t))}})},function(t,e,i){var n=i(3),s=i(0),r=i(14);t.exports=function(t,e){var i=(s.Object||{})[t]||Object[t],o={};o[t]=e(i),n(n.S+n.F*r(function(){i(1)}),"Object",o)}},function(t,e,i){"use strict";(function(t,n){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 s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},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}}(),o=i(135);function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var u=function t(e){a(this,t),this.type=e.type,this.data=e.data,this.size=[0,0,0,e.data.length]};e.Chunk=u;var h={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=h;e.ControllerChangeEvent=function t(e){a(this,t),this.type="controller",this.data=m.numberToVariableLength(0).concat(h.CONTROLLER_CHANGE_STATUS,e.controllerNumber,e.controllerValue)};var l=function t(e){a(this,t),this.type="meta",this.data=m.numberToVariableLength(0),this.data=this.data.concat(h.META_EVENT_ID,e.data)};e.MetaEvent=l;var c=function(){function t(e){a(this,t),this.type="note",this.pitch=m.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,i,n=this.getTickDuration(this.duration,"note"),s=this.getTickDuration(this.wait,"rest");if(this.grace){this.grace=m.toArray(this.grace),this.grace.forEach(function(e){var i=new t({pitch:this.grace,duration:"T1"});this.data=this.data.concat(i.data),n-=1},this)}if(Array.isArray(this.pitch)){if(this.sequential)for(r=0;r<this.repeat;r++)this.pitch.forEach(function(t,r){if(r>0&&(s=0),"8t"===this.duration&&r==this.pitch.length-1){var o=m.numberFromBytes(h.HEADER_CHUNK_DIVISION);n=o-2*n}e=new f({data:m.numberToVariableLength(s).concat([this.getNoteOnStatus(),m.getPitch(t),this.velocity])}),i=new p({data:m.numberToVariableLength(n).concat([this.getNoteOffStatus(),m.getPitch(t),this.velocity])}),this.data=this.data.concat(e.data,i.data)},this);else for(var r=0;r<this.repeat;r++)this.pitch.forEach(function(t,i){e=new f(0==i?{data:m.numberToVariableLength(s).concat(this.getNoteOnStatus(),m.getPitch(t),this.velocity)}:{data:[0,m.getPitch(t),this.velocity]}),this.data=this.data.concat(e.data)},this),this.pitch.forEach(function(t,e){i=new p(0==e?{data:m.numberToVariableLength(n).concat(this.getNoteOffStatus(),m.getPitch(t),this.velocity)}:{data:[0,m.getPitch(t),this.velocity]}),this.data=this.data.concat(i.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=t.toString()).toLowerCase().charAt(0))return parseInt(t.substring(1));var i=m.numberFromBytes(h.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=c;var p=function t(e){a(this,t),this.data=e.data};e.NoteOffEvent=p;var f=function t(e){a(this,t),this.data=e.data};e.NoteOnEvent=f;e.ProgramChangeEvent=function t(e){a(this,t),this.type="program",this.data=m.numberToVariableLength(0).concat(h.PROGRAM_CHANGE_STATUS,e.instrument)};var d=function(){function t(){a(this,t),this.type=h.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":s(n))){for(var r in n)switch(r){case"duration":t.duration=n[r];break;case"sequential":t.sequential=n[r];break;case"velocity":t.velocity=t.convertVelocity(n[r])}t.buildData()}}this.data=this.data.concat(t.data),this.size=m.numberToBytes(this.data.length,4),this.events.push(t)},this):(this.data=this.data.concat(t.data),this.size=m.numberToBytes(this.data.length,4),this.events.push(t)),this}},{key:"setTempo",value:function(t){var e=new l({data:[h.META_TEMPO_ID]});e.data.push(3);var i=Math.round(6e7/t);return e.data=e.data.concat(m.numberToBytes(i,3)),this.addEvent(e)}},{key:"setTimeSignature",value:function(t,e,i,n){i=i||24,n=n||8;var s=new l({data:[h.META_TIME_SIGNATURE_ID]});s.data.push(4),s.data=s.data.concat(m.numberToBytes(t,1));var r=Math.log2(e);return s.data=s.data.concat(m.numberToBytes(r,1)),s.data=s.data.concat(m.numberToBytes(i,1)),s.data=s.data.concat(m.numberToBytes(n,1)),this.addEvent(s)}},{key:"setKeySignature",value:function(t,e){var i=new l({data:[h.META_KEY_SIGNATURE_ID]});i.data.push(2);var n=e||0;if(t=t||0,void 0===e){var s=t.length,r=t||"C";if(t[0]===t[0].toLowerCase()&&(n=1),s>1)switch(t.charAt(s-1)){case"m":case"-":n=1,r=(r=t.charAt(0).toLowerCase()).concat(t.substring(1,s-1));break;case"M":case"+":n=0,r=(r=t.charAt(0).toUpperCase()).concat(t.substring(1,s-1))}var o=[["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#"]][n].indexOf(r);t=-1===o?0:o-7}return i.data=i.data.concat(m.numberToBytes(t,1)),i.data=i.data.concat(m.numberToBytes(n,1)),this.addEvent(i)}},{key:"addText",value:function(t){var e=new l({data:[h.META_TEXT_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addCopyright",value:function(t){var e=new l({data:[h.META_COPYRIGHT_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addTrackName",value:function(t){var e=new l({data:[h.META_TRACK_NAME_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addInstrumentName",value:function(t){var e=new l({data:[h.META_INSTRUMENT_NAME_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addMarker",value:function(t){var e=new l({data:[h.META_MARKER_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addCuePoint",value:function(t){var e=new l({data:[h.META_CUE_POINT]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"addLyric",value:function(t){var e=new l({data:[h.META_LYRIC_ID]}),i=m.stringToBytes(t);return e.data=e.data.concat(m.numberToVariableLength(i.length)),e.data=e.data.concat(i),this.addEvent(e)}},{key:"polyModeOn",value:function(){var t=new f({data:[0,176,126,0]});return this.addEvent(t)}}]),t}();e.Track=d;var m=function(){function t(){a(this,t)}return r(t,null,[{key:"version",value:function(){return h.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,o.toMidi)(t)}},{key:"numberToVariableLength",value:function(t){for(var e=127&t;t>>=7;)e<<=8,e|=127&t|128;for(var i=[];i.push(255&e),128&e;)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){1==(e=t.toString(16)).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)})).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=m;var y=function(){function t(){a(this,t)}return r(t,[{key:"trackFromVoice",value:function(t){var e,i=new d,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 c({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=y;var v=function(){function e(t){a(this,e),this.data=[];var i=t.length>1?h.HEADER_CHUNK_FORMAT1:h.HEADER_CHUNK_FORMAT0,n=m.numberToBytes(t.length,2);this.data.push(new u({type:h.HEADER_CHUNK_TYPE,data:i.concat(n,h.HEADER_CHUNK_DIVISION)})),t.forEach(function(t,e){t.addEvent(new l({data:h.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=v}).call(e,i(6).Buffer,i(11))},function(t,e,i){"use strict";e.byteLength=function(t){var e=h(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){for(var e,i=h(t),n=i[0],o=i[1],a=new r(function(t,e,i){return 3*(e+i)/4-i}(0,n,o)),u=0,l=o>0?n-4:n,c=0;c<l;c+=4)e=s[t.charCodeAt(c)]<<18|s[t.charCodeAt(c+1)]<<12|s[t.charCodeAt(c+2)]<<6|s[t.charCodeAt(c+3)],a[u++]=e>>16&255,a[u++]=e>>8&255,a[u++]=255&e;2===o&&(e=s[t.charCodeAt(c)]<<2|s[t.charCodeAt(c+1)]>>4,a[u++]=255&e);1===o&&(e=s[t.charCodeAt(c)]<<10|s[t.charCodeAt(c+1)]<<4|s[t.charCodeAt(c+2)]>>2,a[u++]=e>>8&255,a[u++]=255&e);return a},e.fromByteArray=function(t){for(var e,i=t.length,s=i%3,r=[],o=0,a=i-s;o<a;o+=16383)r.push(c(t,o,o+16383>a?a:o+16383));1===s?(e=t[i-1],r.push(n[e>>2]+n[e<<4&63]+"==")):2===s&&(e=(t[i-2]<<8)+t[i-1],r.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return r.join("")};for(var n=[],s=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=o.length;a<u;++a)n[a]=o[a],s[o.charCodeAt(a)]=a;function h(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function l(t){return n[t>>18&63]+n[t>>12&63]+n[t>>6&63]+n[63&t]}function c(t,e,i){for(var n,s=[],r=e;r<i;r+=3)n=(t[r]<<16&16711680)+(t[r+1]<<8&65280)+(255&t[r+2]),s.push(l(n));return s.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,s){var r,o,a=8*s-n-1,u=(1<<a)-1,h=u>>1,l=-7,c=i?s-1:0,p=i?-1:1,f=t[e+c];for(c+=p,r=f&(1<<-l)-1,f>>=-l,l+=a;l>0;r=256*r+t[e+c],c+=p,l-=8);for(o=r&(1<<-l)-1,r>>=-l,l+=n;l>0;o=256*o+t[e+c],c+=p,l-=8);if(0===r)r=1-h;else{if(r===u)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),r-=h}return(f?-1:1)*o*Math.pow(2,r-n)},e.write=function(t,e,i,n,s,r){var o,a,u,h=8*r-s-1,l=(1<<h)-1,c=l>>1,p=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:r-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+c>=1?p/u:p*Math.pow(2,1-c))*u>=2&&(o++,u/=2),o+c>=l?(a=0,o=l):o+c>=1?(a=(e*u-1)*Math.pow(2,s),o+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,s),o=0));s>=8;t[i+f]=255&a,f+=d,a/=256,s-=8);for(o=o<<s|a,h+=s;h>0;t[i+f]=255&o,f+=d,o/=256,h-=8);t[i+f-d]|=128*m}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toMidi=function(t){return Array.isArray(t)&&2===t.length?7*t[0]+12*t[1]+12:Object(n.a)(t)},e.note=function t(e,i){if(!0===e||!1===e)return function(i){return t(i,e)};e=Math.round(e);var n=!0===i?r:s;var o=n[e%12];var a=Math.floor(e/12)-1;return o+a};var n=i(136);var s="C Db D Eb E F Gb G Ab A Bb B".split(" "),r="C C# D D# E F F# G G# A A# B".split(" ")},function(t,e,i){"use strict";function n(t){return"number"==typeof t}function s(t,e){return Math.pow(2,(t-69)/12)*(e||440)}e.a=u;var r=/^([a-gA-G])(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)\s*$/;var o=[0,2,4,5,7,9,11];function a(t,e,i){if("string"!=typeof t)return null;var n=r.exec(t);if(!n||!e&&n[4])return null;var a={letter:n[1].toUpperCase(),acc:n[2].replace(/x/g,"##")};a.pc=a.letter+a.acc,a.step=(a.letter.charCodeAt(0)+3)%7,a.alt="b"===a.acc[0]?-a.acc.length:a.acc.length;var u=o[a.step]+a.alt;return a.chroma=u<0?12+u:u%12,n[3]&&(a.oct=+n[3],a.midi=u+12*(a.oct+1),a.freq=s(a.midi,i)),e&&(a.tonicOf=n[4]),a}function u(t){if((n(t)||function(t){return"string"==typeof t}(t))&&t>=0&&t<128)return+t;var e=a(t);return e&&function(t){return void 0!==t}(e.midi)?e.midi:null}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.load=void 0;var n=function(t){return t&&t.__esModule?t:{default:t}}(i(138));var s=i(148),r=["mass_shootings_from_columbine","gun_violence_by_month","firearms_manufactured","ar_15_2016_18","media","school_shootings"].map(function(t){return fetch("./data/"+t+".csv").then(function(t){return t.text()}).then(function(t){return new n.default(function(e,i){s(t,{},function(t,i){return e(i)})})}).then(function(e){var i=e.shift();return{name:t,h:i,lines:e.filter(function(t){return!!t})}})}),o=n.default.all(r).then(function(t){return t.reduce(function(t,e){return t[e.name]=e,t},{})});e.load=function(){return o}},function(t,e,i){t.exports={default:i(139),__esModule:!0}},function(t,e,i){i(68),i(18),i(28),i(140),t.exports=i(0).Promise},function(t,e,i){"use strict";var n,s,r,o=i(24),a=i(2),u=i(19),h=i(42),l=i(3),c=i(20),p=i(34),f=i(141),d=i(142),m=i(143),y=i(71).set,v=i(145)(),_=a.TypeError,g=a.process,b=a.Promise,w="process"==h(g=a.process),S=function(){},T=!!function(){try{var t=b.resolve(1),e=(t.constructor={})[i(1)("species")]=function(t){t(S,S)};return(w||"function"==typeof PromiseRejectionEvent)&&t.then(S)instanceof e}catch(t){}}(),x=function(t,e){return t===e||t===b&&e===r},A=function(t){var e;return!(!c(t)||"function"!=typeof(e=t.then))&&e},k=function(t){return x(b,t)?new E(t):new s(t)},E=s=function(t){var e,i;this.promise=new t(function(t,n){if(void 0!==e||void 0!==i)throw _("Bad Promise constructor");e=t,i=n}),this.resolve=p(e),this.reject=p(i)},O=function(t){try{t()}catch(t){return{error:t}}},M=function(t,e){if(!t._n){t._n=!0;var i=t._c;v(function(){for(var n=t._v,s=1==t._s,r=0,o=function(e){var i,r,o=s?e.ok:e.fail,a=e.resolve,u=e.reject,h=e.domain;try{o?(s||(2==t._h&&I(t),t._h=1),!0===o?i=n:(h&&h.enter(),i=o(n),h&&h.exit()),i===e.promise?u(_("Promise-chain cycle")):(r=A(i))?r.call(i,a,u):a(i)):u(n)}catch(t){u(t)}};i.length>r;)o(i[r++]);t._c=[],t._n=!1,e&&!t._h&&P(t)})}},P=function(t){y.call(a,function(){var e,i,n,s=t._v;if(C(t)&&(e=O(function(){w?g.emit("unhandledRejection",s,t):(i=a.onunhandledrejection)?i({promise:t,reason:s}):(n=a.console)&&n.error&&n.error("Unhandled promise rejection",s)}),t._h=w||C(t)?2:1),t._a=void 0,e)throw e.error})},C=function(t){if(1==t._h)return!1;for(var e,i=t._a||t._c,n=0;i.length>n;)if((e=i[n++]).fail||!C(e.promise))return!1;return!0},I=function(t){y.call(a,function(){var e;w?g.emit("rejectionHandled",t):(e=a.onrejectionhandled)&&e({promise:t,reason:t._v})})},R=function(t){var e=this;e._d||(e._d=!0,(e=e._w||e)._v=t,e._s=2,e._a||(e._a=e._c.slice()),M(e,!0))},F=function(t){var e,i=this;if(!i._d){i._d=!0,i=i._w||i;try{if(i===t)throw _("Promise can't be resolved itself");(e=A(t))?v(function(){var n={_w:i,_d:!1};try{e.call(t,u(F,n,1),u(R,n,1))}catch(t){R.call(n,t)}}):(i._v=t,i._s=1,M(i,!1))}catch(t){R.call({_w:i,_d:!1},t)}}};T||(b=function(t){f(this,b,"Promise","_h"),p(t),n.call(this);try{t(u(F,this,1),u(R,this,1))}catch(t){R.call(this,t)}},(n=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=i(146)(b.prototype,{then:function(t,e){var i=k(m(this,b));return i.ok="function"!=typeof t||t,i.fail="function"==typeof e&&e,i.domain=w?g.domain:void 0,this._c.push(i),this._a&&this._a.push(i),this._s&&M(this,!1),i.promise},catch:function(t){return this.then(void 0,t)}}),E=function(){var t=new n;this.promise=t,this.resolve=u(F,t,1),this.reject=u(R,t,1)}),l(l.G+l.W+l.F*!T,{Promise:b}),i(26)(b,"Promise"),i(147)("Promise"),r=i(0).Promise,l(l.S+l.F*!T,"Promise",{reject:function(t){var e=k(this);return(0,e.reject)(t),e.promise}}),l(l.S+l.F*(o||!T),"Promise",{resolve:function(t){if(t instanceof b&&x(t.constructor,this))return t;var e=k(this);return(0,e.resolve)(t),e.promise}}),l(l.S+l.F*!(T&&i(61)(function(t){b.all(t).catch(S)})),"Promise",{all:function(t){var e=this,i=k(e),n=i.resolve,s=i.reject,r=O(function(){var i=[],r=0,o=1;d(t,!1,function(t){var a=r++,u=!1;i.push(void 0),o++,e.resolve(t).then(function(t){u||(u=!0,i[a]=t,--o||n(i))},s)}),--o||n(i)});return r&&s(r.error),i.promise},race:function(t){var e=this,i=k(e),n=i.reject,s=O(function(){d(t,!1,function(t){e.resolve(t).then(i.resolve,n)})});return s&&n(s.error),i.promise}})},function(t,e){t.exports=function(t,e,i,n){if(!(t instanceof e)||void 0!==n&&n in t)throw TypeError(i+": incorrect invocation!");return t}},function(t,e,i){var n=i(19),s=i(59),r=i(60),o=i(5),a=i(37),u=i(41),h={},l={};(e=t.exports=function(t,e,i,c,p){var f,d,m,y,v=p?function(){return t}:u(t),_=n(i,c,e?2:1),g=0;if("function"!=typeof v)throw TypeError(t+" is not iterable!");if(r(v)){for(f=a(t.length);f>g;g++)if((y=e?_(o(d=t[g])[0],d[1]):_(t[g]))===h||y===l)return y}else for(m=v.call(t);!(d=m.next()).done;)if((y=s(m,_,d.value,e))===h||y===l)return y}).BREAK=h,e.RETURN=l},function(t,e,i){var n=i(5),s=i(34),r=i(1)("species");t.exports=function(t,e){var i,o=n(t).constructor;return void 0===o||void 0==(i=n(o)[r])?e:s(i)}},function(t,e){t.exports=function(t,e,i){var n=void 0===i;switch(e.length){case 0:return n?t():t.call(i);case 1:return n?t(e[0]):t.call(i,e[0]);case 2:return n?t(e[0],e[1]):t.call(i,e[0],e[1]);case 3:return n?t(e[0],e[1],e[2]):t.call(i,e[0],e[1],e[2]);case 4:return n?t(e[0],e[1],e[2],e[3]):t.call(i,e[0],e[1],e[2],e[3])}return t.apply(i,e)}},function(t,e,i){var n=i(2),s=i(71).set,r=n.MutationObserver||n.WebKitMutationObserver,o=n.process,a=n.Promise,u="process"==i(22)(o);t.exports=function(){var t,e,i,h=function(){var n,s;for(u&&(n=o.domain)&&n.exit();t;){s=t.fn,t=t.next;try{s()}catch(n){throw t?i():e=void 0,n}}e=void 0,n&&n.enter()};if(u)i=function(){o.nextTick(h)};else if(r){var l=!0,c=document.createTextNode("");new r(h).observe(c,{characterData:!0}),i=function(){c.data=l=!l}}else if(a&&a.resolve){var p=a.resolve();i=function(){p.then(h)}}else i=function(){s.call(n,h)};return function(n){var s={fn:n,next:void 0};e&&(e.next=s),t||(t=s,i()),e=s}}},function(t,e,i){var n=i(7);t.exports=function(t,e,i){for(var s in e)i&&t[s]?t[s]=e[s]:n(t,s,e[s]);return t}},function(t,e,i){"use strict";var n=i(2),s=i(0),r=i(4),o=i(8),a=i(1)("species");t.exports=function(t){var e="function"==typeof s[t]?s[t]:n[t];o&&e&&!e[a]&&r.f(e,a,{configurable:!0,get:function(){return this}})}},function(t,e,i){(function(e,n,s){var r,o,a,u,h;u=i(150),h=i(159),o=i(51).StringDecoder,t.exports=function(){var t,i,s,o,u,h,l;if(3===arguments.length){if(o=arguments[0],h=arguments[1],"function"!=typeof(t=arguments[2]))throw Error(`Invalid callback argument: ${JSON.stringify(t)}`);if("string"!=typeof o&&!e.isBuffer(arguments[0]))return t(Error(`Invalid data argument: ${JSON.stringify(o)}`))}else if(2===arguments.length){if("string"==typeof arguments[0]||e.isBuffer(arguments[0])?o=arguments[0]:a(arguments[0])?h=arguments[0]:u=`Invalid first argument: ${JSON.stringify(arguments[0])}`,"function"==typeof arguments[1]?t=arguments[1]:a(arguments[1])?h?u="Invalid arguments: got options twice as first and second arguments":h=arguments[1]:u=`Invalid first argument: ${JSON.stringify(arguments[1])}`,u){if(t)return t(Error(u));throw Error(u)}}else 1===arguments.length&&("function"==typeof arguments[0]?t=arguments[0]:h=arguments[0]);return null==h&&(h={}),l=new r(h),null!=o&&n.nextTick(function(){return l.write(o),l.end()}),t&&(i=!1,s=h.objname?{}:[],l.on("readable",function(){var t,e;for(e=[];t=l.read();)h.objname?e.push(s[t[0]]=t[1]):e.push(s.push(t));return e}),l.on("error",function(e){return i=!0,t(e)}),l.on("end",function(){if(!i)return t(null,s)})),l},r=function(t={}){var e,i,n,s,r,a,h,l,c,p,f,d,m,y,v,_,g,b,w,S;for(w in this.options={},t)S=t[w],this.options[w]=S;return this.options.objectMode=!0,u.Transform.call(this,this.options),null==(e=this.options).rowDelimiter&&(e.rowDelimiter=null),"string"==typeof this.options.rowDelimiter&&(this.options.rowDelimiter=[this.options.rowDelimiter]),null==(i=this.options).delimiter&&(i.delimiter=","),void 0===this.options.quote||this.options.quote||(this.options.quote=""),null==(f=this.options).quote&&(f.quote='"'),null==(d=this.options).escape&&(d.escape='"'),null==(m=this.options).columns&&(m.columns=null),null==(y=this.options).comment&&(y.comment=""),null==(v=this.options).objname&&(v.objname=!1),null==(_=this.options).trim&&(_.trim=!1),null==(g=this.options).ltrim&&(g.ltrim=!1),null==(b=this.options).rtrim&&(b.rtrim=!1),null!=this.options.auto_parse&&(this.options.cast=this.options.auto_parse),null==(n=this.options).cast&&(n.cast=!1),null!=this.options.auto_parse_date&&(this.options.cast_date=this.options.auto_parse_date),null==(s=this.options).cast_date&&(s.cast_date=!1),!0===this.options.cast_date&&(this.options.cast_date=function(t){var e;return e=Date.parse(t),isNaN(e)||(t=new Date(e)),t}),null==(r=this.options).relax&&(r.relax=!1),null==(a=this.options).relax_column_count&&(a.relax_column_count=!1),null==(h=this.options).skip_empty_lines&&(h.skip_empty_lines=!1),null==(l=this.options).max_limit_on_data_read&&(l.max_limit_on_data_read=128e3),null==(c=this.options).skip_lines_with_empty_values&&(c.skip_lines_with_empty_values=!1),null==(p=this.options).skip_lines_with_error&&(p.skip_lines_with_error=!1),this.lines=0,this.count=0,this.skipped_line_count=0,this.empty_line_count=0,this.is_int=/^(\-|\+)?([1-9]+[0-9]*)$/,this.is_float=function(t){return t-parseFloat(t)+1>=0},this._={decoder:new o,quoting:!1,commenting:!1,field:null,nextChar:null,closingQuote:0,line:[],chunks:[],rawBuf:"",buf:"",rowDelimiterLength:this.options.rowDelimiter?Math.max(...this.options.rowDelimiter.map(function(t){return t.length})):void 0,lineHasError:!1,isEnded:!1},this},h.inherits(r,u.Transform),t.exports.Parser=r,r.prototype._transform=function(t,i,n){return s(()=>{var i;return t instanceof e&&(t=this._.decoder.write(t)),(i=this.__write(t,!1))?this.emit("error",i):n()})},r.prototype._flush=function(t){return t(this.__flush())},r.prototype.__flush=function(){return this.__write(this._.decoder.end(),!0)||(this._.quoting?this.error(`Quoted field not terminated at line ${this.lines+1}`):this._.line.length>0?this.__push(this._.line):void 0)},r.prototype.__push=function(t){var e,i,n,s,r,o,a,u,h;if(!(this._.isEnded||this.options.skip_lines_with_empty_values&&""===t.join("").trim()))if(h=null,!0!==this.options.columns){if("function"==typeof this.options.columns)return e=function(t,e){try{return[null,t.call(null,e)]}catch(t){return[t]}},[n,i]=e(this.options.columns,t),n||void(this.options.columns=i);if(!this._.line_length&&t.length>0&&(this._.line_length=this.options.columns?this.options.columns.length:t.length),1===t.length&&""===t[0])this.empty_line_count++;else if(t.length!==this._.line_length){if(!this.options.relax_column_count)return n=null!=this.options.columns?this.error(`Number of columns on line ${this.lines} does not match header`):this.error(`Number of columns is inconsistent on line ${this.lines}`);this.count++,this.skipped_line_count++}else this.count++;if(null!=this.options.columns){for(u={},r=o=0,a=t.length;o<a;r=++o)s=t[r],!1!==this.options.columns[r]&&(u[this.options.columns[r]]=s);h=this.options.objname?[u[this.options.objname],u]:u}else h=t;if(!(this.count<this.options.from))return this.options.raw?(this.push({raw:this._.rawBuf,row:h}),this._.rawBuf=""):this.push(h),this.listenerCount("record")&&this.emit("record",h),this.count>=this.options.to?(this._.isEnded=!0,this.push(null)):null}else this.options.columns=t},r.prototype.__write=function(t,e){var i,n,s,r,o,a,u,h,l,c,p,f,d,m,y,v,_,g,b,w,S,T,x,A,k,E,O,M,P,C;for(v=(t=>"function"==typeof this.is_int?this.is_int(t):this.is_int.test(t)),y=(t=>"function"==typeof this.is_float?this.is_float(t):this.is_float.test(t)),s=((t,e={})=>this.options.cast?(null==e.quoting&&(e.quoting=!!this._.closingQuote),null==e.lines&&(e.lines=this.lines),null==e.count&&(e.count=this.count),null==e.index&&(e.index=this._.line.length),null==e.header&&(e.header=!0===this.options.columns),null==e.column&&(e.column=Array.isArray(this.options.columns)?this.options.columns[e.index]:e.index),"function"==typeof this.options.cast?this.options.cast(t,e):(v(t)?t=parseInt(t):y(t)?t=parseFloat(t):this.options.cast_date&&(t=this.options.cast_date(t,e)),t)):t),g=this.options.trim||this.options.ltrim,P=this.options.trim||this.options.rtrim,t=this._.buf+t,_=t.length,u=0,0===this.lines&&65279===t.charCodeAt(0)&&u++;u<_&&(e||(O=t.substr(u,_-u),!(!this.options.rowDelimiter&&u+3>_||!this._.commenting&&_-u<this.options.comment.length&&this.options.comment.substr(0,_-u)===O||this.options.rowDelimiter&&_-u<this._.rowDelimiterLength&&this.options.rowDelimiter.some(function(t){return t.substr(0,_-u)===O})||this.options.rowDelimiter&&this._.quoting&&_-u<this.options.quote.length+this._.rowDelimiterLength&&this.options.rowDelimiter.some(t=>(this.options.quote+t).substr(0,_-u)===O)||_-u<=this.options.delimiter.length&&this.options.delimiter.substr(0,_-u)===O||_-u<=this.options.escape.length&&this.options.escape.substr(0,_-u)===O)));)if(r=this._.nextChar?this._.nextChar:t.charAt(u),this._.nextChar=_>u+1?t.charAt(u+1):null,this.options.raw&&(this._.rawBuf+=r),null==this.options.rowDelimiter&&(b=u,M=null,this._.quoting||"\n"!==r&&"\r"!==r?!this._.quoting||r!==this.options.quote||"\n"!==(w=this._.nextChar)&&"\r"!==w||(M=this._.nextChar,b+=2):(M=r,b+=1),M&&("\r"===M&&"\n"===t.charAt(b)&&(M+="\n"),this.options.rowDelimiter=[M],this._.rowDelimiterLength=M.length)),this._.commenting||r!==this.options.escape||(a=this.options.escape===this.options.quote,l=this._.nextChar===this.options.escape,f=this._.nextChar===this.options.quote,a&&!this._.field&&!this._.quoting||!l&&!f)){if(!this._.commenting&&r===this.options.quote){if(this._.acceptOnlyEmptyChars&&" "!==r&&"\t"!==r)return this.error("Only trimable characters are accepted after quotes");if(this._.quoting){if(p=P&&(" "===(S=this._.nextChar)||"\t"===S),n=this.options.rowDelimiter&&this.options.rowDelimiter.some(function(e){return t.substr(u+1,e.length)===e}),i=t.substr(u+1,this.options.delimiter.length)===this.options.delimiter,c=this._.nextChar===this.options.comment,null==this._.nextChar||p||n||i||c){if(null!=this._.nextChar&&p){u++,this._.quoting=!1,this._.closingQuote=this.options.quote.length,this._.acceptOnlyEmptyChars=!0;continue}u++,this._.quoting=!1,this._.closingQuote=this.options.quote.length,e&&u===_&&(this._.line.push(s(this._.field||"")),this._.field=null);continue}if(this.options.relax)this._.quoting=!1,this._.field&&(this._.field=`${this.options.quote}${this._.field}`);else if(o=this.error(`Invalid closing quote at line ${this.lines+1}; found ${JSON.stringify(this._.nextChar)} instead of delimiter ${JSON.stringify(this.options.delimiter)}`))return o}else{if(!this._.field){this._.quoting=!0,u++;continue}if(null!=this._.field&&!this.options.relax&&(o=this.error(`Invalid opening quote at line ${this.lines+1}`)))return o}}if(((d=this.options.rowDelimiter&&this.options.rowDelimiter.some(function(e){return t.substr(u,e.length)===e}))||e&&u===_-1)&&this.lines++,C=!1,this._.commenting||this._.quoting||!this.options.comment||t.substr(u,this.options.comment.length)!==this.options.comment?this._.commenting&&d&&(C=!0,this._.commenting=!1):this._.commenting=!0,h=t.substr(u,this.options.delimiter.length)===this.options.delimiter,this._.acceptOnlyEmptyChars){if(!h&&!d){if(" "===r||"\t"===r){u++;continue}return this.error("Only trimable characters are accepted after quotes")}this._.acceptOnlyEmptyChars=!1}if(this._.commenting||this._.quoting||!h&&!d)this._.commenting||this._.quoting||" "!==r&&"\t"!==r?this._.commenting?u++:(null==this._.field&&(this._.field=""),this._.field+=r,u++):(null==this._.field&&(this._.field=""),g&&!this._.field||(this._.field+=r),u++);else{if(d&&(m=this.options.rowDelimiter.filter(function(e){return t.substr(u,e.length)===e})[0].length),d&&0===this._.line.length&&null==this._.field&&(C||this.options.skip_empty_lines)){u+=m,this._.nextChar=t.charAt(u);continue}if(P&&(this._.closingQuote||(this._.field=null!=(T=this._.field)?T.trimRight():void 0)),this._.line.push(s(this._.field||"")),this._.closingQuote=0,this._.field=null,h&&(u+=this.options.delimiter.length,this._.nextChar=t.charAt(u),e&&!this._.nextChar&&(d=!0,this._.line.push(""))),d){if(!this._.lineHasError&&(o=this.__push(this._.line)))return o;this._.lineHasError&&(this._.lineHasError=!1),this._.line=[],u+=m,this._.nextChar=t.charAt(u);continue}}if(!this._.commenting&&(null!=(x=this._.field)?x.length:void 0)>this.options.max_limit_on_data_read)return Error(`Field exceeds max_limit_on_data_read setting (${this.options.max_limit_on_data_read}) ${JSON.stringify(this.options.delimiter)}`);if(!this._.commenting&&(null!=(A=this._.line)?A.length:void 0)>this.options.max_limit_on_data_read)return Error(`Row delimiter not found in the file ${JSON.stringify(this.options.rowDelimiter)}`)}else u++,r=this._.nextChar,this._.nextChar=t.charAt(u+1),null==this._.field&&(this._.field=""),this._.field+=r,this.options.raw&&(this._.rawBuf+=r),u++;if(e){if(0===_&&this.lines++,null!=this._.field&&(P&&(this._.closingQuote||(this._.field=null!=(k=this._.field)?k.trimRight():void 0)),this._.line.push(s(this._.field||"")),this._.field=null),(null!=(E=this._.field)?E.length:void 0)>this.options.max_limit_on_data_read)return Error(`Delimiter not found in the file ${JSON.stringify(this.options.delimiter)}`);if(this._.line.length>this.options.max_limit_on_data_read)return Error(`Row delimiter not found in the file ${JSON.stringify(this.options.rowDelimiter)}`)}return this._.buf=t.substr(u),null},r.prototype.error=function(t){var e;return e=Error(t),this.options.skip_lines_with_error?(this._.lineHasError||(this._.lineHasError=!0,this.emit("skip",e)),null):e},a=function(t){var e;return e=t,"object"==typeof t&&null!==t&&!Array.isArray(t)&&function(){for(;null!==Object.getPrototypeOf(e=Object.getPrototypeOf(e)););return Object.getPrototypeOf(t===e)}()}}).call(e,i(6).Buffer,i(11),i(72).setImmediate)},function(t,e,i){(function(t,e){!function(t,i){"use strict";if(!t.setImmediate){var n,s=1,r={},o=!1,a=t.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(t);u=u&&u.setTimeout?u:t,"[object process]"==={}.toString.call(t.process)?n=function(t){e.nextTick(function(){l(t)})}:function(){if(t.postMessage&&!t.importScripts){var e=!0,i=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=i,e}}()?function(){var e="setImmediate$"+Math.random()+"$",i=function(i){i.source===t&&"string"==typeof i.data&&0===i.data.indexOf(e)&&l(+i.data.slice(e.length))};t.addEventListener?t.addEventListener("message",i,!1):t.attachEvent("onmessage",i),n=function(i){t.postMessage(e+i,"*")}}():t.MessageChannel?function(){var t=new MessageChannel;t.port1.onmessage=function(t){l(t.data)},n=function(e){t.port2.postMessage(e)}}():a&&"onreadystatechange"in a.createElement("script")?function(){var t=a.documentElement;n=function(e){var i=a.createElement("script");i.onreadystatechange=function(){l(e),i.onreadystatechange=null,t.removeChild(i),i=null},t.appendChild(i)}}():n=function(t){setTimeout(l,0,t)},u.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),i=0;i<e.length;i++)e[i]=arguments[i+1];var o={callback:t,args:e};return r[s]=o,n(s),s++},u.clearImmediate=h}function h(t){delete r[t]}function l(t){if(o)setTimeout(l,0,t);else{var e=r[t];if(e){o=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(i,n)}}(e)}finally{h(t),o=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(e,i(17),i(11))},function(t,e,i){t.exports=s;var n=i(47).EventEmitter;function s(){n.call(this)}i(12)(s,n),s.Readable=i(48),s.Writable=i(155),s.Duplex=i(156),s.Transform=i(157),s.PassThrough=i(158),s.Stream=s,s.prototype.pipe=function(t,e){var i=this;function s(e){t.writable&&!1===t.write(e)&&i.pause&&i.pause()}function r(){i.readable&&i.resume&&i.resume()}i.on("data",s),t.on("drain",r),t._isStdio||e&&!1===e.end||(i.on("end",a),i.on("close",u));var o=!1;function a(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function h(t){if(l(),0===n.listenerCount(this,"error"))throw t}function l(){i.removeListener("data",s),t.removeListener("drain",r),i.removeListener("end",a),i.removeListener("close",u),i.removeListener("error",h),t.removeListener("error",h),i.removeListener("end",l),i.removeListener("close",l),t.removeListener("close",l)}return i.on("error",h),t.on("error",h),i.on("end",l),i.on("close",l),t.on("close",l),t.emit("pipe",i),t}},function(t,e){},function(t,e,i){"use strict";i(6).Buffer;var n=i(31);function s(){this.head=null,this.tail=null,this.length=0}t.exports=s,s.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},s.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},s.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},s.prototype.clear=function(){this.head=this.tail=null,this.length=0},s.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i},s.prototype.concat=function(t){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var e=n.allocUnsafe(t>>>0),i=this.head,s=0;i;)i.data.copy(e,s),s+=i.data.length,i=i.next;return e}},function(t,e,i){(function(e){function i(t){try{if(!e.localStorage)return!1}catch(t){return!1}var i=e.localStorage[t];return null!=i&&"true"===String(i).toLowerCase()}t.exports=function(t,e){if(i("noDeprecation"))return t;var n=!1;return function(){if(!n){if(i("throwDeprecation"))throw new Error(e);i("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(e,i(17))},function(t,e,i){"use strict";t.exports=r;var n=i(75),s=i(23);function r(t){if(!(this instanceof r))return new r(t);n.call(this,t)}s.inherits=i(12),s.inherits(r,n),r.prototype._transform=function(t,e,i){i(null,t)}},function(t,e,i){t.exports=i(50)},function(t,e,i){t.exports=i(13)},function(t,e,i){t.exports=i(48).Transform},function(t,e,i){t.exports=i(48).PassThrough},function(t,e,i){(function(t,n){var s=/%[sdj%]/g;e.format=function(t){if(!v(t)){for(var e=[],i=0;i<arguments.length;i++)e.push(a(arguments[i]));return e.join(" ")}i=1;for(var n=arguments,r=n.length,o=String(t).replace(s,function(t){if("%%"===t)return"%";if(i>=r)return t;switch(t){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch(t){return"[Circular]"}default:return t}}),u=n[i];i<r;u=n[++i])m(u)||!b(u)?o+=" "+u:o+=" "+a(u);return o},e.deprecate=function(i,s){if(_(t.process))return function(){return e.deprecate(i,s).apply(this,arguments)};if(!0===n.noDeprecation)return i;var r=!1;return function(){if(!r){if(n.throwDeprecation)throw new Error(s);n.traceDeprecation?console.trace(s):console.error(s),r=!0}return i.apply(this,arguments)}};var r,o={};function a(t,i){var n={seen:[],stylize:h};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(i)?n.showHidden=i:i&&e._extend(n,i),_(n.showHidden)&&(n.showHidden=!1),_(n.depth)&&(n.depth=2),_(n.colors)&&(n.colors=!1),_(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),l(n,t,n.depth)}function u(t,e){var i=a.styles[e];return i?"["+a.colors[i][0]+"m"+t+"["+a.colors[i][1]+"m":t}function h(t,e){return t}function l(t,i,n){if(t.customInspect&&i&&T(i.inspect)&&i.inspect!==e.inspect&&(!i.constructor||i.constructor.prototype!==i)){var s=i.inspect(n,t);return v(s)||(s=l(t,s,n)),s}var r=function(t,e){if(_(e))return t.stylize("undefined","undefined");if(v(e)){var i="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(i,"string")}if(y(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(m(e))return t.stylize("null","null")}(t,i);if(r)return r;var o=Object.keys(i),a=function(t){var e={};return t.forEach(function(t,i){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(i)),S(i)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return c(i);if(0===o.length){if(T(i)){var u=i.name?": "+i.name:"";return t.stylize("[Function"+u+"]","special")}if(g(i))return t.stylize(RegExp.prototype.toString.call(i),"regexp");if(w(i))return t.stylize(Date.prototype.toString.call(i),"date");if(S(i))return c(i)}var h,b="",x=!1,A=["{","}"];(f(i)&&(x=!0,A=["[","]"]),T(i))&&(b=" [Function"+(i.name?": "+i.name:"")+"]");return g(i)&&(b=" "+RegExp.prototype.toString.call(i)),w(i)&&(b=" "+Date.prototype.toUTCString.call(i)),S(i)&&(b=" "+c(i)),0!==o.length||x&&0!=i.length?n<0?g(i)?t.stylize(RegExp.prototype.toString.call(i),"regexp"):t.stylize("[Object]","special"):(t.seen.push(i),h=x?function(t,e,i,n,s){for(var r=[],o=0,a=e.length;o<a;++o)E(e,String(o))?r.push(p(t,e,i,n,String(o),!0)):r.push("");return s.forEach(function(s){s.match(/^\d+$/)||r.push(p(t,e,i,n,s,!0))}),r}(t,i,n,a,o):o.map(function(e){return p(t,i,n,a,e,x)}),t.seen.pop(),function(t,e,i){if(t.reduce(function(t,e){return 0,e.indexOf("\n")>=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return i[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+i[1];return i[0]+e+" "+t.join(", ")+" "+i[1]}(h,b,A)):A[0]+b+A[1]}function c(t){return"["+Error.prototype.toString.call(t)+"]"}function p(t,e,i,n,s,r){var o,a,u;if((u=Object.getOwnPropertyDescriptor(e,s)||{value:e[s]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),E(n,s)||(o="["+s+"]"),a||(t.seen.indexOf(u.value)<0?(a=m(i)?l(t,u.value,null):l(t,u.value,i-1)).indexOf("\n")>-1&&(a=r?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),_(o)){if(r&&s.match(/^\d+$/))return a;(o=JSON.stringify(""+s)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function f(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function m(t){return null===t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function _(t){return void 0===t}function g(t){return b(t)&&"[object RegExp]"===x(t)}function b(t){return"object"==typeof t&&null!==t}function w(t){return b(t)&&"[object Date]"===x(t)}function S(t){return b(t)&&("[object Error]"===x(t)||t instanceof Error)}function T(t){return"function"==typeof t}function x(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(_(r)&&(r=n.env.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(r)){var i=n.pid;o[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,i,n)}}else o[t]=function(){};return o[t]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=f,e.isBoolean=d,e.isNull=m,e.isNullOrUndefined=function(t){return null==t},e.isNumber=y,e.isString=v,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=_,e.isRegExp=g,e.isObject=b,e.isDate=w,e.isError=S,e.isFunction=T,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=i(160);var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function E(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",function(){var t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":");return[t.getDate(),k[t.getMonth()],e].join(" ")}(),e.format.apply(e,arguments))},e.inherits=i(12),e._extend=function(t,e){if(!e||!b(e))return t;for(var i=Object.keys(e),n=i.length;n--;)t[i[n]]=e[i[n]];return t}}).call(e,i(17),i(11))},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}}]); \ No newline at end of file