@wasm-audio-decoders/common
Advanced tools
Comparing version 5.1.1 to 6.0.0
{ | ||
"name": "@wasm-audio-decoders/common", | ||
"version": "5.1.1", | ||
"version": "6.0.0", | ||
"description": "Web Assembly Audio Decoders Common", | ||
@@ -5,0 +5,0 @@ "module": "index.js", |
@@ -1,2 +0,2 @@ | ||
export default function WASMAudioDecoderCommon(caller) { | ||
export default function WASMAudioDecoderCommon(decoderInstance) { | ||
// setup static methods | ||
@@ -57,3 +57,4 @@ const uint8Array = Uint8Array; | ||
getDecodedAudio: { | ||
value: (channelData, samplesDecoded, sampleRate, bitDepth) => ({ | ||
value: (errors, channelData, samplesDecoded, sampleRate, bitDepth) => ({ | ||
errors, | ||
channelData, | ||
@@ -67,3 +68,10 @@ samplesDecoded, | ||
getDecodedAudioMultiChannel: { | ||
value(input, channelsDecoded, samplesDecoded, sampleRate, bitDepth) { | ||
value( | ||
errors, | ||
input, | ||
channelsDecoded, | ||
samplesDecoded, | ||
sampleRate, | ||
bitDepth | ||
) { | ||
let channelData = [], | ||
@@ -82,2 +90,3 @@ i, | ||
return WASMAudioDecoderCommon.getDecodedAudio( | ||
errors, | ||
channelData, | ||
@@ -217,3 +226,3 @@ samplesDecoded, | ||
this.free = (ptr) => { | ||
this.free = () => { | ||
this._pointers.forEach((ptr) => { | ||
@@ -225,8 +234,27 @@ this._wasm._free(ptr); | ||
this.codeToString = (ptr) => { | ||
const characters = [], | ||
heap = new Uint8Array(this._wasm.HEAP); | ||
for (let character = heap[ptr]; character !== 0; character = heap[++ptr]) | ||
characters.push(character); | ||
return String.fromCharCode.apply(null, characters); | ||
}; | ||
this.addError = (errors, message, frameLength) => { | ||
errors.push({ | ||
message: message, | ||
frameLength: frameLength, | ||
frameNumber: decoderInstance._frameNumber, | ||
inputBytes: decoderInstance._inputBytes, | ||
outputSamples: decoderInstance._outputSamples, | ||
}); | ||
}; | ||
this.instantiate = () => { | ||
const _module = caller._module; | ||
const _EmscriptenWASM = caller._EmscriptenWASM; | ||
const _inputSize = caller._inputSize; | ||
const _outputChannels = caller._outputChannels; | ||
const _outputChannelSize = caller._outputChannelSize; | ||
const _module = decoderInstance._module; | ||
const _EmscriptenWASM = decoderInstance._EmscriptenWASM; | ||
const _inputSize = decoderInstance._inputSize; | ||
const _outputChannels = decoderInstance._outputChannels; | ||
const _outputChannelSize = decoderInstance._outputChannelSize; | ||
@@ -240,7 +268,10 @@ if (_module) WASMAudioDecoderCommon.setModule(_EmscriptenWASM, _module); | ||
if (_inputSize) | ||
caller._input = this.allocateTypedArray(_inputSize, uint8Array); | ||
decoderInstance._input = this.allocateTypedArray( | ||
_inputSize, | ||
uint8Array | ||
); | ||
// output buffer | ||
if (_outputChannelSize) | ||
caller._output = this.allocateTypedArray( | ||
decoderInstance._output = this.allocateTypedArray( | ||
_outputChannels * _outputChannelSize, | ||
@@ -250,2 +281,6 @@ float32Array | ||
decoderInstance._inputBytes = 0; | ||
decoderInstance._outputSamples = 0; | ||
decoderInstance._frameNumber = 0; | ||
return this; | ||
@@ -252,0 +287,0 @@ }); |
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
59488
376