+ if (_meter && _transport_is_rolling && _metering_active) {
+ float dB = const_cast<PeakMeter&> (_route->peak_meter()).meter_level (0, MeterMCP);
+ _meter->send_update (*_surface, dB);
+ }
+}
+
+void
+Strip::zero ()
+{
+ for (Group::Controls::const_iterator it = _controls.begin(); it != _controls.end(); ++it) {
+ _surface->write ((*it)->zero ());
+ }
+
+ _surface->write (blank_display (0));
+ _surface->write (blank_display (1));
+}
+
+MidiByteArray
+Strip::blank_display (uint32_t line_number)
+{
+ return display (line_number, string());
+}
+
+MidiByteArray
+Strip::display (uint32_t line_number, const std::string& line)
+{
+ assert (line_number <= 1);
+
+ MidiByteArray retval;
+
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip_display index: %1, line %2 = %3\n", _index, line_number, line));
+
+ // sysex header
+ retval << _surface->sysex_hdr();
+
+ // code for display
+ retval << 0x12;
+ // offset (0 to 0x37 first line, 0x38 to 0x6f for second line)
+ retval << (_index * 7 + (line_number * 0x38));
+
+ // ascii data to display. @param line is UTF-8
+ string ascii = Glib::convert_with_fallback (line, "UTF-8", "ISO-8859-1", "_");
+ string::size_type len = ascii.length();
+ if (len > 6) {
+ ascii = ascii.substr (0, 6);
+ len = 6;
+ }
+ retval << ascii;
+ // pad with " " out to 6 chars
+ for (int i = len; i < 6; ++i) {
+ retval << ' ';
+ }
+
+ // column spacer, unless it's the right-hand column
+ if (_index < 7) {
+ retval << ' ';
+ }
+
+ // sysex trailer
+ retval << MIDI::eox;
+
+ return retval;
+}
+
+void
+Strip::lock_controls ()
+{
+ _controls_locked = true;
+}
+
+void
+Strip::unlock_controls ()
+{
+ _controls_locked = false;
+}
+
+void
+Strip::gui_selection_changed (const ARDOUR::StrongRouteNotificationList& rl)
+{
+ for (ARDOUR::StrongRouteNotificationList::const_iterator i = rl.begin(); i != rl.end(); ++i) {
+ if ((*i) == _route) {
+ _surface->write (_select->set_state (on));
+ return;
+ }
+ }
+
+ _surface->write (_select->set_state (off));
+}
+
+string
+Strip::vpot_mode_string () const
+{
+ boost::shared_ptr<AutomationControl> ac = _vpot->control();
+
+ if (!ac) {
+ return string();
+ }
+
+ switch (ac->parameter().type()) {
+ case GainAutomation:
+ return "Fader";
+ case TrimAutomation:
+ return "Trim";
+ case PhaseAutomation:
+ return string_compose ("Phase%1", _route->phase_control()->channel() + 1);
+ case PanAzimuthAutomation:
+ return "Pan";
+ case PanWidthAutomation:
+ return "Width";
+ case PanElevationAutomation:
+ return "Elev";
+ case PanFrontBackAutomation:
+ return "F/Rear";
+ case PanLFEAutomation:
+ return "LFE";
+ }
+
+ return "???";
+}
+
+ void
+Strip::potmode_changed (bool notify)
+{
+ if (!_route) {
+ return;
+ }
+
+ // WIP
+ int pm = _surface->mcp().pot_mode();
+ switch (pm) {
+ case MackieControlProtocol::Pan:
+ // This needs to set current pan mode (azimuth or width... or whatever)
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Assign pot to Pan mode %1\n", enum_2_string (_pan_mode)));
+ set_vpot_parameter (_pan_mode);
+ break;
+ case MackieControlProtocol::Trim:
+ DEBUG_TRACE (DEBUG::MackieControl, "Assign pot to Trim mode.\n");
+ set_vpot_parameter (_trim_mode);
+ break;
+ case MackieControlProtocol::Send:
+ DEBUG_TRACE (DEBUG::MackieControl, "Assign pot to Send mode.\n");
+ set_vpot_parameter (SendAutomation);
+ break;
+ }
+
+ if (notify) {
+ notify_all ();
+ }
+}
+
+void
+Strip::block_screen_display_for (uint32_t msecs)
+{
+ _block_screen_redisplay_until = ARDOUR::get_microseconds() + (msecs * 1000);
+}
+
+void
+Strip::block_vpot_mode_display_for (uint32_t msecs)
+{
+ _block_vpot_mode_redisplay_until = ARDOUR::get_microseconds() + (msecs * 1000);
+}
+
+void
+Strip::return_to_vpot_mode_display ()
+{
+ /* returns the second line of the two-line per-strip display
+ back the mode where it shows what the VPot controls.
+ */
+
+ if (_route) {
+ _surface->write (display (1, vpot_mode_string()));
+ } else {
+ _surface->write (blank_display (1));
+ }
+}
+
+void
+Strip::next_pot_mode ()
+{
+ vector<Evoral::Parameter>::iterator i;
+
+ if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
+ /* do not change vpot mode while in flipped mode */
+ DEBUG_TRACE (DEBUG::MackieControl, "not stepping pot mode - in flip mode\n");
+ _surface->write (display (1, "Flip"));
+ block_vpot_mode_display_for (1000);
+ return;
+ }
+
+
+ boost::shared_ptr<AutomationControl> ac = _vpot->control();
+
+ if (!ac) {
+ return;
+ }
+ if (_surface->mcp().pot_mode() == MackieControlProtocol::Pan) {
+ if (possible_pot_parameters.empty() || (possible_pot_parameters.size() == 1 && possible_pot_parameters.front() == ac->parameter())) {
+ return;
+ }
+
+ for (i = possible_pot_parameters.begin(); i != possible_pot_parameters.end(); ++i) {
+ if ((*i) == ac->parameter()) {
+ break;
+ }
+ }
+
+ /* move to the next mode in the list, or back to the start (which will
+ also happen if the current mode is not in the current pot mode list)
+ */
+
+ if (i != possible_pot_parameters.end()) {
+ ++i;
+ }
+
+ if (i == possible_pot_parameters.end()) {
+ i = possible_pot_parameters.begin();
+ }
+ set_vpot_parameter (*i);
+ } else if (_surface->mcp().pot_mode() == MackieControlProtocol::Trim) {
+ if (possible_trim_parameters.empty() || (possible_trim_parameters.size() == 1 && possible_trim_parameters.front() == ac->parameter())) {
+ return;
+ }
+
+ for (i = possible_trim_parameters.begin(); i != possible_trim_parameters.end(); ++i) {
+ if ((*i) == ac->parameter()) {
+ break;
+ }
+ }
+ if ((*i).type() == PhaseAutomation && _route->phase_invert().size() > 1) {
+ // There are more than one channel of phase
+ if ((_route->phase_control()->channel() + 1) < _route->phase_invert().size()) {
+ _route->phase_control()->set_channel(_route->phase_control()->channel() + 1);
+ set_vpot_parameter (*i);
+ return;
+ } else {
+ _route->phase_control()->set_channel(0);
+ }
+ }
+ /* move to the next mode in the list, or back to the start (which will
+ also happen if the current mode is not in the current pot mode list)
+ */
+
+ if (i != possible_trim_parameters.end()) {
+ ++i;
+ }
+
+ if (i == possible_trim_parameters.end()) {
+ i = possible_trim_parameters.begin();
+ }
+ set_vpot_parameter (*i);
+ }
+
+}
+
+void
+Strip::set_vpot_parameter (Evoral::Parameter p)
+{
+ boost::shared_ptr<Pannable> pannable;
+
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch to vpot mode %1\n", p.type()));
+
+ reset_saved_values ();
+
+ /* unset any mapping between the vpot and any existing parameters */
+
+ for (ControlParameterMap::iterator i = control_by_parameter.begin(); i != control_by_parameter.end(); ++i) {
+
+ if (i != control_by_parameter.end() && i->second == _vpot) {
+ i->second = 0;
+ }
+ }
+
+ switch (p.type()) {
+ case PanAzimuthAutomation:
+ _pan_mode = PanAzimuthAutomation;
+ pannable = _route->pannable ();
+ if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
+ /* gain to vpot, pan azi to fader */
+ _vpot->set_control (_route->gain_control());
+ control_by_parameter[GainAutomation] = _vpot;
+ if (pannable) {
+ _fader->set_control (pannable->pan_azimuth_control);
+ control_by_parameter[PanAzimuthAutomation] = _fader;
+ } else {
+ _fader->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[PanAzimuthAutomation] = 0;
+ }
+ } else {
+ /* gain to fader, pan azi to vpot */
+ _fader->set_control (_route->gain_control());
+ control_by_parameter[GainAutomation] = _fader;
+ if (pannable) {
+ _vpot->set_control (pannable->pan_azimuth_control);
+ control_by_parameter[PanAzimuthAutomation] = _vpot;
+ } else {
+ _vpot->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[PanAzimuthAutomation] = 0;
+ }
+ }
+ break;
+ case PanWidthAutomation:
+ _pan_mode = PanWidthAutomation;
+ pannable = _route->pannable ();
+ if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
+ /* gain to vpot, pan width to fader */
+ _vpot->set_control (_route->gain_control());
+ control_by_parameter[GainAutomation] = _vpot;
+ if (pannable) {
+ _fader->set_control (pannable->pan_width_control);
+ control_by_parameter[PanWidthAutomation] = _fader;
+ } else {
+ _fader->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[PanWidthAutomation] = 0;
+ }
+ } else {
+ /* gain to fader, pan width to vpot */
+ _fader->set_control (_route->gain_control());
+ control_by_parameter[GainAutomation] = _fader;
+ if (pannable) {
+ _vpot->set_control (pannable->pan_width_control);
+ control_by_parameter[PanWidthAutomation] = _vpot;
+ } else {
+ _vpot->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[PanWidthAutomation] = 0;
+ }
+ }
+ break;
+ case PanElevationAutomation:
+ break;
+ case PanFrontBackAutomation:
+ break;
+ case PanLFEAutomation:
+ break;
+ case TrimAutomation:
+ _trim_mode = TrimAutomation;
+ if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
+ /* gain to vpot, trim to fader */
+ _vpot->set_control (_route->gain_control());
+ control_by_parameter[GainAutomation] = _vpot;
+ if (_route->trim() && route()->trim()->active()) {
+ _fader->set_control (_route->trim_control());
+ control_by_parameter[TrimAutomation] = _fader;
+ } else {
+ _fader->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[TrimAutomation] = 0;
+ }
+ } else {
+ /* gain to fader, trim to vpot */
+ _fader->set_control (_route->gain_control());
+ control_by_parameter[GainAutomation] = _fader;
+ if (_route->trim() && route()->trim()->active()) {
+ _vpot->set_control (_route->trim_control());
+ control_by_parameter[TrimAutomation] = _vpot;
+ } else {
+ _vpot->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[TrimAutomation] = 0;
+ }
+ }
+ break;
+ case PhaseAutomation:
+ _trim_mode = PhaseAutomation;
+ if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
+ /* gain to vpot, phase to fader */
+ _vpot->set_control (_route->gain_control());
+ control_by_parameter[GainAutomation] = _vpot;
+ if (_route->phase_invert().size()) {
+ _fader->set_control (_route->phase_control());
+ control_by_parameter[PhaseAutomation] = _fader;
+ } else {
+ _fader->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[PhaseAutomation] = 0;
+ }
+ } else {
+ /* gain to fader, phase to vpot */
+ _fader->set_control (_route->gain_control());
+ control_by_parameter[GainAutomation] = _fader;
+ if (_route->phase_invert().size()) {
+ _vpot->set_control (_route->phase_control());
+ control_by_parameter[PhaseAutomation] = _vpot;
+ } else {
+ _vpot->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[PhaseAutomation] = 0;
+ }
+ }
+ break;
+ case SendAutomation:
+ // deal with sends ... needs sends yet :)
+ if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
+ // gain to vpot, trim to fader
+ _vpot->set_control (_route->gain_control());
+ control_by_parameter[GainAutomation] = _vpot;
+ _fader->set_control (boost::shared_ptr<AutomationControl>());
+ } else {
+ // gain to fader, trim to vpot
+ _fader->set_control (_route->gain_control());
+ control_by_parameter[GainAutomation] = _fader;
+ _vpot->set_control (boost::shared_ptr<AutomationControl>());
+ }
+ break;
+ default:
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("vpot mode %1 not known.\n", p));
+ break;
+
+ }
+
+ _surface->write (display (1, vpot_mode_string()));
+}
+
+bool
+Strip::is_midi_track () const
+{
+ return boost::dynamic_pointer_cast<MidiTrack>(_route) != 0;
+}
+
+void
+Strip::reset_saved_values ()
+{
+ _last_pan_azi_position_written = -1.0;
+ _last_pan_width_position_written = -1.0;
+ _last_gain_position_written = -1.0;
+ _last_trim_position_written = -1.0;
+
+}
+
+void
+Strip::notify_metering_state_changed()
+{
+ if (!_route || !_meter) {
+ return;
+ }
+
+ bool transport_is_rolling = (_surface->mcp().get_transport_speed () != 0.0f);
+ bool metering_active = _surface->mcp().metering_active ();
+
+ if ((_transport_is_rolling == transport_is_rolling) && (_metering_active == metering_active)) {
+ return;
+ }
+
+ _meter->notify_metering_state_changed (*_surface, transport_is_rolling, metering_active);
+
+ if (!transport_is_rolling || !metering_active) {
+ notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::name));
+ notify_panner_azi_changed (true);
+ }
+
+ _transport_is_rolling = transport_is_rolling;
+ _metering_active = metering_active;