AudioProcessorValueTreeState::Attachment for radiobuttons/multibuttons/custom controls?

After using AudioParameterFloat/Int/Bool for my last plugin, I’ve started a new plugin using AudioProcessorValueTreeState parameters and attachments and really liking it. I love the way that using Slider/Button/ComboBoxAttachments eliminates tons of code and keeps things nice and neat. Awesome. I’m hooked.


I have a several custom controls that are multi-buttons…3 or 4 buttons that toggle between int values for controlling certain modes. I guess they act like radio buttons but look like 3 or 4 regular text buttons stacked vertically, controlling a single parameter.

I’d LOVE a way to use some sort of Attachment to handle them but I’m stumped. Anyone have any ideas?

Hi there, i’m in the same water here, and was thinking of two possible strategies.

NOTE: maybe trivial, but it’s an essential assumption for my reasoning below : it is possible to have subclasses of slider/button that display the valuetotext lambda passed in valuetreestate->createandaddparameter
(see this gist from @yairadix for a slider, it can be done for the button as well).
So the parameter <–> UI "chain” is :

Parameter <—> Attachment <—> Custom Widget using parameter Lambda for displaying text.

(strategy #1) Hacking the toggle state of a button (normally 0 || 1) and make it cycle in 1/N steps. The value to text lambda would take care of adjusting the text based on the float value of the Toggle state

(strategy #2) Hacking the “On mouse click” of the slider and having a custom LookAndFeel that makes it look like a button ( something like the incdec buttons slider style without the buttons) Mouse click would then advance the slider value (assuming a range with skew = 1 and integer steps) and some additional logic would be needed to make it cycle on the Range.
This might have the interesting property of a multi button supporting both click and drag (it’s a slider after all) so the mobile experience could be interestingly nice.

Still not decided on where to go deeper and still not a juce guru, so maybe (probably) someone has better ideas :slight_smile:

1 Like


I found this: Update AudioProcessorValueTreeState from process block which references

Which looks pretty close to what we’re looking for. Maybe there’s something to be learned there.

1 Like