This project has moved. For the latest updates, please go here.

Sample to 24bit pcm

Jun 16, 2013 at 4:48 PM
Edited Jun 16, 2013 at 8:09 PM
How can I convert a sample(float32) to a 24bit pcm?
I tried different ways like:
                float sample32 = _buffer[i] * 8388608f;
                byte* p = (byte*)&sample32;
                buffer[bufferOffset++] = p[1];
                buffer[bufferOffset++] = p[2];
                buffer[bufferOffset++] = p[3];
but i don't get it :(

EDIT solved:
                uint sample32 = (uint)(_buffer[i] * 8388608f);
                byte* psample32 = (byte*)&sample32;
                buffer[bufferOffset++] = psample32[0];
                buffer[bufferOffset++] = psample32[1];
                buffer[bufferOffset++] = psample32[2];