Hi
I’ve been trying to find the best and cleanest way to change the range and interval (or snapped values, but I will keep using the word interval for simplicity here) on a slider and/or associated parameter, but I am struggling right now. Every approach I try seem to have its own drawbacks and complications.
The simplest approach would be to have different sliders/params for each range I want to address, and show/hide them when required, but I want to be able to have any combination of ranges and intervals, making this approach unpractical (eg frequency ranges, chromatic interval with any given A reference, etc.).
The second obvious approach is to keep the parameter on the largest possible range and continuous interval, and only change the slider interval and range, but this does not play too well with normalized ranges (eg frequency slider with a log progression), and also means that the parameter itself can still be internally (or through automation) be set to a value that does not correspond to the interval and/or range. This also means that the string representation has to be handled elsewhere (eg notes when a chromatic interval is chosen for a frequency slider) rather than taking it directly from the attached parameter (eg note for a chromatic frequency interval).
The third approach is to modify the parameter directly by changing the values returned by the from0-1/to0-1/snap lambdas from the normalized range constructor, as well as lambda returning the string representation. With this approach the initial range has to be set to something arbitrary (eg [0.0, 1.0]), meaning getMinimum()/getMaxium() cannot be used on the attached slider.
This seems like a clean approach and works appropriately, but I am afraid this could fail with some DAWs or wrappers.
I even tried another approach with a “proxy” parameter based on the real one but with a restricted range and interval and a specific string representation. The slider is re attached to a new proxy parameter each time the range/interval is changed.
I tried all these approaches (and then some even more obscure), each implying a large rewriting of my code, and I seem to have lost track (and faith) along the way: I am getting nowhere and need some guidance
Ideally I would want to have the parameter reflect the current state of the range and interval, with no way of setting a parameter in an “illegal” value, but I can live without that.