From f7caba5295680e713c45849a7b97654ac3123281 Mon Sep 17 00:00:00 2001 From: Bruce Brown <1st-BrainStormer@users.noreply.github.com> Date: Sat, 20 Jan 2018 11:17:47 -0800 Subject: [PATCH] de-bounce Midi::USBchanged signal. Debounced USBchanged signal to prevent pauses. --- interface/src/Application.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4b96bc2f2e..3cfa5338ba 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -503,7 +503,13 @@ public: } if (message->message == WM_DEVICECHANGE) { - Midi::USBchanged(); // re-scan the MIDI bus + const float MIN_DELTA_SECONDS = 2.0f; // de-bounce signal + static float lastTriggerTime = 0.0f; + const float deltaSeconds = secTimestampNow() - lastTriggerTime; + lastTriggerTime = secTimestampNow(); + if (deltaSeconds > MIN_DELTA_SECONDS) { + Midi::USBchanged(); // re-scan the MIDI bus + } } } return false;