0

I have a JS webaudio AudioBuffer which I convert to WAV using 3rd party code, and the length / size of WAV is always at least twice the size of the AudioBuffer. As I am handling long duration audio (multi MB) its a potential issue.

My AudioBuffer is single channel (mono) and I have confirmed I am creating a mono WAV (where the library creates a stereo WAV, file size is 4x). I have tried using several solutions for the conversion but cannot get a WAV file of same size as AudioBuffer. I tried Crunker, audiobuffer-to-wav, this post. With audiobuffer-to-wav I tried both 16 bit (2x) and 32 bit (4x).

Maybe it is not possible and due to audio data formats. But ideally I could get a WAV the same file size as AudioBuffer or even better a compressed MP3.

As context, I am feeding the WAV into an HTML audio element. I realise I can play audio direct with Web Audio, but have reasons to use an HTML audio element. Thanks for any help!

Gavin
  • 1
  • 2

1 Answers1

0

The AudioBuffer size you are getting is probably in samples, which are 16 bit or 32 bit when you convert them to WAV. If you can get 8 bit output the length will match (but the quality won't be very good).

Hamish Moffatt
  • 826
  • 4
  • 12