BASS_ChannelGetData

Started by Irrational86,

Irrational86

Is there a way of always retrieving one kind of PCM data from BASS_ChannelGetData?? For example, I want to always retrieve 8bit or 16bit data, but the channel is a 32bit FloatingPoint channel. How can I do this?

Ian @ un4seen

To convert floating-point sample data to 16-bit, simply multiply each sample by 32768, and restrict the result to between -32768 and 32767. For example...
void float2short(float *src,short *dst,int count)
{
      int a;
      for (a=0;a<count;a++) {
            int b=src[a]*32768;
            if (b<-32768) b=-32768;
            else if (b>32767) b=32767;
            dst[a]=(short)b;
      }
}

For 8-bit, multiply by 128, add 128 (because 8-bit PCM is unsigned), and restrict the result to between 0 and 255.