Changed the music fading so that the volume is increased when ABS(_fading)

grows larger, both when fading up and down. This fixes the problem where
the volume would "jump" when changing the fading "direction" of a stream.

svn-id: r12373
This commit is contained in:
Torbjörn Andersson 2004-01-14 08:09:03 +00:00
parent b17d77eae9
commit 2fb7d4c553

View File

@ -45,7 +45,7 @@ void MusicHandle::fadeUp() {
if (_fading > 0)
_fading = -_fading;
else if (_fading == 0)
_fading = -(FADE_LENGTH * getRate());
_fading = -1;
_fadeSamples = FADE_LENGTH * getRate();
}
@ -74,8 +74,10 @@ int MusicHandle::readBuffer(int16 *buffer, const int numSamples) {
}
sample = (sample * _fading) / _fadeSamples;
} else if (_fading < 0) {
_fading++;
sample = (sample * (_fadeSamples + _fading)) / _fadeSamples;
_fading--;
sample = -(sample * _fading) / _fadeSamples;
if (_fading == -_fadeSamples)
_fading = 0;
}
*buffer++ = sample;
}