diff --git a/README.md b/README.md index 0cf7d4e..445eb0c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ With **wavefile** you can: - Encode/decode files as ADPCM, A-Law and mu-Law - Read/write the data in a wav file header - Turn RIFF files to RIFX and RIFX files to RIFF +- Edit BWF metada ("bext" chunk) And more. @@ -203,7 +204,6 @@ console.log(wav.samples); ### BWF data BWF data ("bext" chunk) is stored in the *bextChunkFields* property in human-readable form. -You may edit the data in the "bext" chunk by editing the *bextChunkFields* property on a WaveFile object. ```javascript wav.bextChunkFields = { "description": "", // 256 chars diff --git a/dist/wavefile-min.js b/dist/wavefile-min.js index 06db779..9ee749d 100644 --- a/dist/wavefile-min.js +++ b/dist/wavefile-min.js @@ -1,7 +1,7 @@ /* byte-data - Readable data to and from byte buffers. - Copyright (c) 2017 Rafael da Silva Rocha. + Read and write data to and from byte buffers. + Copyright (c) 2017-2018 Rafael da Silva Rocha. https://github.com/rochars/byte-data endianness @@ -29,6 +29,11 @@ Copyright (c) 2017 Rafael da Silva Rocha. https://github.com/rochars/riff-chunks + byte-data + Readable data to and from byte buffers. + Copyright (c) 2017 Rafael da Silva Rocha. + https://github.com/rochars/byte-data + imaadpcm JavaScript IMA ADPCM codec. Copyright (c) 2018 Rafael da Silva Rocha. @@ -40,70 +45,70 @@ https://wiki.multimedia.cx/index.php/IMA_ADPCM */ -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(g){var a=function(){};a.prototype=g;return new a};$jscomp.underscoreProtoCanBeSet=function(){var g={a:!0},a={};try{return a.__proto__=g,a.a}catch(h){}return!1}; -$jscomp.setPrototypeOf="function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(g,a){g.__proto__=a;if(g.__proto__!==a)throw new TypeError(g+" is not extensible");return g}:null; -$jscomp.inherits=function(g,a){g.prototype=$jscomp.objectCreate(a.prototype);g.prototype.constructor=g;if($jscomp.setPrototypeOf){var h=$jscomp.setPrototypeOf;h(g,a)}else for(h in a)if("prototype"!=h)if(Object.defineProperties){var c=Object.getOwnPropertyDescriptor(a,h);c&&Object.defineProperty(g,h,c)}else g[h]=a[h];g.superClass_=a.prototype};$jscomp.owns=function(g,a){return Object.prototype.hasOwnProperty.call(g,a)}; -$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(g,a,h){g!=Array.prototype&&g!=Object.prototype&&(g[a]=h.value)};$jscomp.getGlobal=function(g){return"undefined"!=typeof window&&window===g?g:"undefined"!=typeof global&&null!=global?global:g};$jscomp.global=$jscomp.getGlobal(this); -$jscomp.polyfill=function(g,a,h,c){if(a){h=$jscomp.global;g=g.split(".");for(c=0;cb.bits?b.bits:b.realBits/8),e.getType(b,f));return a=b.char?a.slice(0,b.bits/8):a[0]}var e=h(7),b=h(1);a.pack=c;a.unpack=k;a.packArray=function(a,b,f){return e.toBytes(a,e.getType(b,void 0===f?10:f))};a.unpackArray=function(a,b,f){return e.fromBytes(a,e.getType(b,void 0===f?10:f))};a.unpackStruct=function(a, -b,f){f=void 0===f?10:f;for(var d=a.length,m=0,e=0;eb[m].bits?1:b[m].realBits/8;d=d.concat(k(a.slice(e,e+c),b[m],f));e+=c;m++}return d};a.packStruct=function(a,b,f){f=void 0===f?10:f;if(a.length>10;var d=a&1023;return(b?Math.pow(2,b-15)*(1+d/1024):d/1024*.00006103515625)*(a>>15?-1:1)};a.prototype.read32F_=function(a,b){k[0]=this.read_(a,b,{bits:32,offset:4});return c[0]};a.prototype.read64F_=function(a,f){b[0]=this.read_(a,f,{bits:32,offset:4});b[1]=this.read_(a,f+4,{bits:32,offset:4});return e[0]};a.prototype.readChar_=function(a,b){for(var d="",m=0;m>16&32768;var f=m>>12&2047;m=m>>23&255;103<=m&&(b=(b|m-112<<10|f>>1)+(f&1));a[d++]=b&255;a[d++]=b>>>8&255;return d};a.prototype.writeChar_=function(a,b,d){a[d++]=b.charCodeAt(0);return d};a.prototype.buildType_= -function(){this.setReader_();this.setWriter_();this.float&&(this.min=-Infinity,this.max=Infinity)};a.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_:32this.max&&(a-=2*this.max+2);return a};a.prototype.overflow=function(a){a>this.max?a=this.max:athis.bits?1:this.realBits/8;this.setReader_();this.setWriter_();this.float||this.setMinMax_()};a.prototype.setReader_=function(){this.reader=this.char?c.BitReader.readChar:c.BitReader["read"+(8>this.bits?8:this.realBits)+"Bit"+(this.float?"Float":"")]};a.prototype.setWriter_=function(){this.writer=this.char?c.BitWriter.writeString:c.BitWriter["write"+this.realBits+"Bit"+(this.float?"Float":"")]};a.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)};a.prototype.setRealBits_=function(){this.realBits=8=this.bits?16:24>=this.bits?24:32>=this.bits?32:40>=this.bits?40:48>=this.bits?48:53>=this.bits?53:64:this.bits};g.exports=a},function(g,a,h){g.exports.alaw=h(17);g.exports.mulaw=h(18)},function(g,a,h){h(0);var c=h(9),k=h(3),e=h(10),b=h(12),l=h(16),n=h(5).alaw,f=h(5).mulaw;g=function(d){var a=e.call(this)||this;d&&a.fromBuffer(d);return a};$jscomp.inherits(g,e);g.prototype.fromScratch= -function(d,a,b,f,e){e=void 0===e?{}:e;this.validBitsPerSample=this.cbSize=0;this.factChunkId="";this.factChunkSize=0;this.factChunkData=[];this.dwSampleLength=0;e.container||(e.container="RIFF");var m=parseInt(b,10)/8;this.chunkSize=36+f.length*m;this.fmtChunkSize=16;this.byteRate=d*m*a;this.blockAlign=d*m;this.chunkId=e.container;this.format="WAVE";this.fmtChunkId="fmt ";this.audioFormat=this.headerFormats_[b];this.numChannels=d;this.sampleRate=a;this.bitsPerSample=parseInt(b,10);this.dataChunkId= -"data";this.dataChunkSize=f.length*m;this.samples=f;this.bitDepth=b;"4"==b&&(this.chunkSize=44+f.length,this.fmtChunkSize=20,this.byteRate=4055,this.blockAlign=256,this.bitsPerSample=4,this.dataChunkSize=f.length,this.cbSize=2,this.validBitsPerSample=505,this.factChunkId="fact",this.factChunkSize=4,this.dwSampleLength=2*f.length);if("8a"==b||"8m"==b)this.chunkSize=44+f.length,this.fmtChunkSize=20,this.cbSize=2,this.validBitsPerSample=8,this.factChunkId="fact",this.factChunkSize=4,this.dwSampleLength= -f.length};g.prototype.fromBuffer=function(d){this.readRIFFChunk_(d);var a="RIFX"==this.chunkId;d=b.read(d,a);this.readFmtChunk_(d.subChunks);this.readFactChunk_(d.subChunks);this.readBextChunk_(d.subChunks);this.readCueChunk_(d.subChunks);this.readDataChunk_(d.subChunks,{be:a,single:!0});this.bitDepth=3==this.audioFormat&&32==this.bitsPerSample?"32f":this.bitsPerSample.toString()};g.prototype.toBuffer=function(){this.checkWriteInput_();return new Uint8Array(this.createWaveFile_())};g.prototype.toRIFF= -function(){this.chunkId="RIFF";this.LEorBE()};g.prototype.toRIFX=function(){this.chunkId="RIFX";this.LEorBE()};g.prototype.toBitDepth=function(d){c.toBitDepth(this.samples,this.bitDepth,d);this.fromScratch(this.numChannels,this.sampleRate,d,this.samples,{container:this.chunkId})};g.prototype.interleave=function(){var d=[],a,b,f=this.samples[0].length;for(a=0;athis.numChannels||65535this.sampleRate||4294967295this.max&&(a-=2*this.max+2);return a};a.prototype.overflow=function(a){a> -this.max?a=this.max:a>>0;return this.overflow(this.sign(e))};a.prototype.readBits_=function(a,c,k){k=void 0===k?this:k;for(var e="",b=0;bthis.bits?1:Math.ceil(this.realBits/8)};a.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)};a.prototype.validateWordSize_=function(){if(1>this.bits||64=this.bits?16:24>=this.bits?24:32>=this.bits?32:40>=this.bits?40:48>=this.bits?48:56>=this.bits?56:64:this.bits};a.prototype.setLastByteMask_=function(){var a=8-(this.realBits-this.bits);this.lastByteMask=Math.pow(2,0e.bits?a[k++]=0>c?c+Math.pow(2,e.bits):c:a[k++]=c&255;return k};g.exports=a},function(g,a){var h=new Float32Array(1),c={8:256,16:65536,24:16777216, -32:4294967296,"32f":1,64:1},k={intToInt:function(a,b){return a=0b.bits?b.bits:b.realBits/8),e.getType(b,f));return a=b.char?a.slice(0,b.bits/8):a[0]}var e=h(14),b=h(4);a.pack=c;a.unpack=k;a.packArray=function(a, -b,f){return e.toBytes(a,e.getType(b,void 0===f?10:f))};a.unpackArray=function(a,b,f){return e.fromBytes(a,e.getType(b,void 0===f?10:f))};a.unpackStruct=function(a,b,f){f=void 0===f?10:f;for(var d=a.length,c=0,e=0;eb[c].bits?1:b[c].realBits/8;d=d.concat(k(a.slice(e,e+g),b[c],f));e+=g;c++}return d};a.packStruct=function(a,b,f){f=void 0===f?10:f;if(a.lengthb.realBits?(2==b.base?b.bits:5>b.bits?1:2)+1:(2==b.base?8:2)+1;a>10;b=d&1023;return(a?Math.pow(2,a-15)*(1+b/1024):b/1024*.00006103515625)*(d>>15?-1:1)},read24Bit:function(a,b){return a[2+b]<<16|l.read16Bit(a,b)},read32Bit:function(a,b){return(a[3+b]<<24|l.read24Bit(a,b))>>>0},read32BitFloat:function(a,b){k[0]=l.read32Bit(a,b);return c[0]},read40Bit:function(a,b){return h(a,b,5)},read48Bit:function(a,b){return h(a,b,6)},read53Bit:function(a,b){return h(a,b,7)},read64BitFloat:function(a,d){b[0]=l.read32Bit(a, -d);b[1]=l.read32Bit(a,d+4);return e[0]},readChar:function(a,b,c){var d="",e=0;for(c=c.bits/8;e>>24&255;return c},write24Bit:function(a,b,c){c=n.write16Bit(a,b,c);a[c++]=b>>>16&255;return c},write16Bit:function(a,b,c){a[c++]=b&255;a[c++]=b>>>8&255;return c},write16BitFloat:function(a,b,e){c[0]=b;var d=k[0];b=d>>16&32768;var f=d>>12&2047;d=d>>23&255;103<=d&&(b=(b|d-112<<10|f>>1)+(f&1));a[e]=b&255;a[e+1]=b>>>8&255;return e+2},write8Bit:function(a, -b,c){a[c++]=b&255;return c},write4Bit:function(a,b,c){a[c++]=b&15;return c},write2Bit:function(a,b,c){a[c++]=0>b?b+4:b;return c},write1Bit:function(a,b,c){a[c++]=b?1:0;return c},writeString:function(a,b,c){a[c++]=b.charCodeAt(0);return c}};a.BitWriter=n;a.BitReader=l},function(g,a,h){function c(a){a-=m;if(0<=a)var b=0;else b=8,a=-a;var c=d[r],e=c>>3;a>c&&(b|=4,a-=c,e+=c);c>>=1;a>c&&(b|=2,a-=c,e+=c);c>>=1;a>c&&(b|=1,e+=c);m=b&8?m-e:m+e;-32768>m?m=-32768:32767r?r=0:88>1);a&1&&(b+=t>>2);b+=t>>3;a&8&&(b=-b);p+=b;32767p&&(p=-32767);q+=f[a];0>q?q=0:88e.length;)e.push(0);return e}function b(a){p=l.unpack([a[0],a[1]],n);q=a[2];t=d[q];for(var b=[p,l.unpack([a[2],a[3]],n)],c=4;c>4;b.push(k(f<<4^e));b.push(k(f))}return b}var l=h(0),n=l.int16,f=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],d=[7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767],m=0,r= -0,p=0,q=0,t=7;g.exports.encode=function(a){for(var b=[],c=[],d=0;d>8&128)||(a*=-1);32635>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<a){a=132-a;var c=127}else a+=132,c=255;32767>7;g&240&&(g>>=4,b+=4);g&12&&(g>>=2,b+=2);g&2&&(b+=1);g=b;return(g<<4|a>>g+3&15)^c}function c(a){a=~a;var c=((a&15)<<3)+132<<((a&112)>>4);return a&128?132-c:c-132}g.exports.encodeSample=h;g.exports.decodeSample=c;g.exports.encode=function(a){for(var c=[],b=0;ba.bits?a.bits:a.realBits/8),f.getType(a,g));return c=a.char?c.slice(0,a.bits/8):c[0]}var f=k(7),c=k(1);b.exports.pack=e;b.exports.unpack=h;b.exports.packArray=function(c,a,g){return f.toBytes(c,f.getType(a,void 0===g?10:g))};b.exports.unpackArray=function(c,a,g){return f.fromBytes(c,f.getType(a,void 0=== +g?10:g))};b.exports.unpackStruct=function(c,a,g){g=void 0===g?10:g;for(var d=c.length,n=0,b=0;ba[n].bits?1:a[n].realBits/8;d=d.concat(h(c.slice(b,b+f),a[n],g));b+=f;n++}return d};b.exports.packStruct=function(c,a,g){g=void 0===g?10:g;if(c.length>10;var d=c&1023;return(a?Math.pow(2,a-15)*(1+d/1024):d/1024*.00006103515625)* +(c>>15?-1:1)};a.prototype.read32F_=function(c,a){h[0]=this.read_(c,a,{bits:32,offset:4});return e[0]};a.prototype.read64F_=function(a,b){c[0]=this.read_(a,b,{bits:32,offset:4});c[1]=this.read_(a,b+4,{bits:32,offset:4});return f[0]};a.prototype.readChar_=function(c,a){for(var d="",b=0;b>16&32768;var g=b>>12&2047;b=b>>23&255;103<=b&&(a=(a|b-112<<10|g>>1)+(g&1));c[d++]=a&255;c[d++]=a>>>8&255;return d};a.prototype.writeChar_=function(c,a,d){c[d++]=a.charCodeAt(0);return d};a.prototype.buildType_=function(){this.setReader_();this.setWriter_();this.float&&(this.min=-Infinity,this.max=Infinity)};a.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_:32this.max&&(a-=2*this.max+2);return a};a.prototype.overflow=function(a){a>this.max?a=this.max:athis.bits?1:this.realBits/8;this.setReader_();this.setWriter_();this.float||this.setMinMax_()}; +a.prototype.setReader_=function(){this.reader=this.char?e.BitReader.readChar:e.BitReader["read"+(8>this.bits?8:this.realBits)+"Bit"+(this.float?"Float":"")]};a.prototype.setWriter_=function(){this.writer=this.char?e.BitWriter.writeString:e.BitWriter["write"+this.realBits+"Bit"+(this.float?"Float":"")]};a.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)};a.prototype.setRealBits_=function(){this.realBits=8= +this.bits?16:24>=this.bits?24:32>=this.bits?32:40>=this.bits?40:48>=this.bits?48:53>=this.bits?53:64:this.bits};b.exports=a},function(b,a,k){b.exports.alaw=k(17);b.exports.mulaw=k(18)},function(b,a,k){k(0);var e=k(9),h=k(3),f=k(10),c=k(12),l=k(16),m=k(5).alaw,g=k(5).mulaw;b=function(d){var a=f.call(this)||this;d&&a.fromBuffer(d);return a};$jscomp.inherits(b,f);b.prototype.fromScratch=function(d,a,c,b,g){g=void 0===g?{}:g;this.validBitsPerSample=this.cbSize=0;this.factChunkId="";this.factChunkSize= +0;this.factChunkData=[];this.dwSampleLength=0;g.container||(g.container="RIFF");var n=parseInt(c,10)/8;this.chunkSize=36+b.length*n;this.fmtChunkSize=16;this.byteRate=d*n*a;this.blockAlign=d*n;this.chunkId=g.container;this.format="WAVE";this.fmtChunkId="fmt ";this.audioFormat=this.headerFormats_[c];this.numChannels=d;this.sampleRate=a;this.bitsPerSample=parseInt(c,10);this.dataChunkId="data";this.dataChunkSize=b.length*n;this.samples=b;this.bitDepth=c;"4"==c&&(this.chunkSize=44+b.length,this.fmtChunkSize= +20,this.byteRate=4055,this.blockAlign=256,this.bitsPerSample=4,this.dataChunkSize=b.length,this.cbSize=2,this.validBitsPerSample=505,this.factChunkId="fact",this.factChunkSize=4,this.dwSampleLength=2*b.length);if("8a"==c||"8m"==c)this.chunkSize=44+b.length,this.fmtChunkSize=20,this.cbSize=2,this.validBitsPerSample=8,this.factChunkId="fact",this.factChunkSize=4,this.dwSampleLength=b.length};b.prototype.fromBuffer=function(d){this.readRIFFChunk_(d);var a="RIFX"==this.chunkId;d=c.read(d,a);this.readFmtChunk_(d.subChunks); +this.readFactChunk_(d.subChunks);this.readBextChunk_(d.subChunks);this.readCueChunk_(d.subChunks);this.readDataChunk_(d.subChunks,{be:a,single:!0});this.bitDepth=3==this.audioFormat&&32==this.bitsPerSample?"32f":this.bitsPerSample.toString()};b.prototype.toBuffer=function(){this.checkWriteInput_();return new Uint8Array(this.createWaveFile_())};b.prototype.toRIFF=function(){this.chunkId="RIFF";this.LEorBE()};b.prototype.toRIFX=function(){this.chunkId="RIFX";this.LEorBE()};b.prototype.toBitDepth=function(d){e.toBitDepth(this.samples, +this.bitDepth,d);this.fromScratch(this.numChannels,this.sampleRate,d,this.samples,{container:this.chunkId})};b.prototype.interleave=function(){var d=[],a,c,b=this.samples[0].length;for(a=0;athis.numChannels||65535this.sampleRate||4294967295this.max&&(a-=2*this.max+2);return a};a.prototype.overflow=function(a){a>this.max?a=this.max:a>>0;return this.overflow(this.sign(f))};a.prototype.readBits_=function(a,b,h){h=void 0===h?this:h;for(var f="",c=0;cthis.bits?1:Math.ceil(this.realBits/8)};a.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)};a.prototype.validateWordSize_=function(){if(1>this.bits||64=this.bits?16:24>=this.bits?24:32>=this.bits? +32:40>=this.bits?40:48>=this.bits?48:56>=this.bits?56:64:this.bits};a.prototype.setLastByteMask_=function(){var a=8-(this.realBits-this.bits);this.lastByteMask=Math.pow(2,0f.bits?a[h++]=0>b?b+Math.pow(2,f.bits):b:a[h++]=b&255;return h};b.exports=a},function(b,a){var k=new Float32Array(1),e={8:256,16:65536,24:16777216,32:4294967296,"32f":1,64:1},h={intToInt:function(a,c){return a=0c.bits?c.bits:c.realBits/8),f.getType(c,b));return a=c.char?a.slice(0,c.bits/8):a[0]}var f=k(14),c=k(4);a.pack=e;a.unpack=h;a.packArray=function(a,c,b){return f.toBytes(a,f.getType(c,void 0===b?10:b))};a.unpackArray=function(a,c,b){return f.fromBytes(a,f.getType(c,void 0===b?10:b))};a.unpackStruct= +function(a,c,b){b=void 0===b?10:b;for(var d=a.length,g=0,f=0;fc[g].bits?1:c[g].realBits/8;d=d.concat(h(a.slice(f,f+e),c[g],b));f+=e;g++}return d};a.packStruct=function(a,c,b){b=void 0===b?10:b;if(a.lengthc.realBits?(2==c.base?c.bits:5>c.bits?1:2)+1:(2==c.base?8:2)+1;a>10;c=b&1023;return(a?Math.pow(2,a-15)*(1+c/1024):c/1024*.00006103515625)*(b>>15?-1:1)},read24Bit:function(a, +c){return a[2+c]<<16|l.read16Bit(a,c)},read32Bit:function(a,c){return(a[3+c]<<24|l.read24Bit(a,c))>>>0},read32BitFloat:function(a,c){h[0]=l.read32Bit(a,c);return e[0]},read40Bit:function(a,c){return k(a,c,5)},read48Bit:function(a,c){return k(a,c,6)},read53Bit:function(a,c){return k(a,c,7)},read64BitFloat:function(a,b){c[0]=l.read32Bit(a,b);c[1]=l.read32Bit(a,b+4);return f[0]},readChar:function(a,c,b){var d="",e=0;for(b=b.bits/8;e>>24&255; +return b},write24Bit:function(a,c,b){b=m.write16Bit(a,c,b);a[b++]=c>>>16&255;return b},write16Bit:function(a,c,b){a[b++]=c&255;a[b++]=c>>>8&255;return b},write16BitFloat:function(a,c,b){e[0]=c;var d=h[0];c=d>>16&32768;var f=d>>12&2047;d=d>>23&255;103<=d&&(c=(c|d-112<<10|f>>1)+(f&1));a[b]=c&255;a[b+1]=c>>>8&255;return b+2},write8Bit:function(a,c,b){a[b++]=c&255;return b},write4Bit:function(a,c,b){a[b++]=c&15;return b},write2Bit:function(a,c,b){a[b++]=0>c?c+4:c;return b},write1Bit:function(a,c,b){a[b++]= +c?1:0;return b},writeString:function(a,c,b){a[b++]=c.charCodeAt(0);return b}};a.BitWriter=m;a.BitReader=l},function(b,a,k){function e(a){a-=n;if(0<=a)var c=0;else c=8,a=-a;var b=d[r],e=b>>3;a>b&&(c|=4,a-=b,e+=b);b>>=1;a>b&&(c|=2,a-=b,e+=b);b>>=1;a>b&&(c|=1,e+=b);n=c&8?n-e:n+e;-32768>n?n=-32768:32767r?r=0:88>1);a&1&&(c+=t>>2);c+=t>>3;a&8&&(c=-c);p+=c;32767p&&(p=-32767);q+=g[a];0>q?q=0:88b.length;)b.push(0);return b}function c(a){p=l.unpack([a[0],a[1]],m);q=a[2];t=d[q];for(var c=[p,l.unpack([a[2],a[3]],m)],b=4;b>4;c.push(h(f<<4^e));c.push(h(f))}return c}var l=k(0),m=l.int16,g=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],d=[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;b.exports.encode=function(a){for(var c=[],b=[],d=0;d>8&128)||(a*=-1);32635>8&127],a=b<<4|a>>b+3&15):a>>=4;return a^c^85}function e(a){var b=0;a^=85;a&128&&(a&=-129,b=-1);var c=((a&240)>>4)+4;a=4!=c?1< +a){a=132-a;var b=127}else a+=132,b=255;32767>7;e&240&&(e>>=4,c+=4);e&12&&(e>>=2,c+=2);e&2&&(c+=1);e=c;return(e<<4|a>>e+3&15)^b}function e(a){a=~a;var b=((a&15)<<3)+132<<((a&112)>>4);return a&128?132-b:b-132}b.exports.encodeSample=k;b.exports.decodeSample=e;b.exports.encode=function(a){for(var b=[],c=0;c} */ this.bextChunkData = []; - /** @type {!Object} */ + /** @type {Object} */ this.bextChunkFields = { "description": "", //256 "originator": "", //32 "originatorReference": "", //32 "originationDate": "", //10 "originationTime": "", //8 - "timeReferenceLow": "", //DWORD - "timeReferenceHigh": "", //DWORD + "timeReference": "", //64-bit value "version": "", //WORD - "UMID_0 ": "", //byte - "UMID_63 ": "", //byte + "UMID": "", // 64 "loudnessValue": "", //WORD "loudnessRange": "", //WORD "maxTruePeakLevel": "", //WORD diff --git a/docs/WaveFile.html b/docs/WaveFile.html index 5ca36cf..e88f52d 100644 --- a/docs/WaveFile.html +++ b/docs/WaveFile.html @@ -2079,7 +2079,7 @@
Throws:

- Documentation generated by JSDoc 3.5.5 on Tue Apr 24 2018 23:24:21 GMT-0300 (Hora oficial do Brasil) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Wed Apr 25 2018 00:52:38 GMT-0300 (Hora oficial do Brasil) using the docdash theme.
diff --git a/docs/index.html b/docs/index.html index 717cdaa..0c94b45 100644 --- a/docs/index.html +++ b/docs/index.html @@ -56,6 +56,7 @@

About

wavefile is a module to work with wav files. I

  • Encode/decode files as ADPCM, A-Law and mu-Law
  • Read/write the data in a wav file header
  • Turn RIFF files to RIFX and RIFX files to RIFF
  • +
  • Edit BWF metada ("bext" chunk)
  • And more.

    wavefile is extensively tested and contains samples of all supported formats. Please note that some formats (like 8-bit A-Law and 64-bit floating point) are not widely supported and may not load in every player.

    @@ -152,8 +153,7 @@

    Use

    let fs = requi
     console.log(wav.dataChunkSize);
     
     // array of numbers
    -console.log(wav.samples);

    BWF data

    BWF data ("bext" chunk) is stored in the bextChunkFields property in human-readable form. -You may edit the data in the "bext" chunk by editing the bextChunkFields property on a WaveFile object.

    +console.log(wav.samples);

    BWF data

    BWF data ("bext" chunk) is stored in the bextChunkFields property in human-readable form.

    wav.bextChunkFields = {
         "description": "", // 256 chars
         "originator": "", // 32 chars
    @@ -208,7 +208,7 @@ 

    LICENSE

    Copyright (c) 2017-2018 Rafael da Silva Rocha.


    - Documentation generated by JSDoc 3.5.5 on Tue Apr 24 2018 23:24:21 GMT-0300 (Hora oficial do Brasil) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Wed Apr 25 2018 00:52:38 GMT-0300 (Hora oficial do Brasil) using the docdash theme.
    diff --git a/docs/index.js.html b/docs/index.js.html index 4363ce6..ade51b1 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -372,7 +372,7 @@

    index.js


    - Documentation generated by JSDoc 3.5.5 on Tue Apr 24 2018 23:24:21 GMT-0300 (Hora oficial do Brasil) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Wed Apr 25 2018 00:52:38 GMT-0300 (Hora oficial do Brasil) using the docdash theme.
    diff --git a/package.json b/package.json index 7984278..17c0d57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wavefile", - "version": "3.0.0", + "version": "3.0.1", "description": "Read & write wave files with 4, 8, 16, 24, 32 & 64-bit data.", "homepage": "https://github.com/rochars/wavefile", "author": "Rafael da Silva Rocha ", @@ -68,7 +68,7 @@ "dependencies": { "alawmulaw": "^2.0.1", "bitdepth": "^1.0.4", - "byte-data": "^4.0.2", + "byte-data": "^4.0.3", "imaadpcm": "^1.1.0", "riff-chunks": "^3.0.3" }, diff --git a/src/wavefile-header.js b/src/wavefile-header.js index ec3b8fe..b937888 100644 --- a/src/wavefile-header.js +++ b/src/wavefile-header.js @@ -88,18 +88,16 @@ class WaveFileHeader { this.bextChunkSize = 0; /** @type {!Array} */ this.bextChunkData = []; - /** @type {!Object} */ + /** @type {Object} */ this.bextChunkFields = { "description": "", //256 "originator": "", //32 "originatorReference": "", //32 "originationDate": "", //10 "originationTime": "", //8 - "timeReferenceLow": "", //DWORD - "timeReferenceHigh": "", //DWORD + "timeReference": "", //64-bit value "version": "", //WORD - "UMID_0 ": "", //byte - "UMID_63 ": "", //byte + "UMID": "", // 64 "loudnessValue": "", //WORD "loudnessRange": "", //WORD "maxTruePeakLevel": "", //WORD