X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fmackie%2Fstrip.cc;h=4def2bc6ec15c3ac281ebd2cad1d0393e2694b00;hb=84d44eb5a3fd95f20f9c5e33ff8c05199dcccc38;hp=d355d13d6314b3ac51e52898ceb19ef2f54f4f12;hpb=03018aeefb3284d970dc9dc86f5acf6dfc2d694a;p=ardour.git diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index d355d13d63..4def2bc6ec 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -43,6 +43,7 @@ #include "ardour/session.h" #include "ardour/send.h" #include "ardour/track.h" +#include "ardour/midi_track.h" #include "ardour/user_bundle.h" #include "mackie_control_protocol.h" @@ -95,6 +96,7 @@ Strip::Strip (Surface& s, const std::string& name, int index, const map r, bool /*with_messages*/) control_by_parameter[PanLFEAutomation] = (Control*) 0; control_by_parameter[GainAutomation] = (Control*) 0; control_by_parameter[TrimAutomation] = (Control*) 0; + control_by_parameter[PhaseAutomation] = (Control*) 0; reset_saved_values (); @@ -197,19 +200,20 @@ Strip::set_route (boost::shared_ptr r, bool /*with_messages*/) _solo->set_control (_route->solo_control()); _mute->set_control (_route->mute_control()); - _pan_mode = PanAzimuthAutomation; - potmode_changed (true); - - _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->mute_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_mute_changed, this), ui_context()); - if (_route->trim()) { + if (_route->trim() && route()->trim()->active()) { _route->trim_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_trim_changed, this, false), ui_context()); } + if (_route->phase_invert().size()) { + _route->phase_invert_changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_phase_changed, this, false), ui_context()); + _route->phase_control()->set_channel(0); + } + boost::shared_ptr pannable = _route->pannable(); if (pannable && _route->panner()) { @@ -234,10 +238,6 @@ Strip::set_route (boost::shared_ptr r, bool /*with_messages*/) _route->active_changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_active_changed, this), ui_context()); _route->DropReferences.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_route_deleted, this), ui_context()); - /* Update */ - - notify_all (); - /* setup legal VPot modes for this route */ possible_pot_parameters.clear(); @@ -258,9 +258,29 @@ Strip::set_route (boost::shared_ptr r, bool /*with_messages*/) } } - if (_route->trim()) { + if (_route->trim() && route()->trim()->active()) { possible_pot_parameters.push_back (TrimAutomation); } + + possible_trim_parameters.clear(); + + if (_route->trim() && route()->trim()->active()) { + possible_trim_parameters.push_back (TrimAutomation); + _trim_mode = TrimAutomation; + } + + if (_route->phase_invert().size()) { + possible_trim_parameters.push_back (PhaseAutomation); + if (_trim_mode != TrimAutomation) { + _trim_mode = PhaseAutomation; + } + } + + /* Update */ + _pan_mode = PanAzimuthAutomation; + potmode_changed (false); + notify_all (); + } void @@ -279,6 +299,7 @@ Strip::notify_all() notify_panner_width_changed (); notify_record_enable_changed (); notify_trim_changed (); + notify_phase_changed (); } void @@ -364,11 +385,18 @@ Strip::notify_trim_changed (bool force_update) { if (_route) { - if (!_route->trim()) { + if (!_route->trim() || !route()->trim()->active()) { _surface->write (_vpot->zero()); return; } - Control* control = control_by_parameter[TrimAutomation]; + Control* control = 0; + ControlParameterMap::iterator i = control_by_parameter.find (TrimAutomation); + + if (i == control_by_parameter.end()) { + return; + } + + control = i->second; boost::shared_ptr ac = _route->trim_control(); @@ -390,6 +418,38 @@ Strip::notify_trim_changed (bool force_update) } } +void +Strip::notify_phase_changed (bool force_update) +{ + if (_route) { + if (!_route->phase_invert().size()) { + _surface->write (_vpot->zero()); + return; + } + + Control* control = 0; + ControlParameterMap::iterator i = control_by_parameter.find (PhaseAutomation); + + if (i == control_by_parameter.end()) { + return; + } + + control = i->second; + + float normalized_position = _route->phase_control()->get_value(); + + if (control == _fader) { + if (!_fader->in_use()) { + _surface->write (_fader->set_position (normalized_position)); + queue_parameter_display (PhaseAutomation, normalized_position); + } + } else if (control == _vpot) { + _surface->write (_vpot->set (normalized_position, true, Pot::wrap)); + queue_parameter_display (PhaseAutomation, normalized_position); + } + } +} + void Strip::notify_property_changed (const PropertyChange& what_changed) { @@ -432,12 +492,15 @@ Strip::notify_panner_azi_changed (bool force_update) return; } - Control* control = control_by_parameter[PanAzimuthAutomation]; + Control* control = 0; + ControlParameterMap::iterator i = control_by_parameter.find (PanAzimuthAutomation); - if (!control) { + if (i == control_by_parameter.end()) { return; } + control = i->second; + double pos = pannable->pan_azimuth_control->internal_to_interface (pannable->pan_azimuth_control->get_value()); if (force_update || pos != _last_pan_azi_position_written) { @@ -452,7 +515,6 @@ Strip::notify_panner_azi_changed (bool force_update) queue_parameter_display (PanAzimuthAutomation, pos); } - queue_parameter_display (PanAzimuthAutomation, pos); _last_pan_azi_position_written = pos; } } @@ -472,13 +534,15 @@ Strip::notify_panner_width_changed (bool force_update) return; } + Control* control = 0; + ControlParameterMap::iterator i = control_by_parameter.find (PanWidthAutomation); - Control* control = control_by_parameter[PanWidthAutomation]; - - if (!control) { + if (i == control_by_parameter.end()) { return; } + control = i->second; + double pos = pannable->pan_width_control->internal_to_interface (pannable->pan_width_control->get_value()); if (force_update || pos != _last_pan_azi_position_written) { @@ -497,7 +561,6 @@ Strip::notify_panner_width_changed (bool force_update) queue_parameter_display (PanWidthAutomation, pos); } - queue_parameter_display (PanWidthAutomation, pos); _last_pan_azi_position_written = pos; } } @@ -583,7 +646,7 @@ Strip::fader_touch_event (Button&, ButtonState bs) _fader->start_touch (_surface->mcp().transport_frame()); if (ac) { - queue_parameter_display ((AutomationType) ac->parameter().type(), ac->internal_to_interface (ac->get_value())); + queue_parameter_display ((AutomationType) ac->parameter().type(), ac->get_value()); } } @@ -719,6 +782,18 @@ Strip::do_parameter_display (AutomationType type, float val) float dB = accurate_coefficient_to_dB (val); snprintf (buf, sizeof (buf), "%6.1f", dB); _surface->write (display (1, buf)); + screen_hold = true; + } + break; + + case PhaseAutomation: + if (_route) { + if (_route->phase_control()->get_value() < 0.5) { + _surface->write (display (1, "Normal")); + } else { + _surface->write (display (1, "Invert")); + } + screen_hold = true; } break; @@ -745,6 +820,10 @@ void Strip::handle_fader (Fader& fader, float position) { DEBUG_TRACE (DEBUG::MackieControl, string_compose ("fader to %1\n", position)); + boost::shared_ptr ac = fader.control(); + if (!ac) { + return; + } fader.set_value (position); @@ -769,6 +848,9 @@ Strip::handle_pot (Pot& pot, float delta) */ boost::shared_ptr ac = pot.control(); + if (!ac) { + return; + } double p = pot.get_value (); p += delta; p = max (ac->lower(), p); @@ -787,7 +869,9 @@ Strip::periodic (ARDOUR::microseconds_t now) } if (_block_screen_redisplay_until >= now) { - + if (_surface->mcp().device_info().has_separate_meters()) { + goto meters; + } /* no drawing here, for now */ return; @@ -822,6 +906,7 @@ Strip::periodic (ARDOUR::microseconds_t now) update_automation (); } + meters: update_meter (); } @@ -861,7 +946,7 @@ Strip::update_automation () notify_panner_width_changed (false); } } - if (_route->trim()) { + if (_route->trim() && route()->trim()->active()) { ARDOUR::AutoState trim_state = _route->trim_control()->automation_state(); if (trim_state == Touch || trim_state == Play) { notify_trim_changed (false); @@ -975,6 +1060,8 @@ Strip::vpot_mode_string () const return "Fader"; case TrimAutomation: return "Trim"; + case PhaseAutomation: + return string_compose ("Phase%1", _route->phase_control()->channel() + 1); case PanAzimuthAutomation: return "Pan"; case PanWidthAutomation: @@ -997,58 +1084,24 @@ Strip::potmode_changed (bool notify) return; } - 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; - } // WIP int pm = _surface->mcp().pot_mode(); switch (pm) { - case MackieControlProtocol::Pan: - // This needs to set current pan mode (azimuth or width... or whatever) - set_vpot_parameter (_pan_mode); - DEBUG_TRACE (DEBUG::MackieControl, "Assign pot to Pan mode.\n"); - break; - case MackieControlProtocol::Tracks: // should change the Tracks to Trim - DEBUG_TRACE (DEBUG::MackieControl, "Assign pot to Trim mode.\n"); - set_vpot_parameter (TrimAutomation); - break; - case MackieControlProtocol::Send: - DEBUG_TRACE (DEBUG::MackieControl, "Assign pot to Send mode.\n"); - // set to current send - break; - default: - break; - } - - if (notify) { - notify_all (); - } -} - -void -Strip::flip_mode_changed (bool notify) -{ - if (!_route) { - return; + 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; } - reset_saved_values (); - - boost::shared_ptr fader_controllable = _fader->control (); - boost::shared_ptr vpot_controllable = _vpot->control (); - - _fader->set_control (vpot_controllable); - _vpot->set_control (fader_controllable); - - control_by_parameter[fader_controllable->parameter()] = _vpot; - control_by_parameter[vpot_controllable->parameter()] = _fader; - - _surface->write (display (1, vpot_mode_string ())); - if (notify) { notify_all (); } @@ -1122,7 +1175,40 @@ Strip::next_pot_mode () 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 @@ -1130,12 +1216,16 @@ Strip::set_vpot_parameter (Evoral::Parameter p) { boost::shared_ptr pannable; - DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch to vpot mode %1\n", p)); + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch to vpot mode %1\n", p.type())); reset_saved_values (); - for (int i = 0; i <= TrimAutomation; ++i) { - if (control_by_parameter[i] == _vpot) { - control_by_parameter[i] = 0; + + /* 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; } } @@ -1143,58 +1233,54 @@ Strip::set_vpot_parameter (Evoral::Parameter p) case PanAzimuthAutomation: _pan_mode = PanAzimuthAutomation; pannable = _route->pannable (); - if (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()); - control_by_parameter[PanAzimuthAutomation] = 0; - } + 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 { - /* 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()); - control_by_parameter[PanAzimuthAutomation] = 0; - } + _fader->set_control (boost::shared_ptr()); + 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()); + control_by_parameter[PanAzimuthAutomation] = 0; } } break; case PanWidthAutomation: _pan_mode = PanWidthAutomation; pannable = _route->pannable (); - if (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()); - control_by_parameter[PanWidthAutomation] = 0; - } + 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 { - /* 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()); - control_by_parameter[PanWidthAutomation] = 0; - } + _fader->set_control (boost::shared_ptr()); + 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()); + control_by_parameter[PanWidthAutomation] = 0; } } break; @@ -1205,23 +1291,69 @@ Strip::set_vpot_parameter (Evoral::Parameter p) case PanLFEAutomation: break; case TrimAutomation: - if (_route->trim()) { - 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 (_route->trim_control()); - control_by_parameter[TrimAutomation] = _fader; + _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()); + 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()); + 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 { - /* gain to fader, trim to vpot */ - _fader->set_control (_route->gain_control()); - control_by_parameter[GainAutomation] = _fader; - _vpot->set_control (_route->trim_control()); - control_by_parameter[TrimAutomation] = _vpot; + _fader->set_control (boost::shared_ptr()); + 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()); + 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()); + } else { + // gain to fader, trim to vpot + _fader->set_control (_route->gain_control()); + control_by_parameter[GainAutomation] = _fader; _vpot->set_control (boost::shared_ptr()); - control_by_parameter[TrimAutomation] = 0; } break; default: @@ -1233,6 +1365,12 @@ Strip::set_vpot_parameter (Evoral::Parameter p) _surface->write (display (1, vpot_mode_string())); } +bool +Strip::is_midi_track () const +{ + return boost::dynamic_pointer_cast(_route) != 0; +} + void Strip::reset_saved_values () {