views:

35

answers:

3

I have to reduce the bit-depth of a digital audio signal from 24 to 16 bit.

Taking only the 16 most significant bits (i.e. truncating) of each sample is equivalent to doing a proportional calculation (out = in * 0xFFFF / 0xFFFFFF)?

+2  A: 

You'll get better sounding results by adding a carefully crafted noise signal to the original signal, just below the truncating threshold, before truncating (a.k.a. dithering).

tdammers
I know that by reducing bit depth I'm introducing quantization noise (and therefore a reduced 24 bit signal would sound worst than a 16 bit master), but how can I "carefully craft" the noise for the dithering?
Lorenzo
The goal of dithering is to distribute the rounding error, but you want to minimize the amount of audible artifacts you are introducing. White noise would be a good starting point, but depending on the application, balancing the noise's spectrum one way or the other might deliver better results.
tdammers
+1  A: 

I assume you mean (in * 0xFFFF) / 0xFFFFFF, in which case, yes.

andrewmu
Of course, sorry for the typo...
Lorenzo
And of course you could simply shift the bits down: `out = in >> 8` (for unsigned samples).
andrewmu
Why only for unsigned samples?
Lorenzo
Because if you have signed samples you might be able to do: `out = in >>> 16`, but you maybe need to extend up the sign bit if only 24 bits are actually set in your original data.
andrewmu
@andrewmu: I'm working in C++ so no need to >>>. I have 24 bit signed samples stored in 32 bit signed integers, so the value "-1" is the same for all the bit-depths.
Lorenzo
+1  A: 

Dithering by adding noise will in general give you better results. The key to this is the shape of the noise. The popula pow-r dithering algorithms have a specific shape that is very popular in a lot of digital audio workstation applications (Cakewalk's SONAR, Logic, etc).

If you don't need the full on fidelity of pow-r, you can simply generate some noise at fairly low amplitude and mix it into your signal. You'll find this masks some of the quantization effects.

Nick Haddad