okay, after a bit of headscratching i figured out a sensible way of getting setParameterAutomated to work, in a nice JUCEy way without exposing the vst framework to the AudioFilterBase. As you said you’ve not tackled that just yet i thought i’d offer my solution in case it helps at all.
Here’s a rundown on what i’ve done and why:
Changes to AudioFilterBase
- AudioFilterBase is now a ChangeBroadcaster
- It now has the following additions…
public:
...
virtual void setParameterAutomated (int index, float newValue) {};
int getCurrentActiveParameter()
{
return currentActiveParameter;
}
void notifyHostOfChange( int paramIndex )
{
currentActiveParameter = paramIndex;
sendChangeMessage( this );
}
private:
int currentActiveParameter;
...
Changes to JuceVSTWrapper
- JuceVSTWrapper is now a ChangeListener
- The override of setParameterAutomated has been removed.
public:
...
// respond to changes in the filter's controls...
void changeListenerCallback( void *source )
{
// find out which parameter has been changed...
int param = filter->getCurrentActiveParameter();
float value = filter->getParameter( param );
// inform the host of the change...
setParameterAutomated( param, value );
}
...
Now, let’s presume that the EditorComponent will be using a changeListenerCallback(void*) function to respond to changes in the panel controls. The callback establishes which parameter has changed, and calls owner->setParameterAutomated( param, value );
Here’s an example of what the ‘owner’ filter class’s definition of that function would be:
void ExampleFilter::setParameterAutomated (int index, float newValue)
{
params[index] = newValue;
notifyHostOfChange(index);
}
As you can see, it updates the value of the parameter in the filter, and then calls ‘notifyHostOfChange’ with the parameter index.
This causes the ‘currentActiveParameter’ in the audioFilterBase to be set to the current index, and notifies the wrapper of an editor-based parameter change via a change message.
In response, the wrapper asks the filter which parameter it was, gets the value, and then calls the native ‘setParameterAutomated’. This call is for the benefit of the filter (to notify the host), not the host, so it wants to have the original AudioEffect base code to send the appropriate info back to the host. This is why the override was taken out.