diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 151efa207..f998b5d6c 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -1260,7 +1260,7 @@ do_play_audio_sample (const SGPropertyNode * arg) static FGSampleQueue *queue = 0; if ( !queue ) { SGSoundMgr *smgr = globals->get_soundmgr(); - queue = new FGSampleQueue(smgr, "queue"); + queue = new FGSampleQueue(smgr, "chatter"); queue->tie_to_listener(); } diff --git a/src/Sound/fg_fx.cxx b/src/Sound/fg_fx.cxx index 831375454..739b746f0 100644 --- a/src/Sound/fg_fx.cxx +++ b/src/Sound/fg_fx.cxx @@ -39,18 +39,16 @@ #include FGFX::FGFX ( SGSoundMgr *smgr, const string &refname ) : - last_enabled( true ), - last_volume( 0.0 ), _enabled( fgGetNode("/sim/sound/effects/enabled", true) ), - _volume( fgGetNode("/sim/sound/effects/volume", true) ) + _volume( fgGetNode("/sim/sound/effects/volume", true) ), + _avionics_enabled( fgGetNode("/sim/sound/avionics/enabled", true) ), + _avionics_volume( fgGetNode("/sim/sound/avionics/volume", true) ) { SGSampleGroup::_smgr = smgr; SGSampleGroup::_refname = refname; SGSampleGroup::_smgr->add(this, refname); _avionics = _smgr->find("avionics", true); _avionics->tie_to_listener(); - _enabled->setBoolValue(true); - _volume->setFloatValue(1.0); } @@ -118,22 +116,16 @@ FGFX::reinit() void FGFX::update (double dt) { - bool new_enabled = _enabled->getBoolValue(); - if ( new_enabled != last_enabled ) { - if ( new_enabled ) { - resume(); - } else { - suspend(); - } - last_enabled = new_enabled; - } + if ( _avionics_enabled->getBoolValue() ) + _avionics->resume(); // no-op if already in resumed state + else + _avionics->suspend(); + _avionics->set_volume( _avionics_volume->getDoubleValue() ); - if ( new_enabled ) { - double volume = _volume->getDoubleValue(); - if ( volume != last_volume ) { - set_volume( volume ); - last_volume = volume; - } + + if ( _enabled->getBoolValue() ) { + set_volume( _volume->getDoubleValue() ); + resume(); // update sound effects if not paused for ( unsigned int i = 0; i < _sound.size(); i++ ) { @@ -142,6 +134,8 @@ FGFX::update (double dt) SGSampleGroup::update(dt); } + else + suspend(); } // end of fg_fx.cxx diff --git a/src/Sound/fg_fx.hxx b/src/Sound/fg_fx.hxx index f28d3677b..caa32646a 100644 --- a/src/Sound/fg_fx.hxx +++ b/src/Sound/fg_fx.hxx @@ -60,11 +60,10 @@ private: SGSharedPtr _avionics; std::vector _sound; - bool last_enabled; - double last_volume; - SGPropertyNode_ptr _enabled; SGPropertyNode_ptr _volume; + SGPropertyNode_ptr _avionics_enabled; + SGPropertyNode_ptr _avionics_volume; };