]> git.mxchange.org Git - flightgear.git/blob - src/Sound/scenefx.hxx
Interim windows build fix
[flightgear.git] / src / Sound / scenefx.hxx
1 // scenefx.hxx -- Scene sound effect management class
2 //
3 // Started by Erik Hofman, November 2015
4 //
5 // Copyright (C) 2015  Erik Hofman <erik@ehofman.com>
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23 #ifndef __FGSCENEFX_HXX
24 #define __FGSCENEFX_HXX 1
25
26 #include <simgear/compiler.h>
27
28 #include <simgear/structure/subsystem_mgr.hxx>
29 #include <simgear/props/props.hxx>
30 #include <simgear/sound/sample_group.hxx>
31 #include <simgear/math/SGMathFwd.hxx>
32
33 #define _DEFAULT_MAX_DISTANCE           100000.0
34
35 class SGXmlSound;
36
37 /**
38  * Container for FlightGear envirnonmetal sound effects.
39  */
40 class FGSceneFX : public SGSampleGroup
41 {
42
43 public:
44
45     FGSceneFX();
46     virtual ~FGSceneFX();
47
48     void init ();
49     void reinit();
50     void update (double dt);
51     void unbind();
52
53     /* Adjust volume and distance properties for the aircraft model */
54     /* These work on all active sounds                              */
55     void model_damping(float damping);
56
57     /* (Over)load the sound file for a particular ref. name         */
58     bool load(const std::string& refname, const std::string& path_str);
59
60
61     /* Control the sounds from the generating side.
62      *
63      * Every sound has a reference name and an instance number:
64      * A reference name would be for instance 'thunder' or 'rain'.
65      * The number indicates the exact instance in case multiple
66      * variants are active simultaniously.
67      */
68     size_t add(const std::string& refname);
69     bool remove(const std::string& refname, size_t num);
70
71     void position(const std::string& refname, size_t num, double lon, double lat, double elevation = 0.0);
72     void pitch(const std::string& refname, size_t num, float pitch);
73     void volume(const std::string& refname, size_t num, float volume);
74     void properties(const std::string& refname, size_t num, float reference_dist, float max_dist = -1 );
75     void play(const std::string& refname, size_t num, bool looping = false);
76     void stop(const std::string& refname, size_t num);
77
78 private:
79     SGPropertyNode_ptr _enabled;
80     SGPropertyNode_ptr _volume;
81     SGPropertyNode_ptr _damping;        // model sound damping
82
83     std::vector<SGXmlSound *> _sound;
84     SGPropertyNode_ptr _props;
85
86     const char* full_name(const std::string& refname, size_t num);
87     SGSoundSample *find(const std::string& refname, size_t num);
88 };
89
90
91 #endif
92
93 // end of scenefx.hxx