I am having some trouble generating MP3s from 24-bit source input using LAME (the library, not the command-line encoder).
There are two API candidates to choose from: lame_encode_buffer_long2 and lame_encode_buffer_int. On my system both longs and ints are 4 bytes, so scaling of these types isn't an issue. I wasn't sure which function would be best. In any case, I have used lame_encode_buffer_long2 to generate MP3s from 32-bit source input with no problems. When I attempt to do the same with 24-bit input, I get extremely garbled output.
I assume that since LAME doesn't support 24-bit input naturally, I need to rescale the 24-bit input to match 32-bit scaling. This is the gist I got from lame.h, anyway.
I've tried to rescale the input several different ways: source << 8, (source << 8) | (source & 0xFF), and even passing it straight through- all of which produce different (but equally garbled) output.
I should probably mention that the input is coming from a 24-bit AIFF file, and the data to be processed is coming from an AudioBufferList (on OS X).
Anyone have any ideas?
