now, i’d like to change this range based on a module’s bool value (such as isLowerRange), setting the range from -4 to 0 octaves.
i know Rack doesn’t support param Min/max value change. So a way could be set Min/max normalized to 0/1, and rescale accordely on DSP code due to that bool param.
but what about display value? which are the base/multiplier/offset values (which I’ll set on step() function, ModuleWidget, when isLowerRange change) to set keeping the display in hz from normalized values?
with actual configParam i don’t find a possibile solution (but maybe its my fault and you know). or perhaps i just need to subclass ParamWidget and implement a switch case (but if necessary; better kept with actual code).
well, i prefer to delegate correctly the scaling on ParamQuantity, instead of force it to a fixed value.
also, a user can insert a value from interface, so it must to scale correctly based on actual range.
this is basically the function that will be applied, but i’m not able to think a way to rescale v before v = std::pow(displayBase, v) (which is what should be done I believe…).
Not with frequencies, however I recently went down the “change min/maxValue” rabbit hole scaling my min/maxValue based on a context-menu. It worked fine while running the patch, however when later loading the patch it would scale the values once again.
For a module I needed an attenuate knob to change is range between -1/1, -2/2, -5/5 and -10/10 based on context-menu. For this struct I left the actual mix/maxValue range to -1/1 and then I simply scale input/output-values in getDisplayValue (the one shown in tooltip/and populating the entry field when you right-click the knob) and setDisplayValue (the one converting the entry-value when accepting the input after right-clicking).
To change the (logical) range I simply call setRange, which also updated the “name” of ParamQuantity, so it shows the correct “range” when the user hoovers the mouse ouver the knob. In your case you in stead need getDisplayValue/setDisplayValue to scale between your fysical/logical range according to freq.
Just make sure to serialize the value of use_alt_range in dataToJson/dataFromJson. You’ll need to call updateParamScaling() from your context menu item, and in dataFromJson to make sure it loads correctly.
Edit: I originally put in random values here as an example, but I edited them to use the real values.