Need help with drawing a MIDI Keyboard in my Plugin

Hello!
I am designing an audio synthesizer for my university (I guess in the US It’s called “bachelor’s degree”, basically becoming a licensed engineer) as my project. I have figured out most of the processing of my plugin, most of the features i wanted to implement from the beginning. Moving on to the graphical interface part, I really need help drawing a Midi Keyboard in the plugin that listens to my midi controller input and displays notes accordingly (I get so confused reading the docs for this, there are so many methods, a keyboard state, a keyboard state listener, a keyListener for the keyboard component class, which one do i use? how? etc.)

Thank you so much!

You need two of these classes: MidiKeyboardComponent in the editor and MidiKeyboardState in the processor.
The separation of processing (here collecting MidiMessages from processBlock()) and viewing makes it necessary.
The AudioProcessor has to expose the MidiKeyboardState by an accessor or making the state public.

In processBlock (AudioBuffer&, MidiBuffer& midi) do this:

void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midi) override
{
    midiState.processNextMidiBuffer (midi, 0, buffer.getNumSamples(), true);
    // ...
}

HTH

2 Likes

Thank you so much for your help! It works perfectly.