JUCE/examples/audio plugin demo (question about keyboardState)

Hi,
I am studying the audio plugin demo project.
I have set up a new project using the audio plugin template.

So, in the Processor.h file, the keyboardState is a public property. And it says there is a better way to do this. So my question is, what is the better way to do it?
In the Editor, the keyboardComponent gets initialize like this: midiKeyboard (owner.keyboardState, …horizontal…)

So, when I try to make keyboardState private, and add a public getter, I get a error: call to deleted constructor. How do you make this work any other way? It seems the keyboardState has to be public, for the midiKeyboard to access it and initialize…

Thanks!

It sounds like you need to return a reference to the keyboard state e.g.,

MidiKeyboardState& getMidiKeyboardState() { return myMidiKeyboardState; }

1 Like

Oh I see. Yes I tried your suggestion and it works. Thank you!