Hey all,
Since updating to the latest JUCE, a plug-in that was previously working is now throwing assertions whenever a GUI element is moved, with the comment next to the assertion being “called with an out-of-range parameter index!” (line 222 of AudioProcessor.cpp). The same error is thrown with line 244. (ending the gesture).
There are two things I did that lead to this starting to happen- I updated to the latest JUCE, and rebuilt the plugin host. I unfortunately no longer have the prior host.
Is this perhaps due to how I’m handling my AudioProcessorValueTreeState? I’ve included what should be the relevant code below, but I’m at a loss:
In the processor-
const int ISWTestPluginAudioProcessor::NUMPROCESSORPARAMS = 3;
String ISWTestPluginAudioProcessor::processorParamArray[] = {"drygain", "wetgain", "stereomode"};
ISWTestPluginAudioProcessor::ISWTestPluginAudioProcessor()
{
mUndoManager = new UndoManager();
mState = new AudioProcessorValueTreeState(*this, mUndoManager);
initParams();
mState->state = ValueTree("ISWTest");
}
ISWTestPluginAudioProcessor::~ISWTestPluginAudioProcessor()
{
//ScopedPointer objects take care of deletion
mUndoManager = nullptr;
mState = nullptr;
}
void ISWTestPluginAudioProcessor::initParams()
{
//I/O processor parameters
mState->createAndAddParameter(processorParamArray[0], "Dry Gain", "Dry Gain", NormalisableRange<float>(0.0, 4.0, 0.0, 1.2), 0.75, nullptr, nullptr);
mState->createAndAddParameter(processorParamArray[1], "Wet Gain", "Wet Gain", NormalisableRange<float>(0.0, 4.0, 0.0, 1.2), 0.25, nullptr, nullptr);
mState->createAndAddParameter(processorParamArray[2], "Stereo Mode", "Stereo Mode", NormalisableRange<float>(0, 3, 1), 0, nullptr, nullptr);
//Add appropriate listeners for each parameter
for(int i=0; i<NUMPROCESSORPARAMS; i++)
{
mState->addParameterListener(processorParamArray[i], this);
AudioProcessorParameter* tempForInit = mState->getParameter(processorParamArray[i]);
tempForInit->setValue(tempForInit->getValue()); //setValue so that listener is updated
}
}
void ISWTestPluginAudioProcessor::parameterChanged(const String ¶meterID, float newValue)
{
if(parameterID == "stereomode")
{
stereoMode = int(newValue);
}
else if(parameterID == "drygain")
{
dryGain = newValue;
}
else if(parameterID == "wetgain")
{
wetGain = newValue;
}
else
{
//cout used here for troubleshooting- not lockfree!!!!
//should never occur in finished product; replace with exception/assertion
std::cout << "Unknown processor param change: " << parameterID << std::endl;
}
}
And then in the Editor-
ISWTestPluginAudioProcessorEditor::ISWTestPluginAudioProcessorEditor (ISWTestPluginAudioProcessor& p)
: AudioProcessorEditor (&p), processor (p)
{
gui = ISWGUI::getInstance();
//Processor Controls
sliderStereoMode = gui->addKnob(Colour(0,0,0), Colour(0,0,0), this, float_Pi*5.0/4.0, float_Pi*11.0/4.0, true);
sliderDryGain = gui->addKnob(Colour(0,0,0), Colour(0,0,0), this, float_Pi*5.0/4.0, float_Pi*11.0/4.0, true);
sliderWetGain = gui->addKnob(Colour(0,0,0), Colour(0,0,0), this, float_Pi*5.0/4.0, float_Pi*11.0/4.0, true);
//Make all Slider objects visible
for(int i=0; i<gui->getNumSliders(); i++)
{
addAndMakeVisible(gui->getSlider(i));
}
//use SliderAttachment objects to connect a Slider and a parameter
attachmentDryGain = new AudioProcessorValueTreeState::SliderAttachment(p.getValueTreeState(), ISWTestPluginAudioProcessor::processorParamArray[0], *sliderDryGain);
attachmentWetGain = new AudioProcessorValueTreeState::SliderAttachment(p.getValueTreeState(), ISWTestPluginAudioProcessor::processorParamArray[1], *sliderWetGain);
attachmentStereoMode = new AudioProcessorValueTreeState::SliderAttachment(p.getValueTreeState(), ISWTestPluginAudioProcessor::processorParamArray[2], *sliderStereoMode);
//Skewing, suffixes etc
sliderWetGain->setSkewFactorFromMidPoint(0.5);
sliderDryGain->setSkewFactorFromMidPoint(0.5);
//window size- must be set last
setSize (400, 150);
}
ISWTestPluginAudioProcessorEditor::~ISWTestPluginAudioProcessorEditor()
{
//ScopedPointer objects take care of deletion when set to null
attachmentDryGain = nullptr;
attachmentWetGain = nullptr;
attachmentStereoMode = nullptr;
//Takes care of slider deletion with internal vector of ScopedPointer objects
gui->clearGUI();
}
Any ideas as to what might be causing my issue / how to fix it?