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...
 
bool SupportsCustomModulePaths () const override
 
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 bool SupportsCustomModulePaths () const
 
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 140 of file VSTEffectsModule.cpp.

141{
142}

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

312{
313 const auto modulePath = path.BeforeFirst(wxT(';'));
314 return wxFileName::FileExists(modulePath) || wxFileName::DirExists(modulePath);
315}
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 271 of file VSTEffectsModule.cpp.

274{
275
276 VSTEffectBase effect(path);
277 if(effect.InitializePlugin())
278 {
279 auto effectIDs = effect.GetEffectIDs();
280 if(effectIDs.empty())
281 //Each VST plugin path in Audacity should have id(index) part in it
282 effectIDs.push_back(0);
283
284 for(auto id : effectIDs)
285 {
286 //Subsequent VSTEffect::Load may seem like overhead, but we need
287 //to initialize EffectDefinitionInterface part, which includes
288 //properly formatted plugin path
289 VSTEffectBase subeffect(wxString::Format("%s;%d", path, id));
290 subeffect.Load();
291 if(callback)
292 callback(this, &subeffect);
293 }
294 return effectIDs.size();
295 }
296 errMsg = XO("Could not load the library");
297 return 0;
298}
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 144 of file VSTEffectsModule.cpp.

145{
146 FilePaths pathList;
147 FilePaths files;
148
149 // Check for the VST_PATH environment variable
150 wxString vstpath = wxString::FromUTF8(getenv("VST_PATH"));
151 if (!vstpath.empty())
152 {
153 wxStringTokenizer tok(vstpath, wxPATH_SEP);
154 while (tok.HasMoreTokens())
155 {
156 pathList.push_back(tok.GetNextToken());
157 }
158 }
159
160 const auto AddCustomPaths = [](PluginManagerInterface& pm, VSTEffectsModule& module, FilePaths& pathList)
161 {
162 const auto customPaths = pm.ReadCustomPaths(module);
163 std::copy(customPaths.begin(), customPaths.end(), std::back_inserter(pathList));
164 };
165
166#if defined(__WXMAC__)
167#define VSTPATH wxT("/Library/Audio/Plug-Ins/VST")
168
169 // Look in ~/Library/Audio/Plug-Ins/VST and /Library/Audio/Plug-Ins/VST
170 pathList.push_back(wxGetHomeDir() + wxFILE_SEP_PATH + VSTPATH);
171 pathList.push_back(VSTPATH);
172
173 AddCustomPaths(pm, *this, pathList);
174
175 // Recursively search all paths for Info.plist files. This will identify all
176 // bundles.
177 pm.FindFilesInPathList(wxT("Info.plist"), pathList, files, true);
178
179 // Remove the 'Contents/Info.plist' portion of the names
180 for (size_t i = 0; i < files.size(); i++)
181 {
182 files[i] = wxPathOnly(wxPathOnly(files[i]));
183 if (!files[i].EndsWith(wxT(".vst")))
184 {
185 files.erase( files.begin() + i-- );
186 }
187 }
188
189#elif defined(__WXMSW__)
190
191 TCHAR dpath[MAX_PATH];
192 TCHAR tpath[MAX_PATH];
193 DWORD len;
194
195 // Try HKEY_CURRENT_USER registry key first
196 len = WXSIZEOF(tpath);
197 if (SHRegGetUSValue(wxT("Software\\VST"),
198 wxT("VSTPluginsPath"),
199 NULL,
200 tpath,
201 &len,
202 FALSE,
203 NULL,
204 0) == ERROR_SUCCESS)
205 {
206 tpath[len] = 0;
207 dpath[0] = 0;
208 ExpandEnvironmentStrings(tpath, dpath, WXSIZEOF(dpath));
209 pathList.push_back(dpath);
210 }
211
212 // Then try HKEY_LOCAL_MACHINE registry key
213 len = WXSIZEOF(tpath);
214 if (SHRegGetUSValue(wxT("Software\\VST"),
215 wxT("VSTPluginsPath"),
216 NULL,
217 tpath,
218 &len,
219 TRUE,
220 NULL,
221 0) == ERROR_SUCCESS)
222 {
223 tpath[len] = 0;
224 dpath[0] = 0;
225 ExpandEnvironmentStrings(tpath, dpath, WXSIZEOF(dpath));
226 pathList.push_back(dpath);
227 }
228
229 // Add the default path last
230 dpath[0] = 0;
231 ExpandEnvironmentStrings(wxT("%ProgramFiles%\\Steinberg\\VSTPlugins"),
232 dpath,
233 WXSIZEOF(dpath));
234 pathList.push_back(dpath);
235
236 dpath[0] = 0;
237 ExpandEnvironmentStrings(wxT("%COMMONPROGRAMFILES%\\VST2"),
238 dpath,
239 WXSIZEOF(dpath));
240 pathList.push_back(dpath);
241
242 AddCustomPaths(pm, *this, pathList);
243
244 // Recursively scan for all DLLs
245 pm.FindFilesInPathList(wxT("*.dll"), pathList, files, true);
246
247#else
248
249 // Nothing specified in the VST_PATH environment variable...provide defaults
250 if (vstpath.empty())
251 {
252 // We add this "non-default" one
253 pathList.push_back(wxT(LIBDIR) wxT("/vst"));
254
255 // These are the defaults used by other hosts
256 pathList.push_back(wxT("/usr/lib/vst"));
257 pathList.push_back(wxT("/usr/local/lib/vst"));
258 pathList.push_back(wxGetHomeDir() + wxFILE_SEP_PATH + wxT(".vst"));
259 }
260
261 AddCustomPaths(pm, *this, pathList);
262
263 // Recursively scan for all shared objects
264 pm.FindFilesInPathList(wxT("*.so"), pathList, files, true);
265
266#endif
267
268 return { files.begin(), files.end() };
269}
#define VSTPATH
virtual PluginPaths ReadCustomPaths(const PluginProvider &provider)=0
virtual void FindFilesInPathList(const wxString &pattern, const FilePaths &pathList, FilePaths &files, bool directories=false)=0
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
void copy(const T *src, T *dst, int32_t n)
Definition: VectorOps.h:40

References staffpad::vo::copy(), PluginManagerInterface::FindFilesInPathList(), PluginManagerInterface::ReadCustomPaths(), 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 126 of file VSTEffectsModule.cpp.

127{
128 static FileExtensions result{{ _T("vst") }};
129 return result;
130}

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

122{
123 return VSTPLUGINTYPE;
124}
#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 132 of file VSTEffectsModule.cpp.

133{
134 // Not yet ready for VST drag-and-drop...
135 // return FileNames::PlugInDir();
136
137 return {};
138}

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

302{
303 // Acquires a resource for the application.
304 // For us, the ID is simply the path to the effect
305 auto result = Factory::Call(path);
306 if (!result->InitializePlugin())
307 result.reset();
308 return result;
309}
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:

◆ SupportsCustomModulePaths()

bool VSTEffectsModule::SupportsCustomModulePaths ( ) const
overridevirtual

Reimplemented from PluginProvider.

Definition at line 116 of file VSTEffectsModule.cpp.

117{
118 return true;
119}

◆ 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: