Binding a variable to default parameter value

Is there a way to bind a variable to the default value of a parameter?
just like this:

configParam(VOLT_PARAM, -10.f,10.f, oneVoltDefault, “Volt”, “v”);

I would like to change the default value via context menu,
I tried but it doesn’t work, maybe because its value is locked on init?


    // in your Module subclass:
    engine::ParamQuantity* pq = getParamQuantity(SOME_PARAM);
    pq->defaultValue = myNewDefaultvalue;

You’d want to load and save this custom default value in the json, so that the user wouldn’t have to change it every time.

1 Like

It’s generally considered a bad design to have the default value change. But if that’s what you really want to do…

This would be the application:

The knobs act as attenuverter if CV inputs are connected, or give a fixed voltage if unconnected.
I think It would be helpful too set the appropriate usage default

1 Like

I don’t quite understand. could you explain more?

The module it’s an adder like shown. Using the switch it adds or subtracts cv inputs (attenuverted by knobs) to the first output connected from top to bottom. If cv input is not connected a fixed voltage (set by the same knob) is given to be added or subtracted in the same way.

When the knob is acting as an attenuverter you could want to have the default to 0 or maybe to +10 (100%), just to have a quick command for it. If the adder is used to change the pitch by octaves you could want to have your knob default set to +1

I think I would want the default to be zero in both cases. That’s a simple yet conventional solution.

I imagined it to be used in live performing, to reset to a specific pitch voltage after an eventual (intentional or not) detuning. It’s just a double click instead of: right click, digit voltage, enter.

Unfortunately this solution increases by 0.1% the Cpu load… But… Am I placing the code in the right place?

1 Like

To minimize CPU, one pattern is to do this parameter manipulation at some control rate than sample rate. The logic is that human interactions happen at a much lower rate than audio.

This can be as simple as counting samples and updating parameters every n samples (32 or 64 are common). I use one that lets me set the control rate by time (invariant to sample rate) rather than sample count (time changes based on sample rate), but there’s more plumbing to get that hooked up.

Another option is to make your knobs also pushbuttons that when pushed, memorize the “return” value. This I can imagine in a physical module.

I have a knob implementation that enables click actions per knob (with a callback) or step-click to increment/decrement by some defined step, if you want to see how clicky knobs can be implemented.

1 Like

I’ll try, thanks