# Inheriting from AudioParameterFloat

**URL:** <https://forum.juce.com/t/inheriting-from-audioparameterfloat/23343>\
**Category:** General JUCE discussion\
**Created:** [July 17, 2017, 9:10am UTC](https://forum.juce.com/t/inheriting-from-audioparameterfloat/23343 "2017-07-17T09:10:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cascassette](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cascassette/32/16757_2.png) [@cascassette](https://forum.juce.com/u/cascassette)\
**Post date:** [July 17, 2017, 9:10am UTC](https://forum.juce.com/t/inheriting-from-audioparameterfloat/23343/1 "2017-07-17T09:10:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cascassette](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cascassette/32/16757_2.png) [@cascassette](https://forum.juce.com/u/cascassette)\
**Post date:** [July 17, 2017, 8:29pm UTC](https://forum.juce.com/t/inheriting-from-audioparameterfloat/23343/2 "2017-07-17T20:29:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cascassette](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cascassette/32/16757_2.png) [@cascassette](https://forum.juce.com/u/cascassette)\
**Post date:** [July 20, 2017, 8:26pm UTC](https://forum.juce.com/t/inheriting-from-audioparameterfloat/23343/3 "2017-07-20T20:26:50Z")

</div>

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!
