diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index 4b452aad56d..fd1e6f1bd95 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -36,6 +36,9 @@ namespace Sci { +// When defined, volume fading immediately sets the final sound volume +#define DISABLE_VOLUME_FADING + SciMusic::SciMusic(SciVersion soundVersion) : _soundVersion(soundVersion), _soundOn(true) { @@ -513,6 +516,7 @@ MusicEntry::MusicEntry() { fadeTickerStep = 0; fadeSetVolume = false; fadeCompleted = false; + stopAfterFading = false; status = kSoundStopped; @@ -557,7 +561,11 @@ void MusicEntry::doFade() { // Only process MIDI streams in this thread, not digital sound effects if (pMidiParser) +#ifndef DISABLE_VOLUME_FADING pMidiParser->setVolume(volume); +#else + pMidiParser->setVolume(fadeTo); +#endif fadeSetVolume = true; // set flag so that SoundCommandParser::cmdUpdateCues will set the volume of the stream } } diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h index ce1570eb2cb..049e192c237 100644 --- a/engines/sci/sound/music.h +++ b/engines/sci/sound/music.h @@ -95,6 +95,7 @@ public: uint32 fadeTickerStep; bool fadeSetVolume; bool fadeCompleted; + bool stopAfterFading; SoundStatus status; diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp index 8a09b078cf5..feaa2e69060 100644 --- a/engines/sci/sound/soundcmd.cpp +++ b/engines/sci/sound/soundcmd.cpp @@ -669,12 +669,13 @@ void SoundCommandParser::cmdFadeSound(reg_t obj, int16 value) { musicSlot->fadeTicker = 0; break; - case 5: // Possibly SCI1?! - case 6: // SCI 1.1 TODO: find out what additional parameter is + case 5: // SCI01+ + case 6: // SCI1+ (SCI1 late sound scheme), with fade and continue musicSlot->fadeTo = CLIP(_argv[2].toUint16(), 0, MUSIC_VOLUME_MAX); musicSlot->fadeStep = volume > _argv[2].toUint16() ? -_argv[4].toUint16() : _argv[4].toUint16(); musicSlot->fadeTickerStep = _argv[3].toUint16() * 16667 / _music->soundGetTempo(); musicSlot->fadeTicker = 0; + musicSlot->stopAfterFading = (_argc == 6) ? (_argv[5].toUint16() != 0) : false; break; default: @@ -846,6 +847,8 @@ void SoundCommandParser::cmdUpdateCues(reg_t obj, int16 value) { cmdStopSound(obj, 0); } else { PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET); + if (musicSlot->stopAfterFading) + cmdStopSound(obj, 0); } }