SHERLOCK: SS: Fix playback of voices in cutscenes

This commit is contained in:
Paul Gilbert 2015-10-10 16:38:28 -04:00
parent 1e0b18684c
commit 177409390f
4 changed files with 26 additions and 12 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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);
/**

View file

@ -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;