[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: [linux-audio-dev] 24 bits, 2's complement - help!
From: Paul Barton-Davis (pbd_AT_Op.Net)
Date: la tammi  15 2000 - 10:43:17 EST


i am trying to figure out how to convert 24 bit samples to 16. The 24
bits seem to be encoded in Intel style (little endian, 2's complement
for negative). it seemed simple to me.

but consider this: the 24 bits are part of a 32 bit unit. the
right-most byte is always zero.

the range of numbers we can represent with 24 bits (23 bits+sign bit)
is 8388607 .. -8388607. yet with 2's complement, -9189120 is (bytes
right to left):
         
         0 c9 73 ff

So a 32 bit unit containing a 24 bit quantity that just happens to
look like this is seen by the processor as a number that is larger
than the signed 24 bit minimum value.

I am totally confused. System architecture rather than bytes and bits
was always my interest in programming, and I could use some
help. Clearly. I imagine its very simple, and just something that i
never had to learn in the last 13 years :)

--p


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