When one of my UI components gets notified via a parameter listener on a change on a ComboBox, the value I read from the tree state is outdated.
I have a tree parameter, representing a choice, declared like this (getOptions
returns a StringArray):
layout.add(std::make_unique<juce::AudioParameterChoice>("WaveShapeFunction", "WaveShapeFunction", getOptions(), 0));
Now one of my UI components subscribes to this parameter via a listener:
for (auto param : audioProcessor.getParameters()) {
...
if (param->getName(64) == "WaveShapeFunction") { param->addListener(this); continue; }
}
void Component::parameterValueChanged(int parameterIndex, float newValue) {
... // in practice, it's a call back to the Processor to get the tree state value
... // I've condensed it here into one line
value = apvts.getRawParameterValue("WaveShapeFunction")->load();
DBG(value);
}
Listening itself works, but the value got is always one selection behind.
So the “standard” selection is 0.
I select 4, output: 0
. I select 2, output: 4
.
I’ve completely wrecked my brain by now, does anyone have an idea?