Calling a PluginProcessor method from a GUI component


Hello everybody!

I have a midi -sequencer like GUI where single notes can be drag’n’dropped to manipulate real audio data in my model. The GUI notes are represented by juce::Component’s. After a drag they call a PluginProcessor member function (changeNote) which manipulates the data in the model.
Now I tried this in the GUI note’s mouseUp method:

[code]void GraphicNote::mouseUp(const MouseEvent& event){

Point<int> sequencerDimension;

	->changeNote(noteNumber, this->getPosition(), sequencerDimension);


This looks totally ugly and the NewProjectAudioProcessor::changeNote method can’t access PluginEditor’s members. But without the casts I can not call the specific methods I need.

How would I elegantly do this? (I’m a beginner and try to implement the Model-View-Contoller pattern we were taught at University)



It’d be a bit easier to pass a pointer to the AudioProcessor to the constructor of the AudioProcessorEditor. I think an IntroJucer generated plugin project does this by default:

NewProjectAudioProcessorEditor::NewProjectAudioProcessorEditor (NewProjectAudioProcessor* ownerFilter) : AudioProcessorEditor (ownerFilter)

You’ll want a pointer of the derived type instead, so add a member variable of type NewProjectAudioProcessorEditor* and initialise that with ownerFilter. You can then pass this to any child components as they’re constructed.

Now, this will let you access NewProjectAudioProcessor but you will have to be careful of concurrency. Take a look at this post and think about it in the reverse direction.