Audacity  2.3.1
Public Member Functions | Private Attributes | List of all members
NyquistEffectsModule Class Referencefinal

#include <LoadNyquist.h>

Inheritance diagram for NyquistEffectsModule:
ModuleInterface ComponentInterface

Public Member Functions

 NyquistEffectsModule (ModuleManagerInterface *moduleManager, const wxString *path)
 
virtual ~NyquistEffectsModule ()
 
wxString GetPath () override
 
ComponentInterfaceSymbol GetSymbol () override
 
ComponentInterfaceSymbol GetVendor () override
 
wxString GetVersion () override
 
wxString GetDescription () override
 
bool Initialize () override
 
void Terminate () override
 
wxArrayString FileExtensions () override
 
wxString InstallPath () override
 
bool AutoRegisterPlugins (PluginManagerInterface &pm) override
 
wxArrayString FindPluginPaths (PluginManagerInterface &pm) override
 
unsigned DiscoverPluginsAtPath (const wxString &path, wxString &errMsg, const RegistrationCallback &callback) override
 
bool IsPluginValid (const wxString &path, bool bFast) override
 
ComponentInterfaceCreateInstance (const wxString &path) override
 
void DeleteInstance (ComponentInterface *instance) override
 
- Public Member Functions inherited from ModuleInterface
virtual ~ModuleInterface ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
const wxString & GetTranslatedName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 

Private Attributes

ModuleManagerInterfacemModMan
 
wxString mPath
 

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 ( ModuleManagerInterface moduleManager,
const wxString *  path 
)

Definition at line 80 of file LoadNyquist.cpp.

References mModMan, and mPath.

82 {
83  mModMan = moduleManager;
84  if (path)
85  {
86  mPath = *path;
87  }
88 }
ModuleManagerInterface * mModMan
Definition: LoadNyquist.h:58
NyquistEffectsModule::~NyquistEffectsModule ( )
virtual

Definition at line 90 of file LoadNyquist.cpp.

References mPath.

91 {
92  mPath.Clear();
93 }

Member Function Documentation

bool NyquistEffectsModule::AutoRegisterPlugins ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 170 of file LoadNyquist.cpp.

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

171 {
172  // Autoregister effects that we "think" are ones that have been shipped with
173  // Audacity. A little simplistic, but it should suffice for now.
174  wxArrayString pathList = NyquistEffect::GetNyquistSearchPath();
175  wxArrayString files;
176  wxString ignoredErrMsg;
177 
179  {
180  // No checking of error ?
183  }
184 
185  for (size_t i = 0; i < WXSIZEOF(kShippedEffects); i++)
186  {
187  files.Clear();
188  pm.FindFilesInPathList(kShippedEffects[i], pathList, files);
189  for (size_t j = 0, cnt = files.GetCount(); j < cnt; j++)
190  {
191  if (!pm.IsPluginRegistered(files[j]))
192  {
193  // No checking of error ?
194  DiscoverPluginsAtPath(files[j], ignoredErrMsg,
196  }
197  }
198  }
199 
200  // We still want to be called during the normal registration process
201  return false;
202 }
virtual void FindFilesInPathList(const wxString &pattern, const wxArrayString &pathList, wxArrayString &files, bool directories=false)=0
static wxArrayString GetNyquistSearchPath()
Definition: Nyquist.cpp:2344
#define NYQUIST_PROMPT_ID
Definition: Nyquist.h:37
unsigned DiscoverPluginsAtPath(const wxString &path, wxString &errMsg, const RegistrationCallback &callback) override
virtual bool IsPluginRegistered(const wxString &path)=0
static const wxChar * kShippedEffects[]
Definition: LoadNyquist.cpp:23
static const PluginID & DefaultRegistrationCallback(ModuleInterface *provider, ComponentInterface *ident)
ComponentInterface * NyquistEffectsModule::CreateInstance ( const wxString &  path)
overridevirtual

Implements ModuleInterface.

Definition at line 248 of file LoadNyquist.cpp.

249 {
250  // Acquires a resource for the application.
251  auto effect = std::make_unique<NyquistEffect>(path);
252  if (effect->IsOk())
253  {
254  // Safety of this depends on complementary calls to DeleteInstance on the module manager side.
255  return effect.release();
256  }
257 
258  return NULL;
259 }
void NyquistEffectsModule::DeleteInstance ( ComponentInterface instance)
overridevirtual

Implements ModuleInterface.

Definition at line 261 of file LoadNyquist.cpp.

262 {
263  std::unique_ptr < NyquistEffect > {
264  dynamic_cast<NyquistEffect *>(instance)
265  };
266 }
An Effect that calls up a Nyquist (XLISP) plug-in, i.e. many possible effects from this one class...
Definition: Nyquist.h:77
unsigned NyquistEffectsModule::DiscoverPluginsAtPath ( const wxString &  path,
wxString &  errMsg,
const RegistrationCallback callback 
)
overridevirtual

Implements ModuleInterface.

Definition at line 220 of file LoadNyquist.cpp.

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

Referenced by AutoRegisterPlugins().

223 {
224  errMsg.clear();
225  NyquistEffect effect(path);
226  if (effect.IsOk())
227  {
228  if (callback)
229  callback(this, &effect);
230  return 1;
231  }
232 
233  errMsg = effect.InitializationError();
234  return 0;
235 }
An Effect that calls up a Nyquist (XLISP) plug-in, i.e. many possible effects from this one class...
Definition: Nyquist.h:77
wxArrayString NyquistEffectsModule::FileExtensions ( )
overridevirtual

Implements ModuleInterface.

Definition at line 158 of file LoadNyquist.cpp.

159 {
160  static const wxString ext[] = { _T("ny") };
161  static const wxArrayString result{ sizeof(ext)/sizeof(*ext), ext };
162  return result;
163 }
wxArrayString NyquistEffectsModule::FindPluginPaths ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 204 of file LoadNyquist.cpp.

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

205 {
206  wxArrayString pathList = NyquistEffect::GetNyquistSearchPath();
207  wxArrayString files;
208 
209  // Add the Nyquist prompt
210  files.Add(NYQUIST_PROMPT_ID);
211 
212  // Load .ny plug-ins
213  pm.FindFilesInPathList(wxT("*.ny"), pathList, files);
214  // LLL: Works for all platform with NEW plugin support (dups are removed)
215  pm.FindFilesInPathList(wxT("*.NY"), pathList, files); // Ed's fix for bug 179
216 
217  return files;
218 }
virtual void FindFilesInPathList(const wxString &pattern, const wxArrayString &pathList, wxArrayString &files, bool directories=false)=0
static wxArrayString GetNyquistSearchPath()
Definition: Nyquist.cpp:2344
#define NYQUIST_PROMPT_ID
Definition: Nyquist.h:37
wxString NyquistEffectsModule::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 120 of file LoadNyquist.cpp.

References _().

121 {
122  return _("Provides Nyquist Effects support to Audacity");
123 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxString NyquistEffectsModule::GetPath ( )
overridevirtual

Implements ComponentInterface.

Definition at line 99 of file LoadNyquist.cpp.

References mPath.

100 {
101  return mPath;
102 }
ComponentInterfaceSymbol NyquistEffectsModule::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 104 of file LoadNyquist.cpp.

References XO.

105 {
106  return XO("Nyquist Effects");
107 }
#define XO(s)
Definition: Internat.h:33
ComponentInterfaceSymbol NyquistEffectsModule::GetVendor ( )
overridevirtual

Implements ComponentInterface.

Definition at line 109 of file LoadNyquist.cpp.

References XO.

110 {
111  return XO("The Audacity Team");
112 }
#define XO(s)
Definition: Internat.h:33
wxString NyquistEffectsModule::GetVersion ( )
overridevirtual

Implements ComponentInterface.

Definition at line 114 of file LoadNyquist.cpp.

References NYQUISTEFFECTS_VERSION.

115 {
116  // This "may" be different if this were to be maintained as a separate DLL
117  return NYQUISTEFFECTS_VERSION;
118 }
#define NYQUISTEFFECTS_VERSION
Definition: Nyquist.h:30
bool NyquistEffectsModule::Initialize ( )
overridevirtual

Implements ModuleInterface.

Definition at line 129 of file LoadNyquist.cpp.

References AudacityApp::audacityPathList, name, and wxGetApp().

130 {
131  wxArrayString audacityPathList = wxGetApp().audacityPathList;
132 
133  for (size_t i = 0, cnt = audacityPathList.GetCount(); i < cnt; i++)
134  {
135  wxFileName name(audacityPathList[i], wxT(""));
136  name.AppendDir(wxT("nyquist"));
137  name.SetFullName(wxT("nyquist.lsp"));
138  if (name.FileExists())
139  {
140  // set_xlisp_path doesn't handle fn_Str() in Unicode build. May or may not actually work.
141  nyx_set_xlisp_path(name.GetPath().ToUTF8());
142  return true;
143  }
144  }
145 
146  wxLogWarning(wxT("Critical Nyquist files could not be found. Nyquist effects will not work."));
147 
148  return false;
149 }
const wxChar * name
Definition: Distortion.cpp:94
wxArrayString audacityPathList
A list of directories that should be searched for Audacity files (plug-ins, help files, etc.).
Definition: AudacityApp.h:143
AudacityApp & wxGetApp()
wxString NyquistEffectsModule::InstallPath ( )
overridevirtual

Implements ModuleInterface.

Definition at line 165 of file LoadNyquist.cpp.

References FileNames::PlugInDir().

166 {
167  return FileNames::PlugInDir();
168 }
static wxString PlugInDir()
The user plug-in directory (not a system one)
Definition: FileNames.cpp:230
bool NyquistEffectsModule::IsPluginValid ( const wxString &  path,
bool  bFast 
)
overridevirtual

Implements ModuleInterface.

Definition at line 237 of file LoadNyquist.cpp.

References NYQUIST_PROMPT_ID.

238 {
239  // Ignores bFast parameter, since checking file exists is fast enough for
240  // the small number of Nyquist plug-ins that we have.
241  static_cast<void>(bFast);
242  if(path == NYQUIST_PROMPT_ID)
243  return true;
244 
245  return wxFileName::FileExists(path);
246 }
#define NYQUIST_PROMPT_ID
Definition: Nyquist.h:37
void NyquistEffectsModule::Terminate ( )
overridevirtual

Implements ModuleInterface.

Definition at line 151 of file LoadNyquist.cpp.

152 {
153  nyx_set_xlisp_path(NULL);
154 
155  return;
156 }

Member Data Documentation

ModuleManagerInterface* NyquistEffectsModule::mModMan
private

Definition at line 58 of file LoadNyquist.h.

Referenced by NyquistEffectsModule().

wxString NyquistEffectsModule::mPath
private

Definition at line 59 of file LoadNyquist.h.

Referenced by GetPath(), NyquistEffectsModule(), and ~NyquistEffectsModule().


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