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 0.5.0 to 0.6.0

104

dist/wavefile-min.js
/*
byte-data
Readable data to and from byte buffers.
Copyright (c) 2017 Rafael da Silva Rocha.
https://github.com/rochars/byte-data
endianness: Swap byte endianness in arrays.

@@ -12,3 +7,3 @@ Copyright (c) 2017 Rafael da Silva Rocha.

wavefile
Read & write wave files with 8, 16, 24, 32 PCM, 32 IEEE & 64-bit data.
Read & write wave files with 8, 16, 24, 32 & 64-bit data.
Copyright (c) 2017 Rafael da Silva Rocha.

@@ -18,6 +13,11 @@ https://github.com/rochars/wavefile

bitdepth
Change the bit depth of audio samples to and from 8, 16, 24, 32, 32 IEEE & 64-bit.
Copyright (c) 2017 Rafael da Silva Rocha. MIT License.
Change the bit depth of samples to and from 8, 16, 24, 32 & 64-bit..
Copyright (c) 2017 Rafael da Silva Rocha.
https://github.com/rochars/bitdepth
byte-data
Readable data to and from byte buffers.
Copyright (c) 2017 Rafael da Silva Rocha.
https://github.com/rochars/byte-data
riff-chunks

@@ -29,38 +29,52 @@ Get the chunks of RIFF and RIFX files.

*/
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 g=function(){};g.prototype=a;return new g};$jscomp.underscoreProtoCanBeSet=function(){var a={a:!0},g={};try{return g.__proto__=a,g.a}catch(k){}return!1};
$jscomp.setPrototypeOf="function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(a,g){a.__proto__=g;if(a.__proto__!==g)throw new TypeError(a+" is not extensible");return a}:null;
$jscomp.inherits=function(a,g){a.prototype=$jscomp.objectCreate(g.prototype);a.prototype.constructor=a;if($jscomp.setPrototypeOf){var k=$jscomp.setPrototypeOf;k(a,g)}else for(k in g)if("prototype"!=k)if(Object.defineProperties){var e=Object.getOwnPropertyDescriptor(g,k);e&&Object.defineProperty(a,k,e)}else a[k]=g[k];a.superClass_=g.prototype};
(function(a){function g(e){if(k[e])return k[e].exports;var l=k[e]={i:e,l:!1,exports:{}};a[e].call(l.exports,l,l.exports,g);l.l=!0;return l.exports}var k={};g.m=a;g.c=k;g.d=function(a,l,h){g.o(a,l)||Object.defineProperty(a,l,{configurable:!1,enumerable:!0,get:h})};g.n=function(a){var l=a&&a.__esModule?function(){return a["default"]}:function(){return a};g.d(l,"a",l);return l};g.o=function(a,l){return Object.prototype.hasOwnProperty.call(a,l)};g.p="";return g(g.s=6)})([function(a,g){function k(a,h){var b=
a.length+1;2==h?b=8:16==h&&(b=2);return e(a,b)}function e(a,h){for(;a.length<h;)a="0"+a;return a}a.exports.fixByteArraySize=function(a,h){var b=0,c=a.length%h;if(c)for(c=-1*(c-h);b<c;)a.push(0),b++};a.exports.padding=function(a,h,b){a[b]=k(a[b],h)};a.exports.paddingNibble=function(a,h,b){2==h&&4>a[b].length&&(a[b]=Array(5-a[b].length).join("0")+a[b])};a.exports.paddingCrumb=function(a,h,b){(2==h||16==h)&&2>a[b].length&&(a[b]="0"+a[b])};a.exports.bytePadding=k;a.exports.lPadZeros=e},function(a,g){function k(a){e[0]=
a;return l[0]}g=new Int8Array(4);var e=new Int32Array(g.buffer,0,1),l=new Float32Array(g.buffer,0,1);a.exports=k;a.exports.pack=k;a.exports.unpack=function(a){l[0]=a;return e[0]}},function(a,g){a.exports.BitDepthOffsets={1:1,2:1,4:1,8:1,16:2,24:3,32:4,40:5,48:6,64:8};a.exports.BitDepthMaxValues={2:4,4:16,8:256,16:65536,24:16777216,32:4294967296,40:1099511627776,48:281474976710656}},function(a,g,k){g=k(9);var e=k(11),l=k(13);k=k(2);a.exports.findString=function(a,b){for(var c,f=0;f<a.length;f++)if(c=
e.fromBytes(a.slice(f,f+b.length),8,{"char":!0}),c==b)return f;return-1};a.exports.toBytes=g.toBytes;a.exports.fromBytes=e.fromBytes;a.exports.packBooleans=l.packBooleans;a.exports.unpackBooleans=l.unpackBooleans;a.exports.packCrumbs=l.packCrumbs;a.exports.unpackCrumbs=l.unpackCrumbs;a.exports.packNibbles=l.packNibbles;a.exports.unpackNibbles=l.unpackNibbles;a.exports.BitDepthOffsets=k.BitDepthOffsets;a.exports.BitDepthMaxValues=k.BitDepthMaxValues},function(a,g){a.exports.endianness=function(a,e){for(var l=
a.length,h=0;h<l;){for(var b,c=a,f=h,d=0,g=e-1,k=parseInt(e/2,10);d<k;)b=c[f+d],c[f+d]=c[f+g],c[f+g]=b,d++,g--;h+=e}return a}},function(a,g,k){function e(b,f){f=void 0===f?!1:f;for(var c="",a=0,h=b.length;a<h;){var e=l.lPadZeros(b[a].toString(2),8);c=f?c+e:e+c;a++}return c}var l=k(0),h=new Float32Array(1),b=new Int32Array(h.buffer);a.exports.getBinary=e;a.exports.decodeFloat16=function(b){b=parseInt(e(b,!0),2);var c=(b&31744)>>10,d=b&1023;return(c?Math.pow(2,c-15)*(1+d/1024):d/1024*.00006103515625)*
(b>>15?-1:1)};a.exports.decodeFloat64=function(b){if("0,0,0,0,0,0,0,0"==b.toString())return 0;b=e(b);for(var c="1"+b.substr(12,52),d=1,a=0,h=0;h<c.length;)a+=d*parseInt(c.charAt(h),10),d/=2,h++;return("1"==b.charAt(0)?-1:1)*a*Math.pow(2,parseInt(b.substr(1,11),2)-1023)};a.exports.toFloat64=function(b){if(0==b)return[0,0];var c=0;0>=b&&(c=2147483648,b=-b);var d=Math.floor(Math.log(b)/Math.log(2)),a=Math.floor(b/Math.pow(2,d)*Math.pow(2,52));b=a&4294967295;a/=Math.pow(2,32);return[c|d+1023<<20|a&1048575,
b]};a.exports.toHalf=function(c){h[0]=c;var a=b[0];c=a>>16&32768;var d=a>>12&2047;a=a>>23&255;return 103>a?c:(c|a-112<<10|d>>1)+(d&1)}},function(a,g,k){var e=k(7),l=k(8);a=function(a,b,c){b=l.WaveFileReaderWriter.call(this,void 0===b?!1:b,void 0===c?!1:c)||this;a&&b.fromBuffer(a);return b};$jscomp.inherits(a,l.WaveFileReaderWriter);a.prototype.fromScratch=function(a,b,c,f,d){d=void 0===d?{}:d;d.container||(d.container="RIFF");var e=parseInt(c,10)/8;this.chunkSize=36+f.length*e;this.fmtChunkSize=16;
this.byteRate=a*e*b;this.blockAlign=a*e;this.chunkId=d.container;this.format="WAVE";this.fmtChunkId="fmt ";this.audioFormat=this.headerFormats_[c];this.numChannels=a;this.sampleRate=b;this.bitsPerSample=parseInt(c,10);this.dataChunkId="data";this.dataChunkSize=f.length*e;this.samples_=f;this.bitDepth_=c};a.prototype.toRIFF=function(){this.chunkId="RIFF"};a.prototype.toRIFX=function(){this.chunkId="RIFX"};a.prototype.toBitDepth=function(a){e.toBitDepth(this.samples_,this.bitDepth_,a);this.fromScratch(this.numChannels,
this.sampleRate,a,this.samples_,{container:this.chunkId})};a.prototype.interleave=function(){var a=[],b,c,f=this.samples_[0].length;for(b=0;b<f;b++)for(c=0;c<this.samples_.length;c++)a.push(this.samples_[c][b]);this.samples_=a};a.prototype.deInterleave=function(){var a=[],b;for(b=0;b<this.numChannels;b++)a[b]=[];b=0;for(var c;b<this.samples_.length;){for(c=0;c<this.numChannels;c++)a[c].push(this.samples_[b+c]);b+=c}this.samples_=a};window.WaveFile=a},function(a,g){var k={8:256,16:65536,24:16777216,
32:4294967296};a.exports.toBitDepth=function(a,l,h){if(l!=h){var b="8 16 24 32 32f 64".split(" ");if(-1==b.indexOf(l)||-1==b.indexOf(h))throw Error("Invalid bit depth.");b=a.length;for(var c=0;c<b;c++){var f=a[c];"8"==l&&(f-=128);if("32f"==h||"64"==h){var d=l,e=parseInt(k[d]/2,10);"32f"!=d&&"64"!=d&&(f=0<f?f/(e-1):f/e)}else{d=f;e=l;f=h;var g=parseInt(k[e]/2,10),n=parseInt(k[f]/2,10);d="32f"==e||"64"==e?0<d?d*(n-1):d*n:0<d?parseInt(d/(g-1)*n-1,10):parseInt(d/g*n,10);"8"==f&&(d+=128);f=d}a[c]=f}}};
a.exports.BitDepthMaxValues=k},function(a,g,k){var e=k(3),l=k(14),h=k(15);g=function(b,c){b=void 0===b?!1:b;c=void 0===c?!1:c;var a=l.WaveFileHeader.call(this)||this;a.enforceFact=b;a.enforceBext=c;a.enforceCue=!1;a.WaveErrors={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",bext:"Could not find the 'bext' chunk","cue ":"Could not find the 'cue ' chunk",
bitDepth:"Invalid bit depth.",numChannels:"Invalid number of channels.",sampleRate:"Invalid sample rate."};a.headerFormats_={4:17,8:1,16:1,24:1,32:1,"32f":3,64:3};a.samples_=[];return a};$jscomp.inherits(g,l.WaveFileHeader);g.prototype.fromBuffer=function(b){this.readRIFFChunk_(b);var a="RIFX"==this.chunkId;b=h.getChunks(b,a);a={be:a};this.readFmtChunk_(b.subChunks,a);this.readFactChunk_(b.subChunks,a);this.readBextChunk_(b.subChunks,a);this.readCueChunk_(b.subChunks,a);this.readDataChunk_(b.subChunks,
a)};g.prototype.toBuffer=function(){this.checkWriteInput_();return new Uint8Array(this.createWaveFile_())};g.prototype.readRIFFChunk_=function(b){this.chunkId=e.fromBytes(b.slice(0,4),8,{"char":!0});if("RIFF"!=this.chunkId&&"RIFX"!=this.chunkId)throw Error(this.WaveErrors.format);this.chunkSize=e.fromBytes(b.slice(4,8),32,{be:"RIFX"==this.chunkId})[0];this.format=e.fromBytes(b.slice(8,12),8,{"char":!0});if("WAVE"!=this.format)throw Error(this.WaveErrors.wave);};g.prototype.readFmtChunk_=function(b,
a){if(b=this.findChunk(b,"fmt "))this.fmtChunkId="fmt ",this.fmtChunkSize=b.subChunkSize,this.audioFormat=e.fromBytes(b.subChunkData.slice(0,2),16,a)[0],this.numChannels=e.fromBytes(b.subChunkData.slice(2,4),16,a)[0],this.sampleRate=e.fromBytes(b.subChunkData.slice(4,8),32,a)[0],this.byteRate=e.fromBytes(b.subChunkData.slice(8,12),32,a)[0],this.blockAlign=e.fromBytes(b.subChunkData.slice(12,14),16,a)[0],this.bitsPerSample=e.fromBytes(b.subChunkData.slice(14,16),16,a)[0],this.bitDepth_=3==this.audioFormat&&
32==this.bitsPerSample?"32f":this.bitsPerSample.toString(),16<this.fmtChunkSize&&(this.cbSize=e.fromBytes(b.subChunkData.slice(16,18),16)[0],18<this.fmtChunkSize&&(this.validBitsPerSample=e.fromBytes(b.subChunkData.slice(18,20),16)[0]));else throw Error(this.WaveErrors["fmt "]);};g.prototype.readFactChunk_=function(b,a){if(b=this.findChunk(b,"fact"))this.factChunkId="fact",this.factChunkSize=b.subChunkSize,this.dwSampleLength=e.fromBytes(b.subChunkData.slice(0,4),32,a)[0];else if(this.enforceFact)throw Error(this.WaveErrors.fact);
};g.prototype.readBextChunk_=function(b,a){if(b=this.findChunk(b,"bext"))this.bextChunkId="bext",this.bextChunkSize=b.subChunkSize,this.bextChunkData=e.fromBytes(b.subChunkData,8);else if(this.enforceBext)throw Error(this.WaveErrors.bext);};g.prototype.readCueChunk_=function(b,a){if(b=this.findChunk(b,"cue "))this.cueChunkId="cue ",this.cueChunkSize=b.subChunkSize,this.cueChunkData=e.fromBytes(b.subChunkData,8);else if(this.enforceCue)throw Error(this.WaveErrors["cue "]);};g.prototype.readDataChunk_=
function(b,a){if(b=this.findChunk(b,"data"))this.dataChunkId="data",this.dataChunkSize=b.subChunkSize,this.samplesFromBytes_(b.subChunkData,a);else throw Error(this.WaveErrors.data);};g.prototype.samplesFromBytes_=function(b,a){a.signed=8==this.bitsPerSample?!1:!0;32==this.bitsPerSample&&3==this.audioFormat&&(a.float=!0);this.samples_=4==this.bitsPerSample?e.fromBytes(b,8,a):e.fromBytes(b,this.bitsPerSample,a)};g.prototype.findChunk=function(b,a){for(var c=0;c<b.length;c++)if(b[c].subChunkId==a)return b[c];
return null};g.prototype.checkWriteInput_=function(){this.validateBitDepth_();this.validateNumChannels_();this.validateSampleRate_()};g.prototype.validateBitDepth_=function(){if(!this.headerFormats_[this.bitDepth_])throw Error(this.WaveErrors.bitDepth);return!0};g.prototype.validateNumChannels_=function(){var b=this.numChannels*this.bitsPerSample/8;if(1>this.numChannels||65535<b)throw Error(this.WaveErrors.numChannels);return!0};g.prototype.validateSampleRate_=function(){var b=this.bitsPerSample/
8*this.numChannels*this.sampleRate;if(1>this.sampleRate||4294967295<b)throw Error(this.WaveErrors.sampleRate);return!0};g.prototype.samplesToBytes_=function(b){32==this.bitsPerSample&&3==this.audioFormat&&(b.float=!0);b=e.toBytes(this.samples_,4==this.bitsPerSample?8:this.bitsPerSample,b);b.length%2&&b.push(0);return b};g.prototype.getBextBytes=function(b){var a=[];this.bextChunkId&&(a=a.concat(e.toBytes(this.bextChunkId,8,{"char":!0}),e.toBytes([this.bextChunkSize],32,b),e.toBytes(this.bextChunkData,
8)));return a};g.prototype.getCueBytes=function(b){var a=[];this.cueChunkId&&(a=a.concat(e.toBytes(this.cueChunkId,8,{"char":!0}),e.toBytes([this.cueChunkSize],32,b),e.toBytes(this.cueChunkData,8)));return a};g.prototype.getFactBytes=function(b){var a=[];this.factChunkId&&(a=a.concat(e.toBytes(this.factChunkId,8,{"char":!0}),e.toBytes([this.factChunkSize],32,b),e.toBytes([this.dwSampleLength],32,b)));return a};g.prototype.createWaveFile_=function(){var b={be:"RIFX"==this.chunkId},a=[],f=[];16<this.fmtChunkSize&&
(a=e.toBytes([this.cbSize],16,b),18<this.fmtChunkSize&&(f=e.toBytes([this.validBitsPerSample],16,b)));return e.toBytes(this.chunkId,8,{"char":!0}).concat(e.toBytes([this.chunkSize],32,b),e.toBytes(this.format,8,{"char":!0}),this.getBextBytes(b),e.toBytes(this.fmtChunkId,8,{"char":!0}),e.toBytes([this.fmtChunkSize],32,b),e.toBytes([this.audioFormat],16,b),e.toBytes([this.numChannels],16,b),e.toBytes([this.sampleRate],32,b),e.toBytes([this.byteRate],32,b),e.toBytes([this.blockAlign],16,b),e.toBytes([this.bitsPerSample],
16,b),a,f,this.getFactBytes(b),e.toBytes(this.dataChunkId,8,{"char":!0}),e.toBytes([this.dataChunkSize],32,b),this.samplesToBytes_(b),this.getCueBytes(b))};a.exports.WaveFileReaderWriter=g},function(a,g,k){function e(b,a,c){4==a?l(b,c,h.paddingNibble):2==a?l(b,c,h.paddingCrumb):1==a?l(b,c,function(){}):l(b,c)}function l(b,a,c){c=void 0===c?h.padding:c;if(10!=a)for(var d=0,f=b.length;d<f;)b[d]=b[d].toString(a),c(b,a,d),d++}k(1);var h=k(0),b=k(4),c=k(10),f=k(2);a.exports.toBytes=function(a,l,h){h=void 0===
h?{}:h;var d=10;"base"in h&&(d=h.base);var g=h.char?c.writeString:c["write"+l+"Bit"+(h.float?"Float":"")];for(var k=0,m=0,q=a.length,p=[];k<q;)m=g(p,a,k,m),k++;a=p;h.be&&b.endianness(a,f.BitDepthOffsets[l]);e(a,l,d);h.buffer&&(a=new Uint8Array(a));return a}},function(a,g,k){function e(b,a,f,d){b[d++]=a[f]&255;b[d++]=a[f]>>>8&255;b[d++]=a[f]>>>16&255;b[d++]=a[f]>>>24&255;return d}var l=k(5),h=k(1);a.exports.write64Bit=function(b,a,f,d){a=l.toFloat64(a[f]);d=e(b,a,1,d);return e(b,a,0,d)};a.exports.write48Bit=
function(b,a,f,d){b[d++]=a[f]&255;b[d++]=a[f]>>8&255;b[d++]=a[f]>>16&255;b[d++]=a[f]>>24&255;b[d++]=a[f]/4294967296&255;b[d++]=a[f]/1099511627776&255;return d};a.exports.write40Bit=function(b,a,f,d){b[d++]=a[f]&255;b[d++]=a[f]>>8&255;b[d++]=a[f]>>16&255;b[d++]=a[f]>>24&255;b[d++]=a[f]/4294967296&255;return d};a.exports.write32BitFloat=function(a,c,f,d){c=h.unpack(c[f]);a[d++]=c&255;a[d++]=c>>>8&255;a[d++]=c>>>16&255;a[d++]=c>>>24&255;return d};a.exports.write32Bit=e;a.exports.write24Bit=function(a,
c,f,d){a[d++]=c[f]&255;a[d++]=c[f]>>>8&255;a[d++]=c[f]>>>16&255;return d};a.exports.write16Bit=function(a,c,f,d){a[d++]=c[f]&255;a[d++]=c[f]>>>8&255;return d};a.exports.write16BitFloat=function(a,c,f,d){c=l.toHalf(c[f]);a[d++]=c>>>8&255;a[d++]=c&255;return d};a.exports.write8Bit=function(a,c,f,d){a[d++]=c[f]&255;return d};a.exports.write4Bit=function(a,c,f,d){a[d++]=c[f]&15;return d};a.exports.write2Bit=function(a,c,f,d){a[d++]=0>c[f]?c[f]+4:c[f];return d};a.exports.write1Bit=function(a,c,f,d){a[d++]=
c[f]?1:0;return d};a.exports.writeString=function(a,c,f,d){a[d++]=c.charCodeAt(f);return d}},function(a,g,k){function e(a,b,e,h){var d=[],f=0,g=0,k=c.BitDepthOffsets[b],m=a.length-(k-1);b=c.BitDepthMaxValues[b];for(e=e?l:function(a,b){return a};f<m;)d[g]=e(h(a,f),b),f+=k,g++;return d}function l(a,b){a>parseInt(b/2,10)-1&&(a-=b);return a}var h=k(4),b=k(12),c=k(2);a.exports.fromBytes=function(a,d,c){c=void 0===c?{}:c;var f=10;"base"in c&&(f=c.base);c.be&&h.endianness(a,d/8);if(10!=f)for(var l=0,g=a.length;l<
g;)a[l]=parseInt(a[l],f),l++;a=e(a,d,c.signed,c.char?b.readChar:b["read"+(2==d||4==d?8:d)+"Bit"+(c.float?"Float":"")]);c.char&&(a=a.join(""));return a}},function(a,g,k){function e(a,b,c){--c;for(var d="";0<=c;)d+=h.bytePadding(a[c+b].toString(2),2),c--;return parseInt(d,2)}function l(a,b){return(a[3+b]<<24|a[2+b]<<16|a[1+b]<<8|a[b])>>>0}var h=k(0),b=k(5),c=k(1);a.exports.readChar=function(a,b){return String.fromCharCode(a[b])};a.exports.read1Bit=function(a,b){return parseInt(a[b],2)};a.exports.read8Bit=
function(a,b){return a[b]};a.exports.read16Bit=function(a,b){return a[1+b]<<8|a[b]};a.exports.read16BitFloat=function(a,d){return b.decodeFloat16(a.slice(d,d+2))};a.exports.read24Bit=function(a,b){return a[2+b]<<16|a[1+b]<<8|a[b]};a.exports.read32Bit=l;a.exports.read32BitFloat=function(a,b){return c.pack(l(a,b))};a.exports.read40Bit=function(a,b){return e(a,b,5)};a.exports.read48Bit=function(a,b){return e(a,b,6)};a.exports.read64Bit=function(a,c){return b.decodeFloat64(a.slice(c,c+8))}},function(a,
g,k){var e=k(0);a.exports.packBooleans=function(a){var h=[],b=0,c=0;e.fixByteArraySize(a,8);for(var f=a.length-7;b<f;)h[c++]=parseInt(a[b].toString(2)+a[b+1].toString(2)+a[b+2].toString(2)+a[b+3].toString(2)+a[b+4].toString(2)+a[b+5].toString(2)+a[b+6].toString(2)+a[b+7].toString(2),2),b+=8;return h};a.exports.unpackBooleans=function(a){for(var h=[],b=0,c=0,f=a.length,d;b<f;)d=e.lPadZeros(a[b].toString(2),8),h[c++]=parseInt(d[0],2),h[c++]=parseInt(d[1],2),h[c++]=parseInt(d[2],2),h[c++]=parseInt(d[3],
2),h[c++]=parseInt(d[4],2),h[c++]=parseInt(d[5],2),h[c++]=parseInt(d[6],2),h[c++]=parseInt(d[7],2),b++;return h};a.exports.packCrumbs=function(a){var h=[],b=0,c=0;e.fixByteArraySize(a,4);for(var f=a.length-3;b<f;)h[c++]=parseInt(e.lPadZeros(a[b].toString(2),2)+e.lPadZeros(a[b+1].toString(2),2)+e.lPadZeros(a[b+2].toString(2),2)+e.lPadZeros(a[b+3].toString(2),2),2),b+=4;return h};a.exports.unpackCrumbs=function(a){var h=[],b=0,c=0,f=a.length;for(console.log(f);b<f;){var d=e.lPadZeros(a[b].toString(2),
8);h[c++]=parseInt(d[0]+d[1],2);h[c++]=parseInt(d[2]+d[3],2);h[c++]=parseInt(d[4]+d[5],2);h[c++]=parseInt(d[6]+d[7],2);b++}return h};a.exports.packNibbles=function(a){var e=[],b=0,c=0,f=a.length;for(f%2&&a.push(0);b<f;)e[c++]=parseInt(a[b].toString(16)+a[b+1].toString(16),16),b+=2;return e};a.exports.unpackNibbles=function(a){for(var e=[],b=0,c=0,f=a.length;b<f;)e[c++]=parseInt(a[b].toString(16)[0],16),e[c++]=parseInt(a[b].toString(16)[1],16),b++;return e}},function(a,g){a.exports.WaveFileHeader=
function(){this.chunkId="";this.chunkSize=0;this.fmtChunkId=this.format="";this.validBitsPerSample=this.cbSize=this.bitsPerSample=this.blockAlign=this.byteRate=this.sampleRate=this.numChannels=this.audioFormat=this.fmtChunkSize=0;this.factChunkId="";this.factChunkSize=0;this.factChunkData=[];this.dwSampleLength=0;this.cueChunkId="";this.cueChunkSize=-1;this.cueChunkData=[];this.dataChunkId="";this.dataChunkSize=0;this.bextChunkId="";this.bextChunkSize=0;this.bextChunkData=[]}},function(a,g,k){function e(a,
b){for(var c=[],f=a.length,d=12,h,g;d<f;)g=l.fromBytes(a.slice(d,d+4),8,{"char":!0}),h=l.fromBytes(a.slice(d+4,d+8),32,{be:b})[0],"LIST"==g?c.push({subChunkId:g,subChunkSize:h,subChunks:e(a.slice(d,d+h),b)}):c.push({subChunkId:g,subChunkSize:h,subChunkData:a.slice(d+8,d+8+h)}),d=d+8+h;return c}var l=k(3);a.exports.getChunks=function(a,b){b=void 0===b?!1:b;return{chunkId:l.fromBytes(a.slice(0,4),8,{"char":!0}),chunkSize:l.fromBytes(a.slice(4,8),32,{be:b})[0],format:l.fromBytes(a.slice(8,12),8,{"char":!0}),
subChunks:e(a,b)}}}]);
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 l=function(){};l.prototype=a;return new l};$jscomp.underscoreProtoCanBeSet=function(){var a={a:!0},l={};try{return l.__proto__=a,l.a}catch(h){}return!1};
$jscomp.setPrototypeOf="function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(a,l){a.__proto__=l;if(a.__proto__!==l)throw new TypeError(a+" is not extensible");return a}:null;
$jscomp.inherits=function(a,l){a.prototype=$jscomp.objectCreate(l.prototype);a.prototype.constructor=a;if($jscomp.setPrototypeOf){var h=$jscomp.setPrototypeOf;h(a,l)}else for(h in l)if("prototype"!=h)if(Object.defineProperties){var g=Object.getOwnPropertyDescriptor(l,h);g&&Object.defineProperty(a,h,g)}else a[h]=l[h];a.superClass_=l.prototype};
(function(a){function l(g){if(h[g])return h[g].exports;var k=h[g]={i:g,l:!1,exports:{}};a[g].call(k.exports,k,k.exports,l);k.l=!0;return k.exports}var h={};l.m=a;l.c=h;l.d=function(a,k,f){l.o(a,k)||Object.defineProperty(a,k,{configurable:!1,enumerable:!0,get:f})};l.n=function(a){var k=a&&a.__esModule?function(){return a["default"]}:function(){return a};l.d(k,"a",k);return k};l.o=function(a,k){return Object.prototype.hasOwnProperty.call(a,k)};l.p="";return l(l.s=8)})([function(a,l){function h(a){g[0]=
a;return k[0]}l=new Int8Array(4);var g=new Int32Array(l.buffer,0,1),k=new Float32Array(l.buffer,0,1);a.exports=h;a.exports.pack=h;a.exports.unpack=function(a){k[0]=a;return g[0]}},function(a,l){function h(a,f){var b=a.length+1;2==f?b=8:16==f&&(b=2);return g(a,b)}function g(a,f){for(;a.length<f;)a="0"+a;return a}a.exports.fixByteArraySize=function(a,f){var b=0,c=a.length%f;if(c)for(c=-1*(c-f);b<c;)a.push(0),b++};a.exports.padding=function(a,f,b){a[b]=h(a[b],f)};a.exports.paddingNibble=function(a,f,
b){2==f&&4>a[b].length&&(a[b]=Array(5-a[b].length).join("0")+a[b])};a.exports.paddingCrumb=function(a,f,b){(2==f||16==f)&&2>a[b].length&&(a[b]="0"+a[b])};a.exports.bytePadding=h;a.exports.lPadZeros=g},function(a,l){a.exports.endianness=function(a,g){for(var k=a.length,f=0;f<k;){for(var b,c=a,e=f,d=0,m=g-1,h=parseInt(g/2,10);d<h;)b=c[e+d],c[e+d]=c[e+m],c[e+m]=b,d++,m--;f+=g}return a}},function(a,l){function h(a,f){var b=a.length+1;2==f?b=8:16==f&&(b=2);return g(a,b)}function g(a,f){for(;a.length<f;)a=
"0"+a;return a}a.exports.fixByteArraySize=function(a,f){var b=0,c=a.length%f;if(c)for(c=-1*(c-f);b<c;)a.push(0),b++};a.exports.padding=function(a,f,b){a[b]=h(a[b],f)};a.exports.paddingNibble=function(a,f,b){2==f&&4>a[b].length&&(a[b]=Array(5-a[b].length).join("0")+a[b])};a.exports.paddingCrumb=function(a,f,b){(2==f||16==f)&&2>a[b].length&&(a[b]="0"+a[b])};a.exports.bytePadding=h;a.exports.lPadZeros=g},function(a,l){a.exports.BitDepthOffsets={1:1,2:1,4:1,8:1,16:2,24:3,32:4,40:5,48:6,64:8};a.exports.BitDepthMaxValues=
{2:4,4:16,8:256,16:65536,24:16777216,32:4294967296,40:1099511627776,48:281474976710656}},function(a,l){a.exports.BitDepthOffsets={1:1,2:1,4:1,8:1,16:2,24:3,32:4,40:5,48:6,64:8};a.exports.BitDepthMaxValues={2:4,4:16,8:256,16:65536,24:16777216,32:4294967296,40:1099511627776,48:281474976710656}},function(a,l,h){function g(b,e){e=void 0===e?!1:e;for(var d="",c=0,a=b.length;c<a;){var f=k.lPadZeros(b[c].toString(2),8);d=e?d+f:f+d;c++}return d}var k=h(1),f=new Float32Array(1),b=new Int32Array(f.buffer);
a.exports.getBinary=g;a.exports.decodeFloat16=function(b){b=parseInt(g(b,!0),2);var c=(b&31744)>>10,d=b&1023;return(c?Math.pow(2,c-15)*(1+d/1024):d/1024*.00006103515625)*(b>>15?-1:1)};a.exports.decodeFloat64=function(b){if("0,0,0,0,0,0,0,0"==b.toString())return 0;b=g(b);for(var c="1"+b.substr(12,52),d=1,a=0,f=0;f<c.length;)a+=d*parseInt(c.charAt(f),10),d/=2,f++;return("1"==b.charAt(0)?-1:1)*a*Math.pow(2,parseInt(b.substr(1,11),2)-1023)};a.exports.toFloat64=function(b){if(0==b)return[0,0];var c=0;
0>=b&&(c=2147483648,b=-b);var d=Math.floor(Math.log(b)/Math.log(2)),a=Math.floor(b/Math.pow(2,d)*Math.pow(2,52));b=a&4294967295;a/=Math.pow(2,32);return[c|d+1023<<20|a&1048575,b]};a.exports.toHalf=function(c){f[0]=c;var e=b[0];c=e>>16&32768;var d=e>>12&2047;e=e>>23&255;return 103>e?c:(c|e-112<<10|d>>1)+(d&1)}},function(a,l,h){function g(b,e){e=void 0===e?!1:e;for(var d="",c=0,a=b.length;c<a;){var f=k.lPadZeros(b[c].toString(2),8);d=e?d+f:f+d;c++}return d}var k=h(3),f=new Float32Array(1),b=new Int32Array(f.buffer);
a.exports.getBinary=g;a.exports.decodeFloat16=function(b){b=parseInt(g(b,!0),2);var c=(b&31744)>>10,d=b&1023;return(c?Math.pow(2,c-15)*(1+d/1024):d/1024*.00006103515625)*(b>>15?-1:1)};a.exports.decodeFloat64=function(b){if("0,0,0,0,0,0,0,0"==b.toString())return 0;b=g(b);for(var c="1"+b.substr(12,52),d=1,a=0,f=0;f<c.length;)a+=d*parseInt(c.charAt(f),10),d/=2,f++;return("1"==b.charAt(0)?-1:1)*a*Math.pow(2,parseInt(b.substr(1,11),2)-1023)};a.exports.toFloat64=function(b){if(0==b)return[0,0];var c=0;
0>=b&&(c=2147483648,b=-b);var d=Math.floor(Math.log(b)/Math.log(2)),a=Math.floor(b/Math.pow(2,d)*Math.pow(2,52));b=a&4294967295;a/=Math.pow(2,32);return[c|d+1023<<20|a&1048575,b]};a.exports.toHalf=function(c){f[0]=c;var e=b[0];c=e>>16&32768;var d=e>>12&2047;e=e>>23&255;return 103>e?c:(c|e-112<<10|d>>1)+(d&1)}},function(a,l,h){var g=h(9),k=h(10);a=function(a){var b=k.WaveFileReaderWriter.call(this)||this;a&&b.fromBuffer(a);return b};$jscomp.inherits(a,k.WaveFileReaderWriter);a.prototype.fromScratch=
function(a,b,c,e,d){d=void 0===d?{}:d;d.container||(d.container="RIFF");var f=parseInt(c,10)/8;this.chunkSize=36+e.length*f;this.fmtChunkSize=16;this.byteRate=a*f*b;this.blockAlign=a*f;this.chunkId=d.container;this.format="WAVE";this.fmtChunkId="fmt ";this.audioFormat=this.headerFormats_[c];this.numChannels=a;this.sampleRate=b;this.bitsPerSample=parseInt(c,10);this.dataChunkId="data";this.dataChunkSize=e.length*f;this.samples_=e;this.bitDepth_=c};a.prototype.toRIFF=function(){this.chunkId="RIFF"};
a.prototype.toRIFX=function(){this.chunkId="RIFX"};a.prototype.toBitDepth=function(a){g.toBitDepth(this.samples_,this.bitDepth_,a);this.fromScratch(this.numChannels,this.sampleRate,a,this.samples_,{container:this.chunkId})};a.prototype.interleave=function(){var a=[],b,c,e=this.samples_[0].length;for(b=0;b<e;b++)for(c=0;c<this.samples_.length;c++)a.push(this.samples_[c][b]);this.samples_=a};a.prototype.deInterleave=function(){var a=[],b;for(b=0;b<this.numChannels;b++)a[b]=[];b=0;for(var c;b<this.samples_.length;){for(c=
0;c<this.numChannels;c++)a[c].push(this.samples_[b+c]);b+=c}this.samples_=a};window.WaveFile=a},function(a,l){var h={8:256,16:65536,24:16777216,32:4294967296};a.exports.toBitDepth=function(a,k,f){var b="8 16 24 32 32f 64".split(" ");if(-1==b.indexOf(k)||-1==b.indexOf(f))throw Error("Invalid bit depth.");b=a.length;for(var c=0;c<b;c++){var e=a[c];"8"==k&&(e-=128);if("32f"==f||"64"==f){var d=k,g=parseInt(h[d]/2,10);"32f"!=d&&"64"!=d&&(e=0<e?e/(g-1):e/g)}else{g=e;var l=k;e=f;d=parseInt(h[e]/2,10);"32f"==
l||"64"==l?g=0<g?g*(d-1):g*d:(l=parseInt(h[l]/2,10),g=0<g?parseInt(g/(l-1)*d-1,10):parseInt(g/l*d,10));d=g=d=g;"8"==e&&(d+=128);e=d}a[c]=e}};a.exports.BitDepthMaxValues=h},function(a,l,h){var g=h(11),k=h(17),f=h(18);l=function(){var b=k.WaveFileHeader.call(this)||this;b.enforceFact_=!1;b.WaveErrors={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."};b.headerFormats_={4:17,8:1,16:1,24:1,32:1,"32f":3,64:3};b.samples_=[];return b};$jscomp.inherits(l,k.WaveFileHeader);l.prototype.fromBuffer=function(b){this.readRIFFChunk_(b);var c="RIFX"==this.chunkId;b=f.getChunks(b,c);c={be:c,single:!0};this.readFmtChunk_(b.subChunks,c);this.readFactChunk_(b.subChunks,c);this.readBextChunk_(b.subChunks,c);this.readCueChunk_(b.subChunks,c);this.readDataChunk_(b.subChunks,
c);this.bitDepth_=3==this.audioFormat&&32==this.bitsPerSample?"32f":this.bitsPerSample.toString()};l.prototype.toBuffer=function(){this.checkWriteInput_();return new Uint8Array(this.createWaveFile_())};l.prototype.readRIFFChunk_=function(b){this.chunkId=g.fromBytes(b.slice(0,4),8,{"char":!0});if("RIFF"!=this.chunkId&&"RIFX"!=this.chunkId)throw Error(this.WaveErrors.format);this.chunkSize=g.fromBytes(b.slice(4,8),32,{be:"RIFX"==this.chunkId,single:!0});this.format=g.fromBytes(b.slice(8,12),8,g.str);
if("WAVE"!=this.format)throw Error(this.WaveErrors.wave);};l.prototype.readFmtChunk_=function(b,c){if(b=this.findChunk(b,"fmt "))this.fmtChunkId="fmt ",this.fmtChunkSize=b.subChunkSize,this.audioFormat=g.fromBytes(b.subChunkData.slice(0,2),16,c),this.numChannels=g.fromBytes(b.subChunkData.slice(2,4),16,c),this.sampleRate=g.fromBytes(b.subChunkData.slice(4,8),32,c),this.byteRate=g.fromBytes(b.subChunkData.slice(8,12),32,c),this.blockAlign=g.fromBytes(b.subChunkData.slice(12,14),16,c),this.bitsPerSample=
g.fromBytes(b.subChunkData.slice(14,16),16,c),16<this.fmtChunkSize&&(this.cbSize=g.fromBytes(b.subChunkData.slice(16,18),16),18<this.fmtChunkSize&&(this.validBitsPerSample=g.fromBytes(b.subChunkData.slice(18,20),16)));else throw Error(this.WaveErrors["fmt "]);};l.prototype.readFactChunk_=function(b,c){if(b=this.findChunk(b,"fact"))this.factChunkId="fact",this.factChunkSize=b.subChunkSize,this.dwSampleLength=g.fromBytes(b.subChunkData.slice(0,4),32,c);else if(this.enforceFact)throw Error(this.WaveErrors.fact);
};l.prototype.readBextChunk_=function(b,c){if(b=this.findChunk(b,"bext"))this.bextChunkId="bext",this.bextChunkSize=b.subChunkSize,this.bextChunkData=g.fromBytes(b.subChunkData,8)};l.prototype.readCueChunk_=function(b,c){if(b=this.findChunk(b,"cue "))this.cueChunkId="cue ",this.cueChunkSize=b.subChunkSize,this.cueChunkData=g.fromBytes(b.subChunkData,8)};l.prototype.readDataChunk_=function(b,c){if(b=this.findChunk(b,"data"))this.dataChunkId="data",this.dataChunkSize=b.subChunkSize,this.samplesFromBytes_(b.subChunkData,
c);else throw Error(this.WaveErrors.data);};l.prototype.samplesFromBytes_=function(b,c){c.signed=8==this.bitsPerSample?!1:!0;32==this.bitsPerSample&&3==this.audioFormat&&(c.float=!0);c.single=!1;this.samples_=4==this.bitsPerSample?g.fromBytes(b,8,c):g.fromBytes(b,this.bitsPerSample,c)};l.prototype.findChunk=function(b,c){for(var a=0;a<b.length;a++)if(b[a].subChunkId==c)return b[a];return null};l.prototype.checkWriteInput_=function(){this.validateBitDepth_();this.validateNumChannels_();this.validateSampleRate_()};
l.prototype.validateBitDepth_=function(){if(!this.headerFormats_[this.bitDepth_])throw Error(this.WaveErrors.bitDepth);return!0};l.prototype.validateNumChannels_=function(){var b=this.numChannels*this.bitsPerSample/8;if(1>this.numChannels||65535<b)throw Error(this.WaveErrors.numChannels);return!0};l.prototype.validateSampleRate_=function(){var b=this.bitsPerSample/8*this.numChannels*this.sampleRate;if(1>this.sampleRate||4294967295<b)throw Error(this.WaveErrors.sampleRate);return!0};l.prototype.samplesToBytes_=
function(b){32==this.bitsPerSample&&3==this.audioFormat&&(b.float=!0);b=g.toBytes(this.samples_,4==this.bitsPerSample?8:this.bitsPerSample,b);b.length%2&&b.push(0);return b};l.prototype.getBextBytes=function(b){var c=[];this.bextChunkId&&(c=c.concat(g.toBytes(this.bextChunkId,8,{"char":!0}),g.toBytes(this.bextChunkSize,32,b),g.toBytes(this.bextChunkData,8)));return c};l.prototype.getCueBytes=function(b){var c=[];this.cueChunkId&&(c=c.concat(g.toBytes(this.cueChunkId,8,{"char":!0}),g.toBytes(this.cueChunkSize,
32,b),g.toBytes(this.cueChunkData,8)));return c};l.prototype.getFactBytes=function(b){var c=[];this.factChunkId&&(c=c.concat(g.toBytes(this.factChunkId,8,{"char":!0}),g.toBytes(this.factChunkSize,32,b),g.toBytes(this.dwSampleLength,32,b)));return c};l.prototype.createWaveFile_=function(){var b={be:"RIFX"==this.chunkId},c=[],a=[];16<this.fmtChunkSize&&(c=g.toBytes(this.cbSize,16,b),18<this.fmtChunkSize&&(a=g.toBytes(this.validBitsPerSample,16,b)));return g.toBytes(this.chunkId,8,{"char":!0}).concat(g.toBytes(this.chunkSize,
32,b),g.toBytes(this.format,8,{"char":!0}),this.getBextBytes(b),g.toBytes(this.fmtChunkId,8,{"char":!0}),g.toBytes(this.fmtChunkSize,32,b),g.toBytes(this.audioFormat,16,b),g.toBytes(this.numChannels,16,b),g.toBytes(this.sampleRate,32,b),g.toBytes(this.byteRate,32,b),g.toBytes(this.blockAlign,16,b),g.toBytes(this.bitsPerSample,16,b),c,a,this.getFactBytes(b),g.toBytes(this.dataChunkId,8,{"char":!0}),g.toBytes(this.dataChunkSize,32,b),this.samplesToBytes_(b),this.getCueBytes(b))};a.exports.WaveFileReaderWriter=
l},function(a,l,h){l=h(12);var g=h(14),k=h(16);h=h(4);a.exports.findString=function(a,b){for(var c,e=0;e<a.length;e++)if(c=g.fromBytes(a.slice(e,e+b.length),8,{"char":!0}),c==b)return e;return-1};a.exports.toBytes=l.toBytes;a.exports.fromBytes=g.fromBytes;a.exports.packBooleans=k.packBooleans;a.exports.unpackBooleans=k.unpackBooleans;a.exports.packCrumbs=k.packCrumbs;a.exports.unpackCrumbs=k.unpackCrumbs;a.exports.packNibbles=k.packNibbles;a.exports.unpackNibbles=k.unpackNibbles;a.exports.BitDepthOffsets=
h.BitDepthOffsets;a.exports.BitDepthMaxValues=h.BitDepthMaxValues;a.exports.floatLE={"float":!0,single:!0};a.exports.intLE={signed:!0,single:!0};a.exports.uIntLE={single:!0};a.exports.floatBE={"float":!0,single:!0,be:!0};a.exports.intBE={signed:!0,single:!0,be:!0};a.exports.uIntBE={single:!0,be:!0};a.exports.char={"char":!0,single:!0};a.exports.floatArrayLE={"float":!0};a.exports.intArrayLE={signed:!0};a.exports.uIntArrayLE={};a.exports.floatArrayBE={"float":!0,be:!0};a.exports.intArrayBE={signed:!0,
be:!0};a.exports.uIntArrayBE={be:!0};a.exports.str={"char":!0}},function(a,l,h){function g(b,a,c){4==a?k(b,c,f.paddingNibble):2==a?k(b,c,f.paddingCrumb):1==a?k(b,c,function(){}):k(b,c)}function k(b,a,c){c=void 0===c?f.padding:c;if(10!=a)for(var d=0,e=b.length;d<e;)b[d]=b[d].toString(a),c(b,a,d),d++}h(0);var f=h(1),b=h(2),c=h(13),e=h(4);a.exports.toBytes=function(d,a,f){f=void 0===f?{}:f;if(!f.char&&"string"!=typeof d){var k=d;Array.isArray(k)||(k=[k]);d=k}k=10;"base"in f&&(k=f.base);var h=f.char?
c.writeString:c["write"+a+"Bit"+(f.float?"Float":"")];for(var l=0,m=0,p=d.length,n=[];l<p;)m=h(n,d,l,m),l++;d=n;f.be&&b.endianness(d,e.BitDepthOffsets[a]);g(d,a,k);f.buffer&&(d=new Uint8Array(d));return d}},function(a,l,h){function g(b,a,e,d){b[d++]=a[e]&255;b[d++]=a[e]>>>8&255;b[d++]=a[e]>>>16&255;b[d++]=a[e]>>>24&255;return d}var k=h(6),f=h(0);a.exports.write64Bit=function(b,a,e,d){a=k.toFloat64(a[e]);d=g(b,a,1,d);return g(b,a,0,d)};a.exports.write48Bit=function(b,a,e,d){b[d++]=a[e]&255;b[d++]=
a[e]>>8&255;b[d++]=a[e]>>16&255;b[d++]=a[e]>>24&255;b[d++]=a[e]/4294967296&255;b[d++]=a[e]/1099511627776&255;return d};a.exports.write40Bit=function(b,a,e,d){b[d++]=a[e]&255;b[d++]=a[e]>>8&255;b[d++]=a[e]>>16&255;b[d++]=a[e]>>24&255;b[d++]=a[e]/4294967296&255;return d};a.exports.write32BitFloat=function(b,a,e,d){a=f.unpack(a[e]);b[d++]=a&255;b[d++]=a>>>8&255;b[d++]=a>>>16&255;b[d++]=a>>>24&255;return d};a.exports.write32Bit=g;a.exports.write24Bit=function(b,a,e,d){b[d++]=a[e]&255;b[d++]=a[e]>>>8&
255;b[d++]=a[e]>>>16&255;return d};a.exports.write16Bit=function(b,a,e,d){b[d++]=a[e]&255;b[d++]=a[e]>>>8&255;return d};a.exports.write16BitFloat=function(b,a,e,d){a=k.toHalf(a[e]);b[d++]=a>>>8&255;b[d++]=a&255;return d};a.exports.write8Bit=function(b,a,e,d){b[d++]=a[e]&255;return d};a.exports.write4Bit=function(b,a,e,d){b[d++]=a[e]&15;return d};a.exports.write2Bit=function(b,a,e,d){b[d++]=0>a[e]?a[e]+4:a[e];return d};a.exports.write1Bit=function(b,a,e,d){b[d++]=a[e]?1:0;return d};a.exports.writeString=
function(b,a,e,d){b[d++]=a.charCodeAt(e);return d}},function(a,l,h){function g(b,a,f,g){var d=[],e=0,h=0,l=c.BitDepthOffsets[a],m=b.length-(l-1);a=c.BitDepthMaxValues[a];for(f=f?k:function(b,a){return b};e<m;)d[h]=f(g(b,e),a),e+=l,h++;return d}function k(b,a){b>parseInt(a/2,10)-1&&(b-=a);return b}var f=h(2),b=h(15),c=h(4);a.exports.fromBytes=function(a,d,c){c=void 0===c?{}:c;var e=10;"base"in c&&(e=c.base);c.be&&f.endianness(a,d/8);if(10!=e)for(var k=0,h=a.length;k<h;)a[k]=parseInt(a[k],e),k++;a=
g(a,d,c.signed,c.char?b.readChar:b["read"+(2==d||4==d?8:d)+"Bit"+(c.float?"Float":"")]);c.char&&(a=a.join(""));c.single&&(a=a[0]);return a}},function(a,l,h){function g(b,a,c){--c;for(var d="";0<=c;)d+=f.bytePadding(b[c+a].toString(2),2),c--;return parseInt(d,2)}function k(b,a){return(b[3+a]<<24|b[2+a]<<16|b[1+a]<<8|b[a])>>>0}var f=h(1),b=h(6),c=h(0);a.exports.readChar=function(b,a){return String.fromCharCode(b[a])};a.exports.read1Bit=function(b,a){return parseInt(b[a],2)};a.exports.read8Bit=function(b,
a){return b[a]};a.exports.read16Bit=function(b,a){return b[1+a]<<8|b[a]};a.exports.read16BitFloat=function(a,d){return b.decodeFloat16(a.slice(d,d+2))};a.exports.read24Bit=function(b,a){return b[2+a]<<16|b[1+a]<<8|b[a]};a.exports.read32Bit=k;a.exports.read32BitFloat=function(b,a){return c.pack(k(b,a))};a.exports.read40Bit=function(b,a){return g(b,a,5)};a.exports.read48Bit=function(b,a){return g(b,a,6)};a.exports.read64Bit=function(a,d){return b.decodeFloat64(a.slice(d,d+8))}},function(a,l,h){var g=
h(1);a.exports.packBooleans=function(a){var f=[],b=0,c=0;g.fixByteArraySize(a,8);for(var e=a.length-7;b<e;)f[c++]=parseInt(a[b].toString(2)+a[b+1].toString(2)+a[b+2].toString(2)+a[b+3].toString(2)+a[b+4].toString(2)+a[b+5].toString(2)+a[b+6].toString(2)+a[b+7].toString(2),2),b+=8;return f};a.exports.unpackBooleans=function(a){for(var f=[],b=0,c=0,e=a.length,d;b<e;)d=g.lPadZeros(a[b].toString(2),8),f[c++]=parseInt(d[0],2),f[c++]=parseInt(d[1],2),f[c++]=parseInt(d[2],2),f[c++]=parseInt(d[3],2),f[c++]=
parseInt(d[4],2),f[c++]=parseInt(d[5],2),f[c++]=parseInt(d[6],2),f[c++]=parseInt(d[7],2),b++;return f};a.exports.packCrumbs=function(a){var f=[],b=0,c=0;g.fixByteArraySize(a,4);for(var e=a.length-3;b<e;)f[c++]=parseInt(g.lPadZeros(a[b].toString(2),2)+g.lPadZeros(a[b+1].toString(2),2)+g.lPadZeros(a[b+2].toString(2),2)+g.lPadZeros(a[b+3].toString(2),2),2),b+=4;return f};a.exports.unpackCrumbs=function(a){var f=[],b=0,c=0,e=a.length;for(console.log(e);b<e;){var d=g.lPadZeros(a[b].toString(2),8);f[c++]=
parseInt(d[0]+d[1],2);f[c++]=parseInt(d[2]+d[3],2);f[c++]=parseInt(d[4]+d[5],2);f[c++]=parseInt(d[6]+d[7],2);b++}return f};a.exports.packNibbles=function(a){var f=[],b=0,c=0,e=a.length;for(e%2&&a.push(0);b<e;)f[c++]=parseInt(a[b].toString(16)+a[b+1].toString(16),16),b+=2;return f};a.exports.unpackNibbles=function(a){for(var f=[],b=0,c=0,e=a.length;b<e;)f[c++]=parseInt(a[b].toString(16)[0],16),f[c++]=parseInt(a[b].toString(16)[1],16),b++;return f}},function(a,l){a.exports.WaveFileHeader=function(){this.chunkId=
"";this.chunkSize=0;this.fmtChunkId=this.format="";this.validBitsPerSample=this.cbSize=this.bitsPerSample=this.blockAlign=this.byteRate=this.sampleRate=this.numChannels=this.audioFormat=this.fmtChunkSize=0;this.factChunkId="";this.factChunkSize=0;this.factChunkData=[];this.dwSampleLength=0;this.cueChunkId="";this.cueChunkSize=-1;this.cueChunkData=[];this.dataChunkId="";this.dataChunkSize=0;this.bextChunkId="";this.bextChunkSize=0;this.bextChunkData=[]}},function(a,l,h){function g(a,b){for(var c=[],
e=a.length,d=12,f,h;d<e;)h=k.fromBytes(a.slice(d,d+4),8,{"char":!0}),f=k.fromBytes(a.slice(d+4,d+8),32,{be:b})[0],"LIST"==h?c.push({subChunkId:h,subChunkSize:f,subChunks:g(a.slice(d,d+f),b)}):c.push({subChunkId:h,subChunkSize:f,subChunkData:a.slice(d+8,d+8+f)}),d=d+8+f;return c}var k=h(19);a.exports.getChunks=function(a,b){b=void 0===b?!1:b;return{chunkId:k.fromBytes(a.slice(0,4),8,{"char":!0}),chunkSize:k.fromBytes(a.slice(4,8),32,{be:b})[0],format:k.fromBytes(a.slice(8,12),8,{"char":!0}),subChunks:g(a,
b)}}},function(a,l,h){l=h(20);var g=h(22),k=h(24);h=h(5);a.exports.findString=function(a,b){for(var c,e=0;e<a.length;e++)if(c=g.fromBytes(a.slice(e,e+b.length),8,{"char":!0}),c==b)return e;return-1};a.exports.toBytes=l.toBytes;a.exports.fromBytes=g.fromBytes;a.exports.packBooleans=k.packBooleans;a.exports.unpackBooleans=k.unpackBooleans;a.exports.packCrumbs=k.packCrumbs;a.exports.unpackCrumbs=k.unpackCrumbs;a.exports.packNibbles=k.packNibbles;a.exports.unpackNibbles=k.unpackNibbles;a.exports.BitDepthOffsets=
h.BitDepthOffsets;a.exports.BitDepthMaxValues=h.BitDepthMaxValues},function(a,l,h){function g(a,b,c){4==b?k(a,c,f.paddingNibble):2==b?k(a,c,f.paddingCrumb):1==b?k(a,c,function(){}):k(a,c)}function k(a,b,c){c=void 0===c?f.padding:c;if(10!=b)for(var d=0,e=a.length;d<e;)a[d]=a[d].toString(b),c(a,b,d),d++}h(0);var f=h(3),b=h(2),c=h(21),e=h(5);a.exports.toBytes=function(a,f,k){k=void 0===k?{}:k;var d=10;"base"in k&&(d=k.base);var h=k.char?c.writeString:c["write"+f+"Bit"+(k.float?"Float":"")];for(var l=
0,m=0,p=a.length,n=[];l<p;)m=h(n,a,l,m),l++;a=n;k.be&&b.endianness(a,e.BitDepthOffsets[f]);g(a,f,d);k.buffer&&(a=new Uint8Array(a));return a}},function(a,l,h){function g(a,c,e,d){a[d++]=c[e]&255;a[d++]=c[e]>>>8&255;a[d++]=c[e]>>>16&255;a[d++]=c[e]>>>24&255;return d}var k=h(7),f=h(0);a.exports.write64Bit=function(a,c,e,d){c=k.toFloat64(c[e]);d=g(a,c,1,d);return g(a,c,0,d)};a.exports.write48Bit=function(a,c,e,d){a[d++]=c[e]&255;a[d++]=c[e]>>8&255;a[d++]=c[e]>>16&255;a[d++]=c[e]>>24&255;a[d++]=c[e]/
4294967296&255;a[d++]=c[e]/1099511627776&255;return d};a.exports.write40Bit=function(a,c,e,d){a[d++]=c[e]&255;a[d++]=c[e]>>8&255;a[d++]=c[e]>>16&255;a[d++]=c[e]>>24&255;a[d++]=c[e]/4294967296&255;return d};a.exports.write32BitFloat=function(a,c,e,d){c=f.unpack(c[e]);a[d++]=c&255;a[d++]=c>>>8&255;a[d++]=c>>>16&255;a[d++]=c>>>24&255;return d};a.exports.write32Bit=g;a.exports.write24Bit=function(a,c,e,d){a[d++]=c[e]&255;a[d++]=c[e]>>>8&255;a[d++]=c[e]>>>16&255;return d};a.exports.write16Bit=function(a,
c,e,d){a[d++]=c[e]&255;a[d++]=c[e]>>>8&255;return d};a.exports.write16BitFloat=function(a,c,e,d){c=k.toHalf(c[e]);a[d++]=c>>>8&255;a[d++]=c&255;return d};a.exports.write8Bit=function(a,c,e,d){a[d++]=c[e]&255;return d};a.exports.write4Bit=function(a,c,e,d){a[d++]=c[e]&15;return d};a.exports.write2Bit=function(a,c,e,d){a[d++]=0>c[e]?c[e]+4:c[e];return d};a.exports.write1Bit=function(a,c,e,d){a[d++]=c[e]?1:0;return d};a.exports.writeString=function(a,c,e,d){a[d++]=c.charCodeAt(e);return d}},function(a,
l,h){function g(a,b,f,g){var d=[],e=0,h=0,l=c.BitDepthOffsets[b],m=a.length-(l-1);b=c.BitDepthMaxValues[b];for(f=f?k:function(a,b){return a};e<m;)d[h]=f(g(a,e),b),e+=l,h++;return d}function k(a,b){a>parseInt(b/2,10)-1&&(a-=b);return a}var f=h(2),b=h(23),c=h(5);a.exports.fromBytes=function(a,d,c){c=void 0===c?{}:c;var e=10;"base"in c&&(e=c.base);c.be&&f.endianness(a,d/8);if(10!=e)for(var k=0,h=a.length;k<h;)a[k]=parseInt(a[k],e),k++;a=g(a,d,c.signed,c.char?b.readChar:b["read"+(2==d||4==d?8:d)+"Bit"+
(c.float?"Float":"")]);c.char&&(a=a.join(""));return a}},function(a,l,h){function g(a,b,c){--c;for(var d="";0<=c;)d+=f.bytePadding(a[c+b].toString(2),2),c--;return parseInt(d,2)}function k(a,b){return(a[3+b]<<24|a[2+b]<<16|a[1+b]<<8|a[b])>>>0}var f=h(3),b=h(7),c=h(0);a.exports.readChar=function(a,b){return String.fromCharCode(a[b])};a.exports.read1Bit=function(a,b){return parseInt(a[b],2)};a.exports.read8Bit=function(a,b){return a[b]};a.exports.read16Bit=function(a,b){return a[1+b]<<8|a[b]};a.exports.read16BitFloat=
function(a,d){return b.decodeFloat16(a.slice(d,d+2))};a.exports.read24Bit=function(a,b){return a[2+b]<<16|a[1+b]<<8|a[b]};a.exports.read32Bit=k;a.exports.read32BitFloat=function(a,b){return c.pack(k(a,b))};a.exports.read40Bit=function(a,b){return g(a,b,5)};a.exports.read48Bit=function(a,b){return g(a,b,6)};a.exports.read64Bit=function(a,c){return b.decodeFloat64(a.slice(c,c+8))}},function(a,l,h){var g=h(3);a.exports.packBooleans=function(a){var f=[],b=0,c=0;g.fixByteArraySize(a,8);for(var e=a.length-
7;b<e;)f[c++]=parseInt(a[b].toString(2)+a[b+1].toString(2)+a[b+2].toString(2)+a[b+3].toString(2)+a[b+4].toString(2)+a[b+5].toString(2)+a[b+6].toString(2)+a[b+7].toString(2),2),b+=8;return f};a.exports.unpackBooleans=function(a){for(var f=[],b=0,c=0,e=a.length,d;b<e;)d=g.lPadZeros(a[b].toString(2),8),f[c++]=parseInt(d[0],2),f[c++]=parseInt(d[1],2),f[c++]=parseInt(d[2],2),f[c++]=parseInt(d[3],2),f[c++]=parseInt(d[4],2),f[c++]=parseInt(d[5],2),f[c++]=parseInt(d[6],2),f[c++]=parseInt(d[7],2),b++;return f};
a.exports.packCrumbs=function(a){var f=[],b=0,c=0;g.fixByteArraySize(a,4);for(var e=a.length-3;b<e;)f[c++]=parseInt(g.lPadZeros(a[b].toString(2),2)+g.lPadZeros(a[b+1].toString(2),2)+g.lPadZeros(a[b+2].toString(2),2)+g.lPadZeros(a[b+3].toString(2),2),2),b+=4;return f};a.exports.unpackCrumbs=function(a){var f=[],b=0,c=0,e=a.length;for(console.log(e);b<e;){var d=g.lPadZeros(a[b].toString(2),8);f[c++]=parseInt(d[0]+d[1],2);f[c++]=parseInt(d[2]+d[3],2);f[c++]=parseInt(d[4]+d[5],2);f[c++]=parseInt(d[6]+
d[7],2);b++}return f};a.exports.packNibbles=function(a){var f=[],b=0,c=0,e=a.length;for(e%2&&a.push(0);b<e;)f[c++]=parseInt(a[b].toString(16)+a[b+1].toString(16),16),b+=2;return f};a.exports.unpackNibbles=function(a){for(var f=[],b=0,c=0,e=a.length;b<e;)f[c++]=parseInt(a[b].toString(16)[0],16),f[c++]=parseInt(a[b].toString(16)[1],16),b++;return f}}]);
/*!
* wavefile
* Read & write wave files with 8, 16, 24, 32 PCM, 32 IEEE & 64-bit data.
* Read & write wave files with 8, 16, 24, 32 & 64-bit data.
* Copyright (c) 2017 Rafael da Silva Rocha.

@@ -19,9 +19,5 @@ * https://github.com/rochars/wavefile

* @param {Uint8Array} bytes A wave file buffer.
* @param {boolean} enforceFact True if it should throw a error
* if no "fact" chunk is found.
* @param {boolean} enforceBext True if it should throw a error
* if no "bext" chunk is found.
*/
constructor(bytes, enforceFact=false, enforceBext=false) {
super(enforceFact, enforceBext);
constructor(bytes) {
super();
if(bytes) {

@@ -136,2 +132,1 @@ this.fromBuffer(bytes);

module.exports.WaveFile = WaveFile;
{
"name": "wavefile",
"version": "0.5.0",
"description": "Read & write wave files with 8, 16, 24, 32 PCM, 32 IEEE & 64-bit data.",
"version": "0.6.0",
"description": "Read & write wave files with 8, 16, 24, 32 & 64-bit data.",
"homepage": "https://github.com/rochars/wavefile",

@@ -27,3 +27,2 @@ "author": "Rafael da Silva Rocha <rocha.rafaelsilva@gmail.com>",

"PCM",
"IEEE",
"resample"

@@ -37,3 +36,3 @@ ],

"lint": "jshint index.js && jshint test",
"test": "nyc ./node_modules/mocha/bin/_mocha test --recursive --timeout=8000",
"test": "nyc ./node_modules/mocha/bin/_mocha test --recursive",
"test_a": "nyc ./node_modules/mocha/bin/_mocha test/write",

@@ -61,4 +60,4 @@ "coverage": "nyc report --reporter=lcov > coverage.lcov && codecov",

"dependencies": {
"bitdepth": "1.0.1",
"byte-data": "0.4.3",
"bitdepth": "1.0.2",
"byte-data": "0.5.0",
"riff-chunks": "1.0.0"

@@ -65,0 +64,0 @@ },

# wavefile
Read & write wave files with 8, 16, 24, 32 PCM, 32 IEEE & 64-bit data.
Read & write wave files with 8, 16, 24, 32 & 64-bit data.
Copyright (c) 2017 Rafael da Silva Rocha.

@@ -87,7 +87,6 @@ https://github.com/rochars/wavefile

## BWF data
Data from the "bext" chunk is preserved in BWF files but there is no way to edit its values.
### The properties
```javascript
let wav = new wavefile.Wavefile(fs.readFileSync("file.wav"));
// The container, "RIFF" or "RIFX"

@@ -128,5 +127,5 @@ console.log(wav.chunkId);

- -8388608 to 8388607 for 24-bit
- -2147483648 to 2147483647 for 32-bit PCM
- -1.0 to 1.0 for 32-bit IEEE
- -1.0 to 1.0 for 64-bit
- -2147483648 to 2147483647 for 32-bit
- -1.0 to 1.0 for 32-bit (float)
- -1.0 to 1.0 for 64-bit (float)

@@ -133,0 +132,0 @@ ## LICENSE

@@ -13,20 +13,11 @@ /*

/**
* A wave file.
* Read and write wave files.
*/
class WaveFileReaderWriter extends waveFileHeader.WaveFileHeader {
/**
* @param {boolean} enforceFact True if it should throw a error
* if no "fact" chunk is found.
* @param {boolean} enforceBext True if it should throw a error
* if no "bext" chunk is found.
*/
constructor(enforceFact=false, enforceBext=false) {
constructor() {
super();
/** @type {boolean} */
this.enforceFact = enforceFact;
/** @type {boolean} */
this.enforceBext = enforceBext;
/** @type {boolean} */
this.enforceCue = false;
// TODO fact must be enforced in some cases
this.enforceFact_ = false;
/**

@@ -42,4 +33,2 @@ * Error messages.

"fact": "Could not find the 'fact' chunk",
"bext": "Could not find the 'bext' chunk",
"cue ": "Could not find the 'cue ' chunk",
"bitDepth": "Invalid bit depth.",

@@ -74,3 +63,3 @@ "numChannels": "Invalid number of channels.",

let chunk = riff.getChunks(bytes, bigEndian);
let options = {"be": bigEndian};
let options = {"be": bigEndian, "single": true};
this.readFmtChunk_(chunk.subChunks, options);

@@ -81,2 +70,7 @@ this.readFactChunk_(chunk.subChunks, options);

this.readDataChunk_(chunk.subChunks, options);
if (this.audioFormat == 3 && this.bitsPerSample == 32) {
this.bitDepth_ = "32f";
}else {
this.bitDepth_ = this.bitsPerSample.toString();
}
}

@@ -105,5 +99,7 @@

this.chunkSize = byteData.fromBytes(
bytes.slice(4, 8), 32, {"be": this.chunkId == "RIFX"})[0];
bytes.slice(4, 8),
32,
{"be": this.chunkId == "RIFX", "single": true});
this.format = byteData.fromBytes(
bytes.slice(8, 12), 8, {"char": true});
bytes.slice(8, 12), 8, byteData.str);
if (this.format != "WAVE") {

@@ -126,24 +122,19 @@ throw Error(this.WaveErrors.wave);

this.audioFormat = byteData.fromBytes(
chunk.subChunkData.slice(0, 2), 16, options)[0];
chunk.subChunkData.slice(0, 2), 16, options);
this.numChannels = byteData.fromBytes(
chunk.subChunkData.slice(2, 4), 16, options)[0];
chunk.subChunkData.slice(2, 4), 16, options);
this.sampleRate = byteData.fromBytes(
chunk.subChunkData.slice(4, 8), 32, options)[0];
chunk.subChunkData.slice(4, 8), 32, options);
this.byteRate = byteData.fromBytes(
chunk.subChunkData.slice(8, 12), 32, options)[0];
chunk.subChunkData.slice(8, 12), 32, options);
this.blockAlign = byteData.fromBytes(
chunk.subChunkData.slice(12, 14), 16, options)[0];
chunk.subChunkData.slice(12, 14), 16, options);
this.bitsPerSample = byteData.fromBytes(
chunk.subChunkData.slice(14, 16), 16, options)[0];
if (this.audioFormat == 3 && this.bitsPerSample == 32) {
this.bitDepth_ = "32f";
}else {
this.bitDepth_ = this.bitsPerSample.toString();
}
chunk.subChunkData.slice(14, 16), 16, options);
if (this.fmtChunkSize > 16) {
this.cbSize = byteData.fromBytes(
chunk.subChunkData.slice(16, 18), 16)[0];
chunk.subChunkData.slice(16, 18), 16);
if (this.fmtChunkSize > 18) {
this.validBitsPerSample = byteData.fromBytes(
chunk.subChunkData.slice(18, 20), 16)[0];
chunk.subChunkData.slice(18, 20), 16);
}

@@ -168,3 +159,3 @@ }

this.dwSampleLength = byteData.fromBytes(
chunk.subChunkData.slice(0, 4), 32, options)[0];
chunk.subChunkData.slice(0, 4), 32, options);
} else if (this.enforceFact) {

@@ -187,4 +178,2 @@ throw Error(this.WaveErrors["fact"]);

this.bextChunkData = byteData.fromBytes(chunk.subChunkData, 8);
} else if (this.enforceBext) {
throw Error(this.WaveErrors["bext"]);
}

@@ -205,4 +194,2 @@ }

this.cueChunkData = byteData.fromBytes(chunk.subChunkData, 8);
} else if (this.enforceCue) {
throw Error(this.WaveErrors["cue "]);
}

@@ -236,6 +223,8 @@ }

}
options.single = false;
if (this.bitsPerSample == 4) {
this.samples_ = byteData.fromBytes(bytes, 8, options);
} else {
this.samples_ = byteData.fromBytes(bytes, this.bitsPerSample, options);
this.samples_ = byteData.fromBytes(
bytes, this.bitsPerSample, options);
}

@@ -324,3 +313,3 @@ }

byteData.toBytes(this.bextChunkId, 8, {"char": true}),
byteData.toBytes([this.bextChunkSize], 32, options),
byteData.toBytes(this.bextChunkSize, 32, options),
byteData.toBytes(this.bextChunkData, 8)

@@ -337,3 +326,3 @@ );

byteData.toBytes(this.cueChunkId, 8, {"char": true}),
byteData.toBytes([this.cueChunkSize], 32, options),
byteData.toBytes(this.cueChunkSize, 32, options),
byteData.toBytes(this.cueChunkData, 8)

@@ -350,4 +339,4 @@ );

byteData.toBytes(this.factChunkId, 8, {"char": true}),
byteData.toBytes([this.factChunkSize], 32, options),
byteData.toBytes([this.dwSampleLength], 32, options)
byteData.toBytes(this.factChunkSize, 32, options),
byteData.toBytes(this.dwSampleLength, 32, options)
);

@@ -367,19 +356,20 @@ }

if (this.fmtChunkSize > 16) {
cbSize = byteData.toBytes([this.cbSize], 16, options);
cbSize = byteData.toBytes(this.cbSize, 16, options);
if (this.fmtChunkSize > 18) {
validBitsPerSample = byteData.toBytes([this.validBitsPerSample], 16, options);
validBitsPerSample = byteData.toBytes(
this.validBitsPerSample, 16, options);
}
}
return byteData.toBytes(this.chunkId, 8, {"char": true}).concat(
byteData.toBytes([this.chunkSize], 32, options),
byteData.toBytes(this.chunkSize, 32, options),
byteData.toBytes(this.format, 8, {"char": true}),
this.getBextBytes(options),
byteData.toBytes(this.fmtChunkId, 8, {"char": true}),
byteData.toBytes([this.fmtChunkSize], 32, options),
byteData.toBytes([this.audioFormat], 16, options),
byteData.toBytes([this.numChannels], 16, options),
byteData.toBytes([this.sampleRate], 32, options),
byteData.toBytes([this.byteRate], 32, options),
byteData.toBytes([this.blockAlign], 16, options),
byteData.toBytes([this.bitsPerSample], 16, options),
byteData.toBytes(this.fmtChunkSize, 32, options),
byteData.toBytes(this.audioFormat, 16, options),
byteData.toBytes(this.numChannels, 16, options),
byteData.toBytes(this.sampleRate, 32, options),
byteData.toBytes(this.byteRate, 32, options),
byteData.toBytes(this.blockAlign, 16, options),
byteData.toBytes(this.bitsPerSample, 16, options),
cbSize,

@@ -389,3 +379,3 @@ validBitsPerSample,

byteData.toBytes(this.dataChunkId, 8, {"char": true}),
byteData.toBytes([this.dataChunkSize], 32, options),
byteData.toBytes(this.dataChunkSize, 32, options),
this.samplesToBytes_(options),

@@ -392,0 +382,0 @@ this.getCueBytes(options)

Sorry, the diff of this file is too big to display

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