Inheriting from AudioParameterFloat


I’m trying out the AudioProcessorParameter system of classes. I want to make a DecibelParameter class, such that on change of the (linear) value in decibels (say a range of -36 to +6) is processed only once into the float ‘gain’ that can be used in multiplication. So I figured I would derive from AudioProcessorFloat, and just override setValue to also do that computation, and add a getGainValue method that always just directly returns the ‘internal’ gain value.
Calling the parent’s setValue is illegal in this case, since it’s also private. I see the following solutions;

  • derive from AudioProcessorParameter instead and copy most of AudioProcessorFloat
  • edit juce class to have setValue and value protected
  • have getGainValue use getValue instead, doing log computation every call (ie at least once every block)
    The cons for the 3 solutions are in my opinion well clear. I’m curious if anybody here can think of a better solution. Maybe I’m thinking the wrong way about it, and the gain value should not be stored in the Parameter, but more internally to the processor. Then still, can I find a way to notify my processor, and through a UIUpdateFlag mechanism the GUI? Obviously I want the slider to show the decibel value, not the computed gain value.


I’ve tried deriving from AudioProcessorFloat still, make the constructors call the parent constructor, and overriding operator=. That works from my custom GUI, and it notifies the host. However, if I change the parameter from the host, which is what happens on MIDI binding, it’s not calling equals but rather the setValue function. So I will now go for solution 1 above.


In doing the first step, I have been able to control from the custom GUI and update in the host, as well as vice versa. I’m now only thinking of making the UIUpdateFlag behaviour a virtual class, so that a pointer to just that functionality can be given away to children objects.

Thanks Cas!