eshaz / wasm-audio-decoders

Browser and NodeJS Web Assembly audio decoder libraries that are highly optimized for size and performance.
399 stars 23 forks source link

Undefined _preSkip when streaming with ogg-opus-decoder #95

Closed jimvella closed 1 year ago

jimvella commented 1 year ago

Thanks for making this library available. I'm having trouble using https://github.com/eshaz/wasm-audio-decoders/tree/master/src/ogg-opus-decoder for streaming. It's producing the first decoded result, but then subsequent calls result in 'TypeError: Cannot convert undefined to a BigInt' at https://github.com/eshaz/wasm-audio-decoders/blob/5e64d49844c4f2ea99927093c595b0df0e55744e/src/ogg-opus-decoder/src/OggOpusDecoder.js#L70

Maybe its just a matter of copying the _preSkip value in the DecoderState constructor? https://github.com/eshaz/wasm-audio-decoders/blob/5e64d49844c4f2ea99927093c595b0df0e55744e/src/ogg-opus-decoder/src/OggOpusDecoder.js#L16

eshaz commented 1 year ago

Thanks for entering this issue. I think I see what the problem is. The DecoderState instance needs to be dereferenced when the first file is done decoding so it can create a new instance for the next decode and decodeFile invocation. I'll get a fix out later today for this.

eshaz commented 1 year ago

It turned out to be a bit more than what I originally thought. I've released ogg-opus-decoder/1.6.7 that fixes this issue. Thanks again for reporting it!