]> git.mxchange.org Git - flightgear.git/blob - src/Sound/fg_fx.cxx
527a5f3a497db67a6099e5e223c0b88feb20ffa3
[flightgear.git] / src / Sound / fg_fx.cxx
1 // fg_fx.cxx -- Sound effect management class implementation
2 //
3 // Started by David Megginson, October 2001
4 // (Reuses some code from main.cxx, probably by Curtis Olson)
5 //
6 // Copyright (C) 2001  Curtis L. Olson - curt@flightgear.org
7 //
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.
12 //
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.
17 //
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.
21 //
22 // $Id$
23
24 #ifdef _MSC_VER
25 #pragma warning (disable: 4786)
26 #endif
27
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>
32 #ifdef __BORLANDC__
33 #  define exception c_exception
34 #endif
35
36 #include <Main/fg_props.hxx>
37
38 #include "fg_fx.hxx"
39 #include "fg_sound.hxx"
40
41
42 FGFX::FGFX ()
43 {
44 }
45
46 FGFX::~FGFX ()
47 {
48    _sound.clear();
49 }
50
51 void
52 FGFX::init()
53 {
54    SGPropertyNode * node = fgGetNode("/sim/sound", true);
55    int i;
56
57    string path_str = node->getStringValue("path");
58    SGPath path( globals->get_fg_root() );
59    if (path_str.empty()) {
60       SG_LOG(SG_GENERAL, SG_ALERT, "Incorrect path in configuration file.");
61       return;
62    }
63
64    path.append(path_str.c_str());
65    SG_LOG(SG_GENERAL, SG_INFO, "Reading Instrument " << node->getName()
66           << " from " << path.str());
67
68    SGPropertyNode root;
69    try {
70       readProperties(path.str(), &root);
71    } catch (const sg_exception &e) {
72       SG_LOG(SG_GENERAL, SG_ALERT,
73        "Incorrect path specified in configuration file");
74       return;
75    }
76
77    node = root.getNode("fx");
78    for (i = 0; i < node->nChildren(); i++) {
79       FGSound *sound = new FGSound();
80       sound->init(node->getChild(i));
81
82       _sound.push_back(sound);
83    }
84 }
85
86 void
87 FGFX::bind ()
88 {
89 }
90
91 void
92 FGFX::unbind ()
93 {
94 }
95
96 void
97 FGFX::update (double dt)
98 {
99     if (fgGetBool("/sim/sound/audible")) {
100         for (unsigned int i = 0; i < _sound.size(); i++ )
101             _sound[i]->update(dt);
102     }
103 }
104
105 // end of fg_fx.cxx