One thing that in every plugin project needs to be resolved newly is the right time to initialize its algorithm. To do so the plugin need to know at least
- what channel configuration
- what sample rate
- what IO processing block size
the plugin has to deal with. There is not a singular place that gets called when ultimately everything is set, so it needs to be re-setted at various places whenever the plugin announces one of these parameter has changed. Unfortunately not all of these have a distinct announcement either. I learnt one place is prepareToPlay.
Now, when instanciating my plugin as VST3 I receive following sequence with varying configurations:
virtual void processor::numChannelsChanged()
virtual void processor::numChannelsChanged()
virtual void processor::numChannelsChanged()
virtual void processor::numChannelsChanged()
virtual void processor::prepareToPlay(double, int)
virtual void processor::prepareToPlay(double, int)
virtual void processor::numChannelsChanged()
virtual void processor::prepareToPlay(double, int)
virtual void processor::prepareToPlay(double, int)
until finally the configuration matches the host expectation. Whenever the blocksize, the number of ins/outs, or the sample rate changes the plugin has to reconfigure its whole processing, which takes a while because of its complexity.
Would it be possible for JUCE to just call each of these functions once, whenever something actually has changes. I don’t see any reason for my plugin to reconfigure its I/O five times because somewhere there is a confusion if the plugin is instantiated in a mono or stereo track. The plugin ignores the call if nothing has changed, but usually the host seems to request to set the configuration in a mono,stereo,mono,stereo,etc. sequence.