Finding parameters with custom plugin host

Hi all!

I’m working on a small VST3 plugin host for Unity using interop with a native Juce dynamic library. So far, I’ve had success scanning for plugins, instantiating a VST3 plugin and having it process audio coming from the game engine.

For testing I am using a simple VST3 test plugin which produces noise and has two AudioParameterFloat added in the plugin constructor with addParameter. Problem is that I cannot find these parameters in my host - getParameters called on plugin instance doesn’t return any parameters.

Opening the plugin in another host (tested with Reaper, 64 bit Windows 10), these parameters are indeed visible and work as expected when automated.

This makes me think I have missed some step in instantiating the plugin. I have poked around in the Juce plugin host source, but didn’t find anything about exposed parameters.

Here is the code, simplified for readability:

// ...Plugins directory scanned
// KnownPluginsList returned as XML and deserialized
// Test VST3 plugin selected from list and serialized to XML, provided as xmlPluginDescription

pluginDescription = new PluginDescription();
ScopedPointer<XmlDocument> document = new XmlDocument(xmlPluginDescription);
XmlElement* element = document->getDocumentElement();

if (pluginDescription->loadFromXml(*element))
{
	String error = "Could not create plugin instance.";
	pluginInstance = formatManager->createPluginInstance(*pluginDescription, sampleRate, bufferSize, error);

	if (pluginInstance)
	{
		pluginEditor = pluginInstance->createEditor();
        pluginInstance->prepareToPlay(sampleRate, expectedSamplesPerBlock);
	}
}

// ...Plugin was loaded and is now providing audio in the game engine
// Now we attempt to get the number of parameters:
const OwnedArray<AudioProcessorParameter>& params = pluginInstance->getParameters();
return params.size();

// When debugging, we see that params is empty (numUsed=0) and params.size returns 0.
// In Reaper, two parameters are visible, as expected.

Am I missing some important setup step here? Thanks!

I’ve solved it (for now) by reverting to the AudioProcessor getNumParameters, getParameter and setParameter methods. Considering these will be deprecated at some point i’d still like to solve it using the AudioProcessorParameter arrays though.

Sounds like it’d be easy enough to watch what happens when the various callbacks are made and see when/if the parameters are really added?

(You have tried debugging it… right?)

Hi Jules, thanks for the reply!

I have been debugging it and upon another look this morning, TestVST3pluginAudioProcessor contains the expected 2 parameters in managedParameters while 0 are contained under AudioProcessor. When calling getParameters on my plugin instance, I reach the AudioProcessor rather than TestVST3pluginAudioProcessor and an empty managedParameters is returned.

Using the old parameter methods, the values are coming from the plugins editController, which works fine.

The plugin instance is stored as type AudioPluginInstance - Could that be an issue? Forgive me if I’m confusing things…

Ah yes, sorry - I misunderstood/misremembered. When you’re writing a host and load a plugin, it does still use the old system (I think… Fabian is the expert on this stuff). The whole parameter system’s due for an overhaul soon to straighten out this kind of thing.

Alright that’s good to know, thanks for the explanation! I’ll stick with the old system then.

Yeah, the new parameters array does not get populated when you host plug-ins. You need to use the old methods.