Programs-Parameter doing wired stuff

For me this looks like a bug in JUCE.
I tried to connect my own presetsystem with the inhouse presets of vst3 and au. So that presets can be triggered from the daw and that the name of the plugin is the preset name. If I load the plugin in DAWs like Logic or FL-studio and use their preset system evrything works fine.

But if I try it by using the program-parameter at the end of the plugins parameters, wired stuff happens, wrong presets are trigged or in same case it even crashes the plugin.

While searching for the error I found that it seems that the program-parameter is sending wrong values.

Here my testingcode for the program functions:

int currentPreset = 0;

int DuckAudioProcessor::getNumPrograms(){
    return 5;
}
int DuckAudioProcessor::getCurrentProgram(){
    return currentPreset;
}
void DuckAudioProcessor::setCurrentProgram (int index){
    DBG("setProg");
    DBG(index);
    currentPreset = index;
}

If I now move the slider I get the following values:
1 2 4
moving back to start gives a 0
so it jumps immediately to 4 from to and for the last position it dosen’t give a value at all.

Which version of JUCE are you using? I fixed an issue to do with program parameter normalisation here:

If you’re seeing the issue on develop, please provide the set of steps you are following to trigger the issue. In particular, we will need to know the plugin format you’re using, the host, and ideally the operating system too. We’ll also need to know how you’re updating the program parameter, e.g. from a control in the host, or from a control in your plugin.

I use 6.1.2 Master branche on Mac OS 11.6.
I tried it in Ableton, GarageBand, FLStudio and AudioPluginHost. GarageBand (AU) and FLStudio(AU and VST3) had now issues, as I could trigger it from the DAWs menu.
In Ableton (VST3) and AudioPluginHost (VST3) I updated withe programs-parameter in the parameterlist (not from the gui)

I tried your fixe, but it still skips numbers.

Thanks, I can reproduce the issue.

This should now be fixed on develop:

Tried it and so far it seems to work as expected :+1: