From dab2513d9f4bdfe30a6bc7c30cbe821b0fb9e75c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=A9rence=20Clastres?= Date: Fri, 10 Aug 2018 18:44:10 +0200 Subject: [PATCH] Add pick-up mode and use it for knobs and faders The pick up mode ignores new controller values until they match with the current setting of the stripable's ac --- libs/surfaces/launch_control_xl/launch_control_xl.cc | 11 +++++++++-- libs/surfaces/launch_control_xl/launch_control_xl.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/surfaces/launch_control_xl/launch_control_xl.cc b/libs/surfaces/launch_control_xl/launch_control_xl.cc index 0881d0647e..6f571794a8 100644 --- a/libs/surfaces/launch_control_xl/launch_control_xl.cc +++ b/libs/surfaces/launch_control_xl/launch_control_xl.cc @@ -444,6 +444,13 @@ LaunchControlXL::handle_button_message(Button* button, MIDI::EventTwoBytes* ev) } } +bool +LaunchControlXL::check_pick_up(Controller* controller, boost::shared_ptr ac) +{ + /* returns false until the controller value matches with the current setting of the stripable's ac */ + return ( abs( controller->value() / 127.0 - ac->internal_to_interface(ac->get_value()) ) < 0.007875 ); +} + void LaunchControlXL::handle_knob_message (Knob* knob) { @@ -462,7 +469,7 @@ LaunchControlXL::handle_knob_message (Knob* knob) ac = stripable[chan]->pan_azimuth_control(); } - if (ac) { + if (ac && check_pick_up(knob, ac)) { ac->set_value ( ac->interface_to_internal( knob->value() / 127.0), PBD::Controllable::UseGroup ); } } @@ -476,7 +483,7 @@ LaunchControlXL::handle_fader_message (Fader* fader) } boost::shared_ptr ac = stripable[fader->id()]->gain_control(); - if (ac) { + if (ac && check_pick_up(fader, ac)) { ac->set_value ( ac->interface_to_internal( fader->value() / 127.0), PBD::Controllable::UseGroup ); } } diff --git a/libs/surfaces/launch_control_xl/launch_control_xl.h b/libs/surfaces/launch_control_xl/launch_control_xl.h index a37eec8734..d4747767c8 100644 --- a/libs/surfaces/launch_control_xl/launch_control_xl.h +++ b/libs/surfaces/launch_control_xl/launch_control_xl.h @@ -429,6 +429,8 @@ private: void handle_fader_message(Fader* fader); void handle_knob_message(Knob* knob); + bool check_pick_up(Controller* controller, boost::shared_ptr ac); + void handle_midi_controller_message(MIDI::Parser &, MIDI::EventTwoBytes *, MIDI::channel_t chan); void handle_midi_note_on_message(MIDI::Parser &, MIDI::EventTwoBytes *, MIDI::channel_t chan); void handle_midi_note_off_message(MIDI::Parser &, MIDI::EventTwoBytes *, MIDI::channel_t chan);