Just cleared up a misconception I had regarding the AudioProcessorListeners:
http://www.rawmaterialsoftware.com/viewtopic.php?f=8&t=2128&hilit=audioProcessorListener
Since it is the case the setParameter doesn’t invoke sendParamChangeMessageToListeners(), I am wondering what the recommended way to update the UI when the host changes a parameter is?
I mean … I can certainly put a changeListener in there … but it seems like this is what the AudioProcessorListeners should be used for (that is … letting the host know if editor changes the parameters … but ALSO letting the UI know if the host changes the parameters … no?).
Anyway … just looking for the cleanest way to keep both UIs updating smoothly.
Currently, I’m putting sendParamChangeMessageToListeners() at the end of my setParameter() method … but I’m sure this is not advised.
hmmm … so thinking about parameters changing in an audioProcessor … there seem to be three situations:
1 - the parameter is changed through the editor UI … it should call setParameterNotifyingHost() … which sends an asynchronous changeMessage to the Host … which updates it’s UI if needed.
2 - AudioProcessor changes a parameter internally … and also calls setParameterNotifyingHost(). In this scenario, the Host receives a notification as above. If the UI is registered as a AudioProcessorListener, it also receives a notification.
3 - The host changes a parameter … here we appear to be out of luck, since the host will just use the setParameter method … the UI won’t know anything has changed, and will NOT update. Of course, we can install a changeListener/Broadcaster … which seems redundant, but works out.
Hey Aaron,
I’ve had good luck just using a Timer to periodically scan the AudioProcessor for any updates. The JuceDemoPlugin does it this way:
void JuceDemoPluginAudioProcessorEditor::timerCallback()
{
JuceDemoPluginAudioProcessor* ourProcessor = getProcessor();
AudioPlayHead::CurrentPositionInfo newPos (ourProcessor->lastPosInfo);
if (lastDisplayedPosition != newPos)
displayPositionInfo (newPos);
gainSlider->setValue (ourProcessor->gain, false);
delaySlider->setValue (ourProcessor->delay, false);
}
There is a small lag, but it isn’t very noticeable. Hope this helps
Matt
Nah, the ChangeListeners work well and are faster I expect.
I realized after the fact that APListeners are synchronous anyway, so I needed to install change listeners for all kinds of things.