]> git.mxchange.org Git - flightgear.git/blob - src/Sound/fg_fx.hxx
Added two missing files from JSBSim.org that were missing in the last sync.
[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/sound/sample_openal.hxx>
33 #include <simgear/structure/subsystem_mgr.hxx>
34
35 using std::queue;
36 using std::vector;
37
38 class SGXmlSound;
39
40 /**
41  * Generator for FlightGear sound effects.
42  *
43  * This module uses FGSoundMgr to generate sound effects based
44  * on current flight conditions.  The sound manager must be initialized
45  * before this object is.
46  *
47  * Note: this module supports two separate sound mechanisms concurrently.
48  *
49  * 1. This module will load and play a set of sound effects defined in an
50  *    xml file and tie them to various property states.
51  * 2. This modules also maintains a queue of 'message' audio files.  These
52  *    are played sequentially with no overlap until the queue is finished.
53  *    This second mechanims is useful for things like tutorial messages or
54  *    background atc chatter.
55  */
56 class FGFX : public SGSubsystem
57 {
58
59 public:
60
61     FGFX ();
62     virtual ~FGFX ();
63
64     virtual void init ();
65     virtual void reinit ();
66     virtual void bind ();
67     virtual void unbind ();
68     virtual void update (double dt);
69
70     /**
71      * add a sound sample to the message queue which is played sequentially
72      * in order.
73      */
74     void play_message( SGSoundSample *_sample );
75     void play_message( const string path, const string fname, double volume );
76
77 private:
78
79     void update_pos_and_orientation(SGSoundMgr *smgr, double dt);
80     sgdVec3 last_visitor_pos;
81     sgdVec3 last_model_pos;
82
83     vector<SGXmlSound *> _sound;
84     queue<SGSoundSample *> _samplequeue;
85
86     bool last_pause;
87     double last_volume;
88
89     SGPropertyNode_ptr _pause;
90     SGPropertyNode_ptr _volume;
91 };
92
93
94 #endif
95
96 // end of fg_fx.hxx