[SOLVED] Recorded WAV file has weird bits per sample in the format chunk

I’ve had reports of recorded audio not working on several occasions.

The app (JUCE 7.0.7) is configured to record 44.1kHz 24bit WAV. Sometimes, for no apparent reason, the recorded audio file is unreadable. I debugged the offending audio file and WavAudioFormatReader fails when the bits per sample is 56. The value is obviously wrong.

What could cause JUCE to produce a WAV file with such, most likely erroneous, format? Is this a JUCE bug or could a possibly buggy audio hardware or driver cause something like this?

WaveLab had no problems opening and playing the file and it seems the problem is only on this bits per sample value, which is obviously incorrect, and the reader just fails with any value between 32 and 64.

What would be the best way to try and tackle this?

On what platform are you writing the WAV file, and how are you writing it? Are you definitely using the JUCE WavAudioFormatWriter as opposed to a platform-specific writer? Are you calling replaceMetadataInFile anywhere?

1 Like

Doh… false alert. The WAV file is fine and a hex-editor shows that the bitsPerSample value is actually correct. My mistake. Sorry for the trouble.