Audacity 3.2.0
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 () 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
 

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 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()

void NyquistEffectsModule::AutoRegisterPlugins ( PluginManagerInterface pluginManager)
overridevirtual

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

Implements PluginProvider.

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
184 if (!pm.IsPluginRegistered(NYQUIST_PROMPT_ID, &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}
const TranslatableString name
Definition: Distortion.cpp:76
static const wxChar * kShippedEffects[]
Definition: LoadNyquist.cpp:26
#define NYQUIST_PROMPT_ID
#define NYQUIST_PROMPT_NAME
static FilePaths GetNyquistSearchPath()
Definition: Nyquist.cpp:2694
unsigned DiscoverPluginsAtPath(const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
static const PluginID & DefaultRegistrationCallback(PluginProvider *provider, ComponentInterface *ident)
Holds a msgid for the translation catalog; may also bind format arguments.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.

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:

◆ CheckPluginExist()

bool NyquistEffectsModule::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 263 of file LoadNyquist.cpp.

264{
265 if(path == NYQUIST_PROMPT_ID)
266 return true;
267
268 return wxFileName::FileExists(path);
269}

References NYQUIST_PROMPT_ID.

◆ DiscoverPluginsAtPath()

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

Implements PluginProvider.

Definition at line 236 of file LoadNyquist.cpp.

239{
240 errMsg = {};
241 NyquistEffect effect(path);
242 if (effect.IsOk())
243 {
244 if (callback)
245 callback(this, &effect);
246 return 1;
247 }
248
249 errMsg = effect.InitializationError();
250 return 0;
251}
An Effect that calls up a Nyquist (XLISP) plug-in, i.e. many possible effects from this one class.
Definition: Nyquist.h:78

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:

◆ FindModulePaths()

PluginPaths NyquistEffectsModule::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 220 of file LoadNyquist.cpp.

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

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

Here is the call graph for this function:

◆ GetDescription()

TranslatableString NyquistEffectsModule::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 117 of file LoadNyquist.cpp.

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

References XO().

Here is the call graph for this function:

◆ GetFileExtensions()

const FileExtensions & NyquistEffectsModule::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 164 of file LoadNyquist.cpp.

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

◆ GetOptionalFamilySymbol()

EffectFamilySymbol NyquistEffectsModule::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 155 of file LoadNyquist.cpp.

156{
157#if USE_NYQUIST
159#else
160 return {};
161#endif
162}
#define NYQUISTEFFECTS_FAMILY
Definition: EffectBase.h:132

References NYQUISTEFFECTS_FAMILY.

◆ GetPath()

PluginPath NyquistEffectsModule::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 96 of file LoadNyquist.cpp.

97{
98 return {};
99}

◆ GetSymbol()

ComponentInterfaceSymbol NyquistEffectsModule::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 101 of file LoadNyquist.cpp.

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

References XO().

Here is the call graph for this function:

◆ GetVendor()

VendorSymbol NyquistEffectsModule::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 106 of file LoadNyquist.cpp.

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

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString NyquistEffectsModule::GetVersion ( ) const
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
115}
#define NYQUISTEFFECTS_VERSION
Definition: Nyquist.h:28

References NYQUISTEFFECTS_VERSION.

◆ Initialize()

bool NyquistEffectsModule::Initialize ( )
overridevirtual

Called immediately after creation. Let provider initialize.

Returns
"true" if initialization was successful

Implements PluginProvider.

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}
FILES_API const FilePaths & AudacityPathList()
A list of directories that should be searched for Audacity files (plug-ins, help files,...

References FileNames::AudacityPathList(), name, and wxT().

Here is the call graph for this function:

◆ InstallPath()

FilePath NyquistEffectsModule::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 170 of file LoadNyquist.cpp.

171{
172 return FileNames::PlugInDir();
173}
FILES_API FilePath PlugInDir()
The user plug-in directory (not a system one)

References FileNames::PlugInDir().

Here is the call graph for this function:

◆ LoadPlugin()

std::unique_ptr< ComponentInterface > NyquistEffectsModule::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 254 of file LoadNyquist.cpp.

255{
256 // Acquires a resource for the application.
257 auto effect = std::make_unique<NyquistEffect>(path);
258 if (effect->IsOk())
259 return effect;
260 return nullptr;
261}

◆ Terminate()

void NyquistEffectsModule::Terminate ( )
overridevirtual

Called just prior to deletion to allow releasing any resources.

Implements PluginProvider.

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: