]> git.mxchange.org Git - flightgear.git/blob - src/Sound/fg_fx.cxx
2c7f5626d2e67d919f94fec7d2415b6f35fc111d
[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 #include <simgear/misc/props.hxx>
25 #include <simgear/misc/sg_path.hxx>
26 #include <simgear/debug/logstream.hxx>
27 #include <simgear/misc/exception.hxx>
28 #ifdef __BORLANDC__
29 #  define exception c_exception
30 #endif
31
32 #include <Main/fg_props.hxx>
33
34 #include "fg_fx.hxx"
35 #include "fg_sound.hxx"
36
37
38 FGFX::FGFX ()
39 {
40 }
41
42 FGFX::~FGFX ()
43 {
44 }
45
46 void
47 FGFX::init()
48 {
49    const SGPropertyNode * node = fgGetNode("/sim/sound", true);
50    int i;
51
52    SGPath path( globals->get_fg_root() );
53    if (node->getStringValue("path") == "") {
54       SG_LOG(SG_GENERAL, SG_ALERT, "Incorect path in configuration file.");
55       return;
56    }
57
58    path.append(node->getStringValue("path"));
59    SG_LOG(SG_GENERAL, SG_INFO, "Reading Instrument " << node->getName()
60     << " from " << path.str());
61
62    SGPropertyNode root;
63    try {
64       readProperties(path.str(), &root);
65    } catch (const sg_exception &e) {
66       SG_LOG(SG_GENERAL, SG_ALERT,
67        "Incorrect path specified in configuration file");
68       return;
69    }
70
71    node = root.getNode("fx");
72    for (i = 0; i < node->nChildren(); i++) {
73       FGSound * sound;
74       sound = new FGSound(node->getChild(i));
75       _sound.push_back(sound);
76    }
77
78    for (i = 0; i < (int)_sound.size(); i++ ) {
79       _sound[i]->init();
80    }
81 }
82
83 void
84 FGFX::bind ()
85 {
86 }
87
88 void
89 FGFX::unbind ()
90 {
91 }
92
93 void
94 FGFX::update (int dt)
95 {
96    for (unsigned int i = 0; i < _sound.size(); i++ )
97       _sound[i]->update(dt);
98 }
99
100 // end of fg_fx.cxx