I posted this in stackoverflow but a poster suggested I ask the question here too...
Basically, I'm getting a USB audio stream in the form of a unsigned 8-bit integer pointer. I want to convert whatever bit rate it's using (whether 16 or 24 bit audio) and scale it up to 32 bits. Once it's scaled up to 32 bits, I'm placing it in a microcontroller's peripheral that will output the data in a 32 bit register. I would also like to do this in the reverse order (getting input from a codec in 32-bit words and then sending it to my USB Host in either 16 or 24 bit audio streams).
Just wanted to open a discussion on how people bit scale these streams and what techniques/algorithms they use.
tl;dr - I want to be able to scale up 16/24 bit audio streams to 32 bit words and vice versa for scaling down. I know the process for scaling down as such:
// For 32 to 16 bits uint16_t adjusted_bit = uint32_bit_data >> 16; // For 32 to 24 bits uint32_t adjusted bit = uint32_bit_data >> 8;