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

#include <LoadVamp.h>

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

Public Member Functions

 VampEffectsModule ()
 
virtual ~VampEffectsModule ()
 
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
 

Private Member Functions

std::unique_ptr< Vamp::Plugin > FindPlugin (const PluginPath &wpath, int &output, bool &hasParameters)
 

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 29 of file LoadVamp.h.

Constructor & Destructor Documentation

◆ VampEffectsModule()

VampEffectsModule::VampEffectsModule ( )

Definition at line 56 of file LoadVamp.cpp.

57{
58}

◆ ~VampEffectsModule()

VampEffectsModule::~VampEffectsModule ( )
virtual

Definition at line 60 of file LoadVamp.cpp.

61{
62}

Member Function Documentation

◆ AutoRegisterPlugins()

void VampEffectsModule::AutoRegisterPlugins ( PluginManagerInterface pluginManager)
overridevirtual

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

Implements PluginProvider.

Definition at line 125 of file LoadVamp.cpp.

126{
127}

◆ CheckPluginExist()

bool VampEffectsModule::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 240 of file LoadVamp.cpp.

241{
242 PluginLoader::PluginKey key = path.BeforeFirst(wxT('/')).ToUTF8().data();
243 const auto libraryPathUTF8 = PluginLoader::getInstance()->getLibraryPathForPlugin(key);
244 if(!libraryPathUTF8.empty())
245 return wxFileName::FileExists(wxString::FromUTF8(libraryPathUTF8));
246 return wxFileName::FileExists(path);
247}
wxT("CloseDown"))
static const AudacityProject::AttachedObjects::RegisteredFactory key

References key, and wxT().

Here is the call graph for this function:

◆ DiscoverPluginsAtPath()

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

Implements PluginProvider.

Definition at line 206 of file LoadVamp.cpp.

209{
210 errMsg = {};
211 int output;
212 bool hasParameters;
213
214 auto vp = FindPlugin(path, output, hasParameters);
215 if (vp)
216 {
217 VampEffect effect(std::move(vp), path, output, hasParameters);
218 if (callback)
219 callback( this, &effect );
220
221 return 1;
222 }
223
224 errMsg = XO("Could not load the library");
225 return 0;
226}
XO("Cut/Copy/Paste")
std::unique_ptr< Vamp::Plugin > FindPlugin(const PluginPath &wpath, int &output, bool &hasParameters)
Definition: LoadVamp.cpp:251

References FindPlugin(), and XO().

Here is the call graph for this function:

◆ FindModulePaths()

PluginPaths VampEffectsModule::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 129 of file LoadVamp.cpp.

130{
132
133 PluginLoader *loader = PluginLoader::getInstance();
134
135 PluginLoader::PluginKeyList keys = loader->listPlugins();
136
137 for (PluginLoader::PluginKeyList::iterator i = keys.begin(); i != keys.end(); ++i)
138 {
139 std::unique_ptr<Plugin> vp{ PluginLoader::getInstance()->loadPlugin(*i, 48000) }; // rate doesn't matter here
140 if (!vp)
141 {
142 continue;
143 }
144
145 // We limit the listed plugin outputs to those whose results can
146 // readily be displayed in an Audacity label track.
147 //
148 // - Any output whose features have no values (time instants only),
149 // with or without duration, is fine
150 //
151 // - Any output whose features have more than one value, or an
152 // unknown or variable number of values, is right out
153 //
154 // - Any output whose features have exactly one value, with
155 // variable sample rate or with duration, should be OK --
156 // this implies a sparse feature, of which the time and/or
157 // duration are significant aspects worth displaying
158 //
159 // - An output whose features have exactly one value, with
160 // fixed sample rate and no duration, cannot be usefully
161 // displayed -- the value is the only significant piece of
162 // data there and we have no good value plot
163
164 Plugin::OutputList outputs = vp->getOutputDescriptors();
165
166 int output = 0;
167
168 for (Plugin::OutputList::iterator j = outputs.begin(); j != outputs.end(); ++j)
169 {
170 if (j->sampleType == Plugin::OutputDescriptor::FixedSampleRate ||
171 j->sampleType == Plugin::OutputDescriptor::OneSamplePerStep ||
172 !j->hasFixedBinCount ||
173 j->binCount > 1)
174 {
175 // All of these qualities disqualify (see notes above)
176
177 ++output;
178 continue;
179 }
180
181 wxString name = wxString::FromUTF8(vp->getName().c_str());
182
183 if (outputs.size() > 1)
184 {
185 // This is not the plugin's only output.
186 // Use "plugin name: output name" as the effect name,
187 // unless the output name is the same as the plugin name
188 wxString outputName = wxString::FromUTF8(j->name.c_str());
189 if (outputName != name)
190 {
191 name = wxString::Format(wxT("%s: %s"),
192 name, outputName);
193 }
194 }
195
196 wxString path = wxString::FromUTF8(i->c_str()) + wxT("/") + name;
197 names.push_back(path);
198
199 ++output;
200 }
201 }
202
203 return names;
204}
const TranslatableString name
Definition: Distortion.cpp:74
std::vector< PluginPath > PluginPaths
Definition: Identifier.h:215
static TranslatableStrings names
Definition: TagsEditor.cpp:152

References name, names, and wxT().

Here is the call graph for this function:

◆ FindPlugin()

std::unique_ptr< Vamp::Plugin > VampEffectsModule::FindPlugin ( const PluginPath wpath,
int &  output,
bool &  hasParameters 
)
private

Definition at line 251 of file LoadVamp.cpp.

254{
255 PluginLoader::PluginKey key = path.BeforeFirst(wxT('/')).ToUTF8().data();
256
257 std::unique_ptr<Plugin> vp{ PluginLoader::getInstance()->loadPlugin(key, 48000) }; // rate doesn't matter here
258 if (!vp)
259 {
260 return nullptr;
261 }
262
263 // We limit the listed plugin outputs to those whose results can
264 // readily be displayed in an Audacity label track.
265 //
266 // - Any output whose features have no values (time instants only),
267 // with or without duration, is fine
268 //
269 // - Any output whose features have more than one value, or an
270 // unknown or variable number of values, is right out
271 //
272 // - Any output whose features have exactly one value, with
273 // variable sample rate or with duration, should be OK --
274 // this implies a sparse feature, of which the time and/or
275 // duration are significant aspects worth displaying
276 //
277 // - An output whose features have exactly one value, with
278 // fixed sample rate and no duration, cannot be usefully
279 // displayed -- the value is the only significant piece of
280 // data there and we have no good value plot
281
282 Plugin::OutputList outputs = vp->getOutputDescriptors();
283
284 output = 0;
285
286 hasParameters = !vp->getParameterDescriptors().empty();
287
288 for (Plugin::OutputList::iterator j = outputs.begin(); j != outputs.end(); ++j)
289 {
290 if (j->sampleType == Plugin::OutputDescriptor::FixedSampleRate ||
291 j->sampleType == Plugin::OutputDescriptor::OneSamplePerStep ||
292 !j->hasFixedBinCount ||
293 j->binCount > 1)
294 {
295 // All of these qualities disqualify (see notes above)
296
297 ++output;
298 continue;
299 }
300
301 wxString name = wxString::FromUTF8(vp->getName().c_str());
302
303 if (outputs.size() > 1)
304 {
305 // This is not the plugin's only output.
306 // Use "plugin name: output name" as the effect name,
307 // unless the output name is the same as the plugin name
308 wxString outputName = wxString::FromUTF8(j->name.c_str());
309 if (outputName != name)
310 {
311 name = wxString::Format(wxT("%s: %s"),
312 name, outputName);
313 }
314 }
315
316 if (wxString::FromUTF8(key.c_str()) + wxT("/") + name == path)
317 {
318 return vp;
319 }
320
321 ++output;
322 }
323
324 return {};
325}

References key, name, and wxT().

Referenced by DiscoverPluginsAtPath(), and LoadPlugin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDescription()

TranslatableString VampEffectsModule::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 89 of file LoadVamp.cpp.

90{
91 return XO("Provides Vamp Effects support to Audacity");
92}

References XO().

Here is the call graph for this function:

◆ GetFileExtensions()

const FileExtensions & VampEffectsModule::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 119 of file LoadVamp.cpp.

120{
121 static FileExtensions empty;
122 return empty;
123}
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.

◆ GetOptionalFamilySymbol()

EffectFamilySymbol VampEffectsModule::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 110 of file LoadVamp.cpp.

111{
112#if USE_VAMP
113 return VAMPEFFECTS_FAMILY;
114#else
115 return {};
116#endif
117}
#define VAMPEFFECTS_FAMILY
Definition: VampEffect.h:35

References VAMPEFFECTS_FAMILY.

◆ GetPath()

PluginPath VampEffectsModule::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 68 of file LoadVamp.cpp.

69{
70 return {};
71}

◆ GetSymbol()

ComponentInterfaceSymbol VampEffectsModule::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 73 of file LoadVamp.cpp.

74{
75 return XO("Vamp Effects");
76}

References XO().

Here is the call graph for this function:

◆ GetVendor()

VendorSymbol VampEffectsModule::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 78 of file LoadVamp.cpp.

79{
80 return XO("The Audacity Team");
81}

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString VampEffectsModule::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 83 of file LoadVamp.cpp.

84{
85 // This "may" be different if this were to be maintained as a separate DLL
87}
#define VAMPEFFECTS_VERSION
Definition: VampEffect.h:32

References VAMPEFFECTS_VERSION.

◆ Initialize()

bool VampEffectsModule::Initialize ( )
overridevirtual

Called immediately after creation. Let provider initialize.

Returns
"true" if initialization was successful

Implements PluginProvider.

Definition at line 98 of file LoadVamp.cpp.

99{
100 // Nothing to do here
101 return true;
102}

◆ InstallPath()

FilePath VampEffectsModule::InstallPath ( )
inlineoverridevirtual

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 50 of file LoadVamp.h.

50{ return {}; }

◆ LoadPlugin()

std::unique_ptr< ComponentInterface > VampEffectsModule::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 229 of file LoadVamp.cpp.

230{
231 // Acquires a resource for the application.
232 int output;
233 bool hasParameters;
234
235 if (auto vp = FindPlugin(path, output, hasParameters))
236 return std::make_unique<VampEffect>(std::move(vp), path, output, hasParameters);
237 return nullptr;
238}

References FindPlugin().

Here is the call graph for this function:

◆ Terminate()

void VampEffectsModule::Terminate ( )
overridevirtual

Called just prior to deletion to allow releasing any resources.

Implements PluginProvider.

Definition at line 104 of file LoadVamp.cpp.

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

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