How to limit one parameter from another parameter?

In a plugin I am writing, I have two parameters that can take any value in the range [0.0f,1.0f]. But I want P1 to also be limited to the range [P0,1.0f]. In other words, P1 cannot be less than P0. What is the best way to do that? I don’t see a snapValue function pointer in the AudioProcessorValueTreeState::createAndAddParameter() function, and even if there was one, I also don’t see how I could access another parameter from a function that is defined (currently, at least) as a lambda function when defining each individual parameter.

There is also the issue that I’d not only need to restrict P1 to >= P0 when P1 is changed, but also restrict P0 to <= P1 when P0 is changed. I do not want to automatically change the other parameter, but merely restrict the current parameter according to the other’s current value.

(Which also brings up the sticky issue of what if the user simply draws some automation that violates these restrictions. The order in which they change via automation may even differ between hosts, so who would win? Another issue for another day, sorry.)

So… what is the preferred method for dynamically restricting the range of a parameter based on another parameter’s current value?

I suppose that I could de-couple the parameters from their dsp code, and limit the values used in the DSP instead of limiting the parameters themselves? I could allow them to move the sliders all the way up/down, but show the limited values in the UI so they can see the limit takng place? That might work better, actually, although users might not get it at first glance.

Yeah, that’s the way. You can also store P1 as an offset of P0.

you could just let the values be interpreted the other way around when the 2nd parameter is below the first one’s value. or you let the parameters go that far at all times, but the gui just shows that it makes no sense, like when the freq response curve of an eq goes to silence when low- and highcut overlap