Reading in 16 and 24-bit audio data into (32-bit) integer buffers
Here is what I am trying to do. I am writing an audio processing program that can read 16 and 24 bit WAV files into int (32-bit) buffers.
The 16-bit condition is straight-forward: I would read in the required number of bits into short buffers. However, since C++ does not have a native 24-bit datatype, and I would like to use the same buffer for 16 or 24 bit data, I would have to read the WAV file data into int buffers.
The further processing that the program does is on the ENTIRE contents of the int buffer and NOT on a byte-by-byte basis.
I have written the WAV read/write part of the program. Where I am running into a bit of difficulty is unpacking three bytes of data (24-bits) into a 32-bit container.
Should I copy the contents of the audio file into a temporary buffer as contiguous data and then fill my main buffer with three bytes of this data, and then skip a byte?
Is there any other way that you would recommend reading 24-bit data into a 32-bit buffer?
Thank you for your pointers, as it were. I do not expect code to be written for me, but pseudocode would be immensely helpful.