aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock
diff options
context:
space:
mode:
authorPaul Gilbert2015-10-10 17:03:11 -0400
committerPaul Gilbert2015-10-10 17:03:11 -0400
commit980810703e66a82d9868ac2fd4968261299e7468 (patch)
tree64da6f1dcc222fd0410dd4cfc926aea77fbc4aca /engines/sherlock
parent177409390f8e116bdc68e4c4741a92aebff5f53c (diff)
downloadscummvm-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')
-rw-r--r--engines/sherlock/scalpel/scalpel_talk.cpp2
-rw-r--r--engines/sherlock/sound.cpp88
-rw-r--r--engines/sherlock/sound.h5
3 files changed, 51 insertions, 44 deletions
diff --git a/engines/sherlock/scalpel/scalpel_talk.cpp b/engines/sherlock/scalpel/scalpel_talk.cpp
index 2fb2221b24..375b27bfad 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.playSound(tempString, WAIT_RETURN_IMMEDIATELY);
+ sound.playSpeech(tempString);
// Set voices to wait for more
sound._voices = 2;
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;
}
diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h
index d086bcdee3..0a0ff83d1f 100644
--- a/engines/sherlock/sound.h
+++ b/engines/sherlock/sound.h
@@ -61,6 +61,11 @@ private:
*/
bool playSoundResource(const Common::String &name, const Common::String &libFilename,
Audio::Mixer::SoundType soundType, Audio::SoundHandle &handle);
+
+ /**
+ * Form a filename from a passed sound resource name
+ */
+ Common::String formFilename(const Common::String &name);
public:
bool _digitized;
int _voices;