- FGSoundMgr * mgr = globals->get_soundmgr();
-
- //
- // Create and add the engine sound
- //
- _engine =
- new FGSimpleSound(fgGetString("/sim/sounds/engine", "Sounds/wasp.wav"));
- mgr->add(_engine, "engine loop");
- mgr->play_looped("engine loop");
-
- SG_LOG( SG_GENERAL, SG_INFO,
- "Rate = " << _engine->get_sample()->getRate()
- << " Bps = " << _engine->get_sample()->getBps()
- << " Stereo = " << _engine->get_sample()->getStereo() );
-
-
- //
- // Create and add the cranking sound.
- //
- _crank =
- new FGSimpleSound(fgGetString("/sim/sounds/cranking",
- "Sounds/cranking.wav"));
- mgr->add(_crank, "crank");
- _crank->set_pitch(1.5);
- _crank->set_volume(0.25);
-
-
- //
- // Create and add the wind noise.
- //
- _wind =
- new FGSimpleSound(fgGetString("/sim/sounds/wind", "Sounds/wind.wav"));
- mgr->add(_wind, "wind");
- mgr->play_looped("wind");
-
-
- //
- // Create and add the stall noise.
- //
- _stall = new FGSimpleSound(fgGetString("/sim/sounds/stall",
- "Sounds/stall.wav"));
- mgr->add(_stall, "stall");
-
- //
- // Create and add the rumble noise.
- //
- _rumble = new FGSimpleSound(fgGetString("/sim/sounds/rumble",
- "Sounds/rumble.wav"));
- mgr->add(_rumble, "rumble");
-
- //
- // Create and add the squeal noise.
- //
- _squeal = new FGSimpleSound(fgGetString("/sim/sounds/squeal",
- "Sounds/squeal.wav"));
- mgr->add(_squeal, "squeal");
-
- //
- // Create and add the click noise.
- _click = new FGSimpleSound(fgGetString("/sim/sounds/click",
- "Sounds/click.wav"));
- mgr->add(_click, "click");
+ 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;
+ }
+ }