Configuring custom parameter display in v1

I quite like the new param config mechanism.

Some of the knobs in my modules use custom tapers. For example, when the user turns a DURATION knob, my modules apply a custom taper to compute the duration.

The custom taper means that I can’t use the param configurations’ built-in linear/exponential mappings.

I would like to make sure the knob rotation and the display value always correspond. Given the knob rotation, I can compute the corresponding duration. Given a duration, I can compute the corresponding rotation.

When the user turns the knob, how can I set its display value to reflect the computed duration?

When the user enters a duration via the keyboard, how can I set the knob’s rotation to reflect the computed rotation?

It’s not obvious to me how to do this. If it’s possible, I’m sure I can figure it out eventually. I’m not sure I can figure it out before v1 launches.

You could make your own ParamQuantity subclass, override

	float getDisplayValue() override {...}
	void setDisplayValue(float displayValue) override {...}

and use

configParam<MyParamQuantity>(...);
2 Likes

Got it. The remaining thing for me to figure out is what event is generated when the user types a value. But you’ve narrowed the search enough that I think I can find that on my own.

Thanks!

When a user types a value for a ParamWidget? No event is generated. But setDisplayValue is called which allows you to call setValue after transforming the value.

1 Like

Okay. That helps. Thanks!

This seems related enough to not warrant a new thread: is there a graceful way to remove the value entry field from a ParamWidget’s context menu?

No

Hi @Vortico,

thanks for this suggestion!

But… what if I want to have a custom subclass that return values due to a range? I mean, I have my configParam<Division>(...); param knob that display division on this range:

 "1/2d", "1/2", "1/2t", "1/4d", "1/4", "1/4t"

Another time, I just need different ranges, such as:

 "4", "3", "2", "1", "1/2d", "1/2", "1/2t", "1/4d", "1/4", "1/4t", "1/8d", "1/8", "1/8t", "1/16d", "1/16", "1/16t"

For the same subclass, of course. How could I pass a custom “array” to my subclass by template?

I don’t see any way. Also, configParam is void, doesn’t return TParamQuantity (which could be used to point to my array).

Any clue? Thanks

In Rack v2, configParam returns the TParamQuantity. In Rack v1, you can use

dynamic_cast<TParamQuantity*>(paramQuantities[PARAM])

Rack v2 also has SwitchQuantity (Rack development blog) but in Rack v1 you have to write your own ParamQuantity subclass.

1 Like