From 177409390f8e116bdc68e4c4741a92aebff5f53c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 10 Oct 2015 16:38:28 -0400 Subject: SHERLOCK: SS: Fix playback of voices in cutscenes --- engines/sherlock/scalpel/scalpel_talk.cpp | 2 +- engines/sherlock/sound.cpp | 24 ++++++++++++++++-------- engines/sherlock/sound.h | 8 +++++++- engines/sherlock/talk.cpp | 4 ++-- 4 files changed, 26 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/sherlock/scalpel/scalpel_talk.cpp b/engines/sherlock/scalpel/scalpel_talk.cpp index 375b27bfad..2fb2221b24 100644 --- a/engines/sherlock/scalpel/scalpel_talk.cpp +++ b/engines/sherlock/scalpel/scalpel_talk.cpp @@ -498,7 +498,7 @@ OpcodeReturn ScalpelTalk::cmdSfxCommand(const byte *&str) { if (sound._voices) { for (int idx = 0; idx < 8 && str[idx] != '~'; ++idx) tempString += str[idx]; - sound.playSpeech(tempString); + sound.playSound(tempString, WAIT_RETURN_IMMEDIATELY); // Set voices to wait for more sound._voices = 2; diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp index a653db51a3..1d809cfe36 100644 --- a/engines/sherlock/sound.cpp +++ b/engines/sherlock/sound.cpp @@ -141,7 +141,7 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit } } - 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()); @@ -222,7 +222,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]; @@ -238,13 +238,11 @@ void Sound::setVolume(int 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); + // 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)) @@ -264,12 +262,22 @@ void Sound::playSpeech(const Common::String &name) { } void Sound::stopSpeech() { - _mixer->stopHandle(_speechHandle); + if (IS_SERRATED_SCALPEL) { + _mixer->stopHandle(_scalpelEffectsHandle); + } else { + _mixer->stopHandle(_speechHandle); + } _speechPlaying = false; } bool Sound::isSpeechPlaying() { _speechPlaying = _mixer->isSoundHandleActive(_speechHandle); + + if (IS_SERRATED_SCALPEL) { + _soundPlaying = _mixer->isSoundHandleActive(_scalpelEffectsHandle); + return _soundPlaying; + } + return _speechPlaying; } diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h index 44969b8923..d086bcdee3 100644 --- a/engines/sherlock/sound.h +++ b/engines/sherlock/sound.h @@ -116,8 +116,14 @@ public: void freeDigiSound(); - Audio::SoundHandle getFreeSoundHandle(); + /** + * Return a sound handle to use + */ + Audio::SoundHandle &getFreeSoundHandle(); + /** + * Set the volume + */ void setVolume(int volume); /** diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp index b61d3f1936..795c4eb9c7 100644 --- a/engines/sherlock/talk.cpp +++ b/engines/sherlock/talk.cpp @@ -846,7 +846,7 @@ int Talk::waitForMore(int delay) { playingSpeech = sound.isSpeechPlaying(); do { - if (IS_SERRATED_SCALPEL && sound._speechOn && !sound.isSpeechPlaying()) + if (IS_SERRATED_SCALPEL && playingSpeech && !sound.isSpeechPlaying()) people._portrait._frameNumber = -1; scene.doBgAnim(); @@ -890,7 +890,7 @@ int Talk::waitForMore(int delay) { } while (!_vm->shouldQuit() && key2 == 254 && (delay || (playingSpeech && sound.isSpeechPlaying())) && !events._released && !events._rightReleased); - // If voices was set 2 to indicate a voice file was place, then reset it back to 1 + // If voices was set 2 to indicate a Scalpel voice file was playing, then reset it back to 1 if (sound._voices == 2) sound._voices = 1; -- cgit v1.2.3