I'm doing music processing on 24bit samples. The raw samples are stored in a char array. I want to convert this array to a qint24 array.
Now since there is no qint24 type, I decided to use qint32. A char has a size of 1 byte, so I will have to convert 3 chars to a 24bit sample at a time and store it in a qint32. This is what I'm currently doing:
buffer is the char array and result my new array for the 24bit samples. g++ complaints that it can't convert char* to qint32 (loses precision).Code:char temp[3]; int bufferCurrent; for(int i = 0; i < size; ++i) { bufferCurrent = i * 3; temp[0] = buffer[bufferCurrent]; temp[1] = buffer[bufferCurrent + 1]; temp[2] = buffer[bufferCurrent + 2]; result[i] = reinterpret_cast<qint32>(temp); }
So I basically need some way to convert 3 chars to a qint32. Any ideas of how to accomplish this?

Reply With Quote

