diff options
author | Paul Gilbert | 2015-10-10 17:03:11 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-10-10 17:03:11 -0400 |
commit | 980810703e66a82d9868ac2fd4968261299e7468 (patch) | |
tree | 64da6f1dcc222fd0410dd4cfc926aea77fbc4aca /engines/sherlock/sound.cpp | |
parent | 177409390f8e116bdc68e4c4741a92aebff5f53c (diff) | |
download | scummvm-rg350-980810703e66a82d9868ac2fd4968261299e7468.tar.gz scummvm-rg350-980810703e66a82d9868ac2fd4968261299e7468.tar.bz2 scummvm-rg350-980810703e66a82d9868ac2fd4968261299e7468.zip |
SHERLOCK: SS: Clean up speech playback to use playSpeech
Diffstat (limited to 'engines/sherlock/sound.cpp')
-rw-r--r-- | engines/sherlock/sound.cpp | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp index 1d809cfe36..36ca67b323 100644 --- a/engines/sherlock/sound.cpp +++ b/engines/sherlock/sound.cpp @@ -123,23 +123,7 @@ byte Sound::decodeSample(byte sample, byte &reference, int16 &scale) { bool Sound::playSound(const Common::String &name, WaitType waitType, int priority, const char *libraryFilename) { 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(); if (!playSoundResource(filename, libraryFilename, Audio::Mixer::kSFXSoundType, soundHandle)) @@ -168,6 +152,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)) { @@ -238,46 +245,41 @@ void Sound::setVolume(int volume) { void Sound::playSpeech(const Common::String &name) { Resources &res = *_vm->_res; Scene &scene = *_vm->_scene; - assert(IS_ROSE_TATTOO); // Stop any previously playing speech stopSpeech(); - // 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; + if (IS_SERRATED_SCALPEL) { + Common::String filename = formFilename(name); + if (playSoundResource(filename, nullptr, 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() { - if (IS_SERRATED_SCALPEL) { - _mixer->stopHandle(_scalpelEffectsHandle); - } else { - _mixer->stopHandle(_speechHandle); - } + _mixer->stopHandle(_speechHandle); _speechPlaying = false; } bool Sound::isSpeechPlaying() { _speechPlaying = _mixer->isSoundHandleActive(_speechHandle); - - if (IS_SERRATED_SCALPEL) { - _soundPlaying = _mixer->isSoundHandleActive(_scalpelEffectsHandle); - return _soundPlaying; - } - return _speechPlaying; } |