diff options
author | Jaromir Wysoglad | 2019-07-25 01:23:36 +0200 |
---|---|---|
committer | Filippos Karapetis | 2019-09-01 22:47:55 +0300 |
commit | a1f69e6b06160d75ff85a0c292c88709abc4f7e9 (patch) | |
tree | dc22ab48bb686a0256e7f17346b5d1b6f3756a1b /engines | |
parent | 99550a95b20d74afd845f95713ce132c2dcbfa93 (diff) | |
download | scummvm-rg350-a1f69e6b06160d75ff85a0c292c88709abc4f7e9.tar.gz scummvm-rg350-a1f69e6b06160d75ff85a0c292c88709abc4f7e9.tar.bz2 scummvm-rg350-a1f69e6b06160d75ff85a0c292c88709abc4f7e9.zip |
MORTEVIELLE: Refactoring as suggested by Criezy
* Add checks if ttsMan != null before trying to use it
* Simplify startSpeech
* Move haut to startSpeech and pass the character index to
the startSpeech instead.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mortevielle/dialogs.cpp | 3 | ||||
-rw-r--r-- | engines/mortevielle/sound.cpp | 46 | ||||
-rw-r--r-- | engines/mortevielle/sound.h | 2 | ||||
-rw-r--r-- | engines/mortevielle/utils.cpp | 3 |
4 files changed, 23 insertions, 31 deletions
diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp index 7069765dcd..54c09cc1d7 100644 --- a/engines/mortevielle/dialogs.cpp +++ b/engines/mortevielle/dialogs.cpp @@ -423,7 +423,8 @@ void DialogManager::checkForF8(int SpeechNum, bool drawFrame2Fl) { } while (_vm->_key != 66); // keycode for F8 // just stop the speech when pressing F8 #ifdef USE_TTS - _vm->_soundManager->_ttsMan->stop(); + if (_vm->_soundManager->_ttsMan != nullptr) + _vm->_soundManager->_ttsMan->stop(); #endif } diff --git a/engines/mortevielle/sound.cpp b/engines/mortevielle/sound.cpp index 66f421e31f..01a9dbbaac 100644 --- a/engines/mortevielle/sound.cpp +++ b/engines/mortevielle/sound.cpp @@ -69,11 +69,13 @@ SoundManager::SoundManager(MortevielleEngine *vm, Audio::Mixer *mixer) { _noiseBuf = nullptr; #ifdef USE_TTS _ttsMan = g_system->getTextToSpeechManager(); - _ttsMan->setLanguage(ConfMan.get("language")); - _ttsMan->stop(); - _ttsMan->setRate(0); - _ttsMan->setPitch(0); - _ttsMan->setVolume(100); + if (_ttsMan) { + _ttsMan->setLanguage(ConfMan.get("language")); + _ttsMan->stop(); + _ttsMan->setRate(0); + _ttsMan->setPitch(0); + _ttsMan->setVolume(100); + } #endif //USE_TTS _soundType = 0; @@ -760,30 +762,26 @@ void SoundManager::handlePhoneme() { * Start speech * @remarks Originally called 'parole' */ -void SoundManager::startSpeech(int rep, int ht, int typ) { +void SoundManager::startSpeech(int rep, int character, int typ) { if (_vm->_soundOff) return; + _soundType = typ; + if (typ == 0) { // Speech #ifdef USE_TTS + const int haut[9] = { 0, 0, 1, -3, 6, -2, 2, 7, -1 }; if (!_ttsMan) return; Common::Array<int> voices; - int pitch; - int voiceIndex; + int pitch = haut[character] * 5; bool male; - if (ht > 5) { + if (haut[character] > 5) { voices = _ttsMan->getVoiceIndicesByGender(Common::TTSVoice::FEMALE); - pitch = ht - 6; - voiceIndex = pitch; - pitch *= 5; male = false; } else { voices = _ttsMan->getVoiceIndicesByGender(Common::TTSVoice::MALE); - pitch = ht - 5; - voiceIndex = -pitch; - pitch *= 4; male = true; } // If there is no voice available for the given gender, just set it to the 0th @@ -791,8 +789,8 @@ void SoundManager::startSpeech(int rep, int ht, int typ) { if (voices.empty()) _ttsMan->setVoice(0); else { - voiceIndex %= voices.size(); - _ttsMan->setVoice(voices[voiceIndex]); + character %= voices.size(); + _ttsMan->setVoice(voices[character]); } // If the selected voice is a different gender, than we want, just try to // set the pitch so it may sound a little bit closer to the gender we want @@ -805,22 +803,16 @@ void SoundManager::startSpeech(int rep, int ht, int typ) { _ttsMan->setPitch(pitch); _ttsMan->say(_vm->getString(rep + kDialogStringIndex), "CP850"); -#else - return; #endif // USE_TTS + return; } uint16 savph[501]; int tempo; _phonemeNumb = rep; - _soundType = typ; - if (_soundType != 0) { - for (int i = 0; i <= 500; ++i) - savph[i] = _cfiphBuffer[i]; - tempo = kTempoNoise; - } else { - return; - } + for (int i = 0; i <= 500; ++i) + savph[i] = _cfiphBuffer[i]; + tempo = kTempoNoise; _vm->_addFix = (float)((tempo - 8)) / 256; cctable(_tbi); switch (typ) { diff --git a/engines/mortevielle/sound.h b/engines/mortevielle/sound.h index 0508d1d4c3..38081c9c6c 100644 --- a/engines/mortevielle/sound.h +++ b/engines/mortevielle/sound.h @@ -104,7 +104,7 @@ public: void playSong(const byte *buf, uint usize, uint loops); void loadAmbiantSounds(); void loadNoise(); - void startSpeech(int rep, int ht, int typ); + void startSpeech(int rep, int character, int typ); void waitSpeech(); }; diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp index 4ad8a8e4b3..dd19c2650c 100644 --- a/engines/mortevielle/utils.cpp +++ b/engines/mortevielle/utils.cpp @@ -1330,7 +1330,6 @@ void MortevielleEngine::displayDiningRoom() { * @remarks Originally called 'sparl' */ void MortevielleEngine::startDialog(int16 rep) { - const int haut[9] = { 0, 0, 1, -3, 6, -2, 2, 7, -1 }; int key; assert(rep >= 0); @@ -1342,7 +1341,7 @@ void MortevielleEngine::startDialog(int16 rep) { key = 0; do { - _soundManager->startSpeech(rep, haut[_caff - 69], 0); + _soundManager->startSpeech(rep, _caff - 69, 0); key = _dialogManager->waitForF3F8(); if (shouldQuit()) return; |