0
0

Hey,
Can anyone share a simple example (like the ones included with fmod) for a dsp, but instead of the default mixer, I want to use a fpu mixer.
The problem is I haven’t been able to get the sample data correctly yet…

  • You must to post comments
0
0

Finally found and fixed the problem.
Stream dsp’s are passed a buffer as it is decoded, which seems to be a 16bit integer buffer, no matter what the mixer is set to.
So that’s the difference with stream dsp’s and dsp’s that are located in the mixer dsp chain…

  • You must to post comments
0
0

Yes, I know, but I seem to be doing something wrong…
Here’s a piece of the code :

void DSP_EffectCallback(void *originalbuffer, void *newbuffer, int length, int param)
{
int count;
float *srcleft,
srcright;
int mixertype = FSOUND_GetMixer();
float l, r;

if (mixertype == FSOUND_MIXER_QUALITY_FPU)
{
srcleft = ((float )newbuffer);
srcright = ((float *)newbuffer)+1;
length <<= 1; //
2 for stereo
}

for (count = 0; count < length; count+=2)
{
if (mixertype == FSOUND_MIXER_QUALITY_FPU)
{
l = srcleft[count];
r = srcright[count];
}

… do some processing …
… handle clipping …

if (mixertype == FSOUND_MIXER_QUALITY_FPU)
{
srcleft[count] = l;
srcright[count] = r;
}
}

return newbuffer;
}

The problem is I keep getting errors (crashes) and when I debug it, sometimes I get values for l and r, but they don’t really make sense to me.
What should floating point values look like?
Are they also ranged -32767 to +32767, or from -1 to +1, or some other format?

  • You must to post comments
0
0

The problem is even more difficult then I thought.
I looked in the fmod example and it had some piece for fpu mixer.
When debugging the application, normal values where retrieved, but when I copied the same piece of code to my dll, it didn’t work.

The code I added was :
if (mixertype == FSOUND_MIXER_QUALITY_FPU)
{
float *src = (float *)newbuffer;
signed short tmp1;
signed short tmp2;

for (int count=0; count < length; count++)
{
tmp1 = (signed short)(src[count << 1]);
tmp2 = (signed short)(src[(count << 1) + 1]);
}
}

The code I already had in my callback for 16-bit mixers works perfectly and looks almost the same.
The only thing I can think of right now is maybe some compiler settings for floating point arrays or something like that?

  • You must to post comments
0
0

Oh, I forgot, the error I receive is an Access Violation on the following line :
tmp1 = (signed short)(src[count << 1]);

When count is about 2200 I think…

  • You must to post comments
0
0

I had a problem like this too…

This was my original code for a DSP which downmixes whatever is in the buffer to mono and stores it for later:

(pi16Buffer is a (signed __int16 *) ptr)
(pDSPBuffer is where I’m storing my stuff)


for (iC = 0; iC < iSamples; iC++)
{
iLV = pi16Buffer[iC << 1];
iRV = pi16Buffer[iC << 1 + 1];
iMonoVal = (signed __int16)((iLV + iRV) / 2);
pDSPBuffer[iC] = iMonoVal;
}

But it kept crashing randomly with large buffer sizes.

It worked when I changed it to this:

for (iC = 0; iC < iSamples; iC++)
{
iLV = pi16Buffer[iC * 2];
iRV = pi16Buffer[iC * 2 + 1];
iMonoVal = (signed __int16)((iLV + iRV) / 2);
pDSPBuffer[iC] = iMonoVal;
}


Weird huh?

  • You must to post comments
0
0

Soz I shoulda added that was for an MMX mixer, but I haven’t tried FPU enough to gauge yet..

HTH,

  • You must to post comments
0
0

Bows head in shame

  • You must to post comments
0
0

I haven’t fixed my problem yet, but I finally found what’s wrong and what causes the Access Violation.
It turns out that a stream dsp passes the length of the buffer in BYTES, and a regular dsp passes the length in SAMPLES.
I think this is quite confusing, and it also makes it very hard to use the same dsp for a stream dsp AND a regular dsp.
It’s probably difficult to change this due to compatibility problems, or is there actually a logical explanation for this?

  • You must to post comments
0
0

Sorry, that wasn’t the problem, I was mistaking in the help file with a stream callback to create a new stream and a dsp callback that works for both stream dsp’s and others.
So i’ll have to search the problem somewhere else…

  • You must to post comments
Showing 9 results
Your Answer

Please first to submit.