Too many decimal places displayed

I have a widget adjusting gain levels of a plugin. This particular parameter displays 8 decimal places. WAAAY too many. I’d like to just display 2. How would you go about shortening it? I have been trying to mess around with the DoubleToString but haven’t been able to make it work. Thanks!

DoubleToString(1.0/3.0, 2) results in 0.33

What is the issue you have?

Where did you put that? Would you mind putting this in a simple script for a knob widget that is displaying the large decimal parameter?

It’s the plugins’ responsibility to provide the correct ‘pretty’ display string. If the developer just let the default handler do the value-to-string translation, you get the raw float value.

If you connected a widget directly to the plugin-parameter and an incorrect value (from a user’s point of view) is displayed, I consider that a bug in the plugin (and it should be reported to the developer).

If you’re using scripting then it becomes your responsibility (you could use this GP script function for getting the string-representation of the current value of a parameter: GetParameterText(p, index))

Sure, you’re technically correct, it’s a new release of a plugin I love and this may likely be improved in the future, but it doesn’t help me right now.

Here is a solution that ended up working:

Var
   InValue : Widget
   rounded : string
   x : string
   xVal : double

On WidgetValueChanged (newValue : double) from InValue
    x = GetWidgetMappedParameterValue(InValue)
    xVal = StringToDouble(x)
    rounded = DoubleToString(xVal, 2)
    SetWidgetLabel(InValue, rounded)
end

Here is another (bit more “manual”, but simpler) work around:

Var
   InValue : Widget
   rounded : string
   x : double

On WidgetValueChanged (newValue : double) from InValue
    x = newValue * 48.0 - 24.0   // adjust to your actual param range. Mine is -12 to +12
    rounded = DoubleToString(x, 2)
    SetWidgetLabel(lblVal, rounded)
end

I wanted to solve this, b/c honestly, there are many plugins that have too many decimal places when values are displayed. I would love to see if there are better ways to do this! :slight_smile:

Of course :grinning_face:. But if the developer doesn’t know it’s an issue, they’re never gonna solve it.

So here is exactly what is happening. There are two functions that developers have to implement as part of their plugin for this.

The first is a function that returns a host parameter a floating point value between 0.0 and 1.0, which is essentially the underlying representation for all host parameters.

The second is a function that returns a string representation of that function and the developer has two choices. Suppose for example the developer is exposing a filter cutoff parameter whose range is nominally from 20Hz to 20,000Hz.

Ideally, to implement that string representation they would have a conversion function which would be applied to that underlying 0.0 - 1.0 floating point value that would return a string representing a frequency in Hz. However, if they don’t (bother), they can just return a string representation of the underlying value and that is why you sometimes see those 8 digit decimal numbers.

That said, as others have observed, it really is up to the plugin developer to return “useful” values so I would encourage you to report the problem to the developers.

We will put this on our tracking system for a possible improvement in a future version.

In the meantime, as others have also pointed out, your issue can be solved with GP Script

Awesome! Yes, I had already created the script(s) I shared above. Thanks