How to handle dynamic choice (ComboBox) selections in audio plugins

Hi all,

I am fairly new to using JUCE and am working on writing an audio plugin. Most of it is going very well, however I need to be able to programmatically create the selection items used in a ComboBox dynamically from the plugin processor and was wondering if someone with more experience can suggest the best way to approach this using JUCE?

I have been using the ComboBox with a ComboBoxAttachment and AudioParameterChoice together for other fixed selection items, but in this case I was looking at changing what could be selected dynamically.

The use scenario is that the plugin keeps track of all the instances of it that are instantiated and allows a custom side-chain to be selected for information between two such instances (without requiring use of the DAW side chain which can be cumbersome to setup). I want to be able to select which instance to link to.

So for example, when first plugin instance is created (A), it cant select any other instances to link to. When I create a second instance (B), then B can see A in its link selection ComboBox and A can see B in its link selection ComboBox to be selected to link to. As more instances are created C,D,E etc they appear in the ComboBox as well.

I started trying to use the AudioParameterChoice since I used it for other similar things, however the first issue I had was that it didn’t seem to support an empty selection list or even a single item in the list (I guess that makes sense as there is no choice). Then I noticed the choice StringArray is const and only definable at construction time so it is obviously the wrong thing to use for this.

I assume I am going to need to work with the AudioProcessorValueTreeState directly instead and use a normal ComboBoxParameterAttachment to link the custom parameter to the ComboBox. Is this the best approach or have I missed something?


Actually as I look at this more, I think the PluginProcessor should just store a AudioParameterInt with the selected ID (not the choice index) as each selection maps to an integral ID in my use.

This means the PluginEditor needs to know how a list index maps to an ID and I think I would just need to create a custom ParameterAttachment that works differently from the standard ComboBoxParameterAttachment