]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/fg_sound.hxx
Fix a bug in transit sound termination and adjust the minimum time we
[flightgear.git] / src / Sound / fg_sound.hxx
index 2ceb2ae80cd5d23cc1df6dbf344cd5335cfc0a9f..ce66e13a3dbdd985c3f9c41313e4a0f0ca8b0e80 100644 (file)
 
 #include "soundmgr.hxx"
 
+static const double MAX_TRANSIT_TIME = 0.1;    // 10 ms.
+
+
 /**
- * Class for handling one sound.
+ * Class for handling one sound event.
  *
  */
-class FGSound : public FGSubsystem
+class FGSound
 {
 
 public:
 
-  enum { MAXPROP=5 };
-  enum { LIN=0, LOG, LN };
-  enum { ONCE=0, LOOPED };
-  enum { LEVEL=0, INVERTED, FLIPFLOP };
-
-  FGSound(const SGPropertyNode *);
+  FGSound();
   virtual ~FGSound();
 
-  virtual void init ();
+  virtual void init (SGPropertyNode *);
   virtual void bind ();
   virtual void unbind ();
-  virtual void update (int dt);
+  virtual void update (double dt);
 
-private:
+protected:
 
-  const SGPropertyNode * _node;
+  enum { MAXPROP=5 };
+  enum { ONCE=0, LOOPED, IN_TRANSIT };
+  enum { LEVEL=0, INVERTED, FLIPFLOP };
+
+  // Sound properties
+  typedef struct {
+        SGPropertyNode * prop;
+        double (*fn)(double);
+        double *intern;
+        double factor;
+        double offset;
+        double min;
+        double max;
+        bool subtract;
+  } _snd_prop;
 
+private:
+
+  FGSoundMgr * _mgr;
   FGSimpleSound * _sample;
-  const SGPropertyNode * _property;
 
-  bool _active;
+  FGCondition * _condition;
+  SGPropertyNode * _property;
 
-  int _mode;
-  int _type;
+  bool _active;
   string _name;
-  float _factor;
-
-#if 0
-  // Sound source (distance, horizontal position in degrees and 
-  // vertical position in degrees)
-  struct {
-       float dist;
-       float hor;
-       float vert;
-  } _pos;
-#endif
-
-  // Sound properties
-  typedef struct {
-        const SGPropertyNode * prop;
-        float factor;
-        int type;
-        float offset;
-        float min;
-        float max;
-       bool subtract;
-  } _snd_prop;
+  int _mode;
+  double _prev_value;
+  double _dt_play;
+  double _dt_stop;
+  double _stopping;    // time after the sound should have stopped.
+                       // This is usefull for lost packets in in-trasit mode.
 
   vector<_snd_prop> _volume;
   vector<_snd_prop> _pitch;