Best practice for radio buttons to communicate with a single AudioProcessorParameter?


#1

What’s the simplest / best way to create a radio group of buttons, so that they all communicate through one parameter, for example an AudioProcessorParameter ?

right now i have buttons set up, but am saving and loading the states of each individual button, rather than the overall radio state.


#2

Don’t know if it’s the best way, but you could create your own component containing a few buttons and call that on each of them :

setClickingTogglesState (true);
setRadioGroupId (999);
addListener (this);

and then if you put all them in a kind of array, you can just do something like that to get the selected index (that would be your “overall radio state”) :

void buttonClicked (Button* b) override
{
    if (b->getToggleState())
    {            
        const int selectedIndex = buttonsArray.indexOf (b);
        // etc.
    }
}