.wav file format

12mar25
I’m interested in understanding what the data format is in the .wav files
I have a little sound recorder which is a bush CMP33DB
I have worked out that the file starts with 44 bytes of data followed by 0s
The sound data starts at 512.
The data is in 1024 byte chunks, running at 4000 bytes per recorded second.
In the chunk, there is a 4 byte leader.
The first is a signed word (2 bytes, LSB and MSB). I don’t know what it does.
Then there is a volume scaling byte which varies with the sound volume of the
chunk recording.
Then there is a 0.
After that there is the data which seems to relate to the sound recorded.
But I’m struggling to work out what the rules are for this data.
Any help would be appreciated.

It’s a standard format, did you try searching for information

12mar25
Yepp, I spent a few hours on different occasions checking out the internet for
any information on .wav files.
My search notes were: wav file definition, geeks for geeks, wavfile specification
McGill university, fileformat wikkipeadia/waveformat tech details and so on
I couldn’t find anything that explained the rules for the data stream bytes.
One of the youtube sites explained the header information and it seesm that
my data stream is made up of 4 bit nibbles (I think that’s what they’re called).
But gave no information on the data stream itself.
I did a spectrum analysis this morning of the 16 possible values and the no of
times each was used in a 4 minute piece of music. Of the 2,060,400 nibbles, about
half were 0. The other values were used in smaller numbers with 3 and 9 having
the highest numbers. 15 was only used 12000 times.
It might be possible that 0 is a control byte followed by a few bytes specifying
some change in sound during the 1/4 second data chunk.
This is the extent of my efforts to deduce what the rules might be, but it’s
taking me ages with no real results.
If I could find a doc that specifies what string of data is required to generate
a sound that would be very helpful.
I guess that different frequencies are just stacked on top of each other. I can
easily deal with that. What I can’t do is relate the data bytes in the files to
the actual sounds generated.
If someone should know from first principles what the data means; that would be
great.

What’s your goal here?

Maybe one of these open source codec projects would help:

https://github.com/warrengalyen/libsoundwave

https://github.com/facebookresearch/AudioDec

https://github.com/Dakkra/OpenWav

Did you read about codecs, encoding/decoding, modulation/demodulation?

The file format is just binary data. Trying to derive how a binary data format is written and read just by looking at the file isn’t very realistic.

Most wav files are some PCM format.

13mar25
Thanks for this lasjorg. I did read up on this days ago and applied the ideas to
a program I’ve written which creates a .wav file. This used the 4 bit nibbles to
create the samples. I chose a frequency that had a period of the factors of 1020
(1024 is the data chunk size - 4 byte leader) 1020 = 4 * 3 * 5 * 17. This is to
avoid phase changes at the end of each data chunk.
So I chose 60 bytes period (68 Hz) and inserted 1 bit and got a racket when I used
the .wav file player. I think I will create an empty file, and start inserting
bits one at a time to see what happens. I envisaged that this was going to be a
really slow process, which I why I made the enquiry on the forum.
I’m wanting to practice some music that we’re singing to in a show we’re doing
next month. The musical director says he hasn’t the time to record all 4 parts
for us. It would only take him 3 hours to do this. So, we’re stuck with
reading from the score, and rehearsing little bits each week.
Our practice sessions are 3 hours of his time each week, and we might just cover
a tenth of the whole show. It’s weird that he does this.
I’ve asked a pianist I know to play the music for my part, but he’s not good,
missing notes everywhere. I can’t read music myself.
So, 12 days ago, I thought I’d do an investigation into
producing a .wav file using Visual Studio’s c++ to interrogate and create .wav
files. And that has been 10 hours a day. I’ll will have another go at the pwm,
but I may have to be mindful of any virtual D/A hitting the limits and then
causing huge distortion.
I’ll have a look the websites that pkdvalis suggested.
What I really need is a document that specifies exactly how the data chunk is
created and how it is used by the .wav player. And this includes the mysterious
word in the leader, that I mentioned earlier.
In the leader the .wav type is 17. This might be a Bush CMP33DB “special”.
That the little recorder that I’m using. “special” could be anything! But it’s
recognised by the .wav player on my pc.