How can my program know which MIDI note he got?


Hello,I have recently started with JUCE and it was love at first sight,at least from my point of view.
I’ve tried to find and read as much articles,posts and blogs to solve my problems,but now I am stuck.I plan to make a 16-pad drum plugin,I have made a nice GUI for start ,but I don’t know how can I make for my drum pad(Image button in this case) to be pressed down automatically when plugin receives specific MIDI note and with that the sound bound to that button to be played?

Thank you in advance for any help.


subclass MidiInputCallback.

When the callback is called, that’s where you’ll modify your drumpad. Be advised that you can’t modify gui stuff from a thread other than the Message thread, so you’ll need to use either a MessageManagerLock or also subclass AsyncUpdater and use the handleAsyncUpdate() callback to do the GUI changes. aka:

class MyClass : public MidiInputCallback, public AsyncUpdater, public Component {...}

void MyClass::midiInputCallback( const MidiInput* input, const MidiMessage& message ) {
    if( message.getNoteNum() == someNum ) {
        somePropertyValue = ... ;//this needs to be a class member so handleAsyncUpdate can read it


void MyClass::handleAsyncUpdate() {