Audacity 3.2.0
Public Member Functions | List of all members
VSTEffectsModule Class Referencefinal

#include <VSTEffect.h>

Inheritance diagram for VSTEffectsModule:
[legend]
Collaboration diagram for VSTEffectsModule:
[legend]

Public Member Functions

 VSTEffectsModule ()
 
virtual ~VSTEffectsModule ()
 
PluginPath GetPath () const override
 
ComponentInterfaceSymbol GetSymbol () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
TranslatableString GetDescription () const override
 
bool Initialize () override
 Called immediately after creation. Let provider initialize. More...
 
void Terminate () override
 Called just prior to deletion to allow releasing any resources. More...
 
EffectFamilySymbol GetOptionalFamilySymbol () override
 A symbol identifying the family of plug-ins provided by this. More...
 
const FileExtensionsGetFileExtensions () override
 File types associated with this protocol. More...
 
FilePath InstallPath () override
 Where plug-in files should be copied to install them. More...
 
void AutoRegisterPlugins (PluginManagerInterface &pm) override
 Called so that a provider of a static set of plug-ins can register them. More...
 
PluginPaths FindModulePaths (PluginManagerInterface &pm) override
 
unsigned DiscoverPluginsAtPath (const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
 
bool CheckPluginExist (const PluginPath &path) const override
 Performs plugin/module existence check, still plugin may fail to load. Implementation should avoid loading plugins during this check. More...
 
std::unique_ptr< ComponentInterfaceLoadPlugin (const PluginPath &path) override
 Load the plug-in at a path reported by DiscoverPluginsAtPath. More...
 
- Public Member Functions inherited from PluginProvider
virtual ~PluginProvider ()
 
virtual bool Initialize ()=0
 Called immediately after creation. Let provider initialize. More...
 
virtual void Terminate ()=0
 Called just prior to deletion to allow releasing any resources. More...
 
virtual EffectFamilySymbol GetOptionalFamilySymbol ()=0
 A symbol identifying the family of plug-ins provided by this. More...
 
virtual const FileExtensionsGetFileExtensions ()=0
 File types associated with this protocol. More...
 
virtual FilePath InstallPath ()=0
 Where plug-in files should be copied to install them. More...
 
virtual void AutoRegisterPlugins (PluginManagerInterface &pluginManager)=0
 Called so that a provider of a static set of plug-ins can register them. More...
 
virtual PluginPaths FindModulePaths (PluginManagerInterface &pluginManager)=0
 
virtual unsigned DiscoverPluginsAtPath (const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback)=0
 
virtual bool CheckPluginExist (const PluginPath &path) const =0
 Performs plugin/module existence check, still plugin may fail to load. Implementation should avoid loading plugins during this check. More...
 
virtual std::unique_ptr< ValidatorMakeValidator () const
 
virtual std::unique_ptr< ComponentInterfaceLoadPlugin (const PluginPath &path)=0
 Load the plug-in at a path reported by DiscoverPluginsAtPath. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 

Additional Inherited Members

- Public Types inherited from PluginProvider
using RegistrationCallback = std::function< const PluginID &(PluginProvider *, ComponentInterface *) >
 Further expand a path reported by FindModulePaths. More...
 

Detailed Description

Definition at line 447 of file VSTEffect.h.

Constructor & Destructor Documentation

◆ VSTEffectsModule()

VSTEffectsModule::VSTEffectsModule ( )

Auto created at program start up, this initialises VST.

Definition at line 166 of file VSTEffect.cpp.

167{
168}

◆ ~VSTEffectsModule()

VSTEffectsModule::~VSTEffectsModule ( )
virtual

Definition at line 170 of file VSTEffect.cpp.

171{
172}

Member Function Documentation

◆ AutoRegisterPlugins()

void VSTEffectsModule::AutoRegisterPlugins ( PluginManagerInterface pluginManager)
overridevirtual

Called so that a provider of a static set of plug-ins can register them.

Implements PluginProvider.

Definition at line 243 of file VSTEffect.cpp.

244{
245}

◆ CheckPluginExist()

bool VSTEffectsModule::CheckPluginExist ( const PluginPath path) const
overridevirtual

Performs plugin/module existence check, still plugin may fail to load. Implementation should avoid loading plugins during this check.

Parameters
pathInternal plugin path/ID discovered via DiscoverPluginsAtPath or module path returned by FindModulePaths

Implements PluginProvider.

Definition at line 402 of file VSTEffect.cpp.

403{
404 const auto modulePath = path.BeforeFirst(wxT(';'));
405 return wxFileName::FileExists(modulePath) || wxFileName::DirExists(modulePath);
406}
wxT("CloseDown"))

References wxT().

Here is the call graph for this function:

◆ DiscoverPluginsAtPath()

unsigned VSTEffectsModule::DiscoverPluginsAtPath ( const PluginPath path,
TranslatableString errMsg,
const RegistrationCallback callback 
)
overridevirtual

Implements PluginProvider.

Definition at line 362 of file VSTEffect.cpp.

365{
366
367 VSTEffect effect(path);
368 if(effect.InitializePlugin())
369 {
370 auto effectIDs = effect.GetEffectIDs();
371 if(effectIDs.empty())
372 //Each VST plugin path in Audacity should have id(index) part in it
373 effectIDs.push_back(0);
374
375 for(auto id : effectIDs)
376 {
377 //Subsequent VSTEffect::Load may seem like overhead, but we need
378 //to initialize EffectDefinitionInterface part, which includes
379 //properly formatted plugin path
380 VSTEffect subeffect(wxString::Format("%s;%d", path, id));
381 subeffect.Load();
382 if(callback)
383 callback(this, &subeffect);
384 }
385 return effectIDs.size();
386 }
387 errMsg = XO("Could not load the library");
388 return 0;
389}
XO("Cut/Copy/Paste")

References VSTEffect::GetEffectIDs(), VSTEffect::InitializePlugin(), VSTEffectWrapper::Load(), and XO().

Here is the call graph for this function:

◆ FindModulePaths()

PluginPaths VSTEffectsModule::FindModulePaths ( PluginManagerInterface pluginManager)
overridevirtual

Find available "paths", which may each be presented to the user, and then reexamined (possibly loading libraries) to find one or more plug-ins

Paths are not necessarily file system paths. Only the provider reinterprets the paths.

Modules may be associated with plug-ins, one-to-many.

See also
GetFileExtensions DiscoverPluginsAtPath

Implements PluginProvider.

Definition at line 247 of file VSTEffect.cpp.

248{
249 FilePaths pathList;
250 FilePaths files;
251
252 // Check for the VST_PATH environment variable
253 wxString vstpath = wxString::FromUTF8(getenv("VST_PATH"));
254 if (!vstpath.empty())
255 {
256 wxStringTokenizer tok(vstpath, wxPATH_SEP);
257 while (tok.HasMoreTokens())
258 {
259 pathList.push_back(tok.GetNextToken());
260 }
261 }
262
263#if defined(__WXMAC__)
264#define VSTPATH wxT("/Library/Audio/Plug-Ins/VST")
265
266 // Look in ~/Library/Audio/Plug-Ins/VST and /Library/Audio/Plug-Ins/VST
267 pathList.push_back(wxGetHomeDir() + wxFILE_SEP_PATH + VSTPATH);
268 pathList.push_back(VSTPATH);
269
270 // Recursively search all paths for Info.plist files. This will identify all
271 // bundles.
272 pm.FindFilesInPathList(wxT("Info.plist"), pathList, files, true);
273
274 // Remove the 'Contents/Info.plist' portion of the names
275 for (size_t i = 0; i < files.size(); i++)
276 {
277 files[i] = wxPathOnly(wxPathOnly(files[i]));
278 if (!files[i].EndsWith(wxT(".vst")))
279 {
280 files.erase( files.begin() + i-- );
281 }
282 }
283
284#elif defined(__WXMSW__)
285
286 TCHAR dpath[MAX_PATH];
287 TCHAR tpath[MAX_PATH];
288 DWORD len;
289
290 // Try HKEY_CURRENT_USER registry key first
291 len = WXSIZEOF(tpath);
292 if (SHRegGetUSValue(wxT("Software\\VST"),
293 wxT("VSTPluginsPath"),
294 NULL,
295 tpath,
296 &len,
297 FALSE,
298 NULL,
299 0) == ERROR_SUCCESS)
300 {
301 tpath[len] = 0;
302 dpath[0] = 0;
303 ExpandEnvironmentStrings(tpath, dpath, WXSIZEOF(dpath));
304 pathList.push_back(dpath);
305 }
306
307 // Then try HKEY_LOCAL_MACHINE registry key
308 len = WXSIZEOF(tpath);
309 if (SHRegGetUSValue(wxT("Software\\VST"),
310 wxT("VSTPluginsPath"),
311 NULL,
312 tpath,
313 &len,
314 TRUE,
315 NULL,
316 0) == ERROR_SUCCESS)
317 {
318 tpath[len] = 0;
319 dpath[0] = 0;
320 ExpandEnvironmentStrings(tpath, dpath, WXSIZEOF(dpath));
321 pathList.push_back(dpath);
322 }
323
324 // Add the default path last
325 dpath[0] = 0;
326 ExpandEnvironmentStrings(wxT("%ProgramFiles%\\Steinberg\\VSTPlugins"),
327 dpath,
328 WXSIZEOF(dpath));
329 pathList.push_back(dpath);
330
331 dpath[0] = 0;
332 ExpandEnvironmentStrings(wxT("%COMMONPROGRAMFILES%\\VST2"),
333 dpath,
334 WXSIZEOF(dpath));
335 pathList.push_back(dpath);
336
337 // Recursively scan for all DLLs
338 pm.FindFilesInPathList(wxT("*.dll"), pathList, files, true);
339
340#else
341
342 // Nothing specified in the VST_PATH environment variable...provide defaults
343 if (vstpath.empty())
344 {
345 // We add this "non-default" one
346 pathList.push_back(wxT(LIBDIR) wxT("/vst"));
347
348 // These are the defaults used by other hosts
349 pathList.push_back(wxT("/usr/lib/vst"));
350 pathList.push_back(wxT("/usr/local/lib/vst"));
351 pathList.push_back(wxGetHomeDir() + wxFILE_SEP_PATH + wxT(".vst"));
352 }
353
354 // Recursively scan for all shared objects
355 pm.FindFilesInPathList(wxT("*.so"), pathList, files, true);
356
357#endif
358
359 return { files.begin(), files.end() };
360}
#define VSTPATH
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.

References PluginManagerInterface::FindFilesInPathList(), VSTPATH, and wxT().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString VSTEffectsModule::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 199 of file VSTEffect.cpp.

200{
201 return XO("Adds the ability to use VST effects in Audacity.");
202}

References XO().

Here is the call graph for this function:

◆ GetFileExtensions()

const FileExtensions & VSTEffectsModule::GetFileExtensions ( )
overridevirtual

File types associated with this protocol.

"Paths" returned by FindModulePaths() and passed back to DiscoverPluginsAtPath() have provider-specific meaning. They are not necessarily file system paths to existent files that could be placed in any folder and queried for plug-in information.

This function returns nonempty only when that is the case, and lists the possible extensions of such files (an empty string in a nonempty array means any file is a candidate).

Implements PluginProvider.

Definition at line 229 of file VSTEffect.cpp.

230{
231 static FileExtensions result{{ _T("vst") }};
232 return result;
233}

◆ GetOptionalFamilySymbol()

EffectFamilySymbol VSTEffectsModule::GetOptionalFamilySymbol ( )
overridevirtual

A symbol identifying the family of plug-ins provided by this.

If it is not empty, then the family as a whole can be enabled or disabled by the user in Preferences

Implements PluginProvider.

Definition at line 220 of file VSTEffect.cpp.

221{
222#if USE_VST
223 return VSTPLUGINTYPE;
224#else
225 return {};
226#endif
227}
#define VSTPLUGINTYPE
Definition: VSTEffect.h:41

References VSTPLUGINTYPE.

◆ GetPath()

PluginPath VSTEffectsModule::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 178 of file VSTEffect.cpp.

179{
180 return {};
181}

◆ GetSymbol()

ComponentInterfaceSymbol VSTEffectsModule::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 183 of file VSTEffect.cpp.

184{
185 return XO("VST Effects");
186}

References XO().

Here is the call graph for this function:

◆ GetVendor()

VendorSymbol VSTEffectsModule::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 188 of file VSTEffect.cpp.

189{
190 return XO("The Audacity Team");
191}

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString VSTEffectsModule::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 193 of file VSTEffect.cpp.

194{
195 // This "may" be different if this were to be maintained as a separate DLL
196 return AUDACITY_VERSION_STRING;
197}

◆ Initialize()

bool VSTEffectsModule::Initialize ( )
overridevirtual

Called immediately after creation. Let provider initialize.

Returns
"true" if initialization was successful

Implements PluginProvider.

Definition at line 208 of file VSTEffect.cpp.

209{
210 // Nothing to do here
211 return true;
212}

◆ InstallPath()

FilePath VSTEffectsModule::InstallPath ( )
overridevirtual

Where plug-in files should be copied to install them.

Returns
may be empty. Drag-and-drop is supported only if GetFileExtensions() returns nonempty and this function returns nonempty.

Implements PluginProvider.

Definition at line 235 of file VSTEffect.cpp.

236{
237 // Not yet ready for VST drag-and-drop...
238 // return FileNames::PlugInDir();
239
240 return {};
241}

◆ LoadPlugin()

std::unique_ptr< ComponentInterface > VSTEffectsModule::LoadPlugin ( const PluginPath path)
overridevirtual

Load the plug-in at a path reported by DiscoverPluginsAtPath.

Returns
smart pointer managing the later unloading

Implements PluginProvider.

Definition at line 392 of file VSTEffect.cpp.

393{
394 // Acquires a resource for the application.
395 // For us, the ID is simply the path to the effect
396 auto result = std::make_unique<VSTEffect>(path);
397 if (!result->InitializePlugin())
398 result.reset();
399 return result;
400}

◆ Terminate()

void VSTEffectsModule::Terminate ( )
overridevirtual

Called just prior to deletion to allow releasing any resources.

Implements PluginProvider.

Definition at line 214 of file VSTEffect.cpp.

215{
216 // Nothing to do here
217 return;
218}

The documentation for this class was generated from the following files: