1 // scenefx.hxx -- Scene sound effect management class
3 // Started by Erik Hofman, November 2015
5 // Copyright (C) 2015 Erik Hofman <erik@ehofman.com>
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.
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.
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.
23 #ifndef __FGSCENEFX_HXX
24 #define __FGSCENEFX_HXX 1
26 #include <simgear/compiler.h>
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>
33 #define _DEFAULT_MAX_DISTANCE 100000.0
38 * Container for FlightGear envirnonmetal sound effects.
40 class FGSceneFX : public SGSampleGroup
50 void update (double dt);
53 /* Adjust volume and distance properties for the aircraft model */
54 /* These work on all active sounds */
55 void model_damping(float damping);
57 /* (Over)load the sound file for a particular ref. name */
58 bool load(const std::string& refname, const std::string& path_str);
61 /* Control the sounds from the generating side.
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.
68 size_t add(const std::string& refname);
69 bool remove(const std::string& refname, size_t num);
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);
79 SGPropertyNode_ptr _enabled;
80 SGPropertyNode_ptr _volume;
81 SGPropertyNode_ptr _damping; // model sound damping
83 std::vector<SGXmlSound *> _sound;
84 SGPropertyNode_ptr _props;
86 const char* full_name(const std::string& refname, size_t num);
87 SGSoundSample *find(const std::string& refname, size_t num);