AddFadePoint does not fade out gently, causes a click


#1

I’m trying to fade out a song that is playing with a volume of 0.2, but after calling Channel_AddFadePoint I get a click and a sudden drop in volume and then it fades out. This is the code I’m using:
FMOD_RESULT result;
result = FMOD_Channel_SetPaused(m_pChannel, true);
racAssert(result == FMOD_OK);
unsigned long long dspClock;
unsigned long long parentClock;
result = FMOD_Channel_GetDSPClock(
m_pChannel, &dspClock, &parentClock);
if (result != FMOD_OK)
{
throw RacException(“FMOD System_PlaySound error:”, FMOD_ErrorString(result));
}
float volume;
result = FMOD_Channel_GetVolume(m_pChannel, &volume);
if (result != FMOD_OK)
{
throw RacException(“FMOD Channel_GetVolume error:”, FMOD_ErrorString(result));
}
result = FMOD_Channel_AddFadePoint(m_pChannel, dspClock, volume);
if (result != FMOD_OK)
{
throw RacException(“FMOD FMOD_Channel_AddFadePoint error:”, FMOD_ErrorString(result));
}
result = FMOD_Channel_AddFadePoint(m_pChannel, dspClock + timeFadeOut*c_systemSampleRate/1000, 0.0f);
if (result != FMOD_OK)
{
throw RacException(“FMOD FMOD_Channel_AddFadePoint error:”, FMOD_ErrorString(result));
}
result = FMOD_Channel_SetPaused(m_pChannel, false);
racAssert(result == FMOD_OK);

Anyone know what I’m doing wrong?


#2

What sort of values are you using for timeFadeOut & c_systemSampleRate?


#3

c_systemSampleRate is 48000 and timeFadeOut is 5000 (i.e. 5 seconds)


#4

Using your code, and those same values in one of our examples, I get a nice smooth gradual fadeout. Could there be something else in the code effecting it?

Are you able to try this in our examples to see if the problem reproduces?


#5

I forget to mention that the problem happens with a OGG track that is opened with FMOD_CREATESTREAM. Maybe that is something to do with it?
Anyways, I managed to solve the problem a different way. I just call FMOD_Channel_SetVolume each frame with a progressively lower value.


#6

Fade points should work the same on all channels, regardless of what is playing through it. If you are able to reproduce the issue in our examples, please send it through to support@fmod.com and we can investigate it further.