enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / ardour / ardour / monitor_processor.h
index 023dacb619a57d373c4eba6c60b6eb2877d84102..d369cb9c282002b8330d02330260dea509bce53b 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef __ardour_monitor_processor_h__
 #define __ardour_monitor_processor_h__
 
+#include <algorithm>
 #include <iostream>
 #include <vector>
 
 #include "pbd/compose.h"
 #include "pbd/controllable.h"
 
+#include "ardour/libardour_visibility.h"
 #include "ardour/types.h"
 #include "ardour/processor.h"
 
+#include "ardour/dB.h"
+
 class XMLNode;
 
 namespace ARDOUR {
@@ -37,7 +41,7 @@ namespace ARDOUR {
 class Session;
 
 template<typename T>
-class MPControl : public PBD::Controllable {
+class /*LIBARDOUR_API*/ MPControl : public PBD::Controllable {
 public:
        MPControl (T initial, const std::string& name, PBD::Controllable::Flag flag,
                   float lower = 0.0f, float upper = 1.0f)
@@ -45,15 +49,16 @@ public:
                , _value (initial)
                , _lower (lower)
                , _upper (upper)
+               , _normal (initial)
        {}
 
        /* Controllable API */
 
-       void set_value (double v) {
+       void set_value (double v, PBD::Controllable::GroupControlDisposition gcd) {
                T newval = (T) v;
                if (newval != _value) {
-                       _value = newval;
-                       Changed(); /* EMIT SIGNAL */
+                       _value = std::max (_lower, std::min (_upper, newval));
+                       Changed (true, gcd); /* EMIT SIGNAL */
                }
        }
 
@@ -61,15 +66,25 @@ public:
                return (float) _value;
        }
 
+       double internal_to_user (double i) const { return accurate_coefficient_to_dB (i);}
+       double user_to_internal (double u) const { return dB_to_coefficient(u) ;}
+
+       std::string get_user_string () const
+       {
+               char theBuf[32]; sprintf( theBuf, "%3.1f dB", accurate_coefficient_to_dB (get_value()));
+               return std::string(theBuf);
+       }
+
        double lower () const { return _lower; }
        double upper () const { return _upper; }
+       double normal () const { return _normal; }
 
        /* "access as T" API */
 
        MPControl& operator=(const T& v) {
                if (v != _value) {
-                       _value = v;
-                       Changed (); /* EMIT SIGNAL */
+                       _value = std::max (_lower, std::min (_upper, v));
+                       Changed (true, PBD::Controllable::UseGroup); /* EMIT SIGNAL */
                }
                return *this;
        }
@@ -101,9 +116,10 @@ protected:
        T _value;
        T _lower;
        T _upper;
+       T _normal;
 };
 
-class MonitorProcessor : public Processor
+class LIBARDOUR_API MonitorProcessor : public Processor
 {
 public:
        MonitorProcessor (Session&);
@@ -111,13 +127,13 @@ public:
 
        bool display_to_user() const;
 
-       void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t /*nframes*/, bool /*result_required*/);
+       void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double /*speed*/, pframes_t /*nframes*/, bool /*result_required*/);
 
        XMLNode& state (bool full);
        int set_state (const XMLNode&, int /* version */);
 
        bool configure_io (ChanCount in, ChanCount out);
-       bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
+       bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
 
        void set_cut_all (bool);
        void set_dim_all (bool);
@@ -138,6 +154,8 @@ public:
        bool dim_all () const;
        bool mono () const;
 
+       bool monitor_active () const { return _monitor_active; }
+
        PBD::Signal0<void> Changed;
 
        boost::shared_ptr<PBD::Controllable> channel_cut_control (uint32_t) const;
@@ -182,6 +200,8 @@ private:
        std::vector<ChannelRecord*> _channels;
 
        uint32_t             solo_cnt;
+       bool                 _monitor_active;
+
 
        /* pointers - created first, but managed by boost::shared_ptr<> */
 
@@ -208,6 +228,7 @@ private:
        MPControl<volatile gain_t>& _solo_boost_level;
 
        void allocate_channels (uint32_t);
+       void update_monitor_state ();
 };
 
 } /* namespace */