hi HN!<p>I've been working in the browser audio domain recently and noticed to my surprise that WebAudio has no way to decode audio files efficiently. WebAudio has no support for partial decoding and can only decode entire audio files upfront which results in huge CPU and memory usage.<p>For example, decoding a typical stereo 44.1 KHz 1-hour long audio file (e.g a podcast) into uncompressed floating point
samples would consume (3600s * 44100Hz * 4 bytes * 2 channels) = ~1.27 GB of memory. <i>Nice</i><p>Obviously this isn't acceptable so I ended up creating this library to work around this issue. I ported FFmpeg over to WASM using Emscripten (a painful process) and then implemented an audio decoder with support for partial decoding. I hope this library can help anyone else with the same issue or at least serve as an additional reference for those looking to roll their own WASM-based workarounds.<p>Thanks for taking a look!<p>P.S: extra info/ranting about WebAudio below for those interested<p>Others have already pointed out this glaring issue in the WebAudio API:
<a href="https://github.com/WebAudio/web-audio-api/issues/1305" rel="nofollow">https://github.com/WebAudio/web-audio-api/issues/1305</a><p>But it's sad to see that so many libraries/applications out there still rely on it such as:
<a href="https://github.com/bbc/waveform-data.js" rel="nofollow">https://github.com/bbc/waveform-data.js</a>
<a href="https://github.com/katspaugh/wavesurfer.js" rel="nofollow">https://github.com/katspaugh/wavesurfer.js</a><p>Thankfully this issue should hopefully be addressed whenever WebCodecs is standardized and implemented:
<a href="https://github.com/WICG/web-codecs/issues/28" rel="nofollow">https://github.com/WICG/web-codecs/issues/28</a><p>But until then it's quite disappointing that developers have to go as far as rolling their own WASM-based solution just to work around the WebAudio API. I've heard unpleasant things about WebAudio and came in with zero expectations and yet was still disappointed. ¯\_(ツ)_/¯