hexpcmtrigonometryaudacity

Understanding hex output of raw 8-bit 8000Hz PCM sine wave


Using Audacity, I generated a 1Hz Sine Wave with a 1 second length and 1.0 amplitude. This resulted in the following wave as expected.

enter image description here

With the Audacity sample size set to 8000Hz, I then exported the audio as RAW (header-less) Signed 8-bit PCM which resulted in an 8000 byte file (each byte is an 8-bit number between -128 and +127).

Opening up the .raw file in HxD and then setting the 'Bytes per row' to 1 and the Offset to decimal shows 8000 lines, each line showing the 8-bit number in Hex.

enter image description here

I can see that there are 10 0's then 10 1's then 10 2's and so on but once it goes to 16, there are 11 16's but then 10 17's and 10 18's. My question is, why are there 10 of some numbers and 11 of others?


Solution

  • This is just the shape of the sine wave. As you get closer to the maximum the curve is flatter so you get more equal sample values.