Hi Hank,
Thanks for writing. I used your same code above, and the sound fades in fine. Are you sure you’re not missing the start of the fade in and it just sounds like its not fading in?
One thing to note, is that although the code above is usable to make it simple, if you delay too long unpausing your sound then the clock value you set it to fade in at 0 at, will have passed, so when you unpause it might be half way through the fade in for example. In this case it can be better to delay the whole sound start, ie
parentclock+= 1024;
result = channel->setDelay(parentclock, 0);
result = channel->addFadePoint(parentclock , 0.0f);
result = channel->addFadePoint(parentclock + (rate * 5), 1.0f);
Also it may sound like its fading in too quickly, due to constant power law. It might be better to add some more points to make it non linear, ie instead of x, use x*x to generate some more points along the way.
A quick test for you with the original code is just to change 5sec to 15sec, its more obvious that way if it is working or not.
A quick test for you with the original code is just to change 5sec to 15sec, its more obvious that way if it is working or not.
I made the fade a much longer duration (the length of the song) and it doesn’t seem to have any effect. Also tried different formats(original was mp3, but i tried a wav from league of legends which i read uses fmod)
One thing to note, is that although the code above is usable to make it simple, if you delay too long unpausing your sound then the clock value you set it to fade in at 0 at, will have passed, so when you unpause it might be half way through the fade in for example. In this case it can be better to delay the whole sound start
I Added a five second delay to the start of the sound:
MusicChannel->setDelay(parentclock + (rate * 5), 0);
result = MusicChannel->addFadePoint(parentclock + (rate*5),0.0f);
result = MusicChannel->addFadePoint(parentclock + (rate * 100), 1.0f);
And it seems like the first fadepoint is still ignored =(.
I am pretty sure the fade points are being seen:
MusicChannel->getFadePoints(&NumFadePoints, FadePointClocks, Volumes);
for (unsigned int i = 0; i < NumFadePoints; i++)
cout << "Fade Point: " << FadePointClocks[i] << ' ' << Volumes[i] << endl;
gives me the “bad”/first fadepoint but it just doesn’t seem to have any effect.
Maybe It has something to do with the way I Initialize the sound:
system->createSound(ToString(Input).c_str(), FMOD_DEFAULT, 0, &ResultingSound);
or System:
FMresult = system->init(32, FMOD_INIT_NORMAL, extradriverdata);
Also it may sound like its fading in too quickly, due to constant power law. It might be better to add some more points to make it non linear, ie instead of x, use x*x to generate some more points along the way.
Is there a way to check the current level of the fade? I would love to have a solid number rather than guess by ear. I tried:
float CurrentVolume;
MusicChannel->getVolume(&CurrentVolume);
but it always seems to return 1.0f even on the working fade out.
I updated to the latest fmod for this problem v67333
I am still trying to format this post. buttons for code/quote seem to be gone when replying.
Can you try this on your version of the playsound example that comes with the low level API in the fmod SDK? I am having trouble seeing why it wouldn’t work. I thought I saw somewhere that adding a fader fixes it, but all channels come with a fader. Maybe addDSP/setDSPIndex is being used somewhere and removing the fader?
Fading shoudl probably be reflected in Channel::getAudibility but it isnt, i’ll look at adding that for an upcoming release.