Hello,
I am trying to have a slider which clicks between 0 and 7 make visible one of eight groups of six sliders. These sliders will all control parameters for the comb filters in the built-in reverb module. 0 selects group 0, 1 selects 1, and so on… these sliders are all added to a flexbox (two actually). At the moment it seems the flexbox will properly display the banks just by toggling their visibility, but I haven’t fully tested that.
My main problem right now is understanding how to attach a GUI listener to the parameter changing. I created a SliderAttachment like so:
AudioProcessorValueTreeState::SliderAttachment combIDAttachment;
// And these are my other variables...
AudioProcessorValueTreeState& valueTreeState;
LabeledSlider combID;
I called it in my editor’s initialization list like so:
combIDAttachment(valueTreeState, "combID", combID.getModSlider()),
All well and good. However I then go to create the callback:
combIDAttachment.onParameterChanged = [this]() {
for (int i = Constants::Parameter::combIDStart;
i <= Constants::Parameter::combIDEnd;
i += Constants::Parameter::combIDInterval)
{
DBG("combID parameter changed callback");
// I need the new value of combID, but I don't know how it's passed in
// Call it "newValue"
float newValue = 0;
bool visible = (i == static_cast<int>(newValue) ? true : false);
combTap[i].setVisible(visible);;
combDampingL[i].setVisible(visible);;
combDampingR[i].setVisible(visible);;
combFeedbackL[i].setVisible(visible);;
combFeedbackR[i].setVisible(visible);;
}
}
And I’m warned that onParameterChanged
does not exist; of course looking at the SliderAttachment documentation, it’s true.
This leads me to the ParameterAttachment class reference which leads me to think I may be totally on the wrong path.
The AVPTS tutorial shows you how to add attachments - of the Slider and Button type, not Parameter - but it doesn’t show you how to add a callback.
I see of course the function callback is simply a parameter in the ParameterAttachment constructor, but is that the right attachment to use? I have read a few forum threads on issues with both types, but frequently people don’t even include the callback code snippets…! Is there something obvious I’m missing?
Thank you