Mackie Control: Don't show hidden routes.
[ardour.git] / libs / surfaces / mackie / strip.cc
index d3b366539d26379bf67b8bf8a8c352b5bf079720..fcb544a92ebd50a352a1198a28f5b8b868f84362 100644 (file)
@@ -303,6 +303,10 @@ Strip::notify_all()
                zero ();
                return;
        }
+       // The active V-pot control may not be active for this strip
+       // But if we zero it in the controls function it may erase
+       // the one we do want
+       _surface->write (_vpot->zero());
 
        notify_solo_changed ();
        notify_mute_changed ();
@@ -400,7 +404,6 @@ Strip::notify_trim_changed (bool force_update)
        if (_route) {
 
                if (!_route->trim() || !route()->trim()->active()) {
-                       _surface->write (_vpot->zero());
                        return;
                }
                Control* control = 0;
@@ -437,7 +440,6 @@ Strip::notify_phase_changed (bool force_update)
 {
        if (_route) {
                if (!_route->phase_invert().size()) {
-                       _surface->write (_vpot->zero());
                        return;
                }
 
@@ -470,7 +472,6 @@ Strip::notify_processor_changed (bool force_update)
        if (_route) {
                boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
                if (!p) {
-                       _surface->write (_vpot->zero());
                        return;
                }
 
@@ -522,11 +523,16 @@ Strip::show_route_name ()
                return;
        }
 
+       string fullname = string();
        if (!_route) {
-               return;
+               // make sure first three strips get cleared of view mode
+               if (_index > 2) {
+                       return;
+               }
+       } else {
+               fullname = _route->name();
        }
        string line1;
-       string fullname = _route->name();
 
        if (fullname.length() <= 6) {
                line1 = fullname;
@@ -651,7 +657,6 @@ Strip::notify_panner_azi_changed (bool force_update)
        boost::shared_ptr<AutomationControl> pan_control = _route->pan_azimuth_control ();
 
        if (!pan_control) {
-               _surface->write (_vpot->zero());
                return;
        }
 
@@ -697,7 +702,6 @@ Strip::notify_panner_width_changed (bool force_update)
        boost::shared_ptr<AutomationControl> pan_control = _route->pan_width_control ();
 
        if (!pan_control) {
-               _surface->write (_vpot->zero());
                return;
        }
 
@@ -752,7 +756,7 @@ Strip::select_event (Button&, ButtonState bs)
                        /* reset to default */
                        boost::shared_ptr<AutomationControl> ac = _fader->control ();
                        if (ac) {
-                               ac->set_value (ac->normal());
+                               ac->set_value (ac->normal(), Controllable::NoGroup);
                        }
                        return;
                }
@@ -785,7 +789,7 @@ Strip::vselect_event (Button&, ButtonState bs)
 
                if (control->toggled()) {
                        if (control->toggled()) {
-                               control->set_value (!control->get_value());
+                               control->set_value (!control->get_value(), Controllable::NoGroup);
                        }
                }
 
@@ -803,7 +807,7 @@ Strip::vselect_event (Button&, ButtonState bs)
                        if (ac) {
 
                                /* reset to default/normal value */
-                               ac->set_value (ac->normal());
+                               ac->set_value (ac->normal(), Controllable::NoGroup);
                        }
 
                }  else {
@@ -826,7 +830,7 @@ Strip::fader_touch_event (Button&, ButtonState bs)
 
                if (_surface->mcp().main_modifier_state() & MackieControlProtocol::MODIFIER_SHIFT) {
                        if (ac) {
-                               ac->set_value (ac->normal());
+                               ac->set_value (ac->normal(), Controllable::NoGroup);
                        }
                } else {
 
@@ -903,7 +907,7 @@ Strip::handle_button (Button& button, ButtonState bs)
                                /* apply change */
 
                                for (MackieControlProtocol::ControlList::iterator c = controls.begin(); c != controls.end(); ++c) {
-                                       (*c)->set_value (new_value);
+                                       (*c)->set_value (new_value, Controllable::NoGroup);
                                }
 
                        } else {
@@ -1092,9 +1096,16 @@ Strip::periodic (ARDOUR::microseconds_t now)
 {
        bool reshow_vpot_mode = false;
        bool reshow_name = false;
+       bool good_strip = true;
 
        if (!_route) {
-               return;
+               // view mode may cover as many as 3 strips
+               // needs to be cleared when there are less than 3 routes
+               if (_index > 2) {
+                       return;
+               } else {
+                       good_strip = false;
+               }
        }
 
        if (_block_screen_redisplay_until >= now) {
@@ -1109,7 +1120,7 @@ Strip::periodic (ARDOUR::microseconds_t now)
                /* timeout reached, reset */
 
                _block_screen_redisplay_until = 0;
-               reshow_vpot_mode = true;
+               reshow_vpot_mode = (true && good_strip);
                reshow_name = true;
        }
 
@@ -1120,7 +1131,7 @@ Strip::periodic (ARDOUR::microseconds_t now)
                /* timeout reached, reset */
 
                _block_vpot_mode_redisplay_until = 0;
-               reshow_vpot_mode = true;
+               reshow_vpot_mode = (true && good_strip);
        }
 
        if (reshow_name) {
@@ -1129,14 +1140,16 @@ Strip::periodic (ARDOUR::microseconds_t now)
 
        if (reshow_vpot_mode) {
                return_to_vpot_mode_display ();
-       } else {
+       } else if (good_strip) {
                /* no point doing this if we just switched back to vpot mode
                   display */
                update_automation ();
        }
 
   meters:
-       update_meter ();
+       if (good_strip) {
+               update_meter ();
+       }
 }
 
 void
@@ -1475,8 +1488,16 @@ Strip::next_pot_mode ()
                        return;
                }
                p = _route->nth_send (_current_send + 1);
-               if (p && p->name() != "Monitor 1") {
+               if (p) {
                        _current_send++;
+                       if (p->name() == "Monitor 1") { // skip monitor
+                               p = _route->nth_send (_current_send + 1);
+                               if (p) {
+                                       _current_send++;
+                               } else {
+                                       _current_send = 0;
+                               }
+                       }
                } else {
                        _current_send = 0;
                }
@@ -1524,79 +1545,79 @@ Strip::setup_dyn_vpot (boost::shared_ptr<Route> r)
        }
 
        boost::shared_ptr<AutomationControl> tc = r->comp_threshold_controllable ();
-        boost::shared_ptr<AutomationControl> sc = r->comp_speed_controllable ();
-        boost::shared_ptr<AutomationControl> mc = r->comp_mode_controllable ();
-        boost::shared_ptr<AutomationControl> kc = r->comp_makeup_controllable ();
-        boost::shared_ptr<AutomationControl> rc = r->comp_redux_controllable ();
-        boost::shared_ptr<AutomationControl> ec = r->comp_enable_controllable ();
-
-        uint32_t pos = _surface->mcp().global_index (*this);
-
-        /* we will control the pos-th available parameter, from the list in the
-         * order shown above.
-         */
-
-        vector<boost::shared_ptr<AutomationControl> > available;
-        vector<AutomationType> params;
-
-        if (tc) { available.push_back (tc); params.push_back (CompThreshold); }
-        if (sc) { available.push_back (sc); params.push_back (CompSpeed); }
-        if (mc) { available.push_back (mc); params.push_back (CompMode); }
-        if (kc) { available.push_back (kc); params.push_back (CompMakeup); }
-        if (rc) { available.push_back (rc); params.push_back (CompRedux); }
-        if (ec) { available.push_back (ec); params.push_back (CompEnable); }
-
-        if (pos >= available.size()) {
-               /* this knob is not needed to control the available parameters */
-               _vpot->set_control (boost::shared_ptr<AutomationControl>());
-               _surface->write (display (0, string()));
-               _surface->write (display (1, string()));
-               return;
-        }
-
-        boost::shared_ptr<AutomationControl> pc;
-        AutomationType param;
-
-        pc = available[pos];
-        param = params[pos];
-
-        pc->Changed.connect (subview_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_dyn_change, this, param, false, true), ui_context());
-        _vpot->set_control (pc);
-
-        string pot_id;
-
-        switch (param) {
-        case CompThreshold:
-               pot_id = "Thresh";
-               break;
-        case CompSpeed:
-               if (mc) {
-                       pot_id = r->comp_speed_name (mc->get_value());
-               } else {
-                       pot_id = "Speed";
-               }
-               break;
-        case CompMode:
-               pot_id = "Mode";
-               break;
-        case CompMakeup:
-               pot_id = "Makeup";
-               break;
-        case CompRedux:
-               pot_id = "Redux";
-               break;
-        case CompEnable:
-               pot_id = "on/off";
-               break;
-        default:
-               break;
-        }
-
-        if (!pot_id.empty()) {
-               _surface->write (display (0, pot_id));
-        }
-
-        notify_dyn_change (param, true, false);
+       boost::shared_ptr<AutomationControl> sc = r->comp_speed_controllable ();
+       boost::shared_ptr<AutomationControl> mc = r->comp_mode_controllable ();
+       boost::shared_ptr<AutomationControl> kc = r->comp_makeup_controllable ();
+       boost::shared_ptr<AutomationControl> rc = r->comp_redux_controllable ();
+       boost::shared_ptr<AutomationControl> ec = r->comp_enable_controllable ();
+
+       uint32_t pos = _surface->mcp().global_index (*this);
+
+       /* we will control the pos-th available parameter, from the list in the
+        * order shown above.
+        */
+
+       vector<boost::shared_ptr<AutomationControl> > available;
+       vector<AutomationType> params;
+
+       if (tc) { available.push_back (tc); params.push_back (CompThreshold); }
+       if (sc) { available.push_back (sc); params.push_back (CompSpeed); }
+       if (mc) { available.push_back (mc); params.push_back (CompMode); }
+       if (kc) { available.push_back (kc); params.push_back (CompMakeup); }
+       if (rc) { available.push_back (rc); params.push_back (CompRedux); }
+       if (ec) { available.push_back (ec); params.push_back (CompEnable); }
+
+       if (pos >= available.size()) {
+               /* this knob is not needed to control the available parameters */
+               _vpot->set_control (boost::shared_ptr<AutomationControl>());
+               _surface->write (display (0, string()));
+               _surface->write (display (1, string()));
+               return;
+       }
+
+       boost::shared_ptr<AutomationControl> pc;
+       AutomationType param;
+
+       pc = available[pos];
+       param = params[pos];
+
+       pc->Changed.connect (subview_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_dyn_change, this, param, false, true), ui_context());
+       _vpot->set_control (pc);
+
+       string pot_id;
+
+       switch (param) {
+       case CompThreshold:
+               pot_id = "Thresh";
+               break;
+       case CompSpeed:
+               if (mc) {
+                       pot_id = r->comp_speed_name (mc->get_value());
+               } else {
+                       pot_id = "Speed";
+               }
+               break;
+       case CompMode:
+               pot_id = "Mode";
+               break;
+       case CompMakeup:
+               pot_id = "Makeup";
+               break;
+       case CompRedux:
+               pot_id = "Redux";
+               break;
+       case CompEnable:
+               pot_id = "on/off";
+               break;
+       default:
+               break;
+       }
+
+       if (!pot_id.empty()) {
+               _surface->write (display (0, pot_id));
+       }
+
+       notify_dyn_change (param, true, false);
 }
 
 void
@@ -1765,7 +1786,7 @@ Strip::set_vpot_parameter (AutomationType p)
                                _pan_mode = PanAzimuthAutomation;
                                if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
                                        /* gain to vpot, pan azi to fader */
-                                       _vpot->set_control (_route->group_gain_control());
+                                       _vpot->set_control (_route->gain_control());
                                        vpot_parameter = GainAutomation;
                                        control_by_parameter[GainAutomation] = _vpot;
                                        _fader->set_control (pan_control);
@@ -1777,7 +1798,7 @@ Strip::set_vpot_parameter (AutomationType p)
                        } else {
                                /* gain to fader, pan azi to vpot */
                                vpot_parameter = PanAzimuthAutomation;
-                               _fader->set_control (_route->group_gain_control());
+                               _fader->set_control (_route->gain_control());
                                control_by_parameter[GainAutomation] = _fader;
                                _vpot->set_control (pan_control);
                                control_by_parameter[PanAzimuthAutomation] = _vpot;
@@ -1794,7 +1815,7 @@ Strip::set_vpot_parameter (AutomationType p)
                                _pan_mode = PanWidthAutomation;
                                if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
                                        /* gain to vpot, pan width to fader */
-                                       _vpot->set_control (_route->group_gain_control());
+                                       _vpot->set_control (_route->gain_control());
                                        vpot_parameter = GainAutomation;
                                        control_by_parameter[GainAutomation] = _vpot;
                                        _fader->set_control (pan_control);
@@ -1806,7 +1827,7 @@ Strip::set_vpot_parameter (AutomationType p)
                        } else {
                                /* gain to fader, pan width to vpot */
                                vpot_parameter = PanWidthAutomation;
-                               _fader->set_control (_route->group_gain_control());
+                               _fader->set_control (_route->gain_control());
                                control_by_parameter[GainAutomation] = _fader;
                                _vpot->set_control (pan_control);
                                control_by_parameter[PanWidthAutomation] = _vpot;
@@ -1828,7 +1849,7 @@ Strip::set_vpot_parameter (AutomationType p)
                vpot_parameter = TrimAutomation;
                if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
                        /* gain to vpot, trim to fader */
-                       _vpot->set_control (_route->group_gain_control());
+                       _vpot->set_control (_route->gain_control());
                        control_by_parameter[GainAutomation] = _vpot;
                        if (_route->trim() && route()->trim()->active()) {
                                _fader->set_control (_route->trim_control());
@@ -1839,7 +1860,7 @@ Strip::set_vpot_parameter (AutomationType p)
                        }
                } else {
                        /* gain to fader, trim to vpot */
-                       _fader->set_control (_route->group_gain_control());
+                       _fader->set_control (_route->gain_control());
                        control_by_parameter[GainAutomation] = _fader;
                        if (_route->trim() && route()->trim()->active()) {
                                _vpot->set_control (_route->trim_control());
@@ -1855,7 +1876,7 @@ Strip::set_vpot_parameter (AutomationType p)
                vpot_parameter = PhaseAutomation;
                if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
                        /* gain to vpot, phase to fader */
-                       _vpot->set_control (_route->group_gain_control());
+                       _vpot->set_control (_route->gain_control());
                        control_by_parameter[GainAutomation] = _vpot;
                        if (_route->phase_invert().size()) {
                                _fader->set_control (_route->phase_control());
@@ -1866,7 +1887,7 @@ Strip::set_vpot_parameter (AutomationType p)
                        }
                } else {
                        /* gain to fader, phase to vpot */
-                       _fader->set_control (_route->group_gain_control());
+                       _fader->set_control (_route->gain_control());
                        control_by_parameter[GainAutomation] = _fader;
                        if (_route->phase_invert().size()) {
                                _vpot->set_control (_route->phase_control());
@@ -1881,7 +1902,7 @@ Strip::set_vpot_parameter (AutomationType p)
                if (!Profile->get_mixbus()) {
                        if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
                                // gain to vpot, send to fader
-                               _vpot->set_control (_route->group_gain_control());
+                               _vpot->set_control (_route->gain_control());
                                control_by_parameter[GainAutomation] = _vpot;
                                // test for send to control
                                boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
@@ -1899,7 +1920,7 @@ Strip::set_vpot_parameter (AutomationType p)
                                }
                        } else {
                                // gain to fader, send to vpot
-                               _fader->set_control (_route->group_gain_control());
+                               _fader->set_control (_route->gain_control());
                                control_by_parameter[GainAutomation] = _fader;
                                boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
                                if (p && p->name() != "Monitor 1") {
@@ -1912,7 +1933,7 @@ Strip::set_vpot_parameter (AutomationType p)
                                        control_by_parameter[SendAutomation] = _vpot;
                                } else {
                                        // gain to fader, send to vpot
-                                       _fader->set_control (_route->group_gain_control());
+                                       _fader->set_control (_route->gain_control());
                                        control_by_parameter[GainAutomation] = _fader;
                                        boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
                                        if (p && p->name() != "Monitor 1") {