Re: [linux-audio-dev] 24 bits, 2's complement - help!

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] 24 bits, 2's complement - help!
From: Benno Senoner (sbenno_AT_gardena.net)
Date: la tammi  15 2000 - 14:32:01 EST


On Sat, 15 Jan 2000, Paul Barton-Davis wrote:
> >assume you have a 24bit int padded with 8bits of zeroes.
> >just take the uppermost 16bits and copy these into a signed int.
>
> I know that will work, but to quote Bill:
>
> >All this will do the trick, but remember that truncation for word
> >length reduction is considered a cardinal sin in digital audio.
> >You're throwing away useful information that you can demonstrate
> >mathematically can be at least partially preserved by the use of
> >dither.
>
> i'm doing fractional conversion: 16bit_val = (24bit_val/24bit_max) * 16bit_max;

way to complicated ... (and maybe ZERO advantages)
:-)

are you using floating point for the operation above ?
if yes this it may work if you round the result.
I don't know if you have to call rint() in order to round things.

if you don't use floating point, you may use
(24bit_val*16_bit_max)/24bit_max
but you will need 64bit longs then in order to preserve the precision.
but ints do not round , they only truncate .. therefore this will not bring
ANY advantage to my truncation method.

For dithering use the following: assume you have the 24value
(stored in a 32bit int signed).
generate a table ( 100k values or so) with 8bit random values ranging
from -128 to +127.

add this random number to the 24bit sample data,
but check clipping (that the 24bit value doesn't exceed the 24bit range)
then just truncate you will have dithered 16bit audio.

Benno.


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:23:26 EST