# How to know if a parameter has been changed by automation or by the plugin?

**URL:** <https://forum.juce.com/t/how-to-know-if-a-parameter-has-been-changed-by-automation-or-by-the-plugin/56331>\
**Category:** General JUCE discussion\
**Created:** [May 22, 2023, 7:21pm UTC](https://forum.juce.com/t/how-to-know-if-a-parameter-has-been-changed-by-automation-or-by-the-plugin/56331 "2023-05-22T19:21:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredofaure](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fredofaure/32/18205_2.png) [@fredofaure](https://forum.juce.com/u/fredofaure)\
**Post date:** [May 22, 2023, 7:21pm UTC](https://forum.juce.com/t/how-to-know-if-a-parameter-has-been-changed-by-automation-or-by-the-plugin/56331/1 "2023-05-22T19:21:22Z")

</div>

Hello,  
i have a parameter  
`juce::AudioParameterInt* P`  
When it is changed, the function `parameterValueChanged ()` is called.  
In this function is it possible to know if the change has been done by automation (the DAW) or by the plugin (myself somewhere else in the code)?  
Thanks,  
Frédéric.

---

<div class="post-metadata">

**Author:** ![moritzsur](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@moritzsur](https://forum.juce.com/u/moritzsur)\
**Post date:** [May 24, 2023, 9:58pm UTC](https://forum.juce.com/t/how-to-know-if-a-parameter-has-been-changed-by-automation-or-by-the-plugin/56331/2 "2023-05-24T21:58:10Z")

</div>

Depending on how you listen to the parameter (sync or async) you might be able to identify it by checking if the current thread is the message thread.

---

<div class="post-metadata">

**Author:** ![fredofaure](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fredofaure/32/18205_2.png) [@fredofaure](https://forum.juce.com/u/fredofaure)\
**Post date:** [May 24, 2023, 10:29pm UTC](https://forum.juce.com/t/how-to-know-if-a-parameter-has-been-changed-by-automation-or-by-the-plugin/56331/3 "2023-05-24T22:29:46Z")

</div>

Thank you very much for your answer.  
And if the current thread is not the message thread, what is the usual way to do thread safe operations with the variables of the plugin? using a mutex for example or using atomic variables etc?

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [May 25, 2023, 7:20am UTC](https://forum.juce.com/t/how-to-know-if-a-parameter-has-been-changed-by-automation-or-by-the-plugin/56331/4 "2023-05-25T07:20:59Z")

</div>

after some plugin releases i decided to subclass juce::AudioProcessorParameter and make my own parameter class in an attempt to be able to add features to parameters at the very source of them and it has already helped me multiple times coming up with a solution that seemed more structured than outsourcing the problem to other places in the code. i see potential with this problem as well, because if you imagine making your own Component for modifying parameter values, like knobs, button, xypads, envelope editors etc, you can imagine how in the mouse functions it would just not call setValueNotifyingHost, but a new method, like setValueFromGUI and this method would call setValueNotifyingHost and then trigger an event or maybe set some bool to true in order to show some other part of the code that a certain value change came from the GUI (or the message thread in general). my suggestion is a bit of work, like an entire parameter class and GUI components, but i think it’s worth it
