I am trying to get access to my MPE Synthesiser from the Plugin Editor. My goal is to try to access some variables from the voices of the MPE Synthesiser from the Plugin Editor so that I can display their values in the GUI.
I thought the best way was to run a function once during each processBlock
in the processor that triggers the Editor to run look the voices and get the pertinent variables to update them in the GUI.
My main relevant structural elements are:
PluginProcessor.h/cpp
*/
class AudioPlugInAudioProcessor
: public AudioProcessor,
public AudioProcessorValueTreeState::Listener
{
private:
MPESynthesiserInherited mMpeSynth;
PluginEditor.h/cpp
class AudioPlugInAudioProcessorEditor
: public AudioProcessorEditor,
public Button::Listener
{...
private:
// This reference is provided as a quick way for your editor to
// access the processor object that created it.
AudioPlugInAudioProcessor& processor;
Here’s what I’m trying to do:
PluginProcessor.h/cpp
/**standard processBlock */
void AudioPlugInAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
const ScopedLock renderLock(lock);
ScopedNoDenormals noDenormals;
buffer.clear();
mMpeSynth.renderNextBlockCustom(buffer, midiMessages, 0, buffer.getNumSamples());
//UPDATE GUI DEBUG HERE
AudioPlugInAudioProcessorEditor* activeEditor = (AudioPlugInAudioProcessorEditor*)getActiveEditor();
activeEditor->updateDebugWindow();
}
/**return MPE Synth */
MPESynthesiserInherited* AudioPlugInAudioProcessor::getMPESynthPtr() {
return &mMpeSynth;
}
PluginEditor.cpp
void AudioPlugInAudioProcessorEditor::updateDebugWindow() {
MPESynthesiserInherited* mpeSynthPtr = processor.getMPESynthPtr();
int numTotalVoices = mpeSynthPtr->getNumVoices();
//access the voices and get the variables so can display them on GUI
...
So in other words, as I understand it, AudioPlugInAudioProcessor
automatically creates a PluginEditor
which I can then access from the processor via getActiveEditor()
. This seems to work okay, because I am able to successfully trigger the Editor’s updateDebugWindow()
in the processor from the processBlock
.
However, the updateDebugWindow
function in the editor is not able to access the MPESynth to get the data I want from it. I keep getting “Exception thrown: read access violation.
this was nullptr.” at the line MPESynthesiserInherited* mpeSynthPtr = processor.getMPESynthPtr();
I am not sure why this is.
I am not the best at transferring and accessing data between classes like this. Is there something obvious I am doing wrong? Is there a more appropriate way to get some variables out of my MPESynth & its voices for displaying in the GUI?
Thanks for any help. Given my weakness in this domain, if you can be specific it will likely help. ie. Please talk to me like I know nothing because it’s likely not far off.
Thanks