diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/saga/interface.cpp | 6 | ||||
-rw-r--r-- | engines/saga/saga.cpp | 13 | ||||
-rw-r--r-- | engines/saga/saga.h | 1 | ||||
-rw-r--r-- | engines/saga/sound.cpp | 47 | ||||
-rw-r--r-- | engines/saga/sound.h | 7 |
5 files changed, 50 insertions, 24 deletions
diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 92ef960f48..9d3831062c 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -1631,8 +1631,8 @@ void Interface::setOption(PanelButton *panelButton) { break; case kTextSound: _vm->_soundVolume = (_vm->_soundVolume + 1) % 11; - _vm->_sound->setVolume(_vm->_soundVolume == 10 ? 255 : _vm->_soundVolume * 25); ConfMan.setInt("sfx_volume", _vm->_soundVolume * 25); + _vm->_sound->setVolume(); break; case kTextVoices: if (_vm->_voiceFilesExist) { @@ -1650,6 +1650,10 @@ void Interface::setOption(PanelButton *panelButton) { _vm->_subtitlesEnabled = true; // Set it to "Text" _vm->_voicesEnabled = false; } + + _vm->_speechVolume = (_vm->_speechVolume + 1) % 11; + ConfMan.setInt("speech_volume", _vm->_speechVolume * 25); + _vm->_sound->setVolume(); ConfMan.setBool("subtitles", _vm->_subtitlesEnabled); ConfMan.setBool("voices", _vm->_voicesEnabled); diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index c359bbb631..47228ae68a 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -141,8 +141,7 @@ SagaEngine::~SagaEngine() { } int SagaEngine::init() { - _soundVolume = ConfMan.getInt("sfx_volume") / 25; - _musicVolume = ConfMan.getInt("music_volume") / 25; + _musicVolume = ConfMan.getInt("music_volume"); _subtitlesEnabled = ConfMan.getBool("subtitles"); _readingSpeed = getTalkspeed(); _copyProtection = ConfMan.getBool("copy_protection"); @@ -202,7 +201,7 @@ int SagaEngine::init() { } // Initialize system specific sound - _sound = new Sound(this, _mixer, _soundVolume); + _sound = new Sound(this, _mixer); _interface->converseInit(); _script->setVerb(_script->getVerbType(kVerbWalkTo)); @@ -224,6 +223,8 @@ int SagaEngine::init() { } } + syncSoundSettings(); + // FIXME: This is the ugly way of reducing redraw overhead. It works // well for 320x200 but it's unclear how well it will work for // 640x480. @@ -512,17 +513,15 @@ int SagaEngine::getTalkspeed() { } void SagaEngine::syncSoundSettings() { - _soundVolume = ConfMan.getInt("sfx_volume"); - _musicVolume = ConfMan.getInt("music_volume"); _subtitlesEnabled = ConfMan.getBool("subtitles"); _readingSpeed = getTalkspeed(); if (_readingSpeed > 3) _readingSpeed = 0; + _musicVolume = ConfMan.getInt("music_volume"); _music->setVolume(_musicVolume, 1); - _sound->setVolume(_soundVolume); - + _sound->setVolume(); } } // End of namespace Saga diff --git a/engines/saga/saga.h b/engines/saga/saga.h index cdbaaaa042..123c11eb7d 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -521,6 +521,7 @@ public: int _soundVolume; int _musicVolume; + int _speechVolume; bool _subtitlesEnabled; bool _voicesEnabled; bool _voiceFilesExist; diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp index 1d3263d302..1d41d39cf2 100644 --- a/engines/saga/sound.cpp +++ b/engines/saga/sound.cpp @@ -22,8 +22,10 @@ * $Id$ * */ -#include "saga/saga.h" +#include "common/config-manager.h" + +#include "saga/saga.h" #include "saga/sound.h" #include "sound/audiostream.h" @@ -32,13 +34,13 @@ namespace Saga { -Sound::Sound(SagaEngine *vm, Audio::Mixer *mixer, int volume) : +Sound::Sound(SagaEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer), _voxStream(0) { for (int i = 0; i < SOUND_HANDLES; i++) _handles[i].type = kFreeHandle; - setVolume(volume == 10 ? 255 : volume * 25); + setVolume(); } Sound::~Sound() { @@ -61,7 +63,8 @@ SndHandle *Sound::getHandle() { return NULL; } -void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop) { +void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, + sndHandleType handleType, bool loop) { byte flags; flags = Audio::Mixer::FLAG_AUTOFREE; @@ -81,7 +84,12 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int flags |= Audio::Mixer::FLAG_UNSIGNED; if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) { - _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume); + if (handleType == kVoiceHandle) + _mixer->playRaw(Audio::Mixer::kSpeechSoundType, handle, buffer.buffer, + buffer.size, buffer.frequency, flags, -1, volume); + else + _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, + buffer.size, buffer.frequency, flags, -1, volume); } else { Audio::AudioStream *stream = NULL; MemoryReadStream *tmp = NULL; @@ -116,12 +124,23 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int #endif default: // No compression, play it as raw sound - _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume); + if (handleType == kVoiceHandle) + _mixer->playRaw(Audio::Mixer::kSpeechSoundType, handle, buffer.buffer, + buffer.size, buffer.frequency, flags, -1, volume); + else + _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, + buffer.size, buffer.frequency, flags, -1, volume); break; } - if (stream != NULL) - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, stream, -1, volume, 0, true, false); + if (stream != NULL) { + if (handleType == kVoiceHandle) + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, handle, stream, -1, + volume, 0, true, false); + else + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, stream, -1, + volume, 0, true, false); + } } } @@ -129,7 +148,7 @@ void Sound::playSound(SoundBuffer &buffer, int volume, bool loop) { SndHandle *handle = getHandle(); handle->type = kEffectHandle; - playSoundBuffer(&handle->handle, buffer, 2 * volume, loop); + playSoundBuffer(&handle->handle, buffer, 2 * volume, handle->type, loop); } void Sound::pauseSound() { @@ -156,7 +175,7 @@ void Sound::playVoice(SoundBuffer &buffer) { SndHandle *handle = getHandle(); handle->type = kVoiceHandle; - playSoundBuffer(&handle->handle, buffer, 255, false); + playSoundBuffer(&handle->handle, buffer, 255, handle->type, false); } void Sound::pauseVoice() { @@ -184,9 +203,11 @@ void Sound::stopAll() { stopSound(); } -void Sound::setVolume(int volume) { - _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volume); - _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume); +void Sound::setVolume() { + _vm->_soundVolume = ConfMan.getInt("sound_volume"); + _vm->_speechVolume = ConfMan.getInt("speech_volume"); + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_soundVolume); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, _vm->_speechVolume); } } // End of namespace Saga diff --git a/engines/saga/sound.h b/engines/saga/sound.h index ce479c64d1..6d9e42a49d 100644 --- a/engines/saga/sound.h +++ b/engines/saga/sound.h @@ -71,7 +71,7 @@ struct SndHandle { class Sound { public: - Sound(SagaEngine *vm, Audio::Mixer *mixer, int volume); + Sound(SagaEngine *vm, Audio::Mixer *mixer); ~Sound(); void playSound(SoundBuffer &buffer, int volume, bool loop); @@ -86,11 +86,12 @@ public: void stopAll(); - void setVolume(int volume); + void setVolume(); private: - void playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop); + void playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, + sndHandleType handleType, bool loop); SndHandle *getHandle(); |