Special-case VCA at 0 (-inf dB), force gain slaves to -inf dB
authorRobin Gareus <robin@gareus.org>
Wed, 14 Jun 2017 13:14:56 +0000 (15:14 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 14 Jun 2017 13:21:16 +0000 (15:21 +0200)
libs/ardour/ardour/gain_control.h
libs/ardour/ardour/slavable_automation_control.h
libs/ardour/gain_control.cc
libs/ardour/slavable_automation_control.cc

index 0a7bddcf4f3639465b4871f02b088cf5401ed665..42465cc225ab725413608ef5196cf559ba6aa468 100644 (file)
@@ -51,6 +51,7 @@ class LIBARDOUR_API GainControl : public SlavableAutomationControl {
        void inc_gain (gain_t);
 
 protected:
+       void post_add_master (boost::shared_ptr<AutomationControl>);
        bool get_masters_curve_locked (framepos_t, framepos_t, float*, framecnt_t) const;
 };
 
index 4a3c990147dbe5117a9028ed11dd2810aa5eb068..5057ef407090174752696285842565d08ce1fae1 100644 (file)
@@ -99,9 +99,9 @@ protected:
 
                double val_ctrl () const { return _val_ctrl; }
                double val_master () const { return _val_master; }
-               double val_master_inv () const { return _val_master == 0 ? 1.0 : 1.0 / _val_master; }
 
-               double master_ratio () const { return _val_master == 0 ? master()->get_value() : master()->get_value() / _val_master; }
+               double val_master_inv () const { return _val_master == 0 ? 0 : 1.0 / _val_master; }
+               double master_ratio () const { return _val_master == 0 ? 0 : master()->get_value() / _val_master; }
 
                int set_state (XMLNode const&, int);
 
index ee356b017c3169c235b70e497325dc0b442b5bbf..7b0f4e404c0d0c93d5d09e58a685b1858eef0d29 100644 (file)
@@ -102,6 +102,15 @@ GainControl::inc_gain (gain_t factor)
        }
 }
 
+void
+GainControl::post_add_master (boost::shared_ptr<AutomationControl> m)
+{
+       if (m->get_value() == 0) {
+               /* master is at -inf, which forces this ctrl to -inf on assignment */
+               Changed (false, Controllable::NoGroup); /* EMIT SIGNAL */
+       }
+}
+
 bool
 GainControl::get_masters_curve_locked (framepos_t start, framepos_t end, float* vec, framecnt_t veclen) const
 {
index 46b86c7cf5068310f74b0c036e952ed12f060e74..cb88d36fe9c55b023ce9c0e5f5a98b67359f05c6 100644 (file)
@@ -150,9 +150,7 @@ SlavableAutomationControl::masters_curve_multiply (framepos_t start, framepos_t
                        = boost::dynamic_pointer_cast<SlavableAutomationControl>(mr->second.master());
                assert (sc);
                rv |= sc->masters_curve_multiply (start, end, vec, veclen);
-               if (mr->second.val_master () != 0) {
-                       apply_gain_to_buffer (vec, veclen, 1.f / mr->second.val_master ());
-               }
+               apply_gain_to_buffer (vec, veclen, mr->second.val_master_inv ());
        }
        return rv;
 }
@@ -166,7 +164,7 @@ SlavableAutomationControl::reduce_by_masters_locked (double value, bool ignore_a
                        /* need to scale given value by current master's scaling */
                        const double masters_value = get_masters_value_locked();
                        if (masters_value == 0.0) {
-                               value = 0.0; // XXX 1.0, see master_ratio(), val_master_inv()
+                               value = 0.0;
                        } else {
                                value /= masters_value;
                                value = std::max (lower(), std::min(upper(), value));