Feb 032009
 

IParam allows you to set special labels at particular values of your parameter’s range. For instance, you could have a volume fader that goes from 0dB at the top to -96dB at the bottom. What if instead you want the bottom to be muted and show “Mute” or “-oo” instead? Here’s how.
Set up your parameter’s extents and the special value as follows:

    GetParam(0)->InitDouble("Output", 0.0, -96.0, 0.0, 0.1, "dB");
    GetParam(0)->SetDisplayText(-96.0, "Mute");
  • Line 1: Initializes parameter zero as a double having range from -96.0dB to 0.0dB in 0.1dB increments.
  • Line 2: Whenever the control is at the bottom, display “Mute” instead of “-96 dB”.

However, the default IPlug implementation (as of WDL v2008.11.15) will display “Mute dB” when at the minimum value. This is undesirable so here is how to keep the output from showing the unit label when displaying a custom value. The value to display and the label for the units are looked up in two entirely different places due to the way the VST SDK is implemented. We need to key in on the lookup function for the label, returning an empty string when we don’t want the label included.

The default implementation:

const char* IParam::GetLabelForHost()
{
    return mLabel;
}

The NEW and IMPROVED implementation:

const char* IParam::GetLabelForHost()
{
    const char* displayText = GetDisplayText((int) mValue);
    return (CSTR_NOT_EMPTY(displayText)) ? "" : mLabel;
}

Now your vst plugin’s parameter will display its normal range of values with the label and special values without the label.

Possible improvements:

  • Allow the behavior to be toggled with a flag on the parameter:
    GetParam(0)->mShowLabelWithText = false;
  • Allow the behavior to be toggled with each registered special value:
    GetParam(0)->SetDisplayText(-96.0, “Mute”, false);
    GetParam(0)->SetDisplayText(0.0, “0.0”, true);
    (by default the parameter will not display trailing zeroes)

That gives me an idea for another IPlug mod, allowing the display of trailing zeroes!

VST plugin development is fun!

Sorry, the comment form is closed at this time.