]> git.mxchange.org Git - flightgear.git/blob - src/Sound/scenefx.hxx
Checkpoint - ground-net skips the cache
[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 /**
36  * Container for FlightGear envirnonmetal sound effects.
37  */
38 class FGSceneFX : public SGSampleGroup
39 {
40
41 public:
42
43     FGSceneFX();
44     virtual ~FGSceneFX();
45
46     void init ();
47     void reinit();
48     void update (double dt);
49     void unbind();
50
51     /* Adjust volume and distance properties for the aircraft model */
52     /* These work on all active sounds                              */
53     void model_damping(float damping);
54
55     /* (Over)load the sound file for a particular ref. name         */
56     bool load(const std::string& refname, const std::string& path_str);
57
58
59     /* Control the sounds from the generating side.
60      *
61      * Every sound has a reference name and an instance number:
62      * A reference name would be for instance 'thunder' or 'rain'.
63      * The number indicates the exact instance in case multiple
64      * variants are active simultaniously.
65      */
66     size_t add(const std::string& refname);
67     bool remove(const std::string& refname, size_t num);
68
69     void position(const std::string& refname, size_t num, double lon, double lat, double elevation = 0.0);
70     void pitch(const std::string& refname, size_t num, float pitch);
71     void volume(const std::string& refname, size_t num, float volume);
72     void properties(const std::string& refname, size_t num, float reference_dist, float max_dist = -1 );
73     void play(const std::string& refname, size_t num, bool looping = false);
74     void stop(const std::string& refname, size_t num);
75
76 private:
77     SGPropertyNode_ptr _enabled;
78     SGPropertyNode_ptr _volume;
79     SGPropertyNode_ptr _damping;        // model sound damping
80
81     const char* full_name(const std::string& refname, size_t num);
82     SGSoundSample *find(const std::string& refname, size_t num);
83 };
84
85
86 #endif
87
88 // end of scenefx.hxx