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.1.1 to 6.2.0

9

CHANGELOG.md
# CHANGELOG
## version 6.2.0 (2018-05-04)
- Limited support of RF64. Need to be tested with files > 4gb in size.
## version 6.1.1 (2018-05-03)
- Using byte-data^7.0.0 and riff-chunks^4.0.1.
## version 6.1.1 (2018-05-03)
- Using byte-data^7.0.0 and riff-chunks^4.0.1.
## version 6.1.0 (2018-05-02)

@@ -4,0 +13,0 @@ - Reading and writing the data in the "cue " chunk.

2

compile.js

@@ -10,2 +10,2 @@ /*

window['WaveFile'] = WaveFile;
window["WaveFile"] = WaveFile;

@@ -8,54 +8,57 @@ /*

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

@@ -12,95 +7,58 @@ Read & write wave files with 4, 8, 11, 12, 16, 20, 24, 32 & 64-bit data.

bitdepth
Change the resolution of samples to and from 8, 11, 12, 16, 20, 24, 32, 48 & 64-bit.
Copyright (c) 2017-2018 Rafael da Silva Rocha.
https://github.com/rochars/bitdepth
riff-chunks
Read and write the chunks of RIFF and RIFX files.
Copyright (c) 2017 Rafael da Silva Rocha.
https://github.com/rochars/riff-chunks
generic-integer
Pack and unpack any integer from 1 to 53-Bit.
Copyright (c) 2018 Rafael da Silva Rocha.
https://github.com/rochars/generic-integer
endianness
Swap endianness in byte arrays.
Copyright (c) 2017 Rafael da Silva Rocha.
https://github.com/rochars/endianness
imaadpcm
JavaScript IMA ADPCM codec.
Copyright (c) 2018 Rafael da Silva Rocha.
https://github.com/rochars/imaadpcm
References:
http://www.cs.columbia.edu/~hgs/audio/dvi/
https://github.com/acida/pyima
https://wiki.multimedia.cx/index.php/IMA_ADPCM
alawmulaw
JavaScript A-Law and mu-Law codecs.
Copyright (c) 2018 Rafael da Silva Rocha.
https://github.com/rochars/alawmulaw
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.objectCreate=$jscomp.ASSUME_ES5||"function"==typeof Object.create?Object.create:function(a){var d=function(){};d.prototype=a;return new d};$jscomp.underscoreProtoCanBeSet=function(){var a={a:!0},d={};try{return d.__proto__=a,d.a}catch(g){}return!1};
$jscomp.setPrototypeOf="function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(a,d){a.__proto__=d;if(a.__proto__!==d)throw new TypeError(a+" is not extensible");return a}:null;
$jscomp.inherits=function(a,d){a.prototype=$jscomp.objectCreate(d.prototype);a.prototype.constructor=a;if($jscomp.setPrototypeOf){var g=$jscomp.setPrototypeOf;g(a,d)}else for(g in d)if("prototype"!=g)if(Object.defineProperties){var m=Object.getOwnPropertyDescriptor(d,g);m&&Object.defineProperty(a,g,m)}else a[g]=d[g];a.superClass_=d.prototype};
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,d,g){a!=Array.prototype&&a!=Object.prototype&&(a[d]=g.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,d,g,m){if(d){g=$jscomp.global;a=a.split(".");for(m=0;m<a.length-1;m++){var c=a[m];c in g||(g[c]={});g=g[c]}a=a[a.length-1];m=g[a];d=d(m);d!=m&&null!=d&&$jscomp.defineProperty(g,a,{configurable:!0,writable:!0,value:d})}};$jscomp.polyfill("Object.is",function(a){return a?a:function(a,g){return a===g?0!==a||1/a===1/g:a!==a&&g!==g}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,g){var d=this;d instanceof String&&(d=String(d));var c=d.length;for(g=g||0;g<c;g++)if(d[g]==a||Object.is(d[g],a))return!0;return!1}},"es7","es3");
$jscomp.checkStringArgs=function(a,d,g){if(null==a)throw new TypeError("The 'this' value for String.prototype."+g+" must not be null or undefined");if(d instanceof RegExp)throw new TypeError("First argument to String.prototype."+g+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,g){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,g||0)}},"es6","es3");
$jscomp.owns=function(a,d){return Object.prototype.hasOwnProperty.call(a,d)};$jscomp.polyfill("Object.assign",function(a){return a?a:function(a,g){for(var d=1;d<arguments.length;d++){var c=arguments[d];if(c)for(var b in c)$jscomp.owns(c,b)&&(a[b]=c[b])}return a}},"es6","es3");
(function(a){function d(m){if(g[m])return g[m].exports;var c=g[m]={i:m,l:!1,exports:{}};a[m].call(c.exports,c,c.exports,d);c.l=!0;return c.exports}var g={};d.m=a;d.c=g;d.d=function(a,c,b){d.o(a,c)||Object.defineProperty(a,c,{configurable:!1,enumerable:!0,get:b})};d.n=function(a){var c=a&&a.__esModule?function(){return a["default"]}:function(){return a};d.d(c,"a",c);return c};d.o=function(a,c){return Object.prototype.hasOwnProperty.call(a,c)};d.p="";return d(d.s=3)})([function(a,d){a.exports={format:"Not a supported format.",
wave:"Could not find the 'WAVE' format identifier","fmt ":"Could not find the 'fmt ' chunk",data:"Could not find the 'data' chunk",fact:"Could not find the 'fact' chunk",bitDepth:"Invalid bit depth.",numChannels:"Invalid number of channels.",sampleRate:"Invalid sample rate."}},function(a,d,g){function m(a,c,k){k=void 0===k?10:k;var e=[];c.char?e=c.char?a.slice(0,c.offset):a:Array.isArray(a)||(e=[a]);return b.toBytes(e,b.getType(c,k))}function c(a,c,k){k=void 0===k?10:k;a=b.fromBytes(a.slice(0,c.offset),
b.getType(c,k));return a=c.char?a.slice(0,c.bits/8):a[0]}var b=g(6),f=g(2);a.exports.pack=m;a.exports.unpack=c;a.exports.packArray=function(a,c,k){return b.toBytes(a,b.getType(c,void 0===k?10:k))};a.exports.unpackArray=function(a,c,k){return b.fromBytes(a,b.getType(c,void 0===k?10:k))};a.exports.unpackStruct=function(a,b,k){k=void 0===k?10:k;for(var e=a.length,n=0,f=0;f<b.length;f++)n+=b[f].offset;if(e<n)return[];e=[];for(f=n=0;n<b.length;)e=e.concat(c(a.slice(f,f+b[n].offset),b[n],k)),f+=b[n].offset,
n++;return e};a.exports.packStruct=function(a,b,c){c=void 0===c?10:c;if(a.length<b.length)return[];for(var e=[],k=0;k<b.length;k++)e=e.concat(m(a[k],b[k],c));return e};a.exports.findString=function(a,b){for(var k,e=0;e<a.length;e++)if(k=c(a.slice(e,e+b.length+1),new f({bits:8*b.length,"char":!0})),k==b)return e;return-1};a.exports.Type=f;a.exports.chr=new f({bits:8,"char":!0});a.exports.fourCC=new f({bits:32,"char":!0});a.exports.bool=new f({bits:1});a.exports.int2=new f({bits:2,signed:!0});a.exports.uInt2=
new f({bits:2});a.exports.int4=new f({bits:4,signed:!0});a.exports.uInt4=new f({bits:4});a.exports.int8=new f({bits:8,signed:!0});a.exports.uInt8=new f({bits:8});a.exports.int16=new f({bits:16,signed:!0});a.exports.uInt16=new f({bits:16});a.exports.float16=new f({bits:16,"float":!0});a.exports.int24=new f({bits:24,signed:!0});a.exports.uInt24=new f({bits:24});a.exports.int32=new f({bits:32,signed:!0});a.exports.uInt32=new f({bits:32});a.exports.float32=new f({bits:32,"float":!0});a.exports.int40=
new f({bits:40,signed:!0});a.exports.uInt40=new f({bits:40});a.exports.int48=new f({bits:48,signed:!0});a.exports.uInt48=new f({bits:48});a.exports.float64=new f({bits:64,"float":!0});a.exports.int16BE=new f({bits:16,signed:!0,be:!0});a.exports.uInt16BE=new f({bits:16,be:!0});a.exports.float16BE=new f({bits:16,"float":!0,be:!0});a.exports.int24BE=new f({bits:24,signed:!0,be:!0});a.exports.uInt24BE=new f({bits:24,be:!0});a.exports.int32BE=new f({bits:32,signed:!0,be:!0});a.exports.uInt32BE=new f({bits:32,
be:!0});a.exports.float32BE=new f({bits:32,"float":!0,be:!0});a.exports.int40BE=new f({bits:40,signed:!0,be:!0});a.exports.uInt40BE=new f({bits:40,be:!0});a.exports.int48BE=new f({bits:48,signed:!0,be:!0});a.exports.uInt48BE=new f({bits:48,be:!0});a.exports.float64BE=new f({bits:64,"float":!0,be:!0})},function(a,d,g){d=new Int8Array(4);var m=new Int32Array(d.buffer,0,1),c=new Float32Array(d.buffer,0,1);d=new Int8Array(8);var b=new Float64Array(d.buffer),f=new Uint32Array(d.buffer),l=g(7),h=function(a){var e=
l.call(this,a)||this;e.char=a["char"];e.float=a["float"];e.base=a.base?a.base:10;e.buildType_();return e};$jscomp.inherits(h,l);h.decodeSample=l.decodeSample;h.encodeSample=l.encodeSample;h.mulaw=l.mulaw;h.alaw=l.alaw;h.decodeBlock=l.decodeBlock;h.encodeBlock=l.encodeBlock;h.decode=l.decode;h.encode=l.encode;h.prototype.read16F_=function(a,e){a=this.read(a,e,{bits:16,offset:2});e=(a&31744)>>10;var b=a&1023;return(e?Math.pow(2,e-15)*(1+b/1024):b/1024*.00006103515625)*(a>>15?-1:1)};h.prototype.read32F_=
function(a,e){m[0]=this.read(a,e,{bits:32,offset:4});return c[0]};h.prototype.read64F_=function(a,e){var c=new h({bits:32,offset:4});f[0]=c.read(a,e,{bits:32,offset:4});f[1]=c.read(a,e+4,{bits:32,offset:4});return b[0]};h.prototype.readChar_=function(a,e){for(var b="",c=0;c<this.offset;)b+=String.fromCharCode(a[e+c]),c++;return b};h.prototype.write64F_=function(a,e,c){b[0]=e;e=new h({bits:32,offset:4,lastByteMask:255});c=e.write(a,f[0],c);return e.write(a,f[1],c)};h.prototype.write32F_=function(a,
e,b){c[0]=e;return b=this.write(a,m[0],b)};h.prototype.write16F_=function(a,e,b){c[0]=e;var f=m[0];e=f>>16&32768;var g=f>>12&2047;f=f>>23&255;103<=f&&(e=(e|f-112<<10|g>>1)+(g&1));a[b++]=e&255;a[b++]=e>>>8&255;return b};h.prototype.writeChar_=function(a,e,b){a[b++]=e.charCodeAt(0);return b};h.prototype.buildType_=function(){this.setReader_();this.setWriter_();this.float&&(this.min=-Infinity,this.max=Infinity)};h.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_)};h.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=h},function(a,d,g){var m=g(0),c=g(4),b=g(5),f=g(9),l=g(10),h=g(13);a=function(a){var e=h.call(this)||this;a&&e.fromBuffer(a);return e};$jscomp.inherits(a,h);a.prototype.fromScratch=
function(a,e,b,c,f){f=void 0===f?{}:f;f.container||(f.container="RIFF");var g=((parseInt(b,10)-1|7)+1)/8;this.clearFactChunk_();this.chunkSize=36+c.length*g;this.fmtChunkSize=16;this.byteRate=a*g*e;this.blockAlign=a*g;this.chunkId=f.container;this.format="WAVE";this.fmtChunkId="fmt ";this.audioFormat=this.headerFormats_[b]?this.headerFormats_[b]:65534;this.numChannels=a;this.sampleRate=e;this.bitsPerSample=parseInt(b,10);this.dataChunkId="data";this.dataChunkSize=c.length*g;this.samples=c;this.bitDepth=
b;"4"==b&&(this.chunkSize=44+c.length,this.fmtChunkSize=20,this.byteRate=4055,this.blockAlign=256,this.bitsPerSample=4,this.dataChunkSize=c.length,this.cbSize=2,this.validBitsPerSample=505,this.factChunkId="fact",this.factChunkSize=4,this.dwSampleLength=2*c.length);if("8a"==b||"8m"==b)this.chunkSize=44+c.length,this.fmtChunkSize=20,this.cbSize=2,this.validBitsPerSample=8,this.factChunkId="fact",this.factChunkSize=4,this.dwSampleLength=c.length;8<parseInt(b,10)&&parseInt(b,10)%8&&(this.chunkSize=60+
c.length*g,this.fmtChunkSize=40,this.bitsPerSample=(parseInt(b,10)-1|7)+1,this.cbSize=22,this.validBitsPerSample=parseInt(b,10),this.dwChannelMask=0,this.subformat1=1,this.subformat2=1048576,this.subformat3=2852126848,this.subformat4=1905997824)};a.prototype.fromBuffer=function(a){this.readRIFFChunk_(a);var e="RIFX"==this.chunkId;a=b.read(a,e);this.readFmtChunk_(a.subChunks);this.readFactChunk_(a.subChunks);this.readBextChunk_(a.subChunks);this.readCueChunk_(a.subChunks);this.readDataChunk_(a.subChunks,
{be:e,single:!0});this.bitDepth=3==this.audioFormat&&32==this.bitsPerSample?"32f":6==this.audioFormat?"8a":7==this.audioFormat?"8m":this.bitsPerSample.toString()};a.prototype.toBuffer=function(){this.checkWriteInput_();return new Uint8Array(this.createWaveFile_())};a.prototype.toRIFF=function(){this.chunkId="RIFF";this.LEorBE_()};a.prototype.toRIFX=function(){this.chunkId="RIFX";this.LEorBE_()};a.prototype.toBitDepth=function(a,e){var b=a,f=this.bitDepth;void 0===e||e||(b=this.realBitDepth_(a),f=
this.realBitDepth_(this.bitDepth));c.toBitDepth(this.samples,f,b);this.fromScratch(this.numChannels,this.sampleRate,a,this.samples,{container:this.chunkId})};a.prototype.interleave=function(){for(var a=[],e=this.samples[0].length,b=0;b<e;b++)for(var c=0;c<this.samples.length;c++)a.push(this.samples[c][b]);this.samples=a};a.prototype.deInterleave=function(){var a=[],e;for(e=0;e<this.numChannels;e++)a[e]=[];e=0;for(var b;e<this.samples.length;){for(b=0;b<this.numChannels;b++)a[b].push(this.samples[e+
b]);e+=b}this.samples=a};a.prototype.toIMAADPCM=function(){this.fromScratch(this.numChannels,this.sampleRate,"4",f.encode(this.samples),{container:this.chunkId})};a.prototype.fromIMAADPCM=function(){this.fromScratch(this.numChannels,this.sampleRate,"16",f.decode(this.samples,this.blockAlign),{container:this.chunkId})};a.prototype.toALaw=function(){this.fromScratch(this.numChannels,this.sampleRate,"8a",l.alaw.encode(this.samples),{container:this.chunkId})};a.prototype.fromALaw=function(){this.fromScratch(this.numChannels,
this.sampleRate,"16",l.alaw.decode(this.samples),{container:this.chunkId})};a.prototype.toMuLaw=function(){this.fromScratch(this.numChannels,this.sampleRate,"8m",l.mulaw.encode(this.samples),{container:this.chunkId})};a.prototype.fromMuLaw=function(){this.fromScratch(this.numChannels,this.sampleRate,"16",l.mulaw.decode(this.samples),{container:this.chunkId})};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)&&32>parseInt(this.bitDepth,10))return!0;throw Error(m.bitDepth);}return!0};a.prototype.validateNumChannels_=function(){var a=this.numChannels*this.bitsPerSample/8;if(1>this.numChannels||65535<a)throw Error(m.numChannels);return!0};a.prototype.validateSampleRate_=function(){var a=this.bitsPerSample/8*this.numChannels*this.sampleRate;
if(1>this.sampleRate||4294967295<a)throw Error(m.sampleRate);return!0};a.prototype.clearFactChunk_=function(){this.validBitsPerSample=this.cbSize=0;this.factChunkId="";this.dwSampleLength=this.factChunkSize=0};window.WaveFile=a},function(a,d){var g=new Float32Array(1),m={intToInt:function(a,b){return a=0<a?parseInt(a/b.oldPositive*b.newPositive,10):parseInt(a/b.oldNegative*b.newNegative,10)},floatToInt:function(a,b){return 0<a?parseInt(a*b.newPositive,10):parseInt(a*b.newNegative,10)},intToFloat:function(a,
b){return 0<a?a/b.oldPositive:a/b.oldNegative},floatToFloat:function(a,b){"64"==b.original&&"32f"==b.target&&(g[0]=a,a=g[0]);return a}};a.exports.toBitDepth=function(a,b,f){for(var c=[],g=8;49>g;g++)c.push(g.toString());c.push("32f");c.push("64");if(-1==c.indexOf(b)||-1==c.indexOf(f))throw Error("Invalid bit depth.");c=["32f","64"].includes(b)?"float":"int";g=["32f","64"].includes(f)?"Float":"Int";c=m[c+"To"+g];g=a.length;for(var d=0;d<g;d++){var e=d,n=a[d];"8"==b&&(n-=128);a[e]=n;a[d]=c(a[d],{oldNegative:parseInt(Math.pow(2,
parseInt(b,10))/2,10),newNegative:parseInt(Math.pow(2,parseInt(f,10))/2,10),oldPositive:parseInt(Math.pow(2,parseInt(b,10))/2-1,10),newPositive:parseInt(Math.pow(2,parseInt(f,10))/2-1,10),original:b,target:f});e=d;n=a[d];"8"==f&&(n+=128);a[e]=n}}},function(a,d,g){function m(a){k.be="RIFX"===a.chunkId;var e=l.packArray(a.chunkId,h).concat(l.pack(a.chunkSize,k),l.packArray(a.format,h),c(a.subChunks));if("RIFF"===a.chunkId||"RIFX"===a.chunkId)e=new Uint8Array(e);return e}function c(a){for(var e=[],b=
0;b<a.length;)e="LIST"===a[b].chunkId?e.concat(m(a[b])):e.concat(l.packArray(a[b].chunkId,h),l.pack(a[b].chunkSize,k),a[b].chunkData),b++;return e}function b(a){for(var b=[],e=12;e<a.length;)b.push(f(a,e)),e+=8+b[b.length-1].chunkSize;return b}function f(a,c){var e={chunkId:l.unpackArray(a.slice(c,c+4),h),chunkSize:l.unpack(a.slice(c+4,c+8),k)};"LIST"===e.chunkId?(e.format=l.unpackArray(a.slice(8,12),h),e.subChunks=b(a.slice(c,c+e.chunkSize))):e.chunkData=a.slice(c+8,c+8+e.chunkSize);return e}var l=
g(1),h=l.chr,k=l.uInt32;a.exports.read=function(a){a=[].slice.call(a);var e=l.unpackArray(a.slice(0,4),h);k.be="RIFX"===e;return{chunkId:e,chunkSize:l.unpack(a.slice(4,8),k),format:l.unpackArray(a.slice(8,12),h),subChunks:b(a)}};a.exports.write=m},function(a,d,g){var m=g(2),c=g(8);a.exports.getType=function(a,c){a=Object.assign(new m({}),a);a.base=c;return a};a.exports.toBytes=function(a,f){for(var b=0,g=0,d=a.length,e=[];b<d;)g=f.writer(e,a[b++],g);f.be&&c(e,f.offset);if(10!=f.base){a=f.base;b=0;
for(g=e.length;b<g;)e[b]=e[b].toString(a),b++;a=0;b=e.length;for(f=(2==f.base?8:2)+1;a<b;)e[a]=Array(f-e[a].length).join("0")+e[a],a++}return e};a.exports.fromBytes=function(a,f){f.be&&c(a,f.offset);if(10!=f.base)for(var b=f.base,g=0,d=a.length;g<d;)a[g]=parseInt(a[g],b),g++;b=[];g=0;for(d=a.length-(f.offset-1);g<d;)b.push(f.reader(a,g)),g+=f.offset;f.char&&(b=b.join(""));return b}},function(a,d){d=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_()};d.prototype.read=function(a,d){d=void 0===d?0:d;if(32<this.bits)return this.readBits_(a,d);for(var c=0,b=this.offset-1;0<b;)c|=a[b+d]<<8*b,b--;c=(a[d]|c)>>>0;return this.overflow_(this.sign_(c))};d.prototype.write=function(a,d,c){c=void 0===c?0:c;d=this.overflow_(d);var b=255;c=this.writeFirstByte_(a,d,c);for(var f=2;f<=this.offset;f++)f==this.offset&&(b=this.lastByteMask_),a[c++]=Math.floor(d/
Math.pow(2,8*(f-1)))&b;return c};d.prototype.readBits_=function(a,d){d=void 0===d?0:d;for(var c="",b=0;b<this.offset;){var f=a[d+b].toString(2);c=Array(9-f.length).join("0")+f+c;b++}return this.overflow_(this.sign_(parseInt(c,2)))};d.prototype.build_=function(){this.validateWordSize_();this.setRealBits_();this.setLastByteMask_();this.setMinMax_();this.offset=8>this.bits?1:Math.ceil(this.realBits_/8)};d.prototype.sign_=function(a){a>this.max&&(a-=2*this.max+2);return a};d.prototype.overflow_=function(a){a>
this.max?a=this.max:a<this.min&&(a=this.min);return a};d.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)};d.prototype.validateWordSize_=function(){if(1>this.bits||64<this.bits)throw Error("Not a supported type.");};d.prototype.setRealBits_=function(){8<this.bits&&(this.realBits_=(this.bits-1|7)+1)};d.prototype.setLastByteMask_=function(){var a=8-(this.realBits_-this.bits);this.lastByteMask_=Math.pow(2,0<a?a:8)-1};d.prototype.writeFirstByte_=
function(a,d,c){8>this.bits?a[c++]=0>d?d+Math.pow(2,this.bits):d:a[c++]=d&255;return c};a.exports=d},function(a,d){a.exports=function(a,d){for(var c=a.length,b=0;b<c;){for(var f=a,g=b,h=0,k=d-1,e=parseInt(d/2,10);h<e;){var m=f[g+h];f[g+h]=f[g+k];f[g+k]=m;h++;k--}b+=d}}},function(a,d){function g(a){return 32768<a?a-65536:a}function m(a){var b=a-k;0<=b?a=0:(a=8,b=-b);var c=h[e],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;k=b&8?k-d:k+d;-32768>k?k=-32768:32767<
k&&(k=32767);e+=l[b&7];0>e?e=0:88<e&&(e=88);return a}function c(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);n+=b;32767<n?n=32767:-32767>n&&(n=-32767);p+=l[a];0>p?p=0:88<p&&(p=88);q=h[p];return n}function b(a){var b=a[0];m(b);var c=[];c.push(b&255);c.push(b>>8&255);c.push(e);c.push(0);for(b=3;b<a.length;b+=2){var d=m(a[b]),f=m(a[b+1]);c.push(f<<4|d)}for(;256>c.length;)c.push(0);return c}function f(a){n=g(a[1]<<8|a[0]);p=a[2];q=h[p];for(var b=[n,g(a[3]<<8|a[2])],e=4;e<a.length;e++){var d=
a[e],f=d>>4;b.push(c(f<<4^d));b.push(c(f))}return b}var l=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],h=[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],k=0,e=0,n=0,p=0,q=7;a.exports.encode=
function(a){for(var e=[],c=[],d=0;d<a.length;d++)if(c.push(a[d]),0==d%505&&0!=d||d==a.length-1)e=e.concat(b(c)),c=[];return e};a.exports.decode=function(a,b){b=void 0===b?256:b;for(var e=[],c=[],d=0;d<a.length;d++)0==d%b&&0!=d&&(e=e.concat(f(c)),c=[]),c.push(a[d]);return e};a.exports.encodeBlock=b;a.exports.decodeBlock=f},function(a,d,g){a.exports.alaw=g(11);a.exports.mulaw=g(12)},function(a,d){function g(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 m(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=g;a.exports.decodeSample=m;a.exports.encode=function(a){for(var b=
[],c=0;c<a.length;c++)b.push(g(a[c]));return b};a.exports.decode=function(a){for(var b=[],c=0;c<a.length;c++)b.push(m(a[c]));return b}},function(a,d){function g(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 m(a){a=~a;var b=((a&15)<<3)+132<<((a&112)>>4);return a&128?132-b:b-132}a.exports.encodeSample=g;a.exports.decodeSample=m;a.exports.encode=function(a){for(var b=[],c=0;c<
a.length;c++)b.push(g(a[c]));return b};a.exports.decode=function(a){for(var b=[],c=0;c<a.length;c++)b.push(m(a[c]));return b}},function(a,d,g){var m=g(0),c=g(14),b=g(1),f=b.uInt8,l=b.uInt16,h=b.uInt32,k=b.chr;d=function(){var a=c.call(this)||this;a.samples=[];a.headerFormats_={4:17,8:1,"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,64:3};a.head_=0;return a};$jscomp.inherits(d,c);d.prototype.readRIFFChunk_=function(a){this.chunkId=b.unpackArray(a.slice(0,4),k);if("RIFF"!=this.chunkId&&"RIFX"!=this.chunkId)throw Error(m.format);
this.LEorBE_();this.chunkSize=b.unpack(a.slice(4,8),h);this.format=b.unpackArray(a.slice(8,12),k);if("WAVE"!=this.format)throw Error(m.wave);};d.prototype.LEorBE_=function(){var a="RIFX"==this.chunkId;f.be=a;l.be=a;return h.be=a};d.prototype.readFmtChunk_=function(a){if(a=this.findChunk_(a,"fmt "))this.fmtChunkId="fmt ",this.fmtChunkSize=a.chunkSize,this.audioFormat=b.unpack(a.chunkData.slice(0,2),l),this.numChannels=b.unpack(a.chunkData.slice(2,4),l),this.sampleRate=b.unpack(a.chunkData.slice(4,
8),h),this.byteRate=b.unpack(a.chunkData.slice(8,12),h),this.blockAlign=b.unpack(a.chunkData.slice(12,14),l),this.bitsPerSample=b.unpack(a.chunkData.slice(14,16),l),this.readFmtExtension_(a);else throw Error(m["fmt "]);};d.prototype.readFmtExtension_=function(a){16<this.fmtChunkSize&&(this.cbSize=b.unpack(a.chunkData.slice(16,18),l),18<this.fmtChunkSize&&(this.validBitsPerSample=b.unpack(a.chunkData.slice(18,20),l),20<this.fmtChunkSize&&(this.dwChannelMask=b.unpack(a.chunkData.slice(20,24),h),this.subformat1=
b.unpack(a.chunkData.slice(24,28),h),this.subformat2=b.unpack(a.chunkData.slice(28,32),h),this.subformat3=b.unpack(a.chunkData.slice(32,36),h),this.subformat4=b.unpack(a.chunkData.slice(36,40),h))))};d.prototype.readFactChunk_=function(a){if(a=this.findChunk_(a,"fact"))this.factChunkId="fact",this.factChunkSize=a.chunkSize,this.dwSampleLength=b.unpack(a.chunkData.slice(0,4),h);else if(this.enforceFact)throw Error(m.fact);};d.prototype.readBextChunk_=function(a){if(a=this.findChunk_(a,"bext"))this.bextChunkId=
"bext",this.bextChunkSize=a.chunkSize,this.bextChunkData_=a.chunkData,this.readBextChunkFields_()};d.prototype.readBextChunkFields_=function(){this.head_=0;this.bextChunkFields={description:this.readVariableSizeString_(this.bextChunkData_,256),originator:this.readVariableSizeString_(this.bextChunkData_,32),originatorReference:this.readVariableSizeString_(this.bextChunkData_,32),originationDate:this.readVariableSizeString_(this.bextChunkData_,10),originationTime:this.readVariableSizeString_(this.bextChunkData_,
8),timeReference:this.readBytes_(this.bextChunkData_,8),version:this.readFromChunk_(this.bextChunkData_,l),UMID:this.readVariableSizeString_(this.bextChunkData_,64),loudnessValue:this.readFromChunk_(this.bextChunkData_,l),loudnessRange:this.readFromChunk_(this.bextChunkData_,l),maxTruePeakLevel:this.readFromChunk_(this.bextChunkData_,l),maxMomentaryLoudness:this.readFromChunk_(this.bextChunkData_,l),maxShortTermLoudness:this.readFromChunk_(this.bextChunkData_,l),reserved:this.readVariableSizeString_(this.bextChunkData_,
180),codingHistory:this.readVariableSizeString_(this.bextChunkData_,this.bextChunkData_.length-602)}};d.prototype.readBytes_=function(a,b){var e=this.head_;this.head_+=b;return a.slice(e,this.head_)};d.prototype.readVariableSizeString_=function(a,c){for(var e="",d=0;d<c;d++)e+=b.unpack([a[this.head_]],k),this.head_++;return e};d.prototype.readFromChunk_=function(a,c){var e=c.bits/8;a=b.unpack(a.slice(this.head_,this.head_+e),c);this.head_+=e;return a};d.prototype.writeVariableSizeString_=function(a,
c){a=b.packArray(a,k);for(var e=a.length;e<c;e++)a.push(0);return a};d.prototype.readCueChunk_=function(a){if(a=this.findChunk_(a,"cue "))this.cueChunkId="cue ",this.cueChunkSize=a.chunkSize,this.cueChunkData_=a.chunkData};d.prototype.readDataChunk_=function(a,b){if(a=this.findChunk_(a,"data"))this.dataChunkId="data",this.dataChunkSize=a.chunkSize,this.samplesFromBytes_(a.chunkData,b);else throw Error(m.data);};d.prototype.samplesFromBytes_=function(a,c){c.bits=4==this.bitsPerSample?8:this.bitsPerSample;
c.signed=8==c.bits?!1:!0;c.float=3==this.audioFormat||64==this.bitsPerSample?!0:!1;c.single=!1;this.samples=b.unpackArray(a,new b.Type(c))};d.prototype.findChunk_=function(a,b){for(var c=0;c<a.length;c++)if(a[c].chunkId==b)return a[c];return null};d.prototype.samplesToBytes_=function(a){a.bits=4==this.bitsPerSample?8:this.bitsPerSample;a.signed=8==a.bits?!1:!0;a.float=3==this.audioFormat||64==this.bitsPerSample?!0:!1;a=b.packArray(this.samples,new b.Type(a));a.length%2&&a.push(0);return a};d.prototype.getBextBytes_=
function(){if(this.bextChunkId){var a=[].concat(this.writeVariableSizeString_(this.bextChunkFields.description,256));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.originator,32));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.originatorReference,32));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.originationDate,10));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.originationTime,8));a=a.concat(this.bextChunkFields.timeReference);a=a.concat(b.pack(this.bextChunkFields.version,
l));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.UMID,64));a=a.concat(b.pack(this.bextChunkFields.loudnessValue,l));a=a.concat(b.pack(this.bextChunkFields.loudnessRange,l));a=a.concat(b.pack(this.bextChunkFields.maxTruePeakLevel,l));a=a.concat(b.pack(this.bextChunkFields.maxMomentaryLoudness,l));a=a.concat(b.pack(this.bextChunkFields.maxShortTermLoudness,l));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.reserved,180));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.codingHistory,
this.bextChunkData_.length-602));return[].concat(b.packArray(this.bextChunkId,k),b.pack(a.length,h),a)}return[]};d.prototype.getCueBytes_=function(){return this.cueChunkId?[].concat(b.packArray(this.cueChunkId,k),b.pack(this.cueChunkSize,h),this.cueChunkData_):[]};d.prototype.getFactBytes_=function(){return this.factChunkId?[].concat(b.packArray(this.factChunkId,k),b.pack(this.factChunkSize,h),b.pack(this.dwSampleLength,h)):[]};d.prototype.getCbSizeBytes_=function(){return 16<this.fmtChunkSize?b.pack(this.cbSize,
l):[]};d.prototype.getValidBitsPerSampleBytes_=function(){return 18<this.fmtChunkSize?b.pack(this.validBitsPerSample,l):[]};d.prototype.getFmtExtensionBytes_=function(){return 20<this.fmtChunkSize?b.pack(this.dwChannelMask,h).concat(b.pack(this.subformat1,h),b.pack(this.subformat2,h),b.pack(this.subformat3,h),b.pack(this.subformat4,h)):[]};d.prototype.createWaveFile_=function(){var a={be:this.LEorBE_()};return b.packArray(this.chunkId,k).concat(b.pack(this.chunkSize,h),b.packArray(this.format,k),
this.getBextBytes_(),b.packArray(this.fmtChunkId,k),b.pack(this.fmtChunkSize,h),b.pack(this.audioFormat,l),b.pack(this.numChannels,l),b.pack(this.sampleRate,h),b.pack(this.byteRate,h),b.pack(this.blockAlign,l),b.pack(this.bitsPerSample,l),this.getCbSizeBytes_(),this.getValidBitsPerSampleBytes_(),this.getFmtExtensionBytes_(),this.getFactBytes_(),b.packArray(this.dataChunkId,k),b.pack(this.dataChunkSize,h),this.samplesToBytes_(a),this.getCueBytes_())};a.exports=d},function(a,d){a.exports=function(){this.chunkId=
"";this.chunkSize=0;this.fmtChunkId=this.format="";this.subformat4=this.subformat3=this.subformat2=this.subformat1=this.dwChannelMask=this.validBitsPerSample=this.cbSize=this.bitsPerSample=this.blockAlign=this.byteRate=this.sampleRate=this.numChannels=this.audioFormat=this.fmtChunkSize=0;this.factChunkId="";this.dwSampleLength=this.factChunkSize=0;this.cueChunkId="";this.cueChunkSize=-1;this.cueChunkData_=[];this.bextChunkId="";this.bextChunkSize=0;this.bextChunkFields={description:"",originator:"",
originatorReference:"",originationDate:"",originationTime:"",timeReference:[],version:"",UMID:"",loudnessValue:"",loudnessRange:"",maxTruePeakLevel:"",maxMomentaryLoudness:"",maxShortTermLoudness:"",reserved:"",codingHistory:""};this.ds64={riffSizeHigh:0,riffSizeLow:0,dataSizeHigh:0,dataSizeLow:0,originationTime:0,sampleCountHigh:0,sampleCountLow:0,tableLength:0,table:[]};this.dataChunkId="";this.dataChunkSize=0;this.bextChunkData_=[]}}]);
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,g){a!=Array.prototype&&a!=Object.prototype&&(a[b]=g.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,b,g,h){if(b){g=$jscomp.global;a=a.split(".");for(h=0;h<a.length-1;h++){var e=a[h];e in g||(g[e]={});g=g[e]}a=a[a.length-1];h=g[a];b=b(h);b!=h&&null!=b&&$jscomp.defineProperty(g,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Object.is",function(a){return a?a:function(b,a){return b===a?0!==b||1/b===1/a:b!==b&&a!==a}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,g){var b=this;b instanceof String&&(b=String(b));var e=b.length;for(g=g||0;g<e;g++)if(b[g]==a||Object.is(b[g],a))return!0;return!1}},"es7","es3");
$jscomp.checkStringArgs=function(a,b,g){if(null==a)throw new TypeError("The 'this' value for String.prototype."+g+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+g+" must not be a regular expression");return a+""};
(function(a){function b(h){if(g[h])return g[h].exports;var e=g[h]={i:h,l:!1,exports:{}};a[h].call(e.exports,e,e.exports,b);e.l=!0;return e.exports}var g={};b.m=a;b.c=g;b.d=function(a,e,g){b.o(a,e)||Object.defineProperty(a,e,{configurable:!1,enumerable:!0,get:g})};b.n=function(a){var e=a&&a.__esModule?function(){return a["default"]}:function(){return a};b.d(e,"a",e);return e};b.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};b.p="";return b(b.s=1)})([function(a,b,g){function h(a,
d,b){var e=[];if(void 0===a)return e;l.assureType_(d,void 0===b?10:b);a.constructor==String?a.length>=d.offset&&(e=l.toBytes_(a.slice(0,d.offset),d)):e=l.toBytes_([a],d);return e}function e(a,d,b){l.assureType_(d,void 0===b?10:b);a=l.fromBytes_(a.slice(0,d.offset),d);return a=d["char"]?a.slice(0,d.offset):a?a[0]:null}var l=g(5);a.exports.pack=h;a.exports.unpack=e;a.exports.packArray=function(a,d,b){l.assureType_(d,void 0===b?10:b);return l.toBytes_(a,d)};a.exports.unpackArray=function(a,d,b){l.assureType_(d,
void 0===b?10:b);return l.fromBytes_(a,d)};a.exports.unpackStruct=function(a,d,b){b=void 0===b?10:b;if(a.length<l.getStructDefSize_(d))return[];for(var g=[],f=0,c=0;c<d.length;c++)g=g.concat(e(a.slice(f,f+d[c].offset),d[c],b)),f+=d[c].offset;return g};a.exports.packStruct=function(a,d,b){b=void 0===b?10:b;if(a.length<d.length)return[];for(var e=[],f=0;f<d.length;f++)e=e.concat(h(a[f],d[f],b));return e};a.exports.chr={bits:8,"char":!0};a.exports.fourCC={bits:32,"char":!0};a.exports.bool={bits:1};a.exports.int2=
{bits:2,signed:!0};a.exports.uInt2={bits:2};a.exports.int4={bits:4,signed:!0};a.exports.uInt4={bits:4};a.exports.int8={bits:8,signed:!0};a.exports.uInt8={bits:8};a.exports.int16={bits:16,signed:!0};a.exports.uInt16={bits:16};a.exports.float16={bits:16,"float":!0};a.exports.int24={bits:24,signed:!0};a.exports.uInt24={bits:24};a.exports.int32={bits:32,signed:!0};a.exports.uInt32={bits:32};a.exports.float32={bits:32,"float":!0};a.exports.int40={bits:40,signed:!0};a.exports.uInt40={bits:40};a.exports.int48=
{bits:48,signed:!0};a.exports.uInt48={bits:48};a.exports.float64={bits:64,"float":!0};a.exports.int16BE={bits:16,signed:!0,be:!0};a.exports.uInt16BE={bits:16,be:!0};a.exports.float16BE={bits:16,"float":!0,be:!0};a.exports.int24BE={bits:24,signed:!0,be:!0};a.exports.uInt24BE={bits:24,be:!0};a.exports.int32BE={bits:32,signed:!0,be:!0};a.exports.uInt32BE={bits:32,be:!0};a.exports.float32BE={bits:32,"float":!0,be:!0};a.exports.int40BE={bits:40,signed:!0,be:!0};a.exports.uInt40BE={bits:40,be:!0};a.exports.int48BE=
{bits:48,signed:!0,be:!0};a.exports.uInt48BE={bits:48,be:!0};a.exports.float64BE={bits:64,"float":!0,be:!0}},function(a,b,g){a=g(2);window.WaveFile=a},function(a,b,g){var h=g(3),e=g(4),l=g(8),n=g(9),d=g(0),m=g(0).uInt8,k=g(0).uInt16,f=g(0).uInt32;b=function(c){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:"",chunkSize:0,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;c&&this.fromBuffer(c)};b.prototype.fromScratch=function(c,d,a,b,f){f=void 0===f?{}:f;f.container||(f.container="RIFF");var e=((parseInt(a,10)-1|7)+1)/8;this.clearHeader_();this.bitDepth=a;this.container=f.container;this.chunkSize=36+b.length*e;this.format=
"WAVE";this.fmt.chunkId="fmt ";this.fmt.chunkSize=16;this.fmt.byteRate=c*e*d;this.fmt.blockAlign=c*e;this.fmt.audioFormat=this.audioFormats_[a]?this.audioFormats_[a]:65534;this.fmt.numChannels=c;this.fmt.sampleRate=d;this.fmt.bitsPerSample=parseInt(a,10);this.data.chunkId="data";this.data.samples=b;0<b.length&&b[0].constructor===Array&&(this.isInterleaved=!1,this.interleave());this.data.chunkSize=b.length*e;"4"==a&&(this.chunkSize=44+b.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*b.length,this.data.chunkSize=b.length);if("8a"==a||"8m"==a)this.chunkSize=44+b.length,this.fmt.chunkSize=20,this.fmt.cbSize=2,this.fmt.validBitsPerSample=8,this.fact.chunkId="fact",this.fact.chunkSize=4,this.fact.dwSampleLength=b.length;65534==this.fmt.audioFormat&&(this.chunkSize=60+b.length*e,this.fmt.chunkSize=40,this.fmt.bitsPerSample=(parseInt(a,
10)-1|7)+1,this.fmt.cbSize=22,this.fmt.validBitsPerSample=parseInt(a,10),this.fmt.dwChannelMask=0,this.fmt.subformat=[1,1048576,2852126848,1905997824])};b.prototype.fromBuffer=function(c){this.readRIFFChunk_(c);var d="RIFX"==this.container;c=e.read(c,d);this.readDs64Chunk_(c.subChunks);this.readFmtChunk_(c.subChunks);this.readFactChunk_(c.subChunks);this.readBextChunk_(c.subChunks);this.readCueChunk_(c.subChunks);this.readDataChunk_(c.subChunks,{be:d,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()};b.prototype.toBuffer=function(){this.checkWriteInput_();this.assureInterleaved_();return this.createWaveFile_()};b.prototype.toRIFF=function(){"RF64"==this.container?this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,this.data.samples):(this.container="RIFF",this.LEorBE_())};b.prototype.toRIFX=function(){"RF64"==this.container?this.fromScratch(this.fmt.numChannels,
this.fmt.sampleRate,this.bitDepth,this.data.samples,{container:"RIFX"}):(this.container="RIFX",this.LEorBE_())};b.prototype.toBitDepth=function(c,d){var a=c,b=this.bitDepth;void 0===d||d||(a=this.realBitDepth_(c),b=this.realBitDepth_(this.bitDepth));this.assureInterleaved_();h.toBitDepth(this.data.samples,b,a);this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,c,this.data.samples,{container:this.correctContainer_()})};b.prototype.correctContainer_=function(){return"RF64"==this.container?"RIFF":
this.container};b.prototype.interleave=function(){if(!this.isInterleaved){for(var c=[],d=this.data.samples[0].length,a=0;a<d;a++)for(var b=0;b<this.data.samples.length;b++)c.push(this.data.samples[b][a]);this.data.samples=c;this.isInterleaved=!0}};b.prototype.deInterleave=function(){if(this.isInterleaved){var c=[],d;for(d=0;d<this.fmt.numChannels;d++)c[d]=[];d=0;for(var a;d<this.data.samples.length;){for(a=0;a<this.fmt.numChannels;a++)c[a].push(this.data.samples[d+a]);d+=a}this.data.samples=c;this.isInterleaved=
!1}};b.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.correctContainer_()})};b.prototype.fromIMAADPCM=function(){this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"16",l.decode(this.data.samples,this.fmt.blockAlign),
{container:this.correctContainer_()})};b.prototype.toALaw=function(){this.assure16Bit_();this.assureInterleaved_();this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"8a",n.alaw.encode(this.data.samples),{container:this.correctContainer_()})};b.prototype.fromALaw=function(){this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"16",n.alaw.decode(this.data.samples),{container:this.correctContainer_()})};b.prototype.toMuLaw=function(){this.assure16Bit_();this.assureInterleaved_();this.fromScratch(this.fmt.numChannels,
this.fmt.sampleRate,"8m",n.mulaw.encode(this.data.samples),{container:this.correctContainer_()})};b.prototype.fromMuLaw=function(){this.fromScratch(this.fmt.numChannels,this.fmt.sampleRate,"16",n.mulaw.decode(this.data.samples),{container:this.correctContainer_()})};b.prototype.realBitDepth_=function(c){"32f"!=c&&(c=((parseInt(c,10)-1|7)+1).toString());return c};b.prototype.checkWriteInput_=function(){this.validateBitDepth_();this.validateNumChannels_();this.validateSampleRate_()};b.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};b.prototype.validateNumChannels_=function(){var c=this.fmt.numChannels*this.fmt.bitsPerSample/8;if(1>this.fmt.numChannels||65535<c)throw Error("Invalid number of channels.");return!0};b.prototype.validateSampleRate_=function(){var c=this.fmt.bitsPerSample/8*this.fmt.numChannels*this.fmt.sampleRate;if(1>this.fmt.sampleRate||4294967295<
c)throw Error("Invalid sample rate.");return!0};b.prototype.clearHeader_=function(){this.fmt.cbSize=0;this.fmt.validBitsPerSample=0;this.fact.chunkId="";this.ds64.chunkId=""};b.prototype.assure16Bit_=function(){this.assureUncompressed_();"16"!=this.bitDepth&&this.toBitDepth("16")};b.prototype.assureUncompressed_=function(){"8a"==this.bitDepth?this.fromALaw():"8m"==this.bitDepth?this.fromMuLaw():"4"==this.bitDepth&&this.fromIMAADPCM()};b.prototype.assureInterleaved_=function(){this.isInterleaved||
this.interleave()};b.prototype.LEorBE_=function(){var c="RIFX"===this.container;m.be=c;k.be=c;return f.be=c};b.prototype.findChunk_=function(c,d){for(var a=0;a<c.length;a++)if(c[a].chunkId===d)return c[a];return null};b.prototype.readRIFFChunk_=function(c){this.container=d.unpackArray(c.slice(0,4),d.chr);if(-1===["RIFF","RIFX","RF64"].indexOf(this.container))throw Error("Not a supported format.");this.LEorBE_();this.chunkSize=d.unpack(c.slice(4,8),f);this.format=d.unpackArray(c.slice(8,12),d.chr);
if("WAVE"!=this.format)throw Error("Could not find the 'WAVE' format identifier");};b.prototype.readFmtChunk_=function(c){if(c=this.findChunk_(c,"fmt "))this.fmt.chunkId="fmt ",this.fmt.chunkSize=c.chunkSize,this.fmt.audioFormat=d.unpack(c.chunkData.slice(0,2),k),this.fmt.numChannels=d.unpack(c.chunkData.slice(2,4),k),this.fmt.sampleRate=d.unpack(c.chunkData.slice(4,8),f),this.fmt.byteRate=d.unpack(c.chunkData.slice(8,12),f),this.fmt.blockAlign=d.unpack(c.chunkData.slice(12,14),k),this.fmt.bitsPerSample=
d.unpack(c.chunkData.slice(14,16),k),this.readFmtExtension_(c);else throw Error("Could not find the 'fmt ' chunk");};b.prototype.readFmtExtension_=function(c){c=c.chunkData;16<this.fmt.chunkSize&&(this.fmt.cbSize=d.unpack(c.slice(16,18),k),18<this.fmt.chunkSize&&(this.fmt.validBitsPerSample=d.unpack(c.slice(18,20),k),20<this.fmt.chunkSize&&(this.fmt.dwChannelMask=d.unpack(c.slice(20,24),f),this.fmt.subformat=[d.unpack(c.slice(24,28),f),d.unpack(c.slice(28,32),f),d.unpack(c.slice(32,36),f),d.unpack(c.slice(36,
40),f)])))};b.prototype.readFactChunk_=function(c){if(c=this.findChunk_(c,"fact"))this.fact.chunkId="fact",this.fact.chunkSize=c.chunkSize,this.fact.dwSampleLength=d.unpack(c.chunkData.slice(0,4),f);else if(this.enforceFact_)throw Error("Could not find the 'fact' chunk");};b.prototype.readCueChunk_=function(c){var a=this.findChunk_(c,"cue ");if(a)for(c=a.chunkData,this.cue.chunkId="cue ",this.cue.chunkSize=a.chunkSize,this.cue.dwCuePoints=d.unpack(c.slice(0,4),f),a=0;a<this.cue.dwCuePoints;a++){var b=
4+24*a;this.cue.points.push({dwName:d.unpack(c.slice(b,b+4),f),dwPosition:d.unpack(c.slice(b+4,b+8),f),fccChunk:d.unpack(c.slice(b+8,b+12),d.fourCC),dwChunkStart:d.unpack(c.slice(b+12,b+16),f),dwBlockStart:d.unpack(c.slice(b+16,b+20),f),dwSampleOffset:d.unpack(c.slice(b+20,b+24),f)})}};b.prototype.readDataChunk_=function(c,d){if(c=this.findChunk_(c,"data"))this.data.chunkId="data",this.data.chunkSize=c.chunkSize,this.samplesFromBytes_(c.chunkData,d);else throw Error("Could not find the 'data' chunk");
};b.prototype.readBextChunk_=function(c){if(c=this.findChunk_(c,"bext"))c=c.chunkData,this.head_=0,this.bext={chunkId:"bext",chunkSize:c.length,description:this.readString_(c,256),originator:this.readString_(c,32),originatorReference:this.readString_(c,32),originationDate:this.readString_(c,10),originationTime:this.readString_(c,8),timeReference:[this.readFromChunk_(c,f),this.readFromChunk_(c,f)],version:this.readFromChunk_(c,k),UMID:this.readString_(c,64),loudnessValue:this.readFromChunk_(c,k),loudnessRange:this.readFromChunk_(c,
k),maxTruePeakLevel:this.readFromChunk_(c,k),maxMomentaryLoudness:this.readFromChunk_(c,k),maxShortTermLoudness:this.readFromChunk_(c,k),reserved:this.readString_(c,180),codingHistory:this.readString_(c,c.length-602)}};b.prototype.readDs64Chunk_=function(c){if(c=this.findChunk_(c,"ds64")){var a=c.chunkData;this.ds64.chunkId=c.chunkId;this.ds64.chunkSize=c.chunkSize;this.ds64.riffSizeHigh=d.unpack(a.slice(0,4),f);this.ds64.riffSizeLow=d.unpack(a.slice(4,8),f);this.ds64.dataSizeHigh=d.unpack(a.slice(8,
12),f);this.ds64.dataSizeLow=d.unpack(a.slice(12,16),f);this.ds64.originationTime=d.unpack(a.slice(16,20),f);this.ds64.sampleCountHigh=d.unpack(a.slice(20,24),f);this.ds64.sampleCountLow=d.unpack(a.slice(24,28),f)}else if("RF64"==this.container)throw Error("Could not find the 'ds64' chunk");};b.prototype.readString_=function(c,a){for(var b="",f=0;f<a;f++)b+=d.unpack([c[this.head_]],d.chr),this.head_++;return b};b.prototype.readFromChunk_=function(c,a){var b=a.bits/8;c=d.unpack(c.slice(this.head_,
this.head_+b),a);this.head_+=b;return c};b.prototype.writeString_=function(c,a){c=d.packArray(c,d.chr);for(var b=c.length;b<a;b++)c.push(0);return c};b.prototype.samplesToBytes_=function(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=d.packArray(this.data.samples,c);c.length%2&&c.push(0);return c};b.prototype.samplesFromBytes_=function(c,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.single=!1;this.data.samples=d.unpackArray(c,a)};b.prototype.getBextBytes_=function(){return this.bext.chunkId?[].concat(d.packArray(this.bext.chunkId,d.chr),d.pack(this.bext.chunkSize,f),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],f),d.pack(this.bext.timeReference[1],f),d.pack(this.bext.version,k),this.writeString_(this.bext.UMID,64),d.pack(this.bext.loudnessValue,k),d.pack(this.bext.loudnessRange,k),d.pack(this.bext.maxTruePeakLevel,k),d.pack(this.bext.maxMomentaryLoudness,k),d.pack(this.bext.maxShortTermLoudness,k),this.writeString_(this.bext.reserved,180),this.writeString_(this.bext.codingHistory,this.bext.chunkSize-602)):[]};b.prototype.getDs64Bytes_=function(){var c=[];this.ds64.chunkId&&
(c=c.concat(d.packArray(this.ds64.chunkId,d.chr),d.pack(this.ds64.chunkSize,f),d.pack(this.ds64.riffSizeHigh,f),d.pack(this.ds64.riffSizeLow,f),d.pack(this.ds64.dataSizeHigh,f),d.pack(this.ds64.dataSizeLow,f),d.pack(this.ds64.originationTime,f),d.pack(this.ds64.sampleCountHigh,f),d.pack(this.ds64.sampleCountLow,f)));return c};b.prototype.getCueBytes_=function(){return this.cue.chunkId?[].concat(d.packArray(this.cue.chunkId,d.chr),d.pack(this.cue.chunkSize,f),d.pack(this.cue.dwCuePoints,f),this.getCuePointsBytes_()):
[]};b.prototype.getCuePointsBytes_=function(){for(var c=[],a=0;a<this.cue.dwCuePoints;a++)c=c.concat(d.pack(this.cue.points[a].dwName,f),d.pack(this.cue.points[a].dwPosition,f),d.pack(this.cue.points[a].fccChunk,d.fourCC),d.pack(this.cue.points[a].dwChunkStart,f),d.pack(this.cue.points[a].dwBlockStart,f),d.pack(this.cue.points[a].dwSampleOffset,f));return c};b.prototype.getFactBytes_=function(){return this.fact.chunkId?[].concat(d.packArray(this.fact.chunkId,d.chr),d.pack(this.fact.chunkSize,f),d.pack(this.fact.dwSampleLength,
f)):[]};b.prototype.getFmtBytes_=function(){if(this.fmt.chunkId)return[].concat(d.packArray(this.fmt.chunkId,d.chr),d.pack(this.fmt.chunkSize,f),d.pack(this.fmt.audioFormat,k),d.pack(this.fmt.numChannels,k),d.pack(this.fmt.sampleRate,f),d.pack(this.fmt.byteRate,f),d.pack(this.fmt.blockAlign,k),d.pack(this.fmt.bitsPerSample,k),this.getFmtExtensionBytes_());throw Error("Could not find the 'fmt ' chunk");};b.prototype.getFmtExtensionBytes_=function(){var c=[];16<this.fmt.chunkSize&&(c=c.concat(d.pack(this.fmt.cbSize,
k)));18<this.fmt.chunkSize&&(c=c.concat(d.pack(this.fmt.validBitsPerSample,k)));20<this.fmt.chunkSize&&(c=c.concat(d.pack(this.fmt.dwChannelMask,f)));24<this.fmt.chunkSize&&(c=c.concat(d.pack(this.fmt.subformat[0],f),d.pack(this.fmt.subformat[1],f),d.pack(this.fmt.subformat[2],f),d.pack(this.fmt.subformat[3],f)));return c};b.prototype.createWaveFile_=function(){var c={be:this.LEorBE_()};return new Uint8Array([].concat(d.packArray(this.container,d.chr),d.pack(this.chunkSize,f),d.packArray(this.format,
d.chr),this.getDs64Bytes_(),this.getBextBytes_(),this.getFmtBytes_(),this.getFactBytes_(),d.packArray(this.data.chunkId,d.chr),d.pack(this.data.chunkSize,f),this.samplesToBytes_(c),this.getCueBytes_()))};a.exports=b},function(a,b){function g(a,c,b){if(c!=b){m(c);m(b);var f=["32f","64"].includes(c)?["32f","64"].includes(b)?d:l:["32f","64"].includes(b)?n:e;var g={oldMin:Math.pow(2,parseInt(c,10))/2,newMin:Math.pow(2,parseInt(b,10))/2,oldMax:Math.pow(2,parseInt(c,10))/2-1,newMax:Math.pow(2,parseInt(b,
10))/2-1};h(a,c,!1);for(c=0;c<a.length;c++)a[c]=f(a[c],g);h(a,b,!0)}}function h(a,c,d){if("8"==c)if(d)for(c=0;c<a.length;c++)a[c]+=128;else for(c=0;c<a.length;c++)a[c]-=128}function e(a,c){return a=0<a?parseInt(a/c.oldMax*c.newMax,10):parseInt(a/c.oldMin*c.newMin,10)}function l(a,c){return parseInt(0<a?a*c.newMax:a*c.newMin,10)}function n(a,c){return 0<a?a/c.oldMax:a/c.oldMin}function d(a){k[0]=a;return a=k[0]}function m(a){if("32f"!=a&&"64"!=a&&("8">parseInt(a,10)||"53"<parseInt(a,10)))throw Error("Invalid bit depth.");
return!0}var k=new Float32Array(1);a.exports=g;a.exports.toBitDepth=g},function(a,b,g){function h(a){m.be="RIFX"===a.chunkId;var b=d.packArray(a.chunkId,d.chr).concat(d.pack(a.chunkSize,m),d.packArray(a.format,d.chr),e(a.subChunks));if("RIFF"===a.chunkId||"RIFX"===a.chunkId)b=new Uint8Array(b);return b}function e(a){for(var b=[],c=0;c<a.length;)b="LIST"===a[c].chunkId?b.concat(h(a[c])):b.concat(d.packArray(a[c].chunkId,d.chr),d.pack(a[c].chunkSize,m),a[c].chunkData),c++;return b}function l(a){for(var b=
[],c=12;c<a.length;)b.push(n(a,c)),c+=8+b[b.length-1].chunkSize;return b}function n(a,b){var c={chunkId:d.unpackArray(a.slice(b,b+4),d.chr),chunkSize:d.unpack(a.slice(b+4,b+8),m)};"LIST"===c.chunkId?(c.format=d.unpackArray(a.slice(8,12),d.chr),c.subChunks=l(a.slice(b,b+c.chunkSize))):c.chunkData=a.slice(b+8,b+8+c.chunkSize);return c}var d=g(0),m=d.uInt32;a.exports.read=function(a){a=[].slice.call(a);var b=d.unpackArray(a.slice(0,4),d.chr);m.be="RIFX"===b;return{chunkId:b,chunkSize:d.unpack(a.slice(4,
8),m),format:d.unpackArray(a.slice(8,12),d.chr),subChunks:l(a)}};a.exports.write=h},function(a,b,g){function h(a,c){return p.read(a,c)}function e(a,c){a=p.read(a,c);c=(a&31744)>>10;var b=a&1023;return(c?Math.pow(2,c-15)*(1+b/1024):b/1024*.00006103515625)*(a>>15?-1:1)}function l(a,c){x[0]=p.read(a,c);return y[0]}function n(a,c){w[0]=p.read(a,c);w[1]=p.read(a,c+4);return z[0]}function d(a,c){for(var b="",d=0;d<p.offset;d++)b+=String.fromCharCode(a[c+d]);return b}function m(a,c,b){return p.write(a,c,
b)}function k(a,c,b){y[0]=c;var d=x[0];c=d>>16&32768;var e=d>>12&2047;d=d>>23&255;103<=d&&(c=(c|d-112<<10|e>>1)+(e&1));a[b++]=c&255;a[b++]=c>>>8&255;return b}function f(a,c,b){y[0]=c;return b=p.write(a,x[0],b)}function c(a,c,b){z[0]=c;b=p.write(a,w[0],b);return p.write(a,w[1],b)}function q(a,c,b){a[b++]=c.charCodeAt(0);return b}var r=g(6),v=g(7);b=new Int8Array(4);var x=new Int32Array(b.buffer,0,1),y=new Float32Array(b.buffer,0,1);b=new Int8Array(8);var z=new Float64Array(b.buffer),w=new Uint32Array(b.buffer),
t,u,p;a.exports.toBytes_=function(a,c){for(var b=0,d=[],e=0;e<a.length;e++)b=u(d,a[e],b);a=d;c.be&&r(a,c.offset);if(10!=c.base){b=c.base;for(d=0;d<a.length;d++)a[d]=a[d].toString(b);b=a;c=(2==c.base?8:2)+1;for(d=0;d<b.length;d++)b[d]=Array(c-b[d].length).join("0")+b[d]}return a};a.exports.fromBytes_=function(a,c){c.be&&r(a,c.offset);if(10!=c.base)for(var b=c.base,d=0;d<a.length;d++)a[d]=parseInt(a[d],b);b=[];d=0;for(var e=a.length-(c.offset-1);d<e;)b.push(t(a,d)),d+=c.offset;c["char"]&&(b=b.join(""));
return b};a.exports.getStructDefSize_=function(a){for(var c=0,b=0;b<a.length;b++)c+=a[b].offset;return c};a.exports.assureType_=function(a,b){a.offset=8>a.bits?1:Math.ceil(a.bits/8);a.base=b;a["float"]?16==a.bits?t=e:32==a.bits?t=l:64==a.bits&&(t=n):t=a["char"]?d:h;a["float"]?16==a.bits?u=k:32==a.bits?u=f:64==a.bits&&(u=c):u=a["char"]?q:m;p=a["float"]?64==a.bits?new v(32,!1):32==a.bits?new v(32,!0):new v(16,!1):new v(a.bits,a.signed)}},function(a,b){a.exports=function(a,b){for(var e=a.length,g=0;g<
e;){for(var h=a,d=g,m=0,k=b-1,f=parseInt(b/2,10);m<f;){var c=h[d+m];h[d+m]=h[d+k];h[d+k]=c;m++;k--}g+=b}}},function(a,b){b=function(a,b){this.bits=a;this.signed=void 0===b?!1:b;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_()};b.prototype.read=function(a,b){b=void 0===b?0:b;if(32<this.bits)return this.readBits_(a,b);for(var e=0,g=this.offset-1;0<g;)e|=a[g+b]<<8*g,g--;e=(a[b]|e)>>>0;return this.overflow_(this.sign_(e))};
b.prototype.write=function(a,b,e){e=void 0===e?0:e;b=this.overflow_(b);var g=255;e=this.writeFirstByte_(a,b,e);for(var h=2;h<=this.offset;h++)h==this.offset&&(g=this.lastByteMask_),a[e++]=Math.floor(b/Math.pow(2,8*(h-1)))&g;return e};b.prototype.readBits_=function(a,b){b=void 0===b?0:b;for(var e="",g=0;g<this.offset;){var h=a[b+g].toString(2);e=Array(9-h.length).join("0")+h+e;g++}return this.overflow_(this.sign_(parseInt(e,2)))};b.prototype.build_=function(){this.validateWordSize_();this.setRealBits_();
this.setLastByteMask_();this.setMinMax_();this.offset=8>this.bits?1:Math.ceil(this.realBits_/8)};b.prototype.sign_=function(a){a>this.max&&(a-=2*this.max+2);return a};b.prototype.overflow_=function(a){a>this.max?a=this.max:a<this.min&&(a=this.min);return a};b.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)};b.prototype.validateWordSize_=function(){if(1>this.bits||64<this.bits)throw Error("Not a supported type.");};b.prototype.setRealBits_=
function(){8<this.bits&&(this.realBits_=(this.bits-1|7)+1)};b.prototype.setLastByteMask_=function(){var a=8-(this.realBits_-this.bits);this.lastByteMask_=Math.pow(2,0<a?a:8)-1};b.prototype.writeFirstByte_=function(a,b,e){8>this.bits?a[e++]=0>b?b+Math.pow(2,this.bits):b:a[e++]=b&255;return e};a.exports=b},function(a,b){function g(a){return 32768<a?a-65536:a}function h(a){var b=a-k;0<=b?a=0:(a=8,b=-b);var c=m[f],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;k=b&
8?k-e:k+e;-32768>k?k=-32768:32767<k&&(k=32767);f+=d[b&7];0>f?f=0:88<f&&(f=88);return a}function e(a){var b=0;a&4&&(b+=r);a&2&&(b+=r>>1);a&1&&(b+=r>>2);b+=r>>3;a&8&&(b=-b);c+=b;32767<c?c=32767:-32767>c&&(c=-32767);q+=d[a];0>q?q=0:88<q&&(q=88);r=m[q];return c}function l(a){var b=a[0];h(b);var c=[];c.push(b&255);c.push(b>>8&255);c.push(f);c.push(0);for(b=3;b<a.length;b+=2){var d=h(a[b]),e=h(a[b+1]);c.push(e<<4|d)}for(;256>c.length;)c.push(0);return c}function n(a){c=g(a[1]<<8|a[0]);q=a[2];r=m[q];for(var b=
[c,g(a[3]<<8|a[2])],d=4;d<a.length;d++){var f=a[d],h=f>>4;b.push(e(h<<4^f));b.push(e(h))}return b}var d=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],m=[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],k=0,f=0,c=0,q=0,r=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 c=[],d=[],e=0;e<a.length;e++)0==e%b&&0!=e&&(c=c.concat(n(d)),d=[]),d.push(a[e]);return c};a.exports.encodeBlock=l;a.exports.decodeBlock=n},function(a,b,g){a.exports.alaw=g(10);a.exports.mulaw=g(11)},function(a,b){function g(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],e;a=-32768==a?-32767:a;(e=~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^e^85}function h(a){var b=0;a^=85;a&128&&(a&=-129,b=-1);var e=((a&240)>>4)+4;a=4!=e?1<<e|(a&15)<<e-4|1<<e-5:a<<1|1;return-8*(0===b?a:-a)}a.exports.encodeSample=
g;a.exports.decodeSample=h;a.exports.encode=function(a){for(var b=[],e=0;e<a.length;e++)b.push(g(a[e]));return b};a.exports.decode=function(a){for(var b=[],e=0;e<a.length;e++)b.push(h(a[e]));return b}},function(a,b){function g(a){if(0>a){a=132-a;var b=127}else a+=132,b=255;32767<a&&(a=32767);var e=0;var d=a>>7;d&240&&(d>>=4,e+=4);d&12&&(d>>=2,e+=2);d&2&&(e+=1);d=e;return(d<<4|a>>d+3&15)^b}function h(a){a=~a;var b=((a&15)<<3)+132<<((a&112)>>4);return a&128?132-b:b-132}a.exports.encodeSample=g;a.exports.decodeSample=
h;a.exports.encode=function(a){for(var b=[],e=0;e<a.length;e++)b.push(g(a[e]));return b};a.exports.decode=function(a){for(var b=[],e=0;e<a.length;e++)b.push(h(a[e]));return b}}]);

@@ -57,3 +57,2 @@ /*!

* @type {!Object<string, *>}
* @nocollapse
*/

@@ -93,3 +92,2 @@ this.fmt = {

* @type {!Object<string, *>}
* @nocollapse
*/

@@ -108,3 +106,2 @@ this.fact = {

* @type {!Object<string, *>}
* @nocollapse
*/

@@ -118,3 +115,3 @@ this.cue = {

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

@@ -126,3 +123,2 @@ };

* @type {!Object<string, *>}
* @nocollapse
*/

@@ -173,3 +169,2 @@ this.bext = {

* @type {!Object<string, *>}
* @nocollapse
*/

@@ -180,2 +175,4 @@ this.ds64 = {

/** @type {!number} */
"chunkSize": 0,
/** @type {!number} */
"riffSizeHigh": 0, // DWORD

@@ -196,3 +193,3 @@ /** @type {!number} */

"tableLength": 0, // DWORD
/** @type {!Array} */
/** @type {!Array<number>} */
"table": []

@@ -204,3 +201,2 @@ };

* @type {!Object<string, *>}
* @nocollapse
*/

@@ -361,2 +357,3 @@ this.data = {

let chunk = riffChunks_.read(bytes, bigEndian);
this.readDs64Chunk_(chunk["subChunks"]);
this.readFmtChunk_(chunk["subChunks"]);

@@ -392,15 +389,32 @@ this.readFactChunk_(chunk["subChunks"]);

/**
* Turn the file to RIFF.
* Force a file as RIFF. Do not work with RF64 files.
*/
toRIFF() {
this.container = "RIFF";
this.LEorBE_();
if (this.container == "RF64") {
this.fromScratch(
this.fmt.numChannels,
this.fmt.sampleRate,
this.bitDepth,
this.data.samples);
} else {
this.container = "RIFF";
this.LEorBE_();
}
}
/**
* Turn the file to RIFX.
* Force a file as RIFX. Do not work with RF64 files.
*/
toRIFX() {
this.container = "RIFX";
this.LEorBE_();
if (this.container == "RF64") {
this.fromScratch(
this.fmt.numChannels,
this.fmt.sampleRate,
this.bitDepth,
this.data.samples,
{"container": "RIFX"});
} else {
this.container = "RIFX";
this.LEorBE_();
}
}

@@ -430,7 +444,16 @@

this.data.samples,
{"container": this.container}
);
{"container": this.correctContainer_()});
}
/**
* Return "RIFF" if the container is "RF64", the current
* container name otherwise.
* Used to enforce "RIFF" as the container in operations where
* RF64 is not allowed.
*/
correctContainer_() {
return this.container == "RF64" ? "RIFF" : this.container;
}
/**
* Interleave multi-channel samples.

@@ -494,4 +517,3 @@ */

imaadpcm_.encode(this.data.samples),
{"container": this.container}
);
{"container": this.correctContainer_()});
}

@@ -509,4 +531,3 @@ }

imaadpcm_.decode(this.data.samples, this.fmt.blockAlign),
{"container": this.container}
);
{"container": this.correctContainer_()});
}

@@ -525,4 +546,3 @@

alawmulaw_.alaw.encode(this.data.samples),
{"container": this.container}
);
{"container": this.correctContainer_()});
}

@@ -539,4 +559,3 @@

alawmulaw_.alaw.decode(this.data.samples),
{"container": this.container}
);
{"container": this.correctContainer_()});
}

@@ -555,4 +574,3 @@

alawmulaw_.mulaw.encode(this.data.samples),
{"container": this.container}
);
{"container": this.correctContainer_()});
}

@@ -569,4 +587,3 @@

alawmulaw_.mulaw.decode(this.data.samples),
{"container": this.container}
);
{"container": this.correctContainer_()});
}

@@ -645,3 +662,4 @@

/**
* Reset the attributes related to the "fact" chunk.
* Reset attributes that should emptied when a file is
* created with the fromScratch() method.
* @private

@@ -653,4 +671,3 @@ */

this.fact.chunkId = "";
this.fact.chunkSize = 0;
this.fact.dwSampleLength = 0;
this.ds64.chunkId = "";
}

@@ -701,6 +718,6 @@

LEorBE_() {
let bigEndian = this.container == "RIFX";
uInt8_.be = bigEndian;
uInt16_.be = bigEndian;
uInt32_.be = bigEndian;
let bigEndian = this.container === "RIFX";
uInt8_["be"] = bigEndian;
uInt16_["be"] = bigEndian;
uInt32_["be"] = bigEndian;
return bigEndian;

@@ -711,3 +728,3 @@ }

* Find a chunk by its FourCC in a array of RIFF chunks.
* @param {!Object<string, Object>} chunks The wav file chunks.
* @param {!Array<!Object>} chunks The wav file chunks.
* @param {!string} fourCC The chunk fourCC.

@@ -719,3 +736,3 @@ * @return {Object|null}

for (let i = 0; i<chunks.length; i++) {
if (chunks[i]["chunkId"] == fourCC) {
if (chunks[i]["chunkId"] === fourCC) {
return chunks[i];

@@ -736,3 +753,3 @@ }

bytes.slice(0, 4), byteData_.chr);
if (this.container != "RIFF" && this.container != "RIFX") {
if (["RIFF", "RIFX", "RF64"].indexOf(this.container) === -1) {
throw Error("Not a supported format.");

@@ -751,3 +768,3 @@ }

* Read the "fmt " chunk of a wave file.
* @param {!Object<string, *>} chunks The wav file chunks.
* @param {!Array<!Object>} chunks The wav file chunks.
* @throws {Error} If no "fmt " chunk is found.

@@ -811,3 +828,3 @@ * @private

* Read the "fact" chunk of a wav file.
* @param {!Object<string, *>} chunks The wav file chunks.
* @param {!Array<!Object>} chunks The wav file chunks.
* @throws {Error} If no "fact" chunk is found.

@@ -830,3 +847,3 @@ * @private

* Read the "cue " chunk of a wave file.
* @param {!Object<string, *>} chunks The RIFF file chunks.
* @param {!Array<!Object>} chunks The RIFF file chunks.
* @private

@@ -865,3 +882,3 @@ */

* Read the "data" chunk of a wave file.
* @param {!Object<string, *>} chunks The RIFF file chunks.
* @param {!Array<!Object>} chunks The RIFF file chunks.
* @param {!Object<string, *>} options Type options.

@@ -884,3 +901,3 @@ * @throws {Error} If no "data" chunk is found.

* Read the "bext" chunk of a wav file.
* @param {!Object<string, *>} chunks The wav file chunks.
* @param {!Array<!Object>} chunks The wav file chunks.
* @private

@@ -925,2 +942,40 @@ */

/**
* Read the "fmt " chunk of a wave file.
* @param {!Array<!Object>} chunks The wav file chunks.
* @throws {Error} If no "fmt " chunk is found.
* @private
*/
readDs64Chunk_(chunks) {
let chunk = this.findChunk_(chunks, "ds64");
if (chunk) {
let chunkData = chunk["chunkData"];
this.ds64.chunkId = chunk["chunkId"];
this.ds64.chunkSize = chunk["chunkSize"];
this.ds64.riffSizeHigh = byteData_.unpack(
chunkData.slice(0, 4), uInt32_);
this.ds64.riffSizeLow = byteData_.unpack(
chunkData.slice(4, 8), uInt32_);
this.ds64.dataSizeHigh = byteData_.unpack(
chunkData.slice(8, 12), uInt32_);
this.ds64.dataSizeLow = byteData_.unpack(
chunkData.slice(12, 16), uInt32_);
this.ds64.originationTime = byteData_.unpack(
chunkData.slice(16, 20), uInt32_);
this.ds64.sampleCountHigh = byteData_.unpack(
chunkData.slice(20, 24), uInt32_);
this.ds64.sampleCountLow = byteData_.unpack(
chunkData.slice(24, 28), uInt32_);
//if (this.ds64.chunkSize > 28) {
// this.ds64.tableLength = byteData_.unpack(
// chunkData.slice(28, 32), uInt32_);
// this.ds64.table = chunkData.slice(32, 32 + this.ds64.tableLength);
//}
} else {
if (this.container == "RF64") {
throw Error("Could not find the 'ds64' chunk");
}
}
}
/**
* Read bytes as a string from a RIFF chunk.

@@ -1043,2 +1098,29 @@ * @param {!Array<number>|!Uint8Array} bytes The bytes.

/**
* Return the bytes of the "ds64" chunk.
* @return {!Array<number>} The "ds64" chunk bytes.
* @private
*/
getDs64Bytes_() {
let ds64Bytes = [];
if (this.ds64["chunkId"]) {
ds64Bytes = ds64Bytes.concat(
byteData_.packArray(this.ds64.chunkId, byteData_.chr),
byteData_.pack(this.ds64.chunkSize, uInt32_),
byteData_.pack(this.ds64.riffSizeHigh, uInt32_),
byteData_.pack(this.ds64.riffSizeLow, uInt32_),
byteData_.pack(this.ds64.dataSizeHigh, uInt32_),
byteData_.pack(this.ds64.dataSizeLow, uInt32_),
byteData_.pack(this.ds64.originationTime, uInt32_),
byteData_.pack(this.ds64.sampleCountHigh, uInt32_),
byteData_.pack(this.ds64.sampleCountLow, uInt32_));
}
//if (this.ds64.tableLength) {
// ds64Bytes = ds64Bytes.concat(
// byteData_.pack(this.ds64.tableLength, uInt32_),
// this.ds64.table);
//}
return ds64Bytes;
}
/**
* Return the bytes of the "cue " chunk.

@@ -1159,2 +1241,3 @@ * @return {!Array<number>} The "cue " chunk bytes.

byteData_.packArray(this.format, byteData_.chr),
this.getDs64Bytes_(),
this.getBextBytes_(),

@@ -1161,0 +1244,0 @@ this.getFmtBytes_(),

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

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

"RIFX",
"RF64",
"WAVE",

@@ -74,3 +75,3 @@ "BWF",

"bitdepth": "^3.0.3",
"byte-data": "^7.0.0",
"byte-data": "^7.0.1",
"imaadpcm": "^1.1.4",

@@ -77,0 +78,0 @@ "riff-chunks": "^4.0.1"

@@ -95,6 +95,6 @@ # wavefile

## Create wave files from scratch
### Create wave files from scratch
You must inform the number of channels, the sample rate, the bit depth and the samples (in this order). The samples should be represented as an array of numbers. The array may be multidimensional if there is more than one channel.
### Mono:
#### Mono:
```javascript

@@ -108,3 +108,3 @@ let wav = new WaveFile();

### Stereo:
#### Stereo:
Samples can be informed interleaved or de-interleaved. If they are de-interleaved, WaveFile will interleave them. In this example they are de-interleaved.

@@ -138,3 +138,3 @@ ```javascript

### A word on bit depths
#### A word on bit depths
Bit depths that do not fill full bytes (like 11-bit, 21-bit and so son) are actually stored

@@ -160,3 +160,3 @@ like the next greater bit depth that fill a full sequence of bytes:

## Interleave and de-interleave stereo samples
### Interleave and de-interleave stereo samples
Samples in WaveFile objects are interleaved by default, even if you created the file from scratch using de-interleaved samples.

@@ -176,3 +176,3 @@

## RIFF to RIFX and RIFX to RIFF
### RIFF to RIFX and RIFX to RIFF
```javascript

@@ -186,3 +186,3 @@ // Turn a RIFF file to a RIFX file

## IMA-ADPCM
### IMA-ADPCM
16-bit 8000 Hz mono wave files can be compressed as IMA-ADPCM:

@@ -206,3 +206,3 @@ ```javascript

## A-Law
### A-Law
16-bit wave files (mono or stereo) can be encoded as A-Law:

@@ -224,3 +224,3 @@ ```javascript

## mu-Law
### mu-Law
16-bit wave files (mono or stereo) can be encoded as mu-Law:

@@ -242,3 +242,3 @@ ```javascript

## Change the bit depth
### Change the bit depth
You **can't** change to and from 4-bit ADPCM, 8-bit A-Law and 8-bit mu-Law. To encode/decode files as ADPCM, A-Law and mu-Law you must use the *toIMAADPCM()*, *fromIMAADPCM()*, *toALaw()*, *fromALaw()*, *toMuLaw()* and *fromMuLaw()* methods.

@@ -261,3 +261,3 @@

### Change the declared bit depth without re-scaling the samples
#### Change the declared bit depth without re-scaling the samples
This may be needed when dealing with files whose audio bit depths do not fill a full sequence of bytes (like 12-bit files), as those files may contain samples that outrange their declared bit depth limits and re-scaling their samples may result in clipping.

@@ -398,2 +398,18 @@

#### RF64
**wavefile** have limited support of RF64 files. Changing the bit depth or applying compression to the samples will result in a RIFF file.
```javascript
this.ds64 = {
"chunkId": "",
"chunkSize": 0,
"riffSizeHigh": 0,
"riffSizeLow": 0,
"dataSizeHigh": 0,
"dataSizeLow": 0,
"originationTime": 0,
"sampleCountHigh": 0,
"sampleCountLow": 0
};
```
### The samples

@@ -400,0 +416,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