"Linking" an AudioProcessorParameter to a GUI Component

Once an AudioProcessParameter (i.e. AudioParameterInt) is linked to the audio processor with addParameter, users can modify the parameter in realtime using their host. With my GUI components, I can modify this parameter when the user changes the GUI component by assigning a listener to the component (i.e. sliderValueChanged) and setting the parameter’s value there.

If the user modifies the parameter in realtime in their host, the GUI component is not updated to reflect the current value as the component has no idea the parameter updated. I could not find a way to listen for specific audio parameter changes.

Is there a straightforward way to assign a AudioProcessParameter to a GUI component, and have changes work and update both ways?

You may find the SliderParameterAttachment, ComboBoxParameterAttachment, and ButtonParameterAttachment classes from JUCE 6 useful. There’s also a ParameterAttachment type which you can use to implement connections to custom GUI components.

1 Like

Hi reuk, I can’t find any information about ComboBoxParameterAttachment. Is there any document I can refer to? I use the old combobox attachment in JUCE 6, but there’s a bug. When I chose the first and the second item, the parameter was 1 when I use
modeAttachment = std::make_unique<AudioProcessorValueTreeState::ComboBoxAttachment>(processor.treeState, "mode", distortionMode);

There’s an example of how the ComboBoxParameterAttachment can be used in the DSPModulePluginDemo, included in examples/Plugins in the JUCE 6 repo. I was unable to repro the indexing issue inside this demo.

JUCE 6 was just released, so now the attachment types now exist. Though, where is type ParameterAttachment? I don’t see it in the documentation. I was hoping to use it for some custom GUI components I have.

Not sure what you are looking for, but this is what you asked for - https://docs.juce.com/develop/classParameterAttachment.html

Ahh, that is it. Thank you!