Connect to a VST plugin

Is there a tutorial which explains how to connect to a VST plugin (like Sylenth1) and exchange data (current preset and bank) including instructing the plugin to change to a different preset/bank?

No tutorial I’m aware of, but take a look at the Juce Audio Plugin Host example. That’s a good starting point.

Ok i now try to use the following code to instantiate Sylenth1:

    String message;
    KnownPluginList plugList;
    AudioPluginFormatManager pluginFormatManager;
    AudioPluginInstance* test;
    OwnedArray<juce::PluginDescription> typesFound;
    juce::VSTPluginFormat format;
    String pluginLoadError;
    
    message << "/Library/Audio/Plug-Ins/VST/Sylenth1.vst";
    pluginFormatManager.addDefaultFormats();
    plugList.scanAndAddFile(message, true, typesFound, format); // error happens here
    test = pluginFormatManager.createPluginInstance(*typesFound[0], 44100, 512, pluginLoadError);

and get the following error when execute it:

JUCE v4.3.1
Attempting to load VST: /Library/Audio/Plug-Ins/VST/Sylenth1.vst
*** Leaked objects detected: 1 instance(s) of class ModuleHandle
JUCE Assertion failure in juce_LeakedObjectDetector.h:97

Sorry, i’m not a C++ programmer and i’m feeling quite lost…
Thanks for any help!

That’s not an error, well, it is, it just says you’re not cleaning up your allocated resources… Is test non-null? If so, you probably succeeded.

Ah ok. test is non-null, and i discovered that i have to disable “Debug executable”.
Therefore: How do i make visible that AudioPluginInstance instance and start communicating with it?

I would strongly advise you to read a book on C++ before diving any deeper into JUCE. Disabling the debugger to work around errors is like using a guillotine to fix a headache.

The code below is untested but with a few minor tweaks it should give you a template for displaying a plug-in’s GUI. At the very least you’ll need to make both instance and editor member variables so that you can access them outside of the scope of the code sample presented here. You will need to do some memory management to prevent leaking objects - look at std::unique_ptr orJUCE’s ScopedPointer for good ways of doing this.

OwnedArray<PluginDescription> pluginDescriptions;
KnownPluginList plist;
AudioPluginFormatManager pluginFormatManager;
pluginFormatManager.addDefaultFormats();
for (int i = 0; i < pluginFormatManager.getNumFormats(); ++i)
{
    plist.scanAndAddFile(PATHTOYOURPLUGIN, true, pluginDescriptions,
                         *pluginFormatManager.getFormat(i));
}
jassert (pluginDescriptions.size() > 0);
String msg ("Oh no!");
auto instance = pluginFormatManager.createPluginInstance(*pluginDescriptions[0],
                                                        48000,
                                                        1024,
                                                        msg);

auto editor = instance->createEditor();
auto bc = editor->getConstrainer();
editor->setBounds(0, 0, bc->getMinimumWidth(), bc->getMinimumHeight());
addAndMakeVisible (editor);
1 Like

Thank you very much, T0m.
I will try your code and definitely also have to refresh my knowledge about C++.
I got the following message when calling

plugList.scanAndAddFile(message, true, typesFound, format);

Therefore i don’t think it’s a coding problem, but we will see what happens with your code.

That looks like the authors of the Sylength1 plug-in have added some protection against loading it when there’s a debugger attached, to stop people reverse engineering it. So, in this case, you’ll probably have to disable the debugger anyway, as your first suggested.

Theres a few good collections of freeware plugins that dont feature copy protection you can use to test on, as a lot of the pay ones will have some pretty frusturating anti debugging measures.