diff options
author | Robert Göffringmann | 2004-01-01 16:56:00 +0000 |
---|---|---|
committer | Robert Göffringmann | 2004-01-01 16:56:00 +0000 |
commit | cf12a5846fc6a164ad46b79c2e12c54128a69ab8 (patch) | |
tree | 4aa8dc4ae4ec74eb772793fbc5acac0f4b805ad1 /sword1 | |
parent | 18f8916c3aef4b0dec659a0c053517bb9c7aa880 (diff) | |
download | scummvm-rg350-cf12a5846fc6a164ad46b79c2e12c54128a69ab8.tar.gz scummvm-rg350-cf12a5846fc6a164ad46b79c2e12c54128a69ab8.tar.bz2 scummvm-rg350-cf12a5846fc6a164ad46b79c2e12c54128a69ab8.zip |
changed music fading duration and made music system fade down the tracks on startMusic(0)
svn-id: r12071
Diffstat (limited to 'sword1')
-rw-r--r-- | sword1/music.cpp | 21 | ||||
-rw-r--r-- | sword1/music.h | 1 |
2 files changed, 15 insertions, 7 deletions
diff --git a/sword1/music.cpp b/sword1/music.cpp index e4dfa33d84..9e8bcee336 100644 --- a/sword1/music.cpp +++ b/sword1/music.cpp @@ -25,8 +25,8 @@ #include "common/util.h" #include "common/file.h" -// This means fading takes about half a second. This may need some tuning... -#define FADE_SAMPLES 5512 +// This means fading takes 3 seconds. +#define FADE_LENGTH 3 // These functions are only called from SwordMusic, so I'm just going to // assume that if locking is needed it has already been taken care of. @@ -35,14 +35,16 @@ void SwordMusicHandle::fadeDown() { if (_fading < 0) _fading = -_fading; else if (_fading == 0) - _fading = FADE_SAMPLES; + _fading = FADE_LENGTH * getRate(); + _fadeSamples = FADE_LENGTH * getRate(); } void SwordMusicHandle::fadeUp() { if (_fading > 0) _fading = -_fading; else if (_fading == 0) - _fading = -FADE_SAMPLES; + _fading = -(FADE_LENGTH * getRate()); + _fadeSamples = FADE_LENGTH * getRate(); } bool SwordMusicHandle::endOfData() const { @@ -74,10 +76,10 @@ int16 SwordMusicHandle::read() { _looping = false; _file.close(); } - sample = (sample * _fading) / FADE_SAMPLES; + sample = (sample * _fading) / _fadeSamples; } else if (_fading < 0) { _fading++; - sample = (sample * (FADE_SAMPLES + _fading)) / FADE_SAMPLES; + sample = (sample * (_fadeSamples + _fading)) / _fadeSamples; } return sample; } @@ -153,9 +155,14 @@ void SwordMusic::startMusic(int32 tuneId, int32 loopFlag) { } char fName[20]; sprintf(fName, "music/%s.wav", _tuneList[tuneId]); - _handles[newStream].play(fName, loopFlag); + _handles[newStream].play(fName, loopFlag != 0); delete _converter[newStream]; _converter[newStream] = makeRateConverter(_handles[newStream].getRate(), _mixer->getOutputRate(), _handles[newStream].isStereo(), false); + } else { + if (_handles[0].streaming()) + _handles[0].fadeDown(); + if (_handles[1].streaming()) + _handles[1].fadeDown(); } } diff --git a/sword1/music.h b/sword1/music.h index 7820efec3e..24c75e3534 100644 --- a/sword1/music.h +++ b/sword1/music.h @@ -39,6 +39,7 @@ private: File _file; bool _looping; int32 _fading; + int32 _fadeSamples; int _rate; bool _stereo; public: |