Comparing version 10.4.1 to 10.4.2
# CHANGELOG | ||
## version 10.4.2 - 2020-01-22 | ||
Better sinc resampling. | ||
## version 10.4.1 - 2020-01-21 | ||
@@ -4,0 +7,0 @@ Faster sinc resampling. |
@@ -23,10 +23,10 @@ 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 ca="function"==typeof Object.create?Object.create:function(n){function m(){}m.prototype=n;return new m},F; | ||
h,d)}catch(q){ka(q,a[f],f)}return d}function O(a,b,c,d,e,f){d=void 0===d?0:d;e=void 0===e?a.length:e;f=void 0===f?!1:f;b=b||{};var h=new J(b.h,b.O,b.G),k=h.offset,q=(e-d)%k;if(f&&(q||a.length<k))throw Error("Bad buffer length");e-=q;f=0;q=d;try{for(b.o&&Y(a,k,d,e);q<e;q+=k,f++)c[f]=h.R(a,q);b.o&&Y(a,k,d,e)}catch(z){ka(z,a.slice(q,q+k),q)}}function g(a,b){var c=[];Q([a],b,c,0);return c}function ba(a,b,c,d,e){d=void 0===d?a.length:d;var f=[];O(a,b,f,void 0===c?0:c,d,void 0===e?!1:e);return f}function R(a, | ||
b,c){c=void 0===c?0:c;return ba(a,b,c,c+Math.ceil(b.h/8),!0)[0]}function ka(a,b,c){a.message=a.constructor.name+" at index "+c+": "+b;throw a;}function A(a,b,c){c=void 0===c?!0:c;a=x(a);if(c)for(c=a.length;c<b;c++)a.push(0);return a}function la(a,b){for(var c=8===b?255:Math.pow(2,b)/2-1,d=8===b?0:-c-1,e=0,f=a.length;e<f;e++)a[e]=Math.round(a[e]),a[e]>c?a[e]=c:a[e]<d&&(a[e]=d)}function xa(a){return Math.exp(-a*a)}function wa(a){return function(b){return(0===b?1:Math.sin(Math.PI*b)/(Math.PI*b))*a(b)}} | ||
function ua(a,b){return Math.max(0,Math.min(a,b-1))}function ea(a,b){a%=b;0>a&&(a+=b);return a}function va(a,b){var c=2*(b-1);a=ea(a,c);a>b-1&&(a=c-a);return a}function ma(a,b,c,d){d=void 0===d?{}:d;var e=new Float64Array(a.length*((c-b)/b+1));d.method=d.method||"cubic";var f=new v(a.length,e.length,{method:d.method,tension:d.tension||0,sincFilterSize:d.sincFilterSize||6,sincWindow:d.sincWindow||void 0,clip:d.clip||"mirror"});void 0===d.LPF&&(d.LPF=Na[d.method]);if(d.LPF){d.LPFType=d.LPFType||"IIR"; | ||
var h=Oa[d.LPFType];if(c>b){b=new h(d.LPForder||na[d.LPFType],c,b/2);c=0;for(d=e.length;c<d;c++)e[c]=b.filter(f.P(c,a));b.reset();for(a=e.length-1;0<=a;a--)e[a]=b.filter(e[a])}else{b=new h(d.LPForder||na[d.LPFType],b,c/2);c=0;for(d=a.length;c<d;c++)a[c]=b.filter(a[c]);b.reset();for(c=a.length-1;0<=c;c--)a[c]=b.filter(a[c]);oa(a,e,f)}}else oa(a,e,f);return e}function oa(a,b,c){for(var d=0,e=b.length;d<e;d++)b[d]=c.P(d,a)}var ja=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],W=[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],H=0,I=0,E=0,G=0,L=7,Ha=[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],Ka=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,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,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,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],Ma=[0,132,396,924,1980,4092,8316,16764];K.prototype.F=function(a,b,c){if("number"!=typeof b)throw new TypeError;Math.abs(b)>this.g-2*this.i&&(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=aa(b/Math.pow(2,e)*Math.pow(2,this.c));b!==b?(f=Math.pow(2,this.c-1),e=(1<<this.b)-1): | ||
0!==b&&(b>=Math.pow(2,1-this.a)?(2<=f/Math.pow(2,this.c)&&(e+=1,f=1),e>this.a?(e=(1<<this.b)-1,f=0):(e+=this.a,f=aa(f)-Math.pow(2,this.c))):(f=aa(b/Math.pow(2,1-this.a-this.c)),e=0));return this.m(a,c,d,e,f)};K.prototype.R=function(a,b){for(var c=(1<<this.b)-1,d="",e=this.f-1;0<=e;e--){var f=a[e+b].toString(2);d+="00000000".substring(f.length)+f}e="1"==d.charAt(0)?-1:1;d=d.substring(1);f=parseInt(d.substring(0,this.b),2);d=d.substring(this.b);if(f==c)return 0!==parseInt(d,2)?NaN:Infinity*e;0===f? | ||
(f+=1,c=parseInt(d,2)):c=parseInt("1"+d,2);return e*c*this.j*Math.pow(2,f-this.a)};K.prototype.m=function(a,b,c,d,e){var f=[];f.push(c);for(c=this.b;0<c;--c)f[c]=d%2?1:0,d=Math.floor(d/2);d=f.length;for(c=this.c;0<c;--c)f[d+c]=e%2?1:0,e=Math.floor(e/2);e=f.join("");f=this.f+b-1;for(d=b;f>=b;)a[f]=parseInt(e.substring(0,8),2),e=e.substring(8),f--,d++;return d};C.prototype.F=function(a,b,c){c=void 0===c?0:c;if(b!==b||"number"!=typeof b)throw new TypeError;this.a(b);return this.g(a,b,c)};C.prototype.R= | ||
b,c){c=void 0===c?0:c;return ba(a,b,c,c+Math.ceil(b.h/8),!0)[0]}function ka(a,b,c){a.message=a.constructor.name+" at index "+c+": "+b;throw a;}function A(a,b,c){c=void 0===c?!0:c;a=x(a);if(c)for(c=a.length;c<b;c++)a.push(0);return a}function la(a,b){for(var c=8===b?255:Math.pow(2,b)/2-1,d=8===b?0:-c-1,e=0,f=a.length;e<f;e++)a[e]=Math.round(a[e]),a[e]>c?a[e]=c:a[e]<d&&(a[e]=d)}function xa(a){return Math.exp(-a/2*a/2)}function wa(a){return function(b){return(0===b?1:Math.sin(Math.PI*b)/(Math.PI*b))* | ||
a(b)}}function ua(a,b){return Math.max(0,Math.min(a,b-1))}function ea(a,b){a%=b;0>a&&(a+=b);return a}function va(a,b){var c=2*(b-1);a=ea(a,c);a>b-1&&(a=c-a);return a}function ma(a,b,c,d){d=void 0===d?{}:d;var e=new Float64Array(a.length*((c-b)/b+1));d.method=d.method||"cubic";var f=new v(a.length,e.length,{method:d.method,tension:d.tension||0,sincFilterSize:d.sincFilterSize||6,sincWindow:d.sincWindow||void 0,clip:d.clip||"mirror"});void 0===d.LPF&&(d.LPF=Na[d.method]);if(d.LPF){d.LPFType=d.LPFType|| | ||
"IIR";var h=Oa[d.LPFType];if(c>b){b=new h(d.LPForder||na[d.LPFType],c,b/2);c=0;for(d=e.length;c<d;c++)e[c]=b.filter(f.P(c,a));b.reset();for(a=e.length-1;0<=a;a--)e[a]=b.filter(e[a])}else{b=new h(d.LPForder||na[d.LPFType],b,c/2);c=0;for(d=a.length;c<d;c++)a[c]=b.filter(a[c]);b.reset();for(c=a.length-1;0<=c;c--)a[c]=b.filter(a[c]);oa(a,e,f)}}else oa(a,e,f);return e}function oa(a,b,c){for(var d=0,e=b.length;d<e;d++)b[d]=c.P(d,a)}var ja=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],W=[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],H=0,I=0,E=0,G=0,L=7,Ha=[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],Ka=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,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,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,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],Ma=[0,132,396,924,1980,4092,8316,16764];K.prototype.F=function(a,b,c){if("number"!=typeof b)throw new TypeError;Math.abs(b)>this.g-2*this.i&&(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=aa(b/Math.pow(2,e)*Math.pow(2,this.c));b!==b?(f=Math.pow(2,this.c-1),e=(1<<this.b)- | ||
1):0!==b&&(b>=Math.pow(2,1-this.a)?(2<=f/Math.pow(2,this.c)&&(e+=1,f=1),e>this.a?(e=(1<<this.b)-1,f=0):(e+=this.a,f=aa(f)-Math.pow(2,this.c))):(f=aa(b/Math.pow(2,1-this.a-this.c)),e=0));return this.m(a,c,d,e,f)};K.prototype.R=function(a,b){for(var c=(1<<this.b)-1,d="",e=this.f-1;0<=e;e--){var f=a[e+b].toString(2);d+="00000000".substring(f.length)+f}e="1"==d.charAt(0)?-1:1;d=d.substring(1);f=parseInt(d.substring(0,this.b),2);d=d.substring(this.b);if(f==c)return 0!==parseInt(d,2)?NaN:Infinity*e;0=== | ||
f?(f+=1,c=parseInt(d,2)):c=parseInt("1"+d,2);return e*c*this.j*Math.pow(2,f-this.a)};K.prototype.m=function(a,b,c,d,e){var f=[];f.push(c);for(c=this.b;0<c;--c)f[c]=d%2?1:0,d=Math.floor(d/2);d=f.length;for(c=this.c;0<c;--c)f[d+c]=e%2?1:0,e=Math.floor(e/2);e=f.join("");f=this.f+b-1;for(d=b;f>=b;)a[f]=parseInt(e.substring(0,8),2),e=e.substring(8),f--,d++;return d};C.prototype.F=function(a,b,c){c=void 0===c?0:c;if(b!==b||"number"!=typeof b)throw new TypeError;this.a(b);return this.g(a,b,c)};C.prototype.R= | ||
function(a,b){var c=this.c(a,void 0===b?0:b);this.a(c);return c};C.prototype.c=function(a,b){b=void 0===b?0:b;for(var c=0,d=0;d<this.b;d++)c+=a[b+d]*Math.pow(256,d);return c};C.prototype.a=function(a){if(a>this.max||a<this.min)throw new RangeError;};C.prototype.g=function(a,b,c){c=void 0===c?0:c;a[c]=(0>b?b+Math.pow(2,this.h):b)&255;c++;for(var d=this.b,e=2;e<d;e++)a[c]=Math.floor(b/Math.pow(2,8*(e-1)))&255,c++;8<this.h&&(a[c]=Math.floor(b/Math.pow(2,8*(this.b-1)))&this.f,c++);return c};S(N,C);N.prototype.F= | ||
@@ -33,0 +33,0 @@ function(a,b,c){return C.prototype.F.call(this,a,b,void 0===c?0:c)};N.prototype.R=function(a,b){var c=C.prototype.c.call(this,a,void 0===b?0:b);c=this.i(c);this.a(c);return c};N.prototype.i=function(a){a>this.max&&(a-=2*this.max+2);return a};J.prototype.R=function(a,b){return this.a.R(a,void 0===b?0:b)};J.prototype.F=function(a,b,c){return this.a.F(a,b,void 0===c?0:c)};J.prototype.c=function(a,b,c){if(b){if(!a||16!==a&&32!==a&&64!==a)throw Error("Unsupported type: float, bits: "+a);return this.b(a)}if(!a|| |
@@ -93,3 +93,3 @@ /* | ||
*/ | ||
this.kernel_ = sincKernel_(details.sincWindow || gaussianWindow_); | ||
this.kernel_ = sincKernel_(details.sincWindow || window_); | ||
} | ||
@@ -191,4 +191,4 @@ | ||
*/ | ||
function gaussianWindow_(x) { | ||
return Math.exp(-x * x); | ||
function window_(x) { | ||
return Math.exp(-x / 2 * x / 2); | ||
} | ||
@@ -195,0 +195,0 @@ |
{ | ||
"name": "wavefile", | ||
"version": "10.4.1", | ||
"version": "10.4.2", | ||
"description": "Create, read and write wav files according to the specs.", | ||
@@ -76,3 +76,3 @@ "homepage": "https://github.com/rochars/wavefile", | ||
"test-sr-cubic": "node ./node_modules/mocha/bin/_mocha test/resampler-full/cubic.js -R dot --timeout=1600000", | ||
"test-sr-sinc": "node ./node_modules/mocha/bin/_mocha test/resampler-full/sinc.js test/resampler-full/sinc-IIR.js -R dot --timeout=1600000", | ||
"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", | ||
@@ -79,0 +79,0 @@ "test-tsc": "tsc ./test/TypeScript/index.ts && node -r esm ./test/TypeScript/index.js", |
@@ -24,3 +24,3 @@ # wavefile | ||
- [Create wav files](#create-wave-files-from-scratch) | ||
- [Read wav files](#use) | ||
- [Read wav files](#read-wave-files) | ||
- [Change the bit depth of the audio](#change-the-bit-depth) | ||
@@ -153,2 +153,3 @@ - [Change the sample rate of the audio](#change-the-sample-rate) | ||
* [Create wave files from scratch](#create-wave-files-from-scratch) | ||
* [Read wave files](#read-wave-files) | ||
* [Add RIFF tags to files](#add-riff-tags-to-files) | ||
@@ -218,2 +219,14 @@ * [Add cue points to files](#add-cue-points-to-files) | ||
### Read wave files | ||
```javascript | ||
const WaveFile = require('wavefile').WaveFile; | ||
wav = new WaveFile(); | ||
// Read a wav file from a buffer | ||
wav.fromBuffer(buffer); | ||
// Read a wav file from a base64 string | ||
wav.fromBase64(base64); | ||
// Read a wav file from a data URI | ||
wav.fromDataURI(dataURI); | ||
``` | ||
### Add RIFF tags to files | ||
@@ -220,0 +233,0 @@ You can create (or overwrite) tags on files with the **WaveFile.setTag()** method. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
259846
1264