Parameter Display: rounded / truncated for precision

I want to add a Parameter Display view and let it show the control tag value but truncated or rounded to a specific number of decimal points. I was thinking value-precision would set just that but it doesn’t seem to have any effect. What’s the proper way to do that?

The value-precision is overwritten when you use the VST3Editor class. In that case you need to make sure that the Parameter in your VST3 plug-in does this truncation for its string representation.

Which class should I use instead of the VST3Editor class for this to work?

You need to change your parameter class, not the UI. Make sure that the string display of your parameter the generic editor is as you want.

1 Like

@clwe found it:

parameter->setPrecision(0);
	parameter->toString (valueNormalized, string);

yes, for those having the same question – you need to override the getParamStringByValue() method in your VST3Editor-derived controller class, e.g. like so:

tresult PLUGIN_API getParamStringByValue (ParamID tag, ParamValue valueNormalized, String128 string) SMTG_OVERRIDE {
    if (Parameter* parameter = getParameterObject (tag))
	{
        parameter->setPrecision(0); //  <-- set precision here
		parameter->toString (valueNormalized, string);
		return kResultTrue;
	}
	return kResultFalse;
  }

Thanks!

Actually you do this at the time when you create the Parameter, not when you change the value of it. That’s at least more efficient.

1 Like