fix solo control to use VCA logic as worked out for mute
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 19 Apr 2016 19:42:50 +0000 (15:42 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 31 May 2016 19:30:41 +0000 (15:30 -0400)
libs/ardour/ardour/solo_control.h
libs/ardour/solo_control.cc

index aefd6abb793bc5f0df129aa7d66a360465fbdabc..78ce7c56be5c25c72c568177f0559c0573d5fd75 100644 (file)
@@ -61,7 +61,7 @@ class LIBARDOUR_API SoloControl : public SlavableAutomationControl
         */
 
        bool soloed_by_others () const {
-               return _soloed_by_others_downstream || _soloed_by_others_downstream;
+               return _soloed_by_others_downstream || _soloed_by_others_downstream || get_masters_value ();
        }
        uint32_t soloed_by_others_upstream () const {
                return _soloed_by_others_upstream;
@@ -81,6 +81,9 @@ class LIBARDOUR_API SoloControl : public SlavableAutomationControl
 
   protected:
        void actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override);
+       void master_changed (bool from_self, GroupControlDisposition, boost::shared_ptr<AutomationControl> m);
+       void pre_remove_master (boost::shared_ptr<AutomationControl>);
+       void post_add_master (boost::shared_ptr<AutomationControl>);
 
   private:
        Soloable&      _soloable;
index 76e7ca536a007ac20b0b57315abea281b7fef27b..b9346406a5e4a63655d0c9b5458952e4ed818cc9 100644 (file)
@@ -171,7 +171,7 @@ SoloControl::get_value () const
                return AutomationControl::get_value();
        }
 
-       return self_soloed() ? 1.0 : 0.0;
+       return soloed() ? 1.0 : 0.0;
 }
 
 void
@@ -234,3 +234,62 @@ SoloControl::get_state ()
 
        return node;
 }
+
+void
+SoloControl::master_changed (bool /*from self*/, GroupControlDisposition, boost::shared_ptr<AutomationControl> m)
+{
+       bool send_signal = false;
+       const double changed_master_value = m->get_value();
+
+       if (changed_master_value) {
+               /* this master is now enabled */
+               if (!self_soloed() && get_boolean_masters() == 0) {
+                       send_signal = true;
+               }
+       } else {
+               if (!self_soloed() && get_boolean_masters() == 1) {
+                       send_signal = true;
+               }
+       }
+
+       update_boolean_masters_records (m);
+
+       if (send_signal) {
+               Changed (false, Controllable::NoGroup);
+       }
+}
+
+void
+SoloControl::post_add_master (boost::shared_ptr<AutomationControl> m)
+{
+       if (m->get_value()) {
+
+               /* boolean masters records are not updated until AFTER
+                * ::post_add_master() is called, so we can use them to check
+                * on whether any master was already enabled before the new
+                * one was added.
+                */
+
+               if (!self_soloed() && !get_boolean_masters()) {
+                       Changed (false, Controllable::NoGroup);
+               }
+       }
+}
+
+void
+SoloControl::pre_remove_master (boost::shared_ptr<AutomationControl> m)
+{
+       if (!m) {
+               /* null control ptr means we're removing all masters. Nothing
+                * to do. Changed will be emitted in
+                * SlavableAutomationControl::clear_masters()
+                */
+               return;
+       }
+
+       if (m->get_value()) {
+               if (!self_soloed() && (get_boolean_masters() == 1)) {
+                       Changed (false, Controllable::NoGroup);
+               }
+       }
+}