Fix gain inc/dec with multiple-selection spanning groups
authorRobin Gareus <robin@gareus.org>
Sat, 8 Jul 2017 13:43:32 +0000 (15:43 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 8 Jul 2017 13:43:32 +0000 (15:43 +0200)
When tracks in a gain-sharing group are selected, stepping gain
up/down affected the tracks N times:
   for-each selected track inc/dec gain w/grouping.

When a mix of grouped and un-grouped tracks is selected, this lead to
inconsistent gain changes.

The new approach expands the groups first. Ignoring groups is not correct
either for single selection.

gtk2_ardour/mixer_ui.cc
gtk2_ardour/mixer_ui.h

index e8c431041a072454bef96672788e3ebe3d193a09..c775b9b2b9b4dc8b16d4bee92d6a9d276370ab92 100644 (file)
@@ -2983,29 +2983,44 @@ Mixer_UI::rec_enable_action ()
        control_action (&Stripable::rec_enable_control);
 }
 
-void
-Mixer_UI::step_gain_up_action ()
+AutomationControlSet
+Mixer_UI::selected_gaincontrols ()
 {
        set_axis_targets_for_operation ();
-
+       AutomationControlSet rv;
        BOOST_FOREACH(AxisView* r, _axis_targets) {
                MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
                if (ms) {
-                       ms->step_gain_up ();
+                       boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
+                       ControlList cl (ac->grouped_controls());
+                       for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
+                               rv.insert (*c);
+                       }
+                       rv.insert (ac);
                }
        }
+       return rv;
 }
 
 void
-Mixer_UI::step_gain_down_action ()
+Mixer_UI::step_gain_up_action ()
 {
-       set_axis_targets_for_operation ();
+       AutomationControlSet acs = selected_gaincontrols ();
+       for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
+               boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
+               assert (ac);
+               ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
+       }
+}
 
-       BOOST_FOREACH(AxisView* r, _axis_targets) {
-               MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
-               if (ms) {
-                       ms->step_gain_down ();
-               }
+void
+Mixer_UI::step_gain_down_action ()
+{
+       AutomationControlSet acs = selected_gaincontrols ();
+       for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
+               boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
+               assert (ac);
+               ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
        }
 }
 
index 27c8f0bce6ec592b1b38aeb027ae08cf6e5611ab..24e457cf72019b66ce8601fab71af89a7939c47f 100644 (file)
@@ -129,6 +129,7 @@ public:
 
 protected:
        void set_axis_targets_for_operation ();
+       ARDOUR::AutomationControlSet selected_gaincontrols ();
 
 private:
        Mixer_UI ();