Thanks for the suggestion, but I was going to start pushing in a different direction with the way I'd recommend using parameters. In the plugins we're building internally we're now using lambdas a lot, and finding that to be a good pattern. I'll be publishing some helper classes based on that very soon.
Also, there's no reason for this to go into the base class. The same thing would work perfectly well as a subclass, which would be a better solution since it wouldn't bloat everyone's parameter objects with unused arrays. Since few people would use this, and many plugins have thousands of parameters, putting it in the base class would probably be a bad move!
+1 lambdas, which can be used instead for any kind of listeners. Would like to see some example code :) The whole listener architecture makes the code untidy. Object initialization/characterization and defining callback-procedures should be on the same place.
+ some thing like a look-free call queue, which should be synchronized in the audio-thread (and if no audio callback happens on a fallback-thread) and some thread safe data-synchronization technics (like this https://github.com/bazrush/juce-toys) should be part of juce, because its a recurrent design pattern in audio-software
something like:
AudioProcessor::CallFunctionOnAudioThread(<Lambda>) would be great
Some context for this suggestion. I'd later like to have something like this "ParamToggleLink":
class ParamToggleLink : public AudioProcessorParameter::Listener, public Button::Listener
{
public:
ParamToggleLink();
ParamToggleLink (AudioProcessorParameter*, Button*);
void link (AudioProcessorParameter*, Button*);
private:
virtual void audioProcessorParameterChanged (AudioProcessorParameter*, float) override;
virtual void buttonClicked (Button*) override;
virtual void buttonStateChanged (Button*) override;
AudioProcessorParameter* parameter;
Button* button;
};
This gets initialized in the plugin editor's initializiation, and replaces the editor being a button listener itself and then comparing to the different buttons in its callback, as well as maintaining their state via either a timerCallback such as in JUCE's example plugin or via being a listener for the AudioProcessor with a big switch statement for all the parameters in its callback.
Similarly I'd like to have something of this sort for Sliders. Except afaik there I need to subclass juce::Slider in order to implement its getTextFromValue and getValueFromText methods to call the parameter's methods.