UPDATE: It might be appropriate to move this to the Linux section. I compiled the same code under WinXP and the problem was gone. So it is a Linux specific problem with the keyboard handling. I checked out juce_linux_Windowing.cpp file, in an attempt to figure out the problem, but it has 2500 lines of code and is way over my head as of now…
I am trying to use the MidiKeyboardComponent together with MidiKeyboardState. I added handleNoteOn and handleNoteOff functions to my class which derives from MidiKeyboardStateListener. In those functions I (obviously) send out midi note on/off messages.
My problem is that when I hold a key on the computer keyboard, it triggers multiple note on/off messages (strangely, note offs are also triggered). I.e. handleNoteOn and handleNoteOff both are triggered multiple times (same as repeating letters when you hold down a key). I expected that when I hold down a key, only handleNoteOn is called, and when I release the key, handleNoteOff will be called.
Any ideas? What am I doing wrong? I thought the MidiKeyboardState class could handle stuff like this … Otherwise I will use a map or set to keep track of which keys are down to avoid triggering multiple noteon/offs. The whole code is here, if you want to take a look: http://virtual-midi-keyboard.googlecode.com/svn/trunk/main.cpp
I’m using Juce 1.40 under Linux.