try{if(!Uint8Array.prototype.slice)Object.defineProperty(Uint8Array.prototype,"slice",{value:function(begin,end){return new Uint8Array(Array.prototype.slice.call(this,begin,end))}})}catch(err){}var ka="function"==typeof Object.create?Object.create:function(n){function m(){}m.prototype=n;return new m},D; if("function"==typeof Object.setPrototypeOf)D=Object.setPrototypeOf;else{var K;a:{var la={D:!0},N={};try{N.__proto__=la;K=N.D;break a}catch(n){}K=!1}D=K?function(n,m){n.__proto__=m;if(n.__proto__!==m)throw new TypeError(n+" is not extensible");return n}:null}var O=D; function P(n,m){n.prototype=ka(m.prototype);n.prototype.constructor=n;if(O)O(n,m);else for(var l in m)if("prototype"!=l)if(Object.defineProperties){var p=Object.getOwnPropertyDescriptor(m,l);p&&Object.defineProperty(n,l,p)}else n[l]=m[l]}var ma="function"==typeof Object.defineProperties?Object.defineProperty:function(n,m,l){n!=Array.prototype&&n!=Object.prototype&&(n[m]=l.value)},na="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this; function Q(n,m){if(m){for(var l=na,p=n.split("."),y=0;yv&&(v=Math.max(v+y,0));vp||56319m||57343c;c++)b["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(c)]=c;c=.75*a.length;"="===a[a.length-1]&&(c--,"="===a[a.length-2]&&c--);c=new Uint8Array(c);for(var d= 0,e=0;d>4;c[e++]=(g&15)<<4|k>>2;c[e++]=(k&3)<<6|r&63}return c}function sa(a,b){return a=0parseInt(a,10)||"53">4;z.push(ba(aa<<4^Z,r));z.push(ba(aa,r))}e=z;d.set(e,f);f+=e.length;e=[]}e.push(a[g])}return d}function xa(a,b){var c=a[0];S(c,b);var d=[];d.push(c&255);d.push(c>>8&255);d.push(b.index);d.push(0);c=3;for(var e=a.length;c>3;c>e&&(d|=4,c-=e,f+=e);e>>=1;c>e&&(d|=2,c-=e,f+=e);e>>=1;c>e&&(d|=1,f+=e);c=d;b.i=c&8?b.i-f:b.i+f;-32768>b.i?b.i=-32768:32767b.index?b.index=0:88>1);a&1&&(c+=b.step>>2);c+=b.step>>3;a&8&&(c=-c);b.i+=c;32767b.i&&(b.i=-32767);b.index+=ca[a];0>b.index?b.index=0:88>8&128;g||(f*=-1);32635>8&127];f=k<<4|f>>k+3&15}else f>>=4;b[e]=f^g^85}return b}function Ca(a){for(var b=new Int16Array(a.length),c=0,d=a.length;c>4)+4;f=4!=k?1<>8&128;0!=g&&(f=-f);f+=132;32635>7&255];b[e]=~(g|k<<4|f>>k+3&15)}return b}function Fa(a){for(var b=new Int16Array(a.length),c=0,d=a.length;c>4&7;g=Ga[g]+((f&15)<f)b[c]=f,c++;else{var g=0,k=0;2047>=f?(g=1,k=192):65535>=f?(g=2,k=224):1114111>=f&&(g=3,k=240,d++);b[c]=(f>>6*g)+k;for(c++;0>6*(g-1)&63,c++,g--}d++}return c}function U(a){var b=Math.floor(a);a-=b;return.5>a?b:.5=k)b+=String.fromCharCode(k);else{var r= 0;194<=k&&223>=k?r=1:224<=k&&239>=k?(r=2,224===a[d]&&(e=160),237===a[d]&&(f=159)):240<=k&&244>=k?(r=3,240===a[d]&&(e=144),244===a[d]&&(f=143)):g=!0;k&=(1<<8-r-1)-1;for(var z=0;zf)g=!0;k=k<<6|a[d]&63;d++}g?b+=String.fromCharCode(65533):65535>=k?b+=String.fromCharCode(k):(k-=65536,b+=String.fromCharCode((k>>10&1023)+55296,(k&1023)+56320))}}return b}function x(a){var b=[];T(a,b);return b}function L(a,b,c,d){d=void 0===d?0:d;b=b||{};for(var e=ea(b.h,b.R,b.O),f=Math.ceil(b.h/8), g=0,k=d,r=a.length;gb){b=new g(d.LPForder||ia[d.LPFType],c,b/2);c=0;for(d=e.length;cthis.max?this.max:athis.max&&(a-=2*this.max+2);return a};H.prototype.ga=function(a,b,c){Math.abs(b)>this.f-2*this.g&&(b=0>b?-Infinity:Infinity);var d=0>((b=+b)||1/b)?1:0>b?1:0;b=Math.abs(b);var e=Math.min(Math.floor(Math.log(b)/Math.LN2),1023),f=U(b/Math.pow(2,e)*Math.pow(2,this.c));b!== b?(f=Math.pow(2,this.c-1),e=(1<=Math.pow(2,1-this.a)?(2<=f/Math.pow(2,this.c)&&(e+=1,f=1),e>this.a?(e=(1<=b;)a[f]=parseInt(e.substring(0,8),2),e=e.substring(8),f--,d++;return d};B.prototype.va=function(a){this.c=0;this.container=this.u(a,4);if(-1===this.Z.indexOf(this.container))throw Error("Not a supported format."); this.a.o="RIFX"===this.container;this.chunkSize=this.b(a);this.format=this.u(a,4);this.Y={chunkId:this.container,chunkSize:this.chunkSize,format:this.format,subChunks:this.V(a)}};B.prototype.s=function(a,b){b=void 0===b?!1:b;for(var c=this.Y.subChunks,d=[],e=0;ethis.data.samples.length)throw Error("Range error");return M(this.data.samples.slice(a,a+this.f.h/8),this.f)};t.prototype.setSample=function(a,b){a*=this.f.h/ 8;if(a+this.f.h/8>this.data.samples.length)throw Error("Range error");L([b],this.f,this.data.samples,void 0===a?0:a)};t.prototype.getiXML=function(){return this.iXML.value};t.prototype.setiXML=function(a){if("string"!==typeof a)throw new TypeError("iXML value must be a string.");this.iXML.value=a;this.iXML.chunkId="iXML"};t.prototype.get_PMX=function(){return this._PMX.value};t.prototype.set_PMX=function(a){if("string"!==typeof a)throw new TypeError("_PMX value must be a string.");this._PMX.value= a;this._PMX.chunkId="_PMX"};t.prototype.W=function(a,b,c,d,e){e.container||(e.container="RIFF");this.container=e.container;this.bitDepth=c;var f=[];if(0parseInt(this.bitDepth,10)))throw Error("Invalid bit depth.");};t.prototype.$=function(){this.f={h:(parseInt(this.bitDepth,10)-1|7)+1,R:"32f"==this.bitDepth||"64"==this.bitDepth,O:"8"!=this.bitDepth,o:"RIFX"==this.container};-1<["4","8a","8m"].indexOf(this.bitDepth)&&(this.f.h=8,this.f.O=!1)};t.prototype.aa=function(){this.wa(); var a=this.fmt.numChannels;if(1>a||65535a||4294967295c.length)for(var d=0,e=4-c.length;db.dwSampleOffset&&!c?(this.B(b,d+1),this.B(a[d],d+2),c=!0):this.B(a[d],c?d+2:d+1);c||this.B(b,this.cue.points.length+1)};w.prototype.I=function(){for(var a=0,b=this.LIST.length;aa||4294967295>2],b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[c]&3)<<4|a[c+1]>>4],b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[c+1]&15)<<2|a[c+2]>>6],b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[c+2]&63];2===a.length%3?b=b.substring(0,b.length-1)+"=":1===a.length%3&&(b=b.substring(0,b.length-2)+"==");return b};m.prototype.toDataURI= function(){return"data:audio/wav;base64,"+this.toBase64()};m.prototype.fromDataURI=function(a){this.fromBase64(a.replace("data:audio/wav;base64,",""))};n.WaveFile=m;Object.defineProperty(n,"__esModule",{value:!0})}"object"===typeof exports&&"undefined"!==typeof module?W(exports):"function"===typeof define&&define.amd?define(["exports"],W):(V=V||self,W(V.wavefile={}));