Audacity  3.0.3
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
AudioUnitEffect Class Reference

An Effect class that handles a wide range of effects. ??Mac only?? More...

#include <AudioUnitEffect.h>

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

Public Member Functions

 AudioUnitEffect (const PluginPath &path, const wxString &name, AudioComponent component, AudioUnitEffect *master=NULL)
 
virtual ~AudioUnitEffect ()
 
PluginPath GetPath () override
 
ComponentInterfaceSymbol GetSymbol () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
TranslatableString GetDescription () override
 
EffectType GetType () override
 
EffectFamilySymbol GetFamily () override
 
bool IsInteractive () override
 
bool IsDefault () override
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 
bool SupportsAutomation () override
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
sampleCount GetLatency () override
 
size_t GetTailSize () override
 
bool IsReady () override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 
bool ProcessFinalize () override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () override
 
bool ShowInterface (wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadUserPreset (const RegistryPath &name) override
 
bool SaveUserPreset (const RegistryPath &name) override
 
bool LoadFactoryPreset (int id) override
 
bool LoadFactoryDefaults () override
 
RegistryPaths GetFactoryPresets () override
 
void SetHostUI (EffectUIHostInterface *host) override
 
bool PopulateUI (ShuttleGui &S) override
 
bool IsGraphicalUI () override
 
bool ValidateUI () override
 
bool HideUI () override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets () override
 
void ImportPresets () override
 
bool HasOptions () override
 
void ShowOptions () override
 
- Public Member Functions inherited from EffectClientInterface
virtual ~EffectClientInterface ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 

Private Member Functions

bool SetRateAndChannels ()
 
bool CopyParameters (AudioUnit srcUnit, AudioUnit dstUnit)
 
TranslatableString Export (const wxString &path)
 
TranslatableString Import (const wxString &path)
 
void Notify (AudioUnit unit, AudioUnitParameterID parm)
 
unsigned GetChannelCount ()
 
void SetChannelCount (unsigned numChannels)
 
OSStatus Render (AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
 
void EventListener (const AudioUnitEvent *inEvent, AudioUnitParameterValue inParameterValue)
 
void GetChannelCounts ()
 
bool LoadPreset (const RegistryPath &group)
 
bool SavePreset (const RegistryPath &group)
 
bool BypassEffect (bool bypass)
 

Static Private Member Functions

static OSStatus RenderCallback (void *inRefCon, AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
 
static void EventListenerCallback (void *inCallbackRefCon, void *inObject, const AudioUnitEvent *inEvent, UInt64 inEventHostTime, AudioUnitParameterValue inParameterValue)
 

Private Attributes

PluginPath mPath
 
wxString mName
 
wxString mVendor
 
AudioComponent mComponent
 
AudioUnit mUnit
 
bool mUnitInitialized
 
bool mSupportsMono
 
bool mSupportsStereo
 
EffectHostInterfacemHost
 
unsigned mAudioIns
 
unsigned mAudioOuts
 
bool mInteractive
 
bool mLatencyDone
 
UInt32 mBlockSize
 
double mSampleRate
 
int mBufferSize
 
bool mUseLatency
 
AudioTimeStamp mTimeStamp
 
bool mReady
 
ArrayOf< AudioBufferList > mInputList
 
ArrayOf< AudioBufferList > mOutputList
 
EffectUIHostInterfacemUIHost
 
wxWindow * mParent
 
wxDialog * mDialog
 
wxString mUIType
 
bool mIsGraphical
 
AudioUnitEffectmMaster
 
AudioUnitEffectArray mSlaves
 
unsigned mNumChannels
 
ArraysOf< float > mMasterIn
 
ArraysOf< float > mMasterOut
 
size_t mNumSamples
 
AUEventListenerRef mEventListenerRef
 
AUControlmpControl {}
 

Friends

class AudioUnitEffectExportDialog
 
class AudioUnitEffectImportDialog
 

Additional Inherited Members

- Public Types inherited from EffectClientInterface
using EffectDialogFactory = std::function< wxDialog *(wxWindow &parent, EffectHostInterface *, EffectUIClientInterface *) >
 

Detailed Description

An Effect class that handles a wide range of effects. ??Mac only??

Definition at line 40 of file AudioUnitEffect.h.

Constructor & Destructor Documentation

◆ AudioUnitEffect()

AudioUnitEffect::AudioUnitEffect ( const PluginPath path,
const wxString &  name,
AudioComponent  component,
AudioUnitEffect master = NULL 
)

Definition at line 824 of file AudioUnitEffect.cpp.

828 {
829  mPath = path;
830  mName = name.AfterFirst(wxT(':')).Trim(true).Trim(false);
831  mVendor = name.BeforeFirst(wxT(':')).Trim(true).Trim(false);
832  mComponent = component;
833  mMaster = master;
834 
835  mpControl = NULL;
836  mUnit = NULL;
837 
838  mBlockSize = 0.0;
839  mInteractive = false;
840  mIsGraphical = false;
841 
842  mUIHost = NULL;
843  mDialog = NULL;
844  mParent = NULL;
845 
846  mUnitInitialized = false;
847 
848  mEventListenerRef = NULL;
849 
850  mReady = false;
851 }

References mBlockSize, mComponent, mDialog, mEventListenerRef, mInteractive, mIsGraphical, mMaster, mName, mParent, mPath, mpControl, mReady, mUIHost, mUnit, mUnitInitialized, mVendor, and name.

◆ ~AudioUnitEffect()

AudioUnitEffect::~AudioUnitEffect ( )
virtual

Definition at line 853 of file AudioUnitEffect.cpp.

854 {
855  if (mUnitInitialized)
856  {
857  AudioUnitUninitialize(mUnit);
858  }
859 
860  if (mEventListenerRef)
861  {
862  AUListenerDispose(mEventListenerRef);
863  }
864 
865  if (mUnit)
866  {
867  AudioComponentInstanceDispose(mUnit);
868  }
869 }

References mEventListenerRef, mUnit, and mUnitInitialized.

Member Function Documentation

◆ BypassEffect()

bool AudioUnitEffect::BypassEffect ( bool  bypass)
private

Definition at line 2682 of file AudioUnitEffect.cpp.

2683 {
2684  OSStatus result;
2685 
2686  UInt32 value = (bypass ? 1 : 0);
2687 
2688  result = AudioUnitSetProperty(mUnit,
2689  kAudioUnitProperty_BypassEffect,
2690  kAudioUnitScope_Global,
2691  0,
2692  &value,
2693  sizeof(value));
2694  if (result != noErr)
2695  {
2696  return false;
2697  }
2698 
2699  return true;
2700 }

References mUnit.

Referenced by ProcessInitialize(), RealtimeResume(), and RealtimeSuspend().

Here is the caller graph for this function:

◆ CanExportPresets()

bool AudioUnitEffect::CanExportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1843 of file AudioUnitEffect.cpp.

1844 {
1845  return true;
1846 }

◆ CloseUI()

bool AudioUnitEffect::CloseUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1821 of file AudioUnitEffect.cpp.

1822 {
1823 #ifdef __WXMAC__
1824 #ifdef __WX_EVTLOOP_BUSY_WAITING__
1825  wxEventLoop::SetBusyWaiting(false);
1826 #endif
1827  if (mpControl)
1828  {
1829  mParent->RemoveEventHandler(this);
1830 
1831  mpControl->Close();
1832  mpControl = nullptr;
1833  }
1834 #endif
1835 
1836  mUIHost = NULL;
1837  mParent = NULL;
1838  mDialog = NULL;
1839 
1840  return true;
1841 }

References AUControl::Close(), mDialog, mParent, mpControl, and mUIHost.

Here is the call graph for this function:

◆ CopyParameters()

bool AudioUnitEffect::CopyParameters ( AudioUnit  srcUnit,
AudioUnit  dstUnit 
)
private

Definition at line 2245 of file AudioUnitEffect.cpp.

2246 {
2247  OSStatus result;
2248 
2249  // Retrieve the class state from the source AU
2250  CFPropertyListRef content;
2251  UInt32 size = sizeof(content);
2252  result = AudioUnitGetProperty(srcUnit,
2253  kAudioUnitProperty_ClassInfo,
2254  kAudioUnitScope_Global,
2255  0,
2256  &content,
2257  &size);
2258  if (result != noErr)
2259  {
2260  return false;
2261  }
2262 
2263  // Make sure it get's freed
2264  CFunique_ptr<char /* CFPropertyList */> ucontent { (char *) content };
2265 
2266  // Set the destination AUs state from the source AU's content
2267  result = AudioUnitSetProperty(dstUnit,
2268  kAudioUnitProperty_ClassInfo,
2269  kAudioUnitScope_Global,
2270  0,
2271  &content,
2272  sizeof(content));
2273  if (result != noErr)
2274  {
2275  return false;
2276  }
2277 
2278  // Notify interested parties
2279  Notify(dstUnit, kAUParameterListener_AnyParameter);
2280 
2281  return true;
2282 }

References Notify().

Referenced by RealtimeAddProcessor().

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

◆ EventListener()

void AudioUnitEffect::EventListener ( const AudioUnitEvent *  inEvent,
AudioUnitParameterValue  inParameterValue 
)
private

Definition at line 2473 of file AudioUnitEffect.cpp.

2475 {
2476  // Handle property changes
2477  if (inEvent->mEventType == kAudioUnitEvent_PropertyChange)
2478  {
2479  // Handle latency changes
2480  if (inEvent->mArgument.mProperty.mPropertyID == kAudioUnitProperty_Latency)
2481  {
2482  // Allow change to be used
2483  //mLatencyDone = false;
2484  }
2485 
2486  return;
2487  }
2488 
2489  // Only parameter changes at this point
2490 
2491  if (mMaster)
2492  {
2493  // We're a slave, so just set the parameter
2494  AudioUnitSetParameter(mUnit,
2495  inEvent->mArgument.mParameter.mParameterID,
2496  kAudioUnitScope_Global,
2497  0,
2498  inParameterValue,
2499  0);
2500  }
2501  else
2502  {
2503  // We're the master, so propagate
2504  for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
2505  {
2506  mSlaves[i]->EventListener(inEvent, inParameterValue);
2507  }
2508  }
2509 }

References mMaster, mSlaves, and mUnit.

◆ EventListenerCallback()

void AudioUnitEffect::EventListenerCallback ( void *  inCallbackRefCon,
void *  inObject,
const AudioUnitEvent *  inEvent,
UInt64  inEventHostTime,
AudioUnitParameterValue  inParameterValue 
)
staticprivate

Definition at line 2512 of file AudioUnitEffect.cpp.

2517 {
2518  ((AudioUnitEffect *) inCallbackRefCon)->EventListener(inEvent,
2519  inParameterValue);
2520 }

Referenced by SetHost().

Here is the caller graph for this function:

◆ Export()

TranslatableString AudioUnitEffect::Export ( const wxString &  path)
private

Definition at line 2294 of file AudioUnitEffect.cpp.

2295 {
2296  // Create the file
2297  wxFFile f(path, wxT("wb"));
2298  if (!f.IsOpened())
2299  {
2300  return XO("Couldn't open \"%s\"").Format(path);
2301  }
2302 
2303  // First set the name of the preset
2304  wxCFStringRef cfname(wxFileName(path).GetName());
2305 
2306  // Define the preset property
2307  AUPreset preset;
2308  preset.presetNumber = -1; // indicates user preset
2309  preset.presetName = cfname;
2310 
2311  // And set it in the audio unit
2312  OSStatus result;
2313  result = AudioUnitSetProperty(mUnit,
2314  kAudioUnitProperty_PresentPreset,
2315  kAudioUnitScope_Global,
2316  0,
2317  &preset,
2318  sizeof(preset));
2319  if (result != noErr)
2320  {
2321  return XO("Failed to set preset name");
2322  }
2323 
2324  // Now retrieve the preset content
2325  CFPropertyListRef content;
2326  UInt32 size = sizeof(content);
2327  result = AudioUnitGetProperty(mUnit,
2328  kAudioUnitProperty_ClassInfo,
2329  kAudioUnitScope_Global,
2330  0,
2331  &content,
2332  &size);
2333  CFunique_ptr<char /* CFPropertyList */> ucontent { (char *) content };
2334  if (result != noErr)
2335  {
2336  return XO("Failed to retrieve preset content");
2337  }
2338 
2339  // And convert it to serialized XML data
2341  {
2342  CFPropertyListCreateData(kCFAllocatorDefault,
2343  content,
2344  kCFPropertyListXMLFormat_v1_0,
2345  0,
2346  NULL)
2347  };
2348  if (!data)
2349  {
2350  return XO("Failed to convert property list to XML data");
2351  }
2352 
2353  // Nothing to do if we don't have any data
2354  SInt32 length = CFDataGetLength(data.get());
2355  if (!length)
2356  {
2357  return XO("XML data is empty after conversion");
2358  }
2359 
2360  // Write XML data
2361  if (f.Write(CFDataGetBytePtr(data.get()), length) != length || f.Error())
2362  {
2363  return XO("Failed to write XML preset to \"%s\"").Format(path);
2364  }
2365 
2366  f.Close();
2367 
2368  return {};
2369 }

References ComponentInterface::GetName(), mUnit, and XO.

Referenced by ExportPresets().

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

◆ ExportPresets()

void AudioUnitEffect::ExportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1848 of file AudioUnitEffect.cpp.

1849 {
1850  // Generate the user domain path
1851  wxFileName fn;
1852  fn.SetPath(PRESET_USER_PATH);
1853  fn.AppendDir(mVendor);
1854  fn.AppendDir(mName);
1855  fn.Normalize();
1856  FilePath path = fn.GetFullPath();
1857 
1858  if (!fn.Mkdir(fn.GetFullPath(), 0755, wxPATH_MKDIR_FULL))
1859  {
1860  wxLogError(wxT("Couldn't create the \"%s\" directory"), fn.GetPath());
1861  return;
1862  }
1863 
1864  // Ask the user for the name to use
1865  //
1866  // Passing a valid parent will cause some effects dialogs to malfunction
1867  // upon returning from the SelectFile().
1868  path = SelectFile(FileNames::Operation::_None,
1869  XO("Export Audio Unit Preset As %s:").Format(fn.GetFullPath()),
1870  fn.GetFullPath(),
1871  wxEmptyString,
1872  wxT("aupreset"),
1873  {
1874  { XO("Standard Audio Unit preset file"), { wxT("aupreset") }, true },
1875  },
1876  wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
1877  NULL);
1878 
1879  // User canceled...
1880  if (path.empty())
1881  {
1882  return;
1883  }
1884 
1885  auto msg = Export(path);
1886  if (!msg.empty())
1887  {
1889  XO("Could not export \"%s\" preset\n\n%s").Format(path, msg),
1890  XO("Export Audio Unit Presets"),
1891  wxOK | wxCENTRE,
1892  mParent);
1893  }
1894 }

References AudacityMessageBox(), Export(), fn, mName, mParent, mVendor, PRESET_USER_PATH, SelectFile(), and XO.

Here is the call graph for this function:

◆ GetAudioInCount()

unsigned AudioUnitEffect::GetAudioInCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1164 of file AudioUnitEffect.cpp.

1165 {
1166  return mAudioIns;
1167 }

References mAudioIns.

◆ GetAudioOutCount()

unsigned AudioUnitEffect::GetAudioOutCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1169 of file AudioUnitEffect.cpp.

1170 {
1171  return mAudioOuts;
1172 }

References mAudioOuts.

◆ GetAutomationParameters()

bool AudioUnitEffect::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 1499 of file AudioUnitEffect.cpp.

1500 {
1501  OSStatus result;
1502  UInt32 dataSize;
1503  Boolean isWritable;
1504 
1505  result = AudioUnitGetPropertyInfo(mUnit,
1506  kAudioUnitProperty_ParameterList,
1507  kAudioUnitScope_Global,
1508  0,
1509  &dataSize,
1510  &isWritable);
1511  if (result != noErr)
1512  {
1513  return false;
1514  }
1515 
1516  UInt32 cnt = dataSize / sizeof(AudioUnitParameterID);
1517  ArrayOf<AudioUnitParameterID> array {cnt};
1518 
1519  result = AudioUnitGetProperty(mUnit,
1520  kAudioUnitProperty_ParameterList,
1521  kAudioUnitScope_Global,
1522  0,
1523  array.get(),
1524  &dataSize);
1525  if (result != noErr)
1526  {
1527  return false;
1528  }
1529 
1530  for (int i = 0; i < cnt; i++)
1531  {
1532  ParameterInfo pi;
1533 
1534  if (!pi.Get(mUnit, array[i]))
1535  {
1536  // Probably failed because of invalid parameter which can happen
1537  // if a plug-in is in a certain mode that doesn't contain the
1538  // parameter. In any case, just ignore it.
1539  continue;
1540  }
1541 
1542  AudioUnitParameterValue value;
1543  result = AudioUnitGetParameter(mUnit,
1544  array[i],
1545  kAudioUnitScope_Global,
1546  0,
1547  &value);
1548  if (result != noErr)
1549  {
1550  // Probably failed because of invalid parameter which can happen
1551  // if a plug-in is in a certain mode that doesn't contain the
1552  // parameter. In any case, just ignore it.
1553  continue;
1554  }
1555 
1556  parms.Write(pi.name, value);
1557  }
1558 
1559  return true;
1560 }

References ParameterInfo::Get(), mUnit, and ParameterInfo::name.

Here is the call graph for this function:

◆ GetBlockSize()

size_t AudioUnitEffect::GetBlockSize ( ) const
overridevirtual

Implements EffectClientInterface.

Definition at line 1194 of file AudioUnitEffect.cpp.

1195 {
1196  return mBlockSize;
1197 }

References mBlockSize.

◆ GetChannelCount()

unsigned AudioUnitEffect::GetChannelCount ( )
private

Definition at line 2284 of file AudioUnitEffect.cpp.

2285 {
2286  return mNumChannels;
2287 }

References mNumChannels.

◆ GetChannelCounts()

void AudioUnitEffect::GetChannelCounts ( )
private

Definition at line 2522 of file AudioUnitEffect.cpp.

2523 {
2524  Boolean isWritable = 0;
2525  UInt32 dataSize = 0;
2526  OSStatus result;
2527 
2528  // Does AU have channel info
2529  result = AudioUnitGetPropertyInfo(mUnit,
2530  kAudioUnitProperty_SupportedNumChannels,
2531  kAudioUnitScope_Global,
2532  0,
2533  &dataSize,
2534  &isWritable);
2535  if (result)
2536  {
2537  // None supplied. Apparently all FX type units can do any number of INs
2538  // and OUTs as long as they are the same number. In this case, we'll
2539  // just say stereo.
2540  //
2541  // We should probably check to make sure we're dealing with an FX type.
2542  mAudioIns = 2;
2543  mAudioOuts = 2;
2544  return;
2545  }
2546 
2547  ArrayOf<char> buffer{ dataSize };
2548  auto info = (AUChannelInfo *) buffer.get();
2549 
2550  // Retrieve the channel info
2551  result = AudioUnitGetProperty(mUnit,
2552  kAudioUnitProperty_SupportedNumChannels,
2553  kAudioUnitScope_Global,
2554  0,
2555  info,
2556  &dataSize);
2557  if (result)
2558  {
2559  // Oh well, not much we can do out this case
2560  mAudioIns = 2;
2561  mAudioOuts = 2;
2562 
2563  return;
2564  }
2565 
2566  // This is where it gets weird...not sure what is the best
2567  // way to do this really. If we knew how many ins/outs we
2568  // really needed, we could make a better choice.
2569 
2570  bool haven2m = false; // nothing -> mono
2571  bool haven2s = false; // nothing -> stereo
2572  bool havem2n = false; // mono -> nothing
2573  bool haves2n = false; // stereo -> nothing
2574  bool havem2m = false; // mono -> mono
2575  bool haves2s = false; // stereo -> stereo
2576  bool havem2s = false; // mono -> stereo
2577  bool haves2m = false; // stereo -> mono
2578 
2579  mAudioIns = 2;
2580  mAudioOuts = 2;
2581 
2582  // Look only for exact channel constraints
2583  for (int i = 0; i < dataSize / sizeof(AUChannelInfo); i++)
2584  {
2585  AUChannelInfo *ci = &info[i];
2586 
2587  int ic = ci->inChannels;
2588  int oc = ci->outChannels;
2589 
2590  if (ic < 0 && oc >= 0)
2591  {
2592  ic = 2;
2593  }
2594  else if (ic >= 0 && oc < 0)
2595  {
2596  oc = 2;
2597  }
2598  else if (ic < 0 && oc < 0)
2599  {
2600  ic = 2;
2601  oc = 2;
2602  }
2603 
2604  if (ic == 2 && oc == 2)
2605  {
2606  haves2s = true;
2607  }
2608  else if (ic == 1 && oc == 1)
2609  {
2610  havem2m = true;
2611  }
2612  else if (ic == 1 && oc == 2)
2613  {
2614  havem2s = true;
2615  }
2616  else if (ic == 2 && oc == 1)
2617  {
2618  haves2m = true;
2619  }
2620  else if (ic == 0 && oc == 2)
2621  {
2622  haven2s = true;
2623  }
2624  else if (ic == 0 && oc == 1)
2625  {
2626  haven2m = true;
2627  }
2628  else if (ic == 1 && oc == 0)
2629  {
2630  havem2n = true;
2631  }
2632  else if (ic == 2 && oc == 0)
2633  {
2634  haves2n = true;
2635  }
2636  }
2637 
2638  if (haves2s)
2639  {
2640  mAudioIns = 2;
2641  mAudioOuts = 2;
2642  }
2643  else if (havem2m)
2644  {
2645  mAudioIns = 1;
2646  mAudioOuts = 1;
2647  }
2648  else if (havem2s)
2649  {
2650  mAudioIns = 1;
2651  mAudioOuts = 2;
2652  }
2653  else if (haves2m)
2654  {
2655  mAudioIns = 2;
2656  mAudioOuts = 1;
2657  }
2658  else if (haven2m)
2659  {
2660  mAudioIns = 0;
2661  mAudioOuts = 1;
2662  }
2663  else if (haven2s)
2664  {
2665  mAudioIns = 0;
2666  mAudioOuts = 2;
2667  }
2668  else if (haves2n)
2669  {
2670  mAudioIns = 2;
2671  mAudioOuts = 0;
2672  }
2673  else if (havem2n)
2674  {
2675  mAudioIns = 1;
2676  mAudioOuts = 0;
2677  }
2678 
2679  return;
2680 }

References mAudioIns, mAudioOuts, and mUnit.

Referenced by SetHost().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString AudioUnitEffect::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 902 of file AudioUnitEffect.cpp.

903 {
904  /* i18n-hint: Can mean "not available," "not applicable," "no answer" */
905  return XO("n/a");
906 }

References XO.

◆ GetFactoryPresets()

RegistryPaths AudioUnitEffect::GetFactoryPresets ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1679 of file AudioUnitEffect.cpp.

1680 {
1681  OSStatus result;
1682  RegistryPaths presets;
1683 
1684  // Retrieve the list of factory presets
1685  CFArrayRef array{};
1686  UInt32 dataSize = sizeof(CFArrayRef);
1687  result = AudioUnitGetProperty(mUnit,
1688  kAudioUnitProperty_FactoryPresets,
1689  kAudioUnitScope_Global,
1690  0,
1691  &array,
1692  &dataSize);
1693  CFunique_ptr<const __CFArray> uarray { array };
1694  if (result == noErr)
1695  {
1696  for (CFIndex i = 0, cnt = CFArrayGetCount(array); i < cnt; i++)
1697  {
1698  AUPreset *preset = (AUPreset *) CFArrayGetValueAtIndex(array, i);
1699  presets.push_back(wxCFStringRef::AsString(preset->presetName));
1700  }
1701  }
1702 
1703  return presets;
1704 }

References mUnit.

◆ GetFamily()

EffectFamilySymbol AudioUnitEffect::GetFamily ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 932 of file AudioUnitEffect.cpp.

933 {
935 }

References AUDIOUNITEFFECTS_FAMILY.

◆ GetLatency()

sampleCount AudioUnitEffect::GetLatency ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1199 of file AudioUnitEffect.cpp.

1200 {
1201  // Retrieve the latency (can be updated via an event)
1202  if (mUseLatency && !mLatencyDone)
1203  {
1204  mLatencyDone = true;
1205 
1206  Float64 latency = 0.0;
1207  UInt32 dataSize = sizeof(latency);
1208  AudioUnitGetProperty(mUnit,
1209  kAudioUnitProperty_Latency,
1210  kAudioUnitScope_Global,
1211  0,
1212  &latency,
1213  &dataSize);
1214 
1215  return sampleCount(latency * mSampleRate);
1216  }
1217 
1218  return 0;
1219 }

References mLatencyDone, mSampleRate, mUnit, and mUseLatency.

◆ GetMidiInCount()

int AudioUnitEffect::GetMidiInCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1174 of file AudioUnitEffect.cpp.

1175 {
1176  return 0;
1177 }

◆ GetMidiOutCount()

int AudioUnitEffect::GetMidiOutCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1179 of file AudioUnitEffect.cpp.

1180 {
1181  return 0;
1182 }

◆ GetPath()

PluginPath AudioUnitEffect::GetPath ( )
overridevirtual

Implements ComponentInterface.

Definition at line 875 of file AudioUnitEffect.cpp.

876 {
877  return mPath;
878 }

References mPath.

◆ GetSymbol()

ComponentInterfaceSymbol AudioUnitEffect::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 880 of file AudioUnitEffect.cpp.

881 {
882  return mName;
883 }

References mName.

Referenced by SetRateAndChannels().

Here is the caller graph for this function:

◆ GetTailSize()

size_t AudioUnitEffect::GetTailSize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1221 of file AudioUnitEffect.cpp.

1222 {
1223  // Retrieve the tail time
1224  Float64 tailTime = 0.0;
1225  UInt32 dataSize = sizeof(tailTime);
1226  AudioUnitGetProperty(mUnit,
1227  kAudioUnitProperty_TailTime,
1228  kAudioUnitScope_Global,
1229  0,
1230  &tailTime,
1231  &dataSize);
1232 
1233  return tailTime * mSampleRate;
1234 }

References mSampleRate, and mUnit.

◆ GetType()

EffectType AudioUnitEffect::GetType ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 912 of file AudioUnitEffect.cpp.

913 {
914  if (mAudioIns == 0 && mAudioOuts == 0)
915  {
916  return EffectTypeNone;
917  }
918 
919  if (mAudioIns == 0)
920  {
921  return EffectTypeGenerate;
922  }
923 
924  if (mAudioOuts == 0)
925  {
926  return EffectTypeAnalyze;
927  }
928 
929  return EffectTypeProcess;
930 }

References EffectTypeAnalyze, EffectTypeGenerate, EffectTypeNone, EffectTypeProcess, mAudioIns, and mAudioOuts.

Referenced by HideUI(), ShowInterface(), SupportsRealtime(), and ValidateUI().

Here is the caller graph for this function:

◆ GetVendor()

VendorSymbol AudioUnitEffect::GetVendor ( )
overridevirtual

Implements ComponentInterface.

Definition at line 885 of file AudioUnitEffect.cpp.

886 {
887  return { mVendor };
888 }

References mVendor.

◆ GetVersion()

wxString AudioUnitEffect::GetVersion ( )
overridevirtual

Implements ComponentInterface.

Definition at line 890 of file AudioUnitEffect.cpp.

891 {
892  UInt32 version;
893 
894  OSStatus result = AudioComponentGetVersion(mComponent, &version);
895 
896  return wxString::Format(wxT("%d.%d.%d"),
897  (version >> 16) & 0xffff,
898  (version >> 8) & 0xff,
899  version & 0xff);
900 }

References mComponent.

◆ HasOptions()

bool AudioUnitEffect::HasOptions ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1938 of file AudioUnitEffect.cpp.

1939 {
1940  return true;
1941 }

◆ HideUI()

bool AudioUnitEffect::HideUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1810 of file AudioUnitEffect.cpp.

1811 {
1812 #if 0
1813  if (GetType() == EffectTypeAnalyze || mNumOutputControls > 0)
1814  {
1815  return false;
1816  }
1817 #endif
1818  return true;
1819 }

References EffectTypeAnalyze, and GetType().

Here is the call graph for this function:

◆ Import()

TranslatableString AudioUnitEffect::Import ( const wxString &  path)
private

Definition at line 2371 of file AudioUnitEffect.cpp.

2372 {
2373  // Open the preset
2374  wxFFile f(path, wxT("r"));
2375  if (!f.IsOpened())
2376  {
2377  return XO("Couldn't open \"%s\"").Format(path);
2378  }
2379 
2380  // Load it into the buffer
2381  size_t len = f.Length();
2382  wxMemoryBuffer buf(len);
2383  if (f.Read(buf.GetData(), len) != len || f.Error())
2384  {
2385  return XO("Unable to read the preset from \"%s\"").Format(path);
2386  }
2387 
2388  // Create a CFData object that references the decoded preset
2390  {
2391  CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
2392  (const UInt8 *) buf.GetData(),
2393  len,
2394  kCFAllocatorNull)
2395  };
2396  if (!data)
2397  {
2398  return XO("Failed to convert preset to internal format");
2399  }
2400 
2401  // Convert it back to a property list.
2402  CFPropertyListRef content
2403  {
2404  CFPropertyListCreateWithData(kCFAllocatorDefault,
2405  data.get(),
2406  kCFPropertyListImmutable,
2407  NULL,
2408  NULL)
2409  };
2410  if (!content)
2411  {
2412  return XO("Failed to create property list for preset");
2413  }
2414  CFunique_ptr<char /* CFPropertyList */> ucontent { (char *) content };
2415 
2416  // Finally, update the properties and parameters
2417  OSStatus result;
2418  result = AudioUnitSetProperty(mUnit,
2419  kAudioUnitProperty_ClassInfo,
2420  kAudioUnitScope_Global,
2421  0,
2422  &content,
2423  sizeof(content));
2424  if (result != noErr)
2425  {
2426  return XO("Failed to set class info for \"%s\" preset");
2427  }
2428 
2429  // Notify interested parties of change and propagate to slaves
2430  Notify(mUnit, kAUParameterListener_AnyParameter);
2431 
2432  return {};
2433 }

References mUnit, Notify(), and XO.

Referenced by ImportPresets().

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

◆ ImportPresets()

void AudioUnitEffect::ImportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1896 of file AudioUnitEffect.cpp.

1897 {
1898  // Generate the user domain path
1899  wxFileName fn;
1900  fn.SetPath(PRESET_USER_PATH);
1901  fn.AppendDir(mVendor);
1902  fn.AppendDir(mName);
1903  fn.Normalize();
1904  FilePath path = fn.GetFullPath();
1905 
1906  // Ask the user for the name to use
1907  //
1908  // Passing a valid parent will cause some effects dialogs to malfunction
1909  // upon returning from the SelectFile().
1910  path = SelectFile(FileNames::Operation::_None,
1911  XO("Import Audio Unit Preset As %s:").Format(fn.GetFullPath()),
1912  fn.GetFullPath(),
1913  wxEmptyString,
1914  wxT("aupreset"),
1915  {
1916  { XO("Standard Audio Unit preset file"), { wxT("aupreset") }, true },
1917  },
1918  wxFD_OPEN | wxRESIZE_BORDER,
1919  NULL);
1920 
1921  // User canceled...
1922  if (path.empty())
1923  {
1924  return;
1925  }
1926 
1927  auto msg = Import(path);
1928  if (!msg.empty())
1929  {
1931  XO("Could not import \"%s\" preset\n\n%s").Format(path, msg),
1932  XO("Import Audio Unit Presets"),
1933  wxOK | wxCENTRE,
1934  mParent);
1935  }
1936 }

References AudacityMessageBox(), fn, Import(), mName, mParent, mVendor, PRESET_USER_PATH, SelectFile(), and XO.

Here is the call graph for this function:

◆ IsDefault()

bool AudioUnitEffect::IsDefault ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 942 of file AudioUnitEffect.cpp.

943 {
944  return false;
945 }

◆ IsGraphicalUI()

bool AudioUnitEffect::IsGraphicalUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1781 of file AudioUnitEffect.cpp.

1782 {
1783  return mUIType != wxT("Plain");
1784 }

References mUIType.

◆ IsInteractive()

bool AudioUnitEffect::IsInteractive ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 937 of file AudioUnitEffect.cpp.

938 {
939  return mInteractive;
940 }

References mInteractive.

◆ IsLegacy()

bool AudioUnitEffect::IsLegacy ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 947 of file AudioUnitEffect.cpp.

948 {
949  return false;
950 }

◆ IsReady()

bool AudioUnitEffect::IsReady ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1236 of file AudioUnitEffect.cpp.

1237 {
1238  return mReady;
1239 }

References mReady.

◆ LoadFactoryDefaults()

bool AudioUnitEffect::LoadFactoryDefaults ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1674 of file AudioUnitEffect.cpp.

1675 {
1677 }

References EffectHostInterface::GetFactoryDefaultsGroup(), LoadPreset(), and mHost.

Here is the call graph for this function:

◆ LoadFactoryPreset()

bool AudioUnitEffect::LoadFactoryPreset ( int  id)
overridevirtual

Implements EffectClientInterface.

Definition at line 1633 of file AudioUnitEffect.cpp.

1634 {
1635  OSStatus result;
1636 
1637  // Retrieve the list of factory presets
1638  CFArrayRef array{};
1639  UInt32 dataSize = sizeof(CFArrayRef);
1640  result = AudioUnitGetProperty(mUnit,
1641  kAudioUnitProperty_FactoryPresets,
1642  kAudioUnitScope_Global,
1643  0,
1644  &array,
1645  &dataSize);
1646  CFunique_ptr<const __CFArray> uarray { array };
1647  if (result != noErr)
1648  {
1649  return false;
1650  }
1651 
1652  if (id < 0 || id >= CFArrayGetCount(array))
1653  {
1654  return false;
1655  }
1656 
1657  const AUPreset *preset = (const AUPreset *) CFArrayGetValueAtIndex(array, id);
1658 
1659  result = AudioUnitSetProperty(mUnit,
1660  kAudioUnitProperty_PresentPreset,
1661  kAudioUnitScope_Global,
1662  0,
1663  preset,
1664  sizeof(AUPreset));
1665  if (result == noErr)
1666  {
1667  // Notify interested parties of change and propagate to slaves
1668  Notify(mUnit, kAUParameterListener_AnyParameter);
1669  }
1670 
1671  return result == noErr;
1672 }

References mUnit, and Notify().

Here is the call graph for this function:

◆ LoadPreset()

bool AudioUnitEffect::LoadPreset ( const RegistryPath group)
private

Definition at line 1958 of file AudioUnitEffect.cpp.

1959 {
1960  wxString parms;
1961 
1962  // Attempt to load old preset parameters and resave using new method
1963  if (mHost->GetPrivateConfig(group, wxT("Parameters"), parms, wxEmptyString))
1964  {
1965  CommandParameters eap;
1966  if (eap.SetParameters(parms))
1967  {
1968  if (SetAutomationParameters(eap))
1969  {
1970  if (SavePreset(group))
1971  {
1972  mHost->RemovePrivateConfig(group, wxT("Parameters"));
1973  }
1974  }
1975  }
1976  return true;
1977  }
1978 
1979  // Retrieve the preset
1980  if (!mHost->GetPrivateConfig(group, PRESET_KEY, parms, wxEmptyString))
1981  {
1982  // Commented "CurrentSettings" gets tried a lot and useless messages appear
1983  // in the log
1984  //wxLogError(wxT("Preset key \"%s\" not found in group \"%s\""), PRESET_KEY, group);
1985  return false;
1986  }
1987 
1988  // Decode it
1989  wxMemoryBuffer buf = wxBase64Decode(parms);
1990  size_t bufLen = buf.GetDataLen();
1991  if (!bufLen)
1992  {
1993  wxLogError(wxT("Failed to decode \"%s\" preset"), group);
1994  return false;
1995  }
1996  const uint8_t *bufPtr = (uint8_t *) buf.GetData();
1997 
1998  // Create a CFData object that references the decoded preset
2000  {
2001  CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
2002  bufPtr,
2003  bufLen,
2004  kCFAllocatorNull)
2005  };
2006  if (!data)
2007  {
2008  wxLogError(wxT("Failed to convert \"%s\" preset to internal format"), group);
2009  return false;
2010  }
2011 
2012  // Convert it back to a property list.
2013  CFPropertyListRef content
2014  {
2015  CFPropertyListCreateWithData(kCFAllocatorDefault,
2016  data.get(),
2017  kCFPropertyListImmutable,
2018  NULL,
2019  NULL)
2020  };
2021  if (!content)
2022  {
2023  wxLogError(wxT("Failed to create property list for \"%s\" preset"), group);
2024  return false;
2025  }
2026  CFunique_ptr<char /* CFPropertyList */> ucontent { (char *) content };
2027 
2028  // See AUView::viewWillDraw
2029  if (mpControl)
2030  {
2032  }
2033 
2034  // Finally, update the properties and parameters
2035  OSStatus result;
2036  result = AudioUnitSetProperty(mUnit,
2037  kAudioUnitProperty_ClassInfo,
2038  kAudioUnitScope_Global,
2039  0,
2040  &content,
2041  sizeof(content));
2042  if (result != noErr)
2043  {
2044  wxLogError(wxT("Failed to set class info for \"%s\" preset"), group);
2045  return false;
2046  }
2047 
2048  // Notify interested parties of change and propagate to slaves
2049  Notify(mUnit, kAUParameterListener_AnyParameter);
2050 
2051  return true;
2052 }

References AUControl::ForceRedraw(), ConfigClientInterface::GetPrivateConfig(), mHost, mpControl, mUnit, Notify(), PRESET_KEY, ConfigClientInterface::RemovePrivateConfig(), SavePreset(), SetAutomationParameters(), and CommandParameters::SetParameters().

Referenced by LoadFactoryDefaults(), LoadUserPreset(), and SetHost().

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

◆ LoadUserPreset()

bool AudioUnitEffect::LoadUserPreset ( const RegistryPath name)
overridevirtual

Implements EffectClientInterface.

Definition at line 1623 of file AudioUnitEffect.cpp.

1624 {
1625  return LoadPreset(name);
1626 }

References LoadPreset(), and name.

Here is the call graph for this function:

◆ Notify()

void AudioUnitEffect::Notify ( AudioUnit  unit,
AudioUnitParameterID  parm 
)
private

Definition at line 2435 of file AudioUnitEffect.cpp.

2436 {
2437  // Notify any interested parties
2438  AudioUnitParameter aup = {};
2439  aup.mAudioUnit = unit;
2440  aup.mParameterID = parm;
2441  aup.mScope = kAudioUnitScope_Global;
2442  aup.mElement = 0;
2443  AUParameterListenerNotify(NULL, NULL, &aup);
2444 }

Referenced by CopyParameters(), Import(), LoadFactoryPreset(), LoadPreset(), and SetAutomationParameters().

Here is the caller graph for this function:

◆ PopulateUI()

bool AudioUnitEffect::PopulateUI ( ShuttleGui S)
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1715 of file AudioUnitEffect.cpp.

1716 {
1717  // OSStatus result;
1718 
1719  auto parent = S.GetParent();
1720  mDialog = static_cast<wxDialog *>(wxGetTopLevelParent(parent));
1721  mParent = parent;
1722  mpControl = NULL;
1723 
1724  wxPanel *container;
1725  {
1726  auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1727 
1728  wxASSERT(mParent); // To justify safenew
1729  container = safenew wxPanelWrapper(mParent, wxID_ANY);
1730  mainSizer->Add(container, 1, wxEXPAND);
1731 
1732  mParent->SetSizer(mainSizer.release());
1733  }
1734 
1735 #if defined(HAVE_AUDIOUNIT_BASIC_SUPPORT)
1736  if (mUIType == wxT("Basic"))
1737  {
1738  if (!CreatePlain(mParent))
1739  {
1740  return false;
1741  }
1742  }
1743  else
1744 #endif
1745  {
1746  auto pControl = Destroy_ptr<AUControl>(safenew AUControl);
1747  if (!pControl)
1748  {
1749  return false;
1750  }
1751 
1752  if (!pControl->Create(container, mComponent, mUnit, mUIType == wxT("Full")))
1753  {
1754  return false;
1755  }
1756 
1757  {
1758  auto innerSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1759 
1760  innerSizer->Add((mpControl = pControl.release()), 1, wxEXPAND);
1761  container->SetSizer(innerSizer.release());
1762  }
1763 
1764  mParent->SetMinSize(wxDefaultSize);
1765 
1766 #ifdef __WXMAC__
1767 #ifdef __WX_EVTLOOP_BUSY_WAITING__
1768  wxEventLoop::SetBusyWaiting(true);
1769 #endif
1770 #endif
1771  }
1772 
1773  if (mpControl)
1774  {
1775  mParent->PushEventHandler(this);
1776  }
1777 
1778  return true;
1779 }

References ShuttleGuiBase::GetParent(), mComponent, mDialog, mParent, mpControl, mUIType, mUnit, and safenew.

Here is the call graph for this function:

◆ ProcessBlock()

size_t AudioUnitEffect::ProcessBlock ( float **  inBlock,
float **  outBlock,
size_t  blockLen 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 1304 of file AudioUnitEffect.cpp.

1305 {
1306  for (size_t i = 0; i < mAudioIns; i++)
1307  {
1308  mInputList[0].mBuffers[i].mNumberChannels = 1;
1309  mInputList[0].mBuffers[i].mData = inBlock[i];
1310  mInputList[0].mBuffers[i].mDataByteSize = sizeof(float) * blockLen;
1311  }
1312 
1313  for (size_t i = 0; i < mAudioOuts; i++)
1314  {
1315  mOutputList[0].mBuffers[i].mNumberChannels = 1;
1316  mOutputList[0].mBuffers[i].mData = outBlock[i];
1317  mOutputList[0].mBuffers[i].mDataByteSize = sizeof(float) * blockLen;
1318  }
1319 
1320  AudioUnitRenderActionFlags flags = 0;
1321  OSStatus result;
1322 
1323  result = AudioUnitRender(mUnit,
1324  &flags,
1325  &mTimeStamp,
1326  0,
1327  blockLen,
1328  mOutputList.get());
1329  if (result != noErr)
1330  {
1331  wxPrintf("Render failed: %d %4.4s\n", (int)result, (char *)&result);
1332  return 0;
1333  }
1334 
1335  mTimeStamp.mSampleTime += blockLen;
1336 
1337  return blockLen;
1338 }

References mAudioIns, mAudioOuts, mInputList, mOutputList, mTimeStamp, and mUnit.

Referenced by RealtimeProcessEnd().

Here is the caller graph for this function:

◆ ProcessFinalize()

bool AudioUnitEffect::ProcessFinalize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1294 of file AudioUnitEffect.cpp.

1295 {
1296  mReady = false;
1297 
1298  mOutputList.reset();
1299  mInputList.reset();
1300 
1301  return true;
1302 }

References mInputList, mOutputList, and mReady.

Referenced by RealtimeFinalize().

Here is the caller graph for this function:

◆ ProcessInitialize()

bool AudioUnitEffect::ProcessInitialize ( sampleCount  totalLen,
ChannelNames  chanMap = NULL 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 1241 of file AudioUnitEffect.cpp.

1242 {
1243  OSStatus result;
1244 
1246  mInputList[0].mNumberBuffers = mAudioIns;
1247 
1249  mOutputList[0].mNumberBuffers = mAudioOuts;
1250 
1251  memset(&mTimeStamp, 0, sizeof(AudioTimeStamp));
1252  mTimeStamp.mSampleTime = 0; // This is a double-precision number that should
1253  // accumulate the number of frames processed so far
1254  mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
1255 
1256  if (!SetRateAndChannels())
1257  {
1258  return false;
1259  }
1260 
1261  AURenderCallbackStruct callbackStruct;
1262  callbackStruct.inputProc = RenderCallback;
1263  callbackStruct.inputProcRefCon = this;
1264  result = AudioUnitSetProperty(mUnit,
1265  kAudioUnitProperty_SetRenderCallback,
1266  kAudioUnitScope_Input,
1267  0,
1268  &callbackStruct,
1269  sizeof(AURenderCallbackStruct));
1270  if (result != noErr)
1271  {
1272  wxPrintf("Setting input render callback failed.\n");
1273  return false;
1274  }
1275 
1276  result = AudioUnitReset(mUnit, kAudioUnitScope_Global, 0);
1277  if (result != noErr)
1278  {
1279  return false;
1280  }
1281 
1282  if (!BypassEffect(false))
1283  {
1284  return false;
1285  }
1286 
1287  mLatencyDone = false;
1288 
1289  mReady = true;
1290 
1291  return true;
1292 }

References BypassEffect(), mAudioIns, mAudioOuts, mInputList, mLatencyDone, mOutputList, mReady, mTimeStamp, mUnit, ArrayOf< X >::reinit(), RenderCallback(), and SetRateAndChannels().

Referenced by RealtimeInitialize().

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

◆ RealtimeAddProcessor()

bool AudioUnitEffect::RealtimeAddProcessor ( unsigned  numChannels,
float  sampleRate 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 1347 of file AudioUnitEffect.cpp.

1348 {
1349  auto slave = std::make_unique<AudioUnitEffect>(mPath, mName, mComponent, this);
1350  if (!slave->SetHost(NULL))
1351  {
1352  return false;
1353  }
1354 
1355  slave->SetBlockSize(mBlockSize);
1356  slave->SetChannelCount(numChannels);
1357  slave->SetSampleRate(sampleRate);
1358 
1359  if (!CopyParameters(mUnit, slave->mUnit))
1360  {
1361  return false;
1362  }
1363 
1364  auto pSlave = slave.get();
1365  mSlaves.push_back(std::move(slave));
1366 
1367  return pSlave->ProcessInitialize(0);
1368 }

References CopyParameters(), mBlockSize, mComponent, mName, mPath, mSlaves, and mUnit.

Here is the call graph for this function:

◆ RealtimeFinalize()

bool AudioUnitEffect::RealtimeFinalize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1370 of file AudioUnitEffect.cpp.

1371 {
1372  for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
1373  {
1374  mSlaves[i]->ProcessFinalize();
1375  }
1376  mSlaves.clear();
1377 
1378  mMasterIn.reset();
1379  mMasterOut.reset();
1380 
1381  return ProcessFinalize();
1382 }

References mMasterIn, mMasterOut, mSlaves, and ProcessFinalize().

Here is the call graph for this function:

◆ RealtimeInitialize()

bool AudioUnitEffect::RealtimeInitialize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1340 of file AudioUnitEffect.cpp.

1341 {
1344  return ProcessInitialize(0);
1345 }

References mAudioIns, mAudioOuts, mBlockSize, mMasterIn, mMasterOut, ProcessInitialize(), and ArraysOf< X >::reinit().

Here is the call graph for this function:

◆ RealtimeProcess()

size_t AudioUnitEffect::RealtimeProcess ( int  group,
float **  inbuf,
float **  outbuf,
size_t  numSamples 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 1432 of file AudioUnitEffect.cpp.

1436 {
1437  wxASSERT(numSamples <= mBlockSize);
1438 
1439  for (size_t c = 0; c < mAudioIns; c++)
1440  {
1441  for (decltype(numSamples) s = 0; s < numSamples; s++)
1442  {
1443  mMasterIn[c][s] += inbuf[c][s];
1444  }
1445  }
1446  mNumSamples = wxMax(numSamples, mNumSamples);
1447 
1448  return mSlaves[group]->ProcessBlock(inbuf, outbuf, numSamples);
1449 }

References mAudioIns, mBlockSize, mMasterIn, mNumSamples, and mSlaves.

◆ RealtimeProcessEnd()

bool AudioUnitEffect::RealtimeProcessEnd ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1451 of file AudioUnitEffect.cpp.

1452 {
1453  ProcessBlock(reinterpret_cast<float**>(mMasterIn.get()),
1454  reinterpret_cast<float**>(mMasterOut.get()),
1455  mNumSamples);
1456 
1457  return true;
1458 }

References mMasterIn, mMasterOut, mNumSamples, and ProcessBlock().

Here is the call graph for this function:

◆ RealtimeProcessStart()

bool AudioUnitEffect::RealtimeProcessStart ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1420 of file AudioUnitEffect.cpp.

1421 {
1422  for (size_t i = 0; i < mAudioIns; i++)
1423  {
1424  memset(mMasterIn[i].get(), 0, mBlockSize * sizeof(float));
1425  }
1426 
1427  mNumSamples = 0;
1428 
1429  return true;
1430 }

References mAudioIns, mBlockSize, mMasterIn, and mNumSamples.

◆ RealtimeResume()

bool AudioUnitEffect::RealtimeResume ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1402 of file AudioUnitEffect.cpp.

1403 {
1404  if (!BypassEffect(false))
1405  {
1406  return false;
1407  }
1408 
1409  for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
1410  {
1411  if (!mSlaves[i]->BypassEffect(false))
1412  {
1413  return false;
1414  }
1415  }
1416 
1417  return true;
1418 }

References BypassEffect(), and mSlaves.

Here is the call graph for this function:

◆ RealtimeSuspend()

bool AudioUnitEffect::RealtimeSuspend ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 1384 of file AudioUnitEffect.cpp.

1385 {
1386  if (!BypassEffect(true))
1387  {
1388  return false;
1389  }
1390 
1391  for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
1392  {
1393  if (!mSlaves[i]->BypassEffect(true))
1394  {
1395  return false;
1396  }
1397  }
1398 
1399  return true;
1400 }

References BypassEffect(), and mSlaves.

Here is the call graph for this function:

◆ Render()

OSStatus AudioUnitEffect::Render ( AudioUnitRenderActionFlags *  inActionFlags,
const AudioTimeStamp *  inTimeStamp,
UInt32  inBusNumber,
UInt32  inNumFrames,
AudioBufferList *  ioData 
)
private

Definition at line 2446 of file AudioUnitEffect.cpp.

2451 {
2452  for (int i = 0; i < ioData->mNumberBuffers; i++)
2453  ioData->mBuffers[i].mData = mInputList[0].mBuffers[i].mData;
2454 
2455  return 0;
2456 }

References mInputList.

◆ RenderCallback()

OSStatus AudioUnitEffect::RenderCallback ( void *  inRefCon,
AudioUnitRenderActionFlags *  inActionFlags,
const AudioTimeStamp *  inTimeStamp,
UInt32  inBusNumber,
UInt32  inNumFrames,
AudioBufferList *  ioData 
)
staticprivate

Definition at line 2459 of file AudioUnitEffect.cpp.

2465 {
2466  return ((AudioUnitEffect *) inRefCon)->Render(inActionFlags,
2467  inTimeStamp,
2468  inBusNumber,
2469  inNumFrames,
2470  ioData);
2471 }

Referenced by ProcessInitialize().

Here is the caller graph for this function:

◆ SavePreset()

bool AudioUnitEffect::SavePreset ( const RegistryPath group)
private

Definition at line 2054 of file AudioUnitEffect.cpp.

2055 {
2056  // First set the name of the preset
2057  wxCFStringRef cfname(wxFileNameFromPath(group));
2058 
2059  // Define the preset property
2060  AUPreset preset;
2061  preset.presetNumber = -1; // indicates user preset
2062  preset.presetName = cfname;
2063 
2064  // And set it in the audio unit
2065  AudioUnitSetProperty(mUnit,
2066  kAudioUnitProperty_PresentPreset,
2067  kAudioUnitScope_Global,
2068  0,
2069  &preset,
2070  sizeof(preset));
2071 
2072  // Now retrieve the preset content
2073  CFPropertyListRef content;
2074  UInt32 size = sizeof(content);
2075  AudioUnitGetProperty(mUnit,
2076  kAudioUnitProperty_ClassInfo,
2077  kAudioUnitScope_Global,
2078  0,
2079  &content,
2080  &size);
2081  CFunique_ptr<char /* CFPropertyList */> ucontent { (char *) content };
2082 
2083  // And convert it to serialized binary data
2085  {
2086  CFPropertyListCreateData(kCFAllocatorDefault,
2087  content,
2088  PRESET_FORMAT,
2089  0,
2090  NULL)
2091  };
2092  if (!data)
2093  {
2094  return false;
2095  }
2096 
2097  // Nothing to do if we don't have any data
2098  SInt32 length = CFDataGetLength(data.get());
2099  if (length)
2100  {
2101  // Base64 encode the returned binary property list
2102  wxString parms = wxBase64Encode(CFDataGetBytePtr(data.get()), length);
2103 
2104  // And write it to the config
2105  if (!mHost->SetPrivateConfig(group, PRESET_KEY, parms))
2106  {
2107  return false;
2108  }
2109  }
2110 
2111  return true;
2112 }

References mHost, mUnit, PRESET_FORMAT, PRESET_KEY, and ConfigClientInterface::SetPrivateConfig().

Referenced by LoadPreset(), SaveUserPreset(), and SetHost().

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

◆ SaveUserPreset()

bool AudioUnitEffect::SaveUserPreset ( const RegistryPath name)
overridevirtual

Implements EffectClientInterface.

Definition at line 1628 of file AudioUnitEffect.cpp.

1629 {
1630  return SavePreset(name);
1631 }

References name, and SavePreset().

Here is the call graph for this function:

◆ SetAutomationParameters()

bool AudioUnitEffect::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 1562 of file AudioUnitEffect.cpp.

1563 {
1564  OSStatus result;
1565  UInt32 dataSize;
1566  Boolean isWritable;
1567 
1568  result = AudioUnitGetPropertyInfo(mUnit,
1569  kAudioUnitProperty_ParameterList,
1570  kAudioUnitScope_Global,
1571  0,
1572  &dataSize,
1573  &isWritable);
1574  if (result != noErr)
1575  {
1576  return false;
1577  }
1578 
1579  UInt32 cnt = dataSize / sizeof(AudioUnitParameterID);
1580  ArrayOf<AudioUnitParameterID> array {cnt};
1581 
1582  result = AudioUnitGetProperty(mUnit,
1583  kAudioUnitProperty_ParameterList,
1584  kAudioUnitScope_Global,
1585  0,
1586  array.get(),
1587  &dataSize);
1588  if (result != noErr)
1589  {
1590  return false;
1591  }
1592 
1593  for (int i = 0; i < cnt; i++)
1594  {
1595  ParameterInfo pi;
1596 
1597  if (!pi.Get(mUnit, array[i]))
1598  {
1599  // Probably failed because of invalid parameter which can happen
1600  // if a plug-in is in a certain mode that doesn't contain the
1601  // parameter. In any case, just ignore it.
1602  continue;
1603  }
1604 
1605  double d = 0.0;
1606  if (parms.Read(pi.name, &d))
1607  {
1608  AudioUnitParameterValue value = d;
1609  AudioUnitSetParameter(mUnit,
1610  array[i],
1611  kAudioUnitScope_Global,
1612  0,
1613  value,
1614  0);
1615 
1616  Notify(mUnit, array[i]);
1617  }
1618  }
1619 
1620  return true;
1621 }

References ParameterInfo::Get(), mUnit, ParameterInfo::name, and Notify().

Referenced by LoadPreset().

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

◆ SetBlockSize()

size_t AudioUnitEffect::SetBlockSize ( size_t  maxBlockSize)
overridevirtual

Implements EffectClientInterface.

Definition at line 1189 of file AudioUnitEffect.cpp.

1190 {
1191  return mBlockSize;
1192 }

References mBlockSize.

◆ SetChannelCount()

void AudioUnitEffect::SetChannelCount ( unsigned  numChannels)
private

Definition at line 2289 of file AudioUnitEffect.cpp.

2290 {
2291  mNumChannels = numChannels;
2292 }

References mNumChannels.

◆ SetHost()

bool AudioUnitEffect::SetHost ( EffectHostInterface host)
overridevirtual

Implements EffectClientInterface.

Definition at line 1009 of file AudioUnitEffect.cpp.

1010 {
1011  OSStatus result;
1012 
1013  mHost = host;
1014 
1015  mSampleRate = 44100;
1016  result = AudioComponentInstanceNew(mComponent, &mUnit);
1017  if (!mUnit)
1018  {
1019  return false;
1020  }
1021 
1022  GetChannelCounts();
1023 
1025 
1026  // Retrieve the desired number of frames per slice
1027  UInt32 dataSize = sizeof(mBlockSize);
1028  mBlockSize = 512;
1029  AudioUnitGetProperty(mUnit,
1030  kAudioUnitProperty_MaximumFramesPerSlice,
1031  kAudioUnitScope_Global,
1032  0,
1033  &mBlockSize,
1034  &dataSize);
1035 
1036  // mHost will be null during registration
1037  if (mHost)
1038  {
1039  mHost->GetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency, true);
1040  mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), mUIType, wxT("Full"));
1041 
1042  bool haveDefaults;
1043  mHost->GetPrivateConfig(mHost->GetFactoryDefaultsGroup(), wxT("Initialized"), haveDefaults, false);
1044  if (!haveDefaults)
1045  {
1047  mHost->SetPrivateConfig(mHost->GetFactoryDefaultsGroup(), wxT("Initialized"), true);
1048  }
1049 
1051  }
1052 
1053  if (!mMaster)
1054  {
1055  result = AUEventListenerCreate(AudioUnitEffect::EventListenerCallback,
1056  this,
1057  (CFRunLoopRef)GetCFRunLoopFromEventLoop(GetCurrentEventLoop()),
1058  kCFRunLoopDefaultMode,
1059  0.0,
1060  0.0,
1062  if (result != noErr)
1063  {
1064  return false;
1065  }
1066 
1067  AudioUnitEvent event;
1068 
1069  event.mEventType = kAudioUnitEvent_ParameterValueChange;
1070  event.mArgument.mParameter.mAudioUnit = mUnit;
1071  event.mArgument.mParameter.mScope = kAudioUnitScope_Global;
1072  event.mArgument.mParameter.mElement = 0;
1073 
1074  UInt32 dataSize;
1075  Boolean isWritable;
1076 
1077  // Retrieve the list of parameters
1078  result = AudioUnitGetPropertyInfo(mUnit,
1079  kAudioUnitProperty_ParameterList,
1080  kAudioUnitScope_Global,
1081  0,
1082  &dataSize,
1083  &isWritable);
1084  if (result != noErr)
1085  {
1086  return false;
1087  }
1088 
1089  // And get them
1090  UInt32 cnt = dataSize / sizeof(AudioUnitParameterID);
1091  if (cnt != 0)
1092  {
1093  ArrayOf<AudioUnitParameterID> array {cnt};
1094 
1095  result = AudioUnitGetProperty(mUnit,
1096  kAudioUnitProperty_ParameterList,
1097  kAudioUnitScope_Global,
1098  0,
1099  array.get(),
1100  &dataSize);
1101  if (result != noErr)
1102  {
1103  return false;
1104  }
1105 
1106  // Register them as something we're interested in
1107  for (int i = 0; i < cnt; i++)
1108  {
1109  event.mArgument.mParameter.mParameterID = array[i];
1110  result = AUEventListenerAddEventType(mEventListenerRef,
1111  this,
1112  &event);
1113  if (result != noErr)
1114  {
1115  return false;
1116  }
1117  }
1118  }
1119 
1120  event.mEventType = kAudioUnitEvent_PropertyChange;
1121  event.mArgument.mProperty.mAudioUnit = mUnit;
1122  event.mArgument.mProperty.mPropertyID = kAudioUnitProperty_Latency;
1123  event.mArgument.mProperty.mScope = kAudioUnitScope_Global;
1124  event.mArgument.mProperty.mElement = 0;
1125 
1126  result = AUEventListenerAddEventType(mEventListenerRef,
1127  this,
1128  &event);
1129  if (result != noErr)
1130  {
1131  return false;
1132  }
1133 
1134  AudioUnitCocoaViewInfo cocoaViewInfo;
1135  dataSize = sizeof(AudioUnitCocoaViewInfo);
1136 
1137  // Check for a Cocoa UI
1138  result = AudioUnitGetProperty(mUnit,
1139  kAudioUnitProperty_CocoaUI,
1140  kAudioUnitScope_Global,
1141  0,
1142  &cocoaViewInfo,
1143  &dataSize);
1144 
1145  bool hasCocoa = result == noErr;
1146 
1147  // Check for a Carbon UI
1148  AudioComponentDescription compDesc;
1149  dataSize = sizeof(compDesc);
1150  result = AudioUnitGetProperty(mUnit,
1151  kAudioUnitProperty_GetUIComponentList,
1152  kAudioUnitScope_Global,
1153  0,
1154  &compDesc,
1155  &dataSize);
1156  bool hasCarbon = result == noErr;
1157 
1158  mInteractive = (cnt > 0) || hasCocoa || hasCarbon;
1159  }
1160 
1161  return true;
1162 }

References EventListenerCallback(), GetChannelCounts(), EffectHostInterface::GetCurrentSettingsGroup(), EffectHostInterface::GetFactoryDefaultsGroup(), ConfigClientInterface::GetPrivateConfig(), ConfigClientInterface::GetSharedConfig(), LoadPreset(), mBlockSize, mComponent, mEventListenerRef, mHost, mInteractive, mMaster, mSampleRate, mUIType, mUnit, mUseLatency, SavePreset(), ConfigClientInterface::SetPrivateConfig(), and SetRateAndChannels().

Referenced by AudioUnitEffectsModule::DiscoverPluginsAtPath().

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

◆ SetHostUI()

void AudioUnitEffect::SetHostUI ( EffectUIHostInterface host)
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1710 of file AudioUnitEffect.cpp.

1711 {
1712  mUIHost = host;
1713 }

References mUIHost.

◆ SetRateAndChannels()

bool AudioUnitEffect::SetRateAndChannels ( )
private

Definition at line 2114 of file AudioUnitEffect.cpp.

2115 {
2116  OSStatus result;
2117 
2118  if (mUnitInitialized)
2119  {
2120  AudioUnitUninitialize(mUnit);
2121 
2122  mUnitInitialized = false;
2123  }
2124 
2125  AudioStreamBasicDescription streamFormat {
2126  // Float64 mSampleRate;
2127  mSampleRate,
2128 
2129  // UInt32 mFormatID;
2130  kAudioFormatLinearPCM,
2131 
2132  // UInt32 mFormatFlags;
2133  (kAudioFormatFlagsNativeFloatPacked |
2134  kAudioFormatFlagIsNonInterleaved),
2135 
2136  // UInt32 mBytesPerPacket;
2137  sizeof(float),
2138 
2139  // UInt32 mFramesPerPacket;
2140  1,
2141 
2142  // UInt32 mBytesPerFrame;
2143  sizeof(float),
2144 
2145  // UInt32 mChannelsPerFrame;
2146  mAudioIns,
2147 
2148  // UInt32 mBitsPerChannel;
2149  sizeof(float) * 8,
2150 
2151  // UInt32 mReserved;
2152  0
2153  };
2154 
2155  result = AudioUnitSetProperty(mUnit,
2156  kAudioUnitProperty_SampleRate,
2157  kAudioUnitScope_Global,
2158  0,
2159  &mSampleRate,
2160  sizeof(Float64));
2161  if (result != noErr)
2162  {
2163  wxPrintf("%ls Didn't accept sample rate on global\n",
2164  // Exposing internal name only in debug printf
2165  GetSymbol().Internal().wx_str());
2166  return false;
2167  }
2168 
2169  if (mAudioIns > 0)
2170  {
2171  result = AudioUnitSetProperty(mUnit,
2172  kAudioUnitProperty_SampleRate,
2173  kAudioUnitScope_Input,
2174  0,
2175  &mSampleRate,
2176  sizeof(Float64));
2177  if (result != noErr)
2178  {
2179  wxPrintf("%ls Didn't accept sample rate on input\n",
2180  // Exposing internal name only in debug printf
2181  GetSymbol().Internal().wx_str());
2182  return false;
2183  }
2184 
2185  result = AudioUnitSetProperty(mUnit,
2186  kAudioUnitProperty_StreamFormat,
2187  kAudioUnitScope_Input,
2188  0,
2189  &streamFormat,
2190  sizeof(AudioStreamBasicDescription));
2191  if (result != noErr)
2192  {
2193  wxPrintf("%ls didn't accept stream format on input\n",
2194  // Exposing internal name only in debug printf
2195  GetSymbol().Internal().wx_str());
2196  return false;
2197  }
2198  }
2199 
2200  if (mAudioOuts > 0)
2201  {
2202  result = AudioUnitSetProperty(mUnit,
2203  kAudioUnitProperty_SampleRate,
2204  kAudioUnitScope_Output,
2205  0,
2206  &mSampleRate,
2207  sizeof(Float64));
2208  if (result != noErr)
2209  {
2210  wxPrintf("%ls Didn't accept sample rate on output\n",
2211  // Exposing internal name only in debug printf
2212  GetSymbol().Internal().wx_str());
2213  return false;
2214  }
2215 
2216  streamFormat.mChannelsPerFrame = mAudioOuts;
2217  result = AudioUnitSetProperty(mUnit,
2218  kAudioUnitProperty_StreamFormat,
2219  kAudioUnitScope_Output,
2220  0,
2221  &streamFormat,
2222  sizeof(AudioStreamBasicDescription));
2223 
2224  if (result != noErr)
2225  {
2226  wxPrintf("%ls didn't accept stream format on output\n",
2227  // Exposing internal name only in debug printf
2228  GetSymbol().Internal().wx_str());
2229  return false;
2230  }
2231  }
2232 
2233  result = AudioUnitInitialize(mUnit);
2234  if (result != noErr)
2235  {
2236  wxPrintf("Couldn't initialize audio unit\n");
2237  return false;
2238  }
2239 
2240  mUnitInitialized = true;
2241 
2242  return true;
2243 }

References GetSymbol(), Internal, mAudioIns, mAudioOuts, mSampleRate, mUnit, and mUnitInitialized.

Referenced by ProcessInitialize(), and SetHost().

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

◆ SetSampleRate()

void AudioUnitEffect::SetSampleRate ( double  rate)
overridevirtual

Implements EffectClientInterface.

Definition at line 1184 of file AudioUnitEffect.cpp.

1185 {
1186  mSampleRate = rate;
1187 }

References mSampleRate.

◆ ShowInterface()

bool AudioUnitEffect::ShowInterface ( wxWindow &  parent,
const EffectDialogFactory factory,
bool  forceModal = false 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 1460 of file AudioUnitEffect.cpp.

1463 {
1464  if (mDialog)
1465  {
1466  if (mDialog->Close(true))
1467  {
1468  mDialog = nullptr;
1469  }
1470  return false;
1471  }
1472 
1473  // mDialog is null
1474  auto cleanup = valueRestorer(mDialog);
1475 
1476  if (factory)
1477  {
1478  mDialog = factory(parent, mHost, this);
1479  }
1480 
1481  if (!mDialog)
1482  {
1483  return false;
1484  }
1485 
1486  if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal)
1487  {
1488  mDialog->Show();
1489  cleanup.release();
1490 
1491  return false;
1492  }
1493 
1494  bool res = mDialog->ShowModal() != 0;
1495 
1496  return res;
1497 }

References EffectTypeAnalyze, factory, GetType(), mDialog, mHost, SupportsRealtime(), and valueRestorer().

Here is the call graph for this function:

◆ ShowOptions()

void AudioUnitEffect::ShowOptions ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1943 of file AudioUnitEffect.cpp.

1944 {
1946  if (dlg.ShowModal())
1947  {
1948  // Reinitialize configuration settings
1949  mHost->GetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency, true);
1950  mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), mUIType, wxT("Full"));
1951  }
1952 }

References ConfigClientInterface::GetSharedConfig(), mHost, mParent, mUIType, and mUseLatency.

Here is the call graph for this function:

◆ SupportsAutomation()

bool AudioUnitEffect::SupportsAutomation ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 957 of file AudioUnitEffect.cpp.

958 {
959  OSStatus result;
960  UInt32 dataSize;
961  Boolean isWritable;
962 
963  result = AudioUnitGetPropertyInfo(mUnit,
964  kAudioUnitProperty_ParameterList,
965  kAudioUnitScope_Global,
966  0,
967  &dataSize,
968  &isWritable);
969  if (result != noErr)
970  {
971  return false;
972  }
973 
974  UInt32 cnt = dataSize / sizeof(AudioUnitParameterID);
976 
977  result = AudioUnitGetProperty(mUnit,
978  kAudioUnitProperty_ParameterList,
979  kAudioUnitScope_Global,
980  0,
981  array.get(),
982  &dataSize);
983  if (result != noErr)
984  {
985  return false;
986  }
987 
988  for (int i = 0; i < cnt; i++)
989  {
990  ParameterInfo pi;
991 
992  if (pi.Get(mUnit, array[i]))
993  {
994  if (pi.info.flags & kAudioUnitParameterFlag_IsWritable)
995  {
996  // All we need is one
997  return true;
998  }
999  }
1000  }
1001 
1002  return false;
1003 }

References ParameterInfo::Get(), ParameterInfo::info, and mUnit.

Here is the call graph for this function:

◆ SupportsRealtime()

bool AudioUnitEffect::SupportsRealtime ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 952 of file AudioUnitEffect.cpp.

953 {
954  return GetType() == EffectTypeProcess;
955 }

References EffectTypeProcess, and GetType().

Referenced by ShowInterface().

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

◆ ValidateUI()

bool AudioUnitEffect::ValidateUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 1786 of file AudioUnitEffect.cpp.

1787 {
1788 #if 0
1789  if (!mParent->Validate())
1790  {
1791  return false;
1792  }
1793 
1794  if (GetType() == EffectTypeGenerate)
1795  {
1796  mHost->SetDuration(mDuration->GetValue());
1797  }
1798 #endif
1799  return true;
1800 }

References EffectTypeGenerate, GetType(), mHost, mParent, and EffectHostInterface::SetDuration().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ AudioUnitEffectExportDialog

friend class AudioUnitEffectExportDialog
friend

Definition at line 222 of file AudioUnitEffect.h.

◆ AudioUnitEffectImportDialog

friend class AudioUnitEffectImportDialog
friend

Definition at line 223 of file AudioUnitEffect.h.

Member Data Documentation

◆ mAudioIns

unsigned AudioUnitEffect::mAudioIns
private

◆ mAudioOuts

unsigned AudioUnitEffect::mAudioOuts
private

◆ mBlockSize

UInt32 AudioUnitEffect::mBlockSize
private

◆ mBufferSize

int AudioUnitEffect::mBufferSize
private

Definition at line 197 of file AudioUnitEffect.h.

◆ mComponent

AudioComponent AudioUnitEffect::mComponent
private

◆ mDialog

wxDialog* AudioUnitEffect::mDialog
private

Definition at line 208 of file AudioUnitEffect.h.

Referenced by AudioUnitEffect(), CloseUI(), PopulateUI(), and ShowInterface().

◆ mEventListenerRef

AUEventListenerRef AudioUnitEffect::mEventListenerRef
private

Definition at line 218 of file AudioUnitEffect.h.

Referenced by AudioUnitEffect(), SetHost(), and ~AudioUnitEffect().

◆ mHost

EffectHostInterface* AudioUnitEffect::mHost
private

◆ mInputList

ArrayOf<AudioBufferList> AudioUnitEffect::mInputList
private

Definition at line 203 of file AudioUnitEffect.h.

Referenced by ProcessBlock(), ProcessFinalize(), ProcessInitialize(), and Render().

◆ mInteractive

bool AudioUnitEffect::mInteractive
private

Definition at line 192 of file AudioUnitEffect.h.

Referenced by AudioUnitEffect(), IsInteractive(), and SetHost().

◆ mIsGraphical

bool AudioUnitEffect::mIsGraphical
private

Definition at line 210 of file AudioUnitEffect.h.

Referenced by AudioUnitEffect().

◆ mLatencyDone

bool AudioUnitEffect::mLatencyDone
private

Definition at line 193 of file AudioUnitEffect.h.

Referenced by GetLatency(), and ProcessInitialize().

◆ mMaster

AudioUnitEffect* AudioUnitEffect::mMaster
private

Definition at line 212 of file AudioUnitEffect.h.

Referenced by AudioUnitEffect(), EventListener(), and SetHost().

◆ mMasterIn

ArraysOf<float> AudioUnitEffect::mMasterIn
private

◆ mMasterOut

ArraysOf<float> AudioUnitEffect::mMasterOut
private

Definition at line 215 of file AudioUnitEffect.h.

Referenced by RealtimeFinalize(), RealtimeInitialize(), and RealtimeProcessEnd().

◆ mName

wxString AudioUnitEffect::mName
private

◆ mNumChannels

unsigned AudioUnitEffect::mNumChannels
private

Definition at line 214 of file AudioUnitEffect.h.

Referenced by GetChannelCount(), and SetChannelCount().

◆ mNumSamples

size_t AudioUnitEffect::mNumSamples
private

Definition at line 216 of file AudioUnitEffect.h.

Referenced by RealtimeProcess(), RealtimeProcessEnd(), and RealtimeProcessStart().

◆ mOutputList

ArrayOf<AudioBufferList> AudioUnitEffect::mOutputList
private

Definition at line 204 of file AudioUnitEffect.h.

Referenced by ProcessBlock(), ProcessFinalize(), and ProcessInitialize().

◆ mParent

wxWindow* AudioUnitEffect::mParent
private

◆ mPath

PluginPath AudioUnitEffect::mPath
private

Definition at line 179 of file AudioUnitEffect.h.

Referenced by AudioUnitEffect(), GetPath(), and RealtimeAddProcessor().

◆ mpControl

AUControl* AudioUnitEffect::mpControl {}
private

Definition at line 220 of file AudioUnitEffect.h.

Referenced by AudioUnitEffect(), CloseUI(), LoadPreset(), and PopulateUI().

◆ mReady

bool AudioUnitEffect::mReady
private

Definition at line 201 of file AudioUnitEffect.h.

Referenced by AudioUnitEffect(), IsReady(), ProcessFinalize(), and ProcessInitialize().

◆ mSampleRate

double AudioUnitEffect::mSampleRate
private

◆ mSlaves

AudioUnitEffectArray AudioUnitEffect::mSlaves
private

◆ mSupportsMono

bool AudioUnitEffect::mSupportsMono
private

Definition at line 186 of file AudioUnitEffect.h.

◆ mSupportsStereo

bool AudioUnitEffect::mSupportsStereo
private

Definition at line 187 of file AudioUnitEffect.h.

◆ mTimeStamp

AudioTimeStamp AudioUnitEffect::mTimeStamp
private

Definition at line 200 of file AudioUnitEffect.h.

Referenced by ProcessBlock(), and ProcessInitialize().

◆ mUIHost

EffectUIHostInterface* AudioUnitEffect::mUIHost
private

Definition at line 206 of file AudioUnitEffect.h.

Referenced by AudioUnitEffect(), CloseUI(), and SetHostUI().

◆ mUIType

wxString AudioUnitEffect::mUIType
private

Definition at line 209 of file AudioUnitEffect.h.

Referenced by IsGraphicalUI(), PopulateUI(), SetHost(), and ShowOptions().

◆ mUnit

AudioUnit AudioUnitEffect::mUnit
private

◆ mUnitInitialized

bool AudioUnitEffect::mUnitInitialized
private

Definition at line 184 of file AudioUnitEffect.h.

Referenced by AudioUnitEffect(), SetRateAndChannels(), and ~AudioUnitEffect().

◆ mUseLatency

bool AudioUnitEffect::mUseLatency
private

Definition at line 198 of file AudioUnitEffect.h.

Referenced by GetLatency(), SetHost(), and ShowOptions().

◆ mVendor

wxString AudioUnitEffect::mVendor
private

The documentation for this class was generated from the following files:
AudioUnitEffect::GetChannelCounts
void GetChannelCounts()
Definition: AudioUnitEffect.cpp:2522
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
AudioUnitEffect::mPath
PluginPath mPath
Definition: AudioUnitEffect.h:179
CommandParameters::SetParameters
bool SetParameters(const wxString &parms)
Definition: EffectAutomationParameters.h:286
valueRestorer
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:354
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
AudioUnitEffect::mDialog
wxDialog * mDialog
Definition: AudioUnitEffect.h:208
ParameterInfo::name
wxString name
Definition: AudioUnitEffect.cpp:221
AudioUnitEffect::EventListenerCallback
static void EventListenerCallback(void *inCallbackRefCon, void *inObject, const AudioUnitEvent *inEvent, UInt64 inEventHostTime, AudioUnitParameterValue inParameterValue)
Definition: AudioUnitEffect.cpp:2512
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
fn
static const auto fn
Definition: WaveformView.cpp:1113
AudioUnitEffect::mIsGraphical
bool mIsGraphical
Definition: AudioUnitEffect.h:210
AudioUnitEffect::mInteractive
bool mInteractive
Definition: AudioUnitEffect.h:192
wxPanelWrapper
Definition: wxPanelWrapper.h:41
EffectTypeGenerate
@ EffectTypeGenerate
Definition: EffectInterface.h:58
SelectFile
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
Definition: SelectFile.cpp:17
AudioUnitEffect::SavePreset
bool SavePreset(const RegistryPath &group)
Definition: AudioUnitEffect.cpp:2054
RegistryPaths
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
AudioUnitEffect::SetRateAndChannels
bool SetRateAndChannels()
Definition: AudioUnitEffect.cpp:2114
AudioUnitEffect::mpControl
AUControl * mpControl
Definition: AudioUnitEffect.h:220
Format
Abstract base class used in importing a file.
ArrayOf::reinit
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
EffectTypeNone
@ EffectTypeNone
Definition: EffectInterface.h:56
AudioUnitEffect::mParent
wxWindow * mParent
Definition: AudioUnitEffect.h:207
AUControl::Close
void Close()
XO
#define XO(s)
Definition: Internat.h:31
EffectHostInterface::GetCurrentSettingsGroup
virtual RegistryPath GetCurrentSettingsGroup()=0
AudioUnitEffect::mOutputList
ArrayOf< AudioBufferList > mOutputList
Definition: AudioUnitEffect.h:204
AudioUnitEffect::mUIHost
EffectUIHostInterface * mUIHost
Definition: AudioUnitEffect.h:206
AudioUnitEffect::RenderCallback
static OSStatus RenderCallback(void *inRefCon, AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
Definition: AudioUnitEffect.cpp:2459
AudioUnitEffect::mAudioOuts
unsigned mAudioOuts
Definition: AudioUnitEffect.h:191
AudioUnitEffect::mUseLatency
bool mUseLatency
Definition: AudioUnitEffect.h:198
AudioUnitEffect::Import
TranslatableString Import(const wxString &path)
Definition: AudioUnitEffect.cpp:2371
AudioUnitEffect::mMasterOut
ArraysOf< float > mMasterOut
Definition: AudioUnitEffect.h:215
ArraysOf::reinit
void reinit(Integral count)
Definition: MemoryX.h:109
AudioUnitEffect::mSlaves
AudioUnitEffectArray mSlaves
Definition: AudioUnitEffect.h:213
AUDIOUNITEFFECTS_FAMILY
#define AUDIOUNITEFFECTS_FAMILY
Definition: AudioUnitEffect.h:32
FilePath
wxString FilePath
Definition: Project.h:20
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:806
AudioUnitEffect::mHost
EffectHostInterface * mHost
Definition: AudioUnitEffect.h:189
AudioUnitEffect::LoadPreset
bool LoadPreset(const RegistryPath &group)
Definition: AudioUnitEffect.cpp:1958
PRESET_USER_PATH
#define PRESET_USER_PATH
Definition: AudioUnitEffect.cpp:71
PRESET_KEY
#define PRESET_KEY
Definition: AudioUnitEffect.cpp:67
AudioUnitEffect::CopyParameters
bool CopyParameters(AudioUnit srcUnit, AudioUnit dstUnit)
Definition: AudioUnitEffect.cpp:2245
name
const TranslatableString name
Definition: Distortion.cpp:98
ShuttleGuiBase::GetParent
wxWindow * GetParent()
Definition: ShuttleGui.h:496
AudioUnitEffect::SupportsRealtime
bool SupportsRealtime() override
Definition: AudioUnitEffect.cpp:952
ParameterInfo
Definition: AudioUnitEffect.cpp:107
CFunique_ptr
std::unique_ptr< T, CFReleaser > CFunique_ptr
Definition: AudioUnitEffect.cpp:99
ParameterInfo::info
AudioUnitParameterInfo info
Definition: AudioUnitEffect.cpp:222
AudioUnitEffect::SetAutomationParameters
bool SetAutomationParameters(CommandParameters &parms) override
Definition: AudioUnitEffect.cpp:1562
AudioUnitEffect::mBlockSize
UInt32 mBlockSize
Definition: AudioUnitEffect.h:194
ConfigClientInterface::GetSharedConfig
virtual bool GetSharedConfig(const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval)=0
AUControl::ForceRedraw
void ForceRedraw()
AudioUnitEffect::mReady
bool mReady
Definition: AudioUnitEffect.h:201
AudioUnitEffect::mAudioIns
unsigned mAudioIns
Definition: AudioUnitEffect.h:190
AudioUnitEffect::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: AudioUnitEffect.cpp:880
AudioUnitEffect::mSampleRate
double mSampleRate
Definition: AudioUnitEffect.h:195
AudioUnitEffect::Notify
void Notify(AudioUnit unit, AudioUnitParameterID parm)
Definition: AudioUnitEffect.cpp:2435
AudioUnitEffectOptionsDialog
Definition: AudioUnitEffect.cpp:499
AudioUnitEffect::mUnitInitialized
bool mUnitInitialized
Definition: AudioUnitEffect.h:184
ParameterInfo::Get
bool Get(AudioUnit mUnit, AudioUnitParameterID parmID)
Definition: AudioUnitEffect.cpp:125
ConfigClientInterface::RemovePrivateConfig
virtual bool RemovePrivateConfig(const RegistryPath &group, const RegistryPath &key)=0
AudioUnitEffect
An Effect class that handles a wide range of effects. ??Mac only??
Definition: AudioUnitEffect.h:43
AUControl
a wxControl with Cocoa/Carbon support
Definition: AUControl.h:40
ConfigClientInterface::SetPrivateConfig
virtual bool SetPrivateConfig(const RegistryPath &group, const RegistryPath &key, const wxString &value)=0
AudioUnitEffect::mUnit
AudioUnit mUnit
Definition: AudioUnitEffect.h:183
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
AudioUnitEffect::mUIType
wxString mUIType
Definition: AudioUnitEffect.h:209
EffectTypeAnalyze
@ EffectTypeAnalyze
Definition: EffectInterface.h:60
AudioUnitEffect::mComponent
AudioComponent mComponent
Definition: AudioUnitEffect.h:182
AudioUnitEffect::ProcessInitialize
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: AudioUnitEffect.cpp:1241
AudioUnitEffect::mMaster
AudioUnitEffect * mMaster
Definition: AudioUnitEffect.h:212
PRESET_FORMAT
#define PRESET_FORMAT
Definition: AudioUnitEffect.cpp:64
AudioUnitEffect::ProcessFinalize
bool ProcessFinalize() override
Definition: AudioUnitEffect.cpp:1294
AudioUnitEffect::mInputList
ArrayOf< AudioBufferList > mInputList
Definition: AudioUnitEffect.h:203
ExceptionType::Internal
@ Internal
Indicates internal failure from Audacity.
AudioUnitEffect::mMasterIn
ArraysOf< float > mMasterIn
Definition: AudioUnitEffect.h:215
AudioUnitEffect::mLatencyDone
bool mLatencyDone
Definition: AudioUnitEffect.h:193
AudioUnitEffect::ProcessBlock
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: AudioUnitEffect.cpp:1304
AudioUnitEffect::mVendor
wxString mVendor
Definition: AudioUnitEffect.h:181
AudioUnitEffect::mNumChannels
unsigned mNumChannels
Definition: AudioUnitEffect.h:214
AudioUnitEffect::BypassEffect
bool BypassEffect(bool bypass)
Definition: AudioUnitEffect.cpp:2682
ComponentInterface::GetName
TranslatableString GetName()
Definition: PluginManager.cpp:2083
AudioUnitEffect::mNumSamples
size_t mNumSamples
Definition: AudioUnitEffect.h:216
ConfigClientInterface::GetPrivateConfig
virtual bool GetPrivateConfig(const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval)=0
AudioUnitEffect::mTimeStamp
AudioTimeStamp mTimeStamp
Definition: AudioUnitEffect.h:200
Destroy_ptr
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:290
safenew
#define safenew
Definition: MemoryX.h:10
AudioUnitEffect::GetType
EffectType GetType() override
Definition: AudioUnitEffect.cpp:912
ArrayOf
Memory.h template class for making an array of float, bool, etc.
Definition: MemoryX.h:27
AudioUnitEffect::Export
TranslatableString Export(const wxString &path)
Definition: AudioUnitEffect.cpp:2294
EffectHostInterface::SetDuration
virtual void SetDuration(double seconds)=0
EffectHostInterface::GetFactoryDefaultsGroup
virtual RegistryPath GetFactoryDefaultsGroup()=0
AudioUnitEffect::mName
wxString mName
Definition: AudioUnitEffect.h:180
AudioUnitEffect::mEventListenerRef
AUEventListenerRef mEventListenerRef
Definition: AudioUnitEffect.h:218