diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8b1d70e9e2..ffe2f781db 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -504,7 +504,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; diff --git a/libraries/midi/src/Midi.cpp b/libraries/midi/src/Midi.cpp index 69c35c4a20..1f190111f2 100644 --- a/libraries/midi/src/Midi.cpp +++ b/libraries/midi/src/Midi.cpp @@ -163,7 +163,7 @@ void Midi::sendRawMessage(int device, int raw) { void Midi::sendMessage(int device, int channel, int type, int note, int velocity) { int message = (channel - 1) | (type << MIDI_SHIFT_STATUS); if (broadcastEnabled) { - for (int i = 0; i < midihout.size(); i++) { + for (int i = 1; i < midihout.size(); i++) { // Skip 0 (Microsoft GS Wavetable Synth) if (midihout[i] != NULL) { midiOutShortMsg(midihout[i], message | (note << MIDI_SHIFT_NOTE) | (velocity << MIDI_SHIFT_VELOCITY)); } @@ -174,9 +174,9 @@ void Midi::sendMessage(int device, int channel, int type, int note, int velocity } void Midi::sendNote(int status, int note, int velocity) { - for (int i = 0; i < midihout.size(); i++) { + for (int i = 1; i < midihout.size(); i++) { // Skip 0 (Microsoft GS Wavetable Synth) if (midihout[i] != NULL) { - midiOutShortMsg(midihout[i], status + (note << MIDI_SHIFT_NOTE) + (velocity << MIDI_SHIFT_VELOCITY)); + midiOutShortMsg(midihout[i], status | (note << MIDI_SHIFT_NOTE) | (velocity << MIDI_SHIFT_VELOCITY)); } } } @@ -283,9 +283,6 @@ void Midi::midiHardwareChange() { Midi::Midi() { instance = this; -#if defined Q_OS_WIN32 - midiOutExclude.push_back("Microsoft GS Wavetable Synth"); // we don't want to hear this thing (Lags) -#endif MidiSetup(); }