@wasm-audio-decoders/common
Advanced tools
Comparing version 1.0.0 to 2.0.0
{ | ||
"name": "@wasm-audio-decoders/common", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Web Assembly Audio Decoders Common", | ||
@@ -5,0 +5,0 @@ "module": "index.js", |
@@ -1,4 +0,5 @@ | ||
const compiledWasm = new WeakMap(); | ||
export default class WASMAudioDecoderCommon { | ||
// share the same WASM instance per thread | ||
static instances = new WeakMap(); | ||
export default class WASMAudioDecoderCommon { | ||
constructor(wasm) { | ||
@@ -18,15 +19,9 @@ this._wasm = wasm; | ||
// new decoder instance | ||
if (this._isWebWorker) { | ||
// web worker | ||
if (WASMAudioDecoderCommon.instances.has(this._EmscriptenWASM)) { | ||
// reuse existing compilation | ||
this._wasm = WASMAudioDecoderCommon.instances.get(this._EmscriptenWASM); | ||
} else { | ||
// first compilation | ||
this._wasm = new this._EmscriptenWASM(WASMAudioDecoderCommon); | ||
} else { | ||
// main thread | ||
if (compiledWasm.has(this._EmscriptenWASM)) { | ||
// reuse existing compilation | ||
this._wasm = compiledWasm.get(this._EmscriptenWASM); | ||
} else { | ||
// first compilation | ||
this._wasm = new this._EmscriptenWASM(WASMAudioDecoderCommon); | ||
compiledWasm.set(this._EmscriptenWASM, this._wasm); | ||
} | ||
WASMAudioDecoderCommon.instances.set(this._EmscriptenWASM, this._wasm); | ||
} | ||
@@ -73,12 +68,2 @@ } | ||
static getDecodedAudioConcat(channelData, samplesDecoded, sampleRate) { | ||
return WASMAudioDecoderCommon.getDecodedAudio( | ||
channelData.map((data) => | ||
WASMAudioDecoderCommon.concatFloat32(data, samplesDecoded) | ||
), | ||
samplesDecoded, | ||
sampleRate | ||
); | ||
} | ||
static getDecodedAudioMultiChannel( | ||
@@ -85,0 +70,0 @@ input, |
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
17835
521