1 // fg_fx.cxx -- Sound effect management class implementation
3 // Started by David Megginson, October 2001
4 // (Reuses some code from main.cxx, probably by Curtis Olson)
6 // Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #pragma warning (disable: 4786)
28 #include <simgear/misc/props.hxx>
29 #include <simgear/misc/sg_path.hxx>
30 #include <simgear/debug/logstream.hxx>
31 #include <simgear/misc/exception.hxx>
33 # define exception c_exception
36 #include <Main/fg_props.hxx>
39 #include "fg_sound.hxx"
48 for (unsigned int i = 0; i < _sound.size(); i++ )
55 SGPropertyNode * node = fgGetNode("/sim/sound", true);
58 string path_str = node->getStringValue("path");
59 SGPath path( globals->get_fg_root() );
60 if (path_str.empty()) {
61 SG_LOG(SG_GENERAL, SG_ALERT, "Incorrect path in configuration file.");
65 path.append(path_str.c_str());
66 SG_LOG(SG_GENERAL, SG_INFO, "Reading Instrument " << node->getName()
67 << " from " << path.str());
71 readProperties(path.str(), &root);
72 } catch (const sg_exception &e) {
73 SG_LOG(SG_GENERAL, SG_ALERT,
74 "Incorrect path specified in configuration file");
78 node = root.getNode("fx");
79 for (i = 0; i < node->nChildren(); i++) {
80 FGSound *sound = new FGSound();
81 sound->init(node->getChild(i));
83 _sound.push_back(sound);
98 FGFX::update (double dt)
100 if (fgGetBool("/sim/sound/audible")) {
101 for (unsigned int i = 0; i < _sound.size(); i++ )
102 _sound[i]->update(dt);