Let’s get back to this. I was trying to get my head around this but couldn’t figure out how to use the MidiKeyboardState
inside a NON-block based application because I always face the “Midi Thru” problem. Why?
The KeyboardStateListener is used to generate Midi notes for a particular note that you may have clicked on the
MidiKeyboardComponent. That Midi note should be sent somewhere but mostly and unsurprisingly to a Midi output
device. So far so good. But if you receive a Midi note from an Midiinput, then you would normally pass it on to the
KeyboardState its processNextMidiMessage method to make the MidiKeyboardComponent acting on it (UI). Since
this will always notify the listener you will end up with the Midi Thru effect!
So from my point of view there is no better way than having a choice to notify the KeyboardStateListener or not
when you call processNextMidiMessage and of course processNextMidiBuffer.
Based on this I added a “sendNotification” argument to processNextMidiMessage and processNextMidiBuffer
and to the other internal class methods noteOnInternal and noteOffInternal.
Furthermore I added another callback to KeyboardStateListener, so called “stateChanged” that gets always
called (even if I don’t want to send a notification) and is used to force the KeyboardComponent to update.
In the hope I didn’t oversee something,
have a good one,