A
_Andy_
I'm looking for the alogithm to take a piece of 8-bit audio data, and
scale it to a 16-bit short. I got as far as:
private static short ByteToShort(byte b)
{
int word = 0;
word |= ( ( b & 0x01 ) << 1 );
word |= ( ( b & 0x02 ) << 2 );
word |= ( ( b & 0x04 ) << 3 );
word |= ( ( b & 0x08 ) << 4 );
word |= ( ( b & 0x10 ) << 5 );
word |= ( ( b & 0x20 ) << 6 );
word |= ( ( b & 0x40 ) << 7 );
word |= ( ( b & 0x80 ) << 8 );
if( b < 0 )
return (short) ( word - 32768 );
else
return (short) ( word );
}
(The "word" was originally a "short", but I kept getting CS0675).
The wall has got a hole in about the size of my head, so your help
would be appreciated!
Rgds,
scale it to a 16-bit short. I got as far as:
private static short ByteToShort(byte b)
{
int word = 0;
word |= ( ( b & 0x01 ) << 1 );
word |= ( ( b & 0x02 ) << 2 );
word |= ( ( b & 0x04 ) << 3 );
word |= ( ( b & 0x08 ) << 4 );
word |= ( ( b & 0x10 ) << 5 );
word |= ( ( b & 0x20 ) << 6 );
word |= ( ( b & 0x40 ) << 7 );
word |= ( ( b & 0x80 ) << 8 );
if( b < 0 )
return (short) ( word - 32768 );
else
return (short) ( word );
}
(The "word" was originally a "short", but I kept getting CS0675).
The wall has got a hole in about the size of my head, so your help
would be appreciated!
Rgds,