From 06bd0708b9f1e12719f8e6064ab8a2f8fdee243a Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Wed, 6 Jan 2021 14:06:27 +0000 Subject: [PATCH] Festival: Fix volume/pitch/speed after preamble Fix from Antonello: when we send a premable to Festival, we need to set the parameters afterwards. Re-order the code so this occurs automatically. --- src/Sound/voice.cxx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Sound/voice.cxx b/src/Sound/voice.cxx index 5d2e2fc58..6489d24bf 100644 --- a/src/Sound/voice.cxx +++ b/src/Sound/voice.cxx @@ -171,16 +171,19 @@ FGFestivalVoice::FGFestivalVoice(FGVoiceMgr *mgr, const SGPropertyNode_ptr node) SG_LOG(SG_SOUND, SG_INFO, "VOICE: connection to Festival server on `" << host << ':' << port << "' established"); - - setVolume(_volume = _volumeNode->getDoubleValue()); - setPitch(_pitch = _pitchNode->getDoubleValue()); - setSpeed(_speed = _speedNode->getDoubleValue()); } - string preamble = node->getStringValue("preamble", ""); - if (!preamble.empty()) - pushMessage(preamble); - node->getNode("text", true)->addChangeListener(this); + const string preamble = node->getStringValue("preamble", ""); + if (!preamble.empty()) { + pushMessage(preamble); + } + + // set these after sending any preamble, since it may reset them + setVolume(_volume = _volumeNode->getDoubleValue()); + setPitch(_pitch = _pitchNode->getDoubleValue()); + setSpeed(_speed = _speedNode->getDoubleValue()); + + node->getNode("text", true)->addChangeListener(this); }