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
36 * Container for FlightGear envirnonmetal sound effects.
38 class FGSceneFX : public SGSampleGroup
48 void update (double dt);
51 /* Adjust volume and distance properties for the aircraft model */
52 /* These work on all active sounds */
53 void model_damping(float damping);
55 /* (Over)load the sound file for a particular ref. name */
56 bool load(const std::string& refname, const std::string& path_str);
59 /* Control the sounds from the generating side.
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.
66 size_t add(const std::string& refname);
67 bool remove(const std::string& refname, size_t num);
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);
77 SGPropertyNode_ptr _enabled;
78 SGPropertyNode_ptr _volume;
79 SGPropertyNode_ptr _damping; // model sound damping
81 const char* full_name(const std::string& refname, size_t num);
82 SGSoundSample *find(const std::string& refname, size_t num);