lundi 2 février 2015

Convert 24 bit signed int signal to 16 bit signed int signal

To put it as simply as I can.



  1. I receive data from device and the signal is 24 bit signed int.

  2. I want to create 16 bit WAV file.

  3. For this purpose I want to keep writing upcoming audio buffer with 256 samples to *.wav file stream.

  4. How can I convert buffer values (well values written in simple pointer to 256 element array) from [24 bit signed int] to [16 bit signed int].


Is there any scaling value? For example when I wanted to cast [24 bit signed int] to [24 bit signed double] I did it like this:



for (int i=0; i<256; i++) {
bufferInDouble = *((int*)bufferRawData[currentPan]+i) / (double)0x7fffffff;
}


Any similar method could be there?


Aucun commentaire:

Enregistrer un commentaire