I want to have three buttons of the same radio group, so that only one at the time can be ticked. So how does the setParameterNotifyingHost() method and the getParameter() method respectively handle bool values? In my AudioProcessorEditor::buttonClicked method intuitively I would write something like this:
if (buttonThatWasClicked == firstButton)
//[UserButtonCode_firstButton] – add your button handler code here…
Again intuitively I’d represent such a button as AudioParameterBool* parameterFirstButton and define it in the AudioProcessor Constructor like this:
addParameter(parameterFirstButton = new AudioParameterBool( “firstButton”,
In the processBlock() I’d want to get the boolean value of the button.
bool firstButtonOn = getParameter(indexParameter_FirstButton);
According to the JUCE reference, the getParameter() method returns a float value, which would not make sense in this case. Similar to the setParameterNotifyingHost() method which expects a float value for the desired value.
How is this handled appropriately?
As you put it in your GUI in three exclusive buttions, you have to make sure, each time is only one bool true, the rest is false. So this is a pointless effort.
Rather store one discrete value (i.e. int) and enumerate your options.
For that purpose the subclass AudioParameterChoice exists, which handles the conversion between the float of the host and your class.
Then I would add a callback when the parameter changes and set the ticked state of the buttons accordingly.
Okay. I’ll try the AudioParameterChoice , since it seems appropriate for what I want to do. What I still don’t understand is, how you handle every non-AudioParameterFloat, because getParameter() returns a float value. I have not implemented it yet, I’m starting right now, but I fear that in the when I want to get or set the parameter, I’ll have the same problem, but let’s see. I’ll try that. Thank you for your time and help.
Yes, I already ran into that problem. How am I supposed to set the AudioParameterChoice to a new value from the AudioProcessorEditor::buttonClicked method? The setParameterNotifyingHost still only accepts a float value. I’m confused, sorry.