# WAV encoding problem

When processing wav files, I encounter this problem: the what I extract PCM from a 8-bit encoded .wav file, I got a sequence of integers. However, when verifying my implementation with wavread in Matlab, the PCM code is represented with so-called double-precision normalized samples. My question is what's the difference between these two format. For example, the hex number is 0x80 0x81, the corresponding double-precision normalized samples are 0, 0.0078. IIRC, PCM code in .wav file records sound pressure value of audio. Is double-precision normalized samples sound pressure level? If so the value should be $10log(P_1/P_2)$ (based 10). But $10log(129/128)$is not 0.078 instead $10ln(129/128)$(based $e$) is. Anything wrong with my intuition?

Thanks and best regards.

The PCM values are proportional to the sound pressure. 8-bit PCM is stored with an offset of 128, so PCM coded values from 0 to 255 code for 'pressure values' from -128 to 127. These values are often normalized to the range -1.0..+1.0. The PCM values are linear representation of the sound pressure, and a log operation is only required if you want to express the sound pressure in decibels. To get actual sound pressure levels in Pascal or dB(A) you would need a calibrated .wav signal.

• Thanks for the reply. So the 0.0078 comes from $(129-128)/128$? – Summer_More_More_Tea Mar 11 '12 at 11:19
• Yes, the [0, 255] range is mapped to [-1, 1 - 1 / 256.0] using the transformation you gave. – pichenettes Mar 11 '12 at 11:46
• @pichenettes Thanks. Thank you all. That's what I need! – Summer_More_More_Tea Mar 11 '12 at 12:08
• You need to calibrate the microphone for that. A calibrator generates a signal with a precisely known sound pressure level, then from the recorded PCM levels you can calculate the scale factor. – Han Mar 12 '12 at 8:33
• @endolith -1 in 2's-complement is 1111110 binary. In 8-bit PCM -1 is 01111111. – Han Mar 12 '12 at 20:59