0
0

hi… i’m trying to make my own DSPs… i’ve started with a simple gain unit… the thing is that when i activate it, the callback causes a lot of noise to be added to the signal as well as cutting/stuttering of sound… i don’t know why this happens, my code is very simple… can you take a look and tell me if you have any ideas what the problem might be?

void * F_CALLBACKAPI DSP_GainCallback(void *originalbuffer, void *newbuffer, int length, int param)
{

signed short * originalBuf = (signed short *) newbuffer;
int i = 0;

for(i = 0; i < length; i++)
{
       *(originalBuf+i) *= 5;
}

//FSOUND_DSP_MixBuffers(newbuffer, originalBuf, length, 44100, 255, 128, FSOUND_16BITS | FSOUND_MONO);


return originalBuf;

}

what do you think? The rest of the code i’m using is essentially the same with the Record sample from the fmod download.

thanx.

Aris

  • You must to post comments
0
0

ok. But listen:

for 1. I use FSOUND_SetMixer(FSOUND_MIXER_QUALITY_AUTODETECT) to set the mixer and when i do get mixer i get the same result, thus i can’t tell if its 16bit integer or 32 bit float (which i don’t think it is)

for 2. you suppose i’m using stereo samples, but i’m only using mono so i guess i’m not missing half the samples.

for 3. this is the updated code:

signed short * originalBuf = (signed short *) newbuffer;
int i = 0;
signed int value = 0;
for(i = 0; i < length; i++)
{
    value = (signed short)*(originalBuf+i);
    value *= 5;
    if(value > 32767)
    {
        value = 32767;
    }
    else if(value < -32768)
    {
        value = -32768;
    }
    *(originalBuf+i) = (signed short) value;


}

//FSOUND_DSP_MixBuffers(newbuffer, originalBuf, length, 44100, 255, 128, FSOUND_16BITS | FSOUND_MONO);


return originalBuf;

}

that’s what you meant by clipping it, right?

still, i’m getting a buzz :/

sorry to ask you so many questions about these things but i guess once i reach a certain level i’ll move on pretty quickly… till then… 😉

thanks

Aris

  • You must to post comments
0
0

actually… when i’m recording a sample at 16bits, are the bytes ordered in little or big endian mode? maybe that’s my problem…

Aris

  • You must to post comments
0
0

one more thing… down to the low level stuff
a 16 bit sample consists of two bytes
so, when i print the two bytes (as signed ints)
i get: the first byte of each sample is somewhere around -22 (without playing anything) and the second byte is always 0. Now, i know that i must shift the bits of the first byte by 8 to the left and then OR the other byte on the shifted value.
does that sound about right to you? i’m really confused as to why i can’t get the callback to work properly and i think its something to do with not reading the values of the samples correctly.

Aris

  • You must to post comments
0
0

i’m sorry, i don’t understand what you said about the stereo output… is the buffer i’m manipulating (newbuffer) holding sterero or mono samples?
or is it just that whatever gets passed on is switched to stereo?

thanx

Aris

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.