diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-02-29 09:09:53 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-05-31 15:30:38 -0400 |
commit | 8eafe8b8045e60b305a40b729b9daea2c6289d28 (patch) | |
tree | c50dff992ee908e81e63296aaa25992ae09b1661 | |
parent | 405f9fc712836937bf44dba48c64c1741bc4101c (diff) |
vca design: gain controls cannot silently "merge" the master(s) value into their own
-rw-r--r-- | libs/ardour/amp.cc | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/gain_control.h | 5 | ||||
-rw-r--r-- | libs/ardour/gain_control.cc | 40 |
3 files changed, 22 insertions, 25 deletions
diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc index d5b9f56ca5..0e29922747 100644 --- a/libs/ardour/amp.cc +++ b/libs/ardour/amp.cc @@ -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) { diff --git a/libs/ardour/ardour/gain_control.h b/libs/ardour/ardour/gain_control.h index 9a79a8046f..c6421a6922 100644 --- a/libs/ardour/ardour/gain_control.h +++ b/libs/ardour/ardour/gain_control.h @@ -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 */ diff --git a/libs/ardour/gain_control.cc b/libs/ardour/gain_control.cc index 3021151bdc..eeb49e7de0 100644 --- a/libs/ardour/gain_control.cc +++ b/libs/ardour/gain_control.cc @@ -36,22 +36,6 @@ GainControl::GainControl (Session& session, const Evoral::Parameter ¶m, 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) { @@ -116,6 +100,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 */ gain_t g = 1.0; @@ -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) { |