#include "ardour/debug.h"
#include "ardour/midi_ui.h"
#include "ardour/meter.h"
+#include "ardour/plugin_insert.h"
#include "ardour/pannable.h"
#include "ardour/panner.h"
#include "ardour/panner_shell.h"
#include "ardour/session.h"
#include "ardour/send.h"
#include "ardour/track.h"
+#include "ardour/midi_track.h"
#include "ardour/user_bundle.h"
+#include "ardour/profile.h"
#include "mackie_control_protocol.h"
#include "surface_port.h"
, _controls_locked (false)
, _transport_is_rolling (false)
, _metering_active (true)
- , _reset_display_at (0)
+ , _block_vpot_mode_redisplay_until (0)
+ , _block_screen_redisplay_until (0)
, _pan_mode (PanAzimuthAutomation)
+ , _trim_mode (TrimAutomation)
+ , vpot_parameter (PanAzimuthAutomation)
, _last_gain_position_written (-1.0)
, _last_pan_azi_position_written (-1.0)
, _last_pan_width_position_written (-1.0)
, _last_trim_position_written (-1.0)
+ , _current_send (0)
, redisplay_requests (256)
{
_fader = dynamic_cast<Fader*> (Fader::factory (*_surface, index, "fader", *this));
return;
}
+ mb_pan_controllable.reset();
+
route_connections.drop_connections ();
_solo->set_control (boost::shared_ptr<AutomationControl>());
_route = r;
control_by_parameter.clear ();
+
+ control_by_parameter[PanAzimuthAutomation] = (Control*) 0;
+ control_by_parameter[PanWidthAutomation] = (Control*) 0;
+ control_by_parameter[PanElevationAutomation] = (Control*) 0;
+ control_by_parameter[PanFrontBackAutomation] = (Control*) 0;
+ control_by_parameter[PanLFEAutomation] = (Control*) 0;
+ control_by_parameter[GainAutomation] = (Control*) 0;
+ control_by_parameter[TrimAutomation] = (Control*) 0;
+ control_by_parameter[PhaseAutomation] = (Control*) 0;
+ control_by_parameter[SendAutomation] = (Control*) 0;
+ control_by_parameter[EQParam1] = (Control*) 0;
+ control_by_parameter[EQParam2] = (Control*) 0;
+ control_by_parameter[EQParam3] = (Control*) 0;
+ control_by_parameter[EQParam4] = (Control*) 0;
+ control_by_parameter[EQParam5] = (Control*) 0;
+ control_by_parameter[EQParam6] = (Control*) 0;
+ control_by_parameter[EQParam7] = (Control*) 0;
+ control_by_parameter[EQParam8] = (Control*) 0;
+
reset_saved_values ();
if (!r) {
_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> pannable = _route->pannable();
- if (pannable && _route->panner()) {
- pannable->pan_azimuth_control->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_panner_azi_changed, this, false), ui_context());
- pannable->pan_width_control->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_panner_width_changed, this, false), ui_context());
+ if(Profile->get_mixbus()) {
+ const uint32_t port_channel_post_pan = 2; // gtk2_ardour/mixbus_ports.h
+ boost::shared_ptr<ARDOUR::PluginInsert> plug = _route->ch_post();
+ mb_pan_controllable = boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_pan)));
+
+ mb_pan_controllable->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_panner_azi_changed, this, false), ui_context());
+ } else {
+ if (pannable && _route->panner()) {
+ pannable->pan_azimuth_control->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_panner_azi_changed, this, false), ui_context());
+ pannable->pan_width_control->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_panner_width_changed, this, false), ui_context());
+ }
}
+
_route->gain_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_gain_changed, this, false), ui_context());
_route->PropertyChanged.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_property_changed, this, _1), ui_context());
_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 */
- build_input_list (_route->input()->n_ports());
- build_output_list (_route->output()->n_ports());
-
possible_pot_parameters.clear();
- if (pannable) {
- boost::shared_ptr<Panner> panner = _route->panner();
- if (panner) {
- set<Evoral::Parameter> automatable = panner->what_can_be_automated ();
- set<Evoral::Parameter>::iterator a;
+ if (Profile->get_mixbus()) {
+ possible_pot_parameters.push_back (PanAzimuthAutomation);
+ } else {
+ if (pannable) {
+ boost::shared_ptr<Panner> panner = _route->panner();
+ if (panner) {
+ set<Evoral::Parameter> automatable = panner->what_can_be_automated ();
+ set<Evoral::Parameter>::iterator a;
- if ((a = automatable.find (PanAzimuthAutomation)) != automatable.end()) {
- possible_pot_parameters.push_back (PanAzimuthAutomation);
- }
+ if ((a = automatable.find (PanAzimuthAutomation)) != automatable.end()) {
+ possible_pot_parameters.push_back (PanAzimuthAutomation);
+ }
- if ((a = automatable.find (PanWidthAutomation)) != automatable.end()) {
- possible_pot_parameters.push_back (PanWidthAutomation);
+ if ((a = automatable.find (PanWidthAutomation)) != automatable.end()) {
+ possible_pot_parameters.push_back (PanWidthAutomation);
+ }
}
}
}
+
+ 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);
+ _route->phase_control()->set_channel(0);
+ if (_trim_mode != TrimAutomation) {
+ _trim_mode = PhaseAutomation;
+ }
+ }
+ _current_send = 0;
+ /* Update */
+ _pan_mode = PanAzimuthAutomation;
+ potmode_changed (false);
+ notify_all ();
+
}
void
notify_panner_width_changed ();
notify_record_enable_changed ();
notify_trim_changed ();
+ notify_phase_changed ();
+ notify_processor_changed ();
}
void
queue_parameter_display (GainAutomation, gain_coefficient);
}
- queue_display_reset (2000);
_last_gain_position_written = normalized_position;
}
}
{
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<AutomationControl> ac = _route->trim_control();
queue_parameter_display (TrimAutomation, gain_coefficient);
}
_last_trim_position_written = normalized_position;
+ }
+ }
+}
+
+void
+Strip::notify_phase_changed (bool force_update)
+{
+ if (_route) {
+ if (!_route->phase_invert().size()) {
+ _surface->write (_vpot->zero());
+ return;
+ }
- queue_display_reset (2000);
+ 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_processor_changed (bool force_update)
+{
+ if (_route) {
+ boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
+ if (!p) {
+ _surface->write (_vpot->zero());
+ return;
+ }
+
+ Control* control = 0;
+ ControlParameterMap::iterator i = control_by_parameter.find (SendAutomation);
+
+ if (i == control_by_parameter.end()) {
+ return;
+ }
+
+ control = i->second;
+
+ boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p);
+ boost::shared_ptr<Amp> a = s->amp();
+ boost::shared_ptr<AutomationControl> ac = a->gain_control();
+
+ float gain_coefficient = ac->get_value();
+ float normalized_position = ac->internal_to_interface (gain_coefficient);
+
+ if (control == _fader) {
+ if (!_fader->in_use()) {
+ _surface->write (_fader->set_position (normalized_position));
+ queue_parameter_display (SendAutomation, gain_coefficient);
+ }
+ } else if (control == _vpot) {
+ _surface->write (_vpot->set (normalized_position, true, Pot::dot));
+ queue_parameter_display (SendAutomation, gain_coefficient);
}
}
}
return;
}
- if (_route) {
+ show_route_name ();
+}
+
+void
+Strip::show_route_name ()
+{
+ MackieControlProtocol::SubViewMode svm = _surface->mcp().subview_mode();
+
+ if (svm == MackieControlProtocol::None) {
+ if (!_route) {
+ return;
+ }
string line1;
string fullname = _route->name();
}
_surface->write (display (0, line1));
+
+ } else if (svm == MackieControlProtocol::EQ) {
+ if (_vpot == control_by_parameter[EQParam1]) {
+ _surface->write (display (0, "HiFreq"));
+ } else if (_vpot == control_by_parameter[EQParam2]) {
+ _surface->write (display (0, "HiGain"));
+ } else if (_vpot == control_by_parameter[EQParam3]) {
+ _surface->write (display (0, "MidFreq"));
+ } else if (_vpot == control_by_parameter[EQParam4]) {
+ _surface->write (display (0, "MidGain"));
+ } else if (_vpot == control_by_parameter[EQParam5]) {
+ _surface->write (display (0, "LoFreq"));
+ } else if (_vpot == control_by_parameter[EQParam6]) {
+ _surface->write (display (0, "LoGain"));
+ } else if (_vpot == control_by_parameter[EQParam7]) {
+ _surface->write (display (0, "HPFreq"));
+ } else if (_vpot == control_by_parameter[EQParam8]) {
+ _surface->write (display (0, "In/Out"));
+ }
+ } else if (svm == MackieControlProtocol::Dynamics) {
+
+ }
+
+}
+
+void
+Strip::notify_eq_change (AutomationType p, uint32_t port_number, bool force_update)
+{
+ if (_surface->mcp().subview_mode() == MackieControlProtocol::None) {
+ /* no longer in EQ subview mode */
+ return;
+ }
+
+ if (_vpot != control_by_parameter[p]) {
+ /* vpot is no longer controlling this EQ parameter */
+ return;
+ }
+
+ boost::shared_ptr<PluginInsert> eq = _surface->mcp().subview_route()->ch_eq();
+
+ if (eq) {
+ boost::shared_ptr<AutomationControl> control = boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_number)));
+
+ if (control) {
+ float val = control->get_value();
+ queue_parameter_display (p, val);
+ _surface->write (_vpot->set (control->internal_to_interface (val), true, Pot::wrap));
+ }
}
}
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;
}
- double pos = pannable->pan_azimuth_control->internal_to_interface (pannable->pan_azimuth_control->get_value());
+ control = i->second;
+
+ double pos = mb_pan_controllable->internal_to_interface (mb_pan_controllable->get_value());
if (force_update || pos != _last_pan_azi_position_written) {
queue_parameter_display (PanAzimuthAutomation, pos);
}
- queue_display_reset (2000);
_last_pan_azi_position_written = pos;
}
}
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) {
+ if (force_update || pos != _last_pan_width_position_written) {
if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
queue_parameter_display (PanWidthAutomation, pos);
}
- queue_display_reset (2000);
- _last_pan_azi_position_written = pos;
+ _last_pan_width_position_written = pos;
}
}
}
if (ms & MackieControlProtocol::MODIFIER_CMDALT) {
_controls_locked = !_controls_locked;
_surface->write (display (1,_controls_locked ? "Locked" : "Unlock"));
- queue_display_reset (1000);
+ block_vpot_mode_display_for (1000);
return;
}
_fader->start_touch (_surface->mcp().transport_frame());
if (ac) {
- queue_parameter_display ((AutomationType) ac->parameter().type(), ac->internal_to_interface (ac->get_value()));
- queue_display_reset (2000);
+ queue_parameter_display ((AutomationType) ac->parameter().type(), ac->get_value());
}
}
void
Strip::do_parameter_display (AutomationType type, float val)
{
+ bool screen_hold = false;
+ char buf[16];
+
switch (type) {
case GainAutomation:
if (val == 0.0) {
_surface->write (display (1, " -inf "));
} else {
- char buf[16];
float dB = accurate_coefficient_to_dB (val);
snprintf (buf, sizeof (buf), "%6.1f", dB);
_surface->write (display (1, buf));
+ screen_hold = true;
}
break;
case PanAzimuthAutomation:
- if (_route) {
- boost::shared_ptr<Pannable> p = _route->pannable();
- if (p && _route->panner()) {
- string str =_route->panner()->value_as_string (p->pan_azimuth_control);
- _surface->write (display (1, str));
+ if (Profile->get_mixbus()) {
+ snprintf (buf, sizeof (buf), "%2.1f", val);
+ _surface->write (display (1, buf));
+ screen_hold = true;
+ } else {
+ if (_route) {
+ boost::shared_ptr<Pannable> p = _route->pannable();
+ if (p && _route->panner()) {
+ string str =_route->panner()->value_as_string (p->pan_azimuth_control);
+ _surface->write (display (1, str));
+ screen_hold = true;
+ }
}
}
break;
case PanWidthAutomation:
if (_route) {
- char buf[16];
snprintf (buf, sizeof (buf), "%5ld%%", lrintf ((val * 200.0)-100));
_surface->write (display (1, buf));
+ screen_hold = true;
}
break;
case TrimAutomation:
if (_route) {
- char buf[16];
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;
+ case SendAutomation:
+ if (val == 0.0) {
+ _surface->write (display (1, " -inf "));
+ } else {
+ float dB = accurate_coefficient_to_dB (val);
+ snprintf (buf, sizeof (buf), "%6.1f", dB);
+ _surface->write (display (1, buf));
+ screen_hold = true;
+ }
+ break;
+ case EQParam1:
+ case EQParam2:
+ case EQParam3:
+ case EQParam4:
+ case EQParam5:
+ case EQParam6:
+ case EQParam7:
+ case EQParam8:
+ snprintf (buf, sizeof (buf), "%6.1f", val);
+ _surface->write (display (1, buf));
+ screen_hold = true;
default:
break;
}
+
+ if (screen_hold) {
+ block_vpot_mode_display_for (1000);
+ }
}
void
Strip::handle_fader (Fader& fader, float position)
{
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("fader to %1\n", position));
+ boost::shared_ptr<AutomationControl> ac = fader.control();
+ if (!ac) {
+ return;
+ }
fader.set_value (position);
*/
boost::shared_ptr<AutomationControl> ac = pot.control();
+ if (!ac) {
+ return;
+ }
double p = pot.get_value ();
p += delta;
- p = max (ac->lower(), p);
- p = min (ac->upper(), p);
+ // fader and pot should be the same and fader is hard coded 0 -> 1
+ p = max (0.0, p);
+ p = min (1.0, p);
pot.set_value (p);
}
void
-Strip::periodic (uint64_t usecs)
+Strip::periodic (ARDOUR::microseconds_t now)
{
+ bool reshow_vpot_mode = false;
+ bool reshow_name = false;
+
if (!_route) {
return;
}
- update_automation ();
- update_meter ();
+ if (_block_screen_redisplay_until >= now) {
+ if (_surface->mcp().device_info().has_separate_meters()) {
+ goto meters;
+ }
+ /* no drawing here, for now */
+ return;
- if (_reset_display_at && _reset_display_at < usecs) {
- reset_display ();
+ } else if (_block_screen_redisplay_until) {
+
+ /* timeout reached, reset */
+
+ _block_screen_redisplay_until = 0;
+ reshow_vpot_mode = true;
+ reshow_name = true;
}
+
+ if (_block_vpot_mode_redisplay_until >= now) {
+ return;
+ } else if (_block_vpot_mode_redisplay_until) {
+
+ /* timeout reached, reset */
+
+ _block_vpot_mode_redisplay_until = 0;
+ reshow_vpot_mode = true;
+ }
+
+ if (reshow_name) {
+ show_route_name ();
+ }
+
+ if (reshow_vpot_mode) {
+ return_to_vpot_mode_display ();
+ } else {
+ /* no point doing this if we just switched back to vpot mode
+ display */
+ update_automation ();
+ }
+
+ meters:
+ update_meter ();
}
void
-Strip::redisplay ()
+Strip::redisplay (ARDOUR::microseconds_t now)
{
RedisplayRequest req;
bool have_request = false;
have_request = true;
}
+ if (_block_screen_redisplay_until >= now) {
+ return;
+ }
+
if (have_request) {
do_parameter_display (req.type, req.val);
}
notify_gain_changed (false);
}
+if ( Profile->get_mixbus() ) {
+ ARDOUR::AutoState panner_state = mb_pan_controllable->automation_state();
+ if (panner_state == Touch || panner_state == Play) {
+ notify_panner_azi_changed (false);
+ }
+} else {
if (_route->panner()) {
ARDOUR::AutoState panner_state = _route->panner()->automation_state();
if (panner_state == Touch || panner_state == Play) {
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);
}
string
-Strip::vpot_mode_string () const
+Strip::vpot_mode_string ()
{
boost::shared_ptr<AutomationControl> ac = _vpot->control();
-
if (!ac) {
return string();
}
- switch (ac->parameter().type()) {
- case GainAutomation:
+ if (control_by_parameter.find (GainAutomation)->second == _vpot) {
return "Fader";
- case TrimAutomation:
+ } else if (control_by_parameter.find (TrimAutomation)->second == _vpot) {
return "Trim";
- case PanAzimuthAutomation:
+ } else if (control_by_parameter.find (PhaseAutomation)->second == _vpot) {
+ return string_compose ("Phase%1", _route->phase_control()->channel() + 1);
+ } else if (control_by_parameter.find (SendAutomation)->second == _vpot) {
+ // should be bus name
+ boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
+ if (p) {
+ return p->name();
+ }
+ } else if (control_by_parameter.find (PanAzimuthAutomation)->second == _vpot) {
return "Pan";
- case PanWidthAutomation:
+ } else if (control_by_parameter.find (PanWidthAutomation)->second == _vpot) {
return "Width";
- case PanElevationAutomation:
+ } else if (control_by_parameter.find (PanElevationAutomation)->second == _vpot) {
return "Elev";
- case PanFrontBackAutomation:
+ } else if (control_by_parameter.find (PanFrontBackAutomation)->second == _vpot) {
return "F/Rear";
- case PanLFEAutomation:
+ } else if (control_by_parameter.find (PanLFEAutomation)->second == _vpot) {
return "LFE";
}
+ if (_surface->mcp().subview_mode() != MackieControlProtocol::None) {
+ return string();
+ }
+
return "???";
}
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"));
- queue_display_reset (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:
+ // _current_send has the number of the send we will show
+ DEBUG_TRACE (DEBUG::MackieControl, "Assign pot to Send mode.\n");
+ set_vpot_parameter (SendAutomation);
+ break;
}
- reset_saved_values ();
-
- boost::shared_ptr<AutomationControl> fader_controllable = _fader->control ();
- boost::shared_ptr<AutomationControl> 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 ();
}
}
void
-Strip::queue_display_reset (uint32_t msecs)
+Strip::block_screen_display_for (uint32_t msecs)
{
- struct timeval now;
- struct timeval delta;
- struct timeval when;
- gettimeofday (&now, 0);
-
- delta.tv_sec = msecs/1000;
- delta.tv_usec = (msecs - ((msecs/1000) * 1000)) * 1000;
-
- timeradd (&now, &delta, &when);
-
- _reset_display_at = (when.tv_sec * 1000000) + when.tv_usec;
+ _block_screen_redisplay_until = ARDOUR::get_microseconds() + (msecs * 1000);
}
void
-Strip::clear_display_reset ()
+Strip::block_vpot_mode_display_for (uint32_t msecs)
{
- _reset_display_at = 0;
+ _block_vpot_mode_redisplay_until = ARDOUR::get_microseconds() + (msecs * 1000);
}
void
-Strip::reset_display ()
+Strip::return_to_vpot_mode_display ()
{
- if (_route) {
+ /* returns the second line of the two-line per-strip display
+ back the mode where it shows what the VPot controls.
+ */
+
+ if (_surface->mcp().subview_mode() != MackieControlProtocol::None) {
+ /* do nothing - second line shows value of current subview parameter */
+ return;
+ } else if (_route) {
_surface->write (display (1, vpot_mode_string()));
} else {
_surface->write (blank_display (1));
}
-
- clear_display_reset ();
-}
-
-struct RouteCompareByName {
- bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
- return a->name().compare (b->name()) < 0;
- }
-};
-
-void
-Strip::maybe_add_to_bundle_map (BundleMap& bm, boost::shared_ptr<Bundle> b, bool for_input, const ChanCount& channels)
-{
- if (b->ports_are_outputs() == !for_input || b->nchannels() != channels) {
- return;
- }
-
- bm[b->name()] = b;
-}
-
-void
-Strip::build_input_list (const ChanCount& channels)
-{
- boost::shared_ptr<ARDOUR::BundleList> b = _surface->mcp().get_session().bundles ();
-
- input_bundles.clear ();
-
- /* give user bundles first chance at being in the menu */
-
- for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
- if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
- maybe_add_to_bundle_map (input_bundles, *i, true, channels);
- }
- }
-
- for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
- if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
- maybe_add_to_bundle_map (input_bundles, *i, true, channels);
- }
- }
-
- boost::shared_ptr<ARDOUR::RouteList> routes = _surface->mcp().get_session().get_routes ();
- RouteList copy = *routes;
- copy.sort (RouteCompareByName ());
-
- for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
- maybe_add_to_bundle_map (input_bundles, (*i)->output()->bundle(), true, channels);
- }
-
-}
-
-void
-Strip::build_output_list (const ChanCount& channels)
-{
- boost::shared_ptr<ARDOUR::BundleList> b = _surface->mcp().get_session().bundles ();
-
- output_bundles.clear ();
-
- /* give user bundles first chance at being in the menu */
-
- for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
- if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
- maybe_add_to_bundle_map (output_bundles, *i, false, channels);
- }
- }
-
- for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
- if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
- maybe_add_to_bundle_map (output_bundles, *i, false, channels);
- }
- }
-
- boost::shared_ptr<ARDOUR::RouteList> routes = _surface->mcp().get_session().get_routes ();
- RouteList copy = *routes;
- copy.sort (RouteCompareByName ());
-
- for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
- maybe_add_to_bundle_map (output_bundles, (*i)->input()->bundle(), false, channels);
- }
}
void
/* 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"));
- queue_display_reset (1000);
+ block_vpot_mode_display_for (1000);
return;
}
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);
+ } else if (_surface->mcp().pot_mode() == MackieControlProtocol::Send) {
+ boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
+ if (!p) {
+ return;
+ }
+ p = _route->nth_send (_current_send + 1);
+ if (p && p->name() != "Monitor 1") {
+ _current_send++;
+ } else {
+ _current_send = 0;
+ }
+ set_vpot_parameter (SendAutomation);
+ }
+}
+
+void
+Strip::subview_mode_changed ()
+{
+ boost::shared_ptr<Route> r = _surface->mcp().subview_route();
+
+ subview_connections.drop_connections ();
+
+ switch (_surface->mcp().subview_mode()) {
+ case MackieControlProtocol::None:
+ if (vpot_parameter != NullAutomation) {
+ set_vpot_parameter (vpot_parameter);
+ }
+ break;
+
+ case MackieControlProtocol::EQ:
+ switch (_index) {
+ case 0:
+ set_vpot_parameter (ARDOUR::EQParam1);
+ break;
+ case 1:
+ set_vpot_parameter (ARDOUR::EQParam2);
+ break;
+ case 2:
+ set_vpot_parameter (ARDOUR::EQParam3);
+ break;
+ case 3:
+ set_vpot_parameter (ARDOUR::EQParam4);
+ break;
+ case 4:
+ set_vpot_parameter (ARDOUR::EQParam5);
+ break;
+ case 5:
+ set_vpot_parameter (ARDOUR::EQParam6);
+ break;
+ case 6:
+ set_vpot_parameter (ARDOUR::EQParam7);
+ break;
+ case 7:
+ set_vpot_parameter (ARDOUR::EQParam8);
+ break;
+ }
+ break;
+
+ case MackieControlProtocol::Dynamics:
+ break;
}
}
{
boost::shared_ptr<Pannable> 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;
}
}
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<AutomationControl>());
- control_by_parameter[PanAzimuthAutomation] = 0;
- }
+ vpot_parameter = PanAzimuthAutomation;
+ if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
+ /* gain to vpot, pan azi to fader */
+ _vpot->set_control (_route->group_gain_control());
+ control_by_parameter[GainAutomation] = _vpot;
+ if (pannable) {
+ _fader->set_control (mb_pan_controllable);
+ 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<AutomationControl>());
- control_by_parameter[PanAzimuthAutomation] = 0;
- }
+ _fader->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[PanAzimuthAutomation] = 0;
+ }
+ } else {
+ /* gain to fader, pan azi to vpot */
+ _fader->set_control (_route->group_gain_control());
+ control_by_parameter[GainAutomation] = _fader;
+ if (pannable) {
+ _vpot->set_control (mb_pan_controllable);
+ 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 (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;
- }
+ vpot_parameter = PanWidthAutomation;
+ if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
+ /* gain to vpot, pan width to fader */
+ _vpot->set_control (_route->group_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<AutomationControl>());
- control_by_parameter[PanWidthAutomation] = 0;
- }
+ _fader->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[PanWidthAutomation] = 0;
+ }
+ } else {
+ /* gain to fader, pan width to vpot */
+ _fader->set_control (_route->group_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 PanLFEAutomation:
break;
case TrimAutomation:
- if (_route->trim()) {
+ _trim_mode = TrimAutomation;
+ vpot_parameter = TrimAutomation;
+ if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
+ /* gain to vpot, trim to fader */
+ _vpot->set_control (_route->group_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->group_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;
+ vpot_parameter = PhaseAutomation;
+ if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
+ /* gain to vpot, phase to fader */
+ _vpot->set_control (_route->group_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->group_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:
+ if (!Profile->get_mixbus()) {
if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
- /* gain to vpot, trim to fader */
- _vpot->set_control (_route->gain_control());
+ // gain to vpot, send to fader
+ _vpot->set_control (_route->group_gain_control());
control_by_parameter[GainAutomation] = _vpot;
- _fader->set_control (_route->trim_control());
- control_by_parameter[TrimAutomation] = _fader;
+ // test for send to control
+ boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
+ if (p && p->name() != "Monitor 1") {
+ boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p);
+ boost::shared_ptr<Amp> a = s->amp();
+ _fader->set_control (a->gain_control());
+ // connect to signal
+ send_connections.drop_connections ();
+ a->gain_control()->Changed.connect(send_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_processor_changed, this, false), ui_context());
+ control_by_parameter[SendAutomation] = _fader;
+ } else {
+ _fader->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[SendAutomation] = 0;
+ }
+ } else {
+ // gain to fader, send to vpot
+ _fader->set_control (_route->group_gain_control());
+ control_by_parameter[GainAutomation] = _fader;
+ boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
+ if (p && p->name() != "Monitor 1") {
+ boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p);
+ boost::shared_ptr<Amp> a = s->amp();
+ _vpot->set_control (a->gain_control());
+ // connect to signal
+ send_connections.drop_connections ();
+ a->gain_control()->Changed.connect(send_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_processor_changed, this, false), ui_context());
+ control_by_parameter[SendAutomation] = _vpot;
} else {
- /* gain to fader, trim to vpot */
- _fader->set_control (_route->gain_control());
+ // gain to fader, send to vpot
+ _fader->set_control (_route->group_gain_control());
control_by_parameter[GainAutomation] = _fader;
- _vpot->set_control (_route->trim_control());
- control_by_parameter[TrimAutomation] = _vpot;
+ boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
+ if (p && p->name() != "Monitor 1") {
+ boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p);
+ boost::shared_ptr<Amp> a = s->amp();
+ _vpot->set_control (a->gain_control());
+ // connect to signal
+ send_connections.drop_connections ();
+ a->gain_control()->Changed.connect(send_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_processor_changed, this, false), ui_context());
+ control_by_parameter[SendAutomation] = _vpot;
+ } else {
+ _vpot->set_control (boost::shared_ptr<AutomationControl>());
+ control_by_parameter[SendAutomation] = 0;
+ }
}
- } else {
- _vpot->set_control (boost::shared_ptr<AutomationControl>());
- control_by_parameter[TrimAutomation] = 0;
}
break;
+ case EQParam1: {
+ const uint32_t eq_hi_freq = 3; /* gtk2_ardour/mixbus_ports.h */
+ hookup_eq (EQParam1, eq_hi_freq);
+ break;
+ }
+ case EQParam2: {
+ const uint32_t eq_hi_gain = 4; /* gtk2_ardour/mixbus_ports.h */
+ hookup_eq (EQParam2, eq_hi_gain);
+ break;
+ }
+ case EQParam3: {
+ const uint32_t eq_mid_freq = 5; /* gtk2_ardour/mixbus_ports.h */
+ hookup_eq (EQParam3, eq_mid_freq);
+ break;
+ }
+ case EQParam4: {
+ const uint32_t eq_mid_gain = 6; /* gtk2_ardour/mixbus_ports.h */
+ hookup_eq (EQParam4, eq_mid_gain);
+ break;
+ }
+ case EQParam5: {
+ const uint32_t eq_lo_freq = 7; /* gtk2_ardour/mixbus_ports.h */
+ hookup_eq (EQParam5, eq_lo_freq);
+ break;
+ }
+ case EQParam6: {
+ const uint32_t eq_lo_gain = 8; /* gtk2_ardour/mixbus_ports.h */
+ hookup_eq (EQParam6, eq_lo_gain);
+ break;
+ }
+ case EQParam7: {
+ const uint32_t eq_hp_freq = 2; /* gtk2_ardour/mixbus_ports.h */
+ hookup_eq (EQParam7, eq_hp_freq);
+ break;
+ }
+ case EQParam8: {
+ const uint32_t eq_in = 1; /* gtk2_ardour/mixbus_ports.h */
+ hookup_eq (EQParam8, eq_in);
+ 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 ()
{
_transport_is_rolling = transport_is_rolling;
_metering_active = metering_active;
}
+
+void
+Strip::hookup_eq (AutomationType param, uint32_t port_number)
+{
+ boost::shared_ptr<Route> r = _surface->mcp().subview_route();
+
+ if (!r) {
+ _vpot->set_control (boost::shared_ptr<AutomationControl>());
+ return;
+ }
+
+ boost::shared_ptr<PluginInsert> eq = r->ch_eq();
+
+ if (!eq) {
+ _vpot->set_control (boost::shared_ptr<AutomationControl>());
+ }
+
+ boost::shared_ptr<AutomationControl> control = boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_number)));
+
+ if (control) {
+ control->Changed.connect (subview_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_eq_change, this, param, port_number, false), ui_context());
+ _vpot->set_control (control);
+ control_by_parameter[param] = _vpot;
+ show_route_name ();
+ }
+}