18#include <wx/stdpaths.h>
39 return std::make_unique<VST3EffectsModule>();
54 wxDirTraverseResult
OnFile(
const wxString& filename)
override
56 if(filename.Matches(
"*.vst3"))
58 return wxDIR_CONTINUE;
60 wxDirTraverseResult
OnDir(
const wxString& dirname)
override
62 if(dirname.Matches(
"*.vst3"))
67 return wxDIR_CONTINUE;
76 if(
auto lock = it->second.lock())
80 std::string moduleCreateError;
83 auto module = VST3::Hosting::Module::create(path.ToStdString(), moduleCreateError);
85 throw std::runtime_error(moduleCreateError.c_str());
100 return XO(
"VST3 Effects");
105 return XO(
"The Audacity Team");
110 return AUDACITY_VERSION_STRING;
115 return XO(
"Adds the ability to use VST3 effects in Audacity.");
142#ifdef VST3_DEFAULT_INSTALL_PATH
143 return FilePath { VST3_DEFAULT_INSTALL_PATH };
168 wxString programFilesPath;
169 if(wxGetEnv(
"programfiles", &programFilesPath))
170 pathList.push_back(programFilesPath +
"\\Common Files\\VST3");
173 pathList.push_back(
"~/Library/Audio/Plug-ins/VST3/");
174 pathList.push_back(
"/Library/Audio/Plug-ins/VST3/");
175 pathList.push_back(
"/Network/Library/Audio/Plug-ins/VST3/");
177 pathList.push_back(wxGetHomeDir() +
"/.vst3/");
178 pathList.push_back(
"/usr/lib/vst3/");
179 pathList.push_back(
"/usr/local/lib/vst3/");
186 path.AppendDir(
"vst3");
188 path.AppendDir(
"VST3");
190 pathList.push_back(path.GetPath());
194 std::copy(customPaths.begin(), customPaths.end(), std::back_inserter(pathList));
199 result.push_back(pluginPath);
202 for(
const auto& path : pathList)
206 dir.Traverse(vst3PluginTraverser, wxEmptyString, wxDIR_DEFAULT);
218 const auto moduleFactory = module->getFactory();
219 auto nEffects { 0u };
220 for(
auto& classInfo : moduleFactory.classInfos())
222 if(classInfo.category() == kVstAudioEffectClass)
224 std::unique_ptr<VST3EffectBase> effect;
230 catch(std::exception& e)
233 "Effect %s@%s cannot be loaded: %s",
234 classInfo.name().c_str(),
242 "Effect %s@%s cannot be loaded: unknown error",
243 classInfo.name().c_str(),
247 if(effect && callback)
248 callback(
this, effect.get());
252 throw std::runtime_error(
"no effects found");
256 catch(std::exception& e)
258 errMsg =
XO(
"VST3 module error: %s").Format(e.what());
264std::unique_ptr<ComponentInterface>
270 std::string effectUIDString;
273 throw std::runtime_error(
"failed to parse plugin string");
276 const auto pluginFactory = module->getFactory();
277 for(
const auto& classInfo : pluginFactory.classInfos())
279 if(effectUIDString == classInfo.ID().toString()) {
284 throw std::runtime_error(
"effect UID not found");
286 catch(std::exception& e)
288 wxLogError(
"VST3 Module was not loaded: %s", e.what());
302 *vst3effect->mModule,
303 vst3effect->mEffectClassInfo
308 throw std::runtime_error(
"Not a VST3Effect");
315 return std::make_unique<VST3PluginValidator>();
323 return wxFileName::FileExists(modulePath) || wxFileName::DirExists(modulePath);
325 return wxFileName::FileExists(path) || wxFileName::DirExists(path);
std::vector< PluginPath > PluginPaths
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Generalized interface for discovery of plug-ins for one protocol.
DECLARE_PROVIDER_ENTRY(AudacityModule)
DECLARE_BUILTIN_PROVIDER(VST3Builtin)
static IHostApplication & Get()
ComponentInterface provides name / vendor / version functions to identify plugins....
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.
virtual PluginPaths ReadCustomPaths(const PluginProvider &provider)=0
std::function< const PluginID &(PluginProvider *, ComponentInterface *) > RegistrationCallback
Further expand a path reported by FindModulePaths.
Holds a msgid for the translation catalog; may also bind format arguments.
Objects of this class connect Audacity with VST3 effects.
static EffectFamilySymbol GetFamilySymbol()
void AutoRegisterPlugins(PluginManagerInterface &pluginManager) override
Called so that a provider of a static set of plug-ins can register them.
const FileExtensions & GetFileExtensions() override
File types associated with this protocol.
PluginPaths FindModulePaths(PluginManagerInterface &pluginManager) override
std::unique_ptr< ComponentInterface > LoadPlugin(const PluginPath &path) override
Load the plug-in at a path reported by DiscoverPluginsAtPath.
void Terminate() override
Called just prior to deletion to allow releasing any resources.
std::unique_ptr< Validator > MakeValidator() const override
TranslatableString GetDescription() const override
bool CheckPluginExist(const PluginPath &path) const override
Performs plugin/module existence check, still plugin may fail to load. Implementation should avoid lo...
FilePath InstallPath() override
Where plug-in files should be copied to install them.
EffectFamilySymbol GetOptionalFamilySymbol() override
A symbol identifying the family of plug-ins provided by this.
bool Initialize() override
Called immediately after creation. Let provider initialize.
VendorSymbol GetVendor() const override
std::unordered_map< wxString, std::weak_ptr< VST3::Hosting::Module > > mModules
wxString GetVersion() const override
PluginPath GetPath() const override
ComponentInterfaceSymbol GetSymbol() const override
std::shared_ptr< VST3::Hosting::Module > GetModule(const wxString &path)
bool SupportsCustomModulePaths() const override
unsigned DiscoverPluginsAtPath(const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
wxDirTraverseResult OnFile(const wxString &filename) override
wxDirTraverseResult OnDir(const wxString &dirname) override
VST3PluginTraverser(std::function< void(const wxString &)> onPluginFound)
std::function< void(const wxString &)> mOnPluginFound
void Validate(ComponentInterface &component) override
static bool ParsePluginPath(const wxString &pluginPath, wxString *modulePath, std::string *effectUIDString)
void InitializeComponents()
Should be called once before almost any other method call.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
void copy(const T *src, T *dst, int32_t n)