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:
- Sixteen bit samples have eight more less-significant bits (all are
lower in significance than the LSB in an 8-bit sample).
- 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:
- Discard the low byte.
- 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:
- Invert the high bit.
- Shift the byte left 8 bits, leaving the lower byte zero.
That's all there is to it!
©1996
Creative Labs, Inc.