From 9873e1d211e1e5033d710aa5acefe2dcd9cfea1c Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 29 Mar 2020 00:47:26 +0100 Subject: [PATCH] VKeybd: fix stuck keys when changing octaves - #7957 Using the mouse/dropdown to change octaves can lead to stuck notes when keys are held. This is because the most recently pressed key, sends key-repeat events. Using Arrow keys to switch octaves does not cause this problem, because the most recently pressed key will be an arrow key. PS. Changing Chromatic Transpose while holding keys still can lead to stuck notes. This will need a different fix. --- gtk2_ardour/pianokeyboard.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gtk2_ardour/pianokeyboard.cc b/gtk2_ardour/pianokeyboard.cc index ae508fdd7a..5a17a35ee1 100644 --- a/gtk2_ardour/pianokeyboard.cc +++ b/gtk2_ardour/pianokeyboard.cc @@ -642,6 +642,15 @@ APianoKeyboard::on_key_press_event (GdkEventKey* event) return true; } + std::map::const_iterator kv = _note_stack.find (key); + if (kv != _note_stack.end ()) { + /* key is already pressed, ignore event. + * this can happen when changing the octave with the mouse + * while playing. + */ + return true; + } + note += _octave * 12; assert (key);