Does anyone have any information regarding writing a JUCE plugin host, The pluginhost example is quite complicated, so I would like to write one from scratch, with only VST3 plugins.
I have seen a JUCE specific tutorial in another post but the link is broken.
There are at least a couple of problems in the code you posted.
You need to call AudioPluginFormatManager:: addDefaultFormats and you also need to enable hosting of the desired plugin formats in your build system before trying to create the plugins.
The uniqueId in the PluginDescription probably can’t be an arbitrary number like 0, it likely needs be initialized to the actual ID of the plugin. (For example VST3 allows several plugins in the same plugin binary, so it’s not enough to provide just the plugin binary file path to instantiate the plugin.) I unfortunately don’t have the code at hand right now how to properly get the ID.
Unfortunately it’s not just a simple dependency addition. One also needs to consider the licensing implications, Tracktion Engine has its own license and financial cost on top of the Juce ones.
OK, wrote some code that works for me on Windows/Juce 8. Note that this assumes the VST3 hosting is enabled in your build system, which does not happen by default.
class MyHost
{
public:
MyHost()
{
pluginmanager.addDefaultFormats();
// the single .vst3 file may have multiple plugin types, so we need to deal with an array
// of PluginDescriptions
juce::OwnedArray<juce::PluginDescription> descs;
juce::VST3PluginFormat v3format;
v3format.findAllTypesForFile(descs,
R"(C:\Program Files\Common Files\VST3\ValhallaRoom.vst3)");
if (descs.size() > 0)
{
juce::String error;
plugin_instance = pluginmanager.createPluginInstance(*descs[0], 44100, 512, error);
if (!plugin_instance)
{
std::cout << error << "\n";
}
else
{
std::cout << "created " << descs[0]->descriptiveName << "\n";
}
}
}
private:
juce::AudioPluginFormatManager pluginmanager;
std::unique_ptr<juce::AudioPluginInstance> plugin_instance;
};
Yes thnx, worked fine. I have added to the pluginhost from scratch project to scan for VST3 plugins. Does anybody have at least an order of operations. Note enable VST3 pluginhost and make it a console application in producer and windows only.
#include <JuceHeader.h>
class MyHost
{
public:
MyHost()
{
scanPlugins();
pluginmanager.addDefaultFormats();
// the single .vst3 file may have multiple plugin types, so we need to deal with an array
// of PluginDescriptions
juce::OwnedArray<juce::PluginDescription> descs;
juce::VST3PluginFormat v3format;
v3format.findAllTypesForFile(descs,
R"(C:\Program Files\Common Files\VST3\SnareBuzz.vst3)");
if (descs.size() > 0)
{
juce::String error;
plugin_instance = pluginmanager.createPluginInstance(*descs[0], 44100, 512, error);
if (!plugin_instance)
{
std::cout << error << "\n";
}
else
{
std::cout << "created " << descs[0]->descriptiveName << "\n";
}
}
}
void scanPlugins()
{
scanner.reset(new juce::PluginDirectoryScanner(knownPluginList,
pluginFormat,
searchPath,
true,
juce::File(),
true));
while (scanner->scanNextFile(true, plugin))
{
juce::File file = plugin;
auto plugin_name = file.getFileNameWithoutExtension();
pluginlist.add(plugin_name);
std::cout << "found " << plugin_name.toStdString() << "\n";
}
num_plugin = pluginlist.size();
}
private:
juce::AudioPluginFormatManager pluginmanager;
std::unique_ptr<juce::AudioPluginInstance> plugin_instance;
juce::VST3PluginFormat pluginFormat;
std::unique_ptr<juce::PluginDirectoryScanner> scanner;
juce::KnownPluginList knownPluginList;
juce::FileSearchPath searchPath = "C:\\Program Files\\Common Files\\VST3";
juce::String plugin;
juce::StringArray pluginlist;
int num_plugin = 0;
};
Is anyone interested in providing information or collaborating?
I was told to find a niche, I have built up a GUI for a MIDI synthesizer, which is somewhat different. I found the JUCE plugin host too complicated, and wanted to improve my C++ by writing it from scratch. How do software engineers work things out from just the documentation? A basic outline of the steps involved would be of great help.