COptionMenu() how to bind to tag correctly

Hello there,

I’m trying to have a parameter as a drop-down menu with text items, this parameter is used in the processor directly.

I created a custom view as described here:
https://steinbergmedia.github.io/vst3_doc/vstgui/html/create_your_own_view.html

namespace VSTGUI {
class DropDownViewFactory : public ViewCreatorAdapter
{
public:
    DropDownViewFactory () { UIViewFactory::registerViewCreator (*this); }
    IdStringPtr getViewName () const override { return "Drop-Down View"; }
    IdStringPtr getBaseViewName () const override { return UIViewCreator::kCControl; }
    CView* create (const UIAttributes& attributes, const IUIDescription* description) const override
    {
        COptionMenu *dropDownMenu = new COptionMenu();
        presetMenu->addEntry("entry 1");
        presetMenu->addEntry("entry 2");
        return dropDownMenu;
    }
};
// create a static instance so that it registers itself with the view factory
DropDownViewFactory __gDropDownViewFactory;
} // namespace VSTGUI

The new view gets added to the UI description editor and I can see the entries just fine.
However, when I add the tag of my parameter in the live editor, the option menu shows the float values of the tag and not the original strings from the view factory. I’m not sure if this is the correct way to use the option menu.

My parameter is defined in the controller as follows:

Vst::Parameter* dropDown = new Vst::Parameter (
                            STR16("Dropdown"),
                            static_cast<int32_t>(ParameterId::Dropdown),
                            nullptr,
                            0.6, 
                            5,
                            Vst::ParameterInfo::kIsList|Vst::ParameterInfo::kCanAutomate
                            );

How can I bind the option menu to a parameter and keep the text labels?

Thanks!

1 Like

I just found the StringListParameter type in the note expression synth example
[vst3sdk/public.sdk/samples/vst/note_expression_synth/source/note_expression_synth_controller.cpp]

auto* filterTypeParam = new StringListParameter (USTRING("Filter Type"), kParamFilterType);
filterTypeParam->appendString (USTRING("Lowpass"));
filterTypeParam->appendString (USTRING("Highpass"));
filterTypeParam->appendString (USTRING("Bandpass"));
parameters.addParameter (filterTypeParam);

I seems the options menu works well together with this type.

A follow-up question is more generally related to the vst3sdk:

Should I use the plainParamToNormalized() function to save my string parameter in a normalized format? It seems that the option menu is returning an integer, but the ParamvalueQueue function getPoint() is returning a float formatted integer. I find the multiple formats a little confusing.

I guess the idea is to save everything normalized between 0.0 and 1.0? What’s the reasoning behind that? That would imply multiple conversions in a few different spots.

1 Like

You may want to read about Parameters in the VST SDK documentation: Parameters and Automation - VST - Steinberg Developer Help
That should give you enough information why a parameters range is 0…1.

Reading this helped, thanks! :slight_smile: