Audacity 3.2.0
Classes | Public Member Functions | List of all members
AudioUnitEffectsModule Class Referencefinal

#include <AudioUnitEffectsModule.h>

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

Classes

struct  Factory
 

Public Member Functions

 AudioUnitEffectsModule ()
 
virtual ~AudioUnitEffectsModule ()
 
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...
 
void LoadAudioUnitsOfType (OSType inAUType, PluginPaths &effects)
 
- 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 30 of file AudioUnitEffectsModule.h.

Constructor & Destructor Documentation

◆ AudioUnitEffectsModule()

AudioUnitEffectsModule::AudioUnitEffectsModule ( )

Definition at line 117 of file AudioUnitEffectsModule.cpp.

118{
119}

◆ ~AudioUnitEffectsModule()

AudioUnitEffectsModule::~AudioUnitEffectsModule ( )
virtual

Definition at line 121 of file AudioUnitEffectsModule.cpp.

122{
123}

Member Function Documentation

◆ AutoRegisterPlugins()

void AudioUnitEffectsModule::AutoRegisterPlugins ( PluginManagerInterface pluginManager)
overridevirtual

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

Implements PluginProvider.

Definition at line 187 of file AudioUnitEffectsModule.cpp.

188{
189}

◆ CheckPluginExist()

bool AudioUnitEffectsModule::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 246 of file AudioUnitEffectsModule.cpp.

247{
248 wxString unused;
249 return FindAudioUnit(path, unused) != nullptr;
250}
AudioComponent FindAudioUnit(const PluginPath &path, wxString &name)

References anonymous_namespace{AudioUnitEffectsModule.cpp}::FindAudioUnit().

Here is the call graph for this function:

◆ DiscoverPluginsAtPath()

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

Implements PluginProvider.

Definition at line 204 of file AudioUnitEffectsModule.cpp.

207{
208 errMsg = {};
209 wxString name;
210 AudioComponent component = FindAudioUnit(path, name);
211 if (component == NULL)
212 {
213 errMsg = XO("Could not find component");
214 return 0;
215 }
216
217 AudioUnitEffectBase effect(path, name, component);
218 if (!effect.InitializePlugin())
219 {
220 // TODO: Is it worth it to discriminate all the ways SetHost might
221 // return false?
222 errMsg = XO("Could not initialize component");
223 return 0;
224 }
225
226 if (callback)
227 {
228 callback(this, &effect);
229 }
230
231 return 1;
232}
const TranslatableString name
Definition: Distortion.cpp:76
XO("Cut/Copy/Paste")
An Effect class that handles a wide range of effects. ??Mac only??

References anonymous_namespace{AudioUnitEffectsModule.cpp}::FindAudioUnit(), AudioUnitEffectBase::InitializePlugin(), name, and XO().

Here is the call graph for this function:

◆ FindModulePaths()

PluginPaths AudioUnitEffectsModule::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 191 of file AudioUnitEffectsModule.cpp.

192{
193 PluginPaths effects;
194
195 LoadAudioUnitsOfType(kAudioUnitType_Effect, effects);
196 LoadAudioUnitsOfType(kAudioUnitType_Generator, effects);
197 LoadAudioUnitsOfType(kAudioUnitType_Mixer, effects);
198 LoadAudioUnitsOfType(kAudioUnitType_MusicEffect, effects);
199 LoadAudioUnitsOfType(kAudioUnitType_Panner, effects);
200
201 return effects;
202}
std::vector< PluginPath > PluginPaths
Definition: Identifier.h:215
void LoadAudioUnitsOfType(OSType inAUType, PluginPaths &effects)

References LoadAudioUnitsOfType().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString AudioUnitEffectsModule::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 151 of file AudioUnitEffectsModule.cpp.

152{
153 return XO("Provides Audio Unit Effects support to Audacity");
154}

References XO().

Here is the call graph for this function:

◆ GetFileExtensions()

const FileExtensions & AudioUnitEffectsModule::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 160 of file AudioUnitEffectsModule.cpp.

161{
162 static FileExtensions result{{ _T("au") }};
163 return result;
164}
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.

◆ GetOptionalFamilySymbol()

EffectFamilySymbol AudioUnitEffectsModule::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 178 of file AudioUnitEffectsModule.cpp.

179{
180#if USE_AUDIO_UNITS
182#else
183 return {};
184#endif
185}
#define AUDIOUNITEFFECTS_FAMILY

References AUDIOUNITEFFECTS_FAMILY.

◆ GetPath()

PluginPath AudioUnitEffectsModule::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 129 of file AudioUnitEffectsModule.cpp.

130{
131 return {};
132}

◆ GetSymbol()

ComponentInterfaceSymbol AudioUnitEffectsModule::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 134 of file AudioUnitEffectsModule.cpp.

135{
136 /* i18n-hint: Audio Unit is the name of an Apple audio software protocol */
137 return XO("Audio Unit Effects");
138}

References XO().

Here is the call graph for this function:

◆ GetVendor()

VendorSymbol AudioUnitEffectsModule::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 140 of file AudioUnitEffectsModule.cpp.

141{
142 return XO("The Audacity Team");
143}

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString AudioUnitEffectsModule::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 145 of file AudioUnitEffectsModule.cpp.

146{
147 // This "may" be different if this were to be maintained as a separate DLL
149}
#define AUDIOUNITEFFECTS_VERSION

References AUDIOUNITEFFECTS_VERSION.

◆ Initialize()

bool AudioUnitEffectsModule::Initialize ( )
overridevirtual

Called immediately after creation. Let provider initialize.

Returns
"true" if initialization was successful

Implements PluginProvider.

Definition at line 166 of file AudioUnitEffectsModule.cpp.

167{
168 // Nothing to do here
169 return true;
170}

◆ InstallPath()

FilePath AudioUnitEffectsModule::InstallPath ( )
inlineoverridevirtual

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 56 of file AudioUnitEffectsModule.h.

56{ return {}; }

◆ LoadAudioUnitsOfType()

void AudioUnitEffectsModule::LoadAudioUnitsOfType ( OSType  inAUType,
PluginPaths effects 
)

Definition at line 256 of file AudioUnitEffectsModule.cpp.

258{
259 AudioComponentDescription desc;
260 AudioComponent component;
261
262 desc.componentType = inAUType;
263 desc.componentSubType = 0;
264 desc.componentManufacturer = 0;
265 desc.componentFlags = 0;
266 desc.componentFlagsMask = 0;
267
268 component = AudioComponentFindNext(NULL, &desc);
269 while (component != NULL)
270 {
271 OSStatus result;
272 AudioComponentDescription found;
273
274 result = AudioComponentGetDescription(component, &found);
275 if (result == noErr)
276 {
277 CFStringRef cfName{};
278 result = AudioComponentCopyName(component, &cfName);
279 CF_ptr<CFStringRef> uName{ cfName };
280 if (result == noErr) {
281 wxString path;
282
283 path.Printf(wxT("%-4.4s/%-4.4s/%-4.4s/%s"),
284 FromOSType(found.componentManufacturer),
285 FromOSType(found.componentType),
286 FromOSType(found.componentSubType),
287 wxCFStringRef::AsString(cfName));
288
289 for (int i = 0; i < WXSIZEOF(BlackList); ++i) {
290 if (BlackList[i].componentType == found.componentType &&
291 BlackList[i].componentSubType == found.componentSubType &&
292 BlackList[i].componentManufacturer ==
293 found.componentManufacturer) {
294 wxLogDebug(wxT("Blacklisted AU skipped: %s"), path);
295 result = !noErr;
296 break;
297 }
298 }
299 if (result == noErr)
300 effects.push_back(path);
301 }
302 }
303 component = AudioComponentFindNext(component, &desc);
304 }
305}
wxT("CloseDown"))
OSType componentType
static const struct @112 BlackList[]
const TranslatableString desc
Definition: ExportPCM.cpp:51

References BlackList, componentType, anonymous_namespace{ExportPCM.cpp}::desc, anonymous_namespace{AudioUnitEffectsModule.cpp}::FromOSType(), and wxT().

Referenced by FindModulePaths().

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

◆ LoadPlugin()

std::unique_ptr< ComponentInterface > AudioUnitEffectsModule::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 235 of file AudioUnitEffectsModule.cpp.

236{
237 // Acquires a resource for the application.
238 if (wxString name; auto component = FindAudioUnit(path, name)) {
239 auto result = Factory::Call(path, name, component);
240 result->InitializePlugin();
241 return result;
242 }
243 return nullptr;
244}
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.

References GlobalHook< Factory, std::remove_pointer_t< decltype(DefaultFunction)>, DefaultFunction, Options... >::Call(), anonymous_namespace{AudioUnitEffectsModule.cpp}::FindAudioUnit(), and name.

Here is the call graph for this function:

◆ Terminate()

void AudioUnitEffectsModule::Terminate ( )
overridevirtual

Called just prior to deletion to allow releasing any resources.

Implements PluginProvider.

Definition at line 172 of file AudioUnitEffectsModule.cpp.

173{
174 // Nothing to do here
175 return;
176}

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