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

#include <VSTEffectsModule.h>

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

Classes

struct  Factory
 

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 21 of file VSTEffectsModule.h.

Constructor & Destructor Documentation

◆ VSTEffectsModule()

VSTEffectsModule::VSTEffectsModule ( )

Auto created at program start up, this initialises VST.

Definition at line 62 of file VSTEffectsModule.cpp.

63{
64}

◆ ~VSTEffectsModule()

VSTEffectsModule::~VSTEffectsModule ( )
virtual

Definition at line 66 of file VSTEffectsModule.cpp.

67{
68}

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 135 of file VSTEffectsModule.cpp.

136{
137}

◆ 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 294 of file VSTEffectsModule.cpp.

295{
296 const auto modulePath = path.BeforeFirst(wxT(';'));
297 return wxFileName::FileExists(modulePath) || wxFileName::DirExists(modulePath);
298}
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 254 of file VSTEffectsModule.cpp.

257{
258
259 VSTEffectBase effect(path);
260 if(effect.InitializePlugin())
261 {
262 auto effectIDs = effect.GetEffectIDs();
263 if(effectIDs.empty())
264 //Each VST plugin path in Audacity should have id(index) part in it
265 effectIDs.push_back(0);
266
267 for(auto id : effectIDs)
268 {
269 //Subsequent VSTEffect::Load may seem like overhead, but we need
270 //to initialize EffectDefinitionInterface part, which includes
271 //properly formatted plugin path
272 VSTEffectBase subeffect(wxString::Format("%s;%d", path, id));
273 subeffect.Load();
274 if(callback)
275 callback(this, &subeffect);
276 }
277 return effectIDs.size();
278 }
279 errMsg = XO("Could not load the library");
280 return 0;
281}
XO("Cut/Copy/Paste")

References VSTEffectBase::GetEffectIDs(), VSTEffectBase::InitializePlugin(), VSTWrapper::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 139 of file VSTEffectsModule.cpp.

140{
141 FilePaths pathList;
142 FilePaths files;
143
144 // Check for the VST_PATH environment variable
145 wxString vstpath = wxString::FromUTF8(getenv("VST_PATH"));
146 if (!vstpath.empty())
147 {
148 wxStringTokenizer tok(vstpath, wxPATH_SEP);
149 while (tok.HasMoreTokens())
150 {
151 pathList.push_back(tok.GetNextToken());
152 }
153 }
154
155#if defined(__WXMAC__)
156#define VSTPATH wxT("/Library/Audio/Plug-Ins/VST")
157
158 // Look in ~/Library/Audio/Plug-Ins/VST and /Library/Audio/Plug-Ins/VST
159 pathList.push_back(wxGetHomeDir() + wxFILE_SEP_PATH + VSTPATH);
160 pathList.push_back(VSTPATH);
161
162 // Recursively search all paths for Info.plist files. This will identify all
163 // bundles.
164 pm.FindFilesInPathList(wxT("Info.plist"), pathList, files, true);
165
166 // Remove the 'Contents/Info.plist' portion of the names
167 for (size_t i = 0; i < files.size(); i++)
168 {
169 files[i] = wxPathOnly(wxPathOnly(files[i]));
170 if (!files[i].EndsWith(wxT(".vst")))
171 {
172 files.erase( files.begin() + i-- );
173 }
174 }
175
176#elif defined(__WXMSW__)
177
178 TCHAR dpath[MAX_PATH];
179 TCHAR tpath[MAX_PATH];
180 DWORD len;
181
182 // Try HKEY_CURRENT_USER registry key first
183 len = WXSIZEOF(tpath);
184 if (SHRegGetUSValue(wxT("Software\\VST"),
185 wxT("VSTPluginsPath"),
186 NULL,
187 tpath,
188 &len,
189 FALSE,
190 NULL,
191 0) == ERROR_SUCCESS)
192 {
193 tpath[len] = 0;
194 dpath[0] = 0;
195 ExpandEnvironmentStrings(tpath, dpath, WXSIZEOF(dpath));
196 pathList.push_back(dpath);
197 }
198
199 // Then try HKEY_LOCAL_MACHINE registry key
200 len = WXSIZEOF(tpath);
201 if (SHRegGetUSValue(wxT("Software\\VST"),
202 wxT("VSTPluginsPath"),
203 NULL,
204 tpath,
205 &len,
206 TRUE,
207 NULL,
208 0) == ERROR_SUCCESS)
209 {
210 tpath[len] = 0;
211 dpath[0] = 0;
212 ExpandEnvironmentStrings(tpath, dpath, WXSIZEOF(dpath));
213 pathList.push_back(dpath);
214 }
215
216 // Add the default path last
217 dpath[0] = 0;
218 ExpandEnvironmentStrings(wxT("%ProgramFiles%\\Steinberg\\VSTPlugins"),
219 dpath,
220 WXSIZEOF(dpath));
221 pathList.push_back(dpath);
222
223 dpath[0] = 0;
224 ExpandEnvironmentStrings(wxT("%COMMONPROGRAMFILES%\\VST2"),
225 dpath,
226 WXSIZEOF(dpath));
227 pathList.push_back(dpath);
228
229 // Recursively scan for all DLLs
230 pm.FindFilesInPathList(wxT("*.dll"), pathList, files, true);
231
232#else
233
234 // Nothing specified in the VST_PATH environment variable...provide defaults
235 if (vstpath.empty())
236 {
237 // We add this "non-default" one
238 pathList.push_back(wxT(LIBDIR) wxT("/vst"));
239
240 // These are the defaults used by other hosts
241 pathList.push_back(wxT("/usr/lib/vst"));
242 pathList.push_back(wxT("/usr/local/lib/vst"));
243 pathList.push_back(wxGetHomeDir() + wxFILE_SEP_PATH + wxT(".vst"));
244 }
245
246 // Recursively scan for all shared objects
247 pm.FindFilesInPathList(wxT("*.so"), pathList, files, true);
248
249#endif
250
251 return { files.begin(), files.end() };
252}
#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 95 of file VSTEffectsModule.cpp.

96{
97 return XO("Adds the ability to use VST effects in Audacity.");
98}

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 121 of file VSTEffectsModule.cpp.

122{
123 static FileExtensions result{{ _T("vst") }};
124 return result;
125}

◆ 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 116 of file VSTEffectsModule.cpp.

117{
118 return VSTPLUGINTYPE;
119}
#define VSTPLUGINTYPE
Definition: VSTEffectBase.h:22

References VSTPLUGINTYPE.

◆ GetPath()

PluginPath VSTEffectsModule::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 74 of file VSTEffectsModule.cpp.

75{
76 return {};
77}

◆ GetSymbol()

ComponentInterfaceSymbol VSTEffectsModule::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 79 of file VSTEffectsModule.cpp.

80{
81 return XO("VST Effects");
82}

References XO().

Here is the call graph for this function:

◆ GetVendor()

VendorSymbol VSTEffectsModule::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 84 of file VSTEffectsModule.cpp.

85{
86 return XO("The Audacity Team");
87}

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString VSTEffectsModule::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 89 of file VSTEffectsModule.cpp.

90{
91 // This "may" be different if this were to be maintained as a separate DLL
92 return AUDACITY_VERSION_STRING;
93}

◆ Initialize()

bool VSTEffectsModule::Initialize ( )
overridevirtual

Called immediately after creation. Let provider initialize.

Returns
"true" if initialization was successful

Implements PluginProvider.

Definition at line 104 of file VSTEffectsModule.cpp.

105{
106 // Nothing to do here
107 return true;
108}

◆ 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 127 of file VSTEffectsModule.cpp.

128{
129 // Not yet ready for VST drag-and-drop...
130 // return FileNames::PlugInDir();
131
132 return {};
133}

◆ 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 284 of file VSTEffectsModule.cpp.

285{
286 // Acquires a resource for the application.
287 // For us, the ID is simply the path to the effect
288 auto result = Factory::Call(path);
289 if (!result->InitializePlugin())
290 result.reset();
291 return result;
292}
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.

References GlobalHook< Factory, std::remove_pointer_t< decltype(DefaultFunction)>, DefaultFunction, Options... >::Call().

Here is the call graph for this function:

◆ Terminate()

void VSTEffectsModule::Terminate ( )
overridevirtual

Called just prior to deletion to allow releasing any resources.

Implements PluginProvider.

Definition at line 110 of file VSTEffectsModule.cpp.

111{
112 // Nothing to do here
113 return;
114}

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