diff --git a/dist/wavefile.js b/dist/wavefile.js index 33b068b..0d339c4 100644 --- a/dist/wavefile.js +++ b/dist/wavefile.js @@ -1,100 +1,104 @@ -try{if(!Uint8Array.prototype.slice)Object.defineProperty(Uint8Array.prototype,"slice",{value:function(begin,end){return new Uint8Array(Array.prototype.slice.call(this,begin,end))}})}catch(err){}var la="function"==typeof Object.create?Object.create:function(n){function m(){}m.prototype=n;return new m},E; -if("function"==typeof Object.setPrototypeOf)E=Object.setPrototypeOf;else{var M;a:{var ma={I:!0},O={};try{O.__proto__=ma;M=O.I;break a}catch(n){}M=!1}E=M?function(n,m){n.__proto__=m;if(n.__proto__!==m)throw new TypeError(n+" is not extensible");return n}:null}var P=E; -function Q(n,m){n.prototype=la(m.prototype);n.prototype.constructor=n;if(P)P(n,m);else for(var l in m)if("prototype"!=l)if(Object.defineProperties){var p=Object.getOwnPropertyDescriptor(m,l);p&&Object.defineProperty(n,l,p)}else n[l]=m[l]}var na="function"==typeof Object.defineProperties?Object.defineProperty:function(n,m,l){n!=Array.prototype&&n!=Object.prototype&&(n[m]=l.value)},oa="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this; -function R(n,m){if(m){for(var l=oa,p=n.split("."),z=0;zw&&(w=Math.max(w+z,0));wp||56319m||57343v&&(v=Math.max(v+u,0));vu||56319l||57343>>0)+"_",u=0;return l}); +L("Symbol.iterator",function(h){if(h)return h;h=Symbol("Symbol.iterator");for(var l="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),m=0;mc;c++)b["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(c)]=c;c=.75*a.length;"="===a[a.length-1]&&(c--,"="===a[a.length-2]&&c--);c=new Uint8Array(c);for(var d=0,e=0;d< -a.length;d+=4){var f=b[a.charCodeAt(d)],h=b[a.charCodeAt(d+1)],k=b[a.charCodeAt(d+2)],v=b[a.charCodeAt(d+3)];c[e++]=f<<2|h>>4;c[e++]=(h&15)<<4|k>>2;c[e++]=(k&3)<<6|v&63}return c}function ta(a,b){return a=0parseInt(a,10)||"53">4;A.push(ca(ba<<4^aa,v));A.push(ca(ba,v))}e=A;d.set(e,f);f+=e.length;e=[]}e.push(a[h])}return d}function ya(a,b){var c=a[0];T(c,b);var d=[];d.push(c&255);d.push(c>>8&255);d.push(b.index);d.push(0);c=3;for(var e=a.length;c>3;c>e&&(d|=4,c-=e,f+=e);e>>=1;c>e&&(d|=2,c-=e,f+=e);e>>=1;c>e&&(d|=1,f+=e);c=d;b.m=c&8?b.m-f:b.m+f;-32768>b.m?b.m=-32768:32767b.index?b.index=0:88>1);a&1&&(c+=b.step>>2);c+=b.step>>3;a&8&&(c=-c);b.m+=c;32767b.m&&(b.m=-32767);b.index+=da[a];0>b.index?b.index=0:88>8&128;h||(f*=-1);32635>8&127];f=k<<4|f>>k+3&15}else f>>=4;b[e]=f^h^85}return b}function Da(a){for(var b=new Int16Array(a.length),c=0,d=a.length;c>4)+4;f=4!=k?1<>8&128;0!=h&&(f=-f);f+=132;32635>7&255];b[e]=~(h|k<<4|f>>k+3&15)}return b}function Ga(a){for(var b=new Int16Array(a.length),c=0,d=a.length;c>4&7;h=Ha[h]+((f&15)<f)b[c]=f,c++;else{var h=0,k=0;2047>=f?(h=1,k=192):65535>=f?(h=2,k=224):1114111>=f&&(h=3,k=240,d++);b[c]=(f>>6*h)+k;for(c++;0>6*(h-1)&63,c++,h--}d++}return c}function V(a){var b=Math.floor(a);a-=b;return.5>a?b:.5=k)b+=String.fromCharCode(k);else{var v= -0;194<=k&&223>=k?v=1:224<=k&&239>=k?(v=2,224===a[d]&&(e=160),237===a[d]&&(f=159)):240<=k&&244>=k?(v=3,240===a[d]&&(e=144),244===a[d]&&(f=143)):h=!0;k&=(1<<8-v-1)-1;for(var A=0;Af)h=!0;k=k<<6|a[d]&63;d++}h?b+=String.fromCharCode(65533):65535>=k?b+=String.fromCharCode(k):(k-=65536,b+=String.fromCharCode((k>>10&1023)+55296,(k&1023)+56320))}}return b}function x(a){var b=[];U(a,b);return b}function N(a,b,c,d){d=void 0===d?0:d;b=b||{};for(var e=fa(b.j,b.S,b.P),f=Math.ceil(b.j/8), -h=0,k=d,v=a.length;hb){b=new h(d.LPForder||ja[d.LPFType],c,b/2);c=0;for(d=e.length;cthis.max?this.max:athis.max&&(a-=2*this.max+2);return a};I.prototype.ga=function(a,b,c){Math.abs(b)>this.f-2*this.h&&(b=0>b?-Infinity:Infinity);var d=0>((b=+b)||1/b)?1:0>b?1:0;b=Math.abs(b);var e=Math.min(Math.floor(Math.log(b)/Math.LN2),1023),f=V(b/Math.pow(2,e)*Math.pow(2,this.c));b!== -b?(f=Math.pow(2,this.c-1),e=(1<=Math.pow(2,1-this.a)?(2<=f/Math.pow(2,this.c)&&(e+=1,f=1),e>this.a?(e=(1<=b;)a[f]=parseInt(e.substring(0,8),2),e=e.substring(8),f--,d++;return d};C.prototype.Ka=function(a){this.c=0;this.container=this.f(a,4);if(-1===this.Z.indexOf(this.container))throw Error("Not a supported format."); -this.a.u="RIFX"===this.container;this.chunkSize=this.b(a);this.format=this.f(a,4);this.Y={chunkId:this.container,chunkSize:this.chunkSize,format:this.format,subChunks:this.V(a)}};C.prototype.o=function(a,b){b=void 0===b?!1:b;for(var c=this.Y.subChunks,d=[],e=0;ec;c++)this.cart.postTimer.push({usage:this.f(a,4),value:this.b(a)});this.cart.reserved=this.f(a,276);this.cart.url=this.f(a,1024);this.cart.tagText=this.f(a,b.chunkSize-2048)}};u.prototype.Aa=function(a){var b=this.o("iXML");b&&(this.c=b.chunkData.start,this.iXML.chunkId=b.chunkId,this.iXML.chunkSize=b.chunkSize,this.iXML.value=F(a,this.c,this.c+ -this.iXML.chunkSize))};u.prototype.ma=function(a){var b=this.o("ds64");if(b)this.c=b.chunkData.start,this.ds64.chunkId=b.chunkId,this.ds64.chunkSize=b.chunkSize,this.ds64.riffSizeHigh=this.b(a),this.ds64.riffSizeLow=this.b(a),this.ds64.dataSizeHigh=this.b(a),this.ds64.dataSizeLow=this.b(a),this.ds64.originationTime=this.b(a),this.ds64.sampleCountHigh=this.b(a),this.ds64.sampleCountLow=this.b(a);else if("RF64"==this.container)throw Error('Could not find the "ds64" chunk');};u.prototype.ta=function(a){var b= -this.o("LIST",!0);if(null!==b)for(var c=0;cb;b++){var c="",d=4294967295;b>=1,d|=b&c,c>>=8;b=10+d;a[5]&2&&(b+=10)}return b};B.prototype.D=function(a){this.A(a);this.numChannels="mono"== -this.channelMode?1:2;this.c=this.g[this.version][this.layer];this.frameSize=this.v();this.sampleLength=this.G(a)};B.prototype.G=function(a){return Math.floor((a.length-this.b)/this.frameSize)*this.c};B.prototype.v=function(){return this.w(this.c,this.layer,this.bitRate,this.sampleRate,this.padding)};B.prototype.w=function(a,b,c,d,e){return 1E3*c/8*a/d+(e?1:0)*(1==b?4:1)|0};B.prototype.A=function(a){for(var b=[],c=0;4>c;c++)b[c]=this.F(a);if(255!==b[0]||224!==(b[1]&224))throw Error("Invalid frame header: [255, 224] != ["+ -b[0]+", "+b[1]+"]");this.version=this.l[b[1]>>3&3];this.layer=this.i[b[1]>>1&3];this.errorProtection=!(b[1]&1);this.bitRate=this.f[this.version][this.layer][b[2]>>4&15];this.sampleRate=this.o[this.version][b[2]>>2&3];this.padding=b[2]&2?!0:!1;this.privateBit=b[2]&1?!0:!1;this.channelMode=this.h[b[3]>>6&3];this.modeExtension=b[3]>>6&3;this.copyright=b[3]&8?!0:!1;this.original=b[3]&4?!0:!1;this.emphasis=b[3]&3};B.prototype.F=function(a){a=a[this.a];this.a+=1;return a};Q(r,t);r.prototype.fromScratch= -function(a,b,c,d,e){e=e||{};this.J();this.W(a,b,c,d,e)};r.prototype.fromMpeg=function(a,b){b=void 0===b?null:b;this.J();null==b&&(b=new B(a));var c=this.sb(b);this.container="RIFF";this.chunkSize=694+c.length+a.length;this.format="WAVE";this.bitDepth="65535";this.fmt.chunkId="fmt ";this.fmt.chunkSize=40;this.fmt.audioFormat=80;this.fmt.numChannels=b.numChannels;this.fmt.sampleRate=b.sampleRate;this.fmt.byteRate=b.bitRate/8*1E3;this.fmt.blockAlign=b.frameSize;this.fmt.bitsPerSample=65535;this.fmt.cbSize= -22;this.fmt.headLayer=Math.pow(2,b.layer-1);this.fmt.headBitRate=1E3*b.bitRate;this.fmt.headMode=this.vb(b);this.fmt.headModeExt=this.ub(b);this.fmt.headEmphasis=b.emphasis+1;this.fmt.headFlags=this.tb(b);this.fmt.ptsLow=0;this.fmt.ptsHigh=0;this.mext.chunkId="mext";this.mext.chunkSize=12;this.mext.soundInformation=this.wb(b);this.mext.frameSize=b.frameSize;this.mext.ancillaryDataLength=0;this.mext.ancillaryDataDef=0;this.mext.reserved="";this.bext.chunkId="bext";this.bext.chunkSize=602+c.length; -this.bext.timeReference=[0,0];this.bext.version=1;this.bext.codingHistory=c;this.fact.chunkId="fact";this.fact.chunkSize=4;this.fact.dwSampleLength=b.sampleLength;this.data.chunkId="data";this.data.samples=a;this.data.chunkSize=this.data.samples.length};r.prototype.wb=function(a){var b=0;a.eb&&(b+=1);a.padding||(b+=2);44100!=a.sampleRate&&22050!=a.sampleRate||!a.padding||(b+=4);a.freeForm&&(b+=8);return b};r.prototype.vb=function(a){return{stereo:1,"joint-stereo":2,"dual-mono":4,mono:8}[a.channelMode]}; -r.prototype.ub=function(a){return"joint-stereo"==a.channelMode?Math.pow(2,a.modeExtension):0};r.prototype.sb=function(a){return"A=MPEG"+a.version+"L"+a.layer+",F="+a.sampleRate+",B="+a.bitRate+",M="+a.channelMode+",T=wavefile\r\n\x00\x00"};r.prototype.tb=function(a){var b=0;a.privateBit&&(b+=1);a.copyright&&(b+=2);a.original&&(b+=4);a.errorProtection&&(b+=8);0this.data.samples.length)throw Error("Range error");return K(this.data.samples.slice(a,a+this.g.j/8),this.g)};r.prototype.setSample=function(a,b){a*=this.g.j/8;if(a+this.g.j/8>this.data.samples.length)throw Error("Range error");N([b],this.g,this.data.samples,void 0===a?0:a)};r.prototype.getiXML=function(){return this.iXML.value};r.prototype.setiXML=function(a){if("string"!==typeof a)throw new TypeError("iXML value must be a string.");this.iXML.value=a;this.iXML.chunkId= -"iXML"};r.prototype.get_PMX=function(){return this._PMX.value};r.prototype.set_PMX=function(a){if("string"!==typeof a)throw new TypeError("_PMX value must be a string.");this._PMX.value=a;this._PMX.chunkId="_PMX"};r.prototype.W=function(a,b,c,d,e){e.container||(e.container="RIFF");this.container=e.container;this.bitDepth=c;var f=[];if(0parseInt(this.bitDepth,10)))throw Error("Invalid bit depth.");};r.prototype.$= -function(){this.g={j:(parseInt(this.bitDepth,10)-1|7)+1,S:"32f"==this.bitDepth||"64"==this.bitDepth,P:"8"!=this.bitDepth,u:"RIFX"==this.container};-1<["4","8a","8m"].indexOf(this.bitDepth)&&(this.g.j=8,this.g.P=!1)};r.prototype.aa=function(){this.Ma();var a=this.fmt.numChannels;if(1>a||65535a||4294967295c.length)for(var d=0,e=4-c.length;d -b.dwSampleOffset&&!c?(this.w(b,d+1),this.w(a[d],d+2),c=!0):this.w(a[d],c?d+2:d+1);c||this.w(b,this.cue.points.length+1)};y.prototype.H=function(){for(var a=0,b=this.LIST.length;aa||4294967295>2],b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[c]&3)<<4|a[c+1]>>4],b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[c+1]&15)<<2|a[c+ -2]>>6],b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[c+2]&63];2===a.length%3?b=b.substring(0,b.length-1)+"=":1===a.length%3&&(b=b.substring(0,b.length-2)+"==");return b};m.prototype.toDataURI=function(){return"data:audio/wav;base64,"+this.toBase64()};m.prototype.fromDataURI=function(a){this.fromBase64(a.replace("data:audio/wav;base64,",""))};n.WaveFile=m;Object.defineProperty(n,"__esModule",{value:!0})} -"object"===typeof exports&&"undefined"!==typeof module?X(exports):"function"===typeof define&&define.amd?define(["exports"],X):(W=W||self,X(W.wavefile={})); +riffSizeLow:0,dataSizeHigh:0,dataSizeLow:0,originationTime:0,sampleCountHigh:0,sampleCountLow:0};a.data={chunkId:"",chunkSize:0,samples:new Uint8Array(0)};a.LIST=[];a.junk={chunkId:"",chunkSize:0,chunkData:[]};a._PMX={chunkId:"",chunkSize:0,value:""};a.m={s:16,D:!1,T:!1,V:!1};return a}function F(){this.container="";this.chunkSize=0;this.format="";this.aa=null;this.i=0;this.g={s:32,D:!1};this.ba=["RIFF","RIFX"]}function P(a,b){this.offset=Math.ceil((a+b)/8);this.h=a;this.i=b;this.g=(1<parseInt(a,10)||"53">3;c>e&&(d|=4,c-=e,f+=e);e>>=1;c>e&&(d|=2,c-=e,f+=e);e>>=1;c>e&&(d|=1,f+=e);c=d;b.u=c&8?b.u-f:b.u+f;-32768>b.u?b.u=-32768:32767b.index? +b.index=0:88>1);a&1&&(c+=b.step>>2);c+=b.step>>3;a&8&&(c=-c);b.u+=c;32767b.u&&(b.u=-32767);b.index+=la[a];0>b.index?b.index=0:88f)b[c]=f,c++;else{var k=0,p=0;2047>=f?(k=1,p=192):65535>=f?(k=2,p=224):1114111>=f&&(k=3,p=240,d++);b[c]=(f>>6*k)+p;for(c++;0>6*(k-1)&63,c++,k--}d++}return c}function da(a){var b=Math.floor(a);a-=b;return.5>a?b:.5=p)b+=String.fromCharCode(p);else{var n=0;194<=p&& +223>=p?n=1:224<=p&&239>=p?(n=2,224===a[d]&&(e=160),237===a[d]&&(f=159)):240<=p&&244>=p?(n=3,240===a[d]&&(e=144),244===a[d]&&(f=143)):k=!0;p&=(1<<8-n-1)-1;for(var r=0;rf)k=!0;p=p<<6|a[d]&63;d++}k?b+=String.fromCharCode(65533):65535>=p?b+=String.fromCharCode(p):(p-=65536,b+=String.fromCharCode((p>>10&1023)+55296,(p&1023)+56320))}}return b}function B(a){var b=[];ca(a,b);return b}function S(a,b,c,d){d=void 0===d?0:d;b=b||{};for(var e=oa(b.s,b.V,b.T),f=Math.ceil(b.s/8),k=0,p=d, +n=a.length;kb){b=new k(d.LPForder||ra[d.LPFType],c,b/2);c=0;for(d=e.length;cthis.max?this.max:athis.max&&(a-=2*this.max+2);return a};P.prototype.ja=function(a,b,c){Math.abs(b)>this.j-2*this.m&&(b=0>b?-Infinity:Infinity);var d=0>((b=+b)||1/b)?1:0>b?1:0;b=Math.abs(b);var e=Math.min(Math.floor(Math.log(b)/Math.LN2),1023),f=da(b/Math.pow(2,e)*Math.pow(2,this.i));b!==b?(f=Math.pow(2,this.i-1), +e=(1<=Math.pow(2,1-this.g)?(2<=f/Math.pow(2,this.i)&&(e+=1,f=1),e>this.g?(e=(1<=b;)a[f]=parseInt(e.substring(0,8),2),e=e.substring(8),f--,d++;return d};F.prototype.Ra=function(a){this.i=0;this.container=this.j(a,4);if(-1===this.ba.indexOf(this.container))throw Error("Not a supported format."); +this.g.D="RIFX"===this.container;this.chunkSize=this.h(a);this.format=this.j(a,4);this.aa={chunkId:this.container,chunkSize:this.chunkSize,format:this.format,subChunks:this.Y(a)}};F.prototype.A=function(a,b){b=void 0===b?!1:b;for(var c=this.aa.subChunks,d=[],e=0;ec;c++)this.cart.postTimer.push({usage:this.j(a,4),value:this.h(a)});this.cart.reserved=this.j(a,276);this.cart.url=this.j(a,1024);this.cart.tagText=this.j(a,b.chunkSize-2048)}};y.prototype.Ha=function(a){var b=this.A("iXML");b&&(this.i=b.chunkData.start,this.iXML.chunkId=b.chunkId,this.iXML.chunkSize=b.chunkSize,this.iXML.value=M(a,this.i,this.i+ +this.iXML.chunkSize))};y.prototype.va=function(a){var b=this.A("ds64");if(b)this.i=b.chunkData.start,this.ds64.chunkId=b.chunkId,this.ds64.chunkSize=b.chunkSize,this.ds64.riffSizeHigh=this.h(a),this.ds64.riffSizeLow=this.h(a),this.ds64.dataSizeHigh=this.h(a),this.ds64.dataSizeLow=this.h(a),this.ds64.originationTime=this.h(a),this.ds64.sampleCountHigh=this.h(a),this.ds64.sampleCountLow=this.h(a);else if("RF64"==this.container)throw Error('Could not find the "ds64" chunk');};y.prototype.Aa=function(a){var b= +this.A("LIST",!0);if(null!==b)for(var c=0;cb;b++){var c="",d=4294967295;b>=1,d|=b&c,c>>=8;b=10+d;a[5]&2&&(b+=10)}return b};E.prototype.G=function(a){this.H(a);this.numChannels="mono"== +this.channelMode?1:2;this.i=this.l[this.version][this.layer];this.frameSize=this.C();this.sampleLength=this.K(a)};E.prototype.K=function(a){return Math.floor((a.length-this.h)/this.frameSize)*this.i};E.prototype.C=function(){return this.F(this.i,this.layer,this.bitRate,this.sampleRate,this.padding)};E.prototype.F=function(a,b,c,d,e){return 1E3*c/8*a/d+(e?1:0)*(1==b?4:1)|0};E.prototype.H=function(a){for(var b=[],c=0;4>c;c++)b[c]=this.J(a);if(255!==b[0]||224!==(b[1]&224))throw Error("Invalid frame header: [255, 224] != ["+ +b[0]+", "+b[1]+"]");this.version=this.v[b[1]>>3&3];this.layer=this.o[b[1]>>1&3];this.errorProtection=!(b[1]&1);this.bitRate=this.j[this.version][this.layer][b[2]>>4&15];this.sampleRate=this.A[this.version][b[2]>>2&3];this.padding=b[2]&2?!0:!1;this.privateBit=b[2]&1?!0:!1;this.channelMode=this.m[b[3]>>6&3];this.modeExtension=b[3]>>6&3;this.copyright=b[3]&8?!0:!1;this.original=b[3]&4?!0:!1;this.emphasis=b[3]&3};E.prototype.J=function(a){a=a[this.g];this.g+=1;return a};X(w,x);w.prototype.fromScratch= +function(a,b,c,d,e){e=e||{};this.M();this.Z(a,b,c,d,e)};w.prototype.fromMpeg=function(a,b){b=void 0===b?null:b;this.M();null==b&&(b=new E(a));var c=this.yb(b);this.container="RIFF";this.chunkSize=694+c.length+a.length;this.format="WAVE";this.bitDepth="65535";this.fmt.chunkId="fmt ";this.fmt.chunkSize=40;this.fmt.audioFormat=80;this.fmt.numChannels=b.numChannels;this.fmt.sampleRate=b.sampleRate;this.fmt.byteRate=b.bitRate/8*1E3;this.fmt.blockAlign=b.frameSize;this.fmt.bitsPerSample=65535;this.fmt.cbSize= +22;this.fmt.headLayer=Math.pow(2,b.layer-1);this.fmt.headBitRate=1E3*b.bitRate;this.fmt.headMode=this.na(b);this.fmt.headModeExt=this.ma(b);this.fmt.headEmphasis=b.emphasis+1;this.fmt.headFlags=this.zb(b);this.fmt.ptsLow=0;this.fmt.ptsHigh=0;this.mext.chunkId="mext";this.mext.chunkSize=12;this.mext.soundInformation=this.oa(b);this.mext.frameSize=b.frameSize;this.mext.ancillaryDataLength=0;this.mext.ancillaryDataDef=0;this.mext.reserved="";this.bext.chunkId="bext";this.bext.chunkSize=602+c.length; +this.bext.timeReference=[0,0];this.bext.version=1;this.bext.codingHistory=c;this.fact.chunkId="fact";this.fact.chunkSize=4;this.fact.dwSampleLength=b.sampleLength;this.data.chunkId="data";this.data.samples=a;this.data.chunkSize=this.data.samples.length};w.prototype.oa=function(a){var b=0;a.hb&&(b+=1);a.padding||(b+=2);44100!=a.sampleRate&&22050!=a.sampleRate||a.padding||(b+=4);a.freeForm&&(b+=8);return b};w.prototype.na=function(a){return{stereo:1,"joint-stereo":2,"dual-mono":4,mono:8}[a.channelMode]}; +w.prototype.ma=function(a){return"joint-stereo"==a.channelMode?Math.pow(2,a.modeExtension):0};w.prototype.yb=function(a){return"A=MPEG"+a.version+"L"+a.layer+",F="+a.sampleRate+",B="+a.bitRate+",M="+a.channelMode+",T=wavefile\r\n\x00\x00"};w.prototype.zb=function(a){var b=0;a.privateBit&&(b+=1);a.copyright&&(b+=2);a.original&&(b+=4);a.errorProtection&&(b+=8);0this.data.samples.length)throw Error("Range error");return Q(this.data.samples.slice(a,a+this.l.s/8),this.l)};w.prototype.setSample=function(a,b){a*=this.l.s/8;if(a+this.l.s/8>this.data.samples.length)throw Error("Range error");S([b],this.l,this.data.samples,void 0===a?0:a)};w.prototype.getiXML=function(){return this.iXML.value};w.prototype.setiXML=function(a){if("string"!==typeof a)throw new TypeError("iXML value must be a string.");this.iXML.value=a;this.iXML.chunkId= +"iXML"};w.prototype.get_PMX=function(){return this._PMX.value};w.prototype.set_PMX=function(a){if("string"!==typeof a)throw new TypeError("_PMX value must be a string.");this._PMX.value=a;this._PMX.chunkId="_PMX"};w.prototype.Z=function(a,b,c,d,e){e.container||(e.container="RIFF");this.container=e.container;this.bitDepth=c;var f=[];if(0parseInt(this.bitDepth,10)))throw Error("Invalid bit depth.");};w.prototype.ca= +function(){this.l={s:(parseInt(this.bitDepth,10)-1|7)+1,V:"32f"==this.bitDepth||"64"==this.bitDepth,T:"8"!=this.bitDepth,D:"RIFX"==this.container};-1<["4","8a","8m"].indexOf(this.bitDepth)&&(this.l.s=8,this.l.T=!1)};w.prototype.da=function(){this.Ta();var a=this.fmt.numChannels;if(1>a||65535a||4294967295c.length)for(var d=0,e=4-c.length;d +b.dwSampleOffset&&!c?(this.F(b,d+1),this.F(a[d],d+2),c=!0):this.F(a[d],c?d+2:d+1);c||this.F(b,this.cue.points.length+1)};A.prototype.L=function(){for(var a=0,b=this.LIST.length;a>8&255);K.push(C.index);K.push(0);D=3;for(var T=k.length;D>4;C.push(ma(U<<4^T,G));C.push(ma(U,G))}n=C;p.set(n,r);r+=n.length;n=[]}n.push(e[z])}b.call(this,c,d,"16",p,{container:this.C()});"16"!=a&&this.toBitDepth(a)};m.prototype.toALaw= +function(){this.K();var a=new Int16Array(R(this.data.samples.length,2));N(this.data.samples,this.l,a,0,this.data.samples.length);for(var b=this.B,c=this.fmt.numChannels,d=this.fmt.sampleRate,e=new Uint8Array(a.length),f=0,k=a.length;f>8&128;r||(n*=-1);32635>8&127];n=z<<4|n>>z+3&15}else n>>=4;e[p]=n^r^85}b.call(this,c,d,"8a",e,{container:this.C()})};m.prototype.fromALaw=function(a){a=void 0===a?"16":a;for(var b= +this.B,c=this.fmt.numChannels,d=this.fmt.sampleRate,e=this.data.samples,f=new Int16Array(e.length),k=0,p=e.length;k>4)+4;r=4!=I?1<>8&128;0!=r&&(n=-n);n+=132;32635>7&255];e[p]=~(r|z<<4|n>>z+3&15)}b.call(this,c,d,"8m",e,{container:this.C()})};m.prototype.fromMuLaw=function(a){a=void 0===a?"16":a;for(var b=this.B,c=this.fmt.numChannels,d=this.fmt.sampleRate,e=this.data.samples,f=new Int16Array(e.length),k=0,p=e.length;k>4&7;z=Ka[z]+((r&15)<a||4294967295d;d++)c["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(d)]=d;d=.75*a.length;"="===a[a.length-1]&&(d--,"="===a[a.length-2]&&d--);d=new Uint8Array(d);for(var e=0,f=0;e>4;d[f++]=(p&15)<<4|n>>2;d[f++]=(n&3)<<6|r&63}b.call(this,d)};l.prototype.toBase64=function(){for(var a=this.toBuffer(),b="",c=0;c>2],b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[c]&3)<<4|a[c+1]>>4],b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[c+1]&15)<<2|a[c+2]>>6],b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[c+ +2]&63];2===a.length%3?b=b.substring(0,b.length-1)+"=":1===a.length%3&&(b=b.substring(0,b.length-2)+"==");return b};l.prototype.toDataURI=function(){return"data:audio/wav;base64,"+this.toBase64()};l.prototype.fromDataURI=function(a){this.fromBase64(a.replace("data:audio/wav;base64,",""))};h.WaveFile=l;Object.defineProperty(h,"__esModule",{value:!0})} +"object"===typeof exports&&"undefined"!==typeof module?Z(exports):"function"===typeof define&&define.amd?define(["exports"],Z):(Y=Y||self,Z(Y.wavefile={})) diff --git a/docs/index.html b/docs/index.html index 18b718a..493bb2a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -57,19 +57,12 @@

-

wavefile

+

prx-wavefile

Copyright (c) 2017-2019 Rafael da Silva Rocha.
https://github.com/rochars/wavefile

NPM version Docs Tests
Codecov Unix Build Windows Build Scrutinizer CII Best Practices

-

MOVING AWAY FROM GITHUB (2020-03-08)

-

Microsoft, owner of GitHub, was one of the main backers of the current fascist regime in Brazil and also of the coup d'etat that led to the present situation of my country.

-

It paid well: The brazilian government was required to run all its systems on open-source software. After the coup d'etat this changed, the goverment began purchasing Microsoft licenses and migrating all their systems to Windows.

-

It is not just a case of business malpractice - there is a genocide going on in Brazil and many people, including myself, have lived under constant death threats for the past couple years bacause of our positions against the current fascist regime. Many have been murdered or incarcerated. Poverty and violence skyrocketed.

-

This software will keep being released in NPM as always - only the repository will be moved. Projects depending on this software will not be affected.

-

For Microsoft owners and collaborators: you have a lot of blood in your hands. I will not share my work with people of your kind.

-
-

wavefile

+

prx-wavefile

Create, read and write wav files according to the specs.

  • MIT licensed
  • @@ -79,7 +72,13 @@

    wavefile

  • Handle files up to 2GB
  • Zero dependencies
-

With wavefile you can:

+

prx-wavefile is a fork of the excellent wavefile project created by @rochars.

+

This fork also supports these additional features:

+ +

With prx-wavefile you can:

And more.

Install

@@ -101,15 +102,15 @@

Install

Use

Node

-
const wavefile = require('wavefile');
+
const wavefile = require("prx-wavefile");
 let wav = new wavefile.WaveFile();
 

or

-
const WaveFile = require('wavefile').WaveFile;
+
const WaveFile = require("prx-wavefile").WaveFile;
 let wav = new WaveFile();
 

or

-
import { WaveFile } from 'wavefile';
+
import { WaveFile } from "prx-wavefile";
 let wav = new WaveFile();
 

Browser

@@ -119,11 +120,11 @@

Browser

var wav = new wavefile.WaveFile(); </script>
-

Or load it from the jsDelivr CDN:

-
<script src="https://cdn.jsdelivr.net/npm/wavefile"></script>
+

Or load it from the jsDelivr CDN:

+
<script src="https://cdn.jsdelivr.net/npm/prx-wavefile"></script>
 
-

Or load it from unpkg:

-
<script src="https://unpkg.com/wavefile"></script>
+

Or load it from unpkg:

+
<script src="https://unpkg.com/prx-wavefile"></script>
 

Browser compatibility

IE10+. Should work in all modern browsers.

@@ -134,7 +135,7 @@

Command line use

wavefile --help
 

Node.js Example

-
const WaveFile = require('wavefile').WaveFile;
+
const WaveFile = require("prx-wavefile").WaveFile;
 
 // Load a wav file buffer as a WaveFile object
 let wav = new WaveFile(buffer);
@@ -169,6 +170,8 @@ 

Table of Contents

  • Change the bit depth
  • Change the sample rate
  • Add BWF metadata
  • +
  • Create BWF from MPEG
  • +
  • Cart Chunk
  • RF64
  • XML Chunks
  • The samples
  • @@ -198,16 +201,16 @@

    Mono:

    let wav = new WaveFile();
     
     // Create a mono wave file, 44.1 kHz, 32-bit and 4 samples
    -wav.fromScratch(1, 44100, '32', [0, -2147483, 2147483, 4]);
    +wav.fromScratch(1, 44100, "32", [0, -2147483, 2147483, 4]);
     fs.writeFileSync(path, wav.toBuffer());
     

    Stereo:

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

    // Stereo, 48 kHz, 8-bit, de-interleaved samples
     // WaveFile interleave the samples automatically
    -wav.fromScratch(2, 48000, '8', [
    -    [0, 2, 4, 3],
    -    [0, 1, 4, 3]
    +wav.fromScratch(2, 48000, "8", [
    +  [0, 2, 4, 3],
    +  [0, 1, 4, 3]
     ]);
     fs.writeFileSync(path, wav.toBuffer());
     
    @@ -225,7 +228,7 @@

    Stereo:

    A word on bit depth

    Resolutions other than 4-bit, 8-bit, 16-bit, 24-bit, 32-bit (integer), 32-bit (fp) and 64-bit (fp) are implemented as WAVE_FORMAT_EXTENSIBLE and may not be supported by some players.

    Read wave files

    -
    const WaveFile = require('wavefile').WaveFile;
    +
    const WaveFile = require("prx-wavefile").WaveFile;
     wav = new WaveFile();
     // Read a wav file from a buffer
     wav.fromBuffer(buffer);
    @@ -249,11 +252,11 @@ 

    Add RIFF tags to files

    Add cue points to files

    You can create cue points using the WaveFile.setCuePoint() method. The method takes a object with the cue point data and creates a cue point in the corresponding position of the file. The only required attribute of the object is position, a number representing the position of the point in milliseconds:

    // to create a cue point
    -wav.setCuePoint({position: 1500});
    +wav.setCuePoint({ position: 1500 });
     

    You can also create cue points with labels by defining a label attribute:

    // to create a cue point with a label
    -wav.setCuePoint({position: 1500, label: 'some label'});
    +wav.setCuePoint({ position: 1500, label: "some label" });
     

    To delete a cue point use WaveFile.deleteCuePoint() informing the index of the point. Points are ordered according to their position. The first point is indexed as 1.

    wav.deleteCuePoint(1);
    @@ -266,11 +269,11 @@ 

    Add cue points to files

    [
       {
         position: 500, // the position in milliseconds
    -    label: 'cue marker 1',
    +    label: "cue marker 1",
         end: 1500, // the end position in milliseconds
         dwName: 1,
         dwPosition: 0,
    -    fccChunk: 'data',
    +    fccChunk: "data",
         dwChunkStart: 0,
         dwBlockStart: 0,
         dwSampleOffset: 22050, // the position as a sample offset
    @@ -279,8 +282,8 @@ 

    Add cue points to files

    dwCountry: 0, dwLanguage: 0, dwDialect: 0, - dwCodePage: 0, - }, + dwCodePage: 0 + } //... ];
    @@ -288,7 +291,7 @@

    Create regions in files

    You can create regions using the WaveFile.setCuePoint() method. Regions are cue points with extra data.

    If you define a not null end attribute in the object describing the cue point, the point will be created as a region. The end attribute should be the end of the region, in milliseconds, counting from the start of the file, and always greater than the position of the point:

    // to create a region with a label:
    -wav.setCuePoint({position: 1500, end: 2500, label: 'some label'});
    +wav.setCuePoint({ position: 1500, end: 2500, label: "some label" });
     

    You can also define the following optional properties when creating a region:

      @@ -299,8 +302,8 @@

      Create regions in files

    • dwCodePage

    RIFX

    -

    wavefile can handle existing RIFX files and create RIFX files from scratch. Files created from scratch will default to RIFF; to create a file as RIFX you must define the container:

    -
    wav.fromScratch(1, 48000, '16', [0, 1, -3278, 327], {"container": "RIFX"});
    +

    WaveFile can handle existing RIFX files and create RIFX files from scratch. Files created from scratch will default to RIFF; to create a file as RIFX you must define the container:

    +
    wav.fromScratch(1, 48000, "16", [0, 1, -3278, 327], { container: "RIFX" });
     

    RIFX to RIFF and RIFF to RIFX:

    // Turn a RIFF file to a RIFX file
    @@ -314,7 +317,7 @@ 

    IMA-ADPCM

    // Encode a 16-bit wave file as 4-bit IMA-ADPCM:
     wav.toIMAADPCM();
     
    -

    IMA-ADPCM files compressed with wavefile will have a block align of 256 bytes.

    +

    IMA-ADPCM files compressed with WaveFile will have a block align of 256 bytes.

    If the audio is not 16-bit it will be converted to 16-bit before compressing. Compressing audio with sample rate different from 8000 Hz or more than one channel is not supported and will throw errors.

    To decode 4-bit IMA-ADPCM as 16-bit linear PCM:

    // Decode 4-bit IMA-ADPCM as 16-bit:
    @@ -379,7 +382,7 @@ 

    Change the sample rate

    To use another method:

    // Change the sample rate to 44.1kHz using sinc
    -wav.toSampleRate(44100, {method: "sinc"});
    +wav.toSampleRate(44100, { method: "sinc" });
     

    Resampling methods

      @@ -390,17 +393,17 @@

      Resampling methods

    You can turn the LPF on and off for any resampling method:

    // Will use 'sinc' method with no LPF
    -wav.toSampleRate(44100, {method: "sinc", LPF: false});
    +wav.toSampleRate(44100, { method: "sinc", LPF: false });
     
     // Will use 'linear' method with LPF
    -wav.toSampleRate(44100, {method: "linear", LPF: true});
    +wav.toSampleRate(44100, { method: "linear", LPF: true });
     

    The default LPF is a IIR LPF. You may define what type of LPF will be used by changing the LPFType attribute on the toSampleRate() param. You can use IIR or FIR:

    // Will use 'linear' method with a FIR LPF
    -wav.toSampleRate(44100, {method: "linear", LPF: true, LPFType: 'FIR'});
    +wav.toSampleRate(44100, { method: "linear", LPF: true, LPFType: "FIR" });
     
     // Will use 'linear' method with a IIR LPF, the default
    -wav.toSampleRate(44100, {method: "linear", LPF: true});
    +wav.toSampleRate(44100, { method: "linear", LPF: true });
     

    Changing the sample rate of ADPCM, mu-Law or A-Law

    You need to convert compressed files to standard PCM before resampling:

    @@ -408,7 +411,7 @@

    Changing the sample rate of ADPCM, mu-Law or A-Law

    // convert the file to PCM
     wav.fromMuLaw();
     // resample
    -wav.toSampleRate(44100, {method: "sinc"});
    +wav.toSampleRate(44100, { method: "sinc" });
     // back to mu-Law
     wav.toMuLaw();
     
    @@ -423,11 +426,55 @@

    Add BWF metadata

    // Write the new BWF file fs.writeFileSync("32bit-file-with-bext.wav", wav.toBuffer());
    -

    By default wavefile will not insert a "bext" chunk in new files or in files that do not already have a "bext" chunk unless a property of WaveFile.bext is changed from it's default value. See below the full list of properties in WaveFile.bext.

    +

    By default WaveFile will not insert a "bext" chunk in new files or in files that do not already have a "bext" chunk unless a property of WaveFile.bext is changed from it's default value. See below the full list of properties in WaveFile.bext.

    +

    Create From MPEG

    +

    Make a wav file from an mpeg audio file, with optional metadata, using WaveFile.fromMpeg(). +There is now an MPEG reader in prx-wavefile that is used to +read metadata from the MPEG and automatically set that in "fact", "fmt", "bext", and "mext" chunks.

    +

    The MPEG specific "mext" chunk is specified below in WaveFile.mext.

    +

    The optional info is specified below in WaveFile.mpegInfo.

    +
    // You can create a wav from just an MPEG audio buffer/stream.
    +let wav = new WaveFile();
    +wav.fromMpeg(fs.readFileSync("test.mp2"));
    +
    +// You can also pass in the mpeg metadata info if you prefer
    +// This is specified by WaveFile.mpegInfo
    +let info = {
    +  version: 1,
    +  layer: 2,
    +  sampleRate: 44100,
    +  bitRate: 128,
    +  channelMode: "stereo",
    +  padding: 1,
    +  modeExtension: 0,
    +  emphasis: 0,
    +  privateBit: 1,
    +  copyright: true,
    +  original: true,
    +  errorProtection: true,
    +  numChannels: 2,
    +  frameSize: 768,
    +  sampleLength: 269568,
    +  freeForm: true
    +};
    +let wav2 = new WaveFile();
    +wav2.fromMpeg(fs.readFileSync("test.mp2"), info);
    +
    +

    Add Cart Chunk

    +

    By default WaveFile will not insert a "cart" chunk in new files or in files that do not already have a "cart" chunk unless a property of WaveFile.cart is changed from it's default value. See below the full list of properties in WaveFile.cart.

    +
    let wav = new WaveFile();
    +wav.fromMpeg(fs.readFileSync("test.mp2"));
    +
    +// Use the wav.cart to set the values
    +wav.cart.chunkId = "cart";
    +wav.cart.cutId = "30000";
    +wav.cart.title = "Title";
    +wav.cart.artist = "Artist";
    +

    RF64

    -

    wavefile have limited support of RF64 files. It possible to read (at least some) RF64 files, but changing the bit depth or applying compression to the samples will result in a RIFF file.

    +

    WaveFile have limited support of RF64 files. It possible to read (at least some) RF64 files, but changing the bit depth or applying compression to the samples will result in a RIFF file.

    XML Chunks

    -

    wavefile support reading and writing iXML and _PMX chunks.

    +

    Wavefile support reading and writing iXML and _PMX chunks.

    To get the value of iXML or _PMX chunks:

    /** @type {string} */
     let iXMLValue = wav.getiXML();
    @@ -567,6 +614,14 @@ 

    The WaveFile methods

    */ WaveFile.fromScratch(numChannels, sampleRate, bitDepth, samples, options) {} +/** + * Set up the WaveFileCreator object from an mpeg buffer and metadata info. + * @param {!Uint8Array} mpegBuffer The buffer. + * @param {Object=} info Mpeg info such as version, layer, bitRate, etc. + * @throws {Error} If any argument does not meet the criteria. + */ +WaveFile.fromMpeg(mpegBuffer, info=null) {}; + /** * Set up the WaveFileParser object from a byte buffer. * @param {!Uint8Array} wavBuffer The buffer. @@ -730,7 +785,7 @@

    The WaveFile methods

    * pointData.dwLanguage * pointData.dwDialect * pointData.dwCodePage - * + * * # This is what a complete pointData object look like: * { * position: number, @@ -842,11 +897,11 @@

    WaveFile.listCuePoints()

    [
       {
         position: 500, // the position in milliseconds
    -    label: 'cue marker 1',
    +    label: "cue marker 1",
         end: 1500, // the end position in milliseconds
         dwName: 1,
         dwPosition: 0,
    -    fccChunk: 'data',
    +    fccChunk: "data",
         dwChunkStart: 0,
         dwBlockStart: 0,
         dwSampleOffset: 22050, // the position as a sample offset
    @@ -856,9 +911,9 @@ 

    WaveFile.listCuePoints()

    dwLanguage: 0, dwDialect: 0, dwCodePage: 0 - }, + } // ... -] +];

    The list order reflects the order of the points in the file.

    The WaveFile properties

    @@ -867,7 +922,7 @@

    The WaveFile properties

    * "RIFF", "RIFX" and "RF64" are supported. * @type {string} */ -WaveFile.container = ''; +WaveFile.container = ""; /** * @type {number} */ @@ -877,138 +932,246 @@

    The WaveFile properties

    * Always 'WAVE'. * @type {string} */ -WaveFile.format = ''; +WaveFile.format = ""; /** * The data of the "fmt" chunk. * @type {!Object<string, *>} */ WaveFile.fmt = { - /** @type {string} */ - chunkId: '', - /** @type {number} */ - chunkSize: 0, - /** @type {number} */ - audioFormat: 0, - /** @type {number} */ - numChannels: 0, - /** @type {number} */ - sampleRate: 0, - /** @type {number} */ - byteRate: 0, - /** @type {number} */ - blockAlign: 0, - /** @type {number} */ - bitsPerSample: 0, - /** @type {number} */ - cbSize: 0, - /** @type {number} */ - validBitsPerSample: 0, - /** @type {number} */ - dwChannelMask: 0, - /** - * 4 32-bit values representing a 128-bit ID - * @type {!Array<number>} - */ - subformat: [] + /** @type {string} */ + chunkId: "", + /** @type {number} */ + chunkSize: 0, + /** @type {number} */ + audioFormat: 0, + /** @type {number} */ + numChannels: 0, + /** @type {number} */ + sampleRate: 0, + /** @type {number} */ + byteRate: 0, + /** @type {number} */ + blockAlign: 0, + /** @type {number} */ + bitsPerSample: 0, + /** @type {number} */ + cbSize: 0, + /** @type {number} */ + validBitsPerSample: 0, + /** @type {number} */ + dwChannelMask: 0, + /** + * 4 32-bit values representing a 128-bit ID + * @type {!Array<number>} + */ + subformat: [] }; /** * The data of the "fact" chunk. * @type {!Object<string, *>} */ WaveFile.fact = { - /** @type {string} */ - chunkId: '', - /** @type {number} */ - chunkSize: 0, - /** @type {number} */ - dwSampleLength: 0 + /** @type {string} */ + chunkId: "", + /** @type {number} */ + chunkSize: 0, + /** @type {number} */ + dwSampleLength: 0 }; /** * The data of the "cue " chunk. * @type {!Object<string, *>} */ WaveFile.cue = { - /** @type {string} */ - chunkId: '', - /** @type {number} */ - chunkSize: 0, - /** @type {number} */ - dwCuePoints: 0, - /** @type {!Array<!Object>} */ - points: [], + /** @type {string} */ + chunkId: "", + /** @type {number} */ + chunkSize: 0, + /** @type {number} */ + dwCuePoints: 0, + /** @type {!Array<!Object>} */ + points: [] }; /** * The data of the "smpl" chunk. * @type {!Object<string, *>} */ WaveFile.smpl = { - /** @type {string} */ - chunkId: '', - /** @type {number} */ - chunkSize: 0, - /** @type {number} */ - dwManufacturer: 0, - /** @type {number} */ - dwProduct: 0, - /** @type {number} */ - dwSamplePeriod: 0, - /** @type {number} */ - dwMIDIUnityNote: 0, - /** @type {number} */ - dwMIDIPitchFraction: 0, - /** @type {number} */ - dwSMPTEFormat: 0, - /** @type {number} */ - dwSMPTEOffset: 0, - /** @type {number} */ - dwNumSampleLoops: 0, - /** @type {number} */ - dwSamplerData: 0, - /** @type {!Array<!Object>} */ - loops: [], + /** @type {string} */ + chunkId: "", + /** @type {number} */ + chunkSize: 0, + /** @type {number} */ + dwManufacturer: 0, + /** @type {number} */ + dwProduct: 0, + /** @type {number} */ + dwSamplePeriod: 0, + /** @type {number} */ + dwMIDIUnityNote: 0, + /** @type {number} */ + dwMIDIPitchFraction: 0, + /** @type {number} */ + dwSMPTEFormat: 0, + /** @type {number} */ + dwSMPTEOffset: 0, + /** @type {number} */ + dwNumSampleLoops: 0, + /** @type {number} */ + dwSamplerData: 0, + /** @type {!Array<!Object>} */ + loops: [] }; /** * The data of the "bext" chunk. * @type {!Object<string, *>} */ WaveFile.bext = { - /** @type {string} */ - chunkId: '', - /** @type {number} */ - chunkSize: 0, - /** @type {string} */ - description: '', //256 - /** @type {string} */ - originator: '', //32 - /** @type {string} */ - originatorReference: '', //32 - /** @type {string} */ - originationDate: '', //10 - /** @type {string} */ - originationTime: '', //8 - /** - * 2 32-bit values, timeReference high and low - * @type {!Array<number>} - */ - timeReference: [0, 0], - /** @type {number} */ - version: 0, //WORD - /** @type {string} */ - UMID: '', // 64 chars - /** @type {number} */ - loudnessValue: 0, //WORD - /** @type {number} */ - loudnessRange: 0, //WORD - /** @type {number} */ - maxTruePeakLevel: 0, //WORD - /** @type {number} */ - maxMomentaryLoudness: 0, //WORD - /** @type {number} */ - maxShortTermLoudness: 0, //WORD - /** @type {string} */ - reserved: '', //180 - /** @type {string} */ - codingHistory: '' // string, unlimited + /** @type {string} */ + chunkId: "", + /** @type {number} */ + chunkSize: 0, + /** @type {string} */ + description: "", //256 + /** @type {string} */ + originator: "", //32 + /** @type {string} */ + originatorReference: "", //32 + /** @type {string} */ + originationDate: "", //10 + /** @type {string} */ + originationTime: "", //8 + /** + * 2 32-bit values, timeReference high and low + * @type {!Array<number>} + */ + timeReference: [0, 0], + /** @type {number} */ + version: 0, //WORD + /** @type {string} */ + UMID: "", // 64 chars + /** @type {number} */ + loudnessValue: 0, //WORD + /** @type {number} */ + loudnessRange: 0, //WORD + /** @type {number} */ + maxTruePeakLevel: 0, //WORD + /** @type {number} */ + maxMomentaryLoudness: 0, //WORD + /** @type {number} */ + maxShortTermLoudness: 0, //WORD + /** @type {string} */ + reserved: "", //180 + /** @type {string} */ + codingHistory: "" // string, unlimited +}; +/** + * The data of the 'mext' chunk. + * @type {!Object<string, *>} + */ +WaveFile.mext = { + /** @type {string} */ + chunkId: "", + /** @type {number} */ + chunkSize: 0, + /** @type {number} */ + soundInformation: 0, + /** @type {number} */ + frameSize: 0, + /** @type {number} */ + ancillaryDataLength: 0, + /** @type {number} */ + ancillaryDataDef: 0, //4 + /** @type {string} */ + reserved: "" +}; +/** + * mpegInfo for making a wav from mpeg audio + * @type {!Object<string, *>} + */ +WaveFile.mpegInfo = { + /** @type {number} */ + version: 0, + /** @type {number} */ + layer: 0, + /** @type {number} */ + sampleRate: 0, + /** @type {number} */ + bitRate: 0, + /** @type {string} */ + channelMode: "", + /** @type {number} */ + padding: 0, + /** @type {number} */ + modeExtension: 0, + /** @type {number} */ + emphasis: 0, + /** @type {number} */ + privateBit: 0, + /** @type {boolean} */ + copyright: false, + /** @type {boolean} */ + original: false, + /** @type {boolean} */ + errorProtection: false, + /** @type {number} */ + numChannels: 0, + /** @type {number} */ + frameSize: 0, + /** @type {number} */ + sampleLength: 0, + /** @type {boolean} */ + freeForm: false +}; +/** + * The data of the cart chunk. + * @type {!Object<string, *>} + */ +WaveFile.cart = { + /** @type {string} */ + chunkId: "", + /** @type {number} */ + chunkSize: 0, + /** @type {string} */ + version: "", + /** @type {string} */ + title: "", + /** @type {string} */ + artist: "", + /** @type {string} */ + cutId: "", + /** @type {string} */ + clientId: "", + /** @type {string} */ + category: "", + /** @type {string} */ + classification: "", + /** @type {string} */ + outCue: "", + /** @type {string} */ + startDate: "", + /** @type {string} */ + startTime: "", + /** @type {string} */ + endDate: "", + /** @type {string} */ + endTime: "", + /** @type {string} */ + producerAppId: "", + /** @type {string} */ + producerAppVersion: "", + /** @type {string} */ + userDef: "", + /** @type {number} */ + levelReference: 0, + /** @type {string} */ + postTimer: "", + /** @type {string} */ + reserved: "", + /** @type {string} */ + url: "", + /** @type {string} */ + tagText: "" }; /** * The data of the 'iXML' chunk. @@ -1016,11 +1179,11 @@

    The WaveFile properties

    */ WaveFile.iXML = { /** @type {string} */ - chunkId: '', + chunkId: "", /** @type {number} */ chunkSize: 0, /** @type {string} */ - value: '' + value: "" }; /** * The data of the "ds64" chunk. @@ -1028,40 +1191,40 @@

    The WaveFile properties

    * @type {!Object<string, *>} */ WaveFile.ds64 = { - /** @type {string} */ - chunkId: '', - /** @type {number} */ - chunkSize: 0, - /** @type {number} */ - riffSizeHigh: 0, // DWORD - /** @type {number} */ - riffSizeLow: 0, // DWORD - /** @type {number} */ - dataSizeHigh: 0, // DWORD - /** @type {number} */ - dataSizeLow: 0, // DWORD - /** @type {number} */ - originationTime: 0, // DWORD - /** @type {number} */ - sampleCountHigh: 0, // DWORD - /** @type {number} */ - sampleCountLow: 0, // DWORD - /** @type {number} */ - //"tableLength": 0, // DWORD - /** @type {!Array<number>} */ - //"table": [] + /** @type {string} */ + chunkId: "", + /** @type {number} */ + chunkSize: 0, + /** @type {number} */ + riffSizeHigh: 0, // DWORD + /** @type {number} */ + riffSizeLow: 0, // DWORD + /** @type {number} */ + dataSizeHigh: 0, // DWORD + /** @type {number} */ + dataSizeLow: 0, // DWORD + /** @type {number} */ + originationTime: 0, // DWORD + /** @type {number} */ + sampleCountHigh: 0, // DWORD + /** @type {number} */ + sampleCountLow: 0 // DWORD + /** @type {number} */ + //"tableLength": 0, // DWORD + /** @type {!Array<number>} */ + //"table": [] }; /** * The data of the "data" chunk. * @type {!Object<string, *>} */ WaveFile.data = { - /** @type {string} */ - chunkId: '', - /** @type {number} */ - chunkSize: 0, - /** @type {!Uint8Array} */ - samples: new Uint8Array(0) + /** @type {string} */ + chunkId: "", + /** @type {number} */ + chunkSize: 0, + /** @type {!Uint8Array} */ + samples: new Uint8Array(0) }; /** * The data of the "LIST" chunks. @@ -1080,12 +1243,12 @@

    The WaveFile properties

    * @type {!Object<string, *>} */ WaveFile.junk = { - /** @type {string} */ - chunkId: '', - /** @type {number} */ - chunkSize: 0, - /** @type {!Array<number>} */ - chunkData: [] + /** @type {string} */ + chunkId: "", + /** @type {number} */ + chunkSize: 0, + /** @type {!Array<number>} */ + chunkData: [] }; /** * The data of the '_PMX' chunk. @@ -1093,17 +1256,17 @@

    The WaveFile properties

    */ WaveFile._PMX = { /** @type {string} */ - chunkId: '', + chunkId: "", /** @type {number} */ chunkSize: 0, /** @type {string} */ - value: '' + value: "" }; /** * The bit depth code according to the samples. * @type {string} */ -WaveFile.bitDepth = ''; +WaveFile.bitDepth = "";

    Cue points

    Items in cue.points are objects like this:

    @@ -1180,6 +1343,15 @@

    Style guide

    https://google.github.io/styleguide/jsguide.html

    Code of conduct

    This project is bound by a Code of Conduct: The Contributor Covenant, version 1.4, also available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

    +

    Creator's note

    +

    The creator of wavefile, @rochars, added this note to the README on the original project:

    +

    MOVING AWAY FROM GITHUB (2020-03-08)

    +

    Microsoft, owner of GitHub, was one of the main backers of the current fascist regime in Brazil and also of the coup d'etat that led to the present situation of my country.

    +

    It paid well: The brazilian government was required to run all its systems on open-source software. After the coup d'etat this changed, the goverment began purchasing Microsoft licenses and migrating all their systems to Windows.

    +

    It is not just a case of business malpractice - there is a genocide going on in Brazil and many people, including myself, have lived under constant death threats for the past couple years bacause of our positions against the current fascist regime. Many have been murdered or incarcerated. Poverty and violence skyrocketed.

    +

    This software will keep being released in NPM as always - only the repository will be moved. Projects depending on this software will not be affected.

    +

    For Microsoft owners and collaborators: you have a lot of blood in your hands. I will not share my work with people of your kind.

    +

    References

    Papers

    https://tech.ebu.ch/docs/tech/tech3285.pdf
    @@ -1189,11 +1361,15 @@

    Papers

    http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/Docs/riffmci.pdf
    https://sites.google.com/site/musicgapi/technical-documents/wav-file-format
    http://www.neurophys.wisc.edu/auditory/riff-format.txt
    -https://sno.phy.queensu.ca/~phil/exiftool/TagNames/RIFF.html#Info

    +https://sno.phy.queensu.ca/~phil/exiftool/TagNames/RIFF.html#Info +http://tech.ebu.ch/docs/tech/tech3285s1.pdf +http://www.cartchunk.org/ +http://www.aes.org/publications/standards/search.cfm?docID=41

    Software

    https://github.com/erikd/libsndfile
    https://gist.github.com/hackNightly/3776503
    -https://github.com/chirlu/sox/blob/master/src/wav.c

    +https://github.com/chirlu/sox/blob/master/src/wav.c +https://github.com/kookster/nu_wav

    Other

    https://developercertificate.org/
    https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
    diff --git a/docs/lib_wavefile-creator.js.html b/docs/lib_wavefile-creator.js.html index 471005c..64adcd0 100644 --- a/docs/lib_wavefile-creator.js.html +++ b/docs/lib_wavefile-creator.js.html @@ -226,7 +226,7 @@

    lib/wavefile-creator.js

    } if ( (info.sampleRate == 44100 || info.sampleRate == 22050) && - info.padding + !info.padding ) { soundInformation += 4; } diff --git a/lib/wavefile-creator.js b/lib/wavefile-creator.js index 770506d..d44f3b1 100644 --- a/lib/wavefile-creator.js +++ b/lib/wavefile-creator.js @@ -182,7 +182,7 @@ export class WaveFileCreator extends WaveFileParser { } if ( (info.sampleRate == 44100 || info.sampleRate == 22050) && - info.padding + !info.padding ) { soundInformation += 4; } diff --git a/package-lock.json b/package-lock.json index 2eae30e..5c619d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,18 +4,66 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@ampproject/rollup-plugin-closure-compiler": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@ampproject/rollup-plugin-closure-compiler/-/rollup-plugin-closure-compiler-0.13.0.tgz", - "integrity": "sha512-uvbNj/ngTZxHZM7y1RLC+hQ1qUZ9JH0BVdVmcAWRH6U/25ek18V/r+ks9VKmkzRfn8Oe9nY4XmXHJozfQGVOIQ==", + "@ampproject/remapping": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-0.2.0.tgz", + "integrity": "sha512-a4EztS9/GOVQjX5Ol+Iz33TFhaXvYBF7aB6D8+Qz0/SCIxOm3UNRhGZiwcCuJ8/Ifc6NCogp3S48kc5hFxRpUw==", "dev": true, "requires": { - "acorn": "7.1.0", - "acorn-dynamic-import": "4.0.0", - "acorn-walk": "7.0.0", - "google-closure-compiler": "20191111.0.0", - "magic-string": "0.25.4", - "temp-write": "4.0.0" + "@jridgewell/resolve-uri": "1.0.0", + "sourcemap-codec": "1.4.8" + }, + "dependencies": { + "sourcemap-codec": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", + "dev": true + } + } + }, + "@ampproject/rollup-plugin-closure-compiler": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@ampproject/rollup-plugin-closure-compiler/-/rollup-plugin-closure-compiler-0.27.0.tgz", + "integrity": "sha512-stpAOn2ZZEJuAV39HFw9cnKJYNhEeHtcsoa83orpLDhSxsxSbVEKwHaWlFBaQYpQRSOdapC4eJhJnCzocZxnqg==", + "dev": true, + "requires": { + "@ampproject/remapping": "0.2.0", + "acorn": "7.3.1", + "acorn-walk": "7.1.1", + "estree-walker": "2.0.1", + "google-closure-compiler": "20210808.0.0", + "magic-string": "0.25.7", + "uuid": "8.1.0" + }, + "dependencies": { + "acorn": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", + "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", + "dev": true + }, + "estree-walker": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.1.tgz", + "integrity": "sha512-tF0hv+Yi2Ot1cwj9eYHtxC0jB9bmjacjQs6ZBTj82H8JwUywFuc+7E83NWfNMwHXZc11mjfFcVXPe9gEP4B8dg==", + "dev": true + }, + "magic-string": { + "version": "0.25.7", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", + "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", + "dev": true, + "requires": { + "sourcemap-codec": "^1.4.4" + } + }, + "uuid": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz", + "integrity": "sha512-CI18flHDznR0lq54xBycOVmphdCYnQLKn8abKn7PXUiKUGdEd+/l9LWNJmugXel4hXq7S+RMNl34ecyC9TntWg==", + "dev": true + } } }, "@babel/code-frame": { @@ -135,6 +183,12 @@ "to-fast-properties": "^2.0.0" } }, + "@jridgewell/resolve-uri": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-1.0.0.tgz", + "integrity": "sha512-9oLAnygRMi8Q5QkYEU4XWK04B+nuoXoxjRvRxgjuChkLZFBja0YPSgdZ7dZtwhncLBcQe/I/E+fLuk5qxcYVJA==", + "dev": true + }, "@rollup/plugin-commonjs": { "version": "11.0.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.0.1.tgz", @@ -197,16 +251,10 @@ "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", "dev": true }, - "acorn-dynamic-import": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz", - "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==", - "dev": true - }, "acorn-walk": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.0.0.tgz", - "integrity": "sha512-7Bv1We7ZGuU79zZbb6rRqcpxo3OY+zrdtloZWoyD8fmGX+FeXRjE+iuGkZjSXLVovLzrsvMGMy0EkwA0E0umxg==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.1.1.tgz", + "integrity": "sha512-wdlPY2tm/9XBr7QkKlq0WQVgiuGTX6YWPyRyBviSoScBuLfTVQhvwg6wJ369GJ/1nPfTLMfnrFIfjqVg6d+jQQ==", "dev": true }, "agent-base": { @@ -852,52 +900,45 @@ "dev": true }, "google-closure-compiler": { - "version": "20191111.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20191111.0.0.tgz", - "integrity": "sha512-Ji+FaqYKXNbJ78N5Do6hu61mPrB9D+8xSnmRO59u2CrIbmNCtoFnqkCAAL4Ye8LR8foRqtkDdiKJSblpe+5ttg==", + "version": "20210808.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20210808.0.0.tgz", + "integrity": "sha512-+R2+P1tT1lEnDDGk8b+WXfyVZgWjcCK9n1mmZe8pMEzPaPWxqK7GMetLVWnqfTDJ5Q+LRspOiFBv3Is+0yuhCA==", "dev": true, "requires": { "chalk": "2.x", - "google-closure-compiler-java": "^20191111.0.0", - "google-closure-compiler-js": "^20191111.0.0", - "google-closure-compiler-linux": "^20191111.0.0", - "google-closure-compiler-osx": "^20191111.0.0", - "google-closure-compiler-windows": "^20191111.0.0", + "google-closure-compiler-java": "^20210808.0.0", + "google-closure-compiler-linux": "^20210808.0.0", + "google-closure-compiler-osx": "^20210808.0.0", + "google-closure-compiler-windows": "^20210808.0.0", "minimist": "1.x", "vinyl": "2.x", "vinyl-sourcemaps-apply": "^0.2.0" } }, "google-closure-compiler-java": { - "version": "20191111.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20191111.0.0.tgz", - "integrity": "sha512-JgsQtJVVgDuj50VPQV1OgHxMy78daTL3d607V6zF/qETl3rEEiazEGfXDGUX/1V1SUOW+Y03Ct9bcO3LMxNlxg==", - "dev": true - }, - "google-closure-compiler-js": { - "version": "20191111.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-js/-/google-closure-compiler-js-20191111.0.0.tgz", - "integrity": "sha512-W3Oy5NF5CMgUv31CMbgLN7zhdCTVMTnNI//iEPYMotzXfX8viyOnTMipDDwJNeMnY7lfXbQrYOo+QkWP6WzZtg==", + "version": "20210808.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20210808.0.0.tgz", + "integrity": "sha512-7dEQfBzOdwdjwa/Pq8VAypNBKyWRrOcKjnNYOO9gEg2hjh8XVMeQzTqw4uANfVvvANGdE/JjD+HF6zHVgLRwjg==", "dev": true }, "google-closure-compiler-linux": { - "version": "20191111.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20191111.0.0.tgz", - "integrity": "sha512-pxxB83Ae7G9OHFSOEzOYlp844YyqQgU1RXBpCGBKeDAQrs3dykHqRhNGZdI7N1tsby/pT+hKL1US2l/CslPqag==", + "version": "20210808.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20210808.0.0.tgz", + "integrity": "sha512-byKi5ITUiWRvEIcQo76i1siVnOwrTmG+GNcBG4cJ7x8IE6+4ki9rG5pUe4+DOYHkfk52XU6XHt9aAAgCcFDKpg==", "dev": true, "optional": true }, "google-closure-compiler-osx": { - "version": "20191111.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20191111.0.0.tgz", - "integrity": "sha512-sviL1DLN+dDfYBLzmU6+2Yk19P1uzUHQuKaXrHxEYZkU4jTJNq/TC4xi6t0ZgvLQEm2Vf7xhOrt80TYKnoQaVg==", + "version": "20210808.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20210808.0.0.tgz", + "integrity": "sha512-iwyAY6dGj1FrrBdmfwKXkjtTGJnqe8F+9WZbfXxiBjkWLtIsJt2dD1+q7g/sw3w8mdHrGQAdxtDZP/usMwj/Rg==", "dev": true, "optional": true }, "google-closure-compiler-windows": { - "version": "20191111.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20191111.0.0.tgz", - "integrity": "sha512-iKdz2bWrrM4zLv3USCRtWX4kLWzZhbj/afh/W6giLxg5XQzbNg+UpVF+2G6f/LEYK9UNBgS2TdyNTuw8mod+Mg==", + "version": "20210808.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20210808.0.0.tgz", + "integrity": "sha512-VI+UUYwtGWDYwpiixrWRD8EklHgl6PMbiEaHxQSrQbH8PDXytwaOKqmsaH2lWYd5Y/BOZie2MzjY7F5JI69q1w==", "dev": true, "optional": true }, @@ -1109,12 +1150,6 @@ "has": "^1.0.3" } }, - "is-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", - "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", - "dev": true - }, "is-symbol": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", @@ -1438,15 +1473,6 @@ "sourcemap-codec": "^1.4.4" } }, - "make-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.0.tgz", - "integrity": "sha512-grNJDhb8b1Jm1qeqW5R/O63wUo4UXo2v2HMic6YT9i/HBlF93S8jkMgH7yugvY9ABDShH4VZMn8I+U8+fCNegw==", - "dev": true, - "requires": { - "semver": "^6.0.0" - } - }, "markdown-it": { "version": "8.4.2", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.2.tgz", @@ -1505,9 +1531,9 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, "mkdirp": { @@ -1917,9 +1943,9 @@ "dev": true }, "replace-ext": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", - "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.1.tgz", + "integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==", "dev": true }, "require-directory": { @@ -2158,25 +2184,6 @@ "uuid": "^3.3.2" } }, - "temp-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-1.0.0.tgz", - "integrity": "sha1-CnwOom06Oa+n4OvqnB/AvE2qAR0=", - "dev": true - }, - "temp-write": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/temp-write/-/temp-write-4.0.0.tgz", - "integrity": "sha512-HIeWmj77uOOHb0QX7siN3OtwV3CTntquin6TNVg6SHOqCP3hYKmox90eeFOGaY1MqJ9WYDDjkyZrW6qS5AWpbw==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.15", - "is-stream": "^2.0.0", - "make-dir": "^3.0.0", - "temp-dir": "^1.0.0", - "uuid": "^3.3.2" - } - }, "test-exclude": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-5.2.3.tgz", @@ -2242,9 +2249,9 @@ } }, "vinyl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz", - "integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", + "integrity": "sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw==", "dev": true, "requires": { "clone": "^2.1.1", diff --git a/package.json b/package.json index b982f2e..75c6baa 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "prx-wavefile", - "version": "11.0.0-prx.1", + "version": "11.0.0-prx.3", "description": "Create, read and write wav files according to the specs.", - "homepage": "https://github.com/rochars/wavefile", + "homepage": "https://github.com/PRX/prx-wavefile", "author": "Rafael da Silva Rocha ", "license": "MIT", "main": "./dist/wavefile.js", @@ -41,10 +41,10 @@ ], "repository": { "type": "git", - "url": "git://github.com/rochars/wavefile.git" + "url": "git://github.com/PRX/prx-wavefile.git" }, "bugs": { - "url": "https://github.com/rochars/wavefile/issues" + "url": "https://github.com/PRX/prx-wavefile/issues" }, "directories": { "bin": "bin", @@ -76,7 +76,7 @@ "test-sr-sinc": "node ./node_modules/mocha/bin/_mocha test/resampler-full/sinc.js test/resampler-full/sinc-IIR.js test/resampler-full/sinc-no-lpf.js -R dot --timeout=1600000", "test-umd": "node ./node_modules/mocha/bin/_mocha test/resampler test/dist test/src --umd --recursive -R dot --timeout=240000", "test-tsc": "tsc ./test/TypeScript/index.ts && node -r esm ./test/TypeScript/index.js", - "test-cli": "wavefile ./test/files/M1F1-int12WE-AFsp.wav --tag=ICMT && wavefile ./test/files/M1F1-int12WE-AFsp.wav --resample=16000 --method=point ./test/files/out/to-sample-rate/M1F1-int12WE-AFsp-CLI.wav", + "test-cli": "prx-wavefile ./test/files/M1F1-int12WE-AFsp.wav --tag=ICMT && prx-wavefile ./test/files/M1F1-int12WE-AFsp.wav --resample=16000 --method=point ./test/files/out/to-sample-rate/M1F1-int12WE-AFsp-CLI.wav", "test-dist": "npm run test-umd && npm run test-tsc && npm run test-cli", "rollup-bundle": "rollup -c && npm run test-dist", "doc": "./node_modules/.bin/jsdoc -c .jsdocrc -d docs -r README.md -t node_modules/docdash", @@ -84,7 +84,7 @@ "coverage": "nyc report --reporter=lcov > coverage.lcov && codecov" }, "devDependencies": { - "@ampproject/rollup-plugin-closure-compiler": "^0.13.0", + "@ampproject/rollup-plugin-closure-compiler": "^0.27.0", "@rollup/plugin-commonjs": "^11.0.0", "@rollup/plugin-node-resolve": "^6.0.0", "byte-data": "^19.0.1", diff --git a/test/dist/cart/cart-rw.js b/test/dist/cart/cart-rw.js index 50a7c99..809ff76 100644 --- a/test/dist/cart/cart-rw.js +++ b/test/dist/cart/cart-rw.js @@ -145,31 +145,31 @@ describe("Create an bwf mpeg cart file from info and an mp2 file", function() { ); assert.equal(wav.mext.frameSize, 768); - assert.equal(wav.mext.soundInformation, 12); + assert.equal(wav.mext.soundInformation, 8); }); describe("Create a bwf mpeg cart file from an mp2 file", function() { let wav = new WaveFile(); - wav.fromMpeg(fs.readFileSync(path + "test.mp2")); + wav.fromMpeg(fs.readFileSync(path + "44100_test.mp2")); fs.writeFileSync(path + "out/test-mp2.wav", wav.toBuffer()); wav = new WaveFile(fs.readFileSync(path + "out/test-mp2.wav")); - assert.equal(wav.fmt.sampleRate, 48000); + assert.equal(wav.fmt.sampleRate, 44100); assert.equal(wav.fmt.byteRate, 32000); assert.equal(wav.fmt.numChannels, 2); - assert.equal(wav.fmt.blockAlign, 768); + assert.equal(wav.fmt.blockAlign, 835); assert.equal(wav.fmt.numChannels, 2); assert.equal(wav.fmt.headBitRate, 256000); assert.equal(wav.fmt.headLayer, 2); - assert.equal(wav.fact.dwSampleLength, 269568); + assert.equal(wav.fact.dwSampleLength, 1323648); assert.equal( wav.bext.codingHistory, - "A=MPEG1L2,F=48000,B=256,M=stereo,T=wavefile\r\n\u0000\u0000" + "A=MPEG1L2,F=44100,B=256,M=stereo,T=wavefile\r\n\u0000\u0000" ); - assert.equal(wav.mext.frameSize, 768); - assert.equal(wav.mext.soundInformation, 3); + assert.equal(wav.mext.frameSize, 835); + assert.equal(wav.mext.soundInformation, 7); }); diff --git a/test/files/44100_test.mp2 b/test/files/44100_test.mp2 new file mode 100644 index 0000000..52692d1 Binary files /dev/null and b/test/files/44100_test.mp2 differ diff --git a/test/files/out/test-mp2-i.wav b/test/files/out/test-mp2-i.wav index ad4fe70..09c375e 100644 Binary files a/test/files/out/test-mp2-i.wav and b/test/files/out/test-mp2-i.wav differ diff --git a/test/files/out/test-mp2.wav b/test/files/out/test-mp2.wav index a34bd64..8aa58eb 100644 Binary files a/test/files/out/test-mp2.wav and b/test/files/out/test-mp2.wav differ