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 6.0.0 to 6.1.0

CHANGELOG.md

106

dist/wavefile-min.js

@@ -52,55 +52,57 @@ /*

$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,g,e){a!=Array.prototype&&a!=Object.prototype&&(a[g]=e.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,g,e,f){if(g){e=$jscomp.global;a=a.split(".");for(f=0;f<a.length-1;f++){var b=a[f];b in e||(e[b]={});e=e[b]}a=a[a.length-1];f=e[a];g=g(f);g!=f&&null!=g&&$jscomp.defineProperty(e,a,{configurable:!0,writable:!0,value:g})}};$jscomp.polyfill("Object.is",function(a){return a?a:function(a,e){return a===e?0!==a||1/a===1/e:a!==a&&e!==e}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,e){var f=this;f instanceof String&&(f=String(f));var b=f.length;for(e=e||0;e<b;e++)if(f[e]==a||Object.is(f[e],a))return!0;return!1}},"es7","es3");
$jscomp.polyfill=function(a,g,e,f){if(g){e=$jscomp.global;a=a.split(".");for(f=0;f<a.length-1;f++){var c=a[f];c in e||(e[c]={});e=e[c]}a=a[a.length-1];f=e[a];g=g(f);g!=f&&null!=g&&$jscomp.defineProperty(e,a,{configurable:!0,writable:!0,value:g})}};$jscomp.polyfill("Object.is",function(a){return a?a:function(a,e){return a===e?0!==a||1/a===1/e:a!==a&&e!==e}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,e){var f=this;f instanceof String&&(f=String(f));var c=f.length;for(e=e||0;e<c;e++)if(f[e]==a||Object.is(f[e],a))return!0;return!1}},"es7","es3");
$jscomp.checkStringArgs=function(a,g,e){if(null==a)throw new TypeError("The 'this' value for String.prototype."+e+" must not be null or undefined");if(g instanceof RegExp)throw new TypeError("First argument to String.prototype."+e+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,e){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,e||0)}},"es6","es3");
$jscomp.owns=function(a,g){return Object.prototype.hasOwnProperty.call(a,g)};$jscomp.polyfill("Object.assign",function(a){return a?a:function(a,e){for(var f=1;f<arguments.length;f++){var b=arguments[f];if(b)for(var l in b)$jscomp.owns(b,l)&&(a[l]=b[l])}return a}},"es6","es3");
(function(a){function g(f){if(e[f])return e[f].exports;var b=e[f]={i:f,l:!1,exports:{}};a[f].call(b.exports,b,b.exports,g);b.l=!0;return b.exports}var e={};g.m=a;g.c=e;g.d=function(a,b,l){g.o(a,b)||Object.defineProperty(a,b,{configurable:!1,enumerable:!0,get:l})};g.n=function(a){var b=a&&a.__esModule?function(){return a["default"]}:function(){return a};g.d(b,"a",b);return b};g.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};g.p="";return g(g.s=2)})([function(a,g,e){function f(a,
b,c){c=void 0===c?10:c;var d=[];b.char?d=b.char?a.slice(0,b.offset):a:Array.isArray(a)||(d=[a]);return l.toBytes(d,l.getType(b,c))}function b(a,b,c){c=void 0===c?10:c;a=l.fromBytes(a.slice(0,b.offset),l.getType(b,c));return a=b.char?a.slice(0,b.bits/8):a[0]}var l=e(5),c=e(1);a.exports.pack=f;a.exports.unpack=b;a.exports.packArray=function(a,b,c){return l.toBytes(a,l.getType(b,void 0===c?10:c))};a.exports.unpackArray=function(a,b,c){return l.fromBytes(a,l.getType(b,void 0===c?10:c))};a.exports.unpackStruct=
function(a,c,l){l=void 0===l?10:l;for(var d=a.length,h=0,e=0;e<c.length;e++)h+=c[e].offset;if(d<h)return[];d=[];for(e=h=0;h<c.length;)d=d.concat(b(a.slice(e,e+c[h].offset),c[h],l)),e+=c[h].offset,h++;return d};a.exports.packStruct=function(a,b,c){c=void 0===c?10:c;if(a.length<b.length)return[];for(var d=[],h=0;h<b.length;h++)d=d.concat(f(a[h],b[h],c));return d};a.exports.findString=function(a,e){for(var d,k=0;k<a.length;k++)if(d=b(a.slice(k,k+e.length+1),new c({bits:8*e.length,"char":!0})),d==e)return k;
return-1};a.exports.Type=c;a.exports.chr=new c({bits:8,"char":!0});a.exports.fourCC=new c({bits:32,"char":!0});a.exports.bool=new c({bits:1});a.exports.int2=new c({bits:2,signed:!0});a.exports.uInt2=new c({bits:2});a.exports.int4=new c({bits:4,signed:!0});a.exports.uInt4=new c({bits:4});a.exports.int8=new c({bits:8,signed:!0});a.exports.uInt8=new c({bits:8});a.exports.int16=new c({bits:16,signed:!0});a.exports.uInt16=new c({bits:16});a.exports.float16=new c({bits:16,"float":!0});a.exports.int24=new c({bits:24,
signed:!0});a.exports.uInt24=new c({bits:24});a.exports.int32=new c({bits:32,signed:!0});a.exports.uInt32=new c({bits:32});a.exports.float32=new c({bits:32,"float":!0});a.exports.int40=new c({bits:40,signed:!0});a.exports.uInt40=new c({bits:40});a.exports.int48=new c({bits:48,signed:!0});a.exports.uInt48=new c({bits:48});a.exports.float64=new c({bits:64,"float":!0});a.exports.int16BE=new c({bits:16,signed:!0,be:!0});a.exports.uInt16BE=new c({bits:16,be:!0});a.exports.float16BE=new c({bits:16,"float":!0,
be:!0});a.exports.int24BE=new c({bits:24,signed:!0,be:!0});a.exports.uInt24BE=new c({bits:24,be:!0});a.exports.int32BE=new c({bits:32,signed:!0,be:!0});a.exports.uInt32BE=new c({bits:32,be:!0});a.exports.float32BE=new c({bits:32,"float":!0,be:!0});a.exports.int40BE=new c({bits:40,signed:!0,be:!0});a.exports.uInt40BE=new c({bits:40,be:!0});a.exports.int48BE=new c({bits:48,signed:!0,be:!0});a.exports.uInt48BE=new c({bits:48,be:!0});a.exports.float64BE=new c({bits:64,"float":!0,be:!0})},function(a,g,
e){g=new Int8Array(4);var f=new Int32Array(g.buffer,0,1),b=new Float32Array(g.buffer,0,1);g=new Int8Array(8);var l=new Float64Array(g.buffer),c=new Uint32Array(g.buffer),d=e(6),n=function(a){var b=d.call(this,a)||this;b.char=a["char"];b.float=a["float"];b.base=a.base?a.base:10;b.buildType_();return b};$jscomp.inherits(n,d);n.decodeSample=d.decodeSample;n.encodeSample=d.encodeSample;n.mulaw=d.mulaw;n.alaw=d.alaw;n.decodeBlock=d.decodeBlock;n.encodeBlock=d.encodeBlock;n.decode=d.decode;n.encode=d.encode;
n.prototype.read16F_=function(a,b){a=this.read(a,b,{bits:16,offset:2});b=(a&31744)>>10;var h=a&1023;return(b?Math.pow(2,b-15)*(1+h/1024):h/1024*.00006103515625)*(a>>15?-1:1)};n.prototype.read32F_=function(a,d){f[0]=this.read(a,d,{bits:32,offset:4});return b[0]};n.prototype.read64F_=function(a,b){var h=new n({bits:32,offset:4});c[0]=h.read(a,b,{bits:32,offset:4});c[1]=h.read(a,b+4,{bits:32,offset:4});return l[0]};n.prototype.readChar_=function(a,b){for(var h="",d=0;d<this.offset;)h+=String.fromCharCode(a[b+
d]),d++;return h};n.prototype.write64F_=function(a,b,h){l[0]=b;b=new n({bits:32,offset:4,lastByteMask:255});h=b.write(a,c[0],h);return b.write(a,c[1],h)};n.prototype.write32F_=function(a,d,h){b[0]=d;return h=this.write(a,f[0],h)};n.prototype.write16F_=function(a,d,h){b[0]=d;var c=f[0];d=c>>16&32768;var e=c>>12&2047;c=c>>23&255;103<=c&&(d=(d|c-112<<10|e>>1)+(e&1));a[h++]=d&255;a[h++]=d>>>8&255;return h};n.prototype.writeChar_=function(a,b,h){a[h++]=b.charCodeAt(0);return h};n.prototype.buildType_=
$jscomp.owns=function(a,g){return Object.prototype.hasOwnProperty.call(a,g)};$jscomp.polyfill("Object.assign",function(a){return a?a:function(a,e){for(var f=1;f<arguments.length;f++){var c=arguments[f];if(c)for(var l in c)$jscomp.owns(c,l)&&(a[l]=c[l])}return a}},"es6","es3");
(function(a){function g(f){if(e[f])return e[f].exports;var c=e[f]={i:f,l:!1,exports:{}};a[f].call(c.exports,c,c.exports,g);c.l=!0;return c.exports}var e={};g.m=a;g.c=e;g.d=function(a,c,l){g.o(a,c)||Object.defineProperty(a,c,{configurable:!1,enumerable:!0,get:l})};g.n=function(a){var c=a&&a.__esModule?function(){return a["default"]}:function(){return a};g.d(c,"a",c);return c};g.o=function(a,c){return Object.prototype.hasOwnProperty.call(a,c)};g.p="";return g(g.s=2)})([function(a,g,e){function f(a,
c,d){d=void 0===d?10:d;var b=[];c.char?b=c.char?a.slice(0,c.offset):a:Array.isArray(a)||(b=[a]);return l.toBytes(b,l.getType(c,d))}function c(a,c,d){d=void 0===d?10:d;a=l.fromBytes(a.slice(0,c.offset),l.getType(c,d));return a=c.char?a.slice(0,c.bits/8):a[0]}var l=e(5),d=e(1);a.exports.pack=f;a.exports.unpack=c;a.exports.packArray=function(a,c,d){return l.toBytes(a,l.getType(c,void 0===d?10:d))};a.exports.unpackArray=function(a,c,d){return l.fromBytes(a,l.getType(c,void 0===d?10:d))};a.exports.unpackStruct=
function(a,d,l){l=void 0===l?10:l;for(var b=a.length,h=0,e=0;e<d.length;e++)h+=d[e].offset;if(b<h)return[];b=[];for(e=h=0;h<d.length;)b=b.concat(c(a.slice(e,e+d[h].offset),d[h],l)),e+=d[h].offset,h++;return b};a.exports.packStruct=function(a,c,d){d=void 0===d?10:d;if(a.length<c.length)return[];for(var b=[],h=0;h<c.length;h++)b=b.concat(f(a[h],c[h],d));return b};a.exports.findString=function(a,e){for(var b,k=0;k<a.length;k++)if(b=c(a.slice(k,k+e.length+1),new d({bits:8*e.length,"char":!0})),b==e)return k;
return-1};a.exports.Type=d;a.exports.chr=new d({bits:8,"char":!0});a.exports.fourCC=new d({bits:32,"char":!0});a.exports.bool=new d({bits:1});a.exports.int2=new d({bits:2,signed:!0});a.exports.uInt2=new d({bits:2});a.exports.int4=new d({bits:4,signed:!0});a.exports.uInt4=new d({bits:4});a.exports.int8=new d({bits:8,signed:!0});a.exports.uInt8=new d({bits:8});a.exports.int16=new d({bits:16,signed:!0});a.exports.uInt16=new d({bits:16});a.exports.float16=new d({bits:16,"float":!0});a.exports.int24=new d({bits:24,
signed:!0});a.exports.uInt24=new d({bits:24});a.exports.int32=new d({bits:32,signed:!0});a.exports.uInt32=new d({bits:32});a.exports.float32=new d({bits:32,"float":!0});a.exports.int40=new d({bits:40,signed:!0});a.exports.uInt40=new d({bits:40});a.exports.int48=new d({bits:48,signed:!0});a.exports.uInt48=new d({bits:48});a.exports.float64=new d({bits:64,"float":!0});a.exports.int16BE=new d({bits:16,signed:!0,be:!0});a.exports.uInt16BE=new d({bits:16,be:!0});a.exports.float16BE=new d({bits:16,"float":!0,
be:!0});a.exports.int24BE=new d({bits:24,signed:!0,be:!0});a.exports.uInt24BE=new d({bits:24,be:!0});a.exports.int32BE=new d({bits:32,signed:!0,be:!0});a.exports.uInt32BE=new d({bits:32,be:!0});a.exports.float32BE=new d({bits:32,"float":!0,be:!0});a.exports.int40BE=new d({bits:40,signed:!0,be:!0});a.exports.uInt40BE=new d({bits:40,be:!0});a.exports.int48BE=new d({bits:48,signed:!0,be:!0});a.exports.uInt48BE=new d({bits:48,be:!0});a.exports.float64BE=new d({bits:64,"float":!0,be:!0})},function(a,g,
e){g=new Int8Array(4);var f=new Int32Array(g.buffer,0,1),c=new Float32Array(g.buffer,0,1);g=new Int8Array(8);var l=new Float64Array(g.buffer),d=new Uint32Array(g.buffer),b=e(6),n=function(a){var c=b.call(this,a)||this;c.char=a["char"];c.float=a["float"];c.base=a.base?a.base:10;c.buildType_();return c};$jscomp.inherits(n,b);n.decodeSample=b.decodeSample;n.encodeSample=b.encodeSample;n.mulaw=b.mulaw;n.alaw=b.alaw;n.decodeBlock=b.decodeBlock;n.encodeBlock=b.encodeBlock;n.decode=b.decode;n.encode=b.encode;
n.prototype.read16F_=function(a,b){a=this.read(a,b,{bits:16,offset:2});b=(a&31744)>>10;var h=a&1023;return(b?Math.pow(2,b-15)*(1+h/1024):h/1024*.00006103515625)*(a>>15?-1:1)};n.prototype.read32F_=function(a,b){f[0]=this.read(a,b,{bits:32,offset:4});return c[0]};n.prototype.read64F_=function(a,b){var h=new n({bits:32,offset:4});d[0]=h.read(a,b,{bits:32,offset:4});d[1]=h.read(a,b+4,{bits:32,offset:4});return l[0]};n.prototype.readChar_=function(a,b){for(var h="",c=0;c<this.offset;)h+=String.fromCharCode(a[b+
c]),c++;return h};n.prototype.write64F_=function(a,b,h){l[0]=b;b=new n({bits:32,offset:4,lastByteMask:255});h=b.write(a,d[0],h);return b.write(a,d[1],h)};n.prototype.write32F_=function(a,b,h){c[0]=b;return h=this.write(a,f[0],h)};n.prototype.write16F_=function(a,b,h){c[0]=b;var d=f[0];b=d>>16&32768;var e=d>>12&2047;d=d>>23&255;103<=d&&(b=(b|d-112<<10|e>>1)+(e&1));a[h++]=b&255;a[h++]=b>>>8&255;return h};n.prototype.writeChar_=function(a,b,h){a[h++]=b.charCodeAt(0);return h};n.prototype.buildType_=
function(){this.setReader_();this.setWriter_();this.float&&(this.min=-Infinity,this.max=Infinity)};n.prototype.setReader_=function(){this.float?16==this.bits?this.reader=this.read16F_:32==this.bits?this.reader=this.read32F_:64==this.bits&&(this.reader=this.read64F_):this.char&&(this.reader=this.readChar_)};n.prototype.setWriter_=function(){this.float?16==this.bits?this.writer=this.write16F_:32==this.bits?this.writer=this.write32F_:64==this.bits&&(this.writer=this.write64F_):this.char&&(this.writer=
this.writeChar_)};a.exports=n},function(a,g,e){var f=e(3),b=e(4),l=e(8),c=e(9),d=e(0),n=e(0).uInt8,m=e(0).uInt16,k=e(0).uInt32;a=function(a){this.container="";this.chunkSize=0;this.format="";this.fmt={chunkId:"",chunkSize:0,audioFormat:0,numChannels:0,sampleRate:0,byteRate:0,blockAlign:0,bitsPerSample:0,cbSize:0,validBitsPerSample:0,dwChannelMask:0,subformat:[]};this.fact={chunkId:"",chunkSize:0,dwSampleLength:0};this.cue={chunkId:"",chunkSize:0,chunkData_:[]};this.bext={chunkId:"",chunkSize:0,description:"",
originator:"",originatorReference:"",originationDate:"",originationTime:"",timeReference:[],version:0,UMID:"",loudnessValue:0,loudnessRange:0,maxTruePeakLevel:0,maxMomentaryLoudness:0,maxShortTermLoudness:0,reserved:"",codingHistory:""};this.ds64={chunkId:"",riffSizeHigh:0,riffSizeLow:0,dataSizeHigh:0,dataSizeLow:0,originationTime:0,sampleCountHigh:0,sampleCountLow:0,tableLength:0,table:[]};this.data={chunkId:"",chunkSize:0,samples:[]};this.bitDepth="0";this.headerFormats_={4:17,8:1,"8a":6,"8m":7,
16:1,24:1,32:1,"32f":3,40:65534,48:65534,64:3};this.head_=0;this.enforceFact_=!1;this.isInterleaved=!0;a&&this.fromBuffer(a)};a.prototype.fromScratch=function(a,b,d,c,e){e=void 0===e?{}:e;e.container||(e.container="RIFF");var h=((parseInt(d,10)-1|7)+1)/8;this.clearHeader_();this.bitDepth=d;this.container=e.container;this.chunkSize=36+c.length*h;this.format="WAVE";this.fmt.chunkId="fmt ";this.fmt.chunkSize=16;this.fmt.byteRate=a*h*b;this.fmt.blockAlign=a*h;this.fmt.audioFormat=this.headerFormats_[d]?
this.headerFormats_[d]:65534;this.fmt.numChannels=a;this.fmt.sampleRate=b;this.fmt.bitsPerSample=parseInt(d,10);this.data.chunkId="data";this.data.samples=c;0<c.length&&c[0].constructor===Array&&(this.isInterleaved=!1,this.interleave());this.data.chunkSize=c.length*h;"4"==d&&(this.chunkSize=44+c.length,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",this.fact.chunkSize=4,this.fact.dwSampleLength=
2*c.length,this.data.chunkSize=c.length);if("8a"==d||"8m"==d)this.chunkSize=44+c.length,this.fmt.chunkSize=20,this.fmt.cbSize=2,this.fmt.validBitsPerSample=8,this.fact.chunkId="fact",this.fact.chunkSize=4,this.fact.dwSampleLength=c.length;65534==this.fmt.audioFormat&&(this.chunkSize=60+c.length*h,this.fmt.chunkSize=40,this.fmt.bitsPerSample=(parseInt(d,10)-1|7)+1,this.fmt.cbSize=22,this.fmt.validBitsPerSample=parseInt(d,10),this.fmt.dwChannelMask=0,this.fmt.subformat=[1,1048576,2852126848,1905997824])};
a.prototype.fromBuffer=function(a){this.readRIFFChunk_(a);var h="RIFX"==this.container;a=b.read(a,h);this.readFmtChunk_(a.subChunks);this.readFactChunk_(a.subChunks);this.readBextChunk_(a.subChunks);this.readCueChunk_(a.subChunks);this.readDataChunk_(a.subChunks,{be:h,single:!0});this.bitDepth=3==this.fmt.audioFormat&&32==this.fmt.bitsPerSample?"32f":6==this.fmt.audioFormat?"8a":7==this.fmt.audioFormat?"8m":this.fmt.bitsPerSample.toString()};a.prototype.toBuffer=function(){this.checkWriteInput_();
this.assureInterleaved_();return new Uint8Array(this.createWaveFile_())};a.prototype.toRIFF=function(){this.container="RIFF";this.LEorBE_()};a.prototype.toRIFX=function(){this.container="RIFX";this.LEorBE_()};a.prototype.toBitDepth=function(a,b){var h=a,d=this.bitDepth;void 0===b||b||(h=this.realBitDepth_(a),d=this.realBitDepth_(this.bitDepth));this.assureInterleaved_();f.toBitDepth(this.data.samples,d,h);this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,a,this.data.samples,{container:this.container})};
a.prototype.interleave=function(){if(!this.isInterleaved){for(var a=[],b=this.data.samples[0].length,d=0;d<b;d++)for(var c=0;c<this.data.samples.length;c++)a.push(this.data.samples[c][d]);this.data.samples=a;this.isInterleaved=!0}};a.prototype.deInterleave=function(){if(this.isInterleaved){var a=[],b;for(b=0;b<this.fmt.numChannels;b++)a[b]=[];b=0;for(var d;b<this.data.samples.length;){for(d=0;d<this.fmt.numChannels;d++)a[d].push(this.data.samples[b+d]);b+=d}this.data.samples=a;this.isInterleaved=
!1}};a.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.assure16Bit_();this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"4",l.encode(this.data.samples),{container:this.container})};a.prototype.fromIMAADPCM=function(){this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"16",l.decode(this.data.samples,this.fmt.blockAlign),
{container:this.container})};a.prototype.toALaw=function(){this.assure16Bit_();this.assureInterleaved_();this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"8a",c.alaw.encode(this.data.samples),{container:this.container})};a.prototype.fromALaw=function(){this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"16",c.alaw.decode(this.data.samples),{container:this.container})};a.prototype.toMuLaw=function(){this.assure16Bit_();this.assureInterleaved_();this.fromScratch(this.fmt.numChannels,
this.fmt.sampleRate,"8m",c.mulaw.encode(this.data.samples),{container:this.container})};a.prototype.fromMuLaw=function(){this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"16",c.mulaw.decode(this.data.samples),{container:this.container})};a.prototype.realBitDepth_=function(a){"32f"!=a&&(a=((parseInt(a,10)-1|7)+1).toString());return a};a.prototype.checkWriteInput_=function(){this.validateBitDepth_();this.validateNumChannels_();this.validateSampleRate_()};a.prototype.validateBitDepth_=function(){if(!this.headerFormats_[this.bitDepth]){if(8<
parseInt(this.bitDepth,10)&&54>parseInt(this.bitDepth,10))return!0;throw Error("Invalid bit depth.");}return!0};a.prototype.validateNumChannels_=function(){var a=this.fmt.numChannels*this.fmt.bitsPerSample/8;if(1>this.fmt.numChannels||65535<a)throw Error("Invalid number of channels.");return!0};a.prototype.validateSampleRate_=function(){var a=this.fmt.bitsPerSample/8*this.fmt.numChannels*this.fmt.sampleRate;if(1>this.fmt.sampleRate||4294967295<a)throw Error("Invalid sample rate.");return!0};a.prototype.clearHeader_=
function(){this.fmt.cbSize=0;this.fmt.validBitsPerSample=0;this.fact.chunkId="";this.fact.chunkSize=0;this.fact.dwSampleLength=0};a.prototype.assure16Bit_=function(){this.assureUncompressed_();"16"!=this.bitDepth&&this.toBitDepth("16")};a.prototype.assureUncompressed_=function(){"8a"==this.bitDepth?this.fromALaw():"8m"==this.bitDepth?this.fromMuLaw():"4"==this.bitDepth&&this.fromIMAADPCM()};a.prototype.assureInterleaved_=function(){this.isInterleaved||this.interleave()};a.prototype.readRIFFChunk_=
function(a){this.container=d.unpackArray(a.slice(0,4),d.chr);if("RIFF"!=this.container&&"RIFX"!=this.container)throw Error("Not a supported format.");this.LEorBE_();this.chunkSize=d.unpack(a.slice(4,8),k);this.format=d.unpackArray(a.slice(8,12),d.chr);if("WAVE"!=this.format)throw Error("Could not find the 'WAVE' format identifier");};a.prototype.LEorBE_=function(){var a="RIFX"==this.container;n.be=a;m.be=a;return k.be=a};a.prototype.readFmtChunk_=function(a){if(a=this.findChunk_(a,"fmt "))this.fmt.chunkId=
"fmt ",this.fmt.chunkSize=a.chunkSize,this.fmt.audioFormat=d.unpack(a.chunkData.slice(0,2),m),this.fmt.numChannels=d.unpack(a.chunkData.slice(2,4),m),this.fmt.sampleRate=d.unpack(a.chunkData.slice(4,8),k),this.fmt.byteRate=d.unpack(a.chunkData.slice(8,12),k),this.fmt.blockAlign=d.unpack(a.chunkData.slice(12,14),m),this.fmt.bitsPerSample=d.unpack(a.chunkData.slice(14,16),m),this.readFmtExtension_(a);else throw Error("Could not find the 'fmt ' chunk");};a.prototype.readFmtExtension_=function(a){a=a.chunkData;
16<this.fmt.chunkSize&&(this.fmt.cbSize=d.unpack(a.slice(16,18),m),18<this.fmt.chunkSize&&(this.fmt.validBitsPerSample=d.unpack(a.slice(18,20),m),20<this.fmt.chunkSize&&(this.fmt.dwChannelMask=d.unpack(a.slice(20,24),k),this.fmt.subformat=[d.unpack(a.slice(24,28),k),d.unpack(a.slice(28,32),k),d.unpack(a.slice(32,36),k),d.unpack(a.slice(36,40),k)])))};a.prototype.readFactChunk_=function(a){if(a=this.findChunk_(a,"fact"))this.fact.chunkId="fact",this.fact.chunkSize=a.chunkSize,this.fact.dwSampleLength=
d.unpack(a.chunkData.slice(0,4),k);else if(this.enforceFact_)throw Error("Could not find the 'fact' chunk");};a.prototype.readBextChunk_=function(a){if(a=this.findChunk_(a,"bext"))a=a.chunkData,this.head_=0,this.bext={chunkId:"bext",chunkSize:a.length,description:this.readString_(a,256),originator:this.readString_(a,32),originatorReference:this.readString_(a,32),originationDate:this.readString_(a,10),originationTime:this.readString_(a,8),timeReference:[this.readFromChunk_(a,k),this.readFromChunk_(a,
k)],version:this.readFromChunk_(a,m),UMID:this.readString_(a,64),loudnessValue:this.readFromChunk_(a,m),loudnessRange:this.readFromChunk_(a,m),maxTruePeakLevel:this.readFromChunk_(a,m),maxMomentaryLoudness:this.readFromChunk_(a,m),maxShortTermLoudness:this.readFromChunk_(a,m),reserved:this.readString_(a,180),codingHistory:this.readString_(a,a.length-602)}};a.prototype.readString_=function(a,b){for(var c="",h=0;h<b;h++)c+=d.unpack([a[this.head_]],d.chr),this.head_++;return c};a.prototype.readFromChunk_=
function(a,b){var c=b.bits/8;a=d.unpack(a.slice(this.head_,this.head_+c),b);this.head_+=c;return a};a.prototype.writeString_=function(a,b){a=d.packArray(a,d.chr);for(var c=a.length;c<b;c++)a.push(0);return a};a.prototype.readCueChunk_=function(a){if(a=this.findChunk_(a,"cue "))this.cue.chunkId="cue ",this.cue.chunkSize=a.chunkSize,this.cue.chunkData_=a.chunkData};a.prototype.readDataChunk_=function(a,b){if(a=this.findChunk_(a,"data"))this.data.chunkId="data",this.data.chunkSize=a.chunkSize,this.samplesFromBytes_(a.chunkData,
b);else throw Error("Could not find the 'data' chunk");};a.prototype.samplesFromBytes_=function(a,b){b.bits=4==this.fmt.bitsPerSample?8:this.fmt.bitsPerSample;b.signed=8==b.bits?!1:!0;b.float=3==this.fmt.audioFormat||64==this.fmt.bitsPerSample?!0:!1;b.single=!1;this.data.samples=d.unpackArray(a,new d.Type(b))};a.prototype.findChunk_=function(a,b){for(var d=0;d<a.length;d++)if(a[d].chunkId==b)return a[d];return null};a.prototype.samplesToBytes_=function(a){a.bits=4==this.fmt.bitsPerSample?8:this.fmt.bitsPerSample;
a.signed=8==a.bits?!1:!0;a.float=3==this.fmt.audioFormat||64==this.fmt.bitsPerSample?!0:!1;a=d.packArray(this.data.samples,new d.Type(a));a.length%2&&a.push(0);return a};a.prototype.getBextBytes_=function(){return this.bext.chunkId?[].concat(d.packArray(this.bext.chunkId,d.chr),d.pack(this.bext.chunkSize,k),this.writeString_(this.bext.description,256),this.writeString_(this.bext.originator,32),this.writeString_(this.bext.originatorReference,32),this.writeString_(this.bext.originationDate,10),this.writeString_(this.bext.originationTime,
8),d.pack(this.bext.timeReference[0],k),d.pack(this.bext.timeReference[1],k),d.pack(this.bext.version,m),this.writeString_(this.bext.UMID,64),d.pack(this.bext.loudnessValue,m),d.pack(this.bext.loudnessRange,m),d.pack(this.bext.maxTruePeakLevel,m),d.pack(this.bext.maxMomentaryLoudness,m),d.pack(this.bext.maxShortTermLoudness,m),this.writeString_(this.bext.reserved,180),this.writeString_(this.bext.codingHistory,this.bext.chunkSize-602)):[]};a.prototype.getCueBytes_=function(){return this.cue.chunkId?
[].concat(d.packArray(this.cue.chunkId,d.chr),d.pack(this.cue.chunkSize,k),this.cue.chunkData_):[]};a.prototype.getFactBytes_=function(){return this.fact.chunkId?[].concat(d.packArray(this.fact.chunkId,d.chr),d.pack(this.fact.chunkSize,k),d.pack(this.fact.dwSampleLength,k)):[]};a.prototype.getFmtExtensionBytes_=function(){var a=[];16<this.fmt.chunkSize&&(a=a.concat(d.pack(this.fmt.cbSize,m)));18<this.fmt.chunkSize&&(a=a.concat(d.pack(this.fmt.validBitsPerSample,m)));20<this.fmt.chunkSize&&(a=a.concat(d.pack(this.fmt.dwChannelMask,
k)));24<this.fmt.chunkSize&&(a=a.concat(d.pack(this.fmt.subformat[0],k),d.pack(this.fmt.subformat[1],k),d.pack(this.fmt.subformat[2],k),d.pack(this.fmt.subformat[3],k)));return a};a.prototype.createWaveFile_=function(){var a={be:this.LEorBE_()};return[].concat(d.packArray(this.container,d.chr),d.pack(this.chunkSize,k),d.packArray(this.format,d.chr),this.getBextBytes_(),d.packArray(this.fmt.chunkId,d.chr),d.pack(this.fmt.chunkSize,k),d.pack(this.fmt.audioFormat,m),d.pack(this.fmt.numChannels,m),d.pack(this.fmt.sampleRate,
k),d.pack(this.fmt.byteRate,k),d.pack(this.fmt.blockAlign,m),d.pack(this.fmt.bitsPerSample,m),this.getFmtExtensionBytes_(),this.getFactBytes_(),d.packArray(this.data.chunkId,d.chr),d.pack(this.data.chunkSize,k),this.samplesToBytes_(a),this.getCueBytes_())};window.WaveFile=window.WaveFile?window.WaveFile:a},function(a,g){var e=new Float32Array(1),f={intToInt:function(a,e){return a=0<a?parseInt(a/e.oldPositive*e.newPositive,10):parseInt(a/e.oldNegative*e.newNegative,10)},floatToInt:function(a,e){return 0<
a?parseInt(a*e.newPositive,10):parseInt(a*e.newNegative,10)},intToFloat:function(a,e){return 0<a?a/e.oldPositive:a/e.oldNegative},floatToFloat:function(a,l){"64"==l.original&&"32f"==l.target&&(e[0]=a,a=e[0]);return a}};a.exports.toBitDepth=function(a,e,c){for(var d=[],b=8;49>b;b++)d.push(b.toString());d.push("32f");d.push("64");if(-1==d.indexOf(e)||-1==d.indexOf(c))throw Error("Invalid bit depth.");d=["32f","64"].includes(e)?"float":"int";b=["32f","64"].includes(c)?"Float":"Int";d=f[d+"To"+b];b=a.length;
for(var l=0;l<b;l++){var k=l,h=a[l];"8"==e&&(h-=128);a[k]=h;a[l]=d(a[l],{oldNegative:parseInt(Math.pow(2,parseInt(e,10))/2,10),newNegative:parseInt(Math.pow(2,parseInt(c,10))/2,10),oldPositive:parseInt(Math.pow(2,parseInt(e,10))/2-1,10),newPositive:parseInt(Math.pow(2,parseInt(c,10))/2-1,10),original:e,target:c});k=l;h=a[l];"8"==c&&(h+=128);a[k]=h}}},function(a,g,e){function f(a){m.be="RIFX"===a.chunkId;var c=d.packArray(a.chunkId,n).concat(d.pack(a.chunkSize,m),d.packArray(a.format,n),b(a.subChunks));
if("RIFF"===a.chunkId||"RIFX"===a.chunkId)c=new Uint8Array(c);return c}function b(a){for(var b=[],c=0;c<a.length;)b="LIST"===a[c].chunkId?b.concat(f(a[c])):b.concat(d.packArray(a[c].chunkId,n),d.pack(a[c].chunkSize,m),a[c].chunkData),c++;return b}function l(a){for(var b=[],d=12;d<a.length;)b.push(c(a,d)),d+=8+b[b.length-1].chunkSize;return b}function c(a,b){var c={chunkId:d.unpackArray(a.slice(b,b+4),n),chunkSize:d.unpack(a.slice(b+4,b+8),m)};"LIST"===c.chunkId?(c.format=d.unpackArray(a.slice(8,12),
n),c.subChunks=l(a.slice(b,b+c.chunkSize))):c.chunkData=a.slice(b+8,b+8+c.chunkSize);return c}var d=e(0),n=d.chr,m=d.uInt32;a.exports.read=function(a){a=[].slice.call(a);var b=d.unpackArray(a.slice(0,4),n);m.be="RIFX"===b;return{chunkId:b,chunkSize:d.unpack(a.slice(4,8),m),format:d.unpackArray(a.slice(8,12),n),subChunks:l(a)}};a.exports.write=f},function(a,g,e){var f=e(1),b=e(7);a.exports.getType=function(a,b){a=Object.assign(new f({}),a);a.base=b;return a};a.exports.toBytes=function(a,c){for(var d=
0,e=0,l=a.length,f=[];d<l;)e=c.writer(f,a[d++],e);c.be&&b(f,c.offset);if(10!=c.base){a=c.base;d=0;for(e=f.length;d<e;)f[d]=f[d].toString(a),d++;a=0;d=f.length;for(c=(2==c.base?8:2)+1;a<d;)f[a]=Array(c-f[a].length).join("0")+f[a],a++}return f};a.exports.fromBytes=function(a,c){c.be&&b(a,c.offset);if(10!=c.base)for(var d=c.base,e=0,f=a.length;e<f;)a[e]=parseInt(a[e],d),e++;d=[];e=0;for(f=a.length-(c.offset-1);e<f;)d.push(c.reader(a,e)),e+=c.offset;c.char&&(d=d.join(""));return d}},function(a,g){g=function(a){this.bits=
a.bits;this.be=a.be;this.signed=a.signed;this.reader=this.read;this.writer=this.write;this.offset=0;this.min=-Infinity;this.max=Infinity;this.realBits_=this.bits;this.lastByteMask_=255;this.build_()};g.prototype.read=function(a,f){f=void 0===f?0:f;if(32<this.bits)return this.readBits_(a,f);for(var b=0,e=this.offset-1;0<e;)b|=a[e+f]<<8*e,e--;b=(a[f]|b)>>>0;return this.overflow_(this.sign_(b))};g.prototype.write=function(a,f,b){b=void 0===b?0:b;f=this.overflow_(f);var e=255;b=this.writeFirstByte_(a,
f,b);for(var c=2;c<=this.offset;c++)c==this.offset&&(e=this.lastByteMask_),a[b++]=Math.floor(f/Math.pow(2,8*(c-1)))&e;return b};g.prototype.readBits_=function(a,f){f=void 0===f?0:f;for(var b="",e=0;e<this.offset;){var c=a[f+e].toString(2);b=Array(9-c.length).join("0")+c+b;e++}return this.overflow_(this.sign_(parseInt(b,2)))};g.prototype.build_=function(){this.validateWordSize_();this.setRealBits_();this.setLastByteMask_();this.setMinMax_();this.offset=8>this.bits?1:Math.ceil(this.realBits_/8)};g.prototype.sign_=
function(a){a>this.max&&(a-=2*this.max+2);return a};g.prototype.overflow_=function(a){a>this.max?a=this.max:a<this.min&&(a=this.min);return a};g.prototype.setMinMax_=function(){var a=Math.pow(2,this.bits);this.signed?(this.max=a/2-1,this.min=-a/2):(this.max=a-1,this.min=0)};g.prototype.validateWordSize_=function(){if(1>this.bits||64<this.bits)throw Error("Not a supported type.");};g.prototype.setRealBits_=function(){8<this.bits&&(this.realBits_=(this.bits-1|7)+1)};g.prototype.setLastByteMask_=function(){var a=
8-(this.realBits_-this.bits);this.lastByteMask_=Math.pow(2,0<a?a:8)-1};g.prototype.writeFirstByte_=function(a,f,b){8>this.bits?a[b++]=0>f?f+Math.pow(2,this.bits):f:a[b++]=f&255;return b};a.exports=g},function(a,g){a.exports=function(a,f){for(var b=a.length,e=0;e<b;){for(var c=a,d=e,g=0,m=f-1,k=parseInt(f/2,10);g<k;){var h=c[d+g];c[d+g]=c[d+m];c[d+m]=h;g++;m--}e+=f}}},function(a,g){function e(a){return 32768<a?a-65536:a}function f(a){var b=a-m;0<=b?a=0:(a=8,b=-b);var c=n[k],e=c>>3;b>c&&(a|=4,b-=c,
e+=c);c>>=1;b>c&&(a|=2,b-=c,e+=c);c>>=1;b>c&&(a|=1,e+=c);b=a;m=b&8?m-e:m+e;-32768>m?m=-32768:32767<m&&(m=32767);k+=d[b&7];0>k?k=0:88<k&&(k=88);return a}function b(a){var b=0;a&4&&(b+=q);a&2&&(b+=q>>1);a&1&&(b+=q>>2);b+=q>>3;a&8&&(b=-b);h+=b;32767<h?h=32767:-32767>h&&(h=-32767);p+=d[a];0>p?p=0:88<p&&(p=88);q=n[p];return h}function l(a){var b=a[0];f(b);var c=[];c.push(b&255);c.push(b>>8&255);c.push(k);c.push(0);for(b=3;b<a.length;b+=2){var d=f(a[b]),e=f(a[b+1]);c.push(e<<4|d)}for(;256>c.length;)c.push(0);
return c}function c(a){h=e(a[1]<<8|a[0]);p=a[2];q=n[p];for(var c=[h,e(a[3]<<8|a[2])],d=4;d<a.length;d++){var f=a[d],g=f>>4;c.push(b(g<<4^f));c.push(b(g))}return c}var d=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],n=[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],m=0,k=0,h=0,p=0,q=7;a.exports.encode=function(a){for(var b=[],c=[],d=0;d<a.length;d++)if(c.push(a[d]),0==d%505&&0!=d||d==a.length-1)b=b.concat(l(c)),c=[];return b};a.exports.decode=function(a,b){b=void 0===b?256:b;for(var d=[],e=[],f=0;f<a.length;f++)0==f%b&&0!=f&&(d=d.concat(c(e)),e=[]),e.push(a[f]);return d};a.exports.encodeBlock=l;a.exports.decodeBlock=c},function(a,g,e){a.exports.alaw=e(10);a.exports.mulaw=
e(11)},function(a,g){function e(a){var b=[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],c;a=-32768==a?-32767:a;(c=~a>>8&128)||(a*=-1);32635<a&&(a=32635);256<=a?(b=b[a>>8&127],a=b<<4|a>>b+3&15):a>>=4;return a^c^85}function f(a){var b=0;a^=85;a&128&&(a&=-129,b=-1);var c=((a&240)>>4)+4;a=4!=c?
1<<c|(a&15)<<c-4|1<<c-5:a<<1|1;return-8*(0===b?a:-a)}a.exports.encodeSample=e;a.exports.decodeSample=f;a.exports.encode=function(a){for(var b=[],c=0;c<a.length;c++)b.push(e(a[c]));return b};a.exports.decode=function(a){for(var b=[],c=0;c<a.length;c++)b.push(f(a[c]));return b}},function(a,g){function e(a){if(0>a){a=132-a;var b=127}else a+=132,b=255;32767<a&&(a=32767);var c=0;var d=a>>7;d&240&&(d>>=4,c+=4);d&12&&(d>>=2,c+=2);d&2&&(c+=1);d=c;return(d<<4|a>>d+3&15)^b}function f(a){a=~a;var b=((a&15)<<
3)+132<<((a&112)>>4);return a&128?132-b:b-132}a.exports.encodeSample=e;a.exports.decodeSample=f;a.exports.encode=function(a){for(var b=[],c=0;c<a.length;c++)b.push(e(a[c]));return b};a.exports.decode=function(a){for(var b=[],c=0;c<a.length;c++)b.push(f(a[c]));return b}}]);
this.writeChar_)};a.exports=n},function(a,g,e){var f=e(3),c=e(4),l=e(8),d=e(9),b=e(0),n=e(0).uInt8,m=e(0).uInt16,k=e(0).uInt32;a=function(a){this.container="";this.chunkSize=0;this.format="";this.fmt={chunkId:"",chunkSize:0,audioFormat:0,numChannels:0,sampleRate:0,byteRate:0,blockAlign:0,bitsPerSample:0,cbSize:0,validBitsPerSample:0,dwChannelMask:0,subformat:[]};this.fact={chunkId:"",chunkSize:0,dwSampleLength:0};this.cue={chunkId:"",chunkSize:0,dwCuePoints:0,points:[]};this.bext={chunkId:"",chunkSize:0,
description:"",originator:"",originatorReference:"",originationDate:"",originationTime:"",timeReference:[],version:0,UMID:"",loudnessValue:0,loudnessRange:0,maxTruePeakLevel:0,maxMomentaryLoudness:0,maxShortTermLoudness:0,reserved:"",codingHistory:""};this.ds64={chunkId:"",riffSizeHigh:0,riffSizeLow:0,dataSizeHigh:0,dataSizeLow:0,originationTime:0,sampleCountHigh:0,sampleCountLow:0,tableLength:0,table:[]};this.data={chunkId:"",chunkSize:0,samples:[]};this.bitDepth="0";this.audioFormats_={4:17,8:1,
"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,40:65534,48:65534,64:3};this.head_=0;this.enforceFact_=!1;this.isInterleaved=!0;a&&this.fromBuffer(a)};a.prototype.fromScratch=function(a,b,c,d,e){e=void 0===e?{}:e;e.container||(e.container="RIFF");var h=((parseInt(c,10)-1|7)+1)/8;this.clearHeader_();this.bitDepth=c;this.container=e.container;this.chunkSize=36+d.length*h;this.format="WAVE";this.fmt.chunkId="fmt ";this.fmt.chunkSize=16;this.fmt.byteRate=a*h*b;this.fmt.blockAlign=a*h;this.fmt.audioFormat=this.audioFormats_[c]?
this.audioFormats_[c]:65534;this.fmt.numChannels=a;this.fmt.sampleRate=b;this.fmt.bitsPerSample=parseInt(c,10);this.data.chunkId="data";this.data.samples=d;0<d.length&&d[0].constructor===Array&&(this.isInterleaved=!1,this.interleave());this.data.chunkSize=d.length*h;"4"==c&&(this.chunkSize=44+d.length,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",this.fact.chunkSize=4,this.fact.dwSampleLength=
2*d.length,this.data.chunkSize=d.length);if("8a"==c||"8m"==c)this.chunkSize=44+d.length,this.fmt.chunkSize=20,this.fmt.cbSize=2,this.fmt.validBitsPerSample=8,this.fact.chunkId="fact",this.fact.chunkSize=4,this.fact.dwSampleLength=d.length;65534==this.fmt.audioFormat&&(this.chunkSize=60+d.length*h,this.fmt.chunkSize=40,this.fmt.bitsPerSample=(parseInt(c,10)-1|7)+1,this.fmt.cbSize=22,this.fmt.validBitsPerSample=parseInt(c,10),this.fmt.dwChannelMask=0,this.fmt.subformat=[1,1048576,2852126848,1905997824])};
a.prototype.fromBuffer=function(a){this.readRIFFChunk_(a);var h="RIFX"==this.container;a=c.read(a,h);this.readFmtChunk_(a.subChunks);this.readFactChunk_(a.subChunks);this.readBextChunk_(a.subChunks);this.readCueChunk_(a.subChunks);this.readDataChunk_(a.subChunks,{be:h,single:!0});this.bitDepth=3==this.fmt.audioFormat&&32==this.fmt.bitsPerSample?"32f":6==this.fmt.audioFormat?"8a":7==this.fmt.audioFormat?"8m":this.fmt.bitsPerSample.toString()};a.prototype.toBuffer=function(){this.checkWriteInput_();
this.assureInterleaved_();return this.createWaveFile_()};a.prototype.toRIFF=function(){this.container="RIFF";this.LEorBE_()};a.prototype.toRIFX=function(){this.container="RIFX";this.LEorBE_()};a.prototype.toBitDepth=function(a,b){var h=a,c=this.bitDepth;void 0===b||b||(h=this.realBitDepth_(a),c=this.realBitDepth_(this.bitDepth));this.assureInterleaved_();f.toBitDepth(this.data.samples,c,h);this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,a,this.data.samples,{container:this.container})};a.prototype.interleave=
function(){if(!this.isInterleaved){for(var a=[],b=this.data.samples[0].length,c=0;c<b;c++)for(var d=0;d<this.data.samples.length;d++)a.push(this.data.samples[d][c]);this.data.samples=a;this.isInterleaved=!0}};a.prototype.deInterleave=function(){if(this.isInterleaved){var a=[],b;for(b=0;b<this.fmt.numChannels;b++)a[b]=[];b=0;for(var c;b<this.data.samples.length;){for(c=0;c<this.fmt.numChannels;c++)a[c].push(this.data.samples[b+c]);b+=c}this.data.samples=a;this.isInterleaved=!1}};a.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.assure16Bit_();this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"4",l.encode(this.data.samples),{container:this.container})};a.prototype.fromIMAADPCM=function(){this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"16",l.decode(this.data.samples,this.fmt.blockAlign),{container:this.container})};
a.prototype.toALaw=function(){this.assure16Bit_();this.assureInterleaved_();this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"8a",d.alaw.encode(this.data.samples),{container:this.container})};a.prototype.fromALaw=function(){this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"16",d.alaw.decode(this.data.samples),{container:this.container})};a.prototype.toMuLaw=function(){this.assure16Bit_();this.assureInterleaved_();this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"8m",d.mulaw.encode(this.data.samples),
{container:this.container})};a.prototype.fromMuLaw=function(){this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"16",d.mulaw.decode(this.data.samples),{container:this.container})};a.prototype.realBitDepth_=function(a){"32f"!=a&&(a=((parseInt(a,10)-1|7)+1).toString());return a};a.prototype.checkWriteInput_=function(){this.validateBitDepth_();this.validateNumChannels_();this.validateSampleRate_()};a.prototype.validateBitDepth_=function(){if(!this.audioFormats_[this.bitDepth]){if(8<parseInt(this.bitDepth,
10)&&54>parseInt(this.bitDepth,10))return!0;throw Error("Invalid bit depth.");}return!0};a.prototype.validateNumChannels_=function(){var a=this.fmt.numChannels*this.fmt.bitsPerSample/8;if(1>this.fmt.numChannels||65535<a)throw Error("Invalid number of channels.");return!0};a.prototype.validateSampleRate_=function(){var a=this.fmt.bitsPerSample/8*this.fmt.numChannels*this.fmt.sampleRate;if(1>this.fmt.sampleRate||4294967295<a)throw Error("Invalid sample rate.");return!0};a.prototype.clearHeader_=function(){this.fmt.cbSize=
0;this.fmt.validBitsPerSample=0;this.fact.chunkId="";this.fact.chunkSize=0;this.fact.dwSampleLength=0};a.prototype.assure16Bit_=function(){this.assureUncompressed_();"16"!=this.bitDepth&&this.toBitDepth("16")};a.prototype.assureUncompressed_=function(){"8a"==this.bitDepth?this.fromALaw():"8m"==this.bitDepth?this.fromMuLaw():"4"==this.bitDepth&&this.fromIMAADPCM()};a.prototype.assureInterleaved_=function(){this.isInterleaved||this.interleave()};a.prototype.LEorBE_=function(){var a="RIFX"==this.container;
n.be=a;m.be=a;return k.be=a};a.prototype.findChunk_=function(a,b){for(var h=0;h<a.length;h++)if(a[h].chunkId==b)return a[h];return null};a.prototype.readRIFFChunk_=function(a){this.container=b.unpackArray(a.slice(0,4),b.chr);if("RIFF"!=this.container&&"RIFX"!=this.container)throw Error("Not a supported format.");this.LEorBE_();this.chunkSize=b.unpack(a.slice(4,8),k);this.format=b.unpackArray(a.slice(8,12),b.chr);if("WAVE"!=this.format)throw Error("Could not find the 'WAVE' format identifier");};a.prototype.readFmtChunk_=
function(a){if(a=this.findChunk_(a,"fmt "))this.fmt.chunkId="fmt ",this.fmt.chunkSize=a.chunkSize,this.fmt.audioFormat=b.unpack(a.chunkData.slice(0,2),m),this.fmt.numChannels=b.unpack(a.chunkData.slice(2,4),m),this.fmt.sampleRate=b.unpack(a.chunkData.slice(4,8),k),this.fmt.byteRate=b.unpack(a.chunkData.slice(8,12),k),this.fmt.blockAlign=b.unpack(a.chunkData.slice(12,14),m),this.fmt.bitsPerSample=b.unpack(a.chunkData.slice(14,16),m),this.readFmtExtension_(a);else throw Error("Could not find the 'fmt ' chunk");
};a.prototype.readFmtExtension_=function(a){a=a.chunkData;16<this.fmt.chunkSize&&(this.fmt.cbSize=b.unpack(a.slice(16,18),m),18<this.fmt.chunkSize&&(this.fmt.validBitsPerSample=b.unpack(a.slice(18,20),m),20<this.fmt.chunkSize&&(this.fmt.dwChannelMask=b.unpack(a.slice(20,24),k),this.fmt.subformat=[b.unpack(a.slice(24,28),k),b.unpack(a.slice(28,32),k),b.unpack(a.slice(32,36),k),b.unpack(a.slice(36,40),k)])))};a.prototype.readFactChunk_=function(a){if(a=this.findChunk_(a,"fact"))this.fact.chunkId="fact",
this.fact.chunkSize=a.chunkSize,this.fact.dwSampleLength=b.unpack(a.chunkData.slice(0,4),k);else if(this.enforceFact_)throw Error("Could not find the 'fact' chunk");};a.prototype.readCueChunk_=function(a){var c=this.findChunk_(a,"cue ");if(c)for(a=c.chunkData,this.cue.chunkId="cue ",this.cue.chunkSize=c.chunkSize,this.cue.dwCuePoints=b.unpack(a.slice(0,4),k),c=0;c<this.cue.dwCuePoints;c++){var d=4+24*c;this.cue.points.push({dwName:b.unpack(a.slice(d,d+4),k),dwPosition:b.unpack(a.slice(d+4,d+8),k),
fccChunk:b.unpack(a.slice(d+8,d+12),b.fourCC),dwChunkStart:b.unpack(a.slice(d+12,d+16),k),dwBlockStart:b.unpack(a.slice(d+16,d+20),k),dwSampleOffset:b.unpack(a.slice(d+20,d+24),k)})}};a.prototype.readDataChunk_=function(a,b){if(a=this.findChunk_(a,"data"))this.data.chunkId="data",this.data.chunkSize=a.chunkSize,this.samplesFromBytes_(a.chunkData,b);else throw Error("Could not find the 'data' chunk");};a.prototype.readBextChunk_=function(a){if(a=this.findChunk_(a,"bext"))a=a.chunkData,this.head_=0,
this.bext={chunkId:"bext",chunkSize:a.length,description:this.readString_(a,256),originator:this.readString_(a,32),originatorReference:this.readString_(a,32),originationDate:this.readString_(a,10),originationTime:this.readString_(a,8),timeReference:[this.readFromChunk_(a,k),this.readFromChunk_(a,k)],version:this.readFromChunk_(a,m),UMID:this.readString_(a,64),loudnessValue:this.readFromChunk_(a,m),loudnessRange:this.readFromChunk_(a,m),maxTruePeakLevel:this.readFromChunk_(a,m),maxMomentaryLoudness:this.readFromChunk_(a,
m),maxShortTermLoudness:this.readFromChunk_(a,m),reserved:this.readString_(a,180),codingHistory:this.readString_(a,a.length-602)}};a.prototype.readString_=function(a,c){for(var d="",h=0;h<c;h++)d+=b.unpack([a[this.head_]],b.chr),this.head_++;return d};a.prototype.readFromChunk_=function(a,c){var d=c.bits/8;a=b.unpack(a.slice(this.head_,this.head_+d),c);this.head_+=d;return a};a.prototype.writeString_=function(a,c){a=b.packArray(a,b.chr);for(var d=a.length;d<c;d++)a.push(0);return a};a.prototype.samplesToBytes_=
function(a){a.bits=4==this.fmt.bitsPerSample?8:this.fmt.bitsPerSample;a.signed=8==a.bits?!1:!0;a.float=3==this.fmt.audioFormat||64==this.fmt.bitsPerSample?!0:!1;a=b.packArray(this.data.samples,new b.Type(a));a.length%2&&a.push(0);return a};a.prototype.samplesFromBytes_=function(a,c){c.bits=4==this.fmt.bitsPerSample?8:this.fmt.bitsPerSample;c.signed=8==c.bits?!1:!0;c.float=3==this.fmt.audioFormat||64==this.fmt.bitsPerSample?!0:!1;c.single=!1;this.data.samples=b.unpackArray(a,new b.Type(c))};a.prototype.getBextBytes_=
function(){return this.bext.chunkId?[].concat(b.packArray(this.bext.chunkId,b.chr),b.pack(this.bext.chunkSize,k),this.writeString_(this.bext.description,256),this.writeString_(this.bext.originator,32),this.writeString_(this.bext.originatorReference,32),this.writeString_(this.bext.originationDate,10),this.writeString_(this.bext.originationTime,8),b.pack(this.bext.timeReference[0],k),b.pack(this.bext.timeReference[1],k),b.pack(this.bext.version,m),this.writeString_(this.bext.UMID,64),b.pack(this.bext.loudnessValue,
m),b.pack(this.bext.loudnessRange,m),b.pack(this.bext.maxTruePeakLevel,m),b.pack(this.bext.maxMomentaryLoudness,m),b.pack(this.bext.maxShortTermLoudness,m),this.writeString_(this.bext.reserved,180),this.writeString_(this.bext.codingHistory,this.bext.chunkSize-602)):[]};a.prototype.getCueBytes_=function(){return this.cue.chunkId?[].concat(b.packArray(this.cue.chunkId,b.chr),b.pack(this.cue.chunkSize,k),b.pack(this.cue.dwCuePoints,k),this.getCuePointsBytes_()):[]};a.prototype.getCuePointsBytes_=function(){for(var a=
[],c=0;c<this.cue.dwCuePoints;c++)a=a.concat(b.pack(this.cue.points[c].dwName,k),b.pack(this.cue.points[c].dwPosition,k),b.pack(this.cue.points[c].fccChunk,b.fourCC),b.pack(this.cue.points[c].dwChunkStart,k),b.pack(this.cue.points[c].dwBlockStart,k),b.pack(this.cue.points[c].dwSampleOffset,k));return a};a.prototype.getFactBytes_=function(){return this.fact.chunkId?[].concat(b.packArray(this.fact.chunkId,b.chr),b.pack(this.fact.chunkSize,k),b.pack(this.fact.dwSampleLength,k)):[]};a.prototype.getFmtBytes_=
function(){if(this.fmt.chunkId)return[].concat(b.packArray(this.fmt.chunkId,b.chr),b.pack(this.fmt.chunkSize,k),b.pack(this.fmt.audioFormat,m),b.pack(this.fmt.numChannels,m),b.pack(this.fmt.sampleRate,k),b.pack(this.fmt.byteRate,k),b.pack(this.fmt.blockAlign,m),b.pack(this.fmt.bitsPerSample,m),this.getFmtExtensionBytes_());throw Error("Could not find the 'fmt ' chunk");};a.prototype.getFmtExtensionBytes_=function(){var a=[];16<this.fmt.chunkSize&&(a=a.concat(b.pack(this.fmt.cbSize,m)));18<this.fmt.chunkSize&&
(a=a.concat(b.pack(this.fmt.validBitsPerSample,m)));20<this.fmt.chunkSize&&(a=a.concat(b.pack(this.fmt.dwChannelMask,k)));24<this.fmt.chunkSize&&(a=a.concat(b.pack(this.fmt.subformat[0],k),b.pack(this.fmt.subformat[1],k),b.pack(this.fmt.subformat[2],k),b.pack(this.fmt.subformat[3],k)));return a};a.prototype.createWaveFile_=function(){var a={be:this.LEorBE_()};return new Uint8Array([].concat(b.packArray(this.container,b.chr),b.pack(this.chunkSize,k),b.packArray(this.format,b.chr),this.getBextBytes_(),
this.getFmtBytes_(),this.getFactBytes_(),b.packArray(this.data.chunkId,b.chr),b.pack(this.data.chunkSize,k),this.samplesToBytes_(a),this.getCueBytes_()))};window.WaveFile=window.WaveFile?window.WaveFile:a},function(a,g){var e=new Float32Array(1),f={intToInt:function(a,e){return a=0<a?parseInt(a/e.oldPositive*e.newPositive,10):parseInt(a/e.oldNegative*e.newNegative,10)},floatToInt:function(a,e){return 0<a?parseInt(a*e.newPositive,10):parseInt(a*e.newNegative,10)},intToFloat:function(a,e){return 0<
a?a/e.oldPositive:a/e.oldNegative},floatToFloat:function(a,l){"64"==l.original&&"32f"==l.target&&(e[0]=a,a=e[0]);return a}};a.exports.toBitDepth=function(a,e,d){for(var b=[],c=8;49>c;c++)b.push(c.toString());b.push("32f");b.push("64");if(-1==b.indexOf(e)||-1==b.indexOf(d))throw Error("Invalid bit depth.");b=["32f","64"].includes(e)?"float":"int";c=["32f","64"].includes(d)?"Float":"Int";b=f[b+"To"+c];c=a.length;for(var l=0;l<c;l++){var k=l,h=a[l];"8"==e&&(h-=128);a[k]=h;a[l]=b(a[l],{oldNegative:parseInt(Math.pow(2,
parseInt(e,10))/2,10),newNegative:parseInt(Math.pow(2,parseInt(d,10))/2,10),oldPositive:parseInt(Math.pow(2,parseInt(e,10))/2-1,10),newPositive:parseInt(Math.pow(2,parseInt(d,10))/2-1,10),original:e,target:d});k=l;h=a[l];"8"==d&&(h+=128);a[k]=h}}},function(a,g,e){function f(a){m.be="RIFX"===a.chunkId;var d=b.packArray(a.chunkId,n).concat(b.pack(a.chunkSize,m),b.packArray(a.format,n),c(a.subChunks));if("RIFF"===a.chunkId||"RIFX"===a.chunkId)d=new Uint8Array(d);return d}function c(a){for(var c=[],d=
0;d<a.length;)c="LIST"===a[d].chunkId?c.concat(f(a[d])):c.concat(b.packArray(a[d].chunkId,n),b.pack(a[d].chunkSize,m),a[d].chunkData),d++;return c}function l(a){for(var b=[],c=12;c<a.length;)b.push(d(a,c)),c+=8+b[b.length-1].chunkSize;return b}function d(a,c){var d={chunkId:b.unpackArray(a.slice(c,c+4),n),chunkSize:b.unpack(a.slice(c+4,c+8),m)};"LIST"===d.chunkId?(d.format=b.unpackArray(a.slice(8,12),n),d.subChunks=l(a.slice(c,c+d.chunkSize))):d.chunkData=a.slice(c+8,c+8+d.chunkSize);return d}var b=
e(0),n=b.chr,m=b.uInt32;a.exports.read=function(a){a=[].slice.call(a);var c=b.unpackArray(a.slice(0,4),n);m.be="RIFX"===c;return{chunkId:c,chunkSize:b.unpack(a.slice(4,8),m),format:b.unpackArray(a.slice(8,12),n),subChunks:l(a)}};a.exports.write=f},function(a,g,e){var f=e(1),c=e(7);a.exports.getType=function(a,c){a=Object.assign(new f({}),a);a.base=c;return a};a.exports.toBytes=function(a,d){for(var b=0,e=0,l=a.length,f=[];b<l;)e=d.writer(f,a[b++],e);d.be&&c(f,d.offset);if(10!=d.base){a=d.base;b=0;
for(e=f.length;b<e;)f[b]=f[b].toString(a),b++;a=0;b=f.length;for(d=(2==d.base?8:2)+1;a<b;)f[a]=Array(d-f[a].length).join("0")+f[a],a++}return f};a.exports.fromBytes=function(a,d){d.be&&c(a,d.offset);if(10!=d.base)for(var b=d.base,e=0,f=a.length;e<f;)a[e]=parseInt(a[e],b),e++;b=[];e=0;for(f=a.length-(d.offset-1);e<f;)b.push(d.reader(a,e)),e+=d.offset;d.char&&(b=b.join(""));return b}},function(a,g){g=function(a){this.bits=a.bits;this.be=a.be;this.signed=a.signed;this.reader=this.read;this.writer=this.write;
this.offset=0;this.min=-Infinity;this.max=Infinity;this.realBits_=this.bits;this.lastByteMask_=255;this.build_()};g.prototype.read=function(a,f){f=void 0===f?0:f;if(32<this.bits)return this.readBits_(a,f);for(var c=0,e=this.offset-1;0<e;)c|=a[e+f]<<8*e,e--;c=(a[f]|c)>>>0;return this.overflow_(this.sign_(c))};g.prototype.write=function(a,f,c){c=void 0===c?0:c;f=this.overflow_(f);var e=255;c=this.writeFirstByte_(a,f,c);for(var d=2;d<=this.offset;d++)d==this.offset&&(e=this.lastByteMask_),a[c++]=Math.floor(f/
Math.pow(2,8*(d-1)))&e;return c};g.prototype.readBits_=function(a,f){f=void 0===f?0:f;for(var c="",e=0;e<this.offset;){var d=a[f+e].toString(2);c=Array(9-d.length).join("0")+d+c;e++}return this.overflow_(this.sign_(parseInt(c,2)))};g.prototype.build_=function(){this.validateWordSize_();this.setRealBits_();this.setLastByteMask_();this.setMinMax_();this.offset=8>this.bits?1:Math.ceil(this.realBits_/8)};g.prototype.sign_=function(a){a>this.max&&(a-=2*this.max+2);return a};g.prototype.overflow_=function(a){a>
this.max?a=this.max:a<this.min&&(a=this.min);return a};g.prototype.setMinMax_=function(){var a=Math.pow(2,this.bits);this.signed?(this.max=a/2-1,this.min=-a/2):(this.max=a-1,this.min=0)};g.prototype.validateWordSize_=function(){if(1>this.bits||64<this.bits)throw Error("Not a supported type.");};g.prototype.setRealBits_=function(){8<this.bits&&(this.realBits_=(this.bits-1|7)+1)};g.prototype.setLastByteMask_=function(){var a=8-(this.realBits_-this.bits);this.lastByteMask_=Math.pow(2,0<a?a:8)-1};g.prototype.writeFirstByte_=
function(a,f,c){8>this.bits?a[c++]=0>f?f+Math.pow(2,this.bits):f:a[c++]=f&255;return c};a.exports=g},function(a,g){a.exports=function(a,f){for(var c=a.length,e=0;e<c;){for(var d=a,b=e,g=0,m=f-1,k=parseInt(f/2,10);g<k;){var h=d[b+g];d[b+g]=d[b+m];d[b+m]=h;g++;m--}e+=f}}},function(a,g){function e(a){return 32768<a?a-65536:a}function f(a){var c=a-m;0<=c?a=0:(a=8,c=-c);var d=n[k],e=d>>3;c>d&&(a|=4,c-=d,e+=d);d>>=1;c>d&&(a|=2,c-=d,e+=d);d>>=1;c>d&&(a|=1,e+=d);c=a;m=c&8?m-e:m+e;-32768>m?m=-32768:32767<
m&&(m=32767);k+=b[c&7];0>k?k=0:88<k&&(k=88);return a}function c(a){var c=0;a&4&&(c+=q);a&2&&(c+=q>>1);a&1&&(c+=q>>2);c+=q>>3;a&8&&(c=-c);h+=c;32767<h?h=32767:-32767>h&&(h=-32767);p+=b[a];0>p?p=0:88<p&&(p=88);q=n[p];return h}function l(a){var c=a[0];f(c);var b=[];b.push(c&255);b.push(c>>8&255);b.push(k);b.push(0);for(c=3;c<a.length;c+=2){var d=f(a[c]),e=f(a[c+1]);b.push(e<<4|d)}for(;256>b.length;)b.push(0);return b}function d(a){h=e(a[1]<<8|a[0]);p=a[2];q=n[p];for(var b=[h,e(a[3]<<8|a[2])],d=4;d<a.length;d++){var f=
a[d],g=f>>4;b.push(c(g<<4^f));b.push(c(g))}return b}var b=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],n=[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],m=0,k=0,h=0,p=0,q=7;a.exports.encode=
function(a){for(var c=[],b=[],d=0;d<a.length;d++)if(b.push(a[d]),0==d%505&&0!=d||d==a.length-1)c=c.concat(l(b)),b=[];return c};a.exports.decode=function(a,c){c=void 0===c?256:c;for(var b=[],e=[],f=0;f<a.length;f++)0==f%c&&0!=f&&(b=b.concat(d(e)),e=[]),e.push(a[f]);return b};a.exports.encodeBlock=l;a.exports.decodeBlock=d},function(a,g,e){a.exports.alaw=e(10);a.exports.mulaw=e(11)},function(a,g){function e(a){var c=[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],d;a=-32768==a?-32767:a;(d=~a>>8&128)||(a*=-1);32635<a&&(a=32635);256<=a?(c=c[a>>8&127],a=c<<4|a>>c+3&15):a>>=4;return a^d^85}function f(a){var c=0;a^=85;a&128&&(a&=-129,c=-1);var d=((a&240)>>4)+4;a=4!=d?1<<d|(a&15)<<d-4|1<<d-5:a<<1|1;return-8*(0===c?a:-a)}a.exports.encodeSample=e;a.exports.decodeSample=f;a.exports.encode=function(a){for(var c=
[],d=0;d<a.length;d++)c.push(e(a[d]));return c};a.exports.decode=function(a){for(var c=[],d=0;d<a.length;d++)c.push(f(a[d]));return c}},function(a,g){function e(a){if(0>a){a=132-a;var c=127}else a+=132,c=255;32767<a&&(a=32767);var d=0;var b=a>>7;b&240&&(b>>=4,d+=4);b&12&&(b>>=2,d+=2);b&2&&(d+=1);b=d;return(b<<4|a>>b+3&15)^c}function f(a){a=~a;var c=((a&15)<<3)+132<<((a&112)>>4);return a&128?132-c:c-132}a.exports.encodeSample=e;a.exports.decodeSample=f;a.exports.encode=function(a){for(var c=[],d=0;d<
a.length;d++)c.push(e(a[d]));return c};a.exports.decode=function(a){for(var c=[],d=0;d<a.length;d++)c.push(f(a[d]));return c}}]);

@@ -113,4 +113,6 @@ /*!

"chunkSize": 0,
/** @type {!Array<number>} */
"chunkData_": []
/** @type {!number} */
"dwCuePoints": 0,
/** @type {!Object<string, string|number>} */
"points": [],
};

@@ -212,8 +214,9 @@

/**
* Header formats.
* Formats not listed here will be 65534.
* @enum {number}
* Audio formats.
* Formats not listed here will be set to 65534
* and treated as WAVE_FORMAT_EXTENSIBLE
* @enum {!number}
* @const
*/
this.headerFormats_ = {
this.audioFormats_ = {
"4": 17,

@@ -239,2 +242,3 @@ "8": 1,

* @type {!boolean}
* @private
*/

@@ -285,4 +289,4 @@ this.enforceFact_ = false;

this.fmt.blockAlign = numChannels * numBytes;
this.fmt.audioFormat = this.headerFormats_[bitDepth] ?
this.headerFormats_[bitDepth] : 65534;
this.fmt.audioFormat = this.audioFormats_[bitDepth] ?
this.audioFormats_[bitDepth] : 65534;
this.fmt.numChannels = numChannels;

@@ -357,4 +361,3 @@ this.fmt.sampleRate = sampleRate;

this.readDataChunk_(
chunk["subChunks"],
{"be": bigEndian, "single": true});
chunk["subChunks"], {"be": bigEndian, "single": true});
if (this.fmt.audioFormat == 3 && this.fmt.bitsPerSample == 32) {

@@ -373,3 +376,4 @@ this.bitDepth = "32f";

* Return a byte buffer representig the WaveFile object as a wav file.
* @return {Uint8Array}
* 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.

@@ -380,3 +384,3 @@ */

this.assureInterleaved_();
return new Uint8Array(this.createWaveFile_());
return this.createWaveFile_();
}

@@ -560,6 +564,6 @@

/**
* Get the closest greater number of bits for a number of bits that
* Return the closest greater number of bits for a number of bits that
* do not fill a full sequence of bytes.
* @param {!string} bitDepth The bit depth.
* @return {string}
* @return {!string}
*/

@@ -586,2 +590,3 @@ realBitDepth_(bitDepth) {

* Validate the bit depth.
* @return {!boolean} True is the bit depth is valid.
* @throws {Error} If bit depth is invalid.

@@ -591,3 +596,3 @@ * @private

validateBitDepth_() {
if (!this.headerFormats_[this.bitDepth]) {
if (!this.audioFormats_[this.bitDepth]) {
if (parseInt(this.bitDepth, 10) > 8 &&

@@ -604,2 +609,3 @@ parseInt(this.bitDepth, 10) < 54) {

* Validate the number of channels.
* @return {!boolean} True is the number of channels is valid.
* @throws {Error} If the number of channels is invalid.

@@ -618,2 +624,3 @@ * @private

* Validate the sample rate value.
* @return {!boolean} True is the sample rate is valid.
* @throws {Error} If the sample rate is invalid.

@@ -679,2 +686,33 @@ * @private

/**
* Set up to work wih big-endian or little-endian files.
* The types used are changed to LE or BE. If the
* the file is big-endian (RIFX), true is returned.
* @return {boolean} True if the file is RIFX.
* @private
*/
LEorBE_() {
let bigEndian = this.container == "RIFX";
uInt8_.be = bigEndian;
uInt16_.be = bigEndian;
uInt32_.be = bigEndian;
return bigEndian;
}
/**
* Find a chunk by its FourCC in a array of RIFF chunks.
* @param {!Object<string, Object>} chunks The wav file chunks.
* @param {!string} fourCC The chunk fourCC.
* @return {Object|null}
* @private
*/
findChunk_(chunks, fourCC) {
for (let i = 0; i<chunks.length; i++) {
if (chunks[i]["chunkId"] == fourCC) {
return chunks[i];
}
}
return null;
}
/**
* Read the RIFF chunk a wave file.

@@ -701,16 +739,2 @@ * @param {!Uint8Array|!Array<number>} bytes A wav buffer.

/**
* Set up to work wih big-endian or little-endian files.
* The types used are changed from LE or BE. If the
* the file is big-endian (RIFX), true is returned.
* @private
*/
LEorBE_() {
let bigEndian = this.container == "RIFX";
uInt8_.be = bigEndian;
uInt16_.be = bigEndian;
uInt32_.be = bigEndian;
return bigEndian;
}
/**
* Read the "fmt " chunk of a wave file.

@@ -793,2 +817,54 @@ * @param {!Object<string, *>} chunks The wav file chunks.

/**
* Read the "cue " chunk of a wave file.
* @param {!Object<string, *>} chunks The RIFF file chunks.
* @private
*/
readCueChunk_(chunks) {
let chunk = this.findChunk_(chunks, "cue ");
if (chunk) {
let chunkData = chunk["chunkData"];
this.cue.chunkId = "cue ";
this.cue.chunkSize = chunk["chunkSize"];
this.cue.dwCuePoints = byteData_.unpack(
chunkData.slice(0, 4), uInt32_);
for (let i=0; i<this.cue.dwCuePoints; i++) {
let offset = 4 + (i * 24);
this.cue.points.push(
{
"dwName": byteData_.unpack(
chunkData.slice(offset, offset + 4), uInt32_),
"dwPosition": byteData_.unpack(
chunkData.slice(offset + 4, offset + 8), uInt32_),
"fccChunk": byteData_.unpack(
chunkData.slice(offset + 8, offset + 12), byteData_.fourCC),
"dwChunkStart": byteData_.unpack(
chunkData.slice(offset + 12, offset + 16), uInt32_),
"dwBlockStart": byteData_.unpack(
chunkData.slice(offset + 16, offset + 20), uInt32_),
"dwSampleOffset": byteData_.unpack(
chunkData.slice(offset + 20, offset + 24), uInt32_),
});
}
}
}
/**
* Read the "data" chunk of a wave file.
* @param {!Object<string, *>} chunks The RIFF file chunks.
* @param {!Object<string, *>} options Type options.
* @throws {Error} If no "data" chunk is found.
* @private
*/
readDataChunk_(chunks, options) {
let chunk = this.findChunk_(chunks, "data");
if (chunk) {
this.data.chunkId = "data";
this.data.chunkSize = chunk["chunkSize"];
this.samplesFromBytes_(chunk["chunkData"], options);
} else {
throw Error("Could not find the 'data' chunk");
}
}
/**
* Read the "bext" chunk of a wav file.

@@ -838,2 +914,3 @@ * @param {!Object<string, *>} chunks The wav file chunks.

* @param {!number} maxSize the max size of the string.
* @return {!string} The string.
* @private

@@ -854,2 +931,3 @@ */

* @param {!Object<string, *>} bdType The byte-data corresponding type.
* @return {!number} The number.
* @private

@@ -871,2 +949,3 @@ */

* @param {!number} maxSize the max size of the string.
* @return {!Array<number>} The bytes.
* @private

@@ -883,36 +962,24 @@ */

/**
* Read the "cue " chunk of a wave file.
* @param {!Object<string, *>} chunks The RIFF file chunks.
* @private
*/
readCueChunk_(chunks) {
let chunk = this.findChunk_(chunks, "cue ");
if (chunk) {
this.cue.chunkId = "cue ";
this.cue.chunkSize = chunk["chunkSize"];
this.cue.chunkData_ = chunk["chunkData"];
}
}
/**
* Read the "data" chunk of a wave file.
* @param {!Object<string, *>} chunks The RIFF file chunks.
* Turn the samples to bytes.
* @param {!Object<string, *>} options Type options.
* @throws {Error} If no "data" chunk is found.
* @return {!Array<number>} The bytes.
* @private
*/
readDataChunk_(chunks, options) {
let chunk = this.findChunk_(chunks, "data");
if (chunk) {
this.data.chunkId = "data";
this.data.chunkSize = chunk["chunkSize"];
this.samplesFromBytes_(chunk["chunkData"], options);
} else {
throw Error("Could not find the 'data' chunk");
samplesToBytes_(options) {
options.bits = this.fmt.bitsPerSample == 4 ?
8 : this.fmt.bitsPerSample;
options.signed = options.bits == 8 ? false : true;
options.float = (this.fmt.audioFormat == 3 ||
this.fmt.bitsPerSample == 64) ? true : false;
let bytes = byteData_.packArray(
this.data.samples, new byteData_.Type(options));
if (bytes.length % 2) {
bytes.push(0);
}
return bytes;
}
/**
* Find and return the start offset of the data chunk on a wave file.
* @param {!Array<number>|!Uint8Array} bytes A wav file buffer.
* Turn bytes to samples and load them in the data.samples property.
* @param {!Array<number>|!Uint8Array} bytes The bytes.
* @param {!Object<string, *>} options Type options.

@@ -933,38 +1000,3 @@ * @private

/**
* Find a chunk by its FourCC in a array of RIFF chunks.
* @param {!Object<string, Object>} chunks The wav file chunks.
* @param {!string} fourCC The chunk fourCC.
* @return {Object|null}
* @private
*/
findChunk_(chunks, fourCC) {
for (let i = 0; i<chunks.length; i++) {
if (chunks[i]["chunkId"] == fourCC) {
return chunks[i];
}
}
return null;
}
/**
* Turn samples to bytes.
* @param {!Object<string, *>} options Type options.
* @private
*/
samplesToBytes_(options) {
options.bits = this.fmt.bitsPerSample == 4 ?
8 : this.fmt.bitsPerSample;
options.signed = options.bits == 8 ? false : true;
options.float = (this.fmt.audioFormat == 3 ||
this.fmt.bitsPerSample == 64) ? true : false;
let bytes = byteData_.packArray(
this.data.samples, new byteData_.Type(options));
if (bytes.length % 2) {
bytes.push(0);
}
return bytes;
}
/**
* Get the bytes of the "bext" chunk.
* Return the bytes of the "bext" chunk.
* @return {!Array<number>} The "bext" chunk bytes.

@@ -1001,3 +1033,3 @@ * @private

/**
* Get the bytes of the "cue " chunk.
* Return the bytes of the "cue " chunk.
* @return {!Array<number>} The "cue " chunk bytes.

@@ -1011,3 +1043,4 @@ * @private

byteData_.pack(this.cue.chunkSize, uInt32_),
this.cue.chunkData_);
byteData_.pack(this.cue.dwCuePoints, uInt32_),
this.getCuePointsBytes_());
}

@@ -1018,3 +1051,23 @@ return [];

/**
* Get the bytes of the "fact" chunk.
* Return the bytes of the "cue " points.
* @return {!Array<number>} The "cue " points as an array of bytes.
* @private
*/
getCuePointsBytes_() {
let points = [];
for (let i=0; i<this.cue.dwCuePoints; i++) {
points = points.concat(
byteData_.pack(this.cue.points[i].dwName, uInt32_),
byteData_.pack(this.cue.points[i].dwPosition, uInt32_),
byteData_.pack(this.cue.points[i].fccChunk, byteData_.fourCC),
byteData_.pack(this.cue.points[i].dwChunkStart, uInt32_),
byteData_.pack(this.cue.points[i].dwBlockStart, uInt32_),
byteData_.pack(this.cue.points[i].dwSampleOffset, uInt32_)
);
}
return points;
}
/**
* Return the bytes of the "fact" chunk.
* @return {!Array<number>} The "fact" chunk bytes.

@@ -1034,3 +1087,27 @@ * @private

/**
* Get the bytes of the fmt extension fields.
* Return the bytes of the "fmt " chunk.
* @return {!Array<number>} The "fmt" chunk bytes.
* @private
* @throws {Error} if no "fmt " chunk is present.
*/
getFmtBytes_() {
if (this.fmt.chunkId) {
return [].concat(
byteData_.packArray(this.fmt.chunkId, byteData_.chr),
byteData_.pack(this.fmt.chunkSize, uInt32_),
byteData_.pack(this.fmt.audioFormat, uInt16_),
byteData_.pack(this.fmt.numChannels, uInt16_),
byteData_.pack(this.fmt.sampleRate, uInt32_),
byteData_.pack(this.fmt.byteRate, uInt32_),
byteData_.pack(this.fmt.blockAlign, uInt16_),
byteData_.pack(this.fmt.bitsPerSample, uInt16_),
this.getFmtExtensionBytes_()
);
} else {
throw Error("Could not find the 'fmt ' chunk");
}
}
/**
* Return the bytes of the fmt extension fields.
* @return {!Array<number>} The fmt extension bytes.

@@ -1064,4 +1141,5 @@ * @private

/**
* Turn a WaveFile object into a file.
* @return {!Array<number>} The wav file bytes.
* Return a .wav file byte buffer with the data from the WaveFile object.
* The return value of this method can be written straight to disk.
* @return {!Uint8Array} The wav file bytes.
* @private

@@ -1071,3 +1149,3 @@ */

let options = {"be": this.LEorBE_()};
return [].concat(
return new Uint8Array([].concat(
byteData_.packArray(this.container, byteData_.chr),

@@ -1077,11 +1155,3 @@ byteData_.pack(this.chunkSize, uInt32_),

this.getBextBytes_(),
byteData_.packArray(this.fmt.chunkId, byteData_.chr),
byteData_.pack(this.fmt.chunkSize, uInt32_),
byteData_.pack(this.fmt.audioFormat, uInt16_),
byteData_.pack(this.fmt.numChannels, uInt16_),
byteData_.pack(this.fmt.sampleRate, uInt32_),
byteData_.pack(this.fmt.byteRate, uInt32_),
byteData_.pack(this.fmt.blockAlign, uInt16_),
byteData_.pack(this.fmt.bitsPerSample, uInt16_),
this.getFmtExtensionBytes_(),
this.getFmtBytes_(),
this.getFactBytes_(),

@@ -1091,3 +1161,3 @@ byteData_.packArray(this.data.chunkId, byteData_.chr),

this.samplesToBytes_(options),
this.getCueBytes_());
this.getCueBytes_()));
}

@@ -1094,0 +1164,0 @@ }

{
"name": "wavefile",
"version": "6.0.0",
"version": "6.1.0",
"description": "Read & write wave files with 4, 8, 11, 12, 16, 20, 24, 32 & 64-bit data.",

@@ -31,2 +31,4 @@ "homepage": "https://github.com/rochars/wavefile",

"32-bit",
"40-bit",
"48-bit",
"64-bit",

@@ -33,0 +35,0 @@ "PCM",

@@ -81,3 +81,3 @@ # wavefile

Some bit depths may not be supported by your browser, like 32-bit floating point or 64-bit floating point (WaveFile is used just to create the files, not play them).
Some bit depths may not be supported by your browser, like 32-bit floating point or 64-bit floating point (WaveFile is used just to create the files, not to play them).

@@ -287,3 +287,10 @@ ## Use

### The properties
Since **version 6.0.0** (2018-05-02) the samples are stored in **data.samples**.
```javascript
console.log(wav.data.samples);
// Output an array of numbers
```
The other public properties:
```javascript
let wav = new Wavefile(fs.readFileSync("file.wav"));

@@ -296,2 +303,7 @@

// "bext"
console.log(wav.bext.chunkId);
console.log(wav.bext.chunkSize);
// ...
// "fmt "

@@ -321,7 +333,2 @@ console.log(wav.fmt.chunkId);

// "bext"
console.log(wav.bext.chunkId);
console.log(wav.bext.chunkSize);
// ...
// "data"

@@ -331,5 +338,10 @@ console.log(wav.data.chunkId);

console.log(wav.data.samples);
// "cue "
console.log(wav.cue.chunkId);
console.log(wav.cue.chunkSize);
// ...
```
### BWF data
#### BWF data
BWF data ("bext" chunk) is stored in the *bext* property.

@@ -346,9 +358,9 @@ ```javascript

"timeReference": [], // 2 32-bit numbers representing a 64-bit value
"version": "", // 16-bit number
"version": 0, // 16-bit number
"UMID": "", // 64 chars
"loudnessValue": "", // 16-bit number
"loudnessRange": "", // 16-bit number
"maxTruePeakLevel": "", // 16-bit number
"maxMomentaryLoudness": "", // 16-bit number
"maxShortTermLoudness": "", // 16-bit number
"loudnessValue": 0, // 16-bit number
"loudnessRange": 0, // 16-bit number
"maxTruePeakLevel": 0, // 16-bit number
"maxMomentaryLoudness": 0, // 16-bit number
"maxShortTermLoudness": 0, // 16-bit number
"reserved": "", // 180 chars

@@ -359,2 +371,25 @@ "codingHistory": "" // string, unlimited size

#### Cue points
"cue " chunk data is stored as follows:
```javascript
wav.cue = {
"chunkId": "",
"chunkSize": 0,
"dwCuePoints": 0, //DWORD
"points": [],
};
```
Items in cue.points are objects with this signature:
```javascript
{
"dwName": 0, //DWORD
"dwPosition": 0, //DWORD
"fccChunk": 0, //FOURCC,
"dwChunkStart": 0, //DWORD,
"dwBlockStart": 0, //DWORD,
"dwSampleOffset": 0, //DWORD,
}
```
### The samples

@@ -361,0 +396,0 @@ Range:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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