# AudioProcessorGraph question

**URL:** <https://forum.juce.com/t/audioprocessorgraph-question/4818>\
**Category:** General JUCE discussion\
**Created:** [February 1, 2010, 4:08pm UTC](https://forum.juce.com/t/audioprocessorgraph-question/4818 "2010-02-01T16:08:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![williamk](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@williamk](https://forum.juce.com/u/williamk)\
**Post date:** [February 1, 2010, 4:08pm UTC](https://forum.juce.com/t/audioprocessorgraph-question/4818/1 "2010-02-01T16:08:40Z")

</div>

SOLVED: see my solution below… :mrgreen:

How can I handle a parameter that has changed in a AudioProcessorGraph node, to tell the host that something changed? Therefore, making automation work.

Its like this, we have the AudioProcessorGraph graph, which holds up to 16 loaded plugins. (VSTs on my case) If you move a parameter in any of those “child” VSTs, what happens inside the graph class? How can I handle this, so I can tell the host some automation occurred?

I posted this too in the other area, but I though I should re-write it here too. 😉

Thanks, Wk

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [February 1, 2010, 4:20pm UTC](https://forum.juce.com/t/audioprocessorgraph-question/4818/2 "2010-02-01T16:20:56Z")

</div>

Well, some sort of listener/broadcaster model, I guess. Though it’ll be challenging to make one that works on the audio thread, you’d need to have some sort of external class that checks it for updates and does the broadcast, maybe using a Timer.

---

<div class="post-metadata">

**Author:** ![williamk](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@williamk](https://forum.juce.com/u/williamk)\
**Post date:** [February 1, 2010, 9:01pm UTC](https://forum.juce.com/t/audioprocessorgraph-question/4818/3 "2010-02-01T21:01:37Z")

</div>

Actually, it looks like AudioProcessorListener would do the trick, as it does get called when the child VST parameter is moved on the GUI.

The only problem is, that I can’t seem to be able to create a new class that derivatives from it. ☹

`c:\work\ ___current projects__ \wusik juce projects\juce\extras\__wusik station x\demo\src\FilterComponent.h(92) : error C2259: 'juce::AudioProcessorListener' : cannot instantiate abstract class
        due to following members:
        'void juce::AudioProcessorListener::audioProcessorParameterChanged(juce::AudioProcessor *,int,float)' : is abstract
        c:\work\ ___current projects__ \wusik juce projects\juce\extras\__wusik station x\demo\src\../../../../juce_amalgamated.h(17096) : see declaration of 'juce::AudioProcessorListener::audioProcessorParameterChanged'
        'void juce::AudioProcessorListener::audioProcessorChanged(juce::AudioProcessor *)' : is abstract
        c:\work\ ___current projects__ \wusik juce projects\juce\extras\__wusik station x\demo\src\../../../../juce_amalgamated.h(17100) : see declaration of 'juce::AudioProcessorListener::audioProcessorChanged'`

If I could create a class, and add the listener to each child VST, I could them process things up and it will all be good. :mrgreen:

This is what I’m trying to do:

[code]class JUCE\_API AudioProcessorListenerEx : public AudioProcessorListener  
{  
public:  
AudioProcessorListenerEx(int aindexN, void\* afilter);

```
virtual void audioProcessorParameterChanged (AudioProcessor* processor,
											 int parameterIndex,
											 float newValue);

// Variables //
int indexN;
void* filter;

```

};[/code]

The indexN tells me the number of the VST in my 16 VSTs list. The filter variable is just a copy of my filter’s plugin.

Them I could just add on the filter AudioProcessorListenerEx plugsListeners[16]; but sadly, it won’t work, shows me the error above…

---

<div class="post-metadata">

**Author:** ![williamk](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@williamk](https://forum.juce.com/u/williamk)\
**Post date:** [February 1, 2010, 9:17pm UTC](https://forum.juce.com/t/audioprocessorgraph-question/4818/4 "2010-02-01T21:17:43Z")

</div>

Actually, the following compiles without problems. :oops:

[code]class JUCE\_API AudioProcessorListenerEx : public AudioProcessorListener  
{  
public:  
virtual void audioProcessorChanged (AudioProcessor\* processor);

```
virtual void audioProcessorParameterChanged (AudioProcessor* processor,
											 int parameterIndex,
											 float newValue);

// Variables //
int indexN;
void* filter;

```

};[/code]

---

<div class="post-metadata">

**Author:** ![williamk](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@williamk](https://forum.juce.com/u/williamk)\
**Post date:** [February 1, 2010, 9:23pm UTC](https://forum.juce.com/t/audioprocessorgraph-question/4818/5 "2010-02-01T21:23:06Z")

</div>

YES! IT WORKS! :mrgreen: 8)

Let me post my complete solution, hang on…

---

<div class="post-metadata">

**Author:** ![williamk](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@williamk](https://forum.juce.com/u/williamk)\
**Post date:** [February 1, 2010, 9:25pm UTC](https://forum.juce.com/t/audioprocessorgraph-question/4818/6 "2010-02-01T21:25:18Z")

</div>

First, since all my VST childs are fixed, I know the number of parameters each one takes, 2000 parameters.

`int FilterComponent::getNumParameters()
{
	return 2000 * 6;
}`

So for each child VST, I know how to handle parameters into the graph.

`void FilterComponent::setParameter (int index, float newValue)
{
	int index2 = index - ((index/2000) * 2000);
	graph.WgetByIndex(index/2000)->setParameter (index2, newValue);
}`

Inside my graph class, I did some new calls, the WgetByIndex is one of those. It holds a list of 16 nodes, the child VSTs.

---

<div class="post-metadata">

**Author:** ![williamk](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@williamk](https://forum.juce.com/u/williamk)\
**Post date:** [February 1, 2010, 9:26pm UTC](https://forum.juce.com/t/audioprocessorgraph-question/4818/7 "2010-02-01T21:26:36Z")

</div>

Now, in my filter’s class, I added AudioProcessorListenerEx plugsListen[16];

And I handle it like this in the filter’s constructor:

`	for (int x=0; x<16; x++) { plugsListen[x].indexN = x; plugsListen[x].filter = (void*)this; }
	MainInstance->addListener(&plugsListen[0]);`

And this takes care of the automation:

`void AudioProcessorListenerEx::audioProcessorParameterChanged (AudioProcessor* processor,
												 int parameterIndex,
												 float newValue)
{
	((FilterComponent*)filter)->setParameterNotifyingHost(parameterIndex+(indexN*2000),newValue);
}`

I tested with Orion, and its working. :mrgreen:
