wasm-audio-decoders icon indicating copy to clipboard operation
wasm-audio-decoders copied to clipboard

How to playback decoded audio

Open jjackevans opened this issue 2 years ago • 3 comments

Hi,

I'm having some difficulties with the opus decoder, would you be able to answer a few questions over email?

You can contact me at [email protected] if this is ok?

Thanks

jjackevans avatar Sep 13 '22 21:09 jjackevans

Hi, we can discuss here in this issue if you don't mind. I like to keep these discussions public so that if someone else also has a similar issue they will be able to refer back here.

eshaz avatar Sep 14 '22 18:09 eshaz

Hi, we can discuss here in this issue if you don't mind. I like to keep these discussions public so that if someone else also has a similar issue they will be able to refer back here.

How would you recommend playing the audio data (with minimal latency) in the browser, from the decodeFrame callback?

jjackevans avatar Oct 09 '22 20:10 jjackevans

You can use the Web Audio API to play back the decoded results. You can asynchronously decode using OpusDecoderWebWorker.decodeFrame, put the results into an AudioBuffer, and playback the buffer using an AudioBufferSourceNode.

Here are a few examples of where I use this library to decode audio and playback through the Web Audio api:

eshaz avatar Oct 14 '22 04:10 eshaz

Just ran into this issue, I solved it using this code. I hope this helps someone

https://github.com/samirkumardas/pcm-player/issues/11#issuecomment-788322380

zusorio avatar Nov 11 '22 20:11 zusorio

Thanks all for the input, closing since there are a number of examples noted here.

eshaz avatar Dec 16 '22 04:12 eshaz