0
0

I’m writing PCM data from a DSP in an application using the following method:

[code:8dxqacz4]queue<unsigned char*> wavData;
int pos;
bool isPlaying;

FMOD_RESULT F_CALLBACK dspCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels) {

if(isPlaying) {        
    unsigned char *tmp = new unsigned char[length*2];
    int a;
    for (a=0;a&lt;length*2;a++) 
    {
        unsigned char v=(unsigned char)((inbuffer[a]*128.0)+127.0);
        tmp[a]=(unsigned char) v;
    }

    wavData.push(tmp);
}
unsigned int count;
int count2;
for (count = 0; count &lt; length; count++)
{
    outbuffer[(count * outchannels)] = inbuffer[(count * inchannels)];
    outbuffer[(count * outchannels)+1] = inbuffer[(count * inchannels)+1];
}
return FMOD_OK;

}
[/code:8dxqacz4]

This works fine on OSX and allows me to create an 8bit PCM file that I can do anything with. On WinXP though, the PCM file is just high pitched oscillation. Is there a fundamental difference between what the input buffer will consist of on Win vs on OSX? I’ve tried signed int, unsigned int, unsigned char, and none will generate meaningful PCM data on Win32. Since the sound files I’m playing and mixing are the same and what I hear is the same I’d expect that the data is the same, but apparently this isn’t the case? Any advice would be greatly appreciated.

  • You must to post comments
0
0

[quote:1jst1w2b]signed int, unsigned int[/quote:1jst1w2b]
For those two types you will probably get issues with endianess. However, there shouldn’t be any issues with 8-bit.

You have the number of channels hardcoded to 2, so sure you’re running in stereo mode on Windows:
[code:1jst1w2b]assert(inchannels == 2 && outchannels ==2);[/code:1jst1w2b]

Alternatively change the hardcoded ‘2’ to inchannels if you want to create a multichannel wav.

  • You must to post comments
0
0

Hi Peter,

Thanks for the response. I double-checked the channels are there are 2 inchannels and 2 outchannels every time the DSP is called.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.