From 1a3daf39a083ec7fbc53409f2c0a5f1f7f571f4e Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Tue, 4 Jun 2019 14:15:13 +0100 Subject: [PATCH] ATC volume and settings passed to the group MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note sure this is strictly the correct place to do this, but it’s where we do it for avionics, so following for now. --- src/Sound/fg_fx.cxx | 28 +++++++++++++++++++++++----- src/Sound/fg_fx.hxx | 13 +++++++++---- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/Sound/fg_fx.cxx b/src/Sound/fg_fx.cxx index 66c06d5d8..62e85e5d3 100644 --- a/src/Sound/fg_fx.cxx +++ b/src/Sound/fg_fx.cxx @@ -61,6 +61,10 @@ FGFX::FGFX ( const std::string &refname, SGPropertyNode *props ) : _avionics_ext = _props->getNode("sim/sound/avionics/external-view", true); _internal = _props->getNode("sim/current-view/internal", true); + _atc_enabled = _props->getNode("sim/sound/atc/enabled", true); + _atc_volume = _props->getNode("sim/sound/atc/volume", true); + _atc_ext = _props->getNode("sim/sound/atc/external-view", true); + _smgr = globals->get_subsystem<FGSoundManager>(); if (!_smgr) { return; @@ -70,13 +74,14 @@ FGFX::FGFX ( const std::string &refname, SGPropertyNode *props ) : _refname = refname; _smgr->add(this, refname); - if (!_is_aimodel) + if (!_is_aimodel) // only for the main aircraft { _avionics = _smgr->find("avionics", true); _avionics->tie_to_listener(); + + _atc = _smgr->find("atc", true); + _atc->tie_to_listener(); } - else - _avionics = NULL; } void FGFX::unbind() @@ -176,9 +181,10 @@ FGFX::update (double dt) if ( _enabled->getBoolValue() ) { - if ( _avionics && _avionics_enabled->getBoolValue()) + if ( _avionics) { - if (_avionics_ext->getBoolValue() || _internal->getBoolValue()) { + const bool e = _avionics_enabled->getBoolValue(); + if (e && (_avionics_ext->getBoolValue() || _internal->getBoolValue())) { // avionics sound is enabled _avionics->resume(); // no-op if already in resumed state _avionics->set_volume( _avionics_volume->getFloatValue() ); @@ -186,6 +192,18 @@ FGFX::update (double dt) else _avionics->suspend(); } + + if ( _atc) + { + const bool e = _atc_enabled->getBoolValue(); + if (e && (_atc_ext->getBoolValue() || _internal->getBoolValue())) { + // ATC sound is enabled + _atc->resume(); // no-op if already in resumed state + _atc->set_volume( _atc_volume->getFloatValue() ); + } + else + _atc->suspend(); + } set_volume( _volume->getDoubleValue() ); resume(); diff --git a/src/Sound/fg_fx.hxx b/src/Sound/fg_fx.hxx index 36c738215..c4516e140 100644 --- a/src/Sound/fg_fx.hxx +++ b/src/Sound/fg_fx.hxx @@ -52,16 +52,18 @@ public: FGFX ( const std::string &refname, SGPropertyNode *props = 0 ); virtual ~FGFX (); - virtual void init (); - virtual void reinit (); - virtual void update (double dt); - void unbind(); + void init (); + void reinit (); + void update (double dt) override; + void unbind(); private: bool _active; bool _is_aimodel; SGSharedPtr<SGSampleGroup> _avionics; + SGSharedPtr<SGSampleGroup> _atc; + std::vector<SGXmlSound *> _sound; SGPropertyNode_ptr _props; @@ -71,6 +73,9 @@ private: SGPropertyNode_ptr _avionics_volume; SGPropertyNode_ptr _avionics_ext; SGPropertyNode_ptr _internal; + SGPropertyNode_ptr _atc_enabled; + SGPropertyNode_ptr _atc_volume; + SGPropertyNode_ptr _atc_ext; };