AudioBuffer size vs Wav file size

I’m sure there’s a simple answer but I’m trying to understand why an audio AudioBuffer size is larger than the wav file it comes from.

Example: I have a 2.3mb wav file, and when I load it into an AudioBuffer if I do a calculation (numSamples * numChannels * sizeof(float)) I end up with 3,45mb… What am I not calculating or taking into consideration? Is it the bitrate?

And finally, is there any way to have an AudioBuffer that has a size that matches the wav file? I’m sending the audio through sockets so anything that can save room is something I’m interested in.


This is most probably because the AudioBuffer stores samples as normalized 32Bit floating point values (aka float) while the wav format allows different types.

While there are 32 Bit float wav files, most of the time 24 Bit or 16 Bit integer will be used as the sample type of a wav file, leading to a smaller file size. However, as far as I know there is no direct way of using integer audio buffers in juce. If your main goal is less bytes to transfer, you could consider sending the wav file content directly and decoding it at the receiver side.

Thanks for the answer, that makes sense. I’ll need to brush up some more on this subject. My goal is less bytes to transfer, with the user case of someone dropping a sample and another user being able to hear it play as quick as possible.

Thinking out loud, I suppose the fastest way would be to convert to flac, write to file, then transfer just the audio data from the flac file over the socket, then read on player 2s side as it comes in.