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

#include <AudioUnitEffectsModule.h>

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

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

Constructor & Destructor Documentation

◆ AudioUnitEffectsModule()

AudioUnitEffectsModule::AudioUnitEffectsModule ( )

Definition at line 116 of file AudioUnitEffectsModule.cpp.

117{
118}

◆ ~AudioUnitEffectsModule()

AudioUnitEffectsModule::~AudioUnitEffectsModule ( )
virtual

Definition at line 120 of file AudioUnitEffectsModule.cpp.

121{
122}

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 186 of file AudioUnitEffectsModule.cpp.

187{
188}

◆ 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 245 of file AudioUnitEffectsModule.cpp.

246{
247 wxString unused;
248 return FindAudioUnit(path, unused) != nullptr;
249}
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 203 of file AudioUnitEffectsModule.cpp.

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

References anonymous_namespace{AudioUnitEffectsModule.cpp}::FindAudioUnit(), AudioUnitEffect::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 190 of file AudioUnitEffectsModule.cpp.

191{
192 PluginPaths effects;
193
194 LoadAudioUnitsOfType(kAudioUnitType_Effect, effects);
195 LoadAudioUnitsOfType(kAudioUnitType_Generator, effects);
196 LoadAudioUnitsOfType(kAudioUnitType_Mixer, effects);
197 LoadAudioUnitsOfType(kAudioUnitType_MusicEffect, effects);
198 LoadAudioUnitsOfType(kAudioUnitType_Panner, effects);
199
200 return effects;
201}
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 150 of file AudioUnitEffectsModule.cpp.

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

References XO.

◆ 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 159 of file AudioUnitEffectsModule.cpp.

160{
161 static FileExtensions result{{ _T("au") }};
162 return result;
163}
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 177 of file AudioUnitEffectsModule.cpp.

178{
179#if USE_AUDIO_UNITS
181#else
182 return {};
183#endif
184}
#define AUDIOUNITEFFECTS_FAMILY

References AUDIOUNITEFFECTS_FAMILY.

◆ GetPath()

PluginPath AudioUnitEffectsModule::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 128 of file AudioUnitEffectsModule.cpp.

129{
130 return {};
131}

◆ GetSymbol()

ComponentInterfaceSymbol AudioUnitEffectsModule::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 133 of file AudioUnitEffectsModule.cpp.

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

References XO.

◆ GetVendor()

VendorSymbol AudioUnitEffectsModule::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 139 of file AudioUnitEffectsModule.cpp.

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

References XO.

◆ GetVersion()

wxString AudioUnitEffectsModule::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 144 of file AudioUnitEffectsModule.cpp.

145{
146 // This "may" be different if this were to be maintained as a separate DLL
148}
#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 165 of file AudioUnitEffectsModule.cpp.

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

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

48{ return {}; }

◆ LoadAudioUnitsOfType()

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

Definition at line 255 of file AudioUnitEffectsModule.cpp.

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

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

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 234 of file AudioUnitEffectsModule.cpp.

235{
236 // Acquires a resource for the application.
237 if (wxString name; auto component = FindAudioUnit(path, name)) {
238 auto result = std::make_unique<AudioUnitEffect>(path, name, component);
239 result->FullyInitializePlugin();
240 return result;
241 }
242 return nullptr;
243}

References 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 171 of file AudioUnitEffectsModule.cpp.

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

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