- FGSoundMgr * mgr = globals->get_soundmgr();
- int i;
-
- //
- // Create and add engine-related sounds.
- //
- for (i = 0; i < MAX_ENGINES; i++) {
- // Engine
- _engine[i] =
- new FGSimpleSound(fgGetString("/sim/sounds/engine/path",
- "Sounds/wasp.wav"));
- _engine[i]->set_volume(fgGetFloat("/sim/sounds/engine/volume", 1.0));
- _engine[i]->set_pitch(fgGetFloat("/sim/sounds/engine/pitch", 1.0));
- mgr->add(_engine[i], engine_names[i]);
-
- // Starter
- _crank[i] = new FGSimpleSound(fgGetString("/sim/sounds/cranking/path",
- "Sounds/cranking.wav"));
- _crank[i]->set_volume(fgGetFloat("/sim/sounds/cranking/volume", 0.5));
- _crank[i]->set_pitch(fgGetFloat("/sim/sounds/cranking/pitch", 1.00));
- mgr->add(_crank[i], crank_names[i]);
- }
-
-
- //
- // Create and add the wind noise.
- //
- _wind = new FGSimpleSound(fgGetString("/sim/sounds/wind/path",
- "Sounds/wind.wav"));
- _wind->set_volume(fgGetFloat("/sim/sounds/wind/volume", 1.0));
- _wind->set_pitch(fgGetFloat("/sim/sounds/wind/pitch", 1.0));
- mgr->add(_wind, "wind");
-
-
- //
- // Create and add the stall noise.
- //
- _stall = new FGSimpleSound(fgGetString("/sim/sounds/stall/path",
- "Sounds/stall.wav"));
- _stall->set_volume(fgGetFloat("/sim/sounds/stall/volume", 1.0));
- _stall->set_pitch(fgGetFloat("/sim/sounds/stall/pitch", 1.0));
- mgr->add(_stall, "stall");
-
- //
- // Create and add the rumble noise.
- //
- _rumble = new FGSimpleSound(fgGetString("/sim/sounds/rumble/path",
- "Sounds/rumble.wav"));
- _rumble->set_volume(fgGetFloat("/sim/sounds/rumble/volume", 1.0));
- _rumble->set_pitch(fgGetFloat("/sim/sounds/rumble/pitch", 1.0));
- mgr->add(_rumble, "rumble");
-
-
- //
- // Create and add the flaps noise
- //
- _flaps = new FGSimpleSound(fgGetString("/sim/sounds/flaps/path",
- "Sounds/flaps.wav"));
- _flaps->set_volume(fgGetFloat("/sim/sounds/flaps/volume", 0.25));
- _flaps->set_pitch(fgGetFloat("/sim/sounds/flaps/pitch", 1.0));
- mgr->add(_flaps, "flaps");
-
- //
- // Create and add the gear noises.
- //
- _gear_up = new FGSimpleSound(fgGetString("/sim/sounds/gear-up/path",
- "Sounds/gear-up.wav"));
- _gear_dn = new FGSimpleSound(fgGetString("/sim/sounds/gear-down/path",
- "Sounds/gear-dn.wav"));
- _gear_up->set_volume(fgGetFloat("/sim/sounds/gear-up/volume", 1.0));
- _gear_dn->set_volume(fgGetFloat("/sim/sounds/gear-down/volume", 1.0));
- _gear_up->set_pitch(fgGetFloat("/sim/sounds/gear-up/pitch", 1.0));
- _gear_dn->set_pitch(fgGetFloat("/sim/sounds/gear-down/pitch", 1.0));
- mgr->add(_gear_up, "gear-up");
- mgr->add(_gear_dn, "gear-down");
-
- //
- // Create and add the squeal noise.
- //
- _squeal = new FGSimpleSound(fgGetString("/sim/sounds/squeal/path",
- "Sounds/squeal.wav"));
- _squeal->set_volume(fgGetFloat("/sim/sounds/squeal/volume", 1.0));
- _squeal->set_pitch(fgGetFloat("/sim/sounds/squeal/pitch", 1.0));
- mgr->add(_squeal, "squeal");
-
- //
- // Simplistic wheel spin model for audio effect purposes only. We
- // don't want to play a full squeel, if the wheel has only departed
- // from the ground for a split second.
- //
- for (i = 0; i < MAX_GEAR; i++) {
- _wheel_spin[i] = 0.0;
- }
-
- //
- // Create and add the click noise.
- _click = new FGSimpleSound(fgGetString("/sim/sounds/click/path",
- "Sounds/click.wav"));
- _flaps->set_volume(fgGetFloat("/sim/sounds/click/volume", 1.0));
- _flaps->set_pitch(fgGetFloat("/sim/sounds/click/pitch", 1.0));
- mgr->add(_click, "click");
-
-
- ////////////////////////////////////////////////////////////////////
- // Grab some properties.
- ////////////////////////////////////////////////////////////////////
-
- for (i = 0; i < MAX_ENGINES; i++) {
- char buf[100];
- sprintf(buf, "/engines/engine[%d]/running", i);
- _engine_running_prop[i] = fgGetNode(buf, true);
- sprintf(buf, "/engines/engine[%d]/cranking", i);
- _engine_cranking_prop[i] = fgGetNode(buf, true);
- }
- _stall_warning_prop = fgGetNode("/sim/aero/alarms/stall-warning", true);
- _vc_prop = fgGetNode("/velocities/airspeed-kt", true);
- _flaps_prop = fgGetNode("/controls/flaps", true);
- _gear_prop = fgGetNode("/controls/gear-down", true);
+ SGPropertyNode *node = fgGetNode("/sim/sound", true);
+ int i;
+
+ string path_str = node->getStringValue("path");
+ SGPath path( globals->get_fg_root() );
+ if (path_str.empty()) {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Incorrect path in configuration file.");
+ return;
+ }
+
+ path.append(path_str.c_str());
+ SG_LOG(SG_GENERAL, SG_INFO, "Reading sound " << node->getName()
+ << " from " << path.str());
+
+ SGPropertyNode root;
+ try {
+ readProperties(path.str(), &root);
+ } catch (const sg_exception &) {
+ SG_LOG(SG_GENERAL, SG_ALERT,
+ "Incorrect path specified in configuration file");
+ return;
+ }
+
+ node = root.getNode("fx");
+ for (i = 0; i < node->nChildren(); i++) {
+ SGXmlSound *sound = new SGXmlSound();
+
+ try {
+ sound->init(globals->get_props(), node->getChild(i),
+ globals->get_soundmgr(), globals->get_fg_root());
+
+ _sound.push_back(sound);
+ } catch ( sg_io_exception &e ) {
+ SG_LOG(SG_GENERAL, SG_ALERT, e.getFormattedMessage());
+ delete sound;
+ }
+ }