AudioProcessorGraph stops working after loading plugin instance in host


#1

Hello, I am having a bit of trouble.
My AudioProcessorGraph stops working after loading any plugin (Tried VST and LADSPA), i.e. none of the “processBlock” methods from any processors are being called.
I tried so many things, running out of ideas.
Setting “useplugin” to false in the code below will make them audible. Setting it to true makes them inaudible. This happens even without adding the plugin instance to the graph or modifying the graph in any way.
The plugin loads without any errors, calling it’s methods returns sensible values. So I must be missing something very simple. Apologies for not having a complete example and for the hardcoded values.
I am testing on Ubuntu using Jack Audio.
This is roughly derived from the AudioProcessorGraph tutorial, but updateGraph is not called from a timer here, only once during startup.
“SampleProcessor” plays a continousl audio loop.

void updateGraph()
{
	for (auto connection : mainProcessor->getConnections())
		mainProcessor->removeConnection (connection);

	bool useplugin = true;
	if (useplugin) {
		PluginNode = mainProcessor->addNode (loadVST());
		mixnodes.add (PluginNode);
	}

	auto mixer = new VolumeProcessor();
	auto sam1 = new SampleProcessor();
	auto sam1vol = new VolumeProcessor();
	sam1->loadFile("/stuff/samples/mpc500/small/fire.wav");

	MixerNode = mainProcessor->addNode (mixer);
	Sample1Node = mainProcessor->addNode (sam1);
	Sample1Send = mainProcessor->addNode (sam1vol);

	mixnodes.add (MixerNode);
	mixnodes.add (Sample1Node);
	mixnodes.add (Sample1Send);

	for (auto slot : mixnodes)
	{
		slot->getProcessor()->setPlayConfigDetails (mainProcessor->getMainBusNumInputChannels(),
							mainProcessor->getMainBusNumOutputChannels(),
							mainProcessor->getSampleRate(),
							mainProcessor->getBlockSize());
	}

	MixerNode->getProcessor()->setPlayConfigDetails (mainProcessor->getMainBusNumInputChannels(),
							 mainProcessor->getMainBusNumOutputChannels(),
							 mainProcessor->getSampleRate(),
							 mainProcessor->getBlockSize());

	if (useplugin) {
		mainProcessor->addConnection ({ { Sample1Node->nodeID, 0}, { PluginNode->nodeID, 0} });
		mainProcessor->addConnection ({ { Sample1Node->nodeID, 1}, { PluginNode->nodeID, 1} });

		mainProcessor->addConnection ({ { PluginNode->nodeID, 0}, { MixerNode->nodeID, 0} });
		mainProcessor->addConnection ({ { PluginNode->nodeID, 1}, { MixerNode->nodeID, 1} });
	} else {
		mainProcessor->addConnection ({ { Sample1Node->nodeID, 0}, { Sample1Send->nodeID, 0} });
		mainProcessor->addConnection ({ { Sample1Node->nodeID, 1}, { Sample1Send->nodeID, 1} });

		mainProcessor->addConnection ({ { Sample1Send->nodeID, 0}, { MixerNode->nodeID, 0} });
		mainProcessor->addConnection ({ { Sample1Send->nodeID, 1}, { MixerNode->nodeID, 1} });

	}


	for (int channel = 0; channel < 2; ++channel)
	{
		mainProcessor->addConnection ({ { MixerNode->nodeID,  channel },
						{ audioOutputNode->nodeID,        channel } });
	}

	connectMidiNodes();

	for (auto node : mainProcessor->getNodes())
		node->getProcessor()->enableAllBuses();

}

The plugin loading code:

PluginDirectoryScanner* scanner = nullptr;
AudioPluginFormatManager pluginFormatManager;
KnownPluginList pluginList;

AudioPluginInstance* loadVST()
{

	VSTPluginFormat formatToScan;
	File deadMansFile;
	auto path = FileSearchPath("/tmp/plug");
	scanner = new PluginDirectoryScanner(pluginList, formatToScan, path, true, deadMansFile, true);
	bool ongoing = true;
	String scannedPluginName;

	pluginFormatManager.addDefaultFormats();

	while (ongoing){
		ongoing = scanner->scanNextFile(false, scannedPluginName);
		if (scannedPluginName.length() != 0)
			printf ("Scanning: %s\n", scannedPluginName.toStdString().c_str());
	};

	KnownPluginList::PluginTree* tree = pluginList.createTree(KnownPluginList::defaultOrder);
	if (tree->plugins.size()){
		const PluginDescription* first = tree->plugins.getFirst();
		printf("Name of first found plugin: %s\n", first->name.toStdString().c_str());


		for (auto d = tree->plugins.begin(); d != tree->plugins.end(); d++){
			const PluginDescription* desc = *d;
			fprintf(stderr, "Name of other found plugin: %s\n", desc->name.toStdString().c_str());
			if (desc->name == String("mdaDelay")) {
				fprintf (stderr, "Found mdaDelay, will attempt to load.\n");

				AudioPluginInstance *plugin = nullptr;
				String errorMessage;
				plugin = pluginFormatManager.createPluginInstance (*desc, 44100, 512, errorMessage);
				if (plugin == nullptr) {
					fprintf (stderr, "Error: %s\n", errorMessage.toStdString().c_str());
				}
				plugin->suspendProcessing(false);
				return plugin;
			}
		}
	}

	return nullptr;
}

#2

I’ve just skimmed your code, rather than digging into the details, but it looks like you might be missing some calls to AudioProcessor::enableAllBuses().