vca design: gain controls cannot silently "merge" the master(s) value into their own
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 29 Feb 2016 14:09:53 +0000 (09:09 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 31 May 2016 19:30:38 +0000 (15:30 -0400)
libs/ardour/amp.cc
libs/ardour/ardour/gain_control.h
libs/ardour/gain_control.cc

index d5b9f56ca5f932a7ddc67eaeada5668815c1e2e5..0e299227476e16bd4bedb5e9f964b4187dfea6cb 100644 (file)
@@ -118,7 +118,7 @@ Amp::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/,
 
                } else { /* manual (scalar) gain */
 
-                       gain_t const dg = _gain_control->user_double();
+                       gain_t const dg = _gain_control->user_double() * _gain_control->get_master_gain ();
 
                        if (_current_gain != dg) {
 
index 9a79a8046f50053affd575e39e99cc1b28f37f8b..c6421a6922a673629e7b9428737056e91936d04c 100644 (file)
@@ -43,7 +43,6 @@ class LIBARDOUR_API GainControl : public AutomationControl {
 
        void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
        void set_value_unchecked (double);
-       double get_value () const;
 
        double internal_to_interface (double) const;
        double interface_to_internal (double) const;
@@ -54,18 +53,20 @@ class LIBARDOUR_API GainControl : public AutomationControl {
        double lower_db;
        double range_db;
 
+       gain_t get_master_gain () const;
        void add_master (boost::shared_ptr<GainControl>);
        void remove_master (boost::shared_ptr<GainControl>);
        void clear_masters ();
 
   private:
        void _set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
-       gain_t get_master_gain () const;
 
        mutable Glib::Threads::Mutex master_lock;
 
        typedef std::list<boost::shared_ptr<GainControl> > Masters;
        Masters _masters;
+
+       gain_t get_master_gain_locked () const;
 };
 
 } /* namespace */
index 3021151bdc6491b4f51472fa8a2801b5350eb4a0..eeb49e7de04fecc214892faa049bb6ae5b17b49c 100644 (file)
@@ -36,22 +36,6 @@ GainControl::GainControl (Session& session, const Evoral::Parameter &param, boos
        range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db;
 }
 
-double
-GainControl::get_value() const
-{
-       Glib::Threads::Mutex::Lock sm (master_lock, Glib::Threads::TRY_LOCK);
-
-       if (sm.locked()) {
-               if (_masters.empty()) {
-                       return AutomationControl::get_value();
-               }
-               return AutomationControl::get_value() * get_master_gain ();
-       } else {
-               /* could not take lock */
-               return AutomationControl::get_value ();
-       }
-}
-
 void
 GainControl::set_value (double val, PBD::Controllable::GroupControlDisposition group_override)
 {
@@ -115,6 +99,18 @@ GainControl::get_user_string () const
 
 gain_t
 GainControl::get_master_gain () const
+{
+       Glib::Threads::Mutex::Lock sm (master_lock, Glib::Threads::TRY_LOCK);
+
+       if (sm.locked()) {
+               return get_master_gain_locked ();
+       }
+
+       return 1.0;
+}
+
+gain_t
+GainControl::get_master_gain_locked () const
 {
        /* Master lock MUST be held */
 
@@ -135,9 +131,9 @@ GainControl::add_master (boost::shared_ptr<GainControl> m)
 
        {
                Glib::Threads::Mutex::Lock lm (master_lock);
-               old_master_val = get_master_gain ();
+               old_master_val = get_master_gain_locked ();
                _masters.push_back (m);
-               new_master_val = get_master_gain ();
+               new_master_val = get_master_gain_locked ();
        }
 
        if (old_master_val != new_master_val) {
@@ -153,9 +149,9 @@ GainControl::remove_master (boost::shared_ptr<GainControl> m)
 
        {
                Glib::Threads::Mutex::Lock lm (master_lock);
-               old_master_val = get_master_gain ();
+               old_master_val = get_master_gain_locked ();
                _masters.remove (m);
-               new_master_val = get_master_gain ();
+               new_master_val = get_master_gain_locked ();
        }
 
        if (old_master_val != new_master_val) {
@@ -171,9 +167,9 @@ GainControl::clear_masters ()
 
        {
                Glib::Threads::Mutex::Lock lm (master_lock);
-               old_master_val = get_master_gain ();
+               old_master_val = get_master_gain_locked ();
                _masters.clear ();
-               new_master_val = get_master_gain ();
+               new_master_val = get_master_gain_locked ();
        }
 
        if (old_master_val != new_master_val) {