Lately I’ve been trying to figure out the best way of giving objects access to other objects:
In the audio plugin demo, there exists a private method (it’s also inlined) that acts as an accessor to the AudioProcessor object:
JuceDemoPluginAudioProcessor* getProcessor() const
{
return static_cast <JuceDemoPluginAudioProcessor*> (getAudioProcessor());
}
This allows getAudioProcessor() to be called whenever a pointer to the AudioProcessor object is needed, right?
What is the advantage of using getAudioProcessor() over having a member variable (such as m_pAudioProcessor) that is set to AudioProcessor upon construction?
Also, as a side question, I’ve noticed that when creating a new audio plugin project via the Introjucer the PluginEditor.cpp is not editable via the GUI editor (in the Introjucer). I’ve ended up right clicking and selecting “Add New GUI Component”, and then using the addAndMakeVisible method in PluginEditor.cpp:
[code]CrossroadsAudioProcessorEditor::CrossroadsAudioProcessorEditor (CrossroadsAudioProcessor* ownerFilter)
: AudioProcessorEditor (ownerFilter)
{
// This is where our plugin’s editor size is set.
//setSize (800, 800);
MainComponent* m_pMainComponent = new MainComponent();
addAndMakeVisible(m_pMainComponent);
m_pMainComponent->setAudioProcessorParent(ownerFilter);
m_pMainComponent->setGainChange(&(ownerFilter->m_GainChange));
setSize(m_pMainComponent->getWidth(), m_pMainComponent->getHeight());
}
[/code]
(Also I know there is a much more elegant RAII method of doing this, but I haven’t quite gotten there yet)
Is there a way to be able to use the GUI editor on PluginEditor.cpp without having to add an extra header & source file?
Many many thanks in advance!
Cheers,
Muir