Skip to content

Commit

Permalink
SCI32: Fix SFX volume being misapplied to music & speech in some games
Browse files Browse the repository at this point in the history
This was happening in games with game scripts that control the
master volume themselves by applying the master volume to each
channel sent to the kernel, instead of relying on the kernel to
manage the master volume for them.
  • Loading branch information
csnover committed Aug 26, 2017
1 parent 72b033c commit 7473848
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
11 changes: 11 additions & 0 deletions engines/sci/engine/features.h
Expand Up @@ -110,6 +110,17 @@ class GameFeatures {
}
}

inline bool gameScriptsControlMasterVolume() const {
switch (g_sci->getGameId()) {
case GID_LSL7:
case GID_PHANTASMAGORIA2:
case GID_TORIN:
return true;
default:
return false;
}
}

inline bool hasSci3Audio() const {
return getSciVersion() == SCI_VERSION_3 || g_sci->getGameId() == GID_GK2;
}
Expand Down
16 changes: 12 additions & 4 deletions engines/sci/sound/audio32.cpp
Expand Up @@ -181,10 +181,18 @@ Audio32::Audio32(ResourceManager *resMan) :
}

_useModifiedAttenuation = g_sci->_features->usesModifiedAudioAttenuation();
// The mixer stream type is given as `kSFXSoundType` so that audio from
// Audio32 will be mixed at the same standard volume as the video players
// (which must use `kSFXSoundType` as well).
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);

// In games where scripts premultiply master audio volumes into the volumes
// of the individual audio channels sent to the mixer, Audio32 needs to use
// the kPlainSoundType so that the master SFX volume is not applied twice.
// Otherwise, we simply pass along master volume changes to the ScummVM
// mixer for the kSFXSoundType and allow it to control master volume.
// (The volume of the kSFXSoundType in the mixer still needs to be updated
// for games that control master volumes themselves so that videos will play
// at the same volume as the rest of the game.)
const Audio::Mixer::SoundType soundType = g_sci->_features->gameScriptsControlMasterVolume() ? Audio::Mixer::kPlainSoundType : Audio::Mixer::kSFXSoundType;

_mixer->playStream(soundType, &_handle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
}

Audio32::~Audio32() {
Expand Down

0 comments on commit 7473848

Please sign in to comment.