46FGFX::FGFX (
const std::string &refname, SGPropertyNode *props ) :
52 _enabled =
fgGetNode(
"/sim/sound/effects/enabled",
true);
53 _volume =
fgGetNode(
"/sim/sound/effects/volume",
true);
56 _enabled = _props->getNode(
"/sim/sound/aimodels/enabled",
true);
57 _enabled->setBoolValue(
fgGetBool(
"/sim/sound/effects/enabled"));
58 _volume = _props->getNode(
"/sim/sound/aimodels/volume",
true);
59 _volume->setFloatValue(
fgGetFloat(
"/sim/sound/effects/volume"));
62 _avionics_enabled = _props->getNode(
"sim/sound/avionics/enabled",
true);
63 _avionics_volume = _props->getNode(
"sim/sound/avionics/volume",
true);
64 _avionics_ext = _props->getNode(
"sim/sound/avionics/external-view",
true);
65 _internal = _props->getNode(
"sim/current-view/internal",
true);
67 _atc_enabled = _props->getNode(
"sim/sound/atc/enabled",
true);
68 _atc_volume = _props->getNode(
"sim/sound/atc/volume",
true);
69 _atc_ext = _props->getNode(
"sim/sound/atc/external-view",
true);
71 _machwave_active = _props->getNode(
"sim/sound/machwave/active",
true);
72 _machwave_volume = _props->getNode(
"sim/sound/machwave/offset-m",
true);
78 _active = _smgr->is_active();
81 _smgr->add(
this, refname);
85 _avionics = _smgr->find(
"avionics",
true);
86 _avionics->tie_to_listener();
88 _atc = _smgr->find(
"atc",
true);
89 _atc->tie_to_listener();
117 SGPropertyNode *node = _props->getNode(
"sim/sound",
true);
119 std::string path_str = node->getStringValue(
"path");
120 if (path_str.empty()) {
121 SG_LOG(SG_SOUND, SG_ALERT,
"No path in sim/sound/path");
125 SGPath path =
globals->resolve_aircraft_path(path_str);
128 simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::AudioFX,
129 "Failed to find FX XML file:" + path_str, sg_location{path_str});
130 SG_LOG(SG_SOUND, SG_ALERT,
131 "File not found: '" << path_str);
134 SG_LOG(SG_SOUND, SG_INFO,
"Reading sound " << node->getNameString()
135 <<
" from " << path);
139 readProperties(path, &root);
140 }
catch (
const sg_exception& e) {
141 simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::AudioFX,
142 "Failure loading FX XML:" + e.getFormattedMessage(), e.getLocation());
146 node = root.getNode(
"fx");
148 for (
int i = 0;
i < node->nChildren(); ++
i) {
149 std::unique_ptr<SGXmlSound> soundfx{
new SGXmlSound};
152 bool ok = soundfx->init( _props, node->getChild(
i),
this, _avionics,
156 _sound.push_back( soundfx.release() );
158 }
catch ( sg_exception &e ) {
159 SG_LOG(SG_SOUND, SG_ALERT, e.getFormattedMessage());
160 simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::AudioFX,
161 "Failure creating Audio FX:" + e.getFormattedMessage(), path);
186 if (!_active && _smgr->is_active())
189 for (
unsigned int i = 0;
i < _sound.size();
i++ ) {
195 if ( _enabled->getBoolValue() ) {
198 const bool e = _avionics_enabled->getBoolValue();
199 if (e && (_avionics_ext->getBoolValue() || _internal->getBoolValue())) {
202 _avionics->set_volume( _avionics_volume->getFloatValue() );
205 _avionics->suspend();
210 const bool e = _atc_enabled->getBoolValue();
211 if (e && (_atc_ext->getBoolValue() || _internal->getBoolValue())) {
214 _atc->set_volume( _atc_volume->getFloatValue() );
220 _machwave_active->setBoolValue(_mInCone);
221 _machwave_volume->setFloatValue(_mOffset_m);
223 set_volume( _volume->getDoubleValue() );
227 for (
unsigned int i = 0;
i < _sound.size();
i++ ) {
228 _sound[
i]->update(dt);
231 SGSampleGroup::update(dt);