diff options
Diffstat (limited to 'engines/xeen/sound.cpp')
-rw-r--r-- | engines/xeen/sound.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/engines/xeen/sound.cpp b/engines/xeen/sound.cpp index 9800af5403..ae70c1f5d8 100644 --- a/engines/xeen/sound.cpp +++ b/engines/xeen/sound.cpp @@ -29,7 +29,8 @@ namespace Xeen { Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer), _fxOn(true), _musicOn(true), _subtitles(false), - _songData(nullptr), _effectsData(nullptr), _musicSide(0), _musicPercent(100) { + _songData(nullptr), _effectsData(nullptr), _musicSide(0), _musicPercent(100), + _musicVolume(0), _sfxVolume(0) { _SoundDriver = new AdlibSoundDriver(); } @@ -106,18 +107,6 @@ void Sound::setFxOn(bool isOn) { g_vm->syncSoundSettings(); } -void Sound::updateSoundSettings() { - _fxOn = !ConfMan.getBool("sfx_mute"); - if (!_fxOn) - stopFX(); - - _musicOn = !ConfMan.getBool("music_mute"); - if (!_musicOn) - stopSong(); - - _subtitles = ConfMan.hasKey("subtitles") ? ConfMan.getBool("subtitles") : true; -} - void Sound::loadEffectsData() { // Stop any prior FX stopFX(); @@ -160,8 +149,8 @@ void Sound::stopFX() { _SoundDriver->stopFX(); } -int Sound::songCommand(uint commandId, byte volume) { - int result = _SoundDriver->songCommand(commandId, volume); +int Sound::songCommand(uint commandId, byte musicVolume, byte sfxVolume) { + int result = _SoundDriver->songCommand(commandId, musicVolume, sfxVolume); if (commandId == STOP_SONG) { delete[] _songData; _songData = nullptr; @@ -212,8 +201,26 @@ void Sound::setMusicPercent(byte percent) { assert(percent <= 100); _musicPercent = percent; - songCommand(SET_VOLUME, (int)percent * 127 / 100); + updateVolume(); } +void Sound::updateSoundSettings() { + _fxOn = !ConfMan.getBool("sfx_mute"); + if (!_fxOn) + stopFX(); + + _musicOn = !ConfMan.getBool("music_mute"); + if (!_musicOn) + stopSong(); + + _subtitles = ConfMan.hasKey("subtitles") ? ConfMan.getBool("subtitles") : true; + _musicVolume = CLIP(ConfMan.getInt("music_volume"), 0, 255); + _sfxVolume = CLIP(ConfMan.getInt("sfx_volume"), 0, 255); + updateVolume(); +} + +void Sound::updateVolume() { + songCommand(SET_VOLUME, _musicPercent * _musicVolume / 100, _sfxVolume); +} } // End of namespace Xeen |