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 just came across this because a user reported that one of our plugins loads the wrong preset on program changes. It seems like the issue is not fixed, here is what happens:
But the normalised value Iām getting seems to be normalised using the Standard Program Change range (0-127). So finally when setCurrentProgram() gets called in my processor I end up with a Program multiplied by 2.
Whoās to blame? Either Ableton sends the wrong normalised value (but according to the standard MIDI Program Change messages are 0-127) or JUCE handles it wrong?
BTW in Reaper everything works fine but Reaper seems to check for the number of programs and normalises based on that number.
Look at the code snippets I linked above, it happens in the denormalise function, which is here to exact:
And info.stepCount is set here:
letās say you normalise a value of 1 using 128 programs ā 1/128.
Now you denormalise using 256 programs ā 1/128 * 256 = 256/128 = 2.
So it looks like either the value is not correctly normalised (using 128 programs) because Ableton doesnāt check how many programs a plugin has and just uses the MIDI standard - or JUCE doesnāt correctly denormalise it in this case. In any case it doesnāt work as expected
I think you are getting me totally wrong here: Iām asking for either Ableton to correctly normalise the value or JUCE to correctly denormalise it. Iām not expecting it to work this way. Yes, at the moment there are gaps because it is not correct.
The only thing I can do to fix this is returning 128 in getNumPrograms() (and handle the presets accordingly). But there is nothing about that in the JUCE documentation and everyone who is overriding getNumPrograms() and returning anything else than 128 will get bit by this!
There is no mathematical solution to this. There is no way to fix reality with code. You canāt map 0-127 to 0-255 without having gaps. Itās impossible.
You claim itās because Ableton or JUCE donāt convert values correctly, so Iām asking you again how a formula can map something from one discrete range to a larger discrete range without having gaps?
Weāve all been on the same page from the start here: mapping 0-127 to 0-255 without gaps simply isnāt mathematically possible. My question was never about āfixingā that, but about who is doing what: is Ableton sending a value normalised to 128 while JUCE assumes numPrograms, or is JUCEās VST3 wrapper making an incorrect assumption about how the host normalises program changes? In other words, Iām trying to figure out whether this is a JUCE-side issue or simply undefined behaviour that every host handles differently.
I have a feeling itās the latter and in this case this should be documented so others donāt end up in a discussion here.
Thanks for the clarification and for the pointers ā understood.
I can see this thread is tightly scoped around a specific JUCE/VST3 behaviour, and my broader line of questioning sits outside that boundary. I didnāt intend to derail the discussion.
Iāll step back here and keep any follow-up exploration framed in a more appropriate context elsewhere. Appreciate the time and input.