0

I want to read the data of an 8bit wav file using textPad, I know that the data is located at the 44/46th byte, but I am having problems reading it.

I have that code:

52 49 46 46 F8 37 01 00 57 41 56 45 66 6D 74 20
12 00 00 00 06 00 01 00 40 1F 00 00 40 1F 00 00
01 00 08 00 00 00 66 61 63 74 04 00 00 00 C6 37
01 00 64 61 74 61 C6 37 01 00 D6 D4 56 54 D5 56
56 51 D4 D3 D0 D6 54 57 D4 54 57 51 57 D0 D3 D1

etc.

The part in bold is the data of it.

The problem is when i read it in sndfile using sf_read_int I get in the buffer the following values:

3670016  1572864  -3670016   -1572864   524288   -3670016   -3670016 

etc

How am I supposed to read the data in the wav file? What is the equation or 'relationship' between the numbers i got in sndfile and the data in textPad?

Oh and one more thing, if i switch the reading to sf_read_float instead of int i get values between -0.0001 and +0.0001...

Any idea what's happening, the writing and data processing is very good but I don't understand what's up with these values.

Thank you.

2 Answers2

1

You have some pattern to see in a .wav file:

  • "RIFF" : 0x52 0x49 0x46 0x46
  • "WAVE" : 0x57 0x41 0x56 0x45
  • "fmt " : 0x66 0x6d 0x74 0x20
  • "data" : 0x64 0x61 0x74 0x61

We see 64 61 74 61 at offset 50. So data begins only at offset 54 and not 46.

You can find a wave specification to understand how is encoded your file.

Thanks to this spec, I can tell you that your file is encoded in "8-bit ITU-T G.711 A-law".

Mathieu
  • 8,840
  • 7
  • 32
  • 45
1

Okay so i found out that the wav file is encoded and libsndfile takes care of it without any intervention. That caused the "unequal" values.