Audacity  3.0.3
Public Member Functions | List of all members
NyquistEffectsModule Class Referencefinal

#include <LoadNyquist.h>

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

Public Member Functions

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

Additional Inherited Members

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

Detailed Description

Definition at line 21 of file LoadNyquist.h.

Constructor & Destructor Documentation

◆ NyquistEffectsModule()

NyquistEffectsModule::NyquistEffectsModule ( )

Definition at line 84 of file LoadNyquist.cpp.

85 {
86 }

◆ ~NyquistEffectsModule()

NyquistEffectsModule::~NyquistEffectsModule ( )
virtual

Definition at line 88 of file LoadNyquist.cpp.

89 {
90 }

Member Function Documentation

◆ AutoRegisterPlugins()

bool NyquistEffectsModule::AutoRegisterPlugins ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 175 of file LoadNyquist.cpp.

176 {
177  // Autoregister effects that we "think" are ones that have been shipped with
178  // Audacity. A little simplistic, but it should suffice for now.
179  auto pathList = NyquistEffect::GetNyquistSearchPath();
180  FilePaths files;
181  TranslatableString ignoredErrMsg;
182 
183  auto name = NYQUIST_PROMPT_NAME;
185  {
186  // No checking of error ?
189  }
190 
191  for (size_t i = 0; i < WXSIZEOF(kShippedEffects); i++)
192  {
193  files.clear();
194  pm.FindFilesInPathList(kShippedEffects[i], pathList, files);
195  for (size_t j = 0, cnt = files.size(); j < cnt; j++)
196  {
197  /*
198  TODO: Currently the names of Nyquist plug-ins cannot have
199  context specific translations or internal names different from
200  the visible English names.
201 
202  This makes it unnecessary to pass a second argument to
203  IsPluginRegistered for correction of the registry (as is needed
204  in the case of built-in effects).
205 
206  If it does become necessary in the future, we will need to open the
207  .ny files to access their $name lines so that this argument could
208  be supplied.
209  */
210  if (!pm.IsPluginRegistered(files[j]))
211  {
212  // No checking of error ?
213  DiscoverPluginsAtPath(files[j], ignoredErrMsg,
215  }
216  }
217  }
218 
219  // We still want to be called during the normal registration process
220  return false;
221 }

References PluginManagerInterface::DefaultRegistrationCallback(), DiscoverPluginsAtPath(), PluginManagerInterface::FindFilesInPathList(), NyquistEffect::GetNyquistSearchPath(), PluginManagerInterface::IsPluginRegistered(), kShippedEffects, name, NYQUIST_PROMPT_ID, and NYQUIST_PROMPT_NAME.

Here is the call graph for this function:

◆ CreateInstance()

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

Implements ModuleInterface.

Definition at line 268 of file LoadNyquist.cpp.

269 {
270  // Acquires a resource for the application.
271  auto effect = std::make_unique<NyquistEffect>(path);
272  if (effect->IsOk())
273  return effect;
274  return nullptr;
275 }

◆ DiscoverPluginsAtPath()

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

Implements ModuleInterface.

Definition at line 239 of file LoadNyquist.cpp.

242 {
243  errMsg = {};
244  NyquistEffect effect(path);
245  if (effect.IsOk())
246  {
247  if (callback)
248  callback(this, &effect);
249  return 1;
250  }
251 
252  errMsg = effect.InitializationError();
253  return 0;
254 }

References NyquistEffect::InitializationError(), and NyquistEffect::IsOk().

Referenced by AutoRegisterPlugins().

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

◆ FindPluginPaths()

PluginPaths NyquistEffectsModule::FindPluginPaths ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 223 of file LoadNyquist.cpp.

224 {
225  auto pathList = NyquistEffect::GetNyquistSearchPath();
226  FilePaths files;
227 
228  // Add the Nyquist prompt
229  files.push_back(NYQUIST_PROMPT_ID);
230 
231  // Load .ny plug-ins
232  pm.FindFilesInPathList(wxT("*.ny"), pathList, files);
233  // LLL: Works for all platform with NEW plugin support (dups are removed)
234  pm.FindFilesInPathList(wxT("*.NY"), pathList, files); // Ed's fix for bug 179
235 
236  return { files.begin(), files.end() };
237 }

References PluginManagerInterface::FindFilesInPathList(), NyquistEffect::GetNyquistSearchPath(), and NYQUIST_PROMPT_ID.

Here is the call graph for this function:

◆ GetDescription()

TranslatableString NyquistEffectsModule::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 117 of file LoadNyquist.cpp.

118 {
119  return XO("Provides Nyquist Effects support to Audacity");
120 }

References XO.

◆ GetFileExtensions()

const FileExtensions & NyquistEffectsModule::GetFileExtensions ( )
overridevirtual

Implements ModuleInterface.

Definition at line 164 of file LoadNyquist.cpp.

165 {
166  static FileExtensions result{{ _T("ny") }};
167  return result;
168 }

◆ GetOptionalFamilySymbol()

EffectFamilySymbol NyquistEffectsModule::GetOptionalFamilySymbol ( )
overridevirtual

Implements ModuleInterface.

Definition at line 155 of file LoadNyquist.cpp.

156 {
157 #if USE_NYQUIST
158  return NYQUISTEFFECTS_FAMILY;
159 #else
160  return {};
161 #endif
162 }

References NYQUISTEFFECTS_FAMILY.

◆ GetPath()

PluginPath NyquistEffectsModule::GetPath ( )
overridevirtual

Implements ComponentInterface.

Definition at line 96 of file LoadNyquist.cpp.

97 {
98  return {};
99 }

◆ GetSymbol()

ComponentInterfaceSymbol NyquistEffectsModule::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 101 of file LoadNyquist.cpp.

102 {
103  return XO("Nyquist Effects");
104 }

References XO.

◆ GetVendor()

VendorSymbol NyquistEffectsModule::GetVendor ( )
overridevirtual

Implements ComponentInterface.

Definition at line 106 of file LoadNyquist.cpp.

107 {
108  return XO("The Audacity Team");
109 }

References XO.

◆ GetVersion()

wxString NyquistEffectsModule::GetVersion ( )
overridevirtual

Implements ComponentInterface.

Definition at line 111 of file LoadNyquist.cpp.

112 {
113  // This "may" be different if this were to be maintained as a separate DLL
114  return NYQUISTEFFECTS_VERSION;
115 }

References NYQUISTEFFECTS_VERSION.

◆ Initialize()

bool NyquistEffectsModule::Initialize ( )
overridevirtual

Implements ModuleInterface.

Definition at line 126 of file LoadNyquist.cpp.

127 {
128  const auto &audacityPathList = FileNames::AudacityPathList();
129 
130  for (size_t i = 0, cnt = audacityPathList.size(); i < cnt; i++)
131  {
132  wxFileName name(audacityPathList[i], wxT(""));
133  name.AppendDir(wxT("nyquist"));
134  name.SetFullName(wxT("nyquist.lsp"));
135  if (name.FileExists())
136  {
137  // set_xlisp_path doesn't handle fn_Str() in Unicode build. May or may not actually work.
138  nyx_set_xlisp_path(name.GetPath().ToUTF8());
139  return true;
140  }
141  }
142 
143  wxLogWarning(wxT("Critical Nyquist files could not be found. Nyquist effects will not work."));
144 
145  return false;
146 }

References FileNames::AudacityPathList(), and name.

Here is the call graph for this function:

◆ InstallPath()

FilePath NyquistEffectsModule::InstallPath ( )
overridevirtual

Implements ModuleInterface.

Definition at line 170 of file LoadNyquist.cpp.

171 {
172  return FileNames::PlugInDir();
173 }

References FileNames::PlugInDir().

Here is the call graph for this function:

◆ IsPluginValid()

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

Implements ModuleInterface.

Definition at line 256 of file LoadNyquist.cpp.

257 {
258  // Ignores bFast parameter, since checking file exists is fast enough for
259  // the small number of Nyquist plug-ins that we have.
260  static_cast<void>(bFast);
261  if(path == NYQUIST_PROMPT_ID)
262  return true;
263 
264  return wxFileName::FileExists(path);
265 }

References NYQUIST_PROMPT_ID.

◆ Terminate()

void NyquistEffectsModule::Terminate ( )
overridevirtual

Implements ModuleInterface.

Definition at line 148 of file LoadNyquist.cpp.

149 {
150  nyx_set_xlisp_path(NULL);
151 
152  return;
153 }

The documentation for this class was generated from the following files:
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
NYQUIST_PROMPT_ID
#define NYQUIST_PROMPT_ID
Definition: PluginManager.h:360
NyquistEffect
An Effect that calls up a Nyquist (XLISP) plug-in, i.e. many possible effects from this one class.
Definition: Nyquist.h:65
XO
#define XO(s)
Definition: Internat.h:31
FileNames::PlugInDir
FILES_API FilePath PlugInDir()
The user plug-in directory (not a system one)
NYQUISTEFFECTS_FAMILY
#define NYQUISTEFFECTS_FAMILY
Definition: Effect.h:60
wxArrayStringEx
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: wxArrayStringEx.h:18
PluginManagerInterface::IsPluginRegistered
virtual bool IsPluginRegistered(const PluginPath &path, const TranslatableString *pName=nullptr)=0
Was the plugin registry already populated for a path (maybe from loading the config file)?
NyquistEffect::GetNyquistSearchPath
static FilePaths GetNyquistSearchPath()
Definition: Nyquist.cpp:2568
NYQUIST_PROMPT_NAME
#define NYQUIST_PROMPT_NAME
Definition: PluginManager.h:362
name
const TranslatableString name
Definition: Distortion.cpp:98
PluginManagerInterface::FindFilesInPathList
virtual void FindFilesInPathList(const wxString &pattern, const FilePaths &pathList, FilePaths &files, bool directories=false)=0
NyquistEffectsModule::DiscoverPluginsAtPath
unsigned DiscoverPluginsAtPath(const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
Definition: LoadNyquist.cpp:239
PluginManagerInterface::DefaultRegistrationCallback
static const PluginID & DefaultRegistrationCallback(ModuleInterface *provider, ComponentInterface *ident)
Definition: PluginManager.cpp:329
FileNames::AudacityPathList
FILES_API const FilePaths & AudacityPathList()
A list of directories that should be searched for Audacity files (plug-ins, help files,...
kShippedEffects
static const wxChar * kShippedEffects[]
Definition: LoadNyquist.cpp:26
NYQUISTEFFECTS_VERSION
#define NYQUISTEFFECTS_VERSION
Definition: Nyquist.h:24