Monitoring auxiliary outputs triggers prepareToPlay/releaseResources?

Hi folks. I’m working on implementing auxiliary outputs into my plug-in.

Just to give a brief overview, my plug-in is delay/loop-based and has a number of AudioSampleBuffers under the hood. What I’m trying to implement is a dedicated auxiliary output for each AudioSampleBuffer, for the user’s convenience.

In prepareToPlay, I call setSize for the AudioSampleBuffers (using the sampleRate to calculate their proper maximum size), and in releaseResources I null them out by setting setSize(0, 0).

I’ve got the auxiliary outputs working fine, and I can see the outputs in Ableton and monitor them. What I’m noticing, however, is that when I start monitoring one of the outputs, releaseResources and prepareToPlay are called. The end result is that the contents of the AudioSampleBuffer get dumped, which seem like a poor user experience.

My question is basically this:

  1. Is it wise to skip releaseResources/prepareToPlay in some cases? Is there a proper way to identify that there was no real change, and to avoid dumping the contents of the Buffers in this case?

  2. Alternatively, am I misusing prepareToPlay and releaseResources for setting up my Buffers? Is there a better way to properly identify the lifecycle of the plug-in, since prepareToPlay/releaseResources can be called while the plug-in is still running?

After doing a bit more testing and logging, I’m finding that prepareToPlay/releaseResources can be called any number of times during the lifecycle of the plug-in, whereas the destructor (~MyAudioProcessor) seems to more accurately reflect the overall lifecycle of the plug-in and is only called when the plug-in is truly destroyed.

To verify, I moved my setSize(0, 0) calls into the destructor (rather than releaseResources) and everything works as expected.

I guess my general question would be: In which cases should you use releaseResources versus the destructor? The documentation for AudioProcessor is a bit sparse. It says:

virtual void AudioProcessor::releaseResources()
Called after playback has stopped, to let the object free up any resources it no longer needs.

Though I’m not exactly sure what “playback has stopped” means in this case.