Problems unit-testing AudioProcessorGraph topology changes in non-realtime

I have been having problems unit-testing a plugin that wraps an AudioProcessorGraph. I have been working off of the tutorial at

In order to properly unit test in an offline manner, I have set mProcessorGraph->setNonRealtime(true). But I find that my graph routing is incorrect when I call processBlock.

After some debugging, it appears that the problem is that when topologyChanged() is called while updating the graph, it calls triggerAsyncUpdate() but the update is not performed before processBlock() runs. The result is that though my sub-processors get called, the routing is incorrect.

I have temporarily modified juce_AudioProcessorGraph.cpp to handle non-realtime mode as well:

void AudioProcessorGraph::topologyChanged()

	if (isPrepared.get() != 0)
		if (isNonRealtime() && MessageManager::getInstance()->isThisTheMessageThread())

Routing seems to be working in my unit tests now. My question is, is this an appropriate fix for getting an AudioProcessorGraph working in nonRealtime mode?

There’s been some back-and-forth with a similar issue here:

We’ll look into it.

1 Like