]> git.mxchange.org Git - simgear.git/blob - simgear/sound/sound.hxx
Tweaks to doxygen comments.
[simgear.git] / simgear / sound / sound.hxx
1 // sound.hxx -- Sound class implementation
2 //
3 // Started by Erik Hofman, February 2002
4 //
5 // Copyright (C) 2002  Erik Hofman - erik@ehofman.com
6 //
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.
11 //
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.
16 //
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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23 /** 
24  * \file sound.hxx 
25  * Provides a class to manage a single sound event including things
26  * like looping, volume and pitch changes.
27  */
28
29 #ifndef _SG_SOUND_HXX
30 #define _SG_SOUND_HXX 1
31
32 #ifndef __cplusplus
33 # error This library requires C++
34 #endif
35
36 #include <simgear/compiler.h>
37 #include <simgear/props/condition.hxx>
38
39 #include "soundmgr.hxx"
40
41 static const double MAX_TRANSIT_TIME = 0.1;     // 100 ms.
42
43
44 /**
45  * Class for handling one sound event.
46  *
47  */
48 class SGSound
49 {
50
51 public:
52
53   SGSound();
54   virtual ~SGSound();
55
56   virtual void init (SGPropertyNode *, SGPropertyNode *, SGSoundMgr *,
57                      const string &);
58   virtual void update (double dt);
59
60   void stop();
61
62 protected:
63
64   enum { MAXPROP=5 };
65   enum { ONCE=0, LOOPED, IN_TRANSIT };
66   enum { LEVEL=0, INVERTED, FLIPFLOP };
67
68   // SGSound properties
69   typedef struct {
70         SGPropertyNode * prop;
71         double (*fn)(double);
72         double *intern;
73         double factor;
74         double offset;
75         double min;
76         double max;
77         bool subtract;
78   } _snd_prop;
79
80 private:
81
82   SGSoundMgr * _mgr;
83   SGSimpleSound * _sample;
84
85   SGCondition * _condition;
86   SGPropertyNode * _property;
87
88   bool _active;
89   string _name;
90   int _mode;
91   double _prev_value;
92   double _dt_play;
93   double _dt_stop;
94   double _stopping;     // time after the sound should have stopped.
95                         // This is usefull for lost packets in in-trasit mode.
96
97   vector<_snd_prop> _volume;
98   vector<_snd_prop> _pitch;
99
100 };
101
102 #endif // _SG_SOUND_HXX