Creative Developers' Corner - Programmer's Handbook

Converting between 8-bit and 16-bit samples

Converting digital audio samples from 16-bit format to 8-bit format, and vice-versa, is very easy. There are only two differences between 16-bit and 8-bit samples:

  1. Sixteen bit samples have eight more less-significant bits (all are lower in significance than the LSB in an 8-bit sample).
  2. Sixteen bit samples are signed values (-32768 to +32767), while 8-bit samples are unsigned (0 to 255).

So if you've recorded a sound in 16-bit format, and want to play it in 8-bit format, here's all you have to do. For each sample point:

  1. Discard the low byte.
  2. Invert the high bit (which has the same effect as adding 80H, converting the sample to unsigned).

To convert 8-bit samples to 16-bit samples, just do the reverse. For each sample point:

  1. Invert the high bit.
  2. Shift the byte left 8 bits, leaving the lower byte zero.
That's all there is to it!

Creative Zone Developers' Corner ©1996 Creative Labs, Inc.