From 2fb7d4c553e01cebc5a3f30485db015fd884ff80 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Wed, 14 Jan 2004 08:09:03 +0000 Subject: 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 --- sword1/music.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sword1') diff --git a/sword1/music.cpp b/sword1/music.cpp index 911cfceb1d..8b0af804c3 100644 --- a/sword1/music.cpp +++ b/sword1/music.cpp @@ -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; } -- cgit v1.2.3