Skip to content
Advertisement

Convert AudioBuffer to ArrayBuffer / Blob for WAV Download

I’d like to convert an AudioBuffer to a Blob so that I can create an ObjectURL from it and then download the audio file.

JavaScript

Advertisement

Answer

An AudioBuffer contains non-interleaved Float32Array PCM samples for each decoded audio channel. For a stereo AudioBuffer, it will contain 2 channels. Those channels need to be interleaved first, and then the interleaved PCM must have a WAV header appended to it so you can download and play as a WAV.

JavaScript

supporting functions below:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement