I’m relatively new to JUCE and I’m attempting to work out the best way to write audio plugins (VST). The AudioProcessorValueTree based technique for managing plugin parameters looks the best and works well for Sliders, using the createAndAddParameter in the AudioProcessor class and the AudioProcessorValueTreeState::SliderAttachment in the AudioProcessorEditor. It appears to not be as convenient when using comboBoxes however. I was expecting that the AudioProcessorValueTreeState::ComboBoxAttachment would populate the ComboBox components, but it doesn’t. Is this intended behaviour or am I missing something here? Do I need to populate the comboBox myself?
I think the problem is, that the ComboBoxAttachment only connects an AudioProcessorParameter to the combo box. But the parameter has no information, of how the options in your combobox are named. It only knows of the variable that is connected to the host, the parameter. And for the host it is a simple scalar value.
So yes, you will need to populate the combobox yourself.
You can inherit a ComboBoxAttachment and override the constructor to accept a StringArray and set them as options in the combobox. That’s a nice exercise…
If you don’t want to connect to an automatable parameter but to any other value stored in the AudioProcessorValueTreeState’s ValueTree, then you can checkout the construct I used here: https://github.com/ffAudio/ffGuiAttachments
It populates a combobox with the options given as nodes in your ValueTree.
Thanks for the example @daniel!
But I came to this discussion looking for examples of the AudioProcessorValueTreeState::ComboBoxAttachment usage, to keep a CombBox sync’ed to a parameter the “ValueTree” way. It still isn’t very clear for me how that would work, could you please advise?
well, it works the same as the other attachments.
Here is a tutorial that explains how to create attachments. Just you use a ComboBox instead of a Slider and a ComboBoxAttachment instead of a SliderAttachment.
Let me know, if you get stuck in the tutorial.
Thanks again for the attention @daniel!
I was aware of the tutorial, I could make it work with a similar approach
parameters.createAndAddParameter ("list", // parameter ID "List", // parameter name String(), // parameter label (suffix) NormalisableRange<float> (0.0f, 5.0f /*list size*/, 1.0f), // range 0.0f, // default value nullptr, nullptr);
I just have to keep the ComboBox index consistent with the parameter value. I was thinking that might be a legitimate way to use a AudioParameterChoice-like parameter.