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 3.0.1 to 3.0.2

src/bwf-header.js

56

dist/wavefile-min.js

@@ -47,6 +47,6 @@ /*

$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,d,f){a!=Array.prototype&&a!=Object.prototype&&(a[d]=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,d,f,c){if(d){f=$jscomp.global;a=a.split(".");for(c=0;c<a.length-1;c++){var h=a[c];h in f||(f[h]={});f=f[h]}a=a[a.length-1];c=f[a];d=d(c);d!=c&&null!=d&&$jscomp.defineProperty(f,a,{configurable:!0,writable:!0,value:d})}};$jscomp.polyfill("Object.assign",function(a){return a?a:function(a,f){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var e in d)$jscomp.owns(d,e)&&(a[e]=d[e])}return a}},"es6","es3");
$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 c=this;c instanceof String&&(c=String(c));var d=c.length;for(f=f||0;f<d;f++)if(c[f]==a||Object.is(c[f],a))return!0;return!1}},"es7","es3");
$jscomp.polyfill=function(a,d,f,c){if(d){f=$jscomp.global;a=a.split(".");for(c=0;c<a.length-1;c++){var h=a[c];h in f||(f[h]={});f=f[h]}a=a[a.length-1];c=f[a];d=d(c);d!=c&&null!=d&&$jscomp.defineProperty(f,a,{configurable:!0,writable:!0,value:d})}};$jscomp.polyfill("Object.assign",function(a){return a?a:function(a,f){for(var c=1;c<arguments.length;c++){var h=arguments[c];if(h)for(var d in h)$jscomp.owns(h,d)&&(a[d]=h[d])}return a}},"es6","es3");
$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 c=this;c instanceof String&&(c=String(c));var h=c.length;for(f=f||0;f<h;f++)if(c[f]==a||Object.is(c[f],a))return!0;return!1}},"es7","es3");
$jscomp.checkStringArgs=function(a,d,f){if(null==a)throw new TypeError("The 'this' value for String.prototype."+f+" must not be null or undefined");if(d instanceof RegExp)throw new TypeError("First argument to String.prototype."+f+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,f){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,f||0)}},"es6","es3");
(function(a){function d(c){if(f[c])return f[c].exports;var h=f[c]={i:c,l:!1,exports:{}};a[c].call(h.exports,h,h.exports,d);h.l=!0;return h.exports}var f={};d.m=a;d.c=f;d.d=function(a,h,e){d.o(a,h)||Object.defineProperty(a,h,{configurable:!1,enumerable:!0,get:e})};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,d){return Object.prototype.hasOwnProperty.call(a,d)};d.p="";return d(d.s=4)})([function(a,d,f){function c(a,
(function(a){function d(c){if(f[c])return f[c].exports;var h=f[c]={i:c,l:!1,exports:{}};a[c].call(h.exports,h,h.exports,d);h.l=!0;return h.exports}var f={};d.m=a;d.c=f;d.d=function(a,h,e){d.o(a,h)||Object.defineProperty(a,h,{configurable:!1,enumerable:!0,get:e})};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,h){return Object.prototype.hasOwnProperty.call(a,h)};d.p="";return d(d.s=4)})([function(a,d,f){function c(a,
b,c){c=void 0===c?10:c;var g=[];b.char?g=b.char?a.slice(0,b.realBits/8):a:Array.isArray(a)||(g=[a]);return e.toBytes(g,e.getType(b,c))}function h(a,b,c){c=void 0===c?10:c;a=e.fromBytes(a.slice(0,8>b.bits?b.bits:b.realBits/8),e.getType(b,c));return a=b.char?a.slice(0,b.bits/8):a[0]}var e=f(5),b=f(1);a.exports.pack=c;a.exports.unpack=h;a.exports.packArray=function(a,b,c){return e.toBytes(a,e.getType(b,void 0===c?10:c))};a.exports.unpackArray=function(a,b,c){return e.fromBytes(a,e.getType(b,void 0===

@@ -61,3 +61,3 @@ c?10:c))};a.exports.unpackStruct=function(a,b,c){c=void 0===c?10:c;for(var g=a.length,e=0,d=0;d<b.length;d++)e+=b[d].realBits/8;if(g<e)return[];g=[];for(d=e=0;e<b.length;){var f=8>b[e].bits?1:b[e].realBits/8;g=g.concat(h(a.slice(d,d+f),b[e],c));d+=f;e++}return g};a.exports.packStruct=function(a,b,e){e=void 0===e?10:e;if(a.length<b.length)return[];for(var g=[],d=0;d<b.length;d++)g=g.concat(c(a[d],b[d],e));return g};a.exports.findString=function(a,c){for(var e,g=0;g<a.length;g++)if(e=h(a.slice(g,g+

32==this.bits?this.reader=this.read32F_:64==this.bits&&(this.reader=this.read64F_):this.char?this.reader=this.readChar_:32<this.bits&&(this.reader=this.readBits_)};d.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=d},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,f){a.exports.alaw=f(13);a.exports.mulaw=f(14)},function(a,d,f){f(0);var c=f(8),h=f(2),e=f(9),b=f(11),k=f(12),l=f(3).alaw,m=f(3).mulaw;a=function(g){var a=e.call(this)||this;g&&a.fromBuffer(g);return a};$jscomp.inherits(a,e);a.prototype.fromScratch=function(a,b,c,e,d){d=void 0===d?{}:d;this.validBitsPerSample=
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,f){a.exports.alaw=f(14);a.exports.mulaw=f(15)},function(a,d,f){f(0);var c=f(8),h=f(2),e=f(9),b=f(12),k=f(13),l=f(3).alaw,m=f(3).mulaw;a=function(g){var a=e.call(this)||this;g&&a.fromBuffer(g);return a};$jscomp.inherits(a,e);a.prototype.fromScratch=function(a,b,c,e,d){d=void 0===d?{}:d;this.validBitsPerSample=
this.cbSize=0;this.factChunkId="";this.factChunkSize=0;this.factChunkData=[];this.dwSampleLength=0;d.container||(d.container="RIFF");var g=parseInt(c,10)/8;this.chunkSize=36+e.length*g;this.fmtChunkSize=16;this.byteRate=a*g*b;this.blockAlign=a*g;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*g;this.samples=e;this.bitDepth=

@@ -70,3 +70,3 @@ c;"4"==c&&(this.chunkSize=44+e.length,this.fmtChunkSize=20,this.byteRate=4055,this.blockAlign=256,this.bitsPerSample=4,this.dataChunkSize=e.length,this.cbSize=2,this.validBitsPerSample=505,this.factChunkId="fact",this.factChunkSize=4,this.dwSampleLength=2*e.length);if("8a"==c||"8m"==c)this.chunkSize=44+e.length,this.fmtChunkSize=20,this.cbSize=2,this.validBitsPerSample=8,this.factChunkId="fact",this.factChunkSize=4,this.dwSampleLength=e.length};a.prototype.fromBuffer=function(a){this.readRIFFChunk_(a);

this.validateSampleRate_()};a.prototype.validateBitDepth_=function(){if(!this.headerFormats_[this.bitDepth])throw Error(h.bitDepth);return!0};a.prototype.validateNumChannels_=function(){var a=this.numChannels*this.bitsPerSample/8;if(1>this.numChannels||65535<a)throw Error(h.numChannels);return!0};a.prototype.validateSampleRate_=function(){var a=this.bitsPerSample/8*this.numChannels*this.sampleRate;if(1>this.sampleRate||4294967295<a)throw Error(h.sampleRate);return!0};window.WaveFile=a},function(a,
d,f){var c=f(1),h=f(7);a.exports.getType=function(a,b){a=Object.assign(new c({}),a);a.base=b;return a};a.exports.toBytes=function(a,b){for(var c=0,e=0,d=a.length,g=[];c<d;)e=b.writer(g,a[c++],e);b.be&&h(g,b.offset);if(10!=b.base){a=b.base;c=0;for(e=g.length;c<e;)g[c]=g[c].toString(a),c++;a=0;c=g.length;for(b=(2==b.base?8:2)+1;a<c;)g[a]=Array(b-g[a].length).join("0")+g[a],a++}return g};a.exports.fromBytes=function(a,b){b.be&&h(a,b.offset);if(10!=b.base)for(var c=b.base,d=0,e=a.length;d<e;)a[d]=parseInt(a[d],
d,f){var c=f(1),h=f(7);a.exports.getType=function(a,b){a=Object.assign(new c({}),a);a.base=b;return a};a.exports.toBytes=function(a,b){for(var c=0,d=0,e=a.length,g=[];c<e;)d=b.writer(g,a[c++],d);b.be&&h(g,b.offset);if(10!=b.base){a=b.base;c=0;for(d=g.length;c<d;)g[c]=g[c].toString(a),c++;a=0;c=g.length;for(b=(2==b.base?8:2)+1;a<c;)g[a]=Array(b-g[a].length).join("0")+g[a],a++}return g};a.exports.fromBytes=function(a,b){b.be&&h(a,b.offset);if(10!=b.base)for(var c=b.base,d=0,e=a.length;d<e;)a[d]=parseInt(a[d],
c),d++;c=[];d=0;for(e=a.length-(b.offset-1);d<e;)c.push(b.reader(a,d)),d+=b.offset;b.char&&(c=c.join(""));return c}},function(a,d){d=function(a){this.bits=a.bits;this.be=a.be;this.signed=a.signed;this.base=a.base?a.base:10;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.sign=function(a){a>this.max&&(a-=2*this.max+2);return a};d.prototype.overflow=function(a){a>this.max?a=this.max:

@@ -78,24 +78,24 @@ a<this.min&&(a=this.min);return a};d.prototype.read_=function(a,c,d){var e=0;for(d=(void 0===d?this:d).offset-1;0<d;)e|=a[d+c]<<8*d,d--;e=(a[c]|e)>>>0;return this.overflow(this.sign(e))};d.prototype.readBits_=function(a,c,d){d=void 0===d?this:d;for(var e="",b=0;b<d.offset;){var h=a[c+b].toString(2);e=Array(9-h.length).join("0")+h+e;b++}return this.overflow(this.sign(parseInt(e,2)))};d.prototype.write_=function(a,c,d,e){e=void 0===e?this:e;c=this.overflow(c);var b=255,h=e.offset;d=this.writeFirstByte_(a,

b.original&&"32f"==b.target&&(f[0]=a,a=f[0]);return a}};a.exports.toBitDepth=function(a,b,d){var e="8 16 24 32 32f 64".split(" ");if(-1==e.indexOf(b)||-1==e.indexOf(d))throw Error("Invalid bit depth.");e=["32f","64"].includes(b)?"float":"int";var f=["32f","64"].includes(d)?"Float":"Int";e=h[e+"To"+f];f=a.length;for(var g=0;g<f;g++){var n=g,k=a[g];"8"==b&&(k-=128);a[n]=k;a[g]=e(a[g],{oldNegative:c[b]/2,newNegative:c[d]/2,oldPositive:c[b]/2-1,newPositive:c[d]/2-1,original:b,target:d});n=g;k=a[g];"8"==
d&&(k+=128);a[n]=k}};a.exports.BitDepthMaxValues=c},function(a,d,f){var c=f(0),h=f(2),e=c.uInt8,b=c.uInt16,k=c.uInt32,l=c.chr,m=f(10);d=function(){var a=m.call(this)||this;a.headerFormats_={4:17,8:1,"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,64:3};a.samples=[];a.head_=0;return a};$jscomp.inherits(d,m);d.decodeSample=m.decodeSample;d.encodeSample=m.encodeSample;d.decodeBlock=m.decodeBlock;d.encodeBlock=m.encodeBlock;d.decode=m.decode;d.encode=m.encode;d.write=m.write;d.read=m.read;d.prototype.readRIFFChunk_=
function(a){this.chunkId=c.unpackArray(a.slice(0,4),l);if("RIFF"!=this.chunkId&&"RIFX"!=this.chunkId)throw Error(h.format);this.LEorBE();this.chunkSize=c.unpack(a.slice(4,8),k);this.format=c.unpackArray(a.slice(8,12),l);if("WAVE"!=this.format)throw Error(h.wave);};d.prototype.LEorBE=function(){var a="RIFX"==this.chunkId;e.be=a;b.be=a;return k.be=a};d.prototype.readFmtChunk_=function(a){if(a=this.findChunk(a,"fmt "))this.fmtChunkId="fmt ",this.fmtChunkSize=a.chunkSize,this.audioFormat=c.unpack(a.chunkData.slice(0,
2),b),this.numChannels=c.unpack(a.chunkData.slice(2,4),b),this.sampleRate=c.unpack(a.chunkData.slice(4,8),k),this.byteRate=c.unpack(a.chunkData.slice(8,12),k),this.blockAlign=c.unpack(a.chunkData.slice(12,14),b),this.bitsPerSample=c.unpack(a.chunkData.slice(14,16),b),this.readFmtExtension(a);else throw Error(h["fmt "]);};d.prototype.readFmtExtension=function(a){16<this.fmtChunkSize&&(this.cbSize=c.unpack(a.chunkData.slice(16,18),b),18<this.fmtChunkSize&&(this.validBitsPerSample=c.unpack(a.chunkData.slice(18,
20),b)))};d.prototype.readFactChunk_=function(a){if(a=this.findChunk(a,"fact"))this.factChunkId="fact",this.factChunkSize=a.chunkSize,this.dwSampleLength=c.unpack(a.chunkData.slice(0,4),k);else if(this.enforceFact)throw Error(h.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,b),UMID:this.readVariableSizeString_(this.bextChunkData,64),loudnessValue:this.readFromChunk_(this.bextChunkData,b),loudnessRange:this.readFromChunk_(this.bextChunkData,
b),maxTruePeakLevel:this.readFromChunk_(this.bextChunkData,b),maxMomentaryLoudness:this.readFromChunk_(this.bextChunkData,b),maxShortTermLoudness:this.readFromChunk_(this.bextChunkData,b),reserved:this.readVariableSizeString_(this.bextChunkData,180),codingHistory:this.readVariableSizeString_(this.bextChunkData,this.bextChunkData.length-602)}};d.prototype.readBytes=function(a,b){var c=this.head_;this.head_+=b;return a.slice(c,this.head_)};d.prototype.readVariableSizeString_=function(a,b){for(var d=
"",g=0;g<b;g++)d+=c.unpack([a[this.head_]],l),this.head_++;return d};d.prototype.readFromChunk_=function(a,b){var d=b.bits/8;a=c.unpack(a.slice(this.head_,this.head_+d),b);this.head_+=d;return a};d.prototype.writeVariableSizeString_=function(a,b){a=c.packArray(a,l);for(var d=a.length;d<b;d++)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(h.data);};d.prototype.samplesFromBytes_=function(a,b){b.bits=4==this.bitsPerSample?8:this.bitsPerSample;b.signed=8==b.bits?!1:!0;b.float=3==this.audioFormat||64==this.bitsPerSample?!0:!1;b.single=!1;this.samples=c.unpackArray(a,new c.Type(b))};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=c.packArray(this.samples,new c.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(c.pack(this.bextChunkFields.version,b));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.UMID,64));a=a.concat(c.pack(this.bextChunkFields.loudnessValue,b));a=a.concat(c.pack(this.bextChunkFields.loudnessRange,b));a=a.concat(c.pack(this.bextChunkFields.maxTruePeakLevel,
b));a=a.concat(c.pack(this.bextChunkFields.maxMomentaryLoudness,b));a=a.concat(c.pack(this.bextChunkFields.maxShortTermLoudness,b));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.reserved,180));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.codingHistory,this.bextChunkData.length-602));return[].concat(c.packArray(this.bextChunkId,l),c.pack(a.length,k),a)}return[]};d.prototype.getCueBytes_=function(){return this.cueChunkId?[].concat(c.packArray(this.cueChunkId,l),c.pack(this.cueChunkSize,
k),this.cueChunkData):[]};d.prototype.getFactBytes_=function(){return this.factChunkId?[].concat(c.packArray(this.factChunkId,l),c.pack(this.factChunkSize,k),c.pack(this.dwSampleLength,k)):[]};d.prototype.getCbSizeBytes_=function(){return 16<this.fmtChunkSize?c.pack(this.cbSize,b):[]};d.prototype.getValidBitsPerSampleBytes_=function(){return 18<this.fmtChunkSize?c.pack(this.validBitsPerSample,b):[]};d.prototype.createWaveFile_=function(){var a={be:this.LEorBE()};return c.packArray(this.chunkId,l).concat(c.pack(this.chunkSize,
k),c.packArray(this.format,l),this.getBextBytes_(),c.packArray(this.fmtChunkId,l),c.pack(this.fmtChunkSize,k),c.pack(this.audioFormat,b),c.pack(this.numChannels,b),c.pack(this.sampleRate,k),c.pack(this.byteRate,k),c.pack(this.blockAlign,b),c.pack(this.bitsPerSample,b),this.getCbSizeBytes_(),this.getValidBitsPerSampleBytes_(),this.getFactBytes_(),c.packArray(this.dataChunkId,l),c.pack(this.dataChunkSize,k),this.samplesToBytes_(a),this.getCueBytes_())};a.exports=d},function(a,d){a.exports=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=[];this.bextChunkFields={description:"",originator:"",
originatorReference:"",originationDate:"",originationTime:"",timeReference:"",version:"",UMID:"",loudnessValue:"",loudnessRange:"",maxTruePeakLevel:"",maxMomentaryLoudness:"",maxShortTermLoudness:"",reserved:"",codingHistory:""}}},function(a,d,f){function c(a,b){(void 0===b?0:b)||(l.be="RIFX"==a.chunkId);b=k.packArray(a.chunkId,m).concat(k.pack(a.chunkSize,l),k.packArray(a.format,m),h(a.subChunks,l.be));if("RIFF"==a.chunkId||"RIFX"==a.chunkId)b=new Uint8Array(b);return b}function h(a,b){for(var d=
[],e=0;e<a.length;)d="LIST"==a[e].chunkId?d.concat(c(a[e],b)):d.concat(k.packArray(a[e].chunkId,m),k.pack(a[e].chunkSize,l),a[e].chunkData),e++;return d}function e(a){for(var c=[],d=12;d<a.length;)c.push(b(a,d)),d+=8+c[c.length-1].chunkSize;return c}function b(a,b){var c={chunkId:k.unpackArray(a.slice(b,b+4),m),chunkSize:k.unpack(a.slice(b+4,b+8),l)};"LIST"==c.chunkId?(c.format=k.unpackArray(a.slice(8,12),m),c.subChunks=e(a.slice(b,b+c.chunkSize))):c.chunkData=a.slice(b+8,b+8+c.chunkSize);return c}
var k=f(0),l=k.uInt32,m=k.chr;a.exports.read=function(a){a=[].slice.call(a);var b=k.unpackArray(a.slice(0,4),m);l.be="RIFX"==b;return{chunkId:b,chunkSize:k.unpack(a.slice(4,8),l),format:k.unpackArray(a.slice(8,12),m),subChunks:e(a)}};a.exports.write=c},function(a,d,f){function c(a){a-=n;if(0<=a)var b=0;else b=8,a=-a;var c=g[r],d=c>>3;a>c&&(b|=4,a-=c,d+=c);c>>=1;a>c&&(b|=2,a-=c,d+=c);c>>=1;a>c&&(b|=1,d+=c);n=b&8?n-d:n+d;-32768>n?n=-32768:32767<n&&(n=32767);r+=m[b&7];0>r?r=0:88<r&&(r=88);return b}function h(a){var b=
0;a&4&&(b+=t);a&2&&(b+=t>>1);a&1&&(b+=t>>2);b+=t>>3;a&8&&(b=-b);p+=b;32767<p?p=32767:-32767>p&&(p=-32767);q+=m[a];0>q?q=0:88<q&&(q=88);t=g[q];return p}function e(a){var b=a[0];c(b);var d=[];d.push(k.pack(b,l)[0]);d.push(k.pack(b,l)[1]);d.push(r);d.push(0);for(b=3;b<a.length;b+=2){var e=c(a[b]),h=c(a[b+1]);d.push(h<<4|e)}for(;256>d.length;)d.push(0);return d}function b(a){p=k.unpack([a[0],a[1]],l);q=a[2];t=g[q];for(var b=[p,k.unpack([a[2],a[3]],l)],c=4;c<a.length;c++){var d=a[c],e=d>>4;b.push(h(e<<
4^d));b.push(h(e))}return b}var k=f(0),l=k.int16,m=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],g=[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],n=0,r=0,p=0,q=0,t=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(e(c)),c=[];return b};a.exports.decode=function(a,c){c=void 0===c?256:c;for(var d=[],e=[],h=0;h<a.length;h++)0==h%c&&0!=h&&(d=d.concat(b(e)),e=[]),e.push(a[h]);return d};a.exports.encodeBlock=e;a.exports.decodeBlock=b},function(a,d){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],b;a=-32768==a?-32767:a;(b=~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^b^85}function c(a){var c=0;a^=85;a&128&&(a&=-129,c=-1);var b=((a&240)>>4)+4;a=4!=b?1<<b|(a&15)<<b-4|1<<b-5:a<<1|1;return-8*(0==c?a:-a)}a.exports.encodeSample=f;a.exports.decodeSample=c;a.exports.encode=function(a){for(var c=[],b=0;b<a.length;b++)c.push(f(a[b]));return c};
a.exports.decode=function(a){for(var d=[],b=0;b<a.length;b++)d.push(c(a[b]));return d}},function(a,d){function f(a){if(0>a){a=132-a;var c=127}else a+=132,c=255;32767<a&&(a=32767);var b=0;var d=a>>7;d&240&&(d>>=4,b+=4);d&12&&(d>>=2,b+=2);d&2&&(b+=1);d=b;return(d<<4|a>>d+3&15)^c}function c(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=c;a.exports.encode=function(a){for(var c=[],b=0;b<a.length;b++)c.push(f(a[b]));return c};a.exports.decode=
function(a){for(var d=[],b=0;b<a.length;b++)d.push(c(a[b]));return d}}]);
d&&(k+=128);a[n]=k}};a.exports.BitDepthMaxValues=c},function(a,d,f){var c=f(0),h=f(2),e=c.uInt8,b=c.uInt16,k=c.uInt32,l=c.chr,m=f(10);d=function(){var a=m.call(this)||this;a.headerFormats_={4:17,8:1,"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,64:3};a.samples=[];a.head_=0;return a};$jscomp.inherits(d,m);d.prototype.readRIFFChunk_=function(a){this.chunkId=c.unpackArray(a.slice(0,4),l);if("RIFF"!=this.chunkId&&"RIFX"!=this.chunkId)throw Error(h.format);this.LEorBE();this.chunkSize=c.unpack(a.slice(4,8),k);
this.format=c.unpackArray(a.slice(8,12),l);if("WAVE"!=this.format)throw Error(h.wave);};d.prototype.LEorBE=function(){var a="RIFX"==this.chunkId;e.be=a;b.be=a;return k.be=a};d.prototype.readFmtChunk_=function(a){if(a=this.findChunk(a,"fmt "))this.fmtChunkId="fmt ",this.fmtChunkSize=a.chunkSize,this.audioFormat=c.unpack(a.chunkData.slice(0,2),b),this.numChannels=c.unpack(a.chunkData.slice(2,4),b),this.sampleRate=c.unpack(a.chunkData.slice(4,8),k),this.byteRate=c.unpack(a.chunkData.slice(8,12),k),this.blockAlign=
c.unpack(a.chunkData.slice(12,14),b),this.bitsPerSample=c.unpack(a.chunkData.slice(14,16),b),this.readFmtExtension(a);else throw Error(h["fmt "]);};d.prototype.readFmtExtension=function(a){16<this.fmtChunkSize&&(this.cbSize=c.unpack(a.chunkData.slice(16,18),b),18<this.fmtChunkSize&&(this.validBitsPerSample=c.unpack(a.chunkData.slice(18,20),b)))};d.prototype.readFactChunk_=function(a){if(a=this.findChunk(a,"fact"))this.factChunkId="fact",this.factChunkSize=a.chunkSize,this.dwSampleLength=c.unpack(a.chunkData.slice(0,
4),k);else if(this.enforceFact)throw Error(h.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,b),UMID:this.readVariableSizeString_(this.bextChunkData,64),loudnessValue:this.readFromChunk_(this.bextChunkData,b),loudnessRange:this.readFromChunk_(this.bextChunkData,b),maxTruePeakLevel:this.readFromChunk_(this.bextChunkData,b),maxMomentaryLoudness:this.readFromChunk_(this.bextChunkData,
b),maxShortTermLoudness:this.readFromChunk_(this.bextChunkData,b),reserved:this.readVariableSizeString_(this.bextChunkData,180),codingHistory:this.readVariableSizeString_(this.bextChunkData,this.bextChunkData.length-602)}};d.prototype.readBytes=function(a,b){var c=this.head_;this.head_+=b;return a.slice(c,this.head_)};d.prototype.readVariableSizeString_=function(a,b){for(var d="",g=0;g<b;g++)d+=c.unpack([a[this.head_]],l),this.head_++;return d};d.prototype.readFromChunk_=function(a,b){var d=b.bits/
8;a=c.unpack(a.slice(this.head_,this.head_+d),b);this.head_+=d;return a};d.prototype.writeVariableSizeString_=function(a,b){a=c.packArray(a,l);for(var d=a.length;d<b;d++)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(h.data);};d.prototype.samplesFromBytes_=function(a,b){b.bits=4==this.bitsPerSample?8:this.bitsPerSample;b.signed=8==b.bits?!1:!0;b.float=3==this.audioFormat||64==this.bitsPerSample?!0:!1;b.single=!1;this.samples=c.unpackArray(a,new c.Type(b))};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=c.packArray(this.samples,new c.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(c.pack(this.bextChunkFields.version,b));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.UMID,64));a=a.concat(c.pack(this.bextChunkFields.loudnessValue,b));a=a.concat(c.pack(this.bextChunkFields.loudnessRange,b));a=a.concat(c.pack(this.bextChunkFields.maxTruePeakLevel,b));a=a.concat(c.pack(this.bextChunkFields.maxMomentaryLoudness,b));a=a.concat(c.pack(this.bextChunkFields.maxShortTermLoudness,b));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.reserved,
180));a=a.concat(this.writeVariableSizeString_(this.bextChunkFields.codingHistory,this.bextChunkData.length-602));return[].concat(c.packArray(this.bextChunkId,l),c.pack(a.length,k),a)}return[]};d.prototype.getCueBytes_=function(){return this.cueChunkId?[].concat(c.packArray(this.cueChunkId,l),c.pack(this.cueChunkSize,k),this.cueChunkData):[]};d.prototype.getFactBytes_=function(){return this.factChunkId?[].concat(c.packArray(this.factChunkId,l),c.pack(this.factChunkSize,k),c.pack(this.dwSampleLength,
k)):[]};d.prototype.getCbSizeBytes_=function(){return 16<this.fmtChunkSize?c.pack(this.cbSize,b):[]};d.prototype.getValidBitsPerSampleBytes_=function(){return 18<this.fmtChunkSize?c.pack(this.validBitsPerSample,b):[]};d.prototype.createWaveFile_=function(){var a={be:this.LEorBE()};return c.packArray(this.chunkId,l).concat(c.pack(this.chunkSize,k),c.packArray(this.format,l),this.getBextBytes_(),c.packArray(this.fmtChunkId,l),c.pack(this.fmtChunkSize,k),c.pack(this.audioFormat,b),c.pack(this.numChannels,
b),c.pack(this.sampleRate,k),c.pack(this.byteRate,k),c.pack(this.blockAlign,b),c.pack(this.bitsPerSample,b),this.getCbSizeBytes_(),this.getValidBitsPerSampleBytes_(),this.getFactBytes_(),c.packArray(this.dataChunkId,l),c.pack(this.dataChunkSize,k),this.samplesToBytes_(a),this.getCueBytes_())};a.exports=d},function(a,d,f){var c=f(11);d=function(){var a=c.call(this)||this;a.bextChunkId="";a.bextChunkSize=0;a.bextChunkData=[];a.bextChunkFields={description:"",originator:"",originatorReference:"",originationDate:"",
originationTime:"",timeReference:"",version:"",UMID:"",loudnessValue:"",loudnessRange:"",maxTruePeakLevel:"",maxMomentaryLoudness:"",maxShortTermLoudness:"",reserved:"",codingHistory:""};return a};$jscomp.inherits(d,c);d.decodeSample=c.decodeSample;d.encodeSample=c.encodeSample;d.decodeBlock=c.decodeBlock;d.encodeBlock=c.encodeBlock;d.decode=c.decode;d.encode=c.encode;d.write=c.write;d.read=c.read;a.exports=d},function(a,d){a.exports=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}},function(a,d,f){function c(a,b){(void 0===b?0:b)||(l.be="RIFX"==a.chunkId);b=k.packArray(a.chunkId,m).concat(k.pack(a.chunkSize,l),k.packArray(a.format,m),
h(a.subChunks,l.be));if("RIFF"==a.chunkId||"RIFX"==a.chunkId)b=new Uint8Array(b);return b}function h(a,b){for(var d=[],e=0;e<a.length;)d="LIST"==a[e].chunkId?d.concat(c(a[e],b)):d.concat(k.packArray(a[e].chunkId,m),k.pack(a[e].chunkSize,l),a[e].chunkData),e++;return d}function e(a){for(var c=[],d=12;d<a.length;)c.push(b(a,d)),d+=8+c[c.length-1].chunkSize;return c}function b(a,b){var c={chunkId:k.unpackArray(a.slice(b,b+4),m),chunkSize:k.unpack(a.slice(b+4,b+8),l)};"LIST"==c.chunkId?(c.format=k.unpackArray(a.slice(8,
12),m),c.subChunks=e(a.slice(b,b+c.chunkSize))):c.chunkData=a.slice(b+8,b+8+c.chunkSize);return c}var k=f(0),l=k.uInt32,m=k.chr;a.exports.read=function(a){a=[].slice.call(a);var b=k.unpackArray(a.slice(0,4),m);l.be="RIFX"==b;return{chunkId:b,chunkSize:k.unpack(a.slice(4,8),l),format:k.unpackArray(a.slice(8,12),m),subChunks:e(a)}};a.exports.write=c},function(a,d,f){function c(a){a-=n;if(0<=a)var b=0;else b=8,a=-a;var c=g[r],d=c>>3;a>c&&(b|=4,a-=c,d+=c);c>>=1;a>c&&(b|=2,a-=c,d+=c);c>>=1;a>c&&(b|=1,
d+=c);n=b&8?n-d:n+d;-32768>n?n=-32768:32767<n&&(n=32767);r+=m[b&7];0>r?r=0:88<r&&(r=88);return b}function h(a){var b=0;a&4&&(b+=t);a&2&&(b+=t>>1);a&1&&(b+=t>>2);b+=t>>3;a&8&&(b=-b);p+=b;32767<p?p=32767:-32767>p&&(p=-32767);q+=m[a];0>q?q=0:88<q&&(q=88);t=g[q];return p}function e(a){var b=a[0];c(b);var d=[];d.push(k.pack(b,l)[0]);d.push(k.pack(b,l)[1]);d.push(r);d.push(0);for(b=3;b<a.length;b+=2){var e=c(a[b]),h=c(a[b+1]);d.push(h<<4|e)}for(;256>d.length;)d.push(0);return d}function b(a){p=k.unpack([a[0],
a[1]],l);q=a[2];t=g[q];for(var b=[p,k.unpack([a[2],a[3]],l)],c=4;c<a.length;c++){var d=a[c],e=d>>4;b.push(h(e<<4^d));b.push(h(e))}return b}var k=f(0),l=k.int16,m=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],g=[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],n=0,r=0,p=0,q=0,t=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(e(c)),c=[];return b};a.exports.decode=function(a,c){c=void 0===c?256:c;for(var d=[],e=[],h=0;h<a.length;h++)0==h%c&&0!=h&&(d=d.concat(b(e)),e=[]),e.push(a[h]);return d};a.exports.encodeBlock=e;a.exports.decodeBlock=b},function(a,d){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],b;a=-32768==a?-32767:a;(b=~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^b^85}function c(a){var c=0;a^=85;a&128&&(a&=-129,c=-1);var b=((a&240)>>4)+4;a=4!=b?1<<b|(a&15)<<b-4|1<<b-5:a<<1|1;return-8*(0==c?a:-a)}a.exports.encodeSample=
f;a.exports.decodeSample=c;a.exports.encode=function(a){for(var c=[],b=0;b<a.length;b++)c.push(f(a[b]));return c};a.exports.decode=function(a){for(var d=[],b=0;b<a.length;b++)d.push(c(a[b]));return d}},function(a,d){function f(a){if(0>a){a=132-a;var c=127}else a+=132,c=255;32767<a&&(a=32767);var b=0;var d=a>>7;d&240&&(d>>=4,b+=4);d&12&&(d>>=2,b+=2);d&2&&(b+=1);d=b;return(d<<4|a>>d+3&15)^c}function c(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=
c;a.exports.encode=function(a){for(var c=[],b=0;b<a.length;b++)c.push(f(a[b]));return c};a.exports.decode=function(a){for(var d=[],b=0;b<a.length;b++)d.push(c(a[b]));return d}}]);
{
"name": "wavefile",
"version": "3.0.1",
"version": "3.0.2",
"description": "Read & write wave files with 4, 8, 16, 24, 32 & 64-bit data.",

@@ -45,13 +45,12 @@ "homepage": "https://github.com/rochars/wavefile",

"lint": "jshint index.js && jshint test",
"test": "nyc ./node_modules/mocha/bin/_mocha test --recursive",
"test_a": "nyc ./node_modules/mocha/bin/_mocha test/write",
"test": "nyc ./node_modules/mocha/bin/_mocha test --src --recursive",
"test-dist": "nyc ./node_modules/mocha/bin/_mocha test --dist --recursive",
"coverage": "nyc report --reporter=lcov > coverage.lcov && codecov",
"bundle": "webpack",
"compile": "google-closure-compiler-js dist/wavefile.js > dist/wavefile-min.js",
"doc": "./node_modules/.bin/jsdoc index.js -d docs -r README.md -t node_modules/docdash",
"qa": "npm run lint && npm test",
"pack": "npm run bundle && npm run compile && npm run doc",
"build": "npm run qa && npm run pack"
"pack": "webpack && npm run compile && npm run doc",
"build": "npm run lint && npm run pack && npm run test-dist && npm test"
},
"devDependencies": {
"browser-env": "^3.2.5",
"chai": "^4.1.2",

@@ -58,0 +57,0 @@ "codecov": "^3.0.0",

@@ -9,7 +9,5 @@ # wavefile

## About
**wavefile** is a module to work with wav files. It is partly inspired by SoX and intended to run in both Node.js and the browser.
**wavefile** is a module to work with wav files. It is partly inspired by SoX, and intended to run in both Node.js and the browser.
With **wavefile** you can:

@@ -16,0 +14,0 @@ - Create wav files from scratch

@@ -82,29 +82,2 @@ /*

this.dataChunkSize = 0;
/**
* "bext"
* @type {string}
*/
this.bextChunkId = "";
/** @type {number} */
this.bextChunkSize = 0;
/** @type {!Array<number>} */
this.bextChunkData = [];
/** @type {Object} */
this.bextChunkFields = {
"description": "", //256
"originator": "", //32
"originatorReference": "", //32
"originationDate": "", //10
"originationTime": "", //8
"timeReference": "", //64-bit value
"version": "", //WORD
"UMID": "", // 64
"loudnessValue": "", //WORD
"loudnessRange": "", //WORD
"maxTruePeakLevel": "", //WORD
"maxMomentaryLoudness": "", //WORD
"maxShortTermLoudness": "", //WORD
"reserved": "", //180
"codingHistory": "" // string, unlimited
};
}

@@ -111,0 +84,0 @@ }

@@ -18,3 +18,3 @@ /*

const chr = byteData.chr;
let WaveFileHeader = require("../src/wavefile-header");
const BWFHeader = require("../src/bwf-header");

@@ -24,3 +24,3 @@ /**

*/
class WaveFileReaderWriter extends WaveFileHeader {
class WaveFileReaderWriter extends BWFHeader {

@@ -27,0 +27,0 @@ constructor() {

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