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 bool SupportsCustomModulePaths () const
 
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 86 of file LoadNyquist.cpp.

87{
88}

◆ ~NyquistEffectsModule()

NyquistEffectsModule::~NyquistEffectsModule ( )
virtual

Definition at line 90 of file LoadNyquist.cpp.

91{
92}

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

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

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

References NYQUIST_PROMPT_ID.

◆ DiscoverPluginsAtPath()

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

Implements PluginProvider.

Definition at line 238 of file LoadNyquist.cpp.

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

References NyquistBase::InitializationError(), and NyquistBase::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 222 of file LoadNyquist.cpp.

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

References PluginManagerInterface::FindFilesInPathList(), NyquistBase::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 119 of file LoadNyquist.cpp.

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

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

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

158{
159#if USE_NYQUIST
161#else
162 return {};
163#endif
164}
#define NYQUISTEFFECTS_FAMILY
Definition: EffectBase.h:141

References NYQUISTEFFECTS_FAMILY.

◆ GetPath()

PluginPath NyquistEffectsModule::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 98 of file LoadNyquist.cpp.

99{
100 return {};
101}

◆ GetSymbol()

ComponentInterfaceSymbol NyquistEffectsModule::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 103 of file LoadNyquist.cpp.

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

References XO().

Here is the call graph for this function:

◆ GetVendor()

VendorSymbol NyquistEffectsModule::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 108 of file LoadNyquist.cpp.

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

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString NyquistEffectsModule::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 113 of file LoadNyquist.cpp.

114{
115 // This "may" be different if this were to be maintained as a separate DLL
117}
#define NYQUISTEFFECTS_VERSION
Definition: NyquistBase.h:24

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

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

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

257{
258 // Acquires a resource for the application.
259 auto effect = NyquistBase::GetEffectHook::Call(path);
260 if (effect && effect->IsOk())
261 return effect;
262 return nullptr;
263}
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.

References GlobalHook< GetEffectHook, std::unique_ptr< NyquistBase >(const wxString &pluginId)>::Call().

Here is the call graph for this function:

◆ Terminate()

void NyquistEffectsModule::Terminate ( )
overridevirtual

Called just prior to deletion to allow releasing any resources.

Implements PluginProvider.

Definition at line 150 of file LoadNyquist.cpp.

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

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