#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"
, _block_vpot_mode_redisplay_until (0)
, _block_screen_redisplay_until (0)
, _pan_mode (PanAzimuthAutomation)
+ , _trim_mode (TrimAutomation)
, _last_gain_position_written (-1.0)
, _last_pan_azi_position_written (-1.0)
, _last_pan_width_position_written (-1.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;
reset_saved_values ();
_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()) {
_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();
}
}
- 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
notify_panner_width_changed ();
notify_record_enable_changed ();
notify_trim_changed ();
+ notify_phase_changed ();
}
void
{
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();
}
}
+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)
{
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) {
queue_parameter_display (PanAzimuthAutomation, pos);
}
- queue_parameter_display (PanAzimuthAutomation, pos);
_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) {
queue_parameter_display (PanWidthAutomation, pos);
}
- queue_parameter_display (PanWidthAutomation, pos);
_last_pan_azi_position_written = pos;
}
}
_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());
}
}
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;
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);
}
if (_block_screen_redisplay_until >= now) {
-
+ if (_surface->mcp().device_info().has_separate_meters()) {
+ goto meters;
+ }
/* no drawing here, for now */
return;
update_automation ();
}
+ meters:
update_meter ();
}
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);
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;
}
- 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<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 ();
}
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
{
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;
- }
+ 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<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->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 (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;
- }
+ 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<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->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()) {
- 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<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 {
- /* 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<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>());
- control_by_parameter[TrimAutomation] = 0;
}
break;
default:
_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 ()
{