# Parameters values and approximatelyEqual()

**URL:** <https://forum.juce.com/t/parameters-values-and-approximatelyequal/49820>\
**Category:** Audio Plugins\
**Created:** [January 24, 2022, 11:36am UTC](https://forum.juce.com/t/parameters-values-and-approximatelyequal/49820 "2022-01-24T11:36:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [January 24, 2022, 11:36am UTC](https://forum.juce.com/t/parameters-values-and-approximatelyequal/49820/1 "2022-01-24T11:36:04Z")

</div>

Wouldn’t it make sense to use  
`approximatelyEqual (param.getValue(), newValue)`  
instead of the normal comparison in `setValueAndNotifyIfChanged()` ?

> <https://github.com/juce-framework/JUCE/blob/0bac0e78c815d9b6328e238fefc2bb151a5163ec/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp#L629>

I have a plugin where unexpected changes are triggered (somehow the issue only appeared in FL studio with vt3 for now) and using `approximatelyEqual()` fixes it.

---

<div class="post-metadata">

**Author:** ![JeffMcClintock](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jeffmcclintock/32/21430_2.png) [@JeffMcClintock](https://forum.juce.com/u/JeffMcClintock)\
**Post date:** [January 24, 2022, 8:14pm UTC](https://forum.juce.com/t/parameters-values-and-approximatelyequal/49820/2 "2022-01-24T20:14:05Z")

</div>

you might be experiencing a feedback loop.  
This is when the plugin notifies the DAW of a parameter change, and the DAW notifies the plugin back.

You wouldn’t think this was a problem, but with floating-point math it’s very easy for tiny tiny differences to creep in and cause the DAW to set the parameter _slightly_ different each time around the feedback loop.

However the root cause of the problem is often _not_ the rounding errors, it’s that you are notifying the DAW _unnecessarily_ when you are not meant to. i.e. if the DAW notifies a parameter change, your plugin should NOT be notifying it back.

Another technique I’ve used is to retain the last parameter value that the DAW sent, and compare any future notification with that cached value. Ignore notifications that don’t change it.  
It is critical that you don’t convert or alter this value at all, i.e you can’t convert it from normalized to real or vice versa, because it’s that type of operation that introduces the quantization or rounding errors.

Hope that’s helpful
