Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wavefile

Package Overview
Dependencies
Maintainers
1
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wavefile - npm Package Compare versions

Comparing version 10.4.3 to 11.0.0

lib/codecs/alaw.js

104

bin/wavefile.js
#!/usr/bin/env node
/*
* Copyright (c) 2017-2019 Rafael da Silva Rocha.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/

@@ -14,2 +37,3 @@ /**

" Copyright (c) 2017-2018 Rafael da Silva Rocha.\n";
/** @type {string} */

@@ -22,2 +46,8 @@ const help = " Usage:\n" +

"\n" +
" --resample Ex: wavefile input.wav --resample=16000 output.wav\n" +
" Change the sample rate. The input file is not affected\n" +
" Use with --method to change the interpolation method:\n" +
" Ex: wavefile in.wav --resample=8000 --method=sinc out.wav\n" +
" If --method is ommited, cubic interpolation will be used.\n" +
"\n" +
" --bitdepth Ex: wavefile input.wav --bitdepth=32f output.wav\n" +

@@ -53,3 +83,4 @@ " Change the bit depth.\n" +

// Help
if (process.argv[2] == '-h' || process.argv[2] == '--help' || process.argv.length < 4) {
if (process.argv[2] == '-h' ||
process.argv[2] == '--help' || process.argv.length < 4) {
console.log(presentation);

@@ -60,12 +91,16 @@ console.log(help);

// Anything that is not a arg will be considered a file reference;
// the first item in the list will be considered the input, all
// others will be output
/** @type {Array<string>} */
/**
* Anything that is not a command will be considered a file reference;
* the first item in the list will be considered the input, all
* others will be considered output.
* @type {!Array<string>}
*/
let files = [];
// Anything that is not a file will be considered a command;
// All commands should be executed against the input file
/** @type {Array<string>} */
let commands = [];
/**
* Anything that is not a file will be considered a command;
* All commands should be executed against the input file.
* @type {Object}
*/
let commands = {};

@@ -75,3 +110,3 @@ // parse args

if (process.argv[arg].slice(0, 1) == '-') {
commands.push(process.argv[arg]);
commands[process.argv[arg].split("=")[0]] = process.argv[arg].split("=")[1];
} else {

@@ -92,15 +127,22 @@ files.push(process.argv[arg]);

// --bitdepth
let splitCommand = commands[command].split("=");
if (splitCommand[0] == '--bitdepth') {
wav.toBitDepth(splitCommand[1]);
if (command == '--bitdepth') {
wav.toBitDepth(commands[command]);
shouldWrite = true;
// --resample
} else if (command == '--resample') {
/** @type {!Object} */
let options = {
'method' : commands['--method'] ? commands['--method'] : 'cubic'
};
wav.toSampleRate(parseInt(commands[command], 10), options);
shouldWrite = true;
// --compress
} else if (splitCommand[0] == '--compress') {
if (splitCommand[1] == 'adpcm') {
} else if (command == '--compress') {
if (commands[command] == 'adpcm') {
wav.toIMAADPCM();
shouldWrite = true;
} else if (splitCommand[1] == 'alaw') {
} else if (commands[command] == 'alaw') {
wav.toALaw();
shouldWrite = true;
} else if (splitCommand[1] == 'mulaw') {
} else if (commands[command] == 'mulaw') {
wav.toMuLaw();

@@ -110,17 +152,18 @@ shouldWrite = true;

// --tag
} else if (splitCommand[0] == '--tag') {
console.log(wav.getTag(splitCommand[1]));
} else if (command == '--tag') {
console.log(wav.getTag(commands[command]));
// --list-tag
} else if (splitCommand[0] == '--list-tags') {
} else if (command == '--list-tags') {
/** @type {!Object} */
tags = wav.listTags();
for (var tag in tags) {
if (tags.hasOwnProperty(tag)) {
console.log(tag + ': ' + tags[tag]);
}
if (tags.hasOwnProperty(tag)) {
console.log(tag + ': ' + tags[tag]);
}
}
// --list-cue
} else if (splitCommand[0] == '--list-cue') {
} else if (command == '--list-cue') {
console.log(wav.listCuePoints());
// --bits
} else if (splitCommand[0] == '--bits') {
} else if (command == '--bits') {
if (wav.fmt.validBitsPerSample) {

@@ -132,12 +175,15 @@ console.log(wav.fmt.validBitsPerSample);

// --rate
} else if (splitCommand[0] == '--rate') {
} else if (command == '--rate') {
console.log(wav.fmt.sampleRate);
// error
} else {
console.log('ERROR: Bad option. Run wavefile -h to check the available options.');
process.exit();
if (!(command === '--method' && commands['--resample'])) {
console.log('ERROR: Bad option. Run wavefile -h to check the available'+
' options.');
process.exit();
}
}
}
// Write the output
// Write the output file
if (shouldWrite) {

@@ -144,0 +190,0 @@ if (files.length) {

# CHANGELOG
## version 11.0.0 - 2020-01-30
### API changes
- clamp int samples on overflow instead of throwing RangeError
### Other changes
- Zero dependencies
## version 10.4.3 - 2020-01-27

@@ -4,0 +13,0 @@ - Fix: large files RIFF/RIFX conversion

@@ -1,87 +0,84 @@

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 aa="function"==typeof Object.create?Object.create:function(n){function m(){}m.prototype=n;return new m},H;
if("function"==typeof Object.setPrototypeOf)H=Object.setPrototypeOf;else{var O;a:{var ba={D:!0},pa={};try{pa.__proto__=ba;O=pa.D;break a}catch(n){}O=!1}H=O?function(n,m){n.__proto__=m;if(n.__proto__!==m)throw new TypeError(n+" is not extensible");return n}:null}var qa=H;
function Q(n,m){n.prototype=aa(m.prototype);n.prototype.constructor=n;if(qa)qa(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 ra="function"==typeof Object.defineProperties?Object.defineProperty:function(n,m,l){n!=Array.prototype&&n!=Object.prototype&&(n[m]=l.value)},sa="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;
function R(n,m){if(m){for(var l=sa,p=n.split("."),y=0;y<p.length-1;y++){var v=p[y];v in l||(l[v]={});l=l[v]}p=p[p.length-1];y=l[p];v=m(y);v!=y&&null!=v&&ra(l,p,{configurable:!0,writable:!0,value:v})}}R("Object.is",function(n){return n?n:function(m,l){return m===l?0!==m||1/m===1/l:m!==m&&l!==l}});
R("Array.prototype.includes",function(n){return n?n:function(m,l){var p=this;p instanceof String&&(p=String(p));var y=p.length,v=l||0;for(0>v&&(v=Math.max(v+y,0));v<y;v++){var w=p[v];if(w===m||Object.is(w,m))return!0}return!1}});
R("String.prototype.codePointAt",function(n){return n?n:function(m){if(null==this)throw new TypeError("The 'this' value for String.prototype.codePointAt must not be null or undefined");var l=this.length;m=Number(m)||0;if(0<=m&&m<l){m|=0;var p=this.charCodeAt(m);if(55296>p||56319<p||m+1===l)return p;m=this.charCodeAt(m+1);return 56320>m||57343<m?p:1024*(p-55296)+m+9216}}});
var ta="function"==typeof Object.assign?Object.assign:function(n,m){for(var l=1;l<arguments.length;l++){var p=arguments[l];if(p)for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(n[y]=p[y])}return n};R("Object.assign",function(n){return n||ta});var S=this;
function T(n){function m(a){a=void 0===a?null:a;var b=l.call(this)||this;a&&b.fromBuffer(a);return b}function l(){return w.apply(this,arguments)||this}function p(a,b,c){for(var d=[],e=0;e<a;e++)d.push(this.b({oa:b,na:c,Q:.5/Math.sin(Math.PI/(2*a)*(e+.5))}));this.a=[];for(a=0;a<d.length;a++)this.a[a]={Ja:d[a].A[0],Ka:d[a].A[1],La:d[a].A[2],Ga:d[a].D[0],Ha:d[a].D[1],k:d[a].k,z:[0,0]}}function y(a,b,c){c=2*Math.PI*c/b;b=0;this.a=[];for(var d=0;d<=a;d++)0===d-a/2?this.a[d]=c:(this.a[d]=Math.sin(c*(d-
a/2))/(d-a/2),this.a[d]*=.54-.46*Math.cos(2*Math.PI*d/a)),b+=this.a[d];for(c=0;c<=a;c++)this.a[c]/=b;this.z=this.b()}function v(a,b,c){this.v=a;this.i=(a-1)/b;this.O=this.J;"point"===c.method?this.O=this.I:"linear"===c.method?this.O=this.H:"cubic"===c.method&&(this.O=this.C);this.m=ua;"periodic"===c.clip?(this.i=a/b,this.m=ca):"mirror"===c.clip&&(this.m=va);this.K=1-Math.max(0,Math.min(1,c.tension||0));this.B=c.sincFilterSize||1;this.G=wa(c.sincWindow||xa)}function w(){return C.apply(this,arguments)||
this}function C(){return t.apply(this,arguments)||this}function t(){var a=r.call(this)||this;a.bitDepth="0";a.f={g:0,o:!1,F:!1,N:!1};a.G={4:17,8:1,"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,64:3};return a}function r(){return u.apply(this,arguments)||this}function u(){var a=B.call(this)||this;a.Y.push("RF64");a.fmt={chunkId:"",chunkSize:0,audioFormat:0,numChannels:0,sampleRate:0,byteRate:0,blockAlign:0,bitsPerSample:0,cbSize:0,validBitsPerSample:0,dwChannelMask:0,subformat:[]};a.fact={chunkId:"",chunkSize:0,
dwSampleLength:0};a.cue={chunkId:"",chunkSize:0,dwCuePoints:0,points:[]};a.smpl={chunkId:"",chunkSize:0,dwManufacturer:0,dwProduct:0,dwSamplePeriod:0,dwMIDIUnityNote:0,dwMIDIPitchFraction:0,dwSMPTEFormat:0,dwSMPTEOffset:0,dwNumSampleLoops:0,dwSamplerData:0,loops:[]};a.bext={chunkId:"",chunkSize:0,description:"",originator:"",originatorReference:"",originationDate:"",originationTime:"",timeReference:[0,0],version:0,UMID:"",loudnessValue:0,loudnessRange:0,maxTruePeakLevel:0,maxMomentaryLoudness:0,maxShortTermLoudness:0,
reserved:"",codingHistory:""};a.iXML={chunkId:"",chunkSize:0,value:""};a.ds64={chunkId:"",chunkSize:0,riffSizeHigh:0,riffSizeLow:0,dataSizeHigh:0,dataSizeLow:0,originationTime:0,sampleCountHigh:0,sampleCountLow:0};a.data={chunkId:"",chunkSize:0,samples:new Uint8Array(0)};a.LIST=[];a.junk={chunkId:"",chunkSize:0,chunkData:[]};a._PMX={chunkId:"",chunkSize:0,value:""};a.h={g:16,o:!1,F:!1,N:!1};return a}function B(){this.container="";this.chunkSize=0;this.format="";this.X={};this.c=0;this.a={g:32,o:!1,
F:!1,N:!1};this.Y=["RIFF","RIFX"]}function K(a,b){this.b=a;this.c=b;this.a=(1<<a-1)-1;this.f=Math.ceil((a+b)/8);this.h=Math.pow(2,this.a+1);this.j=a+b;this.i=Math.pow(2,-(8*this.f-1-a))}function E(a,b,c){this.g=a;this.b=8>a?1:Math.ceil(a/8);this.max=Math.pow(2,a)-1;this.min=0;var d=8-((a-1|7)+1-a);this.f=Math.pow(2,0<d?d:8)-1;this.R=this.l;if(void 0===b?0:b)this.max=Math.pow(2,a)/2-1,this.min=-this.max-1,this.R=this.i;if(void 0===c?0:c)this.a=this.h}function ya(a){for(var b=new Uint8Array(256),c=
0;64>c;c++)b["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(c)]=c;c=.75*a.length;"="===a[a.length-1]&&(c--,"="===a[a.length-2]&&c--);c=new ArrayBuffer(c);for(var d=new Uint8Array(c),e=0,f=0;e<a.length;e+=4){var g=b[a.charCodeAt(e)],k=b[a.charCodeAt(e+1)],q=b[a.charCodeAt(e+2)],z=b[a.charCodeAt(e+3)];d[f++]=g<<2|k>>4;d[f++]=(k&15)<<4|q>>2;d[f++]=(q&3)<<6|z&63}return c}function za(a,b){return a=0<a?parseInt(a/b.da*b.ba,10):parseInt(a/b.ea*b.ca,10)}function Aa(a,b){return parseInt(0<
a?a*b.ba:a*b.ca,10)}function Ba(a,b){return 0<a?a/b.da:a/b.ea}function Ca(a,b){function c(d){return d}a!=b&&(c=["32f","64"].includes(a)?Aa:["32f","64"].includes(b)?Ba:za);return c}function da(a){if("32f"!=a&&"64"!=a&&("8">parseInt(a,10)||"53"<parseInt(a,10)))throw Error("Invalid bit depth.");}function ea(a,b,c){if("8"==a)for(a=c?-128:128,c=0;c<b.length;c++)b[c]=b[c]+=a}function Da(a){for(var b=new Uint8Array(a.length),c=[],d=0,e=0,f=0;f<a.length;f++)0==f%505&&0!=f&&(b.set(Ea(c),d),d+=256,c=[],e++),
c.push(a[f]);a=a.length/2;a%2&&a++;return b.slice(0,a+512+4*e)}function Fa(a,b){b=void 0===b?256:b;for(var c=new Int16Array(2*a.length),d=[],e=0,f=0;f<a.length;f++){if(0==f%b&&0!=f){var g=d[1]<<8|d[0];D=32768<g?g-65536:g;F=d[2];L=U[F];g=[D,D];for(var k=4;k<d.length;k++){var q=d[k],z=q>>4;g.push(fa(z<<4^q));g.push(fa(z))}d=g;c.set(d,e);e+=d.length;d=[]}d.push(a[f])}return c}function Ea(a){var b=a[0];V(b);var c=[];c.push(b&255);c.push(b>>8&255);c.push(I);c.push(0);for(b=3;b<a.length;b+=2){var d=V(a[b]),
e=V(a[b+1]);c.push(e<<4|d)}return c}function V(a){var b=a-G;0<=b?a=0:(a=8,b=-b);var c=U[I],d=c>>3;b>c&&(a|=4,b-=c,d+=c);c>>=1;b>c&&(a|=2,b-=c,d+=c);c>>=1;b>c&&(a|=1,d+=c);b=a;G=b&8?G-d:G+d;-32768>G?G=-32768:32767<G&&(G=32767);I+=ha[b&7];0>I?I=0:88<I&&(I=88);return a}function fa(a){var b=0;a&4&&(b+=L);a&2&&(b+=L>>1);a&1&&(b+=L>>2);b+=L>>3;a&8&&(b=-b);D+=b;32767<D?D=32767:-32767>D&&(D=-32767);F+=ha[a];0>F?F=0:88<F&&(F=88);L=U[F];return D}function Ga(a){for(var b=new Uint8Array(a.length),c=0;c<a.length;c++){var d=
c;var e=a[c];e=-32768==e?-32767:e;var f=~e>>8&128;f||(e*=-1);32635<e&&(e=32635);if(256<=e){var g=Ha[e>>8&127];e=g<<4|e>>g+3&15}else e>>=4;b[d]=e^f^85}return b}function Ia(a){for(var b=new Int16Array(a.length),c=0;c<a.length;c++){var d=c,e=a[c],f=0;e^=85;e&128&&(e&=-129,f=-1);var g=((e&240)>>4)+4;e=4!=g?1<<g|(e&15)<<g-4|1<<g-5:e<<1|1;b[d]=-8*(0===f?e:-e)}return b}function Ja(a){for(var b=new Uint8Array(a.length),c=0;c<a.length;c++){var d=c,e=a[c];var f=e>>8&128;0!=f&&(e=-e);32635<e&&(e=32635);e+=132;
var g=Ka[e>>7&255];b[d]=~(f|g<<4|e>>g+3&15)}return b}function La(a){for(var b=new Int16Array(a.length),c=0;c<a.length;c++){var d=c,e=a[c];e=~e;var f=e>>4&7;f=Ma[f]+((e&15)<<f+3);0!=(e&128)&&(f=-f);b[d]=f}return b}function W(a,b,c,d){d=void 0===d?a.length:d;if(d%b)throw Error("Bad buffer length.");for(c=void 0===c?0:c;c<d;c+=b){var e=a,f=b,g=c;f--;for(var k=0;k<f;k++){var q=e[g+k];e[g+k]=e[g+f];e[g+f]=q;f--}}}function X(a,b,c){c=void 0===c?0:c;for(var d=0,e=a.length;d<e;d++){var f=a.codePointAt(d);
if(128>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<g;)b[c]=128|f>>6*(g-1)&63,c++,g--}}return c}function Y(a){var b=Math.floor(a);a-=b;return.5>a?b:.5<a?b+1:b%2?b+1:b}function M(a,b,c){c=void 0===c?a.length:c;var d=void 0===b?0:b;c=void 0===c?a.length:c;b="";for(d=void 0===d?0:d;d<c;){var e=128,f=191,g=!1,k=a[d++];if(0<=k&&127>=k)b+=String.fromCharCode(k);else{var q=0;194<=k&&223>=k?q=1:224<=k&&239>=k?(q=2,224===a[d]&&
(e=160),237===a[d]&&(f=159)):240<=k&&244>=k?(q=3,240===a[d]&&(e=144),244===a[d]&&(f=143)):g=!0;k&=(1<<8-q-1)-1;for(var z=0;z<q;z++){if(a[d]<e||a[d]>f)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=[];X(a,b,0);return b}function ia(a,b,c,d,e){d=void 0===d?0:d;b=b||{};e=ja(b.g,b.N,b.F,void 0===e?!1:e);var f=Math.ceil(b.g/8),g=0,k=d;try{for(var q=a.length;g<q;g++)d=
e.fa(c,a[g],d);b.o&&W(c,f,k,d)}catch(z){ka(z,a[g],g)}return d}function J(a,b,c,d,e,f,g){d=void 0===d?0:d;e=void 0===e?a.length:e;f=void 0===f?!1:f;b=b||{};g=ja(b.g,b.N,b.F,void 0===g?!1:g);var k=Math.ceil(b.g/8),q=(e-d)%k;if(f&&(q||a.length<k))throw Error("Bad buffer length");e-=q;f=0;q=d;try{for(b.o&&W(a,k,d,e);q<e;q+=k,f++)c[f]=g.R(a,q);b.o&&W(a,k,d,e)}catch(z){ka(z,a.slice(q,q+k),q)}}function Z(a,b,c,d,e){return ia([a],b,c,void 0===d?0:d,void 0===e?!1:e)}function h(a,b,c){var d=[];Z(a,b,d,0,void 0===
c?!1:c);return d}function P(a,b,c,d){c=void 0===c?0:c;var e=c+Math.ceil(b.g/8);d=void 0===d?!1:d;e=void 0===e?a.length:e;var f=[];J(a,b,f,void 0===c?0:c,e,!0,void 0===d?!1:d);return f[0]}function ka(a,b,c){a.message=a.constructor.name+" at index "+c+": "+b;throw a;}function ja(a,b,c,d){if(b){if(!a||16!==a&&32!==a&&64!==a)throw Error("Unsupported type: float, bits: "+a);}else if(!a||1>a||53<a)throw Error("Unsupported type: int, bits: "+a);return b&&16===a?new K(5,11):b&&32==a?new K(8,23):b&&64==a?
new K(11,52):new E(a,c,d)}function A(a,b,c){c=void 0===c?!0:c;a=x(a);if(c)for(c=a.length;c<b;c++)a.push(0);return a}function la(a,b){for(var c=8===b?255:Math.pow(2,b)/2-1,d=8===b?0:-c-1,e=0,f=a.length;e<f;e++)a[e]=Math.round(a[e]),a[e]>c?a[e]=c:a[e]<d&&(a[e]=d)}function xa(a){return Math.exp(-a/2*a/2)}function wa(a){return function(b){return(0===b?1:Math.sin(Math.PI*b)/(Math.PI*b))*a(b)}}function ua(a,b){return Math.max(0,Math.min(a,b-1))}function ca(a,b){a%=b;0>a&&(a+=b);return a}function va(a,b){var c=
2*(b-1);a=ca(a,c);a>b-1&&(a=c-a);return a}function ma(a,b,c,d){d=void 0===d?{}:d;var e=new Float64Array(a.length*((c-b)/b+1));d.method=d.method||"cubic";var f=new v(a.length,e.length,{method:d.method,tension:d.tension||0,sincFilterSize:d.sincFilterSize||6,sincWindow:d.sincWindow||void 0,clip:d.clip||"mirror"});void 0===d.LPF&&(d.LPF=Na[d.method]);if(d.LPF){d.LPFType=d.LPFType||"IIR";var g=Oa[d.LPFType];if(c>b){b=new g(d.LPForder||na[d.LPFType],c,b/2);c=0;for(d=e.length;c<d;c++)e[c]=b.filter(f.O(c,
a));b.reset();for(a=e.length-1;0<=a;a--)e[a]=b.filter(e[a])}else{b=new g(d.LPForder||na[d.LPFType],b,c/2);c=0;for(d=a.length;c<d;c++)a[c]=b.filter(a[c]);b.reset();for(c=a.length-1;0<=c;c--)a[c]=b.filter(a[c]);oa(a,e,f)}}else oa(a,e,f);return e}function oa(a,b,c){for(var d=0,e=b.length;d<e;d++)b[d]=c.O(d,a)}function N(a,b){var c=a/b;c%2&&c++;return c}var ha=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],U=[7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,
157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767],G=0,I=0,D=0,F=0,L=7,Ha=[1,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],Ka=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],Ma=[0,132,396,924,1980,4092,8316,16764];E.prototype.fa=function(a,b,c){c=void 0===c?0:c;if(b!==b||b.constructor!=Number)throw new TypeError;b=this.a(b);a[c]=(0>b?b+Math.pow(2,this.g):b)&255;c++;for(var d=2,e=this.b;d<e;d++)a[c]=Math.floor(b/Math.pow(2,8*(d-1)))&255,c++;8<this.g&&(a[c]=Math.floor(b/Math.pow(2,8*(this.b-1)))&this.f,c++);return c};E.prototype.c=function(a,b){b=void 0===b?0:b;for(var c=0,d=0;d<this.b;d++)c+=a[b+
d]*Math.pow(256,d);return c};E.prototype.l=function(a,b){return this.a(this.c(a,void 0===b?0:b))};E.prototype.i=function(a,b){return this.a(this.j(this.c(a,void 0===b?0:b)))};E.prototype.a=function(a){if(a>this.max||a<this.min)throw new RangeError;return a};E.prototype.h=function(a){return a>this.max?this.max:a<this.min?this.min:a};E.prototype.j=function(a){a>this.max&&(a-=2*this.max+2);return a};K.prototype.fa=function(a,b,c){if("number"!=typeof b)throw new TypeError;Math.abs(b)>this.h-2*this.j&&
(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=Y(b/Math.pow(2,e)*Math.pow(2,this.c));b!==b?(f=Math.pow(2,this.c-1),e=(1<<this.b)-1):0!==b&&(b>=Math.pow(2,1-this.a)?(2<=f/Math.pow(2,this.c)&&(e+=1,f=1),e>this.a?(e=(1<<this.b)-1,f=0):(e+=this.a,f=Y(f)-Math.pow(2,this.c))):(f=Y(b/Math.pow(2,1-this.a-this.c)),e=0));return this.l(a,c,d,e,f)};K.prototype.R=function(a,b){for(var c=(1<<this.b)-1,d="",e=this.f-1;0<=e;e--){var f=
a[e+b].toString(2);d+="00000000".substring(f.length)+f}e="1"==d.charAt(0)?-1:1;d=d.substring(1);f=parseInt(d.substring(0,this.b),2);d=d.substring(this.b);if(f==c)return 0!==parseInt(d,2)?NaN:Infinity*e;0===f?(f+=1,c=parseInt(d,2)):c=parseInt("1"+d,2);return e*c*this.i*Math.pow(2,f-this.a)};K.prototype.l=function(a,b,c,d,e){var f=[];f.push(c);for(c=this.b;0<c;--c)f[c]=d%2?1:0,d=Math.floor(d/2);d=f.length;for(c=this.c;0<c;--c)f[d+c]=e%2?1:0,e=Math.floor(e/2);e=f.join("");f=this.f+b-1;for(d=b;f>=b;)a[f]=
parseInt(e.substring(0,8),2),e=e.substring(8),f--,d++;return d};B.prototype.ua=function(a){this.c=0;this.container=this.s(a,4);if(-1===this.Y.indexOf(this.container))throw Error("Not a supported format.");this.a.o="RIFX"===this.container;this.chunkSize=this.b(a);this.format=this.s(a,4);this.X={chunkId:this.container,chunkSize:this.chunkSize,format:this.format,subChunks:this.U(a)}};B.prototype.l=function(a,b){b=void 0===b?!1:b;for(var c=this.X.subChunks,d=[],e=0;e<c.length;e++)if(c[e].chunkId==a)if(b)d.push(c[e]);
else return c[e];return"LIST"==a?d.length?d:null:null};B.prototype.s=function(a,b){var c=M(a,this.c,this.c+b);this.c+=b;return c};B.prototype.b=function(a){a=P(a,this.a,this.c);this.c+=4;return a};B.prototype.U=function(a){for(var b=[],c=this.c;c<=a.length-8;)b.push(this.Za(a,c)),c+=8+b[b.length-1].chunkSize,c=c%2?c+1:c;return b};B.prototype.Za=function(a,b){var c={chunkId:this.Da(a,b),chunkSize:this.Ea(a,b)};"LIST"==c.chunkId?(c.format=M(a,b+8,b+12),this.c+=4,c.subChunks=this.U(a)):(this.c=b+8+(c.chunkSize%
2?c.chunkSize+1:c.chunkSize),c.chunkData={start:b+8,end:this.c});return c};B.prototype.Da=function(a,b){this.c+=4;return M(a,b,b+4)};B.prototype.Ea=function(a,b){this.c+=4;return P(a,this.a,b+4)};Q(u,B);u.prototype.fromBuffer=function(a,b){b=void 0===b?!0:b;this.T();this.ua(a);this.h.o=this.a.o;if("WAVE"!=this.format)throw Error('Could not find the "WAVE" format identifier');this.gb(a);this.ib(a);this.hb(a);this.cb(a);this.pa(a);this.eb(a);this.la(a);this.fb(a,b);this.kb(a);this.ha(a);this.ma(a)};
u.prototype.T=function(){var a=new u;Object.assign(this.fmt,a.fmt);Object.assign(this.fact,a.fact);Object.assign(this.cue,a.cue);Object.assign(this.smpl,a.smpl);Object.assign(this.bext,a.bext);Object.assign(this.iXML,a.iXML);Object.assign(this.ds64,a.ds64);Object.assign(this.data,a.data);this.LIST=[];Object.assign(this.junk,a.junk);Object.assign(this._PMX,a._PMX)};u.prototype.ib=function(a){var b=this.l("fmt ");if(b)this.c=b.chunkData.start,this.fmt.chunkId=b.chunkId,this.fmt.chunkSize=b.chunkSize,
this.fmt.audioFormat=this.j(a),this.fmt.numChannels=this.j(a),this.fmt.sampleRate=this.b(a),this.fmt.byteRate=this.b(a),this.fmt.blockAlign=this.j(a),this.fmt.bitsPerSample=this.j(a),this.jb(a);else throw Error('Could not find the "fmt " chunk');};u.prototype.jb=function(a){16<this.fmt.chunkSize&&(this.fmt.cbSize=this.j(a),18<this.fmt.chunkSize&&(this.fmt.validBitsPerSample=this.j(a),20<this.fmt.chunkSize&&(this.fmt.dwChannelMask=this.b(a),this.fmt.subformat=[this.b(a),this.b(a),this.b(a),this.b(a)])))};
u.prototype.hb=function(a){var b=this.l("fact");b&&(this.c=b.chunkData.start,this.fact.chunkId=b.chunkId,this.fact.chunkSize=b.chunkSize,this.fact.dwSampleLength=this.b(a))};u.prototype.eb=function(a){var b=this.l("cue ");if(b)for(this.c=b.chunkData.start,this.cue.chunkId=b.chunkId,this.cue.chunkSize=b.chunkSize,this.cue.dwCuePoints=this.b(a),b=0;b<this.cue.dwCuePoints;b++)this.cue.points.push({dwName:this.b(a),dwPosition:this.b(a),fccChunk:this.s(a,4),dwChunkStart:this.b(a),dwBlockStart:this.b(a),
dwSampleOffset:this.b(a)})};u.prototype.la=function(a){var b=this.l("smpl");if(b)for(this.c=b.chunkData.start,this.smpl.chunkId=b.chunkId,this.smpl.chunkSize=b.chunkSize,this.smpl.dwManufacturer=this.b(a),this.smpl.dwProduct=this.b(a),this.smpl.dwSamplePeriod=this.b(a),this.smpl.dwMIDIUnityNote=this.b(a),this.smpl.dwMIDIPitchFraction=this.b(a),this.smpl.dwSMPTEFormat=this.b(a),this.smpl.dwSMPTEOffset=this.b(a),this.smpl.dwNumSampleLoops=this.b(a),this.smpl.dwSamplerData=this.b(a),b=0;b<this.smpl.dwNumSampleLoops;b++)this.smpl.loops.push({dwName:this.b(a),
dwType:this.b(a),dwStart:this.b(a),dwEnd:this.b(a),dwFraction:this.b(a),dwPlayCount:this.b(a)})};u.prototype.fb=function(a,b){var c=this.l("data");if(c)this.data.chunkId="data",this.data.chunkSize=c.chunkSize,b&&(this.data.samples=a.slice(c.chunkData.start,c.chunkData.end));else throw Error('Could not find the "data" chunk');};u.prototype.cb=function(a){var b=this.l("bext");b&&(this.c=b.chunkData.start,this.bext.chunkId=b.chunkId,this.bext.chunkSize=b.chunkSize,this.bext.description=this.s(a,256),
this.bext.originator=this.s(a,32),this.bext.originatorReference=this.s(a,32),this.bext.originationDate=this.s(a,10),this.bext.originationTime=this.s(a,8),this.bext.timeReference=[this.b(a),this.b(a)],this.bext.version=this.j(a),this.bext.UMID=this.s(a,64),this.bext.loudnessValue=this.j(a),this.bext.loudnessRange=this.j(a),this.bext.maxTruePeakLevel=this.j(a),this.bext.maxMomentaryLoudness=this.j(a),this.bext.maxShortTermLoudness=this.j(a),this.bext.reserved=this.s(a,180),this.bext.codingHistory=this.s(a,
this.bext.chunkSize-602))};u.prototype.pa=function(a){var b=this.l("iXML");b&&(this.c=b.chunkData.start,this.iXML.chunkId=b.chunkId,this.iXML.chunkSize=b.chunkSize,this.iXML.value=M(a,this.c,this.c+this.iXML.chunkSize))};u.prototype.gb=function(a){var b=this.l("ds64");if(b)this.c=b.chunkData.start,this.ds64.chunkId=b.chunkId,this.ds64.chunkSize=b.chunkSize,this.ds64.riffSizeHigh=this.b(a),this.ds64.riffSizeLow=this.b(a),this.ds64.dataSizeHigh=this.b(a),this.ds64.dataSizeLow=this.b(a),this.ds64.originationTime=
this.b(a),this.ds64.sampleCountHigh=this.b(a),this.ds64.sampleCountLow=this.b(a);else if("RF64"==this.container)throw Error('Could not find the "ds64" chunk');};u.prototype.ha=function(a){var b=this.l("LIST",!0);if(null!==b)for(var c=0;c<b.length;c++){var d=b[c];this.LIST.push({chunkId:d.chunkId,chunkSize:d.chunkSize,format:d.format,subChunks:[]});for(var e=0;e<d.subChunks.length;e++)this.ja(d.subChunks[e],d.format,a)}};u.prototype.ja=function(a,b,c){"adtl"==b?-1<["labl","note","ltxt"].indexOf(a.chunkId)&&
this.ka(c,a):"INFO"==b&&this.ia(c,a)};u.prototype.ka=function(a,b){this.c=b.chunkData.start;var c={chunkId:b.chunkId,chunkSize:b.chunkSize,dwName:this.b(a)};"ltxt"==b.chunkId?(c.dwSampleLength=this.b(a),c.dwPurposeID=this.b(a),c.dwCountry=this.j(a),c.dwLanguage=this.j(a),c.dwDialect=this.j(a),c.dwCodePage=this.j(a),c.value=""):c.value=this.W(a,this.c);this.LIST[this.LIST.length-1].subChunks.push(c)};u.prototype.ia=function(a,b){this.c=b.chunkData.start;this.LIST[this.LIST.length-1].subChunks.push({chunkId:b.chunkId,
chunkSize:b.chunkSize,value:this.W(a,this.c)})};u.prototype.kb=function(a){var b=this.l("junk");b&&(this.junk={chunkId:b.chunkId,chunkSize:b.chunkSize,chunkData:[].slice.call(a.slice(b.chunkData.start,b.chunkData.end))})};u.prototype.ma=function(a){var b=this.l("_PMX");b&&(this.c=b.chunkData.start,this._PMX.chunkId=b.chunkId,this._PMX.chunkSize=b.chunkSize,this._PMX.value=M(a,this.c,this.c+this._PMX.chunkSize))};u.prototype.W=function(a,b){for(var c=b=void 0===b?0:b;c<a.length&&(this.c++,0!==a[c]);c++);
return M(a,b,this.c-1)};u.prototype.j=function(a){a=P(a,this.h,this.c);this.c+=2;return a};Q(r,u);r.prototype.toBuffer=function(){this.h.o="RIFX"===this.container;this.a.o=this.h.o;for(var a=[this.Ra(),this.Na(),this.Ca(),this.ab(),this.Pa(),this.Oa(),x(this.data.chunkId),h(this.data.samples.length,this.a),this.data.samples,this.Fa(),this.Xa(),this.Sa(),this.$a()],b=0,c=0;c<a.length;c++)b+=a[c].length;c=new Uint8Array(b+12);var d=X(this.container,c,0);d=Z(b+4,this.a,c,d);d=X(this.format,c,void 0===
d?0:d);for(b=0;b<a.length;b++)c.set(a[b],d),d+=a[b].length;return c};r.prototype.Ca=function(){var a=[];this.Ba();this.bext.chunkId&&(this.bext.chunkSize=602+this.bext.codingHistory.length,a=a.concat(x(this.bext.chunkId),h(602+this.bext.codingHistory.length,this.a),A(this.bext.description,256),A(this.bext.originator,32),A(this.bext.originatorReference,32),A(this.bext.originationDate,10),A(this.bext.originationTime,8),h(this.bext.timeReference[0],this.a),h(this.bext.timeReference[1],this.a),h(this.bext.version,
this.h),A(this.bext.UMID,64),h(this.bext.loudnessValue,this.h),h(this.bext.loudnessRange,this.h),h(this.bext.maxTruePeakLevel,this.h),h(this.bext.maxMomentaryLoudness,this.h),h(this.bext.maxShortTermLoudness,this.h),A(this.bext.reserved,180),A(this.bext.codingHistory,this.bext.codingHistory.length)));this.i(a);return a};r.prototype.Ba=function(){for(var a in this.bext)if(this.bext.hasOwnProperty(a)&&this.bext[a]&&"timeReference"!=a){this.bext.chunkId="bext";break}if(this.bext.timeReference[0]||this.bext.timeReference[1])this.bext.chunkId=
"bext"};r.prototype.ab=function(){var a=[];if(this.iXML.chunkId){var b=x(this.iXML.value);this.iXML.chunkSize=b.length;a=a.concat(x(this.iXML.chunkId),h(this.iXML.chunkSize,this.a),b)}this.i(a);return a};r.prototype.Na=function(){var a=[];this.ds64.chunkId&&(a=a.concat(x(this.ds64.chunkId),h(this.ds64.chunkSize,this.a),h(this.ds64.riffSizeHigh,this.a),h(this.ds64.riffSizeLow,this.a),h(this.ds64.dataSizeHigh,this.a),h(this.ds64.dataSizeLow,this.a),h(this.ds64.originationTime,this.a),h(this.ds64.sampleCountHigh,
this.a),h(this.ds64.sampleCountLow,this.a)));this.i(a);return a};r.prototype.Fa=function(){var a=[];if(this.cue.chunkId){var b=this.Ia();a=a.concat(x(this.cue.chunkId),h(b.length+4,this.a),h(this.cue.dwCuePoints,this.a),b)}this.i(a);return a};r.prototype.Ia=function(){for(var a=[],b=0;b<this.cue.dwCuePoints;b++)a=a.concat(h(this.cue.points[b].dwName,this.a),h(this.cue.points[b].dwPosition,this.a),x(this.cue.points[b].fccChunk),h(this.cue.points[b].dwChunkStart,this.a),h(this.cue.points[b].dwBlockStart,
this.a),h(this.cue.points[b].dwSampleOffset,this.a));return a};r.prototype.Xa=function(){var a=[];if(this.smpl.chunkId){var b=this.Ya();a=a.concat(x(this.smpl.chunkId),h(b.length+36,this.a),h(this.smpl.dwManufacturer,this.a),h(this.smpl.dwProduct,this.a),h(this.smpl.dwSamplePeriod,this.a),h(this.smpl.dwMIDIUnityNote,this.a),h(this.smpl.dwMIDIPitchFraction,this.a),h(this.smpl.dwSMPTEFormat,this.a),h(this.smpl.dwSMPTEOffset,this.a),h(this.smpl.dwNumSampleLoops,this.a),h(this.smpl.dwSamplerData,this.a),
b)}this.i(a);return a};r.prototype.Ya=function(){for(var a=[],b=0;b<this.smpl.dwNumSampleLoops;b++)a=a.concat(h(this.smpl.loops[b].dwName,this.a),h(this.smpl.loops[b].dwType,this.a),h(this.smpl.loops[b].dwStart,this.a),h(this.smpl.loops[b].dwEnd,this.a),h(this.smpl.loops[b].dwFraction,this.a),h(this.smpl.loops[b].dwPlayCount,this.a));return a};r.prototype.Oa=function(){var a=[];this.fact.chunkId&&(a=a.concat(x(this.fact.chunkId),h(this.fact.chunkSize,this.a),h(this.fact.dwSampleLength,this.a)));this.i(a);
return a};r.prototype.Pa=function(){var a=[];if(this.fmt.chunkId)return a=a.concat(x(this.fmt.chunkId),h(this.fmt.chunkSize,this.a),h(this.fmt.audioFormat,this.h),h(this.fmt.numChannels,this.h),h(this.fmt.sampleRate,this.a),h(this.fmt.byteRate,this.a),h(this.fmt.blockAlign,this.h),h(this.fmt.bitsPerSample,this.h),this.Qa()),this.i(a),a;throw Error('Could not find the "fmt " chunk');};r.prototype.Qa=function(){var a=[];16<this.fmt.chunkSize&&(a=a.concat(h(this.fmt.cbSize,this.h)));18<this.fmt.chunkSize&&
(a=a.concat(h(this.fmt.validBitsPerSample,this.h)));20<this.fmt.chunkSize&&(a=a.concat(h(this.fmt.dwChannelMask,this.a)));24<this.fmt.chunkSize&&(a=a.concat(h(this.fmt.subformat[0],this.a),h(this.fmt.subformat[1],this.a),h(this.fmt.subformat[2],this.a),h(this.fmt.subformat[3],this.a)));return a};r.prototype.Sa=function(){for(var a=[],b=0;b<this.LIST.length;b++){var c=this.Ua(this.LIST[b].subChunks,this.LIST[b].format);a=a.concat(x(this.LIST[b].chunkId),h(c.length+4,this.a),x(this.LIST[b].format),
c)}this.i(a);return a};r.prototype.Ua=function(a,b){for(var c=[],d=0,e=a.length;d<e;d++)"INFO"==b?c=c.concat(this.Ta(a[d])):"adtl"==b&&(c=c.concat(this.Va(a[d]))),this.i(c);return c};r.prototype.Ta=function(a){var b=[],c=A(a.value,a.value.length);b=b.concat(x(a.chunkId),h(c.length+1,this.a),c);b.push(0);return b};r.prototype.Va=function(a){var b=[];if(-1<["labl","note"].indexOf(a.chunkId)){var c=A(a.value,a.value.length);b=b.concat(x(a.chunkId),h(c.length+5,this.a),h(a.dwName,this.a),c);b.push(0)}else"ltxt"==
a.chunkId&&(b=b.concat(this.Wa(a)));return b};r.prototype.Wa=function(a){return x(a.chunkId).concat(h(a.value.length+20,this.a),h(a.dwName,this.a),h(a.dwSampleLength,this.a),h(a.dwPurposeID,this.a),h(a.dwCountry,this.h),h(a.dwLanguage,this.h),h(a.dwDialect,this.h),h(a.dwCodePage,this.h),A(a.value,a.value.length))};r.prototype.$a=function(){var a=[];if(this._PMX.chunkId){var b=x(this._PMX.value);this._PMX.chunkSize=b.length;a=a.concat(x(this._PMX.chunkId),h(this._PMX.chunkSize,this.a),b)}this.i(a);
return a};r.prototype.Ra=function(){var a=[];if(this.junk.chunkId)return a.concat(x(this.junk.chunkId),h(this.junk.chunkData.length,this.a),this.junk.chunkData);this.i(a);return a};r.prototype.i=function(a){a.length%2&&a.push(0)};Q(t,r);t.prototype.fromScratch=function(a,b,c,d,e){e=void 0===e?{}:e;this.T();this.V(a,b,c,d,e)};t.prototype.fromBuffer=function(a,b){r.prototype.fromBuffer.call(this,a,void 0===b?!0:b);this.xa();this.Z()};t.prototype.toBuffer=function(){this.$();return r.prototype.toBuffer.call(this)};
t.prototype.getSamples=function(a,b){a=void 0===a?!1:a;b=void 0===b?Float64Array:b;var c=new b(this.data.samples.length/(this.f.g/8));J(this.data.samples,this.f,c,0,this.data.samples.length,!1,!1);if(!a&&1<this.fmt.numChannels){var d=this.fmt.numChannels,e=b;e=void 0===e?Float64Array:e;for(var f=[],g=0;g<d;g++)f[g]=new e(c.length/d);for(e=0;e<d;e++){g=0;for(var k=e;k<c.length;k+=d)f[e][g++]=c[k]}c=f}return c};t.prototype.getSample=function(a){a*=this.f.g/8;if(a+this.f.g/8>this.data.samples.length)throw Error("Range error");
return P(this.data.samples.slice(a,a+this.f.g/8),this.f,0,!1)};t.prototype.setSample=function(a,b){a*=this.f.g/8;if(a+this.f.g/8>this.data.samples.length)throw Error("Range error");Z(b,this.f,this.data.samples,a,!1)};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.V=function(a,b,c,d,e){e=void 0===e?{}:e;e.container||(e.container="RIFF");this.container=e.container;this.bitDepth=c;var f=[];if(0<d.length)if(d[0].constructor!==Number){f=new Float64Array(d[0].length*d.length);for(var g=0,k=0,q=d[0].length;k<q;k++)for(var z=0,Pa=d.length;z<Pa;z++)f[g]=d[z][k],g++}else f=d;d=f;this.Z();f=this.f.g/8;this.data.samples=new Uint8Array(d.length*f);ia(d,
this.f,this.data.samples,0,!1);this.bb(c,a,b,f,this.data.samples.length,e);this.data.chunkId="data";this.data.chunkSize=this.data.samples.length;this.$()};t.prototype.bb=function(a,b,c,d,e,f){"4"==a?this.ya(a,b,c,d,e,f):"8a"==a||"8m"==a?this.za(a,b,c,d,e,f):-1==Object.keys(this.G).indexOf(a)||2<b?this.Aa(a,b,c,d,e,f):this.B(a,b,c,d,e,f)};t.prototype.B=function(a,b,c,d,e,f){this.container=f.container;this.chunkSize=36+e;this.format="WAVE";this.bitDepth=a;this.fmt={chunkId:"fmt ",chunkSize:16,audioFormat:this.G[a]||
65534,numChannels:b,sampleRate:c,byteRate:b*d*c,blockAlign:b*d,bitsPerSample:parseInt(a,10),cbSize:0,validBitsPerSample:0,dwChannelMask:0,subformat:[]}};t.prototype.ya=function(a,b,c,d,e,f){this.B(a,b,c,d,e,f);this.chunkSize=40+e;this.fmt.chunkSize=20;this.fmt.byteRate=4055;this.fmt.blockAlign=256;this.fmt.bitsPerSample=4;this.fmt.cbSize=2;this.fmt.validBitsPerSample=505;this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:2*e}};t.prototype.Aa=function(a,b,c,d,e,f){this.B(a,b,c,d,e,f);this.chunkSize=
60+e;this.fmt.chunkSize=40;this.fmt.bitsPerSample=(parseInt(a,10)-1|7)+1;this.fmt.cbSize=22;this.fmt.validBitsPerSample=parseInt(a,10);a=this.fmt;c=0;1===b?c=4:2===b?c=3:4===b?c=51:6===b?c=63:8===b&&(c=1599);a.dwChannelMask=c;this.fmt.subformat=[1,1048576,2852126848,1905997824]};t.prototype.za=function(a,b,c,d,e,f){this.B(a,b,c,d,e,f);this.chunkSize=40+e;this.fmt.chunkSize=20;this.fmt.cbSize=2;this.fmt.validBitsPerSample=8;this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:e}};t.prototype.xa=function(){3===
this.fmt.audioFormat&&32===this.fmt.bitsPerSample?this.bitDepth="32f":6===this.fmt.audioFormat?this.bitDepth="8a":7===this.fmt.audioFormat?this.bitDepth="8m":this.bitDepth=this.fmt.bitsPerSample.toString()};t.prototype.va=function(){if(!(this.G[this.bitDepth]||8<parseInt(this.bitDepth,10)&&54>parseInt(this.bitDepth,10)))throw Error("Invalid bit depth.");};t.prototype.Z=function(){this.f={g:(parseInt(this.bitDepth,10)-1|7)+1,N:"32f"==this.bitDepth||"64"==this.bitDepth,F:"8"!=this.bitDepth,o:"RIFX"==
this.container};-1<["4","8a","8m"].indexOf(this.bitDepth)&&(this.f.g=8,this.f.F=!1)};t.prototype.$=function(){this.va();var a=this.fmt.numChannels;if(1>a||65535<a*this.fmt.bitsPerSample/8)throw Error("Invalid number of channels.");a=this.fmt.sampleRate;if(1>a||4294967295<this.fmt.bitsPerSample/8*this.fmt.numChannels*a)throw Error("Invalid sample rate.");};Q(C,t);C.prototype.getTag=function(a){a=this.K(a);return null!==a.w?this.LIST[a.LIST].subChunks[a.w].value:null};C.prototype.setTag=function(a,
b){var c=a;if(c.constructor!==String)throw Error("Invalid tag name.");if(4>c.length)for(var d=0,e=4-c.length;d<e;d++)c+=" ";a=c;c=this.K(a);null!==c.w?(this.LIST[c.LIST].subChunks[c.w].chunkSize=b.length+1,this.LIST[c.LIST].subChunks[c.w].value=b):null!==c.LIST?this.LIST[c.LIST].subChunks.push({chunkId:a,chunkSize:b.length+1,value:b}):(this.LIST.push({chunkId:"LIST",chunkSize:b.length+9,format:"INFO",subChunks:[]}),this.LIST[this.LIST.length-1].subChunks.push({chunkId:a,chunkSize:b.length+1,value:b}))};
C.prototype.deleteTag=function(a){a=this.K(a);return null!==a.w?(this.LIST[a.LIST].subChunks.splice(a.w,1),!0):!1};C.prototype.listTags=function(){var a=this.C("INFO"),b={};if(null!==a)for(var c=0,d=this.LIST[a].subChunks.length;c<d;c++)b[this.LIST[a].subChunks[c].chunkId]=this.LIST[a].subChunks[c].value;return b};C.prototype.C=function(a){for(var b=0,c=this.LIST.length;b<c;b++)if(this.LIST[b].format==a)return b;return null};C.prototype.K=function(a){for(var b={LIST:null,w:null},c=0,d=this.LIST.length;c<
d;c++)if("INFO"==this.LIST[c].format){b.LIST=c;d=0;for(var e=this.LIST[c].subChunks.length;d<e;d++)if(this.LIST[c].subChunks[d].chunkId==a){b.w=d;break}break}return b};Q(w,C);w.prototype.listCuePoints=function(){for(var a=this.J(),b=0,c=a.length;b<c;b++)a[b].position=a[b].dwSampleOffset/this.fmt.sampleRate*1E3,a[b].dwSampleLength?(a[b].end=a[b].dwSampleLength/this.fmt.sampleRate*1E3,a[b].end+=a[b].position):a[b].end=null,delete a[b].value;return a};w.prototype.setCuePoint=function(a){this.cue.chunkId=
"cue ";a.label||(a.label="");var b=this.J();this.I();this.cue.points=[];a.dwSampleOffset=a.position*this.fmt.sampleRate/1E3;a.dwSampleLength=0;a.end&&(a.dwSampleLength=a.end*this.fmt.sampleRate/1E3-a.dwSampleOffset);0===b.length?this.v(a,1):this.qa(b,a);this.cue.dwCuePoints=this.cue.points.length};w.prototype.deleteCuePoint=function(a){this.cue.chunkId="cue ";var b=this.J();this.I();var c=this.cue.points.length;this.cue.points=[];for(var d=0;d<c;d++)d+1!==a&&this.v(b[d],d+1);this.cue.dwCuePoints=
this.cue.points.length;this.cue.dwCuePoints?this.cue.chunkId="cue ":(this.cue.chunkId="",this.I())};w.prototype.updateLabel=function(a,b){var c=this.C("adtl");if(null!==c)for(var d=0,e=this.LIST[c].subChunks.length;d<e;d++)this.LIST[c].subChunks[d].dwName==a&&(this.LIST[c].subChunks[d].value=b)};w.prototype.J=function(){for(var a=[],b=0;b<this.cue.points.length;b++){var c=this.cue.points[b],d=this.Ma(c.dwName);d.label=d.value?d.value:"";d.dwPosition=c.dwPosition;d.fccChunk=c.fccChunk;d.dwChunkStart=
c.dwChunkStart;d.dwBlockStart=c.dwBlockStart;d.dwSampleOffset=c.dwSampleOffset;a.push(d)}return a};w.prototype.Ma=function(a){var b=this.C("adtl"),c={};null!==b&&this.ga(c,b,a);return c};w.prototype.ga=function(a,b,c){for(var d=0,e=this.LIST[b].subChunks.length;d<e;d++)if(this.LIST[b].subChunks[d].dwName==c){var f=this.LIST[b].subChunks[d];a.value=f.value||a.value;a.dwName=f.dwName||0;a.dwSampleLength=f.dwSampleLength||0;a.dwPurposeID=f.dwPurposeID||0;a.dwCountry=f.dwCountry||0;a.dwLanguage=f.dwLanguage||
0;a.dwDialect=f.dwDialect||0;a.dwCodePage=f.dwCodePage||0}};w.prototype.v=function(a,b){this.cue.points.push({dwName:b,dwPosition:a.dwPosition?a.dwPosition:0,fccChunk:a.fccChunk?a.fccChunk:"data",dwChunkStart:a.dwChunkStart?a.dwChunkStart:0,dwBlockStart:a.dwBlockStart?a.dwBlockStart:0,dwSampleOffset:a.dwSampleOffset});this.sa(a,b)};w.prototype.qa=function(a,b){for(var c=!1,d=0;d<a.length;d++)a[d].dwSampleOffset>b.dwSampleOffset&&!c?(this.v(b,d+1),this.v(a[d],d+2),c=!0):this.v(a[d],c?d+2:d+1);c||this.v(b,
this.cue.points.length+1)};w.prototype.I=function(){for(var a=0,b=this.LIST.length;a<b;a++)"adtl"==this.LIST[a].format&&this.LIST.splice(a)};w.prototype.sa=function(a,b){var c=this.C("adtl");null===c&&(this.LIST.push({chunkId:"LIST",chunkSize:4,format:"adtl",subChunks:[]}),c=this.LIST.length-1);this.ra(c,a,b);a.dwSampleLength&&this.ta(c,a,b)};w.prototype.ra=function(a,b,c){this.LIST[a].subChunks.push({chunkId:"labl",chunkSize:4,dwName:c,value:b.label});this.LIST[a].chunkSize+=12};w.prototype.ta=function(a,
b,c){this.LIST[a].subChunks.push({chunkId:"ltxt",chunkSize:20,dwName:c,dwSampleLength:b.dwSampleLength,dwPurposeID:b.dwPurposeID||0,dwCountry:b.dwCountry||0,dwLanguage:b.dwLanguage||0,dwDialect:b.dwDialect||0,dwCodePage:b.dwCodePage||0,value:b.label});this.LIST[a].chunkSize+=28};v.prototype.I=function(a,b){return this.f(Math.round(this.i*a),b)};v.prototype.H=function(a,b){a*=this.i;var c=Math.floor(a);a-=c;return(1-a)*this.f(c,b)+a*this.f(c+1,b)};v.prototype.C=function(a,b){a*=this.i;var c=Math.floor(a),
d=[this.u(c,b),this.u(c+1,b)],e=[this.f(c,b),this.f(c+1,b)];a-=c;c=a*a;var f=a*c;return(2*f-3*c+1)*e[0]+(f-2*c+a)*d[0]+(-2*f+3*c)*e[1]+(f-c)*d[1]};v.prototype.J=function(a,b){a*=this.i;var c=Math.floor(a),d=c+this.B,e=0;for(c=c-this.B+1;c<=d;c++)e+=this.G(a-c)*this.f(c,b);return e};v.prototype.u=function(a,b){return this.K*(this.f(a+1,b)-this.f(a-1,b))/2};v.prototype.f=function(a,b){return 0<=a&&a<this.v?b[a]:b[this.m(a,this.v)]};y.prototype.filter=function(a){this.z.M[this.z.P]=a;for(var b=a=0,c=
this.z.M.length;b<c;b++)a+=this.a[b]*this.z.M[(this.z.P+b)%this.z.M.length];this.z.P=(this.z.P+1)%this.z.M.length;return a};y.prototype.reset=function(){this.z=this.b()};y.prototype.b=function(){for(var a=[],b=0;b<this.a.length-1;b++)a.push(0);return{M:a,P:0}};p.prototype.filter=function(a){for(var b=0,c=this.a.length;b<c;b++)a=this.f(b,a);return a};p.prototype.b=function(a){var b={z:[0,0],D:[],A:[]};a=this.c(a,b);b.k=1;b.A.push((1-a.aa)/(2*a.L));b.A.push(2*b.A[0]);b.A.push(b.A[0]);return b};p.prototype.c=
function(a,b){var c={},d=2*Math.PI*a.na/a.oa;c.alpha=Math.sin(d)/(2*a.Q);c.aa=Math.cos(d);c.L=1+c.alpha;b.L=c.L;b.D.push(-2*c.aa/c.L);b.k=1;b.D.push((1-c.alpha)/c.L);return c};p.prototype.f=function(a,b){var c=b*this.a[a].k-this.a[a].Ga*this.a[a].z[0]-this.a[a].Ha*this.a[a].z[1],d=this.a[a].Ja*c+this.a[a].Ka*this.a[a].z[0]+this.a[a].La*this.a[a].z[1];this.a[a].z[1]=this.a[a].z[0];this.a[a].z[0]=c;return d};p.prototype.reset=function(){for(var a=0;a<this.a.length;a++)this.a[a].z=[0,0]};var Na={point:!1,
linear:!1,cubic:!0,sinc:!0},na={IIR:16,FIR:71},Oa={IIR:p,FIR:y};Q(l,w);l.prototype.toRIFF=function(){var a=new Float64Array(N(this.data.samples.length,this.f.g/8));J(this.data.samples,this.f,a,0,this.data.samples.length,!1,!1);this.m(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,a)};l.prototype.toRIFX=function(){var a=new Float64Array(N(this.data.samples.length,this.f.g/8));J(this.data.samples,this.f,a,0,this.data.samples.length,!1,!1);this.m(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,
a,{container:"RIFX"})};l.prototype.toIMAADPCM=function(){if(8E3!==this.fmt.sampleRate)throw Error("Only 8000 Hz files can be compressed as IMA-ADPCM.");if(1!==this.fmt.numChannels)throw Error("Only mono files can be compressed as IMA-ADPCM.");this.H();var a=new Int16Array(N(this.data.samples.length,2));J(this.data.samples,this.f,a,0,this.data.samples.length,!1,!1);this.m(this.fmt.numChannels,this.fmt.sampleRate,"4",Da(a),{container:this.u()})};l.prototype.fromIMAADPCM=function(a){a=void 0===a?"16":
a;this.m(this.fmt.numChannels,this.fmt.sampleRate,"16",Fa(this.data.samples,this.fmt.blockAlign),{container:this.u()});"16"!=a&&this.toBitDepth(a)};l.prototype.toALaw=function(){this.H();var a=new Int16Array(N(this.data.samples.length,2));J(this.data.samples,this.f,a,0,this.data.samples.length,!1,!1);this.m(this.fmt.numChannels,this.fmt.sampleRate,"8a",Ga(a),{container:this.u()})};l.prototype.fromALaw=function(a){a=void 0===a?"16":a;this.m(this.fmt.numChannels,this.fmt.sampleRate,"16",Ia(this.data.samples),
{container:this.u()});"16"!=a&&this.toBitDepth(a)};l.prototype.toMuLaw=function(){this.H();var a=new Int16Array(N(this.data.samples.length,2));J(this.data.samples,this.f,a,0,this.data.samples.length,!1,!1);this.m(this.fmt.numChannels,this.fmt.sampleRate,"8m",Ja(a),{container:this.u()})};l.prototype.fromMuLaw=function(a){a=void 0===a?"16":a;this.m(this.fmt.numChannels,this.fmt.sampleRate,"16",La(this.data.samples),{container:this.u()});"16"!=a&&this.toBitDepth(a)};l.prototype.toBitDepth=function(a,
b){var c=a,d=this.bitDepth;void 0===b||b||("32f"!=a&&(c=this.f.g.toString()),d=""+this.f.g);this.S();var e=this.getSamples(!0),f=new Float64Array(e.length),g=d;if(-1<["32f","64"].indexOf(g)&&-1<["32f","64"].indexOf(c))f.set(e);else{da(g);da(c);d=Ca(g,c);var k={ea:Math.pow(2,parseInt(g,10))/2,ca:Math.pow(2,parseInt(c,10))/2,da:Math.pow(2,parseInt(g,10))/2-1,ba:Math.pow(2,parseInt(c,10))/2-1};ea(g,e,!0);if(-1<["32f","64"].indexOf(g)){g=e.length;for(var q=0;q<g;q++)1<e[q]?e[q]=1:-1>e[q]&&(e[q]=-1)}for(g=
0;g<e.length;g++)f[g]=d(e[g],k);ea(c,f,!1)}this.m(this.fmt.numChannels,this.fmt.sampleRate,a,f,{container:this.u()})};l.prototype.toSampleRate=function(a,b){b=void 0===b?{}:b;this.wa(a);var c=this.getSamples(),d=[];if(c.constructor===Float64Array)d=ma(c,this.fmt.sampleRate,a,b);else for(var e=0;e<c.length;e++)d.push(ma(c[e],this.fmt.sampleRate,a,b));if("64"!==this.bitDepth&&"32f"!==this.bitDepth)if(d[0].constructor===Number)la(d,this.f.g);else for(c=0;c<d.length;c++)la(d[c],this.f.g);this.m(this.fmt.numChannels,
a,this.bitDepth,d,{container:this.u()})};l.prototype.wa=function(a){if(1>a||4294967295<this.fmt.bitsPerSample/8*this.fmt.numChannels*a)throw Error("Invalid sample rate.");if(-1<["4","8a","8m"].indexOf(this.bitDepth))throw Error("wavefile can't change the sample rate of compressed files.");};l.prototype.H=function(){this.S();"16"!=this.bitDepth&&this.toBitDepth("16")};l.prototype.S=function(){"8a"==this.bitDepth?this.fromALaw():"8m"==this.bitDepth?this.fromMuLaw():"4"==this.bitDepth&&this.fromIMAADPCM()};
l.prototype.u=function(){return"RF64"==this.container?"RIFF":this.container};l.prototype.m=function(a,b,c,d,e){e=void 0===e?{}:e;var f=new w;Object.assign(this.fmt,f.fmt);Object.assign(this.fact,f.fact);Object.assign(this.ds64,f.ds64);Object.assign(this.data,f.data);this.V(a,b,c,d,e)};Q(m,l);m.prototype.fromBase64=function(a){this.fromBuffer(new Uint8Array(ya(a)))};m.prototype.toBase64=function(){for(var a=this.toBuffer(),b="",c=0;c<a.length;c+=3)b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[c]>>
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?T(exports):"function"===typeof define&&define.amd?define(["exports"],T):(S=S||self,T(S.wavefile={}));
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;y<p.length-1;y++){var v=p[y];v in l||(l[v]={});l=l[v]}p=p[p.length-1];y=l[p];v=m(y);v!=y&&null!=v&&ma(l,p,{configurable:!0,writable:!0,value:v})}}Q("Object.is",function(n){return n?n:function(m,l){return m===l?0!==m||1/m===1/l:m!==m&&l!==l}});
Q("Array.prototype.includes",function(n){return n?n:function(m,l){var p=this;p instanceof String&&(p=String(p));var y=p.length,v=l||0;for(0>v&&(v=Math.max(v+y,0));v<y;v++){var w=p[v];if(w===m||Object.is(w,m))return!0}return!1}});
Q("String.prototype.codePointAt",function(n){return n?n:function(m){if(null==this)throw new TypeError("The 'this' value for String.prototype.codePointAt must not be null or undefined");var l=this.length;m=Number(m)||0;if(0<=m&&m<l){m|=0;var p=this.charCodeAt(m);if(55296>p||56319<p||m+1===l)return p;m=this.charCodeAt(m+1);return 56320>m||57343<m?p:1024*(p-55296)+m+9216}}});
var oa="function"==typeof Object.assign?Object.assign:function(n,m){for(var l=1;l<arguments.length;l++){var p=arguments[l];if(p)for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(n[y]=p[y])}return n};Q("Object.assign",function(n){return n||oa});var V=this;
function W(n){function m(a){var b=l.call(this)||this;a&&b.fromBuffer(a);return b}function l(){return w.apply(this,arguments)||this}function p(a,b,c){for(var d=[],e=0;e<a;e++)d.push(this.b({pa:b,oa:c,Q:.5/Math.sin(Math.PI/(2*a)*(e+.5))}));this.a=[];for(a=0;a<d.length;a++)this.a[a]={Ka:d[a].A[0],La:d[a].A[1],Ma:d[a].A[2],Ha:d[a].D[0],Ia:d[a].D[1],k:d[a].k,z:[0,0]}}function y(a,b,c){c=2*Math.PI*c/b;b=0;this.a=[];for(var d=0;d<=a;d++)0===d-a/2?this.a[d]=c:(this.a[d]=Math.sin(c*(d-a/2))/(d-a/2),this.a[d]*=
.54-.46*Math.cos(2*Math.PI*d/a)),b+=this.a[d];for(c=0;c<=a;c++)this.a[c]/=b;this.z=this.b()}function v(a,b,c){this.C=a;this.l=(a-1)/b;this.M=this.I;"point"===c.method?this.M=this.H:"linear"===c.method?this.M=this.G:"cubic"===c.method&&(this.M=this.B);this.J=1-Math.max(0,Math.min(1,c.tension||0));this.v=c.sincFilterSize||1;this.F=pa(c.sincWindow||qa)}function w(){return C.apply(this,arguments)||this}function C(){return t.apply(this,arguments)||this}function t(){var a=q.call(this)||this;a.bitDepth=
"0";a.f={h:0,o:!1};a.G={4:17,8:1,"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,64:3};return a}function q(){return u.apply(this,arguments)||this}function u(){var a=B.call(this)||this;a.Z.push("RF64");a.fmt={chunkId:"",chunkSize:0,audioFormat:0,numChannels:0,sampleRate:0,byteRate:0,blockAlign:0,bitsPerSample:0,cbSize:0,validBitsPerSample:0,dwChannelMask:0,subformat:[]};a.fact={chunkId:"",chunkSize:0,dwSampleLength:0};a.cue={chunkId:"",chunkSize:0,dwCuePoints:0,points:[]};a.smpl={chunkId:"",chunkSize:0,dwManufacturer:0,
dwProduct:0,dwSamplePeriod:0,dwMIDIUnityNote:0,dwMIDIPitchFraction:0,dwSMPTEFormat:0,dwSMPTEOffset:0,dwNumSampleLoops:0,dwSamplerData:0,loops:[]};a.bext={chunkId:"",chunkSize:0,description:"",originator:"",originatorReference:"",originationDate:"",originationTime:"",timeReference:[0,0],version:0,UMID:"",loudnessValue:0,loudnessRange:0,maxTruePeakLevel:0,maxMomentaryLoudness:0,maxShortTermLoudness:0,reserved:"",codingHistory:""};a.iXML={chunkId:"",chunkSize:0,value:""};a.ds64={chunkId:"",chunkSize:0,
riffSizeHigh:0,riffSizeLow:0,dataSizeHigh:0,dataSizeLow:0,originationTime:0,sampleCountHigh:0,sampleCountLow:0};a.data={chunkId:"",chunkSize:0,samples:new Uint8Array(0)};a.LIST=[];a.junk={chunkId:"",chunkSize:0,chunkData:[]};a._PMX={chunkId:"",chunkSize:0,value:""};a.g={h:16,o:!1,O:!1,R:!1};return a}function B(){this.container="";this.chunkSize=0;this.format="";this.Y=null;this.c=0;this.a={h:32,o:!1};this.Z=["RIFF","RIFX"]}function H(a,b){this.offset=Math.ceil((a+b)/8);this.b=a;this.c=b;this.a=(1<<
a-1)-1;this.f=Math.pow(2,this.a+1);this.g=a+b;this.j=Math.pow(2,-(8*this.offset-1-a))}function F(a,b){this.h=a;this.offset=Math.ceil(a/8);this.max=Math.pow(2,a)-1;this.min=0;this.S=this.a;if(void 0===b?0:b)this.max=Math.pow(2,a)/2-1,this.min=-this.max-1,this.S=this.f}function ra(a){for(var b=new Uint8Array(256),c=0;64>c;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<a.length;d+=4){var f=b[a.charCodeAt(d)],g=b[a.charCodeAt(d+1)],k=b[a.charCodeAt(d+2)],r=b[a.charCodeAt(d+3)];c[e++]=f<<2|g>>4;c[e++]=(g&15)<<4|k>>2;c[e++]=(k&3)<<6|r&63}return c}function sa(a,b){return a=0<a?parseInt(a/b.ea*b.ca,10):parseInt(a/b.fa*b.da,10)}function ta(a,b){return parseInt(0<a?a*b.ca:a*b.da,10)}function ua(a,b){return 0<a?a/b.ea:a/b.fa}function va(a,b){function c(d){return d}a!=b&&(c=["32f","64"].includes(a)?ta:["32f","64"].includes(b)?ua:sa);return c}function X(a){if("32f"!=
a&&"64"!=a&&("8">parseInt(a,10)||"53"<parseInt(a,10)))throw Error("Invalid bit depth.");}function Y(a,b,c){if("8"==a){a=c?-128:128;c=0;for(var d=b.length;c<d;c++)b[c]=b[c]+=a}}function wa(a){for(var b={index:0,i:0,step:7},c=new Uint8Array(a.length),d=[],e=0,f=0,g=0,k=a.length;g<k;g++)0==g%505&&0!=g&&(c.set(xa(d,b),e),e+=256,d=[],f++),d.push(a[g]);a=a.length/2;a%2&&a++;return c.slice(0,a+512+4*f)}function ya(a,b){b=void 0===b?256:b;for(var c={index:0,i:0,step:7},d=new Int16Array(2*a.length),e=[],f=
0,g=0,k=a.length;g<k;g++){if(0==g%b&&0!=g){var r=c,z=e[1]<<8|e[0];r.i=32768<z?z-65536:z;r.index=e[2];r.step=R[r.index];z=[r.i,r.i];for(var I=4,za=e.length;I<za;I++){var Z=e[I],aa=Z>>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<e;c+=2){var f=S(a[c],b),g=S(a[c+1],b);d.push(g<<4|f)}return d}function S(a,b){var c=a-b.i;if(0<=c)var d=
0;else d=8,c=-c;var e=R[b.index],f=e>>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:32767<b.i&&(b.i=32767);b.index+=ca[c&7];0>b.index?b.index=0:88<b.index&&(b.index=88);return d}function ba(a,b){var c=0;a&4&&(c+=b.step);a&2&&(c+=b.step>>1);a&1&&(c+=b.step>>2);c+=b.step>>3;a&8&&(c=-c);b.i+=c;32767<b.i?b.i=32767:-32767>b.i&&(b.i=-32767);b.index+=ca[a];0>b.index?b.index=0:88<b.index&&(b.index=88);b.step=R[b.index];return b.i}
function Aa(a){for(var b=new Uint8Array(a.length),c=0,d=a.length;c<d;c++){var e=c;var f=a[c];f=-32768==f?-32767:f;var g=~f>>8&128;g||(f*=-1);32635<f&&(f=32635);if(256<=f){var k=Ba[f>>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<d;c++){var e=c,f=a[c],g=0;f^=85;0!==(f&128)&&(f&=-129,g=-1);var k=((f&240)>>4)+4;f=4!=k?1<<k|(f&15)<<k-4|1<<k-5:f<<1|1;b[e]=-8*(0===g?f:-f)}return b}function Da(a){for(var b=new Uint8Array(a.length),
c=0,d=a.length;c<d;c++){var e=c,f=a[c];var g=f>>8&128;0!=g&&(f=-f);f+=132;32635<f&&(f=32635);var k=Ea[f>>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<d;c++){var e=c,f=a[c];f=~f;var g=f>>4&7;g=Ga[g]+((f&15)<<g+3);0!=(f&128)&&(g=-g);b[e]=g}return b}function da(a,b,c,d){d=void 0===d?a.length:d;for(c=void 0===c?0:c;c<d;c+=b){var e=a,f=b,g=c;f--;for(var k=0;k<f;k++){var r=e[g+k];e[g+k]=e[g+f];e[g+f]=r;f--}}}function T(a,b,c){c=void 0===c?0:
c;for(var d=0,e=a.length;d<e;){var f=a.codePointAt(d);if(128>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<g;)b[c]=128|f>>6*(g-1)&63,c++,g--}d++}return c}function U(a){var b=Math.floor(a);a-=b;return.5>a?b:.5<a?b+1:b%2?b+1:b}function G(a,b,c){c=void 0===c?a.length:c;var d=void 0===b?0:b;c=void 0===c?a.length:c;b="";for(d=void 0===d?0:d;d<c;){var e=128,f=191,g=!1,k=a[d++];if(0<=k&&127>=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;z<r;z++){if(a[d]<e||a[d]>f)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;g<r;g++)d=e.ga(c,a[g],d);b.o&&da(c,f,k,d);return d}function E(a,b,c,d,e){d=void 0===d?0:d;e=void 0===e?a.length:e;b=b||{};var f=ea(b.h,b.R,b.O);e-=(e-d)%f.offset;b.o?(a=new Uint8Array(a),b.o&&da(a,f.offset,d,e),fa(a,c,d,e,f)):fa(a,c,d,e,f)}function h(a,b){var c=[];L([a],b,c,0);return c}function M(a,b,c){c=void 0===c?0:c;var d=[];E(a,b,d,c,c+Math.ceil(b.h/8));return d[0]}function fa(a,b,c,d,e){for(var f=e.offset,g=0;c<d;c+=f,g++)b[g]=e.S(a,c)}function ea(a,b,c){return b&&32==a?new H(8,
23):b&&64==a?new H(11,52):new F(a,c)}function A(a,b){for(var c=x(a),d=c.length;d<b;d++)c.push(0);return c}function qa(a){return Math.exp(-a/2*a/2)}function pa(a){return function(b){return(0===b?1:Math.sin(Math.PI*b)/(Math.PI*b))*a(b)}}function ha(a,b,c,d){d=(void 0===d?null:d)||{};var e=new Float64Array(a.length*((c-b)/b+1));d.method=d.method||"cubic";var f=new v(a.length,e.length,{method:d.method,tension:d.tension||0,sincFilterSize:d.sincFilterSize||6,sincWindow:d.sincWindow||void 0,clip:d.clip||
"mirror"});void 0===d.LPF&&(d.LPF=Ha[d.method]);if(d.LPF){d.LPFType=d.LPFType||"IIR";var g=Ia[d.LPFType];if(c>b){b=new g(d.LPForder||ia[d.LPFType],c,b/2);c=0;for(d=e.length;c<d;c++)e[c]=b.filter(f.M(c,a));b.reset();for(a=e.length-1;0<=a;a--)e[a]=b.filter(e[a])}else{b=new g(d.LPForder||ia[d.LPFType],b,c/2);c=0;for(d=a.length;c<d;c++)a[c]=b.filter(a[c]);b.reset();for(c=a.length-1;0<=c;c--)a[c]=b.filter(a[c]);ja(a,e,f)}}else ja(a,e,f);return e}function ja(a,b,c){for(var d=0,e=b.length;d<e;d++)b[d]=c.M(d,
a)}function J(a,b){var c=a/b;c%2&&c++;return c}var ca=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],R=[7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767],Ba=[1,1,2,2,3,3,3,3,4,4,4,
4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],Ea=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],Ga=[0,132,396,924,1980,4092,8316,16764];F.prototype.ga=function(a,b,c){c=void 0===c?0:c;b=this.b(Math.round(b));for(var d=0,e=this.offset;d<e;d++)a[c]=Math.floor(b/Math.pow(2,8*d))&255,c++;return c};F.prototype.a=function(a,b){b=void 0===b?0:b;for(var c=
0,d=0;d<this.offset;d++)c+=a[b+d]*Math.pow(256,d);return c};F.prototype.f=function(a,b){return this.c(this.a(a,void 0===b?0:b))};F.prototype.b=function(a){return a>this.max?this.max:a<this.min?this.min:a};F.prototype.c=function(a){a>this.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<<this.b)-1):0!==b&&(b>=Math.pow(2,1-this.a)?(2<=f/Math.pow(2,this.c)&&(e+=1,f=1),e>this.a?(e=(1<<this.b)-1,f=0):(e+=this.a,f=U(f)-Math.pow(2,this.c))):(f=U(b/Math.pow(2,1-this.a-this.c)),e=0));return this.l(a,c,d,e,f)};H.prototype.S=function(a,b){for(var c=(1<<this.b)-1,d="",e=this.offset-1;0<=e;e--){var f=a[e+b].toString(2);d+="00000000".substring(f.length)+f}e="1"==d.charAt(0)?-1:1;d=d.substring(1);f=parseInt(d.substring(0,this.b),2);d=d.substring(this.b);if(f==c)return 0!==
parseInt(d,2)?NaN:Infinity*e;0===f?(f+=1,c=parseInt(d,2)):c=parseInt("1"+d,2);return e*c*this.j*Math.pow(2,f-this.a)};H.prototype.l=function(a,b,c,d,e){var f=[];f.push(c);for(c=this.b;0<c;--c)f[c]=d%2?1:0,d=Math.floor(d/2);d=f.length;for(c=this.c;0<c;--c)f[d+c]=e%2?1:0,e=Math.floor(e/2);e=f.join("");f=this.offset+b-1;for(d=b;f>=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;e<c.length;e++)if(c[e].chunkId==a)if(b)d.push(c[e]);else return c[e];return"LIST"==a?d.length?d:null:null};B.prototype.u=function(a,b){var c=G(a,this.c,this.c+b);this.c+=b;return c};B.prototype.b=function(a){a=M(a,this.a,this.c);this.c+=4;return a};
B.prototype.V=function(a){for(var b=[],c=this.c;c<=a.length-8;)b.push(this.$a(a,c)),c+=8+b[b.length-1].chunkSize,c=c%2?c+1:c;return b};B.prototype.$a=function(a,b){var c={chunkId:this.Ea(a,b),chunkSize:this.Fa(a,b)};"LIST"==c.chunkId?(c.format=G(a,b+8,b+12),this.c+=4,c.subChunks=this.V(a)):(this.c=b+8+(c.chunkSize%2?c.chunkSize+1:c.chunkSize),c.chunkData={start:b+8,end:this.c});return c};B.prototype.Ea=function(a,b){this.c+=4;return G(a,b,b+4)};B.prototype.Fa=function(a,b){this.c+=4;return M(a,this.a,
b+4)};P(u,B);u.prototype.fromBuffer=function(a,b){b=void 0===b?!0:b;this.U();this.va(a);this.g.o=this.a.o;if("WAVE"!=this.format)throw Error('Could not find the "WAVE" format identifier');this.hb(a);this.jb(a);this.ib(a);this.eb(a);this.qa(a);this.fb(a);this.ma(a);this.gb(a,b);this.lb(a);this.ia(a);this.na(a)};u.prototype.U=function(){var a=new u;Object.assign(this.fmt,a.fmt);Object.assign(this.fact,a.fact);Object.assign(this.cue,a.cue);Object.assign(this.smpl,a.smpl);Object.assign(this.bext,a.bext);
Object.assign(this.iXML,a.iXML);Object.assign(this.ds64,a.ds64);Object.assign(this.data,a.data);this.LIST=[];Object.assign(this.junk,a.junk);Object.assign(this._PMX,a._PMX)};u.prototype.jb=function(a){var b=this.s("fmt ");if(b)this.c=b.chunkData.start,this.fmt.chunkId=b.chunkId,this.fmt.chunkSize=b.chunkSize,this.fmt.audioFormat=this.j(a),this.fmt.numChannels=this.j(a),this.fmt.sampleRate=this.b(a),this.fmt.byteRate=this.b(a),this.fmt.blockAlign=this.j(a),this.fmt.bitsPerSample=this.j(a),this.kb(a);
else throw Error('Could not find the "fmt " chunk');};u.prototype.kb=function(a){16<this.fmt.chunkSize&&(this.fmt.cbSize=this.j(a),18<this.fmt.chunkSize&&(this.fmt.validBitsPerSample=this.j(a),20<this.fmt.chunkSize&&(this.fmt.dwChannelMask=this.b(a),this.fmt.subformat=[this.b(a),this.b(a),this.b(a),this.b(a)])))};u.prototype.ib=function(a){var b=this.s("fact");b&&(this.c=b.chunkData.start,this.fact.chunkId=b.chunkId,this.fact.chunkSize=b.chunkSize,this.fact.dwSampleLength=this.b(a))};u.prototype.fb=
function(a){var b=this.s("cue ");if(b)for(this.c=b.chunkData.start,this.cue.chunkId=b.chunkId,this.cue.chunkSize=b.chunkSize,this.cue.dwCuePoints=this.b(a),b=0;b<this.cue.dwCuePoints;b++)this.cue.points.push({dwName:this.b(a),dwPosition:this.b(a),fccChunk:this.u(a,4),dwChunkStart:this.b(a),dwBlockStart:this.b(a),dwSampleOffset:this.b(a)})};u.prototype.ma=function(a){var b=this.s("smpl");if(b)for(this.c=b.chunkData.start,this.smpl.chunkId=b.chunkId,this.smpl.chunkSize=b.chunkSize,this.smpl.dwManufacturer=
this.b(a),this.smpl.dwProduct=this.b(a),this.smpl.dwSamplePeriod=this.b(a),this.smpl.dwMIDIUnityNote=this.b(a),this.smpl.dwMIDIPitchFraction=this.b(a),this.smpl.dwSMPTEFormat=this.b(a),this.smpl.dwSMPTEOffset=this.b(a),this.smpl.dwNumSampleLoops=this.b(a),this.smpl.dwSamplerData=this.b(a),b=0;b<this.smpl.dwNumSampleLoops;b++)this.smpl.loops.push({dwName:this.b(a),dwType:this.b(a),dwStart:this.b(a),dwEnd:this.b(a),dwFraction:this.b(a),dwPlayCount:this.b(a)})};u.prototype.gb=function(a,b){var c=this.s("data");
if(c)this.data.chunkId="data",this.data.chunkSize=c.chunkSize,b&&(this.data.samples=a.slice(c.chunkData.start,c.chunkData.end));else throw Error('Could not find the "data" chunk');};u.prototype.eb=function(a){var b=this.s("bext");b&&(this.c=b.chunkData.start,this.bext.chunkId=b.chunkId,this.bext.chunkSize=b.chunkSize,this.bext.description=this.u(a,256),this.bext.originator=this.u(a,32),this.bext.originatorReference=this.u(a,32),this.bext.originationDate=this.u(a,10),this.bext.originationTime=this.u(a,
8),this.bext.timeReference=[this.b(a),this.b(a)],this.bext.version=this.j(a),this.bext.UMID=this.u(a,64),this.bext.loudnessValue=this.j(a),this.bext.loudnessRange=this.j(a),this.bext.maxTruePeakLevel=this.j(a),this.bext.maxMomentaryLoudness=this.j(a),this.bext.maxShortTermLoudness=this.j(a),this.bext.reserved=this.u(a,180),this.bext.codingHistory=this.u(a,this.bext.chunkSize-602))};u.prototype.qa=function(a){var b=this.s("iXML");b&&(this.c=b.chunkData.start,this.iXML.chunkId=b.chunkId,this.iXML.chunkSize=
b.chunkSize,this.iXML.value=G(a,this.c,this.c+this.iXML.chunkSize))};u.prototype.hb=function(a){var b=this.s("ds64");if(b)this.c=b.chunkData.start,this.ds64.chunkId=b.chunkId,this.ds64.chunkSize=b.chunkSize,this.ds64.riffSizeHigh=this.b(a),this.ds64.riffSizeLow=this.b(a),this.ds64.dataSizeHigh=this.b(a),this.ds64.dataSizeLow=this.b(a),this.ds64.originationTime=this.b(a),this.ds64.sampleCountHigh=this.b(a),this.ds64.sampleCountLow=this.b(a);else if("RF64"==this.container)throw Error('Could not find the "ds64" chunk');
};u.prototype.ia=function(a){var b=this.s("LIST",!0);if(null!==b)for(var c=0;c<b.length;c++){var d=b[c];this.LIST.push({chunkId:d.chunkId,chunkSize:d.chunkSize,format:d.format,subChunks:[]});for(var e=0;e<d.subChunks.length;e++)this.ka(d.subChunks[e],d.format,a)}};u.prototype.ka=function(a,b,c){"adtl"==b?-1<["labl","note","ltxt"].indexOf(a.chunkId)&&this.la(c,a):"INFO"==b&&this.ja(c,a)};u.prototype.la=function(a,b){this.c=b.chunkData.start;var c={chunkId:b.chunkId,chunkSize:b.chunkSize,dwName:this.b(a)};
"ltxt"==b.chunkId?(c.dwSampleLength=this.b(a),c.dwPurposeID=this.b(a),c.dwCountry=this.j(a),c.dwLanguage=this.j(a),c.dwDialect=this.j(a),c.dwCodePage=this.j(a),c.value=""):c.value=this.X(a,this.c);this.LIST[this.LIST.length-1].subChunks.push(c)};u.prototype.ja=function(a,b){this.c=b.chunkData.start;this.LIST[this.LIST.length-1].subChunks.push({chunkId:b.chunkId,chunkSize:b.chunkSize,value:this.X(a,this.c)})};u.prototype.lb=function(a){var b=this.s("junk");b&&(this.junk={chunkId:b.chunkId,chunkSize:b.chunkSize,
chunkData:[].slice.call(a.slice(b.chunkData.start,b.chunkData.end))})};u.prototype.na=function(a){var b=this.s("_PMX");b&&(this.c=b.chunkData.start,this._PMX.chunkId=b.chunkId,this._PMX.chunkSize=b.chunkSize,this._PMX.value=G(a,this.c,this.c+this._PMX.chunkSize))};u.prototype.X=function(a,b){for(var c=b=void 0===b?0:b;c<a.length&&(this.c++,0!==a[c]);c++);return G(a,b,this.c-1)};u.prototype.j=function(a){a=M(a,this.g,this.c);this.c+=2;return a};P(q,u);q.prototype.toBuffer=function(){this.g.o="RIFX"===
this.container;this.a.o=this.g.o;for(var a=[this.Sa(),this.Oa(),this.Da(),this.bb(),this.Qa(),this.Pa(),x(this.data.chunkId),h(this.data.samples.length,this.a),this.data.samples,this.Ga(),this.Ya(),this.Ta(),this.ab()],b=0,c=0;c<a.length;c++)b+=a[c].length;c=new Uint8Array(b+12);var d=T(this.container,c,0);d=L([b+4],this.a,c,void 0===d?0:d);d=T(this.format,c,void 0===d?0:d);for(b=0;b<a.length;b++)c.set(a[b],d),d+=a[b].length;return c};q.prototype.Da=function(){var a=[];this.Ca();this.bext.chunkId&&
(this.bext.chunkSize=602+this.bext.codingHistory.length,a=a.concat(x(this.bext.chunkId),h(602+this.bext.codingHistory.length,this.a),A(this.bext.description,256),A(this.bext.originator,32),A(this.bext.originatorReference,32),A(this.bext.originationDate,10),A(this.bext.originationTime,8),h(this.bext.timeReference[0],this.a),h(this.bext.timeReference[1],this.a),h(this.bext.version,this.g),A(this.bext.UMID,64),h(this.bext.loudnessValue,this.g),h(this.bext.loudnessRange,this.g),h(this.bext.maxTruePeakLevel,
this.g),h(this.bext.maxMomentaryLoudness,this.g),h(this.bext.maxShortTermLoudness,this.g),A(this.bext.reserved,180),A(this.bext.codingHistory,this.bext.codingHistory.length)));this.l(a);return a};q.prototype.Ca=function(){for(var a in this.bext)if(this.bext.hasOwnProperty(a)&&this.bext[a]&&"timeReference"!=a){this.bext.chunkId="bext";break}if(this.bext.timeReference[0]||this.bext.timeReference[1])this.bext.chunkId="bext"};q.prototype.bb=function(){var a=[];if(this.iXML.chunkId){var b=x(this.iXML.value);
this.iXML.chunkSize=b.length;a=a.concat(x(this.iXML.chunkId),h(this.iXML.chunkSize,this.a),b)}this.l(a);return a};q.prototype.Oa=function(){var a=[];this.ds64.chunkId&&(a=a.concat(x(this.ds64.chunkId),h(this.ds64.chunkSize,this.a),h(this.ds64.riffSizeHigh,this.a),h(this.ds64.riffSizeLow,this.a),h(this.ds64.dataSizeHigh,this.a),h(this.ds64.dataSizeLow,this.a),h(this.ds64.originationTime,this.a),h(this.ds64.sampleCountHigh,this.a),h(this.ds64.sampleCountLow,this.a)));this.l(a);return a};q.prototype.Ga=
function(){var a=[];if(this.cue.chunkId){var b=this.Ja();a=a.concat(x(this.cue.chunkId),h(b.length+4,this.a),h(this.cue.dwCuePoints,this.a),b)}this.l(a);return a};q.prototype.Ja=function(){for(var a=[],b=0;b<this.cue.dwCuePoints;b++)a=a.concat(h(this.cue.points[b].dwName,this.a),h(this.cue.points[b].dwPosition,this.a),x(this.cue.points[b].fccChunk),h(this.cue.points[b].dwChunkStart,this.a),h(this.cue.points[b].dwBlockStart,this.a),h(this.cue.points[b].dwSampleOffset,this.a));return a};q.prototype.Ya=
function(){var a=[];if(this.smpl.chunkId){var b=this.Za();a=a.concat(x(this.smpl.chunkId),h(b.length+36,this.a),h(this.smpl.dwManufacturer,this.a),h(this.smpl.dwProduct,this.a),h(this.smpl.dwSamplePeriod,this.a),h(this.smpl.dwMIDIUnityNote,this.a),h(this.smpl.dwMIDIPitchFraction,this.a),h(this.smpl.dwSMPTEFormat,this.a),h(this.smpl.dwSMPTEOffset,this.a),h(this.smpl.dwNumSampleLoops,this.a),h(this.smpl.dwSamplerData,this.a),b)}this.l(a);return a};q.prototype.Za=function(){for(var a=[],b=0;b<this.smpl.dwNumSampleLoops;b++)a=
a.concat(h(this.smpl.loops[b].dwName,this.a),h(this.smpl.loops[b].dwType,this.a),h(this.smpl.loops[b].dwStart,this.a),h(this.smpl.loops[b].dwEnd,this.a),h(this.smpl.loops[b].dwFraction,this.a),h(this.smpl.loops[b].dwPlayCount,this.a));return a};q.prototype.Pa=function(){var a=[];this.fact.chunkId&&(a=a.concat(x(this.fact.chunkId),h(this.fact.chunkSize,this.a),h(this.fact.dwSampleLength,this.a)));this.l(a);return a};q.prototype.Qa=function(){var a=[];if(this.fmt.chunkId)return a=a.concat(x(this.fmt.chunkId),
h(this.fmt.chunkSize,this.a),h(this.fmt.audioFormat,this.g),h(this.fmt.numChannels,this.g),h(this.fmt.sampleRate,this.a),h(this.fmt.byteRate,this.a),h(this.fmt.blockAlign,this.g),h(this.fmt.bitsPerSample,this.g),this.Ra()),this.l(a),a;throw Error('Could not find the "fmt " chunk');};q.prototype.Ra=function(){var a=[];16<this.fmt.chunkSize&&(a=a.concat(h(this.fmt.cbSize,this.g)));18<this.fmt.chunkSize&&(a=a.concat(h(this.fmt.validBitsPerSample,this.g)));20<this.fmt.chunkSize&&(a=a.concat(h(this.fmt.dwChannelMask,
this.a)));24<this.fmt.chunkSize&&(a=a.concat(h(this.fmt.subformat[0],this.a),h(this.fmt.subformat[1],this.a),h(this.fmt.subformat[2],this.a),h(this.fmt.subformat[3],this.a)));return a};q.prototype.Ta=function(){for(var a=[],b=0;b<this.LIST.length;b++){var c=this.Va(this.LIST[b].subChunks,this.LIST[b].format);a=a.concat(x(this.LIST[b].chunkId),h(c.length+4,this.a),x(this.LIST[b].format),c)}this.l(a);return a};q.prototype.Va=function(a,b){for(var c=[],d=0,e=a.length;d<e;d++)"INFO"==b?c=c.concat(this.Ua(a[d])):
"adtl"==b&&(c=c.concat(this.Wa(a[d]))),this.l(c);return c};q.prototype.Ua=function(a){var b=[],c=A(a.value,a.value.length);b=b.concat(x(a.chunkId),h(c.length+1,this.a),c);b.push(0);return b};q.prototype.Wa=function(a){var b=[];if(-1<["labl","note"].indexOf(a.chunkId)){var c=A(a.value,a.value.length);b=b.concat(x(a.chunkId),h(c.length+5,this.a),h(a.dwName,this.a),c);b.push(0)}else"ltxt"==a.chunkId&&(b=b.concat(this.Xa(a)));return b};q.prototype.Xa=function(a){return x(a.chunkId).concat(h(a.value.length+
20,this.a),h(a.dwName,this.a),h(a.dwSampleLength,this.a),h(a.dwPurposeID,this.a),h(a.dwCountry,this.g),h(a.dwLanguage,this.g),h(a.dwDialect,this.g),h(a.dwCodePage,this.g),A(a.value,a.value.length))};q.prototype.ab=function(){var a=[];if(this._PMX.chunkId){var b=x(this._PMX.value);this._PMX.chunkSize=b.length;a=a.concat(x(this._PMX.chunkId),h(this._PMX.chunkSize,this.a),b)}this.l(a);return a};q.prototype.Sa=function(){var a=[];if(this.junk.chunkId)return a.concat(x(this.junk.chunkId),h(this.junk.chunkData.length,
this.a),this.junk.chunkData);this.l(a);return a};q.prototype.l=function(a){a.length%2&&a.push(0)};P(t,q);t.prototype.fromScratch=function(a,b,c,d,e){e=e||{};this.U();this.W(a,b,c,d,e)};t.prototype.fromBuffer=function(a,b){q.prototype.fromBuffer.call(this,a,void 0===b?!0:b);this.ya();this.$()};t.prototype.toBuffer=function(){this.aa();return q.prototype.toBuffer.call(this)};t.prototype.getSamples=function(a,b){a=void 0===a?!1:a;b=void 0===b?Float64Array:b;var c=new b(this.data.samples.length/(this.f.h/
8));E(this.data.samples,this.f,c,0,this.data.samples.length);if(!a&&1<this.fmt.numChannels){var d=this.fmt.numChannels,e=b;e=void 0===e?Float64Array:e;for(var f=[],g=0;g<d;g++)f[g]=new e(c.length/d);for(e=0;e<d;e++){g=e;for(var k=0;g<c.length;g+=d,k++)f[e][k]=c[g]}c=f}return c};t.prototype.getSample=function(a){a*=this.f.h/8;if(a+this.f.h/8>this.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(0<d.length)if(d[0].constructor!==Number){f=new Float64Array(d[0].length*d.length);for(var g=0,k=d[0].length,r=0;g<k;g++)for(var z=0,I=d.length;z<I;z++,r++)f[r]=d[z][g]}else f=d;d=f;this.$();f=this.f.h/8;this.data.samples=new Uint8Array(d.length*f);L(d,this.f,this.data.samples,0);this.cb(c,a,b,f,this.data.samples.length,e);this.data.chunkId="data";this.data.chunkSize=
this.data.samples.length;this.aa()};t.prototype.cb=function(a,b,c,d,e,f){"4"==a?this.za(a,b,c,d,e,f):"8a"==a||"8m"==a?this.Aa(a,b,c,d,e,f):-1==Object.keys(this.G).indexOf(a)||2<b?this.Ba(a,b,c,d,e,f):this.F(a,b,c,d,e,f)};t.prototype.F=function(a,b,c,d,e,f){this.container=f.container;this.chunkSize=36+e;this.format="WAVE";this.bitDepth=a;this.fmt={chunkId:"fmt ",chunkSize:16,audioFormat:this.G[a]||65534,numChannels:b,sampleRate:c,byteRate:b*d*c,blockAlign:b*d,bitsPerSample:parseInt(a,10),cbSize:0,
validBitsPerSample:0,dwChannelMask:0,subformat:[]}};t.prototype.za=function(a,b,c,d,e,f){this.F(a,b,c,d,e,f);this.chunkSize=40+e;this.fmt.chunkSize=20;this.fmt.byteRate=4055;this.fmt.blockAlign=256;this.fmt.bitsPerSample=4;this.fmt.cbSize=2;this.fmt.validBitsPerSample=505;this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:2*e}};t.prototype.Ba=function(a,b,c,d,e,f){this.F(a,b,c,d,e,f);this.chunkSize=60+e;this.fmt.chunkSize=40;this.fmt.bitsPerSample=(parseInt(a,10)-1|7)+1;this.fmt.cbSize=22;this.fmt.validBitsPerSample=
parseInt(a,10);a=this.fmt;c=0;1===b?c=4:2===b?c=3:4===b?c=51:6===b?c=63:8===b&&(c=1599);a.dwChannelMask=c;this.fmt.subformat=[1,1048576,2852126848,1905997824]};t.prototype.Aa=function(a,b,c,d,e,f){this.F(a,b,c,d,e,f);this.chunkSize=40+e;this.fmt.chunkSize=20;this.fmt.cbSize=2;this.fmt.validBitsPerSample=8;this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:e}};t.prototype.ya=function(){3===this.fmt.audioFormat&&32===this.fmt.bitsPerSample?this.bitDepth="32f":6===this.fmt.audioFormat?this.bitDepth=
"8a":7===this.fmt.audioFormat?this.bitDepth="8m":this.bitDepth=this.fmt.bitsPerSample.toString()};t.prototype.wa=function(){if(!(this.G[this.bitDepth]||8<parseInt(this.bitDepth,10)&&54>parseInt(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||65535<a*this.fmt.bitsPerSample/8)throw Error("Invalid number of channels.");a=this.fmt.sampleRate;if(1>a||4294967295<this.fmt.bitsPerSample/8*this.fmt.numChannels*a)throw Error("Invalid sample rate.");};P(C,t);C.prototype.getTag=function(a){a=this.P(a);return null!==a.w?this.LIST[a.LIST].subChunks[a.w].value:null};C.prototype.setTag=function(a,b){var c=a;if(c.constructor!==String)throw Error("Invalid tag name.");if(4>c.length)for(var d=0,e=4-c.length;d<e;d++)c+=
" ";a=c;c=this.P(a);null!==c.w?(this.LIST[c.LIST].subChunks[c.w].chunkSize=b.length+1,this.LIST[c.LIST].subChunks[c.w].value=b):null!==c.LIST?this.LIST[c.LIST].subChunks.push({chunkId:a,chunkSize:b.length+1,value:b}):(this.LIST.push({chunkId:"LIST",chunkSize:b.length+9,format:"INFO",subChunks:[]}),this.LIST[this.LIST.length-1].subChunks.push({chunkId:a,chunkSize:b.length+1,value:b}))};C.prototype.deleteTag=function(a){a=this.P(a);return null!==a.w?(this.LIST[a.LIST].subChunks.splice(a.w,1),!0):!1};
C.prototype.listTags=function(){var a=this.C("INFO"),b={};if(null!==a)for(var c=0,d=this.LIST[a].subChunks.length;c<d;c++)b[this.LIST[a].subChunks[c].chunkId]=this.LIST[a].subChunks[c].value;return b};C.prototype.C=function(a){for(var b=0,c=this.LIST.length;b<c;b++)if(this.LIST[b].format==a)return b;return null};C.prototype.P=function(a){for(var b={LIST:null,w:null},c=0,d=this.LIST.length;c<d;c++)if("INFO"==this.LIST[c].format){b.LIST=c;d=0;for(var e=this.LIST[c].subChunks.length;d<e;d++)if(this.LIST[c].subChunks[d].chunkId==
a){b.w=d;break}break}return b};P(w,C);w.prototype.listCuePoints=function(){for(var a=this.J(),b=0,c=a.length;b<c;b++)a[b].position=a[b].dwSampleOffset/this.fmt.sampleRate*1E3,a[b].dwSampleLength?(a[b].end=a[b].dwSampleLength/this.fmt.sampleRate*1E3,a[b].end+=a[b].position):a[b].end=null,delete a[b].value;return a};w.prototype.setCuePoint=function(a){this.cue.chunkId="cue ";a.label||(a.label="");var b=this.J();this.I();this.cue.points=[];a.dwSampleOffset=a.position*this.fmt.sampleRate/1E3;a.dwSampleLength=
0;a.end&&(a.dwSampleLength=a.end*this.fmt.sampleRate/1E3-a.dwSampleOffset);0===b.length?this.B(a,1):this.ra(b,a);this.cue.dwCuePoints=this.cue.points.length};w.prototype.deleteCuePoint=function(a){this.cue.chunkId="cue ";var b=this.J();this.I();var c=this.cue.points.length;this.cue.points=[];for(var d=0;d<c;d++)d+1!==a&&this.B(b[d],d+1);this.cue.dwCuePoints=this.cue.points.length;this.cue.dwCuePoints?this.cue.chunkId="cue ":(this.cue.chunkId="",this.I())};w.prototype.updateLabel=function(a,b){var c=
this.C("adtl");if(null!==c)for(var d=0,e=this.LIST[c].subChunks.length;d<e;d++)this.LIST[c].subChunks[d].dwName==a&&(this.LIST[c].subChunks[d].value=b)};w.prototype.J=function(){for(var a=[],b=0;b<this.cue.points.length;b++){var c=this.cue.points[b],d=this.Na(c.dwName);d.label=d.value?d.value:"";d.dwPosition=c.dwPosition;d.fccChunk=c.fccChunk;d.dwChunkStart=c.dwChunkStart;d.dwBlockStart=c.dwBlockStart;d.dwSampleOffset=c.dwSampleOffset;a.push(d)}return a};w.prototype.Na=function(a){var b=this.C("adtl"),
c={};null!==b&&this.ha(c,b,a);return c};w.prototype.ha=function(a,b,c){for(var d=0,e=this.LIST[b].subChunks.length;d<e;d++)if(this.LIST[b].subChunks[d].dwName==c){var f=this.LIST[b].subChunks[d];a.value=f.value||a.value;a.dwName=f.dwName||0;a.dwSampleLength=f.dwSampleLength||0;a.dwPurposeID=f.dwPurposeID||0;a.dwCountry=f.dwCountry||0;a.dwLanguage=f.dwLanguage||0;a.dwDialect=f.dwDialect||0;a.dwCodePage=f.dwCodePage||0}};w.prototype.B=function(a,b){this.cue.points.push({dwName:b,dwPosition:a.dwPosition?
a.dwPosition:0,fccChunk:a.fccChunk?a.fccChunk:"data",dwChunkStart:a.dwChunkStart?a.dwChunkStart:0,dwBlockStart:a.dwBlockStart?a.dwBlockStart:0,dwSampleOffset:a.dwSampleOffset});this.ta(a,b)};w.prototype.ra=function(a,b){for(var c=!1,d=0;d<a.length;d++)a[d].dwSampleOffset>b.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;a<b;a++)"adtl"==this.LIST[a].format&&this.LIST.splice(a)};
w.prototype.ta=function(a,b){var c=this.C("adtl");null===c&&(this.LIST.push({chunkId:"LIST",chunkSize:4,format:"adtl",subChunks:[]}),c=this.LIST.length-1);this.sa(c,a,b);a.dwSampleLength&&this.ua(c,a,b)};w.prototype.sa=function(a,b,c){this.LIST[a].subChunks.push({chunkId:"labl",chunkSize:4,dwName:c,value:b.label});this.LIST[a].chunkSize+=12};w.prototype.ua=function(a,b,c){this.LIST[a].subChunks.push({chunkId:"ltxt",chunkSize:20,dwName:c,dwSampleLength:b.dwSampleLength,dwPurposeID:b.dwPurposeID||0,
dwCountry:b.dwCountry||0,dwLanguage:b.dwLanguage||0,dwDialect:b.dwDialect||0,dwCodePage:b.dwCodePage||0,value:b.label});this.LIST[a].chunkSize+=28};v.prototype.H=function(a,b){return this.f(Math.round(this.l*a),b)};v.prototype.G=function(a,b){a*=this.l;var c=Math.floor(a);a-=c;return(1-a)*this.f(c,b)+a*this.f(c+1,b)};v.prototype.B=function(a,b){a*=this.l;var c=Math.floor(a),d=[this.m(c,b),this.m(c+1,b)],e=[this.f(c,b),this.f(c+1,b)];a-=c;c=a*a;var f=a*c;return(2*f-3*c+1)*e[0]+(f-2*c+a)*d[0]+(-2*f+
3*c)*e[1]+(f-c)*d[1]};v.prototype.I=function(a,b){a*=this.l;var c=Math.floor(a),d=c+this.v,e=0;for(c=c-this.v+1;c<=d;c++)e+=this.F(a-c)*this.f(c,b);return e};v.prototype.m=function(a,b){return this.J*(this.f(a+1,b)-this.f(a-1,b))/2};v.prototype.f=function(a,b){return 0<=a&&a<this.C?b[a]:0};y.prototype.filter=function(a){this.z.L[this.z.N]=a;for(var b=a=0,c=this.z.L.length;b<c;b++)a+=this.a[b]*this.z.L[(this.z.N+b)%this.z.L.length];this.z.N=(this.z.N+1)%this.z.L.length;return a};y.prototype.reset=
function(){this.z=this.b()};y.prototype.b=function(){for(var a=[],b=0;b<this.a.length-1;b++)a.push(0);return{L:a,N:0}};p.prototype.filter=function(a){for(var b=0,c=this.a.length;b<c;b++)a=this.f(b,a);return a};p.prototype.b=function(a){var b={D:[],A:[]};a=this.c(a,b);b.k=1;b.A.push((1-a.ba)/(2*a.K));b.A.push(2*b.A[0]);b.A.push(b.A[0]);return b};p.prototype.c=function(a,b){var c={},d=2*Math.PI*a.oa/a.pa;c.alpha=Math.sin(d)/(2*a.Q);c.ba=Math.cos(d);c.K=1+c.alpha;b.K=c.K;b.D.push(-2*c.ba/c.K);b.k=1;
b.D.push((1-c.alpha)/c.K);return c};p.prototype.f=function(a,b){var c=b*this.a[a].k-this.a[a].Ha*this.a[a].z[0]-this.a[a].Ia*this.a[a].z[1],d=this.a[a].Ka*c+this.a[a].La*this.a[a].z[0]+this.a[a].Ma*this.a[a].z[1];this.a[a].z[1]=this.a[a].z[0];this.a[a].z[0]=c;return d};p.prototype.reset=function(){for(var a=0;a<this.a.length;a++)this.a[a].z=[0,0]};var Ha={point:!1,linear:!1,cubic:!0,sinc:!0},ia={IIR:16,FIR:71},Ia={IIR:p,FIR:y};P(l,w);l.prototype.toRIFF=function(){var a=new Float64Array(J(this.data.samples.length,
this.f.h/8));E(this.data.samples,this.f,a,0,this.data.samples.length);this.m(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,a,{container:"RIFF"})};l.prototype.toRIFX=function(){var a=new Float64Array(J(this.data.samples.length,this.f.h/8));E(this.data.samples,this.f,a,0,this.data.samples.length);this.m(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,a,{container:"RIFX"})};l.prototype.toIMAADPCM=function(){if(8E3!==this.fmt.sampleRate)throw Error("Only 8000 Hz files can be compressed as IMA-ADPCM.");
if(1!==this.fmt.numChannels)throw Error("Only mono files can be compressed as IMA-ADPCM.");this.H();var a=new Int16Array(J(this.data.samples.length,2));E(this.data.samples,this.f,a,0,this.data.samples.length);this.m(this.fmt.numChannels,this.fmt.sampleRate,"4",wa(a),{container:this.v()})};l.prototype.fromIMAADPCM=function(a){a=void 0===a?"16":a;this.m(this.fmt.numChannels,this.fmt.sampleRate,"16",ya(this.data.samples,this.fmt.blockAlign),{container:this.v()});"16"!=a&&this.toBitDepth(a)};l.prototype.toALaw=
function(){this.H();var a=new Int16Array(J(this.data.samples.length,2));E(this.data.samples,this.f,a,0,this.data.samples.length);this.m(this.fmt.numChannels,this.fmt.sampleRate,"8a",Aa(a),{container:this.v()})};l.prototype.fromALaw=function(a){a=void 0===a?"16":a;this.m(this.fmt.numChannels,this.fmt.sampleRate,"16",Ca(this.data.samples),{container:this.v()});"16"!=a&&this.toBitDepth(a)};l.prototype.toMuLaw=function(){this.H();var a=new Int16Array(J(this.data.samples.length,2));E(this.data.samples,
this.f,a,0,this.data.samples.length);this.m(this.fmt.numChannels,this.fmt.sampleRate,"8m",Da(a),{container:this.v()})};l.prototype.fromMuLaw=function(a){a=void 0===a?"16":a;this.m(this.fmt.numChannels,this.fmt.sampleRate,"16",Fa(this.data.samples),{container:this.v()});"16"!=a&&this.toBitDepth(a)};l.prototype.toBitDepth=function(a,b){var c=a,d=this.bitDepth;void 0===b||b||("32f"!=a&&(c=this.f.h.toString()),d=""+this.f.h);this.T();var e=this.getSamples(!0),f=new Float64Array(e.length),g=d;if(-1<["32f",
"64"].indexOf(g)&&-1<["32f","64"].indexOf(c))f.set(e);else{X(g);X(c);d=va(g,c);var k={fa:Math.pow(2,parseInt(g,10))/2,da:Math.pow(2,parseInt(c,10))/2,ea:Math.pow(2,parseInt(g,10))/2-1,ca:Math.pow(2,parseInt(c,10))/2-1};Y(g,e,!0);g=0;for(var r=e.length;g<r;g++)f[g]=d(e[g],k);Y(c,f,!1)}this.m(this.fmt.numChannels,this.fmt.sampleRate,a,f,{container:this.v()})};l.prototype.toSampleRate=function(a,b){this.xa(a);var c=this.getSamples(),d=[];if(c.constructor===Float64Array)d=ha(c,this.fmt.sampleRate,a,b);
else for(var e=0;e<c.length;e++)d.push(ha(c[e],this.fmt.sampleRate,a,b));this.m(this.fmt.numChannels,a,this.bitDepth,d,{container:this.v()})};l.prototype.xa=function(a){if(1>a||4294967295<this.fmt.bitsPerSample/8*this.fmt.numChannels*a)throw Error("Invalid sample rate.");if(-1<["4","8a","8m"].indexOf(this.bitDepth))throw Error("wavefile can't change the sample rate of compressed files.");};l.prototype.H=function(){this.T();"16"!=this.bitDepth&&this.toBitDepth("16")};l.prototype.T=function(){"8a"==
this.bitDepth?this.fromALaw():"8m"==this.bitDepth?this.fromMuLaw():"4"==this.bitDepth&&this.fromIMAADPCM()};l.prototype.v=function(){return"RF64"==this.container?"RIFF":this.container};l.prototype.m=function(a,b,c,d,e){var f=new w;Object.assign(this.fmt,f.fmt);Object.assign(this.fact,f.fact);Object.assign(this.ds64,f.ds64);Object.assign(this.data,f.data);this.W(a,b,c,d,e)};P(m,l);m.prototype.fromBase64=function(a){this.fromBuffer(ra(a))};m.prototype.toBase64=function(){for(var a=this.toBuffer(),b=
"",c=0;c<a.length;c+=3)b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[c]>>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={}));

@@ -26,3 +26,3 @@ /*

/**
* @fileoverview Externs for wavefile 10.4
* @fileoverview Externs for wavefile 11.0
* @see https://github.com/rochars/wavefile

@@ -322,7 +322,6 @@ * @externs

* Return the samples packed in a Float64Array.
* @param {?boolean} interleaved True to return interleaved samples,
* false to return the samples de-interleaved. Defaults to false.
* @param {?Function=} OutputObject The Typed Array object to write the
* samples. Assumes Float64Array by default.
* @return {!Float64Array|Array<Float64Array>} the samples.
* @param {boolean=} [interleaved=false] True to return interleaved samples,
* false to return the samples de-interleaved.
* @param {Function=} [OutputObject=Float64Array] The sample container.
* @return {!(Array|TypedArray)} the samples.
*/

@@ -350,12 +349,13 @@ WaveFile.prototype.getSamples = function(

/**
* Set up the WaveFile object based on the arguments passed.
* Set up the WaveFileCreator object based on the arguments passed.
* Existing chunks are reset.
* @param {number} numChannels The number of channels.
* @param {number} sampleRate The sample rate.
* Integers like 8000, 44100, 48000, 96000, 192000.
* Integers like 8000, 44100, 48000, 96000, 192000.
* @param {string} bitDepthCode The audio bit depth code.
* One of 4, 8, 8a, 8m, 16, 24, 32, 32f, 64
* or any value between 8 and 32 (like 12).
* @param {!Array|!TypedArray} samples The samples.
* @param {?Object} options Optional. Used to force the container
* as RIFX with {container: RIFX}
* One of '4', '8', '8a', '8m', '16', '24', '32', '32f', '64'
* or any value between '8' and '32' (like '12').
* @param {!(Array|TypedArray)} samples The samples.
* @param {Object=} options Optional. Used to force the container
* as RIFX with {'container': 'RIFX'}
* @throws {Error} If any argument does not meet the criteria.

@@ -368,16 +368,19 @@ */

/**
* Set up the WaveFile object from a byte buffer.
* @param {!Uint8Array} bytes The buffer.
* @param {boolean=} samples True if the samples should be loaded.
* Set up the WaveFileParser object from a byte buffer.
* @param {!Uint8Array} wavBuffer The buffer.
* @param {boolean=} [samples=true] True if the samples should be loaded.
* @throws {Error} If container is not RIFF, RIFX or RF64.
* @throws {Error} If no fmt chunk is found.
* @throws {Error} If no data chunk is found.
* @throws {Error} If format is not WAVE.
* @throws {Error} If no 'fmt ' chunk is found.
* @throws {Error} If no 'data' chunk is found.
*/
WaveFile.prototype.fromBuffer = function(bytes, samples=true) {};
WaveFile.prototype.fromBuffer = function(wavBuffer, samples=true) {};
/**
* Return a byte buffer representig the WaveFile object as a .wav file.
* Return a byte buffer representig the WaveFileParser object as a .wav file.
* The return value of this method can be written straight to disk.
* @return {!Uint8Array} A .wav file.
* @throws {Error} If any property of the object appears invalid.
* @return {!Uint8Array} A wav file.
* @throws {Error} If bit depth is invalid.
* @throws {Error} If the number of channels is invalid.
* @throws {Error} If the sample rate is invalid.
*/

@@ -428,5 +431,5 @@ WaveFile.prototype.toBuffer = function() {};

* @param {string} newBitDepth The new bit depth of the samples.
* One of 8 ... 32 (integers), 32f or 64 (floats)
* @param {boolean} changeResolution A boolean indicating if the
* resolution of samples should be actually changed or not.
* One of '8' ... '32' (integers), '32f' or '64' (floats)
* @param {boolean=} [changeResolution=true] A boolean indicating if the
* resolution of samples should be actually changed or not.
* @throws {Error} If the bit depth is not valid.

@@ -437,8 +440,8 @@ */

/**
* Convert the sample rate of the audio.
* Convert the sample rate of the file.
* @param {number} sampleRate The target sample rate.
* @param {?Object} details The extra configuration, if needed.
* @param {Object=} options The extra configuration, if needed.
*/
WaveFile.prototype.toSampleRate = function(
sampleRate, details= {
sampleRate, options= {
method: 'cubic',

@@ -463,5 +466,4 @@ clip: 'mirror',

* Decode a 4-bit IMA ADPCM wave file as a 16-bit wave file.
* @param {string} bitDepthCode The new bit depth of the samples.
* One of 8 ... 32 (integers), 32f or 64 (floats).
* Optional. Default is 16.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
*/

@@ -477,5 +479,4 @@ WaveFile.prototype.fromIMAADPCM = function(bitDepthCode='16') {};

* Decode a 8-bit A-Law wave file into a 16-bit wave file.
* @param {string} bitDepthCode The new bit depth of the samples.
* One of 8 ... 32 (integers), 32f or 64 (floats).
* Optional. Default is 16.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
*/

@@ -491,5 +492,4 @@ WaveFile.prototype.fromALaw = function(bitDepthCode='16') {};

* Decode a 8-bit mu-Law wave file into a 16-bit wave file.
* @param {string} bitDepthCode The new bit depth of the samples.
* One of 8 ... 32 (integers), 32f or 64 (floats).
* Optional. Default is 16.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
*/

@@ -496,0 +496,0 @@ WaveFile.prototype.fromMuLaw = function(bitDepthCode='16') {};

@@ -1,2 +0,2 @@

// Type definitions for wavefile 10.4
// Type definitions for wavefile 11.0
// Project: https://github.com/rochars/wavefile

@@ -11,10 +11,2 @@ // Definitions by: Rafael da Silva Rocha <https://github.com/rochars>

class WaveFile {
/**
* @param {?Uint8Array=} bytes A wave file buffer.
* @throws {Error} If no 'RIFF' chunk is found.
* @throws {Error} If no 'fmt ' chunk is found.
* @throws {Error} If no 'data' chunk is found.
*/
constructor(bytes?: Uint8Array);

@@ -107,8 +99,15 @@ /**

/**
* @param {Uint8Array=} [wavBuffer=null] A wave file buffer.
* @throws {Error} If no 'RIFF' chunk is found.
* @throws {Error} If no 'fmt ' chunk is found.
* @throws {Error} If no 'data' chunk is found.
*/
constructor(wavBuffer?: Uint8Array);
/**
* Return the samples packed in a Float64Array.
* @param {?boolean} interleaved True to return interleaved samples,
* false to return the samples de-interleaved. Defaults to false.
* @param {?Function=} OutputObject The Typed Array object to write the
* samples. Assumes Float64Array by default.
* @return {!Float64Array|Array<Float64Array>} the samples.
* @param {boolean=} [interleaved=false] True to return interleaved samples,
* false to return the samples de-interleaved.
* @param {Function=} [OutputObject=Float64Array] The sample container.
* @return {!(Array|TypedArray)} the samples.
*/

@@ -134,12 +133,13 @@ getSamples(interleaved?:boolean, OutputObject?: Function): Float64Array;

/**
* Set up the WaveFile object based on the arguments passed.
* Set up the WaveFileCreator object based on the arguments passed.
* Existing chunks are reset.
* @param {number} numChannels The number of channels.
* @param {number} sampleRate The sample rate.
* Integer numbers like 8000, 44100, 48000, 96000, 192000.
* Integers like 8000, 44100, 48000, 96000, 192000.
* @param {string} bitDepthCode The audio bit depth code.
* One of '4', '8', '8a', '8m', '16', '24', '32', '32f', '64'
* or any value between '8' and '32' (like '12').
* @param {!Array|!TypedArray} samples
* @param {?Object} options Optional. Used to force the container
* as RIFX with {'container': 'RIFX'}
* One of '4', '8', '8a', '8m', '16', '24', '32', '32f', '64'
* or any value between '8' and '32' (like '12').
* @param {!(Array|TypedArray)} samples The samples.
* @param {Object=} options Optional. Used to force the container
* as RIFX with {'container': 'RIFX'}
* @throws {Error} If any argument does not meet the criteria.

@@ -155,6 +155,7 @@ */

/**
* Set up the WaveFile object from a byte buffer.
* @param {!Uint8Array} bytes The buffer.
* @param {boolean=} samples True if the samples should be loaded.
* Set up the WaveFileParser object from a byte buffer.
* @param {!Uint8Array} wavBuffer The buffer.
* @param {boolean=} [samples=true] True if the samples should be loaded.
* @throws {Error} If container is not RIFF, RIFX or RF64.
* @throws {Error} If format is not WAVE.
* @throws {Error} If no 'fmt ' chunk is found.

@@ -166,6 +167,8 @@ * @throws {Error} If no 'data' chunk is found.

/**
* Return a byte buffer representig the WaveFile object as a .wav file.
* Return a byte buffer representig the WaveFileParser object as a .wav file.
* The return value of this method can be written straight to disk.
* @return {!Uint8Array} A .wav file.
* @throws {Error} If any property of the object appears invalid.
* @return {!Uint8Array} A wav file.
* @throws {Error} If bit depth is invalid.
* @throws {Error} If the number of channels is invalid.
* @throws {Error} If the sample rate is invalid.
*/

@@ -216,5 +219,5 @@ toBuffer(): Uint8Array;

* @param {string} newBitDepth The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats)
* @param {boolean} changeResolution A boolean indicating if the
* resolution of samples should be actually changed or not.
* One of '8' ... '32' (integers), '32f' or '64' (floats)
* @param {boolean=} [changeResolution=true] A boolean indicating if the
* resolution of samples should be actually changed or not.
* @throws {Error} If the bit depth is not valid.

@@ -225,7 +228,7 @@ */

/**
* Convert the sample rate of the audio.
* Convert the sample rate of the file.
* @param {number} sampleRate The target sample rate.
* @param {?Object} details The extra configuration, if needed.
* @param {Object=} options The extra configuration, if needed.
*/
toSampleRate(samples: number, details?:object): void;
toSampleRate(samples: number, options?:object): void;

@@ -241,5 +244,4 @@ /**

* Decode a 4-bit IMA ADPCM wave file as a 16-bit wave file.
* @param {string} bitDepthCode The new bit depth of the samples.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
* Optional. Default is 16.
*/

@@ -255,5 +257,4 @@ fromIMAADPCM(bitDepthCode?: string): void;

* Decode a 8-bit A-Law wave file into a 16-bit wave file.
* @param {string} bitDepthCode The new bit depth of the samples.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
* Optional. Default is 16.
*/

@@ -269,5 +270,4 @@ fromALaw(bitDepthCode?: string): void;

* Decode a 8-bit mu-Law wave file into a 16-bit wave file.
* @param {string} bitDepthCode The new bit depth of the samples.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
* Optional. Default is 16.
*/

@@ -274,0 +274,0 @@ fromMuLaw(bitDepthCode?: string): void;

@@ -42,3 +42,3 @@ /*

/**
* @param {?Uint8Array=} wavBuffer A wave file buffer.
* @param {Uint8Array=} wav A wave file buffer.
* @throws {Error} If container is not RIFF, RIFX or RF64.

@@ -49,6 +49,6 @@ * @throws {Error} If format is not WAVE.

*/
constructor(wavBuffer=null) {
constructor(wav) {
super();
if (wavBuffer) {
this.fromBuffer(wavBuffer);
if (wav) {
this.fromBuffer(wav);
}

@@ -63,3 +63,3 @@ }

fromBase64(base64String) {
this.fromBuffer(new Uint8Array(decode(base64String)));
this.fromBuffer(decode(base64String));
}

@@ -66,0 +66,0 @@

@@ -34,2 +34,3 @@ /*

export function encode(bytes) {
/** @type {string} */
let base64 = '';

@@ -53,5 +54,6 @@ for (let i = 0; i < bytes.length; i += 3) {

* @param {string} base64 A .wav file as a DataURI.
* @return {ArrayBuffer} A .wav file as a DataURI.
* @return {!Uint8Array} A .wav file as a DataURI.
*/
export function decode(base64) {
/** @type {!Uint8Array} */
let lookup = new Uint8Array(256);

@@ -61,2 +63,3 @@ for (let i = 0; i < chars.length; i++) {

}
/** @type {number} */
let bufferLength = base64.length * 0.75;

@@ -69,8 +72,12 @@ if (base64[base64.length - 1] === '=') {

}
let buffer = new ArrayBuffer(bufferLength);
let bytes = new Uint8Array(buffer);
/** @type {!Uint8Array} */
let bytes = new Uint8Array(bufferLength);
for (let i = 0, j = 0; i < base64.length; i += 4) {
/** @type {number} */
let encoded1 = lookup[base64.charCodeAt(i)];
/** @type {number} */
let encoded2 = lookup[base64.charCodeAt(i + 1)];
/** @type {number} */
let encoded3 = lookup[base64.charCodeAt(i + 2)];
/** @type {number} */
let encoded4 = lookup[base64.charCodeAt(i + 3)];

@@ -81,3 +88,3 @@ bytes[j++] = encoded1 << 2 | encoded2 >> 4;

}
return buffer;
return bytes;
}

@@ -32,7 +32,7 @@ /*

* Interleave de-interleaved samples.
* @param {!Array|!TypedArray} samples The samples.
* @return {!Array|!TypedArray}
* @param {!(Array|TypedArray)} samples The samples.
* @return {!(Array|TypedArray)}
*/
export function interleave(samples) {
/** @type {!Array|!TypedArray} */
/** @type {!(Array|TypedArray)} */
let finalSamples = [];

@@ -42,7 +42,5 @@ if (samples.length > 0) {

finalSamples = new Float64Array(samples[0].length * samples.length);
let x = 0;
for (let i = 0, len = samples[0].length; i < len; i++) {
for (let j = 0, subLen = samples.length; j < subLen; j++) {
for (let i = 0, len = samples[0].length, x = 0; i < len; i++) {
for (let j = 0, subLen = samples.length; j < subLen; j++, x++) {
finalSamples[x] = samples[j][i];
x++;
}

@@ -59,10 +57,10 @@ }

* De-interleave samples into multiple channels.
* @param {!Array|TypedArray} samples The samples.
* @param {!(Array|TypedArray)} samples The samples.
* @param {number} numChannels The number of channels to split the samples.
* @param {?Function=} OutputObject The Typed Array object to write the
* samples. Assumes Float64Array by default.
* @return {!Array|!TypedArray}
* @param {Function} [OutputObject=Float64Array] The type of object to
* write the de-interleaved samples.
* @return {!(Array|TypedArray)}
*/
export function deInterleave(samples, numChannels, OutputObject=Float64Array) {
/** @type {!Array|!TypedArray} */
/** @type {!(Array|TypedArray)} */
let finalSamples = [];

@@ -72,6 +70,5 @@ for (let i = 0; i < numChannels; i++) {

}
for (let i = 0; i < numChannels; i ++) {
let s = 0;
for (let j = i; j < samples.length; j+= numChannels) {
finalSamples[i][s++] = samples[j];
for (let i = 0; i < numChannels; i++) {
for (let j = i, s = 0; j < samples.length; j+= numChannels, s++) {
finalSamples[i][s] = samples[j];
}

@@ -78,0 +75,0 @@ }

@@ -30,21 +30,18 @@ /*

import { packString } from 'byte-data';
import { packString } from './binary';
/**
* Pack a string an array of bytes. If the string is smaller than the max size
* and the string is of fixed size, the output array is filled with 0s.
* Pack a string an array of bytes. If the packed string length is smaller
* than the desired byte length the output array is filled with 0s.
* @param {string} str The string to be written as bytes.
* @param {number} maxSize the max size of the string.
* @param {boolean} fixedSize If the string is of fixed size or not.
* @param {number} byteLength the size of the string in bytes.
* @return {!Array<number>} The packed string.
*/
export function writeString(str, maxSize, fixedSize=true) {
export function writeString(str, byteLength) {
/** @type {!Array<number>} */
let packedString = packString(str);
if (fixedSize) {
for (let i=packedString.length; i<maxSize; i++) {
packedString.push(0);
}
for (let i = packedString.length; i < byteLength; i++) {
packedString.push(0);
}
return packedString;
}

@@ -43,2 +43,3 @@ /*

constructor(order, sampleRate, cutOff) {
/** @type {!Array} */
let filters = [];

@@ -71,2 +72,3 @@ for (let i = 0; i < order; i++) {

filter(sample) {
/** @type {number} */
let out = sample;

@@ -79,7 +81,12 @@ for (let i = 0, len = this.stages.length; i < len; i++) {

/**
* @param {!Object} params The filter params.
* @return {!Object}
*/
getCoeffs_(params) {
/** @type {!Object} */
let coeffs = {};
coeffs.z = [0, 0];
coeffs.a = [];
coeffs.b = [];
/** @type {!Object} */
let p = this.preCalc_(params, coeffs);

@@ -93,4 +100,11 @@ coeffs.k = 1;

/**
* @param {!Object} params The filter params.
* @param {!Object} coeffs The coefficients template.
* @return {!Object}
*/
preCalc_(params, coeffs) {
/** @type {!Object} */
let pre = {};
/** @type {number} */
let w = 2 * Math.PI * params.Fc / params.Fs;

@@ -107,9 +121,14 @@ pre.alpha = Math.sin(w) / (2 * params.Q);

runStage_(i, input) {
let temp =
input * this.stages[i].k - this.stages[i].a1 * this.stages[i].z[0] -
this.stages[i].a2 * this.stages[i].z[1];
let out =
this.stages[i].b0 * temp + this.stages[i].b1 * this.stages[i].z[0] +
this.stages[i].b2 * this.stages[i].z[1];
/**
* @param {number} i The stage index.
* @param {number} sample The sample.
* @return {number}
*/
runStage_(i, sample) {
/** @type {number} */
let temp = sample * this.stages[i].k - this.stages[i].a1 *
this.stages[i].z[0] - this.stages[i].a2 * this.stages[i].z[1];
/** @type {number} */
let out = this.stages[i].b0 * temp + this.stages[i].b1 *
this.stages[i].z[0] + this.stages[i].b2 * this.stages[i].z[1];
this.stages[i].z[1] = this.stages[i].z[0];

@@ -116,0 +135,0 @@ this.stages[i].z[0] = temp;

@@ -43,3 +43,5 @@ /*

constructor(order, sampleRate, cutOff) {
/** @type {number} */
let omega = 2 * Math.PI * cutOff / sampleRate;
/** @type {number} */
let dc = 0;

@@ -70,2 +72,3 @@ this.filters = [];

this.z.buf[this.z.pointer] = sample;
/** @type {number} */
let out = 0;

@@ -92,2 +95,3 @@ for (let i = 0, len = this.z.buf.length; i < len; i++) {

initZ_() {
/** @type {!Array} */
let r = [];

@@ -94,0 +98,0 @@ for (let i = 0; i < this.filters.length - 1; i++) {

@@ -34,2 +34,8 @@ /*

/**
* Default use of LPF for each resampling method.
* @readonly
* @enum {boolean}
* @private
*/
const DEFAULT_LPF_USE = {

@@ -42,2 +48,8 @@ 'point': false,

/**
* Default LPF order for each type of LPF.
* @readonly
* @enum {number}
* @private
*/
const DEFAULT_LPF_ORDER = {

@@ -48,2 +60,8 @@ 'IIR': 16,

/**
* Default LPF class for each type of LPF.
* @readonly
* @enum {!Function}
* @private
*/
const DEFAULT_LPF = {

@@ -56,14 +74,18 @@ 'IIR': ButterworthLPF,

* Change the sample rate of the samples to a new sample rate.
* @param {!Array|!TypedArray} samples The original samples.
* @param {!Array<number>|!TypedArray} samples The original samples.
* @param {number} oldSampleRate The original sample rate.
* @param {number} sampleRate The target sample rate.
* @param {?Object} details The extra configuration, if needed.
* @param {Object=} options The extra configuration, if needed.
* @return {!Float64Array} the new samples.
*/
export function resample(samples, oldSampleRate, sampleRate, details={}) {
export function resample(samples, oldSampleRate, sampleRate, options=null) {
options = options || {};
// Make the new sample container
/** @type {number} */
let rate = ((sampleRate - oldSampleRate) / oldSampleRate) + 1;
/** @type {!Float64Array} */
let newSamples = new Float64Array(samples.length * (rate));
// Create the interpolator
details.method = details.method || 'cubic';
options.method = options.method || 'cubic';
/** @type {!Object} */
let interpolator = new Interpolator(

@@ -73,19 +95,20 @@ samples.length,

{
method: details.method,
tension: details.tension || 0,
sincFilterSize: details.sincFilterSize || 6,
sincWindow: details.sincWindow || undefined,
clip: details.clip || 'mirror'
method: options.method,
tension: options.tension || 0,
sincFilterSize: options.sincFilterSize || 6,
sincWindow: options.sincWindow || undefined,
clip: options.clip || 'mirror'
});
// Resample + LPF
if (details.LPF === undefined) {
details.LPF = DEFAULT_LPF_USE[details.method];
if (options.LPF === undefined) {
options.LPF = DEFAULT_LPF_USE[options.method];
}
if (details.LPF) {
details.LPFType = details.LPFType || 'IIR';
const LPF = DEFAULT_LPF[details.LPFType];
if (options.LPF) {
options.LPFType = options.LPFType || 'IIR';
const LPF = DEFAULT_LPF[options.LPFType];
// Upsampling
if (sampleRate > oldSampleRate) {
/** @type {!Object} */
let filter = new LPF(
details.LPForder || DEFAULT_LPF_ORDER[details.LPFType],
options.LPForder || DEFAULT_LPF_ORDER[options.LPFType],
sampleRate,

@@ -97,4 +120,5 @@ (oldSampleRate / 2));

} else {
/** @type {!Object} */
let filter = new LPF(
details.LPForder || DEFAULT_LPF_ORDER[details.LPFType],
options.LPForder || DEFAULT_LPF_ORDER[options.LPFType],
oldSampleRate,

@@ -114,3 +138,3 @@ sampleRate / 2);

* Resample.
* @param {!Array|!TypedArray} samples The original samples.
* @param {!Array<number>|!TypedArray} samples The original samples.
* @param {!Float64Array} newSamples The container for the new samples.

@@ -129,3 +153,3 @@ * @param {Object} interpolator The interpolator.

* Upsample with LPF.
* @param {!Array|!TypedArray} samples The original samples.
* @param {!Array<number>|!TypedArray} samples The original samples.
* @param {!Float64Array} newSamples The container for the new samples.

@@ -150,3 +174,3 @@ * @param {Object} interpolator The interpolator.

* Downsample with LPF.
* @param {!Array|!TypedArray} samples The original samples.
* @param {!Array<number>|!TypedArray} samples The original samples.
* @param {!Float64Array} newSamples The container for the new samples.

@@ -153,0 +177,0 @@ * @param {Object} interpolator The interpolator.

@@ -41,3 +41,3 @@ /*

* @param {number} scaleTo The length of the new array.
* @param {?Object} details The extra configuration, if needed.
* @param {!Object} details The extra configuration, if needed.
*/

@@ -68,14 +68,2 @@ constructor(scaleFrom, scaleTo, details) {

/**
* The clipping function.
* @type {Function}
*/
this.clip_ = clipClamp_;
// The clip function
if (details.clip === 'periodic') {
this.scaleFactor_ = scaleFrom / scaleTo;
this.clip_ = clipPeriodic_;
} else if (details.clip === 'mirror') {
this.clip_ = clipMirror_;
}
/**
* The tanget factor for cubic interpolation.

@@ -100,3 +88,3 @@ * @type {number}

* @param {number} t The index to interpolate.
* @param {Array|TypedArray} samples the original array.
* @param {Array<number>|TypedArray} samples the original array.
* @return {number} The interpolated value.

@@ -110,3 +98,3 @@ */

* @param {number} t The index to interpolate.
* @param {Array|TypedArray} samples the original array.
* @param {Array<number>|TypedArray} samples the original array.
* @return {number} The interpolated value.

@@ -116,2 +104,3 @@ */

t = this.scaleFactor_ * t;
/** @type {number} */
let k = Math.floor(t);

@@ -126,3 +115,3 @@ t -= k;

* @param {number} t The index to interpolate.
* @param {Array|TypedArray} samples the original array.
* @param {Array<number>|TypedArray} samples the original array.
* @return {number} The interpolated value.

@@ -132,8 +121,13 @@ */

t = this.scaleFactor_ * t;
/** @type {number} */
let k = Math.floor(t);
/** @type {Array<number>} */
let m = [this.getTangent_(k, samples), this.getTangent_(k + 1, samples)];
/** @type {Array<number>} */
let p = [this.getClippedInput_(k, samples),
this.getClippedInput_(k + 1, samples)];
t -= k;
/** @type {number} */
let t2 = t * t;
/** @type {number} */
let t3 = t * t2;

@@ -148,3 +142,3 @@ return (2 * t3 - 3 * t2 + 1) *

* @param {number} t The index to interpolate.
* @param {Array|TypedArray} samples the original array.
* @param {Array<number>|TypedArray} samples the original array.
* @return {number} The interpolated value.

@@ -154,5 +148,9 @@ */

t = this.scaleFactor_ * t;
/** @type {number} */
let k = Math.floor(t);
/** @type {number} */
let ref = k - this.sincFilterSize_ + 1;
/** @type {number} */
let ref1 = k + this.sincFilterSize_;
/** @type {number} */
let sum = 0;

@@ -167,3 +165,3 @@ for (let n = ref; n <= ref1; n++) {

* @param {number} k The scaled index to interpolate.
* @param {Array|TypedArray} samples the original array.
* @param {Array<number>|TypedArray} samples the original array.
* @return {number} The tangent.

@@ -180,3 +178,3 @@ * @private

* @param {number} t The scaled index to interpolate.
* @param {Array|TypedArray} samples the original array.
* @param {Array<number>|TypedArray} samples the original array.
* @return {number} The interpolated value.

@@ -189,8 +187,6 @@ * @private

}
return samples[this.clip_(t, this.length_)];
return 0;
}
}
// Sinc functions
/**

@@ -226,42 +222,1 @@ * The default window function.

}
// Clip functions
/**
* @param {number} t The scaled index
* @param {number} n The size of the original array
* @return {number}
* @private
*/
function clipClamp_(t, n) {
return Math.max(0, Math.min(t, n - 1));
}
/**
* @param {number} t The scaled index
* @param {number} n The size of the original array
* @return {number}
* @private
*/
function clipPeriodic_(t, n) {
t = t % n;
if (t < 0) {
t += n;
}
return t;
}
/**
* @param {number} t The scaled index
* @param {number} n The size of the original array
* @return {number}
* @private
*/
function clipMirror_(t, n) {
let period = 2 * (n - 1);
t = clipPeriodic_(t, period);
if (t > n - 1) {
t = period - t;
}
return t;
}

@@ -30,3 +30,3 @@ /*

import { unpackString, unpack } from 'byte-data';
import { unpackString, unpack } from './parsers/binary';

@@ -56,5 +56,5 @@ /**

* A object defining the start and end of all chunks in a wav buffer.
* @type {!Object}
* @type {Object}
*/
this.signature = {};
this.signature = null;
/**

@@ -66,6 +66,6 @@ * @type {number}

/**
* @type {{be: boolean, bits: number, fp: boolean, signed: boolean}}
* @type {!{bits: number, be: boolean}}
* @protected
*/
this.uInt32 = {bits: 32, be: false, signed: false, fp: false};
this.uInt32 = {bits: 32, be: false};
/**

@@ -86,17 +86,17 @@ * The list of supported containers.

setSignature(buffer) {
this.head = 0;
this.container = this.readString(buffer, 4);
if (this.supported_containers.indexOf(this.container) === -1) {
throw Error('Not a supported format.');
}
this.uInt32.be = this.container === 'RIFX';
this.chunkSize = this.readUInt32(buffer);
this.format = this.readString(buffer, 4);
// The RIFF file signature
this.signature = {
chunkId: this.container,
chunkSize: this.chunkSize,
format: this.format,
subChunks: this.getSubChunksIndex_(buffer)
};
this.head = 0;
this.container = this.readString(buffer, 4);
if (this.supported_containers.indexOf(this.container) === -1) {
throw Error('Not a supported format.');
}
this.uInt32.be = this.container === 'RIFX';
this.chunkSize = this.readUInt32(buffer);
this.format = this.readString(buffer, 4);
// The RIFF file signature
this.signature = {
chunkId: this.container,
chunkSize: this.chunkSize,
format: this.format,
subChunks: this.getSubChunksIndex_(buffer)
};
}

@@ -107,3 +107,3 @@

* @param {string} chunkId The chunk fourCC_.
* @param {boolean} multiple True if there may be multiple chunks
* @param {boolean} [multiple=false] True if there may be multiple chunks
* with the same chunkId.

@@ -114,5 +114,5 @@ * @return {Object}

findChunk(chunkId, multiple=false) {
/** @type {!Array<!Object>} */
/** @type {!Array<Object>} */
let chunks = this.signature.subChunks;
/** @type {!Array<!Object>} */
/** @type {!Array<Object>} */
let chunk = [];

@@ -169,12 +169,12 @@ for (let i=0; i<chunks.length; i++) {

getSubChunksIndex_(buffer) {
/** @type {!Array<!Object>} */
let chunks = [];
/** @type {number} */
let i = this.head;
while(i <= buffer.length - 8) {
chunks.push(this.getSubChunkIndex_(buffer, i));
i += 8 + chunks[chunks.length - 1].chunkSize;
i = i % 2 ? i + 1 : i;
}
return chunks;
/** @type {!Array<!Object>} */
let chunks = [];
/** @type {number} */
let i = this.head;
while(i <= buffer.length - 8) {
chunks.push(this.getSubChunkIndex_(buffer, i));
i += 8 + chunks[chunks.length - 1].chunkSize;
i = i % 2 ? i + 1 : i;
}
return chunks;
}

@@ -190,22 +190,22 @@

getSubChunkIndex_(buffer, index) {
/** @type {!Object} */
let chunk = {
chunkId: this.getChunkId_(buffer, index),
chunkSize: this.getChunkSize_(buffer, index),
/** @type {!Object} */
let chunk = {
chunkId: this.getChunkId_(buffer, index),
chunkSize: this.getChunkSize_(buffer, index),
};
if (chunk.chunkId == 'LIST') {
chunk.format = unpackString(buffer, index + 8, index + 12);
this.head += 4;
chunk.subChunks = this.getSubChunksIndex_(buffer);
} else {
/** @type {number} */
let realChunkSize = chunk.chunkSize % 2 ?
chunk.chunkSize + 1 : chunk.chunkSize;
this.head = index + 8 + realChunkSize;
chunk.chunkData = {
start: index + 8,
end: this.head
};
if (chunk.chunkId == 'LIST') {
chunk.format = unpackString(buffer, index + 8, index + 12);
this.head += 4;
chunk.subChunks = this.getSubChunksIndex_(buffer);
} else {
/** @type {number} */
let realChunkSize = chunk.chunkSize % 2 ?
chunk.chunkSize + 1 : chunk.chunkSize;
this.head = index + 8 + realChunkSize;
chunk.chunkData = {
start: index + 8,
end: this.head
};
}
return chunk;
}
return chunk;
}

@@ -221,4 +221,4 @@

getChunkId_(buffer, index) {
this.head += 4;
return unpackString(buffer, index, index + 4);
this.head += 4;
return unpackString(buffer, index, index + 4);
}

@@ -234,5 +234,5 @@

getChunkSize_(buffer, index) {
this.head += 4;
return unpack(buffer, this.uInt32, index + 4);
this.head += 4;
return unpack(buffer, this.uInt32, index + 4);
}
}

@@ -30,8 +30,8 @@ /*

import { changeBitDepth } from 'bitdepth';
import * as imaadpcm from 'imaadpcm';
import * as alawmulaw from 'alawmulaw';
import { unpackArrayTo } from 'byte-data';
import { changeBitDepth } from './codecs/bitdepth';
import * as imaadpcm from './codecs/imaadpcm';
import * as alaw from './codecs/alaw';
import * as mulaw from './codecs/mulaw';
import { unpackArrayTo } from './parsers/binary';
import { WaveFileCueEditor } from './wavefile-cue-editor';
import { truncateIntSamples } from './parsers/truncate-samples';
import { validateSampleRate } from './validators/validate-sample-rate';

@@ -55,3 +55,3 @@ import { resample } from './resampler';

unpackArrayTo(this.data.samples, this.dataType, output,
0, this.data.samples.length, false, false);
0, this.data.samples.length);
this.fromExisting_(

@@ -61,3 +61,4 @@ this.fmt.numChannels,

this.bitDepth,
output);
output,
{container: 'RIFF'});
}

@@ -73,3 +74,3 @@

unpackArrayTo(this.data.samples, this.dataType, output,
0, this.data.samples.length, false, false);
0, this.data.samples.length);
this.fromExisting_(

@@ -101,3 +102,3 @@ this.fmt.numChannels,

unpackArrayTo(this.data.samples, this.dataType, output,
0, this.data.samples.length, false, false);
0, this.data.samples.length);
this.fromExisting_(

@@ -114,5 +115,4 @@ this.fmt.numChannels,

* Decode a 4-bit IMA ADPCM wave file as a 16-bit wave file.
* @param {string} bitDepthCode The new bit depth of the samples.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
* Optional. Default is 16.
*/

@@ -140,3 +140,3 @@ fromIMAADPCM(bitDepthCode='16') {

unpackArrayTo(this.data.samples, this.dataType, output,
0, this.data.samples.length, false, false);
0, this.data.samples.length);
this.fromExisting_(

@@ -146,3 +146,3 @@ this.fmt.numChannels,

'8a',
alawmulaw.alaw.encode(output),
alaw.encode(output),
{container: this.correctContainer_()});

@@ -153,5 +153,4 @@ }

* Decode a 8-bit A-Law wave file into a 16-bit wave file.
* @param {string} bitDepthCode The new bit depth of the samples.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
* Optional. Default is 16.
*/

@@ -163,3 +162,3 @@ fromALaw(bitDepthCode='16') {

'16',
alawmulaw.alaw.decode(this.data.samples),
alaw.decode(this.data.samples),
{container: this.correctContainer_()});

@@ -180,3 +179,3 @@ if (bitDepthCode != '16') {

unpackArrayTo(this.data.samples, this.dataType, output,
0, this.data.samples.length, false, false);
0, this.data.samples.length);
this.fromExisting_(

@@ -186,3 +185,3 @@ this.fmt.numChannels,

'8m',
alawmulaw.mulaw.encode(output),
mulaw.encode(output),
{container: this.correctContainer_()});

@@ -193,5 +192,4 @@ }

* Decode a 8-bit mu-Law wave file into a 16-bit wave file.
* @param {string} bitDepthCode The new bit depth of the samples.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
* Optional. Default is 16.
*/

@@ -203,3 +201,3 @@ fromMuLaw(bitDepthCode='16') {

'16',
alawmulaw.mulaw.decode(this.data.samples),
mulaw.decode(this.data.samples),
{container: this.correctContainer_()});

@@ -215,3 +213,3 @@ if (bitDepthCode != '16') {

* One of '8' ... '32' (integers), '32f' or '64' (floats)
* @param {boolean} changeResolution A boolean indicating if the
* @param {boolean=} [changeResolution=true] A boolean indicating if the
* resolution of samples should be actually changed or not.

@@ -236,3 +234,3 @@ * @throws {Error} If the bit depth is not valid.

* The original samples, interleaved.
* @type {!Array|!TypedArray}
* @type {!(Array|TypedArray)}
*/

@@ -259,13 +257,13 @@ let samples = this.getSamples(true);

* @param {number} sampleRate The target sample rate.
* @param {?Object} details The extra configuration, if needed.
* @param {Object=} options The extra configuration, if needed.
*/
toSampleRate(sampleRate, details={}) {
toSampleRate(sampleRate, options) {
this.validateResample_(sampleRate);
/** @type {!Array|!TypedArray} */
/** @type {!(Array|TypedArray)} */
let samples = this.getSamples();
/** @type {!Array|!Float64Array} */
/** @type {!(Array|Float64Array)} */
let newSamples = [];
// Mono files
if (samples.constructor === Float64Array) {
newSamples = resample(samples, this.fmt.sampleRate, sampleRate, details);
newSamples = resample(samples, this.fmt.sampleRate, sampleRate, options);
// Multi-channel files

@@ -275,17 +273,5 @@ } else {

newSamples.push(resample(
samples[i], this.fmt.sampleRate, sampleRate, details));
samples[i], this.fmt.sampleRate, sampleRate, options));
}
}
// Truncate samples
if (this.bitDepth !== '64' && this.bitDepth !== '32f') {
// Truncate samples in mono files
if (newSamples[0].constructor === Number) {
truncateIntSamples(newSamples, this.dataType.bits);
// Truncate samples in multi-channel files
} else {
for (let i = 0; i < newSamples.length; i++) {
truncateIntSamples(newSamples[i], this.dataType.bits);
}
}
}
// Recreate the file

@@ -358,10 +344,10 @@ this.fromExisting_(

* or any value between '8' and '32' (like '12').
* @param {!Array|!TypedArray} samples
* @param {!(Array|TypedArray)} samples
* The samples. Must be in the correct range according to the bit depth.
* @param {?Object} options Optional. Used to force the container
* as RIFX with {'container': 'RIFX'}
* @param {Object} options Used to define the container. Uses RIFF by default.
* @throws {Error} If any argument does not meet the criteria.
* @private
*/
fromExisting_(numChannels, sampleRate, bitDepthCode, samples, options={}) {
fromExisting_(numChannels, sampleRate, bitDepthCode, samples, options) {
/** @type {!Object} */
let tmpWav = new WaveFileCueEditor();

@@ -368,0 +354,0 @@ Object.assign(this.fmt, tmpWav.fmt);

@@ -34,3 +34,3 @@ /*

import { validateSampleRate } from './validators/validate-sample-rate';
import { packArrayTo, unpackArrayTo, packTo, unpack } from 'byte-data';
import { packArrayTo, unpackArrayTo, packTo, unpack } from './parsers/binary';

@@ -52,6 +52,6 @@ /**

/**
* @type {{be: boolean, bits: number, fp: boolean, signed: boolean}}
* @type {!{bits: number, be: boolean}}
* @protected
*/
this.dataType = {bits: 0, be: false, signed: false, fp: false};
this.dataType = {bits: 0, be: false};
/**

@@ -86,8 +86,9 @@ * Audio formats.

* or any value between '8' and '32' (like '12').
* @param {!Array|!TypedArray} samples The samples.
* @param {?Object} options Optional. Used to force the container
* @param {!(Array|TypedArray)} samples The samples.
* @param {Object=} options Optional. Used to force the container
* as RIFX with {'container': 'RIFX'}
* @throws {Error} If any argument does not meet the criteria.
*/
fromScratch(numChannels, sampleRate, bitDepthCode, samples, options={}) {
fromScratch(numChannels, sampleRate, bitDepthCode, samples, options) {
options = options || {};
// reset all chunks

@@ -101,3 +102,3 @@ this.clearHeaders();

* @param {!Uint8Array} wavBuffer The buffer.
* @param {boolean=} samples True if the samples should be loaded.
* @param {boolean=} [samples=true] True if the samples should be loaded.
* @throws {Error} If container is not RIFF, RIFX or RF64.

@@ -129,7 +130,6 @@ * @throws {Error} If format is not WAVE.

* Return the samples packed in a Float64Array.
* @param {?boolean} interleaved True to return interleaved samples,
* false to return the samples de-interleaved. Defaults to false.
* @param {?Function=} OutputObject The Typed Array object to write the
* samples. Assumes Float64Array by default.
* @return {!Array|!TypedArray} the samples.
* @param {boolean=} [interleaved=false] True to return interleaved samples,
* false to return the samples de-interleaved.
* @param {Function=} [OutputObject=Float64Array] The sample container.
* @return {!(Array|TypedArray)} the samples.
*/

@@ -140,3 +140,3 @@ getSamples(interleaved=false, OutputObject=Float64Array) {

* the length of the samples.
* @type {!Array|!TypedArray}
* @type {!(Array|TypedArray)}
*/

@@ -147,3 +147,3 @@ let samples = new OutputObject(

unpackArrayTo(this.data.samples, this.dataType, samples,
0, this.data.samples.length, false, false);
0, this.data.samples.length);
if (!interleaved && this.fmt.numChannels > 1) {

@@ -168,3 +168,3 @@ return deInterleave(samples, this.fmt.numChannels, OutputObject);

this.data.samples.slice(index, index + this.dataType.bits / 8),
this.dataType, 0, false);
this.dataType);
}

@@ -183,3 +183,3 @@

}
packTo(sample, this.dataType, this.data.samples, index, false);
packTo(sample, this.dataType, this.data.samples, index, true);
}

@@ -233,13 +233,12 @@

* @param {number} sampleRate The sample rate.
* Integers like 8000, 44100, 48000, 96000, 192000.
* Integers like 8000, 44100, 48000, 96000, 192000.
* @param {string} bitDepthCode The audio bit depth code.
* One of '4', '8', '8a', '8m', '16', '24', '32', '32f', '64'
* or any value between '8' and '32' (like '12').
* @param {!Array|!TypedArray} samples The samples.
* @param {?Object} options Optional. Used to force the container
* as RIFX with {'container': 'RIFX'}
* One of '4', '8', '8a', '8m', '16', '24', '32', '32f', '64'
* or any value between '8' and '32' (like '12').
* @param {!(Array|TypedArray)} samples The samples.
* @param {Object} options Used to define the container.
* @throws {Error} If any argument does not meet the criteria.
* @private
*/
newWavFile_(numChannels, sampleRate, bitDepthCode, samples, options={}) {
newWavFile_(numChannels, sampleRate, bitDepthCode, samples, options) {
if (!options.container) {

@@ -255,3 +254,3 @@ options.container = 'RIFF';

this.data.samples = new Uint8Array(samples.length * numBytes);
packArrayTo(samples, this.dataType, this.data.samples, 0, false);
packArrayTo(samples, this.dataType, this.data.samples, 0, true);
this.makeWavHeader_(

@@ -258,0 +257,0 @@ bitDepthCode, numChannels, sampleRate,

@@ -32,3 +32,3 @@ /*

import { writeString } from './parsers/write-string';
import { packTo, packStringTo, packString, pack } from 'byte-data';
import { packTo, packStringTo, packString, pack } from './parsers/binary';

@@ -146,3 +146,3 @@ /**

if (this.iXML.chunkId) {
// chunkSize = byte len of the packed chunk content
/** @type {!Array<number>} */
let iXMLPackedValue = packString(this.iXML.value);

@@ -306,2 +306,3 @@ this.iXML.chunkSize = iXMLPackedValue.length;

if (this.fmt.chunkId) {
/** @type {!Array<number>} */
let bytes = fmtBytes.concat(

@@ -475,3 +476,3 @@ packString(this.fmt.chunkId),

if (this._PMX.chunkId) {
// chunkSize = byte len of the packed chunk content
/** @type {!Array<number>} */
let _PMXPackedValue = packString(this._PMX.value);

@@ -478,0 +479,0 @@ this._PMX.chunkSize = _PMXPackedValue.length;

@@ -31,3 +31,3 @@ /*

import { RIFFFile } from './riff-file';
import { unpackString, unpack } from 'byte-data';
import { unpackString, unpack } from './parsers/binary';

@@ -275,3 +275,3 @@ /**

* @param {!Uint8Array} wavBuffer The buffer.
* @param {boolean=} samples True if the samples should be loaded.
* @param {boolean=} [samples=true] True if the samples should be loaded.
* @throws {Error} If container is not RIFF, RIFX or RF64.

@@ -309,2 +309,3 @@ * @throws {Error} If format is not WAVE.

clearHeaders() {
/** @type {!Object} */
let tmpWav = new WaveFileReader();

@@ -678,3 +679,3 @@ Object.assign(this.fmt, tmpWav.fmt);

* @param {!Uint8Array} bytes The bytes.
* @param {number} index the index to start reading.
* @param {number=} [index=0] the index to start reading.
* @return {string} The string.

@@ -681,0 +682,0 @@ * @private

{
"name": "wavefile",
"version": "10.4.3",
"version": "11.0.0",
"description": "Create, read and write wav files according to the specs.",

@@ -79,3 +79,3 @@ "homepage": "https://github.com/rochars/wavefile",

"test-tsc": "tsc ./test/TypeScript/index.ts && node -r esm ./test/TypeScript/index.js",
"test-cli": "wavefile ./test/files/M1F1-int12WE-AFsp.wav --tag=ICMT",
"test-cli": "wavefile ./test/files/M1F1-int12WE-AFsp.wav --tag=ICMT && wavefile ./test/files/M1F1-int12WE-AFsp.wav --resample=16000 --method=point ./test/files/out/to-sample-rate/M1F1-int12WE-AFsp-CLI.wav",
"test-dist": "npm run test-umd && npm run test-tsc && npm run test-cli",

@@ -91,2 +91,3 @@ "rollup-bundle": "rollup -c && npm run test-dist",

"@rollup/plugin-node-resolve": "^6.0.0",
"byte-data": "^19.0.1",
"codecov": "^3.6.1",

@@ -103,8 +104,3 @@ "docdash": "^1.1.1",

},
"dependencies": {
"alawmulaw": "^5.0.2",
"bitdepth": "^9.0.0",
"byte-data": "^18.1.1",
"imaadpcm": "^5.0.0"
}
"dependencies": {}
}

@@ -20,2 +20,3 @@ # wavefile

- **Handle files up to 2GB**
- **Zero dependencies**

@@ -91,3 +92,3 @@ With **wavefile** you can:

### Command line
### Command line use
To see the available options:

@@ -98,33 +99,2 @@ ```

The available options:
```
--bitdepth Ex: wavefile input.wav --bitdepth=32f output.wav
Change the bit depth.
The input file is not affected.
Possible values: 8, 16, 24, 32, 32f, 64
--compress Ex: wavefile input.wav --compress=adpcm output.wav
Apply compression to the file.
The input file is not affected.
Possible values: adpcm, alaw, mulaw
--tag Ex: wavefile input.wav --tag=ICRD
Print the value of tag if the tag exists.
--list-tags Ex: wavefile input.wav --list-tags
Print all tags of the file.
--list-cue Ex: wavefile input.wav --list-cue
Print all the cue points of the file.
--bits Ex: wavefile input.wav --bits
Print the bit depth of the file.
--rate Ex: wavefile input.wav --rate
Print the sample rate of the file.
--help Ex: --help
Show this help page.
```
## Node.js Example

@@ -169,2 +139,3 @@ ```javascript

* [The samples](#the-samples)
* [Command line](#command-line)
- [API](#api)

@@ -531,3 +502,2 @@ * [The WaveFile methods:](#the-wavefile-methods-)

To get and set samples in a WaveFile instance you should use WaveFile.getSample(index) and WaveFile.setSample(index, sample). The 'index' is the index of the sample in the sample array, not the index of the bytes in data.samples.

@@ -551,3 +521,3 @@

Range:
### Range:
- 0 to 255 for 8-bit

@@ -560,7 +530,69 @@ - -32768 to 32767 for 16-bit

Floating point samples may be defined out of range. Integer samples will be clamped on overflow.
### Command line
To use **wavefile** from the command line, install it globally:
```
$ npm install wavefile -g
```
To see the available options:
```
$ wavefile --help
```
The available options:
```
--resample Ex: wavefile input.wav --resample=44100 output.wav
Change the sample rate. The input file is not affected.
Use with --method to change the interpolation method:
Ex: wavefile in.wav --resample=8000 --method=sinc out.wav
If --method is ommited, cubic interpolation will be used.
--bitdepth Ex: wavefile input.wav --bitdepth=32f output.wav
Change the bit depth.
The input file is not affected.
Possible values: 8, 16, 24, 32, 32f, 64
--compress Ex: wavefile input.wav --compress=adpcm output.wav
Apply compression to the file.
The input file is not affected.
Possible values: adpcm, alaw, mulaw
--tag Ex: wavefile input.wav --tag=ICRD
Print the value of tag if the tag exists.
--list-tags Ex: wavefile input.wav --list-tags
Print all tags of the file.
--list-cue Ex: wavefile input.wav --list-cue
Print all the cue points of the file.
--bits Ex: wavefile input.wav --bits
Print the bit depth of the file.
--rate Ex: wavefile input.wav --rate
Print the sample rate of the file.
--help Ex: --help
Show this help page.
```
The **--resample** command performs resampling using *cubic interpolation* by default. Use it with the **--method** option to change the interpolation method:
```
$ wavefile input.wav --resample=44100 method=sinc output.wav
```
You can use *point*,*linear*,*cubic* and *sinc*.
## API
To create a WaveFile object:
```javascript
// Create a empty WaveFile object
WaveFile();
// Create a WaveFile object with the contents of a wav file buffer
WaveFile(wav);
/**
* @param {?Uint8Array} bytes A wave file buffer.
* @param {Uint8Array=} wav A wave file buffer.
* @throws {Error} If no "RIFF" chunk is found.

@@ -570,3 +602,3 @@ * @throws {Error} If no "fmt " chunk is found.

*/
WaveFile(bytes=null);
WaveFile(wav);
```

@@ -585,17 +617,19 @@

* or any value between '8' and '32' (like '12').
* @param {!Array|!TypedArray} samples The samples.
* @param {?Object} options Optional. Used to force the container
* @param {!(Array|TypedArray)} samples The samples.
* @param {Object=} options Optional. Used to force the container
* as RIFX with {'container': 'RIFX'}
* @throws {Error} If any argument does not meet the criteria.
*/
WaveFile.fromScratch(numChannels, sampleRate, bitDepth, samples, options={}) {}
WaveFile.fromScratch(numChannels, sampleRate, bitDepth, samples, options) {}
/**
* Set up the WaveFile object from a byte buffer.
* @param {!Uint8Array} bytes The buffer.
* Set up the WaveFileParser object from a byte buffer.
* @param {!Uint8Array} wavBuffer The buffer.
* @param {boolean=} [samples=true] True if the samples should be loaded.
* @throws {Error} If container is not RIFF, RIFX or RF64.
* @throws {Error} If no "fmt " chunk is found.
* @throws {Error} If no "data" chunk is found.
* @throws {Error} If format is not WAVE.
* @throws {Error} If no 'fmt ' chunk is found.
* @throws {Error} If no 'data' chunk is found.
*/
WaveFile.fromBuffer(bytes) {}
WaveFile.fromBuffer(bytes, samples=true) {}

@@ -651,6 +685,6 @@ /**

* Change the bit depth of the samples.
* @param {string} bitDepth The new bit depth of the samples.
* One of "8" ... "32" (integers), "32f" or "64" (floats)
* @param {boolean} changeResolution A boolean indicating if the
* resolution of samples should be actually changed or not.
* @param {string} newBitDepth The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats)
* @param {boolean=} [changeResolution=true] A boolean indicating if the
* resolution of samples should be actually changed or not.
* @throws {Error} If the bit depth is not valid.

@@ -661,7 +695,7 @@ */

/**
* Convert the sample rate of the audio.
* Convert the sample rate of the file.
* @param {number} sampleRate The target sample rate.
* @param {?Object} details The extra configuration, if needed.
* @param {Object=} options The extra configuration, if needed.
*/
WaveFile.toSampleRate(sampleRate, details={}) {};
WaveFile.toSampleRate(sampleRate, options=null) {};

@@ -677,5 +711,4 @@ /**

* Decode a 4-bit IMA ADPCM wave file as a 16-bit wave file.
* @param {string} bitDepth The new bit depth of the samples.
* One of "8" ... "32" (integers), "32f" or "64" (floats).
* Optional. Default is 16.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
*/

@@ -691,5 +724,4 @@ WaveFile.fromIMAADPCM(bitDepth='16') {}

* Decode a 8-bit A-Law wave file into a 16-bit wave file.
* @param {string} bitDepth The new bit depth of the samples.
* One of "8" ... "32" (integers), "32f" or "64" (floats).
* Optional. Default is 16.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
*/

@@ -705,5 +737,4 @@ WaveFile.fromALaw(bitDepth='16') {}

* Decode a 8-bit mu-Law wave file into a 16-bit wave file.
* @param {string} bitDepth The new bit depth of the samples.
* One of "8" ... "32" (integers), "32f" or "64" (floats).
* Optional. Default is 16.
* @param {string=} [bitDepthCode='16'] The new bit depth of the samples.
* One of '8' ... '32' (integers), '32f' or '64' (floats).
*/

@@ -818,7 +849,6 @@ WaveFile.fromMuLaw(bitDepth='16') {}

* Return the samples packed in a Float64Array.
* @param {?boolean} interleaved True to return interleaved samples,
* false to return the samples de-interleaved. Defaults to false.
* @param {?Function=} OutputObject The Typed Array object to write the
* samples. Assumes Float64Array by default.
* @return {!Float64Array|Array<Float64Array>} the samples.
* @param {boolean=} [interleaved=false] True to return interleaved samples,
* false to return the samples de-interleaved.
* @param {Function=} [OutputObject=Float64Array] The sample container.
* @return {!(Array|TypedArray)} the samples.
*/

@@ -825,0 +855,0 @@ WaveFile.getSamples(interleaved=false, OutputObject=Float64Array) {};

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc