How does AudioProcessor::suspendProcessing() work?

I am trying to understand what this does.

void AudioProcessor::suspendProcessing (const bool shouldBeSuspended)
{
    const ScopedLock sl (callbackLock);
    suspended = shouldBeSuspended;
}

I am trying to suspend processing of the entire AudioProcessorGraph in a plugin host (a plugin that is itself a host)…

EDIT: I see that AudioProcessorGraph and AudioProcessorPlayer call isSuspended() - which then uses this variable.

But I don’t understand why suspending the processing of an AudioProcessorGraph inside a plugin doesn’t seem to have any effect…

The “suspended” variable value is returned in juce_AudioProcessor.h from :

bool isSuspended() const noexcept { return suspended; }

That method in turn is used for example in juce_audio_plugin_client_VST3.cpp :

if (pluginInstance->isSuspended())
            {
                buffer.clear();
            }
            else

The AudioProcessorGraph does not for some reason implement suspending the whole graph, but it does do a similar thing to the VST3 client for each hosted AudioProcessor.

What you should probably do in your top level plugin code is to implement the suspending yourself. Iterate through each graph node and call suspendProcessing of the node’s AudioProcessor as needed.

1 Like

Thanks, I think I liked your previous unedited answer better. :wink: . Where you said:

Because, in my top level plugin, in processBlock(), I send the block to the AudioProcessorGraph, so it seems I may be able to do something like:

if (!pluginGraphContainer.mainProcessor->isSuspended())
    pluginGraphContainer.mainProcessor->processBlock(buffer, mio.pluginMidiOutputBuffer);
else
{
    buffer.clear();
    mio.pluginMidiInputBuffer.clear();
}

I changed my answer because it occurred to me it’s probably a good idea to suspend each processor separately instead of just skipping processing the whole graph. If the hosted plugins are not individually suspended, they may end up keeping to process things in the background anyway, even if their processBlock (or equivalent) is not called.

1 Like

OK, I see what you’re saying, I’ll examine both ways. Thanks again!