aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/sound.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sherlock/sound.cpp')
-rw-r--r--engines/sherlock/sound.cpp104
1 files changed, 59 insertions, 45 deletions
diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp
index 66b5b5bf5c..e5b1099123 100644
--- a/engines/sherlock/sound.cpp
+++ b/engines/sherlock/sound.cpp
@@ -58,10 +58,9 @@ Sound::Sound(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
_soundPlaying = false;
_speechPlaying = false;
_curPriority = 0;
- _soundVolume = 255;
-
- _soundOn = true;
- _speechOn = true;
+ _soundVolume = ConfMan.hasKey("sfx_volume") ? ConfMan.getInt("sfx_volume") : 255;
+ _soundOn = ConfMan.hasKey("mute") ? !ConfMan.getBool("mute") : true;
+ _speechOn = ConfMan.hasKey("speech_mute") ? !ConfMan.getBool("speech_mute") : true;
if (IS_3DO) {
// 3DO: we don't need to prepare anything for sound
@@ -90,7 +89,7 @@ Sound::Sound(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
void Sound::syncSoundSettings() {
_digitized = !ConfMan.getBool("mute");
_speechOn = !ConfMan.getBool("mute") && !ConfMan.getBool("speech_mute");
- _voices = _speechOn ? 1 : 0;
+ _voices = _digitized ? 1 : 0;
}
void Sound::loadSound(const Common::String &name, int priority) {
@@ -121,27 +120,13 @@ byte Sound::decodeSample(byte sample, byte &reference, int16 &scale) {
}
bool Sound::playSound(const Common::String &name, WaitType waitType, int priority, const char *libraryFilename) {
- stopSound();
+ // Scalpel has only a single sound handle, so it must be stopped before starting a new sound
+ if (IS_SERRATED_SCALPEL)
+ stopSound();
- Common::String filename = name;
- if (!filename.contains('.')) {
- if (!IS_3DO) {
- if (IS_SERRATED_SCALPEL) {
- filename += ".SND";
- } else {
- filename += ".WAV";
- }
- } else {
- // 3DO uses .aiff extension
- filename += ".AIFF";
- if (!filename.contains('/')) {
- // if no directory was given, use the room sounds directory
- filename = "rooms/sounds/" + filename;
- }
- }
- }
+ Common::String filename = formFilename(name);
- Audio::SoundHandle soundHandle = (IS_SERRATED_SCALPEL) ? _scalpelEffectsHandle : getFreeSoundHandle();
+ Audio::SoundHandle &soundHandle = (IS_SERRATED_SCALPEL) ? _scalpelEffectsHandle : getFreeSoundHandle();
if (!playSoundResource(filename, libraryFilename, Audio::Mixer::kSFXSoundType, soundHandle))
error("Could not find sound resource - %s", filename.c_str());
@@ -168,6 +153,29 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit
return retval;
}
+Common::String Sound::formFilename(const Common::String &name) {
+ Common::String filename = name;
+
+ if (!filename.contains('.')) {
+ if (!IS_3DO) {
+ if (IS_SERRATED_SCALPEL) {
+ filename += ".SND";
+ } else {
+ filename += ".WAV";
+ }
+ } else {
+ // 3DO uses .aiff extension
+ filename += ".AIFF";
+ if (!filename.contains('/')) {
+ // if no directory was given, use the room sounds directory
+ filename = "rooms/sounds/" + filename;
+ }
+ }
+ }
+
+ return filename;
+}
+
void Sound::playAiff(const Common::String &name, int volume, bool loop) {
Common::File *file = new Common::File();
if (!file->open(name)) {
@@ -222,7 +230,7 @@ void Sound::freeDigiSound() {
_soundPlaying = false;
}
-Audio::SoundHandle Sound::getFreeSoundHandle() {
+Audio::SoundHandle &Sound::getFreeSoundHandle() {
for (int i = 0; i < MAX_MIXER_CHANNELS; i++) {
if (!_mixer->isSoundHandleActive(_tattooEffectsHandle[i]))
return _tattooEffectsHandle[i];
@@ -232,35 +240,41 @@ Audio::SoundHandle Sound::getFreeSoundHandle() {
}
void Sound::setVolume(int volume) {
- warning("TODO: setVolume - %d", volume);
+ _soundVolume = volume;
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volume);
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume);
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, volume);
}
void Sound::playSpeech(const Common::String &name) {
Resources &res = *_vm->_res;
Scene &scene = *_vm->_scene;
- stopSpeech();
-
- // TODO: Technically Scalpel has an sfx command which I've set to call this method because it sets the
- // _voice variable as if it were speech. Need to do a play-through of Scalpel and see if it's ever called.
- // If so, will need to enhance this method to handle the Serrated Scalpel voice resources
- assert(IS_ROSE_TATTOO);
- // Figure out which speech library to use
- Common::String libraryName = Common::String::format("speech%02d.lib", scene._currentScene);
- if ((!scumm_strnicmp(name.c_str(), "SLVE12S", 7)) || (!scumm_strnicmp(name.c_str(), "WATS12X", 7))
- || (!scumm_strnicmp(name.c_str(), "HOLM12X", 7)))
- libraryName = "SPEECH12.LIB";
+ // Stop any previously playing speech
+ stopSpeech();
- // If the speech library file doesn't even exist, then we can't play anything
- Common::File f;
- if (!f.exists(libraryName))
- return;
+ if (IS_SERRATED_SCALPEL) {
+ Common::String filename = formFilename(name);
+ if (playSoundResource(filename, Common::String(), Audio::Mixer::kSFXSoundType, _speechHandle))
+ _speechPlaying = true;
+ } else {
+ // Figure out which speech library to use
+ Common::String libraryName = Common::String::format("speech%02d.lib", scene._currentScene);
+ if ((!scumm_strnicmp(name.c_str(), "SLVE12S", 7)) || (!scumm_strnicmp(name.c_str(), "WATS12X", 7))
+ || (!scumm_strnicmp(name.c_str(), "HOLM12X", 7)))
+ libraryName = "SPEECH12.LIB";
+
+ // If the speech library file doesn't even exist, then we can't play anything
+ Common::File f;
+ if (!f.exists(libraryName))
+ return;
- // Ensure the given library is in the cache
- res.addToCache(libraryName);
+ // Ensure the given library is in the cache
+ res.addToCache(libraryName);
- if (playSoundResource(name, libraryName, Audio::Mixer::kSpeechSoundType, _speechHandle))
- _speechPlaying = true;
+ if (playSoundResource(name, libraryName, Audio::Mixer::kSpeechSoundType, _speechHandle))
+ _speechPlaying = true;
+ }
}
void Sound::stopSpeech() {