diff options
author | Robin Gareus <robin@gareus.org> | 2019-05-09 16:06:00 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-05-09 16:06:00 +0200 |
commit | 9ac18a8e0ff50e31654d169b4a6ee331814a8045 (patch) | |
tree | 3fe009f5d69e456f0b9ed5369a577cfd5cd43664 /libs/surfaces | |
parent | 48b960fdefef2b3c02f47baca328638e9ecef9a4 (diff) |
Generic-MIDI ctrl: tweak pitch-bend message behavior
Add support for smoothing, ignore message when controllers are
not in sync to avoid discontinuous jumps.
This is mainly useful for Mackie-like devices that use pitch-bend
messages for faders.
see also https://discourse.ardour.org/t/feature-lazy-sliders/100961
Diffstat (limited to 'libs/surfaces')
-rw-r--r-- | libs/surfaces/generic_midi/midicontrollable.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc index b06a39d7a2..a7ea3dc36b 100644 --- a/libs/surfaces/generic_midi/midicontrollable.cc +++ b/libs/surfaces/generic_midi/midicontrollable.cc @@ -472,8 +472,25 @@ MIDIControllable::midi_sense_pitchbend (Parser &, pitchbend_t pb) _surface->maybe_start_touch (_controllable); if (!_controllable->is_toggle()) { - _controllable->set_value (midi_to_control (pb), Controllable::UseGroup); + + float new_value = pb; + float max_value = max (last_controllable_value, new_value); + float min_value = min (last_controllable_value, new_value); + float range = max_value - min_value; + float threshold = 128.f * _surface->threshold (); + + bool const in_sync = ( + range < threshold && + _controllable->get_value() <= midi_to_control (max_value) && + _controllable->get_value() >= midi_to_control (min_value) + ); + + if (in_sync || _surface->motorised ()) { + _controllable->set_value (midi_to_control (pb), Controllable::UseGroup); + } + DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("MIDI pitchbend %1 value %2 %3\n", (int) control_channel, (float) midi_to_control (pb), current_uri() )); + last_controllable_value = new_value; } else { if (pb > 8065.0f) { _controllable->set_value (1, Controllable::UseGroup); |