SetParameter called twice by setParameterNotifyingHost?


#1

setParameterNotifyingHost has the following two lines:

setParameter (parameterIndex, newValue); sendParamChangeMessageToListeners (parameterIndex, newValue);

However, JuceVSTWrapper ctr adds the plugin filter as a listener:

So, when sendParamChangeMessageToListeners gets called, setParameter is called once again (eventually…from setParameterAutomated).

Of course, we should watch out for and ignore duplicate edits anyway, but I’m wondering if there is a reason that setParameterNotifyingHost needs to call setParameter directly in the first place. It looks like it is maybe there for an application where the filter does not listen to itself? Or maybe when you absolutley positively want to make sure the host gets the edit first and not rely on the order in the listener list?

Maybe I’ve missed the point of the function, and maybe it is better for the plugin GUI to call sendParamChangeMessageToListeners instead of setParameterNotifyingHost.


#2

Well, the filter registers as a listener to get all the other events as well as the parameter changes - I guess it’s just a side-effect that means it’ll get called twice.

You can’t rely on just calling sendParamChangeMessageToListeners to actually set the parameter though - I’m not sure that all the other plugin formats will also end up making a callback to setParameter(). That’s why it explicitly calls setParameter first, just in case the format doesn’t bother doing so.


#3

OK, thanks for that info. I figured there was probably a good reason!