]> git.mxchange.org Git - flightgear.git/blob - src/Sound/fg_fx.hxx
Initial commit of the new sound system, expect more updates to follow
[flightgear.git] / src / Sound / fg_fx.hxx
1 // fg_fx.hxx -- Sound effect management class
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 - http://www.flightgear.org/~curt
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 //
22 // $Id$
23
24 #ifndef __FGFX_HXX
25 #define __FGFX_HXX 1
26
27 #include <simgear/compiler.h>
28
29 #include <queue>
30 #include <vector>
31
32 #include <simgear/structure/subsystem_mgr.hxx>
33 #include <simgear/sound/sample_group.hxx>
34 #include <simgear/math/SGMath.hxx>
35
36 class SGXmlSound;
37
38 /**
39  * Generator for FlightGear sound effects.
40  *
41  * This module uses a FGSampleGroup class to generate sound effects based
42  * on current flight conditions.  The sound manager must be initialized
43  * before this object is.
44  *
45  * Note: this module supports two separate sound mechanisms concurrently.
46  *
47  * 1. This module will load and play a set of sound effects defined in an
48  *    xml file and tie them to various property states.
49  * 2. This modules also maintains a queue of 'message' audio files.  These
50  *    are played sequentially with no overlap until the queue is finished.
51  *    This second mechanims is useful for things like tutorial messages or
52  *    background atc chatter.
53  */
54 class FGFX : public SGSampleGroup
55 {
56
57 public:
58
59     FGFX ( SGSoundMgr *smgr, const string &refname );
60     virtual ~FGFX ();
61
62     virtual void init ();
63     virtual void reinit ();
64     virtual void update (double dt);
65
66     /**
67      * add a sound sample to the message queue which is played sequentially
68      * in order.
69      */
70     void play_message( SGSoundSample *_sample );
71     void play_message( const std::string& path, const std::string& fname, double volume );
72
73 private:
74
75     void update_pos_and_orientation(double dt);
76
77     SGVec3d last_visitor_pos;
78     SGVec3d last_model_pos;
79
80     std::vector<SGXmlSound *> _sound;
81     std::queue<SGSoundSample *> _samplequeue;
82
83     bool last_pause;
84     double last_volume;
85
86     SGPropertyNode_ptr _pause;
87     SGPropertyNode_ptr _volume;
88 };
89
90
91 #endif
92
93 // end of fg_fx.hxx