]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/mk_viii.hxx
Replacement code for ATCDCL functions are in ATC/atcutils.[ch]xx. Thanks to Alex...
[flightgear.git] / src / Instrumentation / mk_viii.hxx
index 4db4b45cec27bcb3a4fb75808e6c4fa6ec03d864..7d33b1ca8358c43f31f973a792d289759c13223b 100755 (executable)
@@ -36,9 +36,16 @@ using std::vector;
 using std::deque;
 using std::map;
 
-#include "Airports/runways.hxx"
-#include "Airports/simple.hxx"
-#include "Main/globals.hxx"
+class SGSampleGroup;
+
+#include <Airports/runways.hxx>
+#include <Airports/simple.hxx>
+#include <Main/globals.hxx>
+
+#ifdef _MSC_VER
+#  pragma warning( push )
+#  pragma warning( disable: 4355 )
+#endif
 
 ///////////////////////////////////////////////////////////////////////////////
 // MK_VIII ////////////////////////////////////////////////////////////////////
@@ -47,7 +54,7 @@ using std::map;
 class MK_VIII : public SGSubsystem
 {
   // keep in sync with Mode6Handler::altitude_callout_definitions[]
-  static const int n_altitude_callouts = 11;
+  static const unsigned n_altitude_callouts = 11;
 
   /////////////////////////////////////////////////////////////////////////////
   // MK_VIII::RawValueMethodsData /////////////////////////////////////////////
@@ -68,7 +75,7 @@ class MK_VIII : public SGSubsystem
       if (_getter)
        return (_obj.*_getter)(_data);
       else
-       return SGRawValue<VT>::DefaultValue;
+       return SGRawValue<VT>::DefaultValue();
     }
     virtual bool setValue (VT value)
     {
@@ -728,10 +735,10 @@ public:
       public:
        bool silence;
 
-       virtual inline void play (double volume) {}
+       virtual inline void play (float volume) {}
        virtual inline void stop () {}
        virtual bool is_playing () = 0;
-       virtual inline void set_volume (double volume) {}
+       virtual inline void set_volume (float volume) {}
       };
 
       /////////////////////////////////////////////////////////////////////////
@@ -740,17 +747,17 @@ public:
 
       class SampleElement : public Element
       {
-       SGSoundSample   *_sample;
-       double          _volume;
+       SGSharedPtr<SGSoundSample>      _sample;
+       float                           _volume;
 
       public:
-       inline SampleElement (SGSoundSample *sample, double volume = 1.0)
+       inline SampleElement (SGSharedPtr<SGSoundSample> sample, float volume = 1.0)
          : _sample(sample), _volume(volume) { silence = false; }
 
-        virtual inline void play (double volume) { if (_sample) { set_volume(volume); _sample->play_once(); } }
+        virtual inline void play (float volume) { if (_sample && (volume > 0.05)) { set_volume(volume); _sample->play_once(); } }
        virtual inline void stop () { if (_sample) _sample->stop(); }
         virtual inline bool is_playing () { return _sample ? _sample->is_playing() : false; }
-       virtual inline void set_volume (double volume) { if (_sample) _sample->set_volume(volume * _volume); }
+       virtual inline void set_volume (float volume) { if (_sample) _sample->set_volume(volume * _volume); }
       };
 
       /////////////////////////////////////////////////////////////////////////
@@ -766,7 +773,7 @@ public:
        inline SilenceElement (double duration)
          : _duration(duration) { silence = true; }
 
-       virtual inline void play (double volume) { start_time = globals->get_sim_time_sec(); }
+       virtual inline void play (float volume) { start_time = globals->get_sim_time_sec(); }
        virtual inline bool is_playing () { return globals->get_sim_time_sec() - start_time < _duration; }
       };
 
@@ -777,7 +784,7 @@ public:
       Element *element;
 
       inline Voice (VoicePlayer *_player)
-       : player(_player), volume(1.0), element(NULL) {}
+        : element(NULL), player(_player), volume(1.0) {}
 
       ~Voice ();
 
@@ -785,19 +792,19 @@ public:
 
       void play ();
       void stop (bool now);
-      void set_volume (double _volume);
+      void set_volume (float _volume);
       void volume_changed ();
       void update ();
 
     private:
       VoicePlayer *player;
 
-      double volume;
+      float volume;
 
       vector<Element *>                        elements;
       vector<Element *>::iterator      iter;
 
-      inline double get_volume () const { return player->volume * player->speaker.volume * volume; }
+      inline float get_volume () const { return player->volume * player->speaker.volume * volume; }
     };
 
     ///////////////////////////////////////////////////////////////////////////
@@ -806,10 +813,10 @@ public:
 
     struct
     {
-      double volume;
+      float volume;
     } conf;
 
-    double volume;
+    float volume;
 
     Voice *voice;
     Voice *next_voice;
@@ -847,7 +854,7 @@ public:
     } voices;
 
     inline VoicePlayer (MK_VIII *device)
-      : mk(device), speaker(this), voice(NULL), next_voice(NULL) {}
+      : voice(NULL), next_voice(NULL),  mk(device), speaker(this) {}
 
     ~VoicePlayer ();
 
@@ -866,7 +873,7 @@ public:
     };
     void stop (unsigned int flags = 0);
 
-    void set_volume (double _volume);
+    void set_volume (float _volume);
     void update ();
 
     inline void bind (SGPropertyNode *node) { speaker.bind(node); }
@@ -882,13 +889,6 @@ public:
       VoicePlayer *player;
 
       double   pitch;
-      float    position[3];
-      float    orientation[3];
-      float    inner_cone;
-      float    outer_cone;
-      float    outer_gain;
-      float    reference_dist;
-      float    max_dist;
 
       template <class T>
       inline void tie (SGPropertyNode *node, const char *name, T *ptr)
@@ -908,20 +908,13 @@ public:
       template <class T>
       inline T get_property (T *ptr) const { return *ptr; }
 
-      double volume;
+      float volume;
 
       inline Speaker (VoicePlayer *_player)
        : player(_player),
-         volume(1),
          pitch(1),
-         inner_cone(360),
-         outer_cone(360),
-         outer_gain(0),
-         reference_dist(3),
-         max_dist(10)
+         volume(1)
       {
-       position[0] = 0; position[1] = 0; position[2] = 0;
-       orientation[0] = 0; orientation[1] = 0; orientation[2] = 0;
       }
 
       void bind (SGPropertyNode *node);
@@ -935,9 +928,10 @@ public:
 
     MK_VIII *mk;
 
+    SGSharedPtr<SGSampleGroup> _sgr;
     Speaker speaker;
 
-    map<string, SGSoundSample *>       samples;
+    map< string, SGSharedPtr<SGSoundSample> >  samples;
     vector<Voice *>                    _voices;
 
     bool looped;
@@ -1026,7 +1020,7 @@ private:
     State state;
 
     inline SelfTestHandler (MK_VIII *device)
-      : mk(device), state(STATE_NONE), button_pressed(false) {}
+      : mk(device), button_pressed(false), state(STATE_NONE) {}
 
     inline void power_off () { stop(); }
     inline void set_inop () { stop(); }
@@ -1460,7 +1454,7 @@ private:
     void power_off ();
     void enter_takeoff ();
     void leave_takeoff ();
-    void set_volume (double volume);
+    void set_volume (float volume);
     bool altitude_callouts_enabled ();
     void update ();
 
@@ -1589,10 +1583,6 @@ private:
         : mk(device) {}
         
       virtual bool passAirport(FGAirport *a) const;
-      
-      virtual FGPositioned::Type maxType() const {
-        return FGPositioned::AIRPORT;
-      }
     private:
       MK_VIII* mk;
     };
@@ -1646,4 +1636,8 @@ public:
   virtual void update (double dt);
 };
 
+#ifdef _MSC_VER
+#  pragma warning( pop )
+#endif
+
 #endif // __INSTRUMENTS_MK_VIII_HXX