-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsynth.min.js
More file actions
2 lines (2 loc) · 41.2 KB
/
synth.min.js
File metadata and controls
2 lines (2 loc) · 41.2 KB
1
2
!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).synth=t()}(function(){return function n(i,o,a){function s(e,t){if(!o[e]){if(!i[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(u)return u(e,!0);throw(t=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",t}r=o[e]={exports:{}},i[e][0].call(r.exports,function(t){return s(i[e][1][t]||t)},r,r.exports,n,i,o,a)}return o[e].exports}for(var u="function"==typeof require&&require,t=0;t<a.length;t++)s(a[t]);return s}({1:[function(t,e,r){"use strict";r.byteLength=function(t){var t=h(t),e=t[0],t=t[1];return 3*(e+t)/4-t},r.toByteArray=function(t){var e,r,n=h(t),i=n[0],n=n[1],o=new f(function(t,e){return 3*(t+e)/4-e}(i,n)),a=0,s=0<n?i-4:i;for(r=0;r<s;r+=4)e=u[t.charCodeAt(r)]<<18|u[t.charCodeAt(r+1)]<<12|u[t.charCodeAt(r+2)]<<6|u[t.charCodeAt(r+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;2===n&&(e=u[t.charCodeAt(r)]<<2|u[t.charCodeAt(r+1)]>>4,o[a++]=255&e);1===n&&(e=u[t.charCodeAt(r)]<<10|u[t.charCodeAt(r+1)]<<4|u[t.charCodeAt(r+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o<a;o+=16383)i.push(function(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(function(t){return s[t>>18&63]+s[t>>12&63]+s[t>>6&63]+s[63&t]}(n));return i.join("")}(t,o,a<o+16383?a:o+16383));1==n?(e=t[r-1],i.push(s[e>>2]+s[e<<4&63]+"==")):2==n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],u=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i<o;++i)s[i]=n[i],u[n.charCodeAt(i)]=i;function h(t){var e=t.length;if(0<e%4)throw new Error("Invalid string. Length must be a multiple of 4");t=t.indexOf("="),e=(t=-1===t?e:t)===e?0:4-t%4;return[t,e]}u["-".charCodeAt(0)]=62,u["_".charCodeAt(0)]=63},{}],2:[function(M,t,x){!function(t){!function(){"use strict";var U=M("base64-js"),o=M("ieee754"),e=(x.Buffer=l,x.SlowBuffer=function(t){+t!=t&&(t=0);return l.alloc(+t)},x.INSPECT_MAX_BYTES=50,2147483647);function u(t){if(e<t)throw new RangeError('The value "'+t+'" is invalid for option "size"');t=new Uint8Array(t);return t.__proto__=l.prototype,t}function l(t,e,r){if("number"!=typeof t)return n(t,e,r);if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}function n(t,e,r){if("string"==typeof t){var n=t,i=e;if(l.isEncoding(i="string"==typeof i&&""!==i?i:"utf8"))return o=0|c(n,i),a=u(o),a=(n=a.write(n,i))!==o?a.slice(0,n):a;throw new TypeError("Unknown encoding: "+i)}if(ArrayBuffer.isView(t))return f(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(I(t,ArrayBuffer)||t&&I(t.buffer,ArrayBuffer)){var o=t,n=e,a=r;if(n<0||o.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(o.byteLength<n+(a||0))throw new RangeError('"length" is outside of buffer bounds');return(o=void 0===n&&void 0===a?new Uint8Array(o):void 0===a?new Uint8Array(o,n):new Uint8Array(o,n,a)).__proto__=l.prototype,o}if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return l.from(i,e,r);var s=function(t){{var e,r;if(l.isBuffer(t))return e=0|h(t.length),0!==(r=u(e)).length&&t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||O(t.length)?u(0):f(t);if("Buffer"===t.type&&Array.isArray(t.data))return f(t.data)}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return l.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function i(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return i(t),u(t<0?0:0|h(t))}function f(t){for(var e=t.length<0?0:0|h(t.length),r=u(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function h(t){if(e<=t)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+e.toString(16)+" bytes");return 0|t}function c(t,e){if(l.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||I(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=2<arguments.length&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return T(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return B(t).length;default:if(i)return n?-1:T(t).length;e=(""+e).toLowerCase(),i=!0}}function r(t,e,r){var n,i=!1;if((e=void 0===e||e<0?0:e)>this.length)return"";if((r=void 0===r||r>this.length?this.length:r)<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t=t||"utf8";;)switch(t){case"hex":var o=this,a=e,s=r,u=o.length;(!s||s<0||u<s)&&(s=u);for(var f="",h=a=!a||a<0?0:a;h<s;++h)f+=function(t){return t<16?"0"+t.toString(16):t.toString(16)}(o[h]);return f;case"utf8":case"utf-8":return A(this,e,r);case"ascii":var l=this,u=e,c=r,p="";c=Math.min(l.length,c);for(var y=u;y<c;++y)p+=String.fromCharCode(127&l[y]);return p;case"latin1":case"binary":var d=this,a=e,g=r,v="";g=Math.min(d.length,g);for(var b=a;b<g;++b)v+=String.fromCharCode(d[b]);return v;case"base64":return m=this,n=r,0===(w=e)&&n===m.length?U.fromByteArray(m):U.fromByteArray(m.slice(w,n));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":for(var m=e,w=r,k=this.slice(m,w),S="",E=0;E<k.length;E+=2)S+=String.fromCharCode(k[E]+256*k[E+1]);return S;default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function s(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function p(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647<r?r=2147483647:r<-2147483648&&(r=-2147483648),(r=(r=O(r=+r)?i?0:t.length-1:r)<0?t.length+r:r)>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=l.from(e,n)),l.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?(i?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o=1,a=t.length,s=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;a/=o=2,s/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i)for(var f=-1,h=r;h<a;h++)if(u(t,h)===u(e,-1===f?0:h-f)){if(h-(f=-1===f?h:f)+1===s)return f*o}else-1!==f&&(h-=h-f),f=-1;else for(h=r=a<r+s?a-s:r;0<=h;h--){for(var l=!0,c=0;c<s;c++)if(u(t,h+c)!==u(e,c)){l=!1;break}if(l)return h}return-1}function g(t,e,r,n){return C(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function v(t,e,r,n){return C(function(t,e){for(var r,n,i=[],o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i.push(r%256),i.push(n);return i}(e,t.length-r),t,r,n)}function A(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,a,s,u,f=t[i],h=null,l=239<f?4:223<f?3:191<f?2:1;if(i+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(o=t[i+1]))&&127<(u=(31&f)<<6|63&o)&&(h=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&2047<(u=(15&f)<<12|(63&o)<<6|63&a)&&(u<55296||57343<u)&&(h=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&65535<(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)&&u<1114112&&(h=u)}null===h?(h=65533,l=1):65535<h&&(n.push((h-=65536)>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}var c=n,p=c.length;if(p<=b)return String.fromCharCode.apply(String,c);for(var y="",d=0;d<p;)y+=String.fromCharCode.apply(String,c.slice(d,d+=b));return y}x.kMaxLength=e,(l.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&l[Symbol.species]===l&&Object.defineProperty(l,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),l.poolSize=8192,l.from=n,l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,l.alloc=function(t,e,r){return e=e,r=r,i(t=t),!(t<=0)&&void 0!==e?"string"==typeof r?u(t).fill(e,r):u(t).fill(e):u(t)},l.allocUnsafe=a,l.allocUnsafeSlow=a,l.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==l.prototype},l.compare=function(t,e){if(I(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),I(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(t)||!l.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},l.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}},l.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return l.alloc(0);if(void 0===e)for(i=e=0;i<t.length;++i)e+=t[i].length;for(var r=l.allocUnsafe(e),n=0,i=0;i<t.length;++i){var o=t[i];if(I(o,Uint8Array)&&(o=l.from(o)),!l.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,n),n+=o.length}return r},l.byteLength=c,l.prototype._isBuffer=!0,l.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)s(this,e,e+1);return this},l.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)s(this,e,e+3),s(this,e+1,e+2);return this},l.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)s(this,e,e+7),s(this,e+1,e+6),s(this,e+2,e+5),s(this,e+3,e+4);return this},l.prototype.toLocaleString=l.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):r.apply(this,arguments)},l.prototype.equals=function(t){if(l.isBuffer(t))return this===t||0===l.compare(this,t);throw new TypeError("Argument must be a Buffer")},l.prototype.inspect=function(){var t="",e=x.INSPECT_MAX_BYTES,t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim();return this.length>e&&(t+=" ... "),"<Buffer "+t+">"},l.prototype.compare=function(t,e,r,n,i){if(I(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),(e=void 0===e?0:e)<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),h=0;h<s;++h)if(u[h]!==f[h]){o=u[h],a=f[h];break}return o<a?-1:a<o?1:0},l.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},l.prototype.indexOf=function(t,e,r){return p(this,t,e,r,!0)},l.prototype.lastIndexOf=function(t,e,r){return p(this,t,e,r,!1)},l.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||i<r)&&(r=i),0<t.length&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n=n||"utf8";for(var o,a,s,u=!1;;)switch(n){case"hex":var f=this,h=t,l=e,c=r,p=(l=Number(l)||0,f.length-l);(!c||p<(c=Number(c)))&&(c=p),(p=h.length)/2<c&&(c=p/2);for(var y=0;y<c;++y){var d=parseInt(h.substr(2*y,2),16);if(O(d))return y;f[l+y]=d}return y;case"utf8":case"utf-8":return p=e,s=r,C(T(t,(a=this).length-p),a,p,s);case"ascii":return g(this,t,e,r);case"latin1":case"binary":return g(this,t,e,r);case"base64":return a=this,s=e,o=r,C(B(t),a,s,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,t,e,r);default:if(u)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),u=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var b=4096;function d(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(r<t+e)throw new RangeError("Trying to access beyond buffer length")}function m(t,e,r,n,i,o){if(!l.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(i<e||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function w(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function k(t,e,r,n,i){return e=+e,r>>>=0,i||w(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,i){return e=+e,r>>>=0,i||w(t,0,r,8),o.write(t,e,r,n,52,8),r+8}l.prototype.slice=function(t,e){var r=this.length,r=((t=~~t)<0?(t+=r)<0&&(t=0):r<t&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):r<e&&(e=r),e<t&&(e=t),this.subarray(t,e));return r.__proto__=l.prototype,r},l.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},l.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=this[t+--e],i=1;0<e&&(i*=256);)n+=this[t+--e]*i;return n},l.prototype.readUInt8=function(t,e){return t>>>=0,e||d(t,1,this.length),this[t]},l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||d(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||d(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||d(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||d(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return(i*=128)<=n&&(n-=Math.pow(2,8*e)),n},l.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0<n&&(i*=256);)o+=this[t+--n]*i;return(i*=128)<=o&&(o-=Math.pow(2,8*e)),o},l.prototype.readInt8=function(t,e){return t>>>=0,e||d(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||d(t,2,this.length);e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},l.prototype.readInt16BE=function(t,e){t>>>=0,e||d(t,2,this.length);e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||d(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||d(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readFloatLE=function(t,e){return t>>>=0,e||d(t,4,this.length),o.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||d(t,4,this.length),o.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||d(t,8,this.length),o.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||d(t,8,this.length),o.read(this,t,!1,52,8)},l.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||m(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},l.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||m(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},l.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeIntLE=function(t,e,r,n){t=+t,e>>>=0,n||m(this,t,e,r,(n=Math.pow(2,8*r-1))-1,-n);var i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},l.prototype.writeIntBE=function(t,e,r,n){t=+t,e>>>=0,n||m(this,t,e,r,(n=Math.pow(2,8*r-1))-1,-n);var i=r-1,o=1,a=0;for(this[e+i]=255&t;0<=--i&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},l.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,1,127,-128),this[e]=255&(t=t<0?255+t+1:t),e+1},l.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,4,2147483647,-2147483648),this[e]=(t=t<0?4294967295+t+1:t)>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeFloatLE=function(t,e,r){return k(this,t,e,!0,r)},l.prototype.writeFloatBE=function(t,e,r){return k(this,t,e,!1,r)},l.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},l.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},l.prototype.copy=function(t,e,r,n){if(!l.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r=r||0,n||0===n||(n=this.length),e>=t.length&&(e=t.length),(n=0<n&&n<r?r:n)===r)return 0;if(0===t.length||0===this.length)return 0;if((e=e||0)<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length);var i=(n=t.length-e<n-r?t.length-e+r:n)-r;if(this===t&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(e,r,n);else if(this===t&&r<e&&e<n)for(var o=i-1;0<=o;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},l.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var i;1===t.length&&(i=t.charCodeAt(0),"utf8"===n&&i<128||"latin1"===n)&&(t=i)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");var o;if(!(r<=e))if(e>>>=0,r=void 0===r?this.length:r>>>0,"number"==typeof(t=t||0))for(o=e;o<r;++o)this[o]=t;else{var a=l.isBuffer(t)?t:l.from(t,n),s=a.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=a[o%s]}return this};var E=/[^+/0-9A-Za-z-_]/g;function T(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],a=0;a<n;++a){if(55295<(r=t.charCodeAt(a))&&r<57344){if(!i){if(56319<r){-1<(e-=3)&&o.push(239,191,189);continue}if(a+1===n){-1<(e-=3)&&o.push(239,191,189);continue}i=r;continue}if(r<56320){-1<(e-=3)&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&-1<(e-=3)&&o.push(239,191,189);if(i=null,r<128){if(--e<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function B(t){return U.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(E,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function C(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function I(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function O(t){return t!=t}}.call(this)}.call(this,M("buffer").Buffer)},{"base64-js":1,buffer:2,ieee754:3}],3:[function(t,e,r){r.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,f=u>>1,h=-7,l=r?i-1:0,c=r?-1:1,i=t[e+l];for(l+=c,o=i&(1<<-h)-1,i>>=-h,h+=s;0<h;o=256*o+t[e+l],l+=c,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=n;0<h;a=256*a+t[e+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(i?-1:1);a+=Math.pow(2,n),o-=f}return(i?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u=8*o-i-1,f=(1<<u)-1,h=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,c=n?0:o-1,p=n?1:-1,o=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(n=Math.pow(2,-a))<1&&(a--,n*=2),2<=(e+=1<=a+h?l/n:l*Math.pow(2,1-h))*n&&(a++,n/=2),f<=a+h?(s=0,a=f):1<=a+h?(s=(e*n-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));8<=i;t[r+c]=255&s,c+=p,s/=256,i-=8);for(a=a<<i|s,u+=i;0<u;t[r+c]=255&a,c+=p,a/=256,u-=8);t[r+c-p]|=128*o}},{}],4:[function(t,e,r){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==i(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===i(t)?t:String(t)}(n.key),n)}}var n=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.data=new Uint8Array(t),this.byteOffset=0,this.lastEventTypeByte=0}var t,r,n;return t=e,(r=[{key:"readString",value:function(t){for(var e=this.byteOffset,r="",n=0;n<t;n++)r+=String.fromCharCode(this.data[e+n]);return this.byteOffset+=t,r}},{key:"readUint32",value:function(){var t=this.byteOffset,t=this.data[t]<<24|this.data[t+1]<<16|this.data[t+2]<<8|this.data[t+3];return this.byteOffset+=4,t}},{key:"readUint24",value:function(){var t=this.byteOffset,t=this.data[t]<<16|this.data[t+1]<<8|this.data[t+2];return this.byteOffset+=3,t}},{key:"readUint16",value:function(){var t=this.byteOffset,t=this.data[t]<<8|this.data[t+1];return this.byteOffset+=2,t}},{key:"readUint8",value:function(){var t=this.byteOffset,t=this.data[t];return this.byteOffset+=1,t}},{key:"readInt8",value:function(){var t=this.byteOffset,t=this.data[t];return 128==(128&t)&&(t^=4294967040),this.byteOffset+=1,t}},{key:"readVarUint",value:function(){for(var t,e=0;e=(e<<7)+(127&(t=this.readUint8())),128==(128&t););return e}},{key:"skip",value:function(t){this.byteOffset+=t}},{key:"readChunk",value:function(){var t=this.readString(4),e=this.readUint32(),r=this.byteOffset;return this.byteOffset+=e,{id:t,length:e,data:this.data.slice(r,this.byteOffset).buffer}}},{key:"readEvent",value:function(){var t={},e=(t.delta=this.readVarUint(),this.readUint8());if(240==(240&e))switch(e){case 255:var r,n=t,i=(n.type="meta",this.readUint8()),o=this.readVarUint();switch(i){case 0:n.subType="sequenceNumber",2===o?t.value=this.readUint16():this.skip(o);break;case 1:n.subType="text",t.value=this.readString(o);break;case 2:n.subType="copyrightNotice",t.value=this.readString(o);break;case 3:n.subType="trackName",t.value=this.readString(o);break;case 4:n.subType="instrumentName",t.value=this.readString(o);break;case 5:n.subType="lyrics",t.value=this.readString(o);break;case 6:n.subType="marker",t.value=this.readString(o);break;case 7:n.subType="cuePoint",t.value=this.readString(o);break;case 32:n.subType="midiChannelPrefix",1===o?t.value=this.readUint8():this.skip(o);break;case 47:n.subType="endOfTrack",0<o&&this.skip(o);break;case 81:n.subType="setTempo",3===o?t.value=this.readUint24():this.skip(o);break;case 84:n.subType="smpteOffset",5===o?(r=this.readUint8(),t.value={frameRate:{0:24,1:25,2:29.97,3:30}[r>>>6],hour:63&r,minute:this.readUint8(),second:this.readUint8(),frame:this.readUint8(),subFrame:this.readUint8()}):this.skip(o);break;case 88:n.subType="timeSignature",4===o?t.value={numerator:this.readUint8(),denominator:1<<this.readUint8(),metronome:this.readUint8(),thirtyseconds:this.readUint8()}:this.skip(o);break;case 89:n.subType="keySignature",2===o?t.value={key:this.readInt8(),scale:this.readUint8()}:this.skip(o);break;case 127:n.subType="sequencerSpecific",t.value=this.readString(o);break;default:n.subType="unknown",t.value=this.readString(o)}break;case 240:t.type="sysEx",o=this.readVarUint(),t.value=this.readString(o);break;case 247:t.type="dividedSysEx",o=this.readVarUint(),t.value=this.readString(o);break;default:i=t;i.type="unknown",i.subType="unknown",o=this.readVarUint(),t.value=this.readString(o)}else{0==(128&e)?(a=e,e=this.lastEventTypeByte):(a=this.readUint8(),this.lastEventTypeByte=e);var a,s=e>>4,u=t;switch(u.channel=15&e,u.type="channel",s){case 8:u.subType="noteOff",t.value={noteNumber:a,velocity:this.readUint8()};break;case 9:t.value={noteNumber:a,velocity:this.readUint8()},0===t.value.velocity?u.subType="noteOff":u.subType="noteOn";break;case 10:u.subType="noteAftertouch",t.value={noteNumber:a,amount:this.readUint8()};break;case 11:u.subType="controller",t.value={controllerNumber:a,controllerValue:this.readUint8()};break;case 12:u.subType="programChange",t.value=a;break;case 13:u.subType="channelAftertouch",t.value=a;break;case 14:u.subType="pitchBend",t.value=a+(this.readUint8()<<7);break;default:u.subType="unknown",t.value=(a<<8)+this.readUint8()}}return t}}])&&o(t.prototype,r),n&&o(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.exports=n},{}],5:[function(t,e,r){"use strict";function F(t,e){var r,n,i,o,a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(a)return n=!(r=!0),{s:function(){a=a.call(t)},n:function(){var t=a.next();return r=t.done,t},e:function(t){n=!0,i=t},f:function(){try{r||null==a.return||a.return()}finally{if(n)throw i}}};if(Array.isArray(t)||(a=function(t,e){var r;if(t)return"string"==typeof t?s(t,e):"Map"===(r="Object"===(r=Object.prototype.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:r)||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(t,e):void 0}(t))||e&&t&&"number"==typeof t.length)return a&&(t=a),o=0,{s:e=function(){},n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:e};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var V=t("./wav"),q=t("./midi"),W=t("./utils/timer");e.exports=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=(e.verbose&&console.log("parsing MIDI header..."),new q(t)),t=r.readChunk();if("MThd"!==t.id||6!==t.length)throw new SyntaxError("malformed header");for(var t=new q(t.data),_=t.readUint16(),t=t.readUint16(),n=[],i=[],o=[],a=0;a<_;a++){e.verbose&&console.log("parsing track ".concat(a+1,"..."));var s=r.readChunk();if("MTrk"===s.id){for(var u=new q(s.data),f=[],h=!0;h&&u.byteOffset<s.length;){var l=u.readEvent();if(f.push(l),"string"==typeof l.value&&(e.verbose&&console.log('{"'.concat(l.subType,'":"').concat(l.value,'"}')),Array.isArray(e.Skip))){var c,p=F(e.Skip);try{for(p.s();!(c=p.n()).done;)if(c.value[l.subType]===l.value){e.verbose&&console.log('skip match found: {"'.concat(l.subType,'":"').concat(l.value,'"}')),h=!1;break}}catch(t){p.e(t)}finally{p.f()}}}(h="function"==typeof e.Skip?!e.Skip(f):h)?n.push(f):e.verbose&&console.log("skipping track ".concat(a+1,"..."))}}if(t>>>15!=0)return console.log("Detected unsupported MIDI timing mode"),null;var y=new W(t);e.verbose&&console.log("initializing timer...");for(var d,g=0,v=0;g<n[0].length;g++)v+=(d=n[0][g]).delta,d.delta,"setTempo"===d.subType&&(y.addCriticalPoint(v,d.value),v=0);for(var b=0;b<n.length;b++){e.verbose&&console.log("generating progression from track ".concat(b+1,"..."));var m,N=n[b],w=0,k=new Map,S=F(N);try{for(S.s();!(m=S.n()).done;){var E,U,A,T,B,C=m.value;w+=C.delta,"channel"===C.type?(E=C.value.noteNumber,"noteOn"===C.subType?(U=C.value.velocity,A=y.getTime(w),k.has(E)?k.get(E).push({offset:A,velocity:U}):k.set(E,[{offset:A,velocity:U}]),o.push({velocity:U,delta:w,note:!0})):"noteOff"===C.subType&&(B=(T=k.get(E))?T.pop():{offset:0,velocity:0},i.push({note:V.note(E),time:y.getTime(w)-B.offset,amplitude:B.velocity/128,offset:B.offset}),o.push({velocity:B.velocity,delta:w,note:!1}))):e.verbose&&"meta"===C.type&&"string"==typeof C.value&&console.log("".concat(y.getTime(w).toFixed(2),"s ").concat(C.subType,": ").concat(C.value))}}catch(t){S.e(t)}finally{S.f()}}e.verbose&&console.log("normalizing volume..."),o.sort(function(t,e){return t.delta-e.delta||Number(t.note)-Number(e.note)}),e.verbose&&(console.log("total notes:",i.length),console.log("total time:",y.getTime(o[o.length-1].delta),"seconds"));var L,I=1,j=0,O=1,M=0,D=0,x=0,P=F(o);try{for(P.s();!(L=P.n()).done;){var R=L.value;R.note?(O+=R.velocity,x++,I<O&&(I=O,j=y.getTime(R.delta)),M<x&&(M=x,D=y.getTime(R.delta))):(O-=R.velocity,x--)}}catch(t){P.e(t)}finally{P.f()}t=128/I,e.verbose&&(console.log("setting volume to",t),console.log(" maximum chord of",M,"at",D,"seconds"),console.log(" maximum velocity of",I-1,"at",j,"seconds")),e.channels=1,e.verbose&&console.log("generating WAV buffer...");var z=new V(e.channels,e.sampleRate,e.bitsPerSample);return z.writeProgression(i,t,[0],!0,!0,e.duration),z}},{"./midi":4,"./utils/timer":6,"./wav":7}],6:[function(t,e,r){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==i(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===i(t)?t:String(t)}(n.key),n)}}var n=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.ticksPerBeat=t,this.criticalPoints=[]}var t,r,n;return t=e,(r=[{key:"addCriticalPoint",value:function(t,e){this.criticalPoints.push({delta:t,microsecondsPerBeat:e})}},{key:"getTime",value:function(t){for(var e,r=0,n=5e5,i=0;i<this.criticalPoints.length&&0<t;i++)t>=(e=this.criticalPoints[i]).delta?(r+=e.delta*n/this.ticksPerBeat/1e6,t-=e.delta):(r+=t*n/this.ticksPerBeat/1e6,t=0),n=e.microsecondsPerBeat;return r+=t*n/this.ticksPerBeat/1e6}}])&&o(t.prototype,r),n&&o(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.exports=n},{}],7:[function(t,e,r){!function(u){!function(){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,f=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){f=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(f)throw i}}return s}}(t,e)||function(t,e){var r;if(t)return"string"==typeof t?n(t,e):"Map"===(r="Object"===(r=Object.prototype.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:r)||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,function(t){t=function(t,e){if("object"!==i(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===i(t)?t:String(t)}(n.key),n)}}var s=/^([A-G])(\-?\d+)(b{0,2}|#{0,2})$/,t=function(){function w(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:44100,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:16,n=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:[],o=this,a=w;if(!(o instanceof a))throw new TypeError("Cannot call a class as a function");o=r>>>3;this.header=new ArrayBuffer(44),this.view=new DataView(this.header),this.data=i,Object.defineProperty(this,"littleEndian",{configurable:!1,enumerable:!0,value:n,writable:!1}),this.pointer=0,this.ChunkID=n?"RIFF":"RIFX",this.ChunkSize=this.header.byteLength-8,this.Format="WAVE",this.SubChunk1ID="fmt ",this.SubChunk1Size=16,this.AudioFormat=1,this.NumChannels=t,this.SampleRate=e,this.ByteRate=t*e*o,this.BlockAlign=t*o,this.BitsPerSample=r,this.SubChunk2ID="data",this.SubChunk2Size=i.length*o,this.littleEndian}var t,e,r;return t=w,r=[{key:"semitone",value:function(){var t,e,r,n,i,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"REST";return!s.test(o)||(t=(o=a(o.match(s)||[],4))[1],e=o[2],o=o[3],n={"-1":0,0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10,10:11},i={bb:-2,b:-1,"":0,"#":1,"##":2},void 0===(r={C:0,D:2,E:4,F:5,G:7,A:9,B:11})[t])||void 0===n[e]||void 0===i[o]?-1/0:r[t]+12*n[e]+i[o]}},{key:"note",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1/0,e=Math.floor(t/12),t=Math.floor(t-12*e),e=[-1,0,1,2,3,4,5,6,7,8,9,10][e],t=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"][t];return void 0===e||void 0===t?"REST":t.charAt(0)+e.toString()+t.charAt(1)}},{key:"frequency",value:function(){return 440*Math.pow(2,((0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1/0)-69)/12)}}],(e=[{key:"setString",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t.length,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,n=0;n<e;n++)this.view.setUint8(r+n,t.charCodeAt(n))}},{key:"getString",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r="",n=0;n<t;n++)r+=String.fromCharCode(this.view.getUint8(e+n));return r}},{key:"ChunkID",get:function(){return this.getString(4,0)},set:function(t){this.setString(t,4,0)}},{key:"ChunkSize",get:function(){return this.view.getUint32(4,this.littleEndian)},set:function(t){this.view.setUint32(4,t,this.littleEndian)}},{key:"Format",get:function(){return this.getString(4,8)},set:function(t){this.setString(t,4,8)}},{key:"SubChunk1ID",get:function(){return this.getString(4,12)},set:function(t){this.setString(t,4,12)}},{key:"SubChunk1Size",get:function(){return this.view.getUint32(16,this.littleEndian)},set:function(t){this.view.setUint32(16,t,this.littleEndian)}},{key:"AudioFormat",get:function(){return this.view.getUint16(20,this.littleEndian)},set:function(t){this.view.setUint16(20,t,this.littleEndian)}},{key:"NumChannels",get:function(){return this.view.getUint16(22,this.littleEndian)},set:function(t){this.view.setUint16(22,t,this.littleEndian)}},{key:"SampleRate",get:function(){return this.view.getUint32(24,this.littleEndian)},set:function(t){this.view.setUint32(24,t,this.littleEndian)}},{key:"ByteRate",get:function(){return this.view.getUint32(28,this.littleEndian)},set:function(t){this.view.setUint32(28,t,this.littleEndian)}},{key:"BlockAlign",get:function(){return this.view.getUint16(32,this.littleEndian)},set:function(t){this.view.setUint16(32,t,this.littleEndian)}},{key:"BitsPerSample",get:function(){return this.view.getUint16(34,this.littleEndian)},set:function(t){this.view.setUint16(34,t,this.littleEndian)}},{key:"SubChunk2ID",get:function(){return this.getString(4,36)},set:function(t){this.setString(t,4,36)}},{key:"SubChunk2Size",get:function(){return this.view.getUint32(40,this.littleEndian)},set:function(t){this.view.setUint32(40,t,this.littleEndian)}},{key:"typedData",get:function(){var t,e,r=this.BitsPerSample>>>3,n=this.data,i=this.SubChunk2Size,o=i/r,i=new ArrayBuffer(i),a=new Uint8Array(i),s=Math.pow(2,(r<<3)-1)-1;switch(r){case 1:for(t=0;t<o;t++)a[t]=n[t]*s+128&255;break;case 2:if(this.littleEndian)for(t=0;t<o;t++)e=n[t]*s+65536&65535,a[2*t]=255&e,a[2*t+1]=e>>>8;else for(t=0;t<o;t++)e=n[t]*s+65536&65535,a[2*t]=e>>>8,a[2*t+1]=255&e;break;case 3:if(this.littleEndian)for(t=0;t<o;t++)e=n[t]*s+16777216&16777215,a[3*t]=255&e,a[3*t+1]=e>>>8&255,a[3*t+2]=e>>>16;else for(t=0;t<o;t++)e=n[t]*s+16777216&16777215,a[3*t]=e>>>16,a[3*t+1]=e>>>8&255,a[3*t+2]=255&e;break;case 4:if(this.littleEndian)for(t=0;t<o;t++)e=n[t]*s+4294967296&4294967295,a[4*t]=255&e,a[4*t+1]=e>>>8&255,a[4*t+2]=e>>>16&255,a[4*t+3]=e>>>24;else for(t=0;t<o;t++)e=n[t]*s+4294967296&4294967295,a[4*t]=e>>>24,a[4*t+1]=e>>>16&255,a[4*t+2]=e>>>8&255,a[4*t+3]=255&e}return i}},{key:"toBlob",value:function(){return new Blob([this.header,this.typedData],{type:"audio/wav"})}},{key:"toBuffer",value:function(){return u.concat([u.from(this.header),u.from(this.typedData)])}},{key:"tell",value:function(){return this.pointer/this.NumChannels/this.SampleRate}},{key:"seek",value:function(t){var e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],r=this.data,t=Math.round(this.SampleRate*t);if(this.pointer=this.NumChannels*t,e)for(;r.length<this.pointer;)r[r.length]=0;else this.pointer=r.length}},{key:"writeNote",value:function(t){var e,r,n,i=t.note,o=t.time,t=t.amplitude,a=void 0===t?1:t,s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],u=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],t=3<arguments.length&&void 0!==arguments[3]&&arguments[3],f=this.data,h=this.NumChannels,l=this.SampleRate,i=w.semitone(i),c=w.frequency(i)*Math.PI*2/l,p=Math.round(l*o),y=p-.001*l,d=p-y+1,g=this.pointer,i=f.length,v=Math.min(Math.floor((i-g)/h),p);if(0===s.length)for(s=[],m=0;m<h;m++)s[m]=m;for(var b=[],m=0;m<h;m++)b[m]=-1===s.indexOf(m);for(m=0;m<v;m++)for(e=0;e<s.length;e++)r=g+m*h+s[e],(n=0)<c&&(n=a*Math.sin(c*m)*(m<d?m:y<m?p-m+1:d)/d),f[r]=n+(u?f[r]:0);for(m=v;m<p;m++)for(r=g+m*h,e=0;e<h;e++)((n=0)<c||!b[e])&&(n=a*Math.sin(c*m)*(m<d?m:y<m?p-m+1:d)/d),f[r+e]=n;o=Math.max(g+p*h,i)*this.BitsPerSample>>>3;this.ChunkSize=o+this.header.byteLength-8,this.SubChunk2Size=o,t||(this.pointer=g+p*h)}},{key:"writeProgression",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],n=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],i=4<arguments.length&&void 0!==arguments[4]&&arguments[4],o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:1,a=this.pointer,s=0;s<t.length;s++){var u=t[s],f=u.note,h=u.time,l=u.amplitude;void 0!==(u=u.offset)&&this.seek(u),1===o||"REST"===f?this.writeNote({note:f,time:h,amplitude:void 0===l?e:l*e},r,n,!1):(h=h-(u=h*o),this.writeNote({note:f,time:u,amplitude:void 0===l?e:l*e},r,n,!1),this.writeNote({note:"REST",time:h},r,n,!1))}i&&(this.pointer=a)}}])&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),w}();e.exports=t}.call(this)}.call(this,t("buffer").Buffer)},{buffer:2}],8:[function(t,e,r){"use strict";e.exports={WAV:t("./src/wav"),MIDIStream:t("./src/midi"),midiToWav:t("./src/midi2wav")}},{"./src/midi":4,"./src/midi2wav":5,"./src/wav":7}]},{},[8])(8)});
//# sourceMappingURL=synth.min.js.map