]> git.mxchange.org Git - flightgear.git/blob - src/Sound/fg_sound.hxx
Sound patch from Erik Hofman:
[flightgear.git] / src / Sound / fg_sound.hxx
1 // fg_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 #ifndef __FGSOUND_HXX
24 #define __FGSOUND_HXX 1
25
26 #ifdef HAVE_CONFIG_H
27 #  include <config.h>
28 #endif
29
30 #include <simgear/compiler.h>
31 #include <Main/fgfs.hxx>
32 #include <Main/globals.hxx>
33
34 #include "soundmgr.hxx"
35
36 /**
37  * Class for handling one sound.
38  *
39  */
40 class FGSound : public FGSubsystem
41 {
42
43 public:
44
45   FGSound(const SGPropertyNode *);
46   virtual ~FGSound();
47
48   virtual void init ();
49   virtual void bind ();
50   virtual void unbind ();
51   virtual void update (int dt);
52
53 protected:
54
55   enum { MAXPROP=5 };
56   enum { ONCE=0, LOOPED };
57   enum { LEVEL=0, INVERTED, FLIPFLOP, RAISE, FALL };
58
59
60   // Sound properties
61   typedef struct {
62         const SGPropertyNode * prop;
63         double (*fn)(double);
64         double factor;
65         double offset;
66         double min;
67         double max;
68         bool subtract;
69   } _snd_prop;
70
71 #if 0
72   // Sound source (distance, horizontal position in degrees and
73   // vertical position in degrees)
74   typedef struct {
75         float dist;
76         float hor;
77         float vert;
78   } _pos_prop;
79 #endif
80
81 private:
82
83   const SGPropertyNode * _node;
84
85   FGSimpleSound * _sample;
86   const SGPropertyNode * _property;
87
88   bool _active;
89
90   int _mode;
91   int _type;
92   string _name;
93   double _factor;
94   double _offset;
95
96   vector<_snd_prop> _volume;
97   vector<_snd_prop> _pitch;
98
99 };
100
101 #endif