From bbaa5c6f45906dcf91072cf6d9a8fff96b3ac3b5 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 27 Nov 2015 16:41:26 -0500 Subject: [PATCH] faderport: shift+encoder controls pan width (for ardour only), input trim now controlled by user+encoder. User is now a modifier key --- libs/surfaces/faderport/faderport.cc | 25 +++++++++++++++++++++---- libs/surfaces/faderport/faderport.h | 4 +++- libs/surfaces/faderport/operations.cc | 25 ++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index 6111a4ef95..9ec34f0d43 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -286,6 +286,9 @@ FaderPort::switch_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb) case Rewind: button_state = (tb->value ? ButtonState (button_state|RewindDown) : ButtonState (button_state&~RewindDown)); break; + case User: + button_state = (tb->value ? ButtonState (button_state|UserDown) : ButtonState (button_state&~UserDown)); + break; case FaderTouch: fader_is_touched = tb->value; if (_current_route) { @@ -348,16 +351,30 @@ FaderPort::encoder_handler (MIDI::Parser &, MIDI::pitchbend_t pb) if (_current_route) { - if ( (button_state & ShiftDown) == ShiftDown ) { //shift+encoder = input trim + ButtonState trim_modifier; + ButtonState width_modifier; + + if (Profile->get_mixbus()) { + trim_modifier = ShiftDown; + width_modifier = ButtonState (0); + } else { + trim_modifier = UserDown; + width_modifier = ShiftDown; + } + + if ((button_state & trim_modifier) == trim_modifier ) { // mod+encoder = input trim boost::shared_ptr gain = _current_route->trim()->gain_control (); if (gain) { float val = gain->get_user(); //for gain elements, the "user" value is in dB val += delta; gain->set_user(val); } - } else { //pan / balance + } else if (width_modifier && ((button_state & width_modifier) == width_modifier)) { + ardour_pan_width (delta); + + } else { // pan/balance if (!Profile->get_mixbus()) { - ardour_pan (delta); + ardour_pan_azimuth (delta); } else { mixbus_pan (delta); } @@ -820,7 +837,7 @@ FaderPort::set_current_route (boost::shared_ptr r) mp->cut_control()->Changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_cut, this), this); } } - + //ToDo: subscribe to the fader automation modes so we can light the LEDs map_route_state (); diff --git a/libs/surfaces/faderport/faderport.h b/libs/surfaces/faderport/faderport.h index 3af6280e2e..14b8e5c3f6 100644 --- a/libs/surfaces/faderport/faderport.h +++ b/libs/surfaces/faderport/faderport.h @@ -172,6 +172,7 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUIset_value (azimuth->interface_to_internal (azimuth->internal_to_interface (azimuth->get_value()) + (delta / 64.0))); } + +void +FaderPort::ardour_pan_width(int delta) +{ + if (!_current_route) { + return; + } + + boost::shared_ptr pannable = _current_route->pannable (); + + if (!pannable) { + return; + } + + boost::shared_ptr width = pannable->pan_width_control; + + if (!width) { + return; + } + + width->set_value (width->interface_to_internal (width->internal_to_interface (width->get_value()) + (delta / 64.0))); +} + void FaderPort::mixbus_pan (int delta) {