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

#include <AudioUnitEffect.h>

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

Public Member Functions

 AudioUnitEffectsModule ()
 
virtual ~AudioUnitEffectsModule ()
 
PluginPath GetPath () override
 
ComponentInterfaceSymbol GetSymbol () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
TranslatableString GetDescription () override
 
bool Initialize () override
 
void Terminate () override
 
EffectFamilySymbol GetOptionalFamilySymbol () override
 
const FileExtensionsGetFileExtensions () override
 
FilePath InstallPath () override
 
bool AutoRegisterPlugins (PluginManagerInterface &pm) override
 
PluginPaths FindPluginPaths (PluginManagerInterface &pm) override
 
unsigned DiscoverPluginsAtPath (const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
 
bool IsPluginValid (const PluginPath &path, bool bFast) override
 
std::unique_ptr< ComponentInterfaceCreateInstance (const PluginPath &path) override
 
void LoadAudioUnitsOfType (OSType inAUType, PluginPaths &effects)
 
AudioComponent FindAudioUnit (const PluginPath &path, wxString &name)
 
wxString FromOSType (OSType type)
 
OSType ToOSType (const wxString &type)
 
- Public Member Functions inherited from ModuleInterface
virtual ~ModuleInterface ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 

Additional Inherited Members

- Public Types inherited from ModuleInterface
using RegistrationCallback = std::function< const PluginID &(ModuleInterface *, ComponentInterface *) >
 

Detailed Description

Definition at line 232 of file AudioUnitEffect.h.

Constructor & Destructor Documentation

◆ AudioUnitEffectsModule()

AudioUnitEffectsModule::AudioUnitEffectsModule ( )

Definition at line 252 of file AudioUnitEffect.cpp.

253 {
254 }

◆ ~AudioUnitEffectsModule()

AudioUnitEffectsModule::~AudioUnitEffectsModule ( )
virtual

Definition at line 256 of file AudioUnitEffect.cpp.

257 {
258 }

Member Function Documentation

◆ AutoRegisterPlugins()

bool AudioUnitEffectsModule::AutoRegisterPlugins ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 322 of file AudioUnitEffect.cpp.

323 {
324  // Nothing to be done here
325  return true;
326 }

◆ CreateInstance()

std::unique_ptr< ComponentInterface > AudioUnitEffectsModule::CreateInstance ( const PluginPath path)
overridevirtual

Implements ModuleInterface.

Definition at line 383 of file AudioUnitEffect.cpp.

384 {
385  // Acquires a resource for the application.
386  if (wxString name; auto component = FindAudioUnit(path, name))
387  return std::make_unique<AudioUnitEffect>(path, name, component);
388  return nullptr;
389 }

References FindAudioUnit(), and name.

Here is the call graph for this function:

◆ DiscoverPluginsAtPath()

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

Implements ModuleInterface.

Definition at line 341 of file AudioUnitEffect.cpp.

344 {
345  errMsg = {};
346  wxString name;
347  AudioComponent component = FindAudioUnit(path, name);
348  if (component == NULL)
349  {
350  errMsg = XO("Could not find component");
351  return 0;
352  }
353 
354  AudioUnitEffect effect(path, name, component);
355  if (!effect.SetHost(NULL))
356  {
357  // TODO: Is it worth it to discriminate all the ways SetHost might
358  // return false?
359  errMsg = XO("Could not initialize component");
360  return 0;
361  }
362 
363  if (callback)
364  {
365  callback(this, &effect);
366  }
367 
368  return 1;
369 }

References FindAudioUnit(), name, AudioUnitEffect::SetHost(), and XO.

Here is the call graph for this function:

◆ FindAudioUnit()

AudioComponent AudioUnitEffectsModule::FindAudioUnit ( const PluginPath path,
wxString &  name 
)

Definition at line 453 of file AudioUnitEffect.cpp.

455 {
456  wxStringTokenizer tokens(path, wxT("/"));
457 
458  AudioComponentDescription desc;
459 
460  desc.componentManufacturer = ToOSType(tokens.GetNextToken());
461  desc.componentType = ToOSType(tokens.GetNextToken());
462  desc.componentSubType = ToOSType(tokens.GetNextToken());
463  desc.componentFlags = 0;
464  desc.componentFlagsMask = 0;
465 
466  name = tokens.GetNextToken();
467  return AudioComponentFindNext(NULL, &desc);
468 }

References desc, name, and ToOSType().

Referenced by CreateInstance(), DiscoverPluginsAtPath(), and IsPluginValid().

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

◆ FindPluginPaths()

PluginPaths AudioUnitEffectsModule::FindPluginPaths ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 328 of file AudioUnitEffect.cpp.

329 {
330  PluginPaths effects;
331 
332  LoadAudioUnitsOfType(kAudioUnitType_Effect, effects);
333  LoadAudioUnitsOfType(kAudioUnitType_Generator, effects);
334  LoadAudioUnitsOfType(kAudioUnitType_Mixer, effects);
335  LoadAudioUnitsOfType(kAudioUnitType_MusicEffect, effects);
336  LoadAudioUnitsOfType(kAudioUnitType_Panner, effects);
337 
338  return effects;
339 }

References LoadAudioUnitsOfType().

Here is the call graph for this function:

◆ FromOSType()

wxString AudioUnitEffectsModule::FromOSType ( OSType  type)

Definition at line 470 of file AudioUnitEffect.cpp.

471 {
472  OSType rev = (type & 0xff000000) >> 24 |
473  (type & 0x00ff0000) >> 8 |
474  (type & 0x0000ff00) << 8 |
475  (type & 0x000000ff) << 24;
476 
477  return wxString::FromUTF8((char *)&rev, 4);
478 }

Referenced by LoadAudioUnitsOfType().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString AudioUnitEffectsModule::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 286 of file AudioUnitEffect.cpp.

287 {
288  return XO("Provides Audio Unit Effects support to Audacity");
289 }

References XO.

◆ GetFileExtensions()

const FileExtensions & AudioUnitEffectsModule::GetFileExtensions ( )
overridevirtual

Implements ModuleInterface.

Definition at line 295 of file AudioUnitEffect.cpp.

296 {
297  static FileExtensions result{{ _T("au") }};
298  return result;
299 }

◆ GetOptionalFamilySymbol()

EffectFamilySymbol AudioUnitEffectsModule::GetOptionalFamilySymbol ( )
overridevirtual

Implements ModuleInterface.

Definition at line 313 of file AudioUnitEffect.cpp.

314 {
315 #if USE_AUDIO_UNITS
317 #else
318  return {};
319 #endif
320 }

References AUDIOUNITEFFECTS_FAMILY.

◆ GetPath()

PluginPath AudioUnitEffectsModule::GetPath ( )
overridevirtual

Implements ComponentInterface.

Definition at line 264 of file AudioUnitEffect.cpp.

265 {
266  return {};
267 }

◆ GetSymbol()

ComponentInterfaceSymbol AudioUnitEffectsModule::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 269 of file AudioUnitEffect.cpp.

270 {
271  /* i18n-hint: Audio Unit is the name of an Apple audio software protocol */
272  return XO("Audio Unit Effects");
273 }

References XO.

◆ GetVendor()

VendorSymbol AudioUnitEffectsModule::GetVendor ( )
overridevirtual

Implements ComponentInterface.

Definition at line 275 of file AudioUnitEffect.cpp.

276 {
277  return XO("The Audacity Team");
278 }

References XO.

◆ GetVersion()

wxString AudioUnitEffectsModule::GetVersion ( )
overridevirtual

Implements ComponentInterface.

Definition at line 280 of file AudioUnitEffect.cpp.

281 {
282  // This "may" be different if this were to be maintained as a separate DLL
284 }

References AUDIOUNITEFFECTS_VERSION.

◆ Initialize()

bool AudioUnitEffectsModule::Initialize ( )
overridevirtual

Implements ModuleInterface.

Definition at line 301 of file AudioUnitEffect.cpp.

302 {
303  // Nothing to do here
304  return true;
305 }

◆ InstallPath()

FilePath AudioUnitEffectsModule::InstallPath ( )
inlineoverridevirtual

Implements ModuleInterface.

Definition at line 253 of file AudioUnitEffect.h.

253 { return {}; }

◆ IsPluginValid()

bool AudioUnitEffectsModule::IsPluginValid ( const PluginPath path,
bool  bFast 
)
overridevirtual

Implements ModuleInterface.

Definition at line 371 of file AudioUnitEffect.cpp.

372 {
373  if (bFast)
374  {
375  return true;
376  }
377 
378  wxString name;
379  return FindAudioUnit(path, name) != NULL;
380 }

References FindAudioUnit(), and name.

Here is the call graph for this function:

◆ LoadAudioUnitsOfType()

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

Definition at line 395 of file AudioUnitEffect.cpp.

397 {
398  AudioComponentDescription desc;
399  AudioComponent component;
400 
401  desc.componentType = inAUType;
402  desc.componentSubType = 0;
403  desc.componentManufacturer = 0;
404  desc.componentFlags = 0;
405  desc.componentFlagsMask = 0;
406 
407  component = AudioComponentFindNext(NULL, &desc);
408  while (component != NULL)
409  {
410  OSStatus result;
411  AudioComponentDescription found;
412 
413  result = AudioComponentGetDescription(component, &found);
414  if (result == noErr)
415  {
416  CFStringRef cfName{};
417  result = AudioComponentCopyName(component, &cfName);
418  CFunique_ptr<const __CFString> uName{ cfName };
419 
420  if (result == noErr)
421  {
422  wxString path;
423 
424  path.Printf(wxT("%-4.4s/%-4.4s/%-4.4s/%s"),
425  FromOSType(found.componentManufacturer),
426  FromOSType(found.componentType),
427  FromOSType(found.componentSubType),
428  wxCFStringRef::AsString(cfName));
429 
430  for (int i = 0; i < WXSIZEOF(BlackList); ++i)
431  {
432  if (BlackList[i].componentType == found.componentType &&
433  BlackList[i].componentSubType == found.componentSubType &&
434  BlackList[i].componentManufacturer == found.componentManufacturer)
435  {
436  wxLogDebug(wxT("Blacklisted AU skipped: %s"), path);
437  result = !noErr;
438  break;
439  }
440  }
441 
442  if (result == noErr)
443  {
444  effects.push_back(path);
445  }
446  }
447  }
448 
449  component = AudioComponentFindNext(component, &desc);
450  }
451 }

References BlackList, componentType, desc, and FromOSType().

Referenced by FindPluginPaths().

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

◆ Terminate()

void AudioUnitEffectsModule::Terminate ( )
overridevirtual

Implements ModuleInterface.

Definition at line 307 of file AudioUnitEffect.cpp.

308 {
309  // Nothing to do here
310  return;
311 }

◆ ToOSType()

OSType AudioUnitEffectsModule::ToOSType ( const wxString &  type)

Definition at line 480 of file AudioUnitEffect.cpp.

481 {
482  wxCharBuffer buf = type.ToUTF8();
483 
484  OSType rev = ((unsigned char)buf.data()[0]) << 24 |
485  ((unsigned char)buf.data()[1]) << 16 |
486  ((unsigned char)buf.data()[2]) << 8 |
487  ((unsigned char)buf.data()[3]);
488 
489  return rev;
490 }

Referenced by FindAudioUnit().

Here is the caller graph for this function:

The documentation for this class was generated from the following files:
AudioUnitEffectsModule::LoadAudioUnitsOfType
void LoadAudioUnitsOfType(OSType inAUType, PluginPaths &effects)
Definition: AudioUnitEffect.cpp:395
BlackList
static const struct @0 BlackList[]
AUDIOUNITEFFECTS_VERSION
#define AUDIOUNITEFFECTS_VERSION
Definition: AudioUnitEffect.h:30
AudioUnitEffectsModule::FindAudioUnit
AudioComponent FindAudioUnit(const PluginPath &path, wxString &name)
Definition: AudioUnitEffect.cpp:453
XO
#define XO(s)
Definition: Internat.h:31
wxArrayStringEx
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: wxArrayStringEx.h:18
AudioUnitEffectsModule::FromOSType
wxString FromOSType(OSType type)
Definition: AudioUnitEffect.cpp:470
desc
const TranslatableString desc
Definition: ExportPCM.cpp:58
componentType
OSType componentType
Definition: AudioUnitEffect.cpp:76
AUDIOUNITEFFECTS_FAMILY
#define AUDIOUNITEFFECTS_FAMILY
Definition: AudioUnitEffect.h:32
name
const TranslatableString name
Definition: Distortion.cpp:98
CFunique_ptr
std::unique_ptr< T, CFReleaser > CFunique_ptr
Definition: AudioUnitEffect.cpp:99
AudioUnitEffect
An Effect class that handles a wide range of effects. ??Mac only??
Definition: AudioUnitEffect.h:43
PluginPaths
std::vector< PluginPath > PluginPaths
Definition: Identifier.h:215
AudioUnitEffectsModule::ToOSType
OSType ToOSType(const wxString &type)
Definition: AudioUnitEffect.cpp:480