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 85 of file LoadNyquist.cpp.

86{
87}

◆ ~NyquistEffectsModule()

NyquistEffectsModule::~NyquistEffectsModule ( )
virtual

Definition at line 89 of file LoadNyquist.cpp.

90{
91}

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 176 of file LoadNyquist.cpp.

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

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

References NYQUIST_PROMPT_ID.

◆ DiscoverPluginsAtPath()

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

Implements PluginProvider.

Definition at line 237 of file LoadNyquist.cpp.

240{
241 errMsg = {};
242 NyquistEffect effect(path);
243 if (effect.IsOk())
244 {
245 if (callback)
246 callback(this, &effect);
247 return 1;
248 }
249
250 errMsg = effect.InitializationError();
251 return 0;
252}
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 221 of file LoadNyquist.cpp.

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

119{
120 return XO("Provides Nyquist Effects support to Audacity");
121}
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 165 of file LoadNyquist.cpp.

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

◆ 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 156 of file LoadNyquist.cpp.

157{
158#if USE_NYQUIST
160#else
161 return {};
162#endif
163}
#define NYQUISTEFFECTS_FAMILY
Definition: EffectBase.h:134

References NYQUISTEFFECTS_FAMILY.

◆ GetPath()

PluginPath NyquistEffectsModule::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 97 of file LoadNyquist.cpp.

98{
99 return {};
100}

◆ GetSymbol()

ComponentInterfaceSymbol NyquistEffectsModule::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 102 of file LoadNyquist.cpp.

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

References XO().

Here is the call graph for this function:

◆ GetVendor()

VendorSymbol NyquistEffectsModule::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 107 of file LoadNyquist.cpp.

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

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString NyquistEffectsModule::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 112 of file LoadNyquist.cpp.

113{
114 // This "may" be different if this were to be maintained as a separate DLL
116}
#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 127 of file LoadNyquist.cpp.

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

172{
173 return FileNames::PlugInDir();
174}
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 255 of file LoadNyquist.cpp.

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

◆ Terminate()

void NyquistEffectsModule::Terminate ( )
overridevirtual

Called just prior to deletion to allow releasing any resources.

Implements PluginProvider.

Definition at line 149 of file LoadNyquist.cpp.

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

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