!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.synth=t()}}(function(){return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var f=r[a]={exports:{}};e[a][0].call(f.exports,function(t){var r=e[a][1][t];return i(r||t)},f,f.exports,t,e,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function i(t){return 3*t.length/4-n(t)}function o(t){var e,r,i,o,a,s,u=t.length;a=n(t),s=new l(3*u/4-a),i=a>0?u-4:u;var h=0;for(e=0,r=0;e>16&255,s[h++]=o>>8&255,s[h++]=255&o;return 2===a?(o=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,s[h++]=255&o):1===a&&(o=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,s[h++]=o>>8&255,s[h++]=255&o),s}function a(t){return h[t>>18&63]+h[t>>12&63]+h[t>>6&63]+h[63&t]}function s(t,e,r){for(var n,i=[],o=e;ou?u:a+16383));return 1===n?(e=t[r-1],i+=h[e>>2],i+=h[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=h[e>>10],i+=h[e>>4&63],i+=h[e<<2&63],i+="="),o.push(i),o.join("")}r.byteLength=i,r.toByteArray=o,r.fromByteArray=u;for(var h=[],f=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=c.length;pZ)throw new RangeError("Invalid typed array length");var e=new Uint8Array(t);return e.__proto__=i.prototype,e}function i(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return u(t)}return o(t,e,r)}function o(t,e,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return t instanceof ArrayBuffer?l(t,e,r):"string"==typeof t?h(t,e):c(t)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function s(t,e,r){return a(t),t<=0?n(t):void 0!==e?"string"==typeof r?n(t).fill(e,r):n(t).fill(e):n(t)}function u(t){return a(t),n(t<0?0:0|p(t))}function h(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!i.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var r=0|g(t,e),o=n(r),a=o.write(t,e);return a!==r&&(o=o.slice(0,a)),o}function f(t){for(var e=t.length<0?0:0|p(t.length),r=n(e),i=0;i=Z)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Z.toString(16)+" bytes");return 0|t}function d(t){return+t!=t&&(t=0),i.alloc(+t)}function g(t,e){if(i.isBuffer(t))return t.length;if(G(t)||t instanceof ArrayBuffer)return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(t).length;default:if(n)return z(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return M(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,W(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){function o(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}var a=1,s=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;a=2,s/=2,u/=2,r/=2}var h;if(i){var f=-1;for(h=r;hs&&(r=s-u),h=r;h>=0;h--){for(var l=!0,c=0;ci&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a239?4:o>223?3:o>191?2:1;if(i+s<=r){var u,h,f,l;switch(s){case 1:o<128&&(a=o);break;case 2:u=t[i+1],128==(192&u)&&(l=(31&o)<<6|63&u)>127&&(a=l);break;case 3:u=t[i+1],h=t[i+2],128==(192&u)&&128==(192&h)&&(l=(15&o)<<12|(63&u)<<6|63&h)>2047&&(l<55296||l>57343)&&(a=l);break;case 4:u=t[i+1],h=t[i+2],f=t[i+3],128==(192&u)&&128==(192&h)&&128==(192&f)&&(l=(15&o)<<18|(63&u)<<12|(63&h)<<6|63&f)>65535&&l<1114112&&(a=l)}}null===a?(a=65533,s=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=s}return C(n)}function C(t){var e=t.length;if(e<=H)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function R(t,e,r,n,o,a){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,n,i){return e=+e,r>>>=0,i||P(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return e=+e,r>>>=0,i||P(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(t,e,r,n,52,8),r+8}function D(t){if(t=t.trim().replace(K,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function F(t){return t<16?"0"+t.toString(16):t.toString(16)}function z(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],a=0;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<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 j(t){for(var e=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function q(t){return X.toByteArray(D(t))}function Y(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function G(t){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(t)}function W(t){return t!==t}var X=t("base64-js"),J=t("ieee754");r.Buffer=i,r.SlowBuffer=d,r.INSPECT_MAX_BYTES=50;var Z=2147483647;r.kMaxLength=Z,i.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}}(),i.TYPED_ARRAY_SUPPORT||"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."),"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),i.poolSize=8192,i.from=function(t,e,r){return o(t,e,r)},i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,i.alloc=function(t,e,r){return s(t,e,r)},i.allocUnsafe=function(t){return u(t)},i.allocUnsafeSlow=function(t){return u(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer},i.compare=function(t,e){if(!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,a=Math.min(r,n);o0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},i.prototype.compare=function(t,e,r,n,o){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var a=o-n,s=r-e,u=Math.min(a,s),h=this.slice(n,o),f=t.slice(e,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return k(this,t,e,r);case"ascii":return E(this,t,e,r);case"latin1":case"binary":return S(this,t,e,r);case"base64":return U(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var H=4096;i.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||_(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||_(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},i.prototype.readUInt8=function(t,e){return t>>>=0,e||_(t,1,this.length),this[t]},i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||_(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||_(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||_(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||_(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);for(var n=this[t],i=1,o=0;++o=i&&(n-=Math.pow(2,8*e)),n},i.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},i.prototype.readInt8=function(t,e){return t>>>=0,e||_(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||_(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(t,e){t>>>=0,e||_(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||_(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||_(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||_(t,4,this.length),J.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||_(t,4,this.length),J.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||_(t,8,this.length),J.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||_(t,8,this.length),J.read(this,t,!1,52,8)},i.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){R(this,t,e,r,Math.pow(2,8*r)-1,0)}var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,!n){R(this,t,e,r,Math.pow(2,8*r)-1,0)}var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},i.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||R(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},i.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||R(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},i.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);R(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},i.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);R(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},i.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||R(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},i.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},i.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},i.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},i.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},i.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=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=0;--i)t[i+e]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var a;if("number"==typeof t)for(a=e;a>1,f=-7,l=r?i-1:0,c=r?-1:1,p=t[e+l];for(l+=c,o=p&(1<<-f)-1,p>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=c,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=c,f-=8);if(0===o)o=1-h;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=h}return(p?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,u,h=8*o-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=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*(u=Math.pow(2,-a))<1&&(a--,u*=2),e+=a+l>=1?c/u:c*Math.pow(2,1-l),e*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,h-=8);t[r+p-d]|=128*g}},{}],5:[function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,e){for(var r=0;r0&&this.skip(n);break;case 81:t.subType="setTempo",3===n?t.value=this.readUint24():this.skip(n);break;case 84:if(t.subType="smpteOffset",5===n){var i=this.readUint8();t.value={frameRate:{0:24,1:25,2:29.97,3:30}[i>>>6],hour:63&i,minute:this.readUint8(),second:this.readUint8(),frame:this.readUint8(),subFrame:this.readUint8()}}else this.skip(n);break;case 88:t.subType="timeSignature",4===n?t.value={numerator:this.readUint8(),denominator:1<>4;switch(t.channel=15&e,t.type="channel",a){case 8:t.subType="noteOff",t.value={noteNumber:o,velocity:this.readUint8()};break;case 9:t.value={noteNumber:o,velocity:this.readUint8()},0===t.value.velocity?t.subType="noteOff":t.subType="noteOn";break;case 10:t.subType="noteAftertouch",t.value={noteNumber:o,amount:this.readUint8()};break;case 11:t.subType="controller",t.value={controllerNumber:o,controllerValue:this.readUint8()};break;case 12:t.subType="programChange",t.value=o;break;case 13:t.subType="channelAftertouch",t.value=o;break;case 14:t.subType="pitchBend",t.value=o+(this.readUint8()<<7);break;default:t.subType="unknown",t.value=(o<<8)+this.readUint8()}}return t}}]),t}();e.exports=o},{}],6:[function(t,e,r){"use strict";var n=t("./wav"),i=t("./midi"),o=t("./utils/timer");e.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.verbose&&console.log("parsing MIDI header...");var r=new i(t),a=r.readChunk();if("MThd"!==a.id||6!==a.length)throw new SyntaxError("malformed header");for(var s=new i(a.data),u=(s.readUint16(),s.readUint16()),h=s.readUint16(),f=[],l=[],c=[],p=void 0,d=0;d>>15!=0)return console.log("Detected unsupported MIDI timing mode"),null;var k=new o(h);e.verbose&&console.log("initializing timer...");for(var E,S=0,U=0,A=0;SL&&(L=D,N=k.getTime(X.delta)),j>F&&(F=j,z=k.getTime(X.delta))):(D-=X.velocity,j--)}}catch(t){q=!0,Y=t}finally{try{!V&&W.return&&W.return()}finally{if(q)throw Y}}p=128/L,e.verbose&&(console.log("setting volume to",p),console.log(" maximum chord of",F,"at",z,"seconds"),console.log(" maximum velocity of",L-1,"at",N,"seconds")),e.channels=1,e.verbose&&console.log("generating WAV buffer...");var J=new n(e.channels,e.sampleRate,e.bitsPerSample);return J.writeProgression(l,p,[0],!0,!0,e.duration),J}},{"./midi":5,"./utils/timer":7,"./wav":8}],7:[function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,e){for(var r=0;r0;i++)e=this.criticalPoints[i],t>=e.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}}]),t}();e.exports=o},{}],8:[function(t,e,r){(function(t){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=function(){function t(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:44100,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16,o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];r(this,e);var s=i>>>3;this.header=new ArrayBuffer(44),this.view=new DataView(this.header),this.data=a,Object.defineProperty(this,"littleEndian",{configurable:!1,enumerable:!0,value:o,writable:!1}),this.pointer=0,this.ChunkID=o?"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=n,this.ByteRate=t*n*s,this.BlockAlign=t*s,this.BitsPerSample=i,this.SubChunk2ID="data",this.SubChunk2Size=a.length*s}return i(e,null,[{key:"semitone",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"REST",e=/^([A-G])(\-?\d+)(b{0,2}|#{0,2})$/;if(!e.test(t))return-1/0;var r=t.match(e),i=n(r,4),o=i[1],a=i[2],s=i[3],u={C:0,D:2,E:4,F:5,G:7,A:9,B:11 },h={"-1":0,0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10,10:11},f={bb:-2,b:-1,"":0,"#":1,"##":2};return void 0===u[o]||void 0===h[a]||void 0===f[s]?-1/0:u[o]+12*h[a]+f[s]}},{key:"note",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1/0,e=[-1,0,1,2,3,4,5,6,7,8,9,10],r=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],n=Math.floor(t/12),i=Math.floor(t-12*n),o=e[n],a=r[i];return void 0===o||void 0===a?"REST":a.charAt(0)+o.toString()+a.charAt(1)}},{key:"frequency",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1/0;return 440*Math.pow(2,(t-69)/12)}}]),i(e,[{key:"setString",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.length,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=0;n1&&void 0!==arguments[1]?arguments[1]:0,r=0,n="";r1&&void 0!==arguments[1])||arguments[1],r=this.data,n=Math.round(this.SampleRate*t);if(this.pointer=this.NumChannels*n,e)for(;r.length1&&void 0!==arguments[1]?arguments[1]:[],l=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],c=arguments.length>3&&void 0!==arguments[3]&&arguments[3],p=this.data,d=this.NumChannels,g=this.SampleRate,y=e.semitone(a),v=e.frequency(y)*Math.PI*2/g,b=(Math.PI,Math.round(g*s)),w=b-.001*g,m=b-w+1,k=this.pointer,E=p.length,S=Math.min(Math.floor((E-k)/d),b);if(0===f.length)for(f=[],r=0;r0&&(o=h*Math.sin(v*r)*(rw?b-r+1:m)/m),p[i]=o+(l?p[i]:0);for(r=S;r0||!U[n])&&(o=h*Math.sin(v*r)*(rw?b-r+1:m)/m),p[i+n]=o;var A=Math.max(k+b*d,E)*this.BitsPerSample>>>3;this.ChunkSize=A+this.header.byteLength-8,this.SubChunk2Size=A,c||(this.pointer=k+b*d)}},{key:"writeProgression",value:function(t){for(var e,r,n,i,o,a,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],h=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],f=arguments.length>4&&void 0!==arguments[4]&&arguments[4],l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1,c=this.pointer,p=0;p>>3,n=this.data,i=this.SubChunk2Size,o=i/r,a=new ArrayBuffer(i),s=new Uint8Array(a),u=Math.pow(2,(r<<3)-1)-1;switch(r){case 1:for(t=0;t>>8;else for(t=0;t>>8,s[2*t+1]=255&e;break;case 3:if(this.littleEndian)for(t=0;t>>8&255,s[3*t+2]=e>>>16;else for(t=0;t>>16,s[3*t+1]=e>>>8&255,s[3*t+2]=255&e;case 4:if(this.littleEndian)for(t=0;t>>8&255,s[4*t+2]=e>>>16&255,s[4*t+3]=e>>>24;else for(t=0;t>>24,s[4*t+1]=e>>>16&255,s[4*t+2]=e>>>8&255,s[4*t+3]=255&e}return a}}]),e}();e.exports=o}).call(this,t("buffer").Buffer)},{buffer:3}]},{},[1])(1)}); //# sourceMappingURL=synth.min.js.map