remove Route::listening_via_monitor()
[ardour.git] / libs / surfaces / mackie / strip.cc
index a2e7b9f9ac96b305c1b750eab481f110cbdf9ac0..9c3fc21bdacaa16089f26a4f5e12e100ff78b4b1 100644 (file)
 #include "ardour/debug.h"
 #include "ardour/midi_ui.h"
 #include "ardour/meter.h"
+#include "ardour/monitor_control.h"
 #include "ardour/plugin_insert.h"
 #include "ardour/pannable.h"
 #include "ardour/panner.h"
 #include "ardour/panner_shell.h"
+#include "ardour/phase_control.h"
 #include "ardour/rc_configuration.h"
 #include "ardour/route.h"
 #include "ardour/session.h"
 #include "ardour/send.h"
+#include "ardour/solo_isolate_control.h"
 #include "ardour/track.h"
 #include "ardour/midi_track.h"
 #include "ardour/user_bundle.h"
@@ -185,6 +188,7 @@ Strip::set_route (boost::shared_ptr<Route> r, bool /*with_messages*/)
        reset_saved_values ();
 
        if (!r) {
+               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface %1 Strip %2 mapped to null route\n", _surface->number(), _index));
                zero ();
                return;
        }
@@ -195,9 +199,7 @@ Strip::set_route (boost::shared_ptr<Route> r, bool /*with_messages*/)
        _solo->set_control (_route->solo_control());
        _mute->set_control (_route->mute_control());
 
-       _route->solo_changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_solo_changed, this), ui_context());
-       _route->listen_changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_solo_changed, this), ui_context());
-
+       _route->solo_control()->Changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_solo_changed, this), ui_context());
        _route->mute_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_mute_changed, this), ui_context());
 
        boost::shared_ptr<AutomationControl> pan_control = _route->pan_azimuth_control();
@@ -283,7 +285,7 @@ void
 Strip::notify_solo_changed ()
 {
        if (_route && _solo) {
-               _surface->write (_solo->set_state ((_route->soloed() || _route->listening_via_monitor()) ? on : off));
+               _surface->write (_solo->set_state (_route->soloed() ? on : off));
        }
 }
 
@@ -303,7 +305,10 @@ void
 Strip::notify_record_enable_changed ()
 {
        if (_route && _recenable)  {
-               _surface->write (_recenable->set_state (_route->record_enabled() ? on : off));
+               boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<Track> (_route);
+               if (trk) {
+                       _surface->write (_recenable->set_state (trk->rec_enable_control()->get_value() ? on : off));
+               }
        }
 }
 
@@ -351,18 +356,15 @@ Strip::notify_gain_changed (bool force_update)
 
        if (force_update || normalized_position != _last_gain_position_written) {
 
-               if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
-                       if (!control->in_use()) {
+               if (!control->in_use()) {
+                       if (control == _vpot) {
                                _surface->write (_vpot->set (normalized_position, true, Pot::wrap));
-                       }
-                       do_parameter_display (GainAutomation, gain_coefficient);
-               } else {
-                       if (!control->in_use()) {
+                       } else {
                                _surface->write (_fader->set_position (normalized_position));
                        }
-                       do_parameter_display (GainAutomation, gain_coefficient);
                }
 
+               do_parameter_display (GainAutomation, gain_coefficient);
                _last_gain_position_written = normalized_position;
        }
 }
@@ -394,22 +396,16 @@ Strip::show_route_name ()
 
        string fullname = string();
        if (!_route) {
-               // make sure first three strips get cleared of view mode
-               if (_index > 2) {
-                       return;
-               }
+               fullname = string();
        } else {
                fullname = _route->name();
        }
-       string line1;
 
        if (fullname.length() <= 6) {
-               line1 = fullname;
+               pending_display[0] = fullname;
        } else {
-               line1 = PBD::short_version (fullname, 6);
+               pending_display[0] = PBD::short_version (fullname, 6);
        }
-
-       pending_display[0] = line1;
 }
 
 void
@@ -435,8 +431,11 @@ Strip::notify_send_level_change (AutomationType type, uint32_t send_num, bool fo
        if (control) {
                float val = control->get_value();
                do_parameter_display (type, val);
-               /* update pot/encoder */
-               _surface->write (_vpot->set (control->internal_to_interface (val), true, Pot::wrap));
+
+               if (_vpot->control() == control) {
+                       /* update pot/encoder */
+                       _surface->write (_vpot->set (control->internal_to_interface (val), true, Pot::wrap));
+               }
        }
 }
 
@@ -456,7 +455,6 @@ Strip::notify_trackview_change (AutomationType type, uint32_t send_num, bool for
        }
 
        boost::shared_ptr<AutomationControl> control;
-
        boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (r);
 
        switch (type) {
@@ -483,11 +481,13 @@ Strip::notify_trackview_change (AutomationType type, uint32_t send_num, bool for
 
        if (control) {
                float val = control->get_value();
-               if (control->desc().enumeration || control->desc().integer_step) {
-                       do_parameter_display (type, val);
-               } else {
-                       do_parameter_display (type, control->internal_to_interface (val));
-               }
+
+               /* Note: all of the displayed controllables require the display
+                * of their *actual* ("internal") value, not the version mapped
+                * into the normalized 0..1.0 ("interface") range.
+                */
+
+               do_parameter_display (type, val);
                /* update pot/encoder */
                _surface->write (_vpot->set (control->internal_to_interface (val), true, Pot::wrap));
        }
@@ -679,15 +679,6 @@ Strip::select_event (Button&, ButtonState bs)
                        return;
                }
 
-               if (ms & MackieControlProtocol::MODIFIER_SHIFT) {
-                       /* reset to default */
-                       boost::shared_ptr<AutomationControl> ac = _fader->control ();
-                       if (ac) {
-                               ac->set_value (ac->normal(), Controllable::NoGroup);
-                       }
-                       return;
-               }
-
                DEBUG_TRACE (DEBUG::MackieControl, "add select button on press\n");
                _surface->mcp().add_down_select_button (_surface->number(), _index);
                _surface->mcp().select_range ();
@@ -926,7 +917,6 @@ Strip::do_parameter_display (AutomationType type, float val)
 
        switch (type) {
        case GainAutomation:
-       case BusSendLevel:
                if (val == 0.0) {
                        pending_display[1] = " -inf ";
                } else {
@@ -937,6 +927,23 @@ Strip::do_parameter_display (AutomationType type, float val)
                }
                break;
 
+       case BusSendLevel:
+               if (Profile->get_mixbus()) {  //Mixbus sends are already stored in dB
+                       snprintf (buf, sizeof (buf), "%2.1f", val);
+                       pending_display[1] = buf;
+                       screen_hold = true;
+               } else {
+                       if (val == 0.0) {
+                               pending_display[1] = " -inf ";
+                       } else {
+                               float dB = accurate_coefficient_to_dB (val);
+                               snprintf (buf, sizeof (buf), "%6.1f", dB);
+                               pending_display[1] = buf;
+                               screen_hold = true;
+                       }
+               }
+               break;
+
        case PanAzimuthAutomation:
                if (Profile->get_mixbus()) {
                        snprintf (buf, sizeof (buf), "%2.1f", val);
@@ -1132,14 +1139,14 @@ Strip::handle_pot (Pot& pot, float delta)
 
        } else {
 
-               double p = ac->get_value();
+               double p = ac->get_interface();
 
                p += delta;
 
-               p = max (ac->lower(), p);
-               p = min (ac->upper(), p);
+               p = max (0.0, p);
+               p = min (1.0, p);
 
-               ac->set_value (p, gcd);
+               ac->set_value ( ac->interface_to_internal(p), gcd);
        }
 }
 
@@ -1224,7 +1231,7 @@ Strip::update_meter ()
        }
 
        if (_meter && _transport_is_rolling && _metering_active) {
-               float dB = const_cast<PeakMeter&> (_route->peak_meter()).meter_level (0, MeterMCP);
+               float dB = _route->peak_meter()->meter_level (0, MeterMCP);
                _meter->send_update (*_surface, dB);
                return;
        }
@@ -1367,6 +1374,15 @@ Strip::flip_mode_changed ()
                        do_parameter_display (BusSendLevel, fader_control->get_value());
                }
 
+               /* update fader */
+
+               _surface->write (_fader->set_position (pot_control->internal_to_interface (pot_control->get_value ())));
+
+               /* update pot */
+
+               _surface->write (_vpot->set (fader_control->internal_to_interface (fader_control->get_value()), true, Pot::wrap));
+
+
        } else {
                /* do nothing */
        }
@@ -1463,6 +1479,10 @@ Strip::subview_mode_changed ()
                set_vpot_parameter (_pan_mode);
                /* need to show strip name again */
                show_route_name ();
+               if (!_route) {
+                       _surface->write (_vpot->set (0, true, Pot::wrap));
+                       _surface->write (_fader->set_position (0.0));
+               }
                notify_metering_state_changed ();
                eq_band = -1;
                break;
@@ -1743,7 +1763,7 @@ Strip::setup_sends_vpot (boost::shared_ptr<Route> r)
        pc->Changed.connect (subview_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_send_level_change, this, BusSendLevel, global_pos, false), ui_context());
        _vpot->set_control (pc);
 
-       pending_display[0] = r->send_name (global_pos);
+       pending_display[0] = PBD::short_version (r->send_name (global_pos), 6);
 
        notify_send_level_change (BusSendLevel, global_pos, true);
 }