Audacity  3.0.3
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 () override
 
ComponentInterfaceSymbol GetSymbol () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
TranslatableString GetDescription () override
 
bool Initialize () override
 
void Terminate () override
 
EffectFamilySymbol GetOptionalFamilySymbol () override
 
const FileExtensionsGetFileExtensions () override
 
FilePath InstallPath () override
 
bool AutoRegisterPlugins (PluginManagerInterface &pm) override
 
PluginPaths FindPluginPaths (PluginManagerInterface &pm) override
 
unsigned DiscoverPluginsAtPath (const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
 
bool IsPluginValid (const PluginPath &path, bool bFast) override
 
std::unique_ptr< ComponentInterfaceCreateInstance (const PluginPath &path) override
 
- Public Member Functions inherited from ModuleInterface
virtual ~ModuleInterface ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 

Private Member Functions

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

Additional Inherited Members

- Public Types inherited from ModuleInterface
using RegistrationCallback = std::function< const PluginID &(ModuleInterface *, ComponentInterface *) >
 

Detailed Description

Definition at line 29 of file LoadVamp.h.

Constructor & Destructor Documentation

◆ VampEffectsModule()

VampEffectsModule::VampEffectsModule ( )

Definition at line 55 of file LoadVamp.cpp.

56 {
57 }

◆ ~VampEffectsModule()

VampEffectsModule::~VampEffectsModule ( )
virtual

Definition at line 59 of file LoadVamp.cpp.

60 {
61 }

Member Function Documentation

◆ AutoRegisterPlugins()

bool VampEffectsModule::AutoRegisterPlugins ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 124 of file LoadVamp.cpp.

125 {
126  return false;
127 }

◆ CreateInstance()

std::unique_ptr< ComponentInterface > VampEffectsModule::CreateInstance ( const PluginPath path)
overridevirtual

Implements ModuleInterface.

Definition at line 240 of file LoadVamp.cpp.

241 {
242  // Acquires a resource for the application.
243  int output;
244  bool hasParameters;
245 
246  if (auto vp = FindPlugin(path, output, hasParameters))
247  return std::make_unique<VampEffect>(std::move(vp), path, output, hasParameters);
248  return nullptr;
249 }

◆ DiscoverPluginsAtPath()

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

Implements ModuleInterface.

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 }

References XO.

◆ FindPlugin()

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

Definition at line 253 of file LoadVamp.cpp.

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

References key, and name.

◆ FindPluginPaths()

PluginPaths VampEffectsModule::FindPluginPaths ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

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 }

References name, and names.

◆ GetDescription()

TranslatableString VampEffectsModule::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 88 of file LoadVamp.cpp.

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

References XO.

◆ GetFileExtensions()

const FileExtensions & VampEffectsModule::GetFileExtensions ( )
overridevirtual

Implements ModuleInterface.

Definition at line 118 of file LoadVamp.cpp.

119 {
120  static FileExtensions empty;
121  return empty;
122 }

◆ GetOptionalFamilySymbol()

EffectFamilySymbol VampEffectsModule::GetOptionalFamilySymbol ( )
overridevirtual

Implements ModuleInterface.

Definition at line 109 of file LoadVamp.cpp.

110 {
111 #if USE_VAMP
112  return VAMPEFFECTS_FAMILY;
113 #else
114  return {};
115 #endif
116 }

References VAMPEFFECTS_FAMILY.

◆ GetPath()

PluginPath VampEffectsModule::GetPath ( )
overridevirtual

Implements ComponentInterface.

Definition at line 67 of file LoadVamp.cpp.

68 {
69  return {};
70 }

◆ GetSymbol()

ComponentInterfaceSymbol VampEffectsModule::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 72 of file LoadVamp.cpp.

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

References XO.

◆ GetVendor()

VendorSymbol VampEffectsModule::GetVendor ( )
overridevirtual

Implements ComponentInterface.

Definition at line 77 of file LoadVamp.cpp.

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

References XO.

◆ GetVersion()

wxString VampEffectsModule::GetVersion ( )
overridevirtual

Implements ComponentInterface.

Definition at line 82 of file LoadVamp.cpp.

83 {
84  // This "may" be different if this were to be maintained as a separate DLL
85  return VAMPEFFECTS_VERSION;
86 }

References VAMPEFFECTS_VERSION.

◆ Initialize()

bool VampEffectsModule::Initialize ( )
overridevirtual

Implements ModuleInterface.

Definition at line 97 of file LoadVamp.cpp.

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

◆ InstallPath()

FilePath VampEffectsModule::InstallPath ( )
inlineoverridevirtual

Implements ModuleInterface.

Definition at line 50 of file LoadVamp.h.

50 { return {}; }

◆ IsPluginValid()

bool VampEffectsModule::IsPluginValid ( const PluginPath path,
bool  bFast 
)
overridevirtual

Implements ModuleInterface.

Definition at line 228 of file LoadVamp.cpp.

229 {
230  int output;
231  bool hasParameters;
232  if( bFast )
233  return true;
234 
235  auto vp = FindPlugin(path, output, hasParameters);
236  return bool(vp);
237 }

◆ Terminate()

void VampEffectsModule::Terminate ( )
overridevirtual

Implements ModuleInterface.

Definition at line 103 of file LoadVamp.cpp.

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

The documentation for this class was generated from the following files:
XO
#define XO(s)
Definition: Internat.h:31
wxArrayStringEx
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: wxArrayStringEx.h:18
VAMPEFFECTS_VERSION
#define VAMPEFFECTS_VERSION
Definition: VampEffect.h:29
name
const TranslatableString name
Definition: Distortion.cpp:98
VAMPEFFECTS_FAMILY
#define VAMPEFFECTS_FAMILY
Definition: VampEffect.h:32
PluginPaths
std::vector< PluginPath > PluginPaths
Definition: Identifier.h:215
VampEffectsModule::FindPlugin
std::unique_ptr< Vamp::Plugin > FindPlugin(const PluginPath &wpath, int &output, bool &hasParameters)
Definition: LoadVamp.cpp:253
key
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: CommandManager.cpp:201
names
static TranslatableStrings names
Definition: Tags.cpp:744
VampEffect
Definition: VampEffect.h:35