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