# Parameter Listener for AudioProcessorValueTreeState?

**URL:** <https://forum.juce.com/t/parameter-listener-for-audioprocessorvaluetreestate/20658>\
**Category:** Audio Plugins\
**Created:** [January 19, 2017, 12:18pm UTC](https://forum.juce.com/t/parameter-listener-for-audioprocessorvaluetreestate/20658 "2017-01-19T12:18:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 19, 2017, 12:18pm UTC](https://forum.juce.com/t/parameter-listener-for-audioprocessorvaluetreestate/20658/1 "2017-01-19T12:18:53Z")

</div>

Can someone make me an example of Parameter Listener for AudioProfeccorValueTreeState?  
I have:

```
parameters.createAndAddParameter("pitchLAVal", "Pitch Left A Value", String(), NormalisableRange<float> (-1.0, 1.0), 1.0, nullptr, nullptr);

```

And I assume that I can add a listener in this way:

```
parameters.addParameterListener("pitchLAVal", ??? );

```

I don’t know what is ???..

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 19, 2017, 2:14pm UTC](https://forum.juce.com/t/parameter-listener-for-audioprocessorvaluetreestate/20658/2 "2017-01-19T14:14:49Z")

</div>

If you look at the header file you can see the definition of the function:

```
void addParameterListener (StringRef parameterID, Listener* listener);

```

Just above it you can see how a `Listener` is defined:

```
struct JUCE_API Listener
{
    Listener();
    virtual ~Listener();

    /** This callback method is called by the AudioProcessorValueTreeState when a parameter changes. */
    virtual void parameterChanged (const String& parameterID, float newValue) = 0;
};

```

So, the second parameter needs to be a pointer to a class that inherits from Listener (and thus implements the `parameterChanged` method). This class will have its `parameterChanged` method called on parameter changes.

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 20, 2017, 8:50am UTC](https://forum.juce.com/t/parameter-listener-for-audioprocessorvaluetreestate/20658/3 "2017-01-20T08:50:17Z")

</div>

Ok but in the header I have to derive from the Listener as SliderListener?  
Something like:

```
class IntellifexAudioProcessorEditor : public AudioProcessorEditor,
                                    private SliderListener,
                                    private ButtonListener,
                                    private Timer

```

Or I have to build a custom class?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 20, 2017, 9:39am UTC](https://forum.juce.com/t/parameter-listener-for-audioprocessorvaluetreestate/20658/4 "2017-01-20T09:39:24Z")

</div>

Neither of those:

```
class IntellifexAudioProcessorEditor : private AudioProcessorValueTreeState::Listener
    : parameters (*this, nullptr)
{
public:
    IntellifexAudioProcessorEditor() {
        ...
        
        parameters.addParameterListener ("yourParamId", this);
    }
private:
    void parameterChanged (const String& parameterID, float newValue) override
    {
        // Called when parameter "yourParamId" is changed.
    }
}

```

I would suggest that you do a lot of reading about C++ to learn about how these things work before continuing to use JUCE.

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 20, 2017, 9:52am UTC](https://forum.juce.com/t/parameter-listener-for-audioprocessorvaluetreestate/20658/5 "2017-01-20T09:52:57Z")

</div>

Thank you very much…  
Your are right… Even friends of mine said that… But is more funny learning C++ by using JUCE…😉

Bitwise I didn’t know only the string for the listener in the constructor…

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 20, 2017, 10:00am UTC](https://forum.juce.com/t/parameter-listener-for-audioprocessorvaluetreestate/20658/6 "2017-01-20T10:00:24Z")

</div>

You don’t have to add a parameter listener in the constructor - I was just putting it there as an example.

Go and find a good C++ book!
