Audacity  3.0.3
AudioUnitEffect.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  AudioUnitEffect.cpp
6 
7  Dominic Mazzoni
8  Leland Lucius
9 
10 *******************************************************************//*******************************************************************/
16 
17 
18 
19 #if USE_AUDIO_UNITS
20 #include "AudioUnitEffect.h"
21 
22 #include <wx/defs.h>
23 #include <wx/base64.h>
24 #include <wx/button.h>
25 #include <wx/control.h>
26 #include <wx/crt.h>
27 #include <wx/dir.h>
28 #include <wx/ffile.h>
29 
30 #ifdef __WXMAC__
31 #include <wx/evtloop.h>
32 #endif
33 
34 #include <wx/filename.h>
35 #include <wx/frame.h>
36 #include <wx/listctrl.h>
37 #include <wx/log.h>
38 #include <wx/sizer.h>
39 #include <wx/settings.h>
40 #include <wx/stattext.h>
41 #include <wx/textctrl.h>
42 #include <wx/tokenzr.h>
43 
44 #include "../../ShuttleGui.h"
45 #include "../../widgets/AudacityMessageBox.h"
46 #include "../../widgets/valnum.h"
47 #include "../../widgets/wxPanelWrapper.h"
48 
49 //
50 // When a plug-ins state is saved to the settings file (as a preset),
51 // it can be one of two formats, binary or XML. In either case, it
52 // gets base64 encoded before storing.
53 //
54 // The advantages of XML format is less chance of failures occurring
55 // when exporting. But, it can take a bit more space per preset int
56 // the Audacity settings file.
57 //
58 // Using binary for now. Use kCFPropertyListXMLFormat_v1_0 if XML
59 // format is desired.
60 //
61 #define PRESET_FORMAT kCFPropertyListBinaryFormat_v1_0
62 
63 // Name of the settings key to use for the above value
64 #define PRESET_KEY wxT("Data")
65 
66 // Where the presets are located
67 #define PRESET_LOCAL_PATH wxT("/Library/Audio/Presets")
68 #define PRESET_USER_PATH wxT("~/Library/Audio/Presets")
69 
70 static const struct
71 {
73  OSType componentType;
75 }
76 BlackList[] =
77 {
78  { 'appl', 'augn', 'afpl' }, // Apple: AUAudioFilePlayer
79  { 'appl', 'augn', 'sspl' }, // Apple: AUScheduledSoundPlayer
80  { 'appl', 'augn', 'ttsp' }, // Apple: AUSpeechSynthesis
81  { 'appl', 'augn', 'nrcv' }, // Apple: AUNetReceive
82  { 'appl', 'aumx', '3dmx' }, // Apple: AUMixer3D
83  { 'appl', 'aumx', 'mspl' }, // Apple: AUMultiSplitter
84  { 'appl', 'aumx', 'mxcm' }, // Apple: AUMultiChannelMixer
85  { 'appl', 'aumx', 'mxmx' }, // Apple: AUMatrixMixer
86  { 'appl', 'aumx', 'smxr' }, // Apple: AUMixer
87 };
88 
89 struct CFReleaser
90 {
91  void operator () (const void *p) const
92  {
93  if (p) CFRelease(p);
94  }
95 };
96 template <typename T> using CFunique_ptr = std::unique_ptr<T, CFReleaser>;
97 
98 // Uncomment to include parameter IDs in the final name. Only needed if it's
99 // discovered that many effects have duplicate names. It could even be done
100 // at runtime by scanning an effects parameters to determine if dups are present
101 // and, if so, enable the clump and parameter IDs.
102 #define USE_EXTENDED_NAMES
104 {
105 public:
107  {
108  info = {};
109  }
110 
111  virtual ~ParameterInfo()
112  {
113  if (info.flags & kAudioUnitParameterFlag_HasCFNameString)
114  {
115  if (info.flags & kAudioUnitParameterFlag_CFNameRelease)
116  {
117  CFRelease(info.cfNameString);
118  }
119  }
120  }
121 
122  bool Get(AudioUnit mUnit, AudioUnitParameterID parmID)
123  {
124  OSStatus result;
125  UInt32 dataSize;
126 
127  info = {};
128  dataSize = sizeof(info);
129  result = AudioUnitGetProperty(mUnit,
130  kAudioUnitProperty_ParameterInfo,
131  kAudioUnitScope_Global,
132  parmID,
133  &info,
134  &dataSize);
135  if (result != noErr)
136  {
137  return false;
138  }
139 
140  if (info.flags & kAudioUnitParameterFlag_HasCFNameString)
141  {
142  name = wxCFStringRef::AsString(info.cfNameString);
143  }
144  else
145  {
146  name = wxString(info.name);
147  }
148 
149 #if defined(USE_EXTENDED_NAMES)
150  // If the parameter has a non-empty name, then the final parameter name will
151  // be either:
152  //
153  // <parmID,ParameterName>
154  //
155  // or (if the name isn't available):
156  //
157  // <parmID>
158  if (!name.empty())
159  {
160  name.Replace(idBeg, wxT('_'));
161  name.Replace(idSep, wxT('_'));
162  name.Replace(idEnd, wxT('_'));
163  name.Append(idSep);
164  }
165  name = wxString::Format(wxT("%c%s%x%c"),
166  idBeg,
167  name,
168  parmID,
169  idEnd);
170 
171  // If the parameter has a clumpID, then the final parameter name will be
172  // either:
173  //
174  // <clumpID,clumpName><parmID,ParameterName>
175  //
176  // or (if the clumpName isn't available):
177  //
178  // <clumpID><parmID,ParameterName>
179  if (info.flags & kAudioUnitParameterFlag_HasClump)
180  {
181  wxString clumpName;
182 
183  AudioUnitParameterNameInfo clumpInfo = {};
184  clumpInfo.inID = info.clumpID;
185  clumpInfo.inDesiredLength = kAudioUnitParameterName_Full;
186  dataSize = sizeof(clumpInfo);
187 
188  result = AudioUnitGetProperty(mUnit,
189  kAudioUnitProperty_ParameterClumpName,
190  kAudioUnitScope_Global,
191  0,
192  &clumpInfo,
193  &dataSize);
194  if (result == noErr)
195  {
196  clumpName = wxCFStringRef::AsString(clumpInfo.outName);
197  clumpName.Replace(idBeg, wxT('_'));
198  clumpName.Replace(idSep, wxT('_'));
199  clumpName.Replace(idEnd, wxT('_'));
200  clumpName.Append(idSep);
201  }
202  name = wxString::Format(wxT("%c%s%x%c%s"),
203  idBeg,
204  clumpName,
205  info.clumpID,
206  idEnd,
207  name);
208  }
209 #endif
210 
211  return true;
212  }
213 
214  static const char idBeg = wxT('<');
215  static const char idSep = wxT(',');
216  static const char idEnd = wxT('>');
217 
218  wxString name;
219  AudioUnitParameterInfo info;
220 };
221 
222 // ============================================================================
223 // Module registration entry point
224 //
225 // This is the symbol that Audacity looks for when the module is built as a
226 // dynamic library.
227 //
228 // When the module is builtin to Audacity, we use the same function, but it is
229 // declared static so as not to clash with other builtin modules.
230 // ============================================================================
231 DECLARE_MODULE_ENTRY(AudacityModule)
232 {
233  // Create and register the importer
234  // Trust the module manager not to leak this
235  return safenew AudioUnitEffectsModule(path);
236 }
237 
238 // ============================================================================
239 // Register this as a builtin module
240 // ============================================================================
241 DECLARE_BUILTIN_MODULE(AudioUnitEffectsBuiltin);
242 
244 //
245 // AudioUnitEffectsModule
246 //
248 
250 {
251  if (path)
252  {
253  mPath = *path;
254  }
255 }
256 
258 {
259  mPath.clear();
260 }
261 
262 // ============================================================================
263 // ComponentInterface implementation
264 // ============================================================================
265 
267 {
268  return mPath;
269 }
270 
272 {
273  /* i18n-hint: Audio Unit is the name of an Apple audio software protocol */
274  return XO("Audio Unit Effects");
275 }
276 
278 {
279  return XO("The Audacity Team");
280 }
281 
283 {
284  // This "may" be different if this were to be maintained as a separate DLL
286 }
287 
289 {
290  return XO("Provides Audio Unit Effects support to Audacity");
291 }
292 
293 // ============================================================================
294 // ModuleInterface implementation
295 // ============================================================================
296 
298 {
299  static FileExtensions result{{ _T("au") }};
300  return result;
301 }
302 
304 {
305  // Nothing to do here
306  return true;
307 }
308 
310 {
311  // Nothing to do here
312  return;
313 }
314 
316 {
317 #if USE_AUDIO_UNITS
319 #else
320  return {};
321 #endif
322 }
323 
325 {
326  // Nothing to be done here
327  return true;
328 }
329 
331 {
332  PluginPaths effects;
333 
334  LoadAudioUnitsOfType(kAudioUnitType_Effect, effects);
335  LoadAudioUnitsOfType(kAudioUnitType_Generator, effects);
336  LoadAudioUnitsOfType(kAudioUnitType_Mixer, effects);
337  LoadAudioUnitsOfType(kAudioUnitType_MusicEffect, effects);
338  LoadAudioUnitsOfType(kAudioUnitType_Panner, effects);
339 
340  return effects;
341 }
342 
344  const PluginPath & path, TranslatableString &errMsg,
345  const RegistrationCallback &callback)
346 {
347  errMsg = {};
348  wxString name;
349  AudioComponent component = FindAudioUnit(path, name);
350  if (component == NULL)
351  {
352  errMsg = XO("Could not find component");
353  return 0;
354  }
355 
356  AudioUnitEffect effect(path, name, component);
357  if (!effect.SetHost(NULL))
358  {
359  // TODO: Is it worth it to discriminate all the ways SetHost might
360  // return false?
361  errMsg = XO("Could not initialize component");
362  return 0;
363  }
364 
365  if (callback)
366  {
367  callback(this, &effect);
368  }
369 
370  return 1;
371 }
372 
373 bool AudioUnitEffectsModule::IsPluginValid(const PluginPath & path, bool bFast)
374 {
375  if (bFast)
376  {
377  return true;
378  }
379 
380  wxString name;
381  return FindAudioUnit(path, name) != NULL;
382 }
383 
385 {
386  // Acquires a resource for the application.
387  wxString name;
388  AudioComponent component = FindAudioUnit(path, name);
389  if (component == NULL)
390  {
391  return NULL;
392  }
393 
394  // Safety of this depends on complementary calls to DeleteInstance on the module manager side.
395  return safenew AudioUnitEffect(path, name, component);
396 }
397 
399 {
400  std::unique_ptr < AudioUnitEffect > {
401  dynamic_cast<AudioUnitEffect *>(instance)
402  };
403 }
404 
405 // ============================================================================
406 // AudioUnitEffectsModule implementation
407 // ============================================================================
408 
410  PluginPaths & effects)
411 {
412  AudioComponentDescription desc;
413  AudioComponent component;
414 
415  desc.componentType = inAUType;
416  desc.componentSubType = 0;
417  desc.componentManufacturer = 0;
418  desc.componentFlags = 0;
419  desc.componentFlagsMask = 0;
420 
421  component = AudioComponentFindNext(NULL, &desc);
422  while (component != NULL)
423  {
424  OSStatus result;
425  AudioComponentDescription found;
426 
427  result = AudioComponentGetDescription(component, &found);
428  if (result == noErr)
429  {
430  CFStringRef cfName{};
431  result = AudioComponentCopyName(component, &cfName);
432  CFunique_ptr<const __CFString> uName{ cfName };
433 
434  if (result == noErr)
435  {
436  wxString path;
437 
438  path.Printf(wxT("%-4.4s/%-4.4s/%-4.4s/%s"),
439  FromOSType(found.componentManufacturer),
440  FromOSType(found.componentType),
441  FromOSType(found.componentSubType),
442  wxCFStringRef::AsString(cfName));
443 
444  for (int i = 0; i < WXSIZEOF(BlackList); ++i)
445  {
446  if (BlackList[i].componentType == found.componentType &&
447  BlackList[i].componentSubType == found.componentSubType &&
448  BlackList[i].componentManufacturer == found.componentManufacturer)
449  {
450  wxLogDebug(wxT("Blacklisted AU skipped: %s"), path);
451  result = !noErr;
452  break;
453  }
454  }
455 
456  if (result == noErr)
457  {
458  effects.push_back(path);
459  }
460  }
461  }
462 
463  component = AudioComponentFindNext(component, &desc);
464  }
465 }
466 
468  wxString & name)
469 {
470  wxStringTokenizer tokens(path, wxT("/"));
471 
472  AudioComponentDescription desc;
473 
474  desc.componentManufacturer = ToOSType(tokens.GetNextToken());
475  desc.componentType = ToOSType(tokens.GetNextToken());
476  desc.componentSubType = ToOSType(tokens.GetNextToken());
477  desc.componentFlags = 0;
478  desc.componentFlagsMask = 0;
479 
480  name = tokens.GetNextToken();
481  return AudioComponentFindNext(NULL, &desc);
482 }
483 
485 {
486  OSType rev = (type & 0xff000000) >> 24 |
487  (type & 0x00ff0000) >> 8 |
488  (type & 0x0000ff00) << 8 |
489  (type & 0x000000ff) << 24;
490 
491  return wxString::FromUTF8((char *)&rev, 4);
492 }
493 
494 OSType AudioUnitEffectsModule::ToOSType(const wxString & type)
495 {
496  wxCharBuffer buf = type.ToUTF8();
497 
498  OSType rev = ((unsigned char)buf.data()[0]) << 24 |
499  ((unsigned char)buf.data()[1]) << 16 |
500  ((unsigned char)buf.data()[2]) << 8 |
501  ((unsigned char)buf.data()[3]);
502 
503  return rev;
504 }
505 
507 //
508 // AudioUnitEffectOptionsDialog
509 //
511 
513 {
514 public:
515  AudioUnitEffectOptionsDialog(wxWindow * parent, EffectHostInterface *host);
517 
518  void PopulateOrExchange(ShuttleGui & S);
519 
520  void OnOk(wxCommandEvent & evt);
521 
522 private:
524 
527 
528  DECLARE_EVENT_TABLE()
529 };
530 
534 
536 : wxDialogWrapper(parent, wxID_ANY, XO("Audio Unit Effect Options"))
537 {
538  mHost = host;
539 
540  mHost->GetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency, true);
541 
542  // Expect one of three string values from the config file
543  wxString uiType;
544  mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), uiType, wxT("Full"));
545 
546  // Get the localization of the string for display to the user
547  mUIType = TranslatableString{ uiType, {} };
548 
549  ShuttleGui S(this, eIsCreating);
550  PopulateOrExchange(S);
551 }
552 
554 {
555 }
556 
558 {
559 
560  S.SetBorder(5);
561  S.StartHorizontalLay(wxEXPAND, 1);
562  {
563  S.StartVerticalLay(false);
564  {
565  S.StartStatic(XO("Latency Compensation"));
566  {
568 "As part of their processing, some Audio Unit effects must delay returning "
569 "audio to Audacity. When not compensating for this delay, you will "
570 "notice that small silences have been inserted into the audio. "
571 "Enabling this option will provide that compensation, but it may "
572 "not work for all Audio Unit effects."),
573  false, 0, 650);
574 
575  S.StartHorizontalLay(wxALIGN_LEFT);
576  {
577  S.TieCheckBox(XXO("Enable &compensation"),
578  mUseLatency);
579  }
580  S.EndHorizontalLay();
581  }
582  S.EndStatic();
583 
584  S.StartStatic(XO("User Interface"));
585  {
587 "Select \"Full\" to use the graphical interface if supplied by the Audio Unit."
588 " Select \"Generic\" to use the system supplied generic interface."
589 #if defined(HAVE_AUDIOUNIT_BASIC_SUPPORT)
590 " Select \"Basic\" for a basic text-only interface."
591 #endif
592 " Reopen the effect for this to take effect."),
593  false, 0, 650);
594 
595  S.StartHorizontalLay(wxALIGN_LEFT);
596  {
597  S.TieChoice(XXO("Select &interface"),
598  mUIType,
599  {
600  XO("Full"),
601  XO("Generic"),
602 #if defined(HAVE_AUDIOUNIT_BASIC_SUPPORT)
603  XO("Basic")
604 #endif
605  });
606  }
607  S.EndHorizontalLay();
608  }
609  S.EndStatic();
610  }
611  S.EndVerticalLay();
612  }
613  S.EndHorizontalLay();
614 
615  S.AddStandardButtons();
616 
617  Layout();
618  Fit();
619  Center();
620 }
621 
622 void AudioUnitEffectOptionsDialog::OnOk(wxCommandEvent & WXUNUSED(evt))
623 {
624  if (!Validate())
625  {
626  return;
627  }
628 
631 
632  // un-translate the type
633  auto uiType = mUIType.MSGID().GET();
634 
635  mHost->SetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency);
636  mHost->SetSharedConfig(wxT("Options"), wxT("UIType"), uiType);
637 
638  EndModal(wxID_OK);
639 }
640 
642 //
643 // AudioUnitEffectImportDialog
644 //
646 
648 {
649 public:
650  AudioUnitEffectImportDialog(wxWindow * parent, AudioUnitEffect *effect);
652 
653  void PopulateOrExchange(ShuttleGui & S);
654  bool HasPresets();
655  TranslatableString Import(const wxString & path, const wxString & name);
656 
657  void OnOk(wxCommandEvent & evt);
658 
659 private:
660  wxWindow *mParent;
662 
663  wxListCtrl *mList;
664 
665  DECLARE_EVENT_TABLE()
666 };
667 
671 
673 : wxDialogWrapper(parent, wxID_ANY, XO("Import Audio Unit Presets"))
674 {
675  mEffect = effect;
676 
677  ShuttleGui S(this, eIsCreating);
678  PopulateOrExchange(S);
679 }
680 
682 {
683 }
684 
686 {
687  S.SetBorder(5);
688  S.StartHorizontalLay(wxEXPAND, 1);
689  {
690  S.StartVerticalLay(true);
691  {
692  S.StartStatic(XO("Presets (may select multiple)"));
693  {
694  mList = S.Style(wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
695  wxLC_NO_SORT_HEADER)
696  .AddListControlReportMode({ XO("Preset"), XO("Location") });
697  }
698  S.EndStatic();
699  }
700  S.EndVerticalLay();
701  }
702  S.EndHorizontalLay();
703 
704  S.AddStandardButtons();
705 
706  FilePaths presets;
707  wxFileName fn;
708 
709  // Generate the local domain path
710  wxString path;
711  path.Printf(wxT("%s/%s/%s"),
713  mEffect->mVendor,
714  mEffect->mName);
715  fn = path;
716  fn.Normalize();
717 
718  // Get all presets in the local domain for this effect
719  wxDir::GetAllFiles(fn.GetFullPath(), &presets, wxT("*.aupreset"));
720 
721  // Generate the user domain path
722  path.Printf(wxT("%s/%s/%s"),
724  mEffect->mVendor,
725  mEffect->mName);
726  fn = path;
727  fn.Normalize();
728 
729  // Get all presets in the user domain for this effect
730  wxDir::GetAllFiles(fn.GetFullPath(), &presets, wxT("*.aupreset"));
731 
732  presets.Sort();
733 
734  for (size_t i = 0, cnt = presets.size(); i < cnt; i++)
735  {
736  fn = presets[i];
737  mList->InsertItem(i, fn.GetName());
738  mList->SetItem(i, 1, fn.GetPath());
739  }
740 
741  mList->SetColumnWidth(0, wxLIST_AUTOSIZE);
742  mList->SetColumnWidth(1, wxLIST_AUTOSIZE);
743 
744  // Set the list size...with a little extra for good measure
745  wxSize sz = mList->GetBestSize();
746  sz.x += 5;
747  sz.y += 5;
748  mList->SetMinSize(sz);
749 
750  Layout();
751  Fit();
752  Center();
753 }
754 
756 {
757  return mList->GetItemCount() > 0;
758 }
759 
761  const wxString & path, const wxString & name)
762 {
763  // Generate the path
764  wxString fullPath;
765  fullPath.Printf(wxT("%s/%s.aupreset"),
766  path,
767  name);
768 
769  // Open the preset
770  wxFFile f(fullPath, wxT("r"));
771  if (!f.IsOpened())
772  {
773  return XO("Couldn't open \"%s\"").Format(fullPath);
774  }
775 
776  // Load it into the buffer
777  size_t len = f.Length();
778  wxMemoryBuffer buf(len);
779  if (f.Read(buf.GetData(), len) != len || f.Error())
780  {
781  return XO("Unable to read the preset from \"%s\"").Format(fullPath);
782  }
783 
784  wxString parms = wxBase64Encode(buf.GetData(), len);
785  if (parms.IsEmpty())
786  {
787  return XO("Failed to encode preset from \"%s\"").Format(fullPath);
788  }
789 
790  // And write it to the config
791  wxString group = mEffect->mHost->GetUserPresetsGroup(name);
792  if (!mEffect->mHost->SetPrivateConfig(group, PRESET_KEY, parms))
793  {
794  return XO("Unable to store preset in config file");
795  }
796 
797  return {};
798 }
799 
800 void AudioUnitEffectImportDialog::OnOk(wxCommandEvent & evt)
801 {
802  evt.Skip();
803 
804  // Import all selected presets
805  long sel = -1;
806  while ((sel = mList->GetNextItem(sel, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) >= 0)
807  {
808  wxListItem item;
809  item.SetId(sel);
810  item.SetColumn(1);
811  item.SetMask(wxLIST_MASK_TEXT);
812  mList->GetItem(item);
813 
814  wxString path = item.GetText();
815  wxString name = mList->GetItemText(sel);
816  auto msg = Import(path, name);
817 
818  if (!msg.empty())
819  {
821  XO("Could not import \"%s\" preset\n\n%s").Format(name, msg),
822  XO("Import Audio Unit Presets"),
823  wxOK | wxCENTRE,
824  this);
825  return;
826  }
827  }
828 
829  EndModal(wxID_OK);
830 }
831 
833 //
834 // AudioUnitEffect
835 //
837 
839  const wxString & name,
840  AudioComponent component,
841  AudioUnitEffect *master)
842 {
843  mPath = path;
844  mName = name.AfterFirst(wxT(':')).Trim(true).Trim(false);
845  mVendor = name.BeforeFirst(wxT(':')).Trim(true).Trim(false);
846  mComponent = component;
847  mMaster = master;
848 
849  mpControl = NULL;
850  mUnit = NULL;
851 
852  mBlockSize = 0.0;
853  mInteractive = false;
854  mIsGraphical = false;
855 
856  mUIHost = NULL;
857  mDialog = NULL;
858  mParent = NULL;
859 
860  mUnitInitialized = false;
861 
862  mEventListenerRef = NULL;
863 
864  mReady = false;
865 }
866 
868 {
869  if (mUnitInitialized)
870  {
871  AudioUnitUninitialize(mUnit);
872  }
873 
874  if (mEventListenerRef)
875  {
876  AUListenerDispose(mEventListenerRef);
877  }
878 
879  if (mUnit)
880  {
881  AudioComponentInstanceDispose(mUnit);
882  }
883 }
884 
885 // ============================================================================
886 // ComponentInterface implementation
887 // ============================================================================
888 
890 {
891  return mPath;
892 }
893 
895 {
896  return mName;
897 }
898 
900 {
901  return { mVendor };
902 }
903 
905 {
906  UInt32 version;
907 
908  OSStatus result = AudioComponentGetVersion(mComponent, &version);
909 
910  return wxString::Format(wxT("%d.%d.%d"),
911  (version >> 16) & 0xffff,
912  (version >> 8) & 0xff,
913  version & 0xff);
914 }
915 
917 {
918  /* i18n-hint: Can mean "not available," "not applicable," "no answer" */
919  return XO("n/a");
920 }
921 
922 // ============================================================================
923 // EffectComponentInterface implementation
924 // ============================================================================
925 
927 {
928  if (mAudioIns == 0 && mAudioOuts == 0)
929  {
930  return EffectTypeNone;
931  }
932 
933  if (mAudioIns == 0)
934  {
935  return EffectTypeGenerate;
936  }
937 
938  if (mAudioOuts == 0)
939  {
940  return EffectTypeAnalyze;
941  }
942 
943  return EffectTypeProcess;
944 }
945 
947 {
949 }
950 
952 {
953  return mInteractive;
954 }
955 
957 {
958  return false;
959 }
960 
962 {
963  return false;
964 }
965 
967 {
968  return GetType() == EffectTypeProcess;
969 }
970 
972 {
973  OSStatus result;
974  UInt32 dataSize;
975  Boolean isWritable;
976 
977  result = AudioUnitGetPropertyInfo(mUnit,
978  kAudioUnitProperty_ParameterList,
979  kAudioUnitScope_Global,
980  0,
981  &dataSize,
982  &isWritable);
983  if (result != noErr)
984  {
985  return false;
986  }
987 
988  UInt32 cnt = dataSize / sizeof(AudioUnitParameterID);
990 
991  result = AudioUnitGetProperty(mUnit,
992  kAudioUnitProperty_ParameterList,
993  kAudioUnitScope_Global,
994  0,
995  array.get(),
996  &dataSize);
997  if (result != noErr)
998  {
999  return false;
1000  }
1001 
1002  for (int i = 0; i < cnt; i++)
1003  {
1004  ParameterInfo pi;
1005 
1006  if (pi.Get(mUnit, array[i]))
1007  {
1008  if (pi.info.flags & kAudioUnitParameterFlag_IsWritable)
1009  {
1010  // All we need is one
1011  return true;
1012  }
1013  }
1014  }
1015 
1016  return false;
1017 }
1018 
1019 // ============================================================================
1020 // EffectClientInterface Implementation
1021 // ============================================================================
1022 
1024 {
1025  OSStatus result;
1026 
1027  mHost = host;
1028 
1029  mSampleRate = 44100;
1030  result = AudioComponentInstanceNew(mComponent, &mUnit);
1031  if (!mUnit)
1032  {
1033  return false;
1034  }
1035 
1036  GetChannelCounts();
1037 
1039 
1040  // Retrieve the desired number of frames per slice
1041  UInt32 dataSize = sizeof(mBlockSize);
1042  mBlockSize = 512;
1043  AudioUnitGetProperty(mUnit,
1044  kAudioUnitProperty_MaximumFramesPerSlice,
1045  kAudioUnitScope_Global,
1046  0,
1047  &mBlockSize,
1048  &dataSize);
1049 
1050  // mHost will be null during registration
1051  if (mHost)
1052  {
1053  mHost->GetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency, true);
1054  mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), mUIType, wxT("Full"));
1055 
1056  bool haveDefaults;
1057  mHost->GetPrivateConfig(mHost->GetFactoryDefaultsGroup(), wxT("Initialized"), haveDefaults, false);
1058  if (!haveDefaults)
1059  {
1061  mHost->SetPrivateConfig(mHost->GetFactoryDefaultsGroup(), wxT("Initialized"), true);
1062  }
1063 
1065  }
1066 
1067  if (!mMaster)
1068  {
1069  result = AUEventListenerCreate(AudioUnitEffect::EventListenerCallback,
1070  this,
1071  (CFRunLoopRef)GetCFRunLoopFromEventLoop(GetCurrentEventLoop()),
1072  kCFRunLoopDefaultMode,
1073  0.0,
1074  0.0,
1076  if (result != noErr)
1077  {
1078  return false;
1079  }
1080 
1081  AudioUnitEvent event;
1082 
1083  event.mEventType = kAudioUnitEvent_ParameterValueChange;
1084  event.mArgument.mParameter.mAudioUnit = mUnit;
1085  event.mArgument.mParameter.mScope = kAudioUnitScope_Global;
1086  event.mArgument.mParameter.mElement = 0;
1087 
1088  UInt32 dataSize;
1089  Boolean isWritable;
1090 
1091  // Retrieve the list of parameters
1092  result = AudioUnitGetPropertyInfo(mUnit,
1093  kAudioUnitProperty_ParameterList,
1094  kAudioUnitScope_Global,
1095  0,
1096  &dataSize,
1097  &isWritable);
1098  if (result != noErr)
1099  {
1100  return false;
1101  }
1102 
1103  // And get them
1104  UInt32 cnt = dataSize / sizeof(AudioUnitParameterID);
1105  if (cnt != 0)
1106  {
1107  ArrayOf<AudioUnitParameterID> array {cnt};
1108 
1109  result = AudioUnitGetProperty(mUnit,
1110  kAudioUnitProperty_ParameterList,
1111  kAudioUnitScope_Global,
1112  0,
1113  array.get(),
1114  &dataSize);
1115  if (result != noErr)
1116  {
1117  return false;
1118  }
1119 
1120  // Register them as something we're interested in
1121  for (int i = 0; i < cnt; i++)
1122  {
1123  event.mArgument.mParameter.mParameterID = array[i];
1124  result = AUEventListenerAddEventType(mEventListenerRef,
1125  this,
1126  &event);
1127  if (result != noErr)
1128  {
1129  return false;
1130  }
1131  }
1132  }
1133 
1134  event.mEventType = kAudioUnitEvent_PropertyChange;
1135  event.mArgument.mProperty.mAudioUnit = mUnit;
1136  event.mArgument.mProperty.mPropertyID = kAudioUnitProperty_Latency;
1137  event.mArgument.mProperty.mScope = kAudioUnitScope_Global;
1138  event.mArgument.mProperty.mElement = 0;
1139 
1140  result = AUEventListenerAddEventType(mEventListenerRef,
1141  this,
1142  &event);
1143  if (result != noErr)
1144  {
1145  return false;
1146  }
1147 
1148  AudioUnitCocoaViewInfo cocoaViewInfo;
1149  dataSize = sizeof(AudioUnitCocoaViewInfo);
1150 
1151  // Check for a Cocoa UI
1152  result = AudioUnitGetProperty(mUnit,
1153  kAudioUnitProperty_CocoaUI,
1154  kAudioUnitScope_Global,
1155  0,
1156  &cocoaViewInfo,
1157  &dataSize);
1158 
1159  bool hasCocoa = result == noErr;
1160 
1161  // Check for a Carbon UI
1162  AudioComponentDescription compDesc;
1163  dataSize = sizeof(compDesc);
1164  result = AudioUnitGetProperty(mUnit,
1165  kAudioUnitProperty_GetUIComponentList,
1166  kAudioUnitScope_Global,
1167  0,
1168  &compDesc,
1169  &dataSize);
1170  bool hasCarbon = result == noErr;
1171 
1172  mInteractive = (cnt > 0) || hasCocoa || hasCarbon;
1173  }
1174 
1175  return true;
1176 }
1177 
1179 {
1180  return mAudioIns;
1181 }
1182 
1184 {
1185  return mAudioOuts;
1186 }
1187 
1189 {
1190  return 0;
1191 }
1192 
1194 {
1195  return 0;
1196 }
1197 
1199 {
1200  mSampleRate = rate;
1201 }
1202 
1203 size_t AudioUnitEffect::SetBlockSize(size_t maxBlockSize)
1204 {
1205  return mBlockSize;
1206 }
1207 
1209 {
1210  return mBlockSize;
1211 }
1212 
1214 {
1215  // Retrieve the latency (can be updated via an event)
1216  if (mUseLatency && !mLatencyDone)
1217  {
1218  mLatencyDone = true;
1219 
1220  Float64 latency = 0.0;
1221  UInt32 dataSize = sizeof(latency);
1222  AudioUnitGetProperty(mUnit,
1223  kAudioUnitProperty_Latency,
1224  kAudioUnitScope_Global,
1225  0,
1226  &latency,
1227  &dataSize);
1228 
1229  return sampleCount(latency * mSampleRate);
1230  }
1231 
1232  return 0;
1233 }
1234 
1236 {
1237  // Retrieve the tail time
1238  Float64 tailTime = 0.0;
1239  UInt32 dataSize = sizeof(tailTime);
1240  AudioUnitGetProperty(mUnit,
1241  kAudioUnitProperty_TailTime,
1242  kAudioUnitScope_Global,
1243  0,
1244  &tailTime,
1245  &dataSize);
1246 
1247  return tailTime * mSampleRate;
1248 }
1249 
1251 {
1252  return mReady;
1253 }
1254 
1255 bool AudioUnitEffect::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames WXUNUSED(chanMap))
1256 {
1257  OSStatus result;
1258 
1260  mInputList[0].mNumberBuffers = mAudioIns;
1261 
1263  mOutputList[0].mNumberBuffers = mAudioOuts;
1264 
1265  memset(&mTimeStamp, 0, sizeof(AudioTimeStamp));
1266  mTimeStamp.mSampleTime = 0; // This is a double-precision number that should
1267  // accumulate the number of frames processed so far
1268  mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
1269 
1270  if (!SetRateAndChannels())
1271  {
1272  return false;
1273  }
1274 
1275  AURenderCallbackStruct callbackStruct;
1276  callbackStruct.inputProc = RenderCallback;
1277  callbackStruct.inputProcRefCon = this;
1278  result = AudioUnitSetProperty(mUnit,
1279  kAudioUnitProperty_SetRenderCallback,
1280  kAudioUnitScope_Input,
1281  0,
1282  &callbackStruct,
1283  sizeof(AURenderCallbackStruct));
1284  if (result != noErr)
1285  {
1286  wxPrintf("Setting input render callback failed.\n");
1287  return false;
1288  }
1289 
1290  result = AudioUnitReset(mUnit, kAudioUnitScope_Global, 0);
1291  if (result != noErr)
1292  {
1293  return false;
1294  }
1295 
1296  if (!BypassEffect(false))
1297  {
1298  return false;
1299  }
1300 
1301  mLatencyDone = false;
1302 
1303  mReady = true;
1304 
1305  return true;
1306 }
1307 
1309 {
1310  mReady = false;
1311 
1312  mOutputList.reset();
1313  mInputList.reset();
1314 
1315  return true;
1316 }
1317 
1318 size_t AudioUnitEffect::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen)
1319 {
1320  for (size_t i = 0; i < mAudioIns; i++)
1321  {
1322  mInputList[0].mBuffers[i].mNumberChannels = 1;
1323  mInputList[0].mBuffers[i].mData = inBlock[i];
1324  mInputList[0].mBuffers[i].mDataByteSize = sizeof(float) * blockLen;
1325  }
1326 
1327  for (size_t i = 0; i < mAudioOuts; i++)
1328  {
1329  mOutputList[0].mBuffers[i].mNumberChannels = 1;
1330  mOutputList[0].mBuffers[i].mData = outBlock[i];
1331  mOutputList[0].mBuffers[i].mDataByteSize = sizeof(float) * blockLen;
1332  }
1333 
1334  AudioUnitRenderActionFlags flags = 0;
1335  OSStatus result;
1336 
1337  result = AudioUnitRender(mUnit,
1338  &flags,
1339  &mTimeStamp,
1340  0,
1341  blockLen,
1342  mOutputList.get());
1343  if (result != noErr)
1344  {
1345  wxPrintf("Render failed: %d %4.4s\n", (int)result, (char *)&result);
1346  return 0;
1347  }
1348 
1349  mTimeStamp.mSampleTime += blockLen;
1350 
1351  return blockLen;
1352 }
1353 
1355 {
1358  return ProcessInitialize(0);
1359 }
1360 
1361 bool AudioUnitEffect::RealtimeAddProcessor(unsigned numChannels, float sampleRate)
1362 {
1363  auto slave = std::make_unique<AudioUnitEffect>(mPath, mName, mComponent, this);
1364  if (!slave->SetHost(NULL))
1365  {
1366  return false;
1367  }
1368 
1369  slave->SetBlockSize(mBlockSize);
1370  slave->SetChannelCount(numChannels);
1371  slave->SetSampleRate(sampleRate);
1372 
1373  if (!CopyParameters(mUnit, slave->mUnit))
1374  {
1375  return false;
1376  }
1377 
1378  auto pSlave = slave.get();
1379  mSlaves.push_back(std::move(slave));
1380 
1381  return pSlave->ProcessInitialize(0);
1382 }
1383 
1385 {
1386  for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
1387  {
1388  mSlaves[i]->ProcessFinalize();
1389  }
1390  mSlaves.clear();
1391 
1392  mMasterIn.reset();
1393  mMasterOut.reset();
1394 
1395  return ProcessFinalize();
1396 }
1397 
1399 {
1400  if (!BypassEffect(true))
1401  {
1402  return false;
1403  }
1404 
1405  for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
1406  {
1407  if (!mSlaves[i]->BypassEffect(true))
1408  {
1409  return false;
1410  }
1411  }
1412 
1413  return true;
1414 }
1415 
1417 {
1418  if (!BypassEffect(false))
1419  {
1420  return false;
1421  }
1422 
1423  for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
1424  {
1425  if (!mSlaves[i]->BypassEffect(false))
1426  {
1427  return false;
1428  }
1429  }
1430 
1431  return true;
1432 }
1433 
1435 {
1436  for (size_t i = 0; i < mAudioIns; i++)
1437  {
1438  memset(mMasterIn[i].get(), 0, mBlockSize * sizeof(float));
1439  }
1440 
1441  mNumSamples = 0;
1442 
1443  return true;
1444 }
1445 
1447  float **inbuf,
1448  float **outbuf,
1449  size_t numSamples)
1450 {
1451  wxASSERT(numSamples <= mBlockSize);
1452 
1453  for (size_t c = 0; c < mAudioIns; c++)
1454  {
1455  for (decltype(numSamples) s = 0; s < numSamples; s++)
1456  {
1457  mMasterIn[c][s] += inbuf[c][s];
1458  }
1459  }
1460  mNumSamples = wxMax(numSamples, mNumSamples);
1461 
1462  return mSlaves[group]->ProcessBlock(inbuf, outbuf, numSamples);
1463 }
1464 
1466 {
1467  ProcessBlock(reinterpret_cast<float**>(mMasterIn.get()),
1468  reinterpret_cast<float**>(mMasterOut.get()),
1469  mNumSamples);
1470 
1471  return true;
1472 }
1473 
1474 bool AudioUnitEffect::ShowInterface(wxWindow &parent,
1476  bool forceModal)
1477 {
1478  if (mDialog)
1479  {
1480  if (mDialog->Close(true))
1481  {
1482  mDialog = nullptr;
1483  }
1484  return false;
1485  }
1486 
1487  // mDialog is null
1488  auto cleanup = valueRestorer(mDialog);
1489 
1490  if (factory)
1491  {
1492  mDialog = factory(parent, mHost, this);
1493  }
1494 
1495  if (!mDialog)
1496  {
1497  return false;
1498  }
1499 
1500  if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal)
1501  {
1502  mDialog->Show();
1503  cleanup.release();
1504 
1505  return false;
1506  }
1507 
1508  bool res = mDialog->ShowModal() != 0;
1509 
1510  return res;
1511 }
1512 
1514 {
1515  OSStatus result;
1516  UInt32 dataSize;
1517  Boolean isWritable;
1518 
1519  result = AudioUnitGetPropertyInfo(mUnit,
1520  kAudioUnitProperty_ParameterList,
1521  kAudioUnitScope_Global,
1522  0,
1523  &dataSize,
1524  &isWritable);
1525  if (result != noErr)
1526  {
1527  return false;
1528  }
1529 
1530  UInt32 cnt = dataSize / sizeof(AudioUnitParameterID);
1531  ArrayOf<AudioUnitParameterID> array {cnt};
1532 
1533  result = AudioUnitGetProperty(mUnit,
1534  kAudioUnitProperty_ParameterList,
1535  kAudioUnitScope_Global,
1536  0,
1537  array.get(),
1538  &dataSize);
1539  if (result != noErr)
1540  {
1541  return false;
1542  }
1543 
1544  for (int i = 0; i < cnt; i++)
1545  {
1546  ParameterInfo pi;
1547 
1548  if (!pi.Get(mUnit, array[i]))
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  AudioUnitParameterValue value;
1557  result = AudioUnitGetParameter(mUnit,
1558  array[i],
1559  kAudioUnitScope_Global,
1560  0,
1561  &value);
1562  if (result != noErr)
1563  {
1564  // Probably failed because of invalid parameter which can happen
1565  // if a plug-in is in a certain mode that doesn't contain the
1566  // parameter. In any case, just ignore it.
1567  continue;
1568  }
1569 
1570  parms.Write(pi.name, value);
1571  }
1572 
1573  return true;
1574 }
1575 
1577 {
1578  OSStatus result;
1579  UInt32 dataSize;
1580  Boolean isWritable;
1581 
1582  result = AudioUnitGetPropertyInfo(mUnit,
1583  kAudioUnitProperty_ParameterList,
1584  kAudioUnitScope_Global,
1585  0,
1586  &dataSize,
1587  &isWritable);
1588  if (result != noErr)
1589  {
1590  return false;
1591  }
1592 
1593  UInt32 cnt = dataSize / sizeof(AudioUnitParameterID);
1594  ArrayOf<AudioUnitParameterID> array {cnt};
1595 
1596  result = AudioUnitGetProperty(mUnit,
1597  kAudioUnitProperty_ParameterList,
1598  kAudioUnitScope_Global,
1599  0,
1600  array.get(),
1601  &dataSize);
1602  if (result != noErr)
1603  {
1604  return false;
1605  }
1606 
1607  for (int i = 0; i < cnt; i++)
1608  {
1609  ParameterInfo pi;
1610 
1611  if (!pi.Get(mUnit, array[i]))
1612  {
1613  // Probably failed because of invalid parameter which can happen
1614  // if a plug-in is in a certain mode that doesn't contain the
1615  // parameter. In any case, just ignore it.
1616  continue;
1617  }
1618 
1619  double d = 0.0;
1620  if (parms.Read(pi.name, &d))
1621  {
1622  AudioUnitParameterValue value = d;
1623  AudioUnitSetParameter(mUnit,
1624  array[i],
1625  kAudioUnitScope_Global,
1626  0,
1627  value,
1628  0);
1629 
1630  Notify(mUnit, array[i]);
1631  }
1632  }
1633 
1634  return true;
1635 }
1636 
1638 {
1639  return LoadPreset(name);
1640 }
1641 
1643 {
1644  return SavePreset(name);
1645 }
1646 
1648 {
1649  OSStatus result;
1650 
1651  // Retrieve the list of factory presets
1652  CFArrayRef array{};
1653  UInt32 dataSize = sizeof(CFArrayRef);
1654  result = AudioUnitGetProperty(mUnit,
1655  kAudioUnitProperty_FactoryPresets,
1656  kAudioUnitScope_Global,
1657  0,
1658  &array,
1659  &dataSize);
1660  CFunique_ptr<const __CFArray> uarray { array };
1661  if (result != noErr)
1662  {
1663  return false;
1664  }
1665 
1666  if (id < 0 || id >= CFArrayGetCount(array))
1667  {
1668  return false;
1669  }
1670 
1671  const AUPreset *preset = (const AUPreset *) CFArrayGetValueAtIndex(array, id);
1672 
1673  result = AudioUnitSetProperty(mUnit,
1674  kAudioUnitProperty_PresentPreset,
1675  kAudioUnitScope_Global,
1676  0,
1677  preset,
1678  sizeof(AUPreset));
1679  if (result == noErr)
1680  {
1681  // Notify interested parties of change and propagate to slaves
1682  Notify(mUnit, kAUParameterListener_AnyParameter);
1683  }
1684 
1685  return result == noErr;
1686 }
1687 
1689 {
1691 }
1692 
1694 {
1695  OSStatus result;
1696  RegistryPaths presets;
1697 
1698  // Retrieve the list of factory presets
1699  CFArrayRef array{};
1700  UInt32 dataSize = sizeof(CFArrayRef);
1701  result = AudioUnitGetProperty(mUnit,
1702  kAudioUnitProperty_FactoryPresets,
1703  kAudioUnitScope_Global,
1704  0,
1705  &array,
1706  &dataSize);
1707  CFunique_ptr<const __CFArray> uarray { array };
1708  if (result == noErr)
1709  {
1710  for (CFIndex i = 0, cnt = CFArrayGetCount(array); i < cnt; i++)
1711  {
1712  AUPreset *preset = (AUPreset *) CFArrayGetValueAtIndex(array, i);
1713  presets.push_back(wxCFStringRef::AsString(preset->presetName));
1714  }
1715  }
1716 
1717  return presets;
1718 }
1719 
1720 // ============================================================================
1721 // EffectUIClientInterface Implementation
1722 // ============================================================================
1723 
1725 {
1726  mUIHost = host;
1727 }
1728 
1730 {
1731  // OSStatus result;
1732 
1733  auto parent = S.GetParent();
1734  mDialog = static_cast<wxDialog *>(wxGetTopLevelParent(parent));
1735  mParent = parent;
1736  mpControl = NULL;
1737 
1738  wxPanel *container;
1739  {
1740  auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1741 
1742  wxASSERT(mParent); // To justify safenew
1743  container = safenew wxPanelWrapper(mParent, wxID_ANY);
1744  mainSizer->Add(container, 1, wxEXPAND);
1745 
1746  mParent->SetSizer(mainSizer.release());
1747  }
1748 
1749 #if defined(HAVE_AUDIOUNIT_BASIC_SUPPORT)
1750  if (mUIType == wxT("Basic"))
1751  {
1752  if (!CreatePlain(mParent))
1753  {
1754  return false;
1755  }
1756  }
1757  else
1758 #endif
1759  {
1760  auto pControl = Destroy_ptr<AUControl>(safenew AUControl);
1761  if (!pControl)
1762  {
1763  return false;
1764  }
1765 
1766  if (!pControl->Create(container, mComponent, mUnit, mUIType == wxT("Full")))
1767  {
1768  return false;
1769  }
1770 
1771  {
1772  auto innerSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1773 
1774  innerSizer->Add((mpControl = pControl.release()), 1, wxEXPAND);
1775  container->SetSizer(innerSizer.release());
1776  }
1777 
1778  mParent->SetMinSize(wxDefaultSize);
1779 
1780 #ifdef __WXMAC__
1781 #ifdef __WX_EVTLOOP_BUSY_WAITING__
1782  wxEventLoop::SetBusyWaiting(true);
1783 #endif
1784 #endif
1785  }
1786 
1787  if (mpControl)
1788  {
1789  mParent->PushEventHandler(this);
1790  }
1791 
1792  return true;
1793 }
1794 
1796 {
1797  return mUIType != wxT("Plain");
1798 }
1799 
1801 {
1802 #if 0
1803  if (!mParent->Validate())
1804  {
1805  return false;
1806  }
1807 
1808  if (GetType() == EffectTypeGenerate)
1809  {
1810  mHost->SetDuration(mDuration->GetValue());
1811  }
1812 #endif
1813  return true;
1814 }
1815 
1816 #if defined(HAVE_AUDIOUNIT_BASIC_SUPPORT)
1817 bool AudioUnitEffect::CreatePlain(wxWindow *parent)
1818 {
1819  // TODO??? Never implemented...
1820  return false;
1821 }
1822 #endif
1823 
1825 {
1826 #if 0
1827  if (GetType() == EffectTypeAnalyze || mNumOutputControls > 0)
1828  {
1829  return false;
1830  }
1831 #endif
1832  return true;
1833 }
1834 
1836 {
1837 #ifdef __WXMAC__
1838 #ifdef __WX_EVTLOOP_BUSY_WAITING__
1839  wxEventLoop::SetBusyWaiting(false);
1840 #endif
1841  if (mpControl)
1842  {
1843  mParent->RemoveEventHandler(this);
1844 
1845  mpControl->Close();
1846  mpControl = nullptr;
1847  }
1848 #endif
1849 
1850  mUIHost = NULL;
1851  mParent = NULL;
1852  mDialog = NULL;
1853 
1854  return true;
1855 }
1856 
1858 {
1859  return true;
1860 }
1861 
1863 {
1864  // Generate the user domain path
1865  wxFileName fn;
1866  fn.SetPath(PRESET_USER_PATH);
1867  fn.AppendDir(mVendor);
1868  fn.AppendDir(mName);
1869  fn.Normalize();
1870  FilePath path = fn.GetFullPath();
1871 
1872  if (!fn.Mkdir(fn.GetFullPath(), 0755, wxPATH_MKDIR_FULL))
1873  {
1874  wxLogError(wxT("Couldn't create the \"%s\" directory"), fn.GetPath());
1875  return;
1876  }
1877 
1878  // Ask the user for the name to use
1879  //
1880  // Passing a valid parent will cause some effects dialogs to malfunction
1881  // upon returning from the FileNames::SelectFile().
1882  path = FileNames::SelectFile(FileNames::Operation::_None,
1883  XO("Export Audio Unit Preset As %s:").Format(fn.GetFullPath()),
1884  fn.GetFullPath(),
1885  wxEmptyString,
1886  wxT("aupreset"),
1887  {
1888  { XO("Standard Audio Unit preset file"), { wxT("aupreset") }, true },
1889  },
1890  wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
1891  NULL);
1892 
1893  // User canceled...
1894  if (path.empty())
1895  {
1896  return;
1897  }
1898 
1899  auto msg = Export(path);
1900  if (!msg.empty())
1901  {
1903  XO("Could not export \"%s\" preset\n\n%s").Format(path, msg),
1904  XO("Export Audio Unit Presets"),
1905  wxOK | wxCENTRE,
1906  mParent);
1907  }
1908 }
1909 
1911 {
1912  // Generate the user domain path
1913  wxFileName fn;
1914  fn.SetPath(PRESET_USER_PATH);
1915  fn.AppendDir(mVendor);
1916  fn.AppendDir(mName);
1917  fn.Normalize();
1918  FilePath path = fn.GetFullPath();
1919 
1920  // Ask the user for the name to use
1921  //
1922  // Passing a valid parent will cause some effects dialogs to malfunction
1923  // upon returning from the FileNames::SelectFile().
1924  path = FileNames::SelectFile(FileNames::Operation::_None,
1925  XO("Import Audio Unit Preset As %s:").Format(fn.GetFullPath()),
1926  fn.GetFullPath(),
1927  wxEmptyString,
1928  wxT("aupreset"),
1929  {
1930  { XO("Standard Audio Unit preset file"), { wxT("aupreset") }, true },
1931  },
1932  wxFD_OPEN | wxRESIZE_BORDER,
1933  NULL);
1934 
1935  // User canceled...
1936  if (path.empty())
1937  {
1938  return;
1939  }
1940 
1941  auto msg = Import(path);
1942  if (!msg.empty())
1943  {
1945  XO("Could not import \"%s\" preset\n\n%s").Format(path, msg),
1946  XO("Import Audio Unit Presets"),
1947  wxOK | wxCENTRE,
1948  mParent);
1949  }
1950 }
1951 
1953 {
1954  return true;
1955 }
1956 
1958 {
1960  if (dlg.ShowModal())
1961  {
1962  // Reinitialize configuration settings
1963  mHost->GetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency, true);
1964  mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), mUIType, wxT("Full"));
1965  }
1966 }
1967 
1968 // ============================================================================
1969 // AudioUnitEffect Implementation
1970 // ============================================================================
1971 
1973 {
1974  wxString parms;
1975 
1976  // Attempt to load old preset parameters and resave using new method
1977  if (mHost->GetPrivateConfig(group, wxT("Parameters"), parms, wxEmptyString))
1978  {
1979  CommandParameters eap;
1980  if (eap.SetParameters(parms))
1981  {
1982  if (SetAutomationParameters(eap))
1983  {
1984  if (SavePreset(group))
1985  {
1986  mHost->RemovePrivateConfig(group, wxT("Parameters"));
1987  }
1988  }
1989  }
1990  return true;
1991  }
1992 
1993  // Retrieve the preset
1994  if (!mHost->GetPrivateConfig(group, PRESET_KEY, parms, wxEmptyString))
1995  {
1996  // Commented "CurrentSettings" gets tried a lot and useless messages appear
1997  // in the log
1998  //wxLogError(wxT("Preset key \"%s\" not found in group \"%s\""), PRESET_KEY, group);
1999  return false;
2000  }
2001 
2002  // Decode it
2003  wxMemoryBuffer buf = wxBase64Decode(parms);
2004  size_t bufLen = buf.GetDataLen();
2005  if (!bufLen)
2006  {
2007  wxLogError(wxT("Failed to decode \"%s\" preset"), group);
2008  return false;
2009  }
2010  const uint8_t *bufPtr = (uint8_t *) buf.GetData();
2011 
2012  // Create a CFData object that references the decoded preset
2014  {
2015  CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
2016  bufPtr,
2017  bufLen,
2018  kCFAllocatorNull)
2019  };
2020  if (!data)
2021  {
2022  wxLogError(wxT("Failed to convert \"%s\" preset to internal format"), group);
2023  return false;
2024  }
2025 
2026  // Convert it back to a property list.
2027  CFPropertyListRef content
2028  {
2029  CFPropertyListCreateWithData(kCFAllocatorDefault,
2030  data.get(),
2031  kCFPropertyListImmutable,
2032  NULL,
2033  NULL)
2034  };
2035  if (!content)
2036  {
2037  wxLogError(wxT("Failed to create property list for \"%s\" preset"), group);
2038  return false;
2039  }
2040  CFunique_ptr<char /* CFPropertyList */> ucontent { (char *) content };
2041 
2042  // See AUView::viewWillDraw
2043  if (mpControl)
2044  {
2046  }
2047 
2048  // Finally, update the properties and parameters
2049  OSStatus result;
2050  result = AudioUnitSetProperty(mUnit,
2051  kAudioUnitProperty_ClassInfo,
2052  kAudioUnitScope_Global,
2053  0,
2054  &content,
2055  sizeof(content));
2056  if (result != noErr)
2057  {
2058  wxLogError(wxT("Failed to set class info for \"%s\" preset"), group);
2059  return false;
2060  }
2061 
2062  // Notify interested parties of change and propagate to slaves
2063  Notify(mUnit, kAUParameterListener_AnyParameter);
2064 
2065  return true;
2066 }
2067 
2069 {
2070  // First set the name of the preset
2071  wxCFStringRef cfname(wxFileNameFromPath(group));
2072 
2073  // Define the preset property
2074  AUPreset preset;
2075  preset.presetNumber = -1; // indicates user preset
2076  preset.presetName = cfname;
2077 
2078  // And set it in the audio unit
2079  AudioUnitSetProperty(mUnit,
2080  kAudioUnitProperty_PresentPreset,
2081  kAudioUnitScope_Global,
2082  0,
2083  &preset,
2084  sizeof(preset));
2085 
2086  // Now retrieve the preset content
2087  CFPropertyListRef content;
2088  UInt32 size = sizeof(content);
2089  AudioUnitGetProperty(mUnit,
2090  kAudioUnitProperty_ClassInfo,
2091  kAudioUnitScope_Global,
2092  0,
2093  &content,
2094  &size);
2095  CFunique_ptr<char /* CFPropertyList */> ucontent { (char *) content };
2096 
2097  // And convert it to serialized binary data
2099  {
2100  CFPropertyListCreateData(kCFAllocatorDefault,
2101  content,
2102  PRESET_FORMAT,
2103  0,
2104  NULL)
2105  };
2106  if (!data)
2107  {
2108  return false;
2109  }
2110 
2111  // Nothing to do if we don't have any data
2112  SInt32 length = CFDataGetLength(data.get());
2113  if (length)
2114  {
2115  // Base64 encode the returned binary property list
2116  wxString parms = wxBase64Encode(CFDataGetBytePtr(data.get()), length);
2117 
2118  // And write it to the config
2119  if (!mHost->SetPrivateConfig(group, PRESET_KEY, parms))
2120  {
2121  return false;
2122  }
2123  }
2124 
2125  return true;
2126 }
2127 
2129 {
2130  OSStatus result;
2131 
2132  if (mUnitInitialized)
2133  {
2134  AudioUnitUninitialize(mUnit);
2135 
2136  mUnitInitialized = false;
2137  }
2138 
2139  AudioStreamBasicDescription streamFormat {
2140  // Float64 mSampleRate;
2141  mSampleRate,
2142 
2143  // UInt32 mFormatID;
2144  kAudioFormatLinearPCM,
2145 
2146  // UInt32 mFormatFlags;
2147  (kAudioFormatFlagsNativeFloatPacked |
2148  kAudioFormatFlagIsNonInterleaved),
2149 
2150  // UInt32 mBytesPerPacket;
2151  sizeof(float),
2152 
2153  // UInt32 mFramesPerPacket;
2154  1,
2155 
2156  // UInt32 mBytesPerFrame;
2157  sizeof(float),
2158 
2159  // UInt32 mChannelsPerFrame;
2160  mAudioIns,
2161 
2162  // UInt32 mBitsPerChannel;
2163  sizeof(float) * 8,
2164 
2165  // UInt32 mReserved;
2166  0
2167  };
2168 
2169  result = AudioUnitSetProperty(mUnit,
2170  kAudioUnitProperty_SampleRate,
2171  kAudioUnitScope_Global,
2172  0,
2173  &mSampleRate,
2174  sizeof(Float64));
2175  if (result != noErr)
2176  {
2177  wxPrintf("%ls Didn't accept sample rate on global\n",
2178  // Exposing internal name only in debug printf
2179  GetSymbol().Internal().wx_str());
2180  return false;
2181  }
2182 
2183  if (mAudioIns > 0)
2184  {
2185  result = AudioUnitSetProperty(mUnit,
2186  kAudioUnitProperty_SampleRate,
2187  kAudioUnitScope_Input,
2188  0,
2189  &mSampleRate,
2190  sizeof(Float64));
2191  if (result != noErr)
2192  {
2193  wxPrintf("%ls Didn't accept sample rate on input\n",
2194  // Exposing internal name only in debug printf
2195  GetSymbol().Internal().wx_str());
2196  return false;
2197  }
2198 
2199  result = AudioUnitSetProperty(mUnit,
2200  kAudioUnitProperty_StreamFormat,
2201  kAudioUnitScope_Input,
2202  0,
2203  &streamFormat,
2204  sizeof(AudioStreamBasicDescription));
2205  if (result != noErr)
2206  {
2207  wxPrintf("%ls didn't accept stream format on input\n",
2208  // Exposing internal name only in debug printf
2209  GetSymbol().Internal().wx_str());
2210  return false;
2211  }
2212  }
2213 
2214  if (mAudioOuts > 0)
2215  {
2216  result = AudioUnitSetProperty(mUnit,
2217  kAudioUnitProperty_SampleRate,
2218  kAudioUnitScope_Output,
2219  0,
2220  &mSampleRate,
2221  sizeof(Float64));
2222  if (result != noErr)
2223  {
2224  wxPrintf("%ls Didn't accept sample rate on output\n",
2225  // Exposing internal name only in debug printf
2226  GetSymbol().Internal().wx_str());
2227  return false;
2228  }
2229 
2230  streamFormat.mChannelsPerFrame = mAudioOuts;
2231  result = AudioUnitSetProperty(mUnit,
2232  kAudioUnitProperty_StreamFormat,
2233  kAudioUnitScope_Output,
2234  0,
2235  &streamFormat,
2236  sizeof(AudioStreamBasicDescription));
2237 
2238  if (result != noErr)
2239  {
2240  wxPrintf("%ls didn't accept stream format on output\n",
2241  // Exposing internal name only in debug printf
2242  GetSymbol().Internal().wx_str());
2243  return false;
2244  }
2245  }
2246 
2247  result = AudioUnitInitialize(mUnit);
2248  if (result != noErr)
2249  {
2250  wxPrintf("Couldn't initialize audio unit\n");
2251  return false;
2252  }
2253 
2254  mUnitInitialized = true;
2255 
2256  return true;
2257 }
2258 
2259 bool AudioUnitEffect::CopyParameters(AudioUnit srcUnit, AudioUnit dstUnit)
2260 {
2261  OSStatus result;
2262 
2263  // Retrieve the class state from the source AU
2264  CFPropertyListRef content;
2265  UInt32 size = sizeof(content);
2266  result = AudioUnitGetProperty(srcUnit,
2267  kAudioUnitProperty_ClassInfo,
2268  kAudioUnitScope_Global,
2269  0,
2270  &content,
2271  &size);
2272  if (result != noErr)
2273  {
2274  return false;
2275  }
2276 
2277  // Make sure it get's freed
2278  CFunique_ptr<char /* CFPropertyList */> ucontent { (char *) content };
2279 
2280  // Set the destination AUs state from the source AU's content
2281  result = AudioUnitSetProperty(dstUnit,
2282  kAudioUnitProperty_ClassInfo,
2283  kAudioUnitScope_Global,
2284  0,
2285  &content,
2286  sizeof(content));
2287  if (result != noErr)
2288  {
2289  return false;
2290  }
2291 
2292  // Notify interested parties
2293  Notify(dstUnit, kAUParameterListener_AnyParameter);
2294 
2295  return true;
2296 }
2297 
2299 {
2300  return mNumChannels;
2301 }
2302 
2303 void AudioUnitEffect::SetChannelCount(unsigned numChannels)
2304 {
2305  mNumChannels = numChannels;
2306 }
2307 
2309 {
2310  // Create the file
2311  wxFFile f(path, wxT("wb"));
2312  if (!f.IsOpened())
2313  {
2314  return XO("Couldn't open \"%s\"").Format(path);
2315  }
2316 
2317  // First set the name of the preset
2318  wxCFStringRef cfname(wxFileName(path).GetName());
2319 
2320  // Define the preset property
2321  AUPreset preset;
2322  preset.presetNumber = -1; // indicates user preset
2323  preset.presetName = cfname;
2324 
2325  // And set it in the audio unit
2326  OSStatus result;
2327  result = AudioUnitSetProperty(mUnit,
2328  kAudioUnitProperty_PresentPreset,
2329  kAudioUnitScope_Global,
2330  0,
2331  &preset,
2332  sizeof(preset));
2333  if (result != noErr)
2334  {
2335  return XO("Failed to set preset name");
2336  }
2337 
2338  // Now retrieve the preset content
2339  CFPropertyListRef content;
2340  UInt32 size = sizeof(content);
2341  result = AudioUnitGetProperty(mUnit,
2342  kAudioUnitProperty_ClassInfo,
2343  kAudioUnitScope_Global,
2344  0,
2345  &content,
2346  &size);
2347  CFunique_ptr<char /* CFPropertyList */> ucontent { (char *) content };
2348  if (result != noErr)
2349  {
2350  return XO("Failed to retrieve preset content");
2351  }
2352 
2353  // And convert it to serialized XML data
2355  {
2356  CFPropertyListCreateData(kCFAllocatorDefault,
2357  content,
2358  kCFPropertyListXMLFormat_v1_0,
2359  0,
2360  NULL)
2361  };
2362  if (!data)
2363  {
2364  return XO("Failed to convert property list to XML data");
2365  }
2366 
2367  // Nothing to do if we don't have any data
2368  SInt32 length = CFDataGetLength(data.get());
2369  if (!length)
2370  {
2371  return XO("XML data is empty after conversion");
2372  }
2373 
2374  // Write XML data
2375  if (f.Write(CFDataGetBytePtr(data.get()), length) != length || f.Error())
2376  {
2377  return XO("Failed to write XML preset to \"%s\"").Format(path);
2378  }
2379 
2380  f.Close();
2381 
2382  return {};
2383 }
2384 
2386 {
2387  // Open the preset
2388  wxFFile f(path, wxT("r"));
2389  if (!f.IsOpened())
2390  {
2391  return XO("Couldn't open \"%s\"").Format(path);
2392  }
2393 
2394  // Load it into the buffer
2395  size_t len = f.Length();
2396  wxMemoryBuffer buf(len);
2397  if (f.Read(buf.GetData(), len) != len || f.Error())
2398  {
2399  return XO("Unable to read the preset from \"%s\"").Format(path);
2400  }
2401 
2402  // Create a CFData object that references the decoded preset
2404  {
2405  CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
2406  (const UInt8 *) buf.GetData(),
2407  len,
2408  kCFAllocatorNull)
2409  };
2410  if (!data)
2411  {
2412  return XO("Failed to convert preset to internal format");
2413  }
2414 
2415  // Convert it back to a property list.
2416  CFPropertyListRef content
2417  {
2418  CFPropertyListCreateWithData(kCFAllocatorDefault,
2419  data.get(),
2420  kCFPropertyListImmutable,
2421  NULL,
2422  NULL)
2423  };
2424  if (!content)
2425  {
2426  return XO("Failed to create property list for preset");
2427  }
2428  CFunique_ptr<char /* CFPropertyList */> ucontent { (char *) content };
2429 
2430  // Finally, update the properties and parameters
2431  OSStatus result;
2432  result = AudioUnitSetProperty(mUnit,
2433  kAudioUnitProperty_ClassInfo,
2434  kAudioUnitScope_Global,
2435  0,
2436  &content,
2437  sizeof(content));
2438  if (result != noErr)
2439  {
2440  return XO("Failed to set class info for \"%s\" preset");
2441  }
2442 
2443  // Notify interested parties of change and propagate to slaves
2444  Notify(mUnit, kAUParameterListener_AnyParameter);
2445 
2446  return {};
2447 }
2448 
2449 void AudioUnitEffect::Notify(AudioUnit unit, AudioUnitParameterID parm)
2450 {
2451  // Notify any interested parties
2452  AudioUnitParameter aup = {};
2453  aup.mAudioUnit = unit;
2454  aup.mParameterID = parm;
2455  aup.mScope = kAudioUnitScope_Global;
2456  aup.mElement = 0;
2457  AUParameterListenerNotify(NULL, NULL, &aup);
2458 }
2459 
2460 OSStatus AudioUnitEffect::Render(AudioUnitRenderActionFlags *inActionFlags,
2461  const AudioTimeStamp *inTimeStamp,
2462  UInt32 inBusNumber,
2463  UInt32 inNumFrames,
2464  AudioBufferList *ioData)
2465 {
2466  for (int i = 0; i < ioData->mNumberBuffers; i++)
2467  ioData->mBuffers[i].mData = mInputList[0].mBuffers[i].mData;
2468 
2469  return 0;
2470 }
2471 
2472 // static
2473 OSStatus AudioUnitEffect::RenderCallback(void *inRefCon,
2474  AudioUnitRenderActionFlags *inActionFlags,
2475  const AudioTimeStamp *inTimeStamp,
2476  UInt32 inBusNumber,
2477  UInt32 inNumFrames,
2478  AudioBufferList *ioData)
2479 {
2480  return ((AudioUnitEffect *) inRefCon)->Render(inActionFlags,
2481  inTimeStamp,
2482  inBusNumber,
2483  inNumFrames,
2484  ioData);
2485 }
2486 
2487 void AudioUnitEffect::EventListener(const AudioUnitEvent *inEvent,
2488  AudioUnitParameterValue inParameterValue)
2489 {
2490  // Handle property changes
2491  if (inEvent->mEventType == kAudioUnitEvent_PropertyChange)
2492  {
2493  // Handle latency changes
2494  if (inEvent->mArgument.mProperty.mPropertyID == kAudioUnitProperty_Latency)
2495  {
2496  // Allow change to be used
2497  //mLatencyDone = false;
2498  }
2499 
2500  return;
2501  }
2502 
2503  // Only parameter changes at this point
2504 
2505  if (mMaster)
2506  {
2507  // We're a slave, so just set the parameter
2508  AudioUnitSetParameter(mUnit,
2509  inEvent->mArgument.mParameter.mParameterID,
2510  kAudioUnitScope_Global,
2511  0,
2512  inParameterValue,
2513  0);
2514  }
2515  else
2516  {
2517  // We're the master, so propagate
2518  for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
2519  {
2520  mSlaves[i]->EventListener(inEvent, inParameterValue);
2521  }
2522  }
2523 }
2524 
2525 // static
2526 void AudioUnitEffect::EventListenerCallback(void *inCallbackRefCon,
2527  void *inObject,
2528  const AudioUnitEvent *inEvent,
2529  UInt64 inEventHostTime,
2530  AudioUnitParameterValue inParameterValue)
2531 {
2532  ((AudioUnitEffect *) inCallbackRefCon)->EventListener(inEvent,
2533  inParameterValue);
2534 }
2535 
2537 {
2538  Boolean isWritable = 0;
2539  UInt32 dataSize = 0;
2540  OSStatus result;
2541 
2542  // Does AU have channel info
2543  result = AudioUnitGetPropertyInfo(mUnit,
2544  kAudioUnitProperty_SupportedNumChannels,
2545  kAudioUnitScope_Global,
2546  0,
2547  &dataSize,
2548  &isWritable);
2549  if (result)
2550  {
2551  // None supplied. Apparently all FX type units can do any number of INs
2552  // and OUTs as long as they are the same number. In this case, we'll
2553  // just say stereo.
2554  //
2555  // We should probably check to make sure we're dealing with an FX type.
2556  mAudioIns = 2;
2557  mAudioOuts = 2;
2558  return;
2559  }
2560 
2561  ArrayOf<char> buffer{ dataSize };
2562  auto info = (AUChannelInfo *) buffer.get();
2563 
2564  // Retrieve the channel info
2565  result = AudioUnitGetProperty(mUnit,
2566  kAudioUnitProperty_SupportedNumChannels,
2567  kAudioUnitScope_Global,
2568  0,
2569  info,
2570  &dataSize);
2571  if (result)
2572  {
2573  // Oh well, not much we can do out this case
2574  mAudioIns = 2;
2575  mAudioOuts = 2;
2576 
2577  return;
2578  }
2579 
2580  // This is where it gets weird...not sure what is the best
2581  // way to do this really. If we knew how many ins/outs we
2582  // really needed, we could make a better choice.
2583 
2584  bool haven2m = false; // nothing -> mono
2585  bool haven2s = false; // nothing -> stereo
2586  bool havem2n = false; // mono -> nothing
2587  bool haves2n = false; // stereo -> nothing
2588  bool havem2m = false; // mono -> mono
2589  bool haves2s = false; // stereo -> stereo
2590  bool havem2s = false; // mono -> stereo
2591  bool haves2m = false; // stereo -> mono
2592 
2593  mAudioIns = 2;
2594  mAudioOuts = 2;
2595 
2596  // Look only for exact channel constraints
2597  for (int i = 0; i < dataSize / sizeof(AUChannelInfo); i++)
2598  {
2599  AUChannelInfo *ci = &info[i];
2600 
2601  int ic = ci->inChannels;
2602  int oc = ci->outChannels;
2603 
2604  if (ic < 0 && oc >= 0)
2605  {
2606  ic = 2;
2607  }
2608  else if (ic >= 0 && oc < 0)
2609  {
2610  oc = 2;
2611  }
2612  else if (ic < 0 && oc < 0)
2613  {
2614  ic = 2;
2615  oc = 2;
2616  }
2617 
2618  if (ic == 2 && oc == 2)
2619  {
2620  haves2s = true;
2621  }
2622  else if (ic == 1 && oc == 1)
2623  {
2624  havem2m = true;
2625  }
2626  else if (ic == 1 && oc == 2)
2627  {
2628  havem2s = true;
2629  }
2630  else if (ic == 2 && oc == 1)
2631  {
2632  haves2m = true;
2633  }
2634  else if (ic == 0 && oc == 2)
2635  {
2636  haven2s = true;
2637  }
2638  else if (ic == 0 && oc == 1)
2639  {
2640  haven2m = true;
2641  }
2642  else if (ic == 1 && oc == 0)
2643  {
2644  havem2n = true;
2645  }
2646  else if (ic == 2 && oc == 0)
2647  {
2648  haves2n = true;
2649  }
2650  }
2651 
2652  if (haves2s)
2653  {
2654  mAudioIns = 2;
2655  mAudioOuts = 2;
2656  }
2657  else if (havem2m)
2658  {
2659  mAudioIns = 1;
2660  mAudioOuts = 1;
2661  }
2662  else if (havem2s)
2663  {
2664  mAudioIns = 1;
2665  mAudioOuts = 2;
2666  }
2667  else if (haves2m)
2668  {
2669  mAudioIns = 2;
2670  mAudioOuts = 1;
2671  }
2672  else if (haven2m)
2673  {
2674  mAudioIns = 0;
2675  mAudioOuts = 1;
2676  }
2677  else if (haven2s)
2678  {
2679  mAudioIns = 0;
2680  mAudioOuts = 2;
2681  }
2682  else if (haves2n)
2683  {
2684  mAudioIns = 2;
2685  mAudioOuts = 0;
2686  }
2687  else if (havem2n)
2688  {
2689  mAudioIns = 1;
2690  mAudioOuts = 0;
2691  }
2692 
2693  return;
2694 }
2695 
2697 {
2698  OSStatus result;
2699 
2700  UInt32 value = (bypass ? 1 : 0);
2701 
2702  result = AudioUnitSetProperty(mUnit,
2703  kAudioUnitProperty_BypassEffect,
2704  kAudioUnitScope_Global,
2705  0,
2706  &value,
2707  sizeof(value));
2708  if (result != noErr)
2709  {
2710  return false;
2711  }
2712 
2713  return true;
2714 }
2715 
2716 #endif
AudioUnitEffect::GetFamily
EffectFamilySymbol GetFamily() override
Definition: AudioUnitEffect.cpp:946
ParameterInfo::idEnd
static const char idEnd
Definition: AudioUnitEffect.cpp:216
EVT_BUTTON
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
RegistryPaths
std::vector< RegistryPath > RegistryPaths
Definition: Types.h:262
AudioUnitEffect::LoadUserPreset
bool LoadUserPreset(const RegistryPath &name) override
Definition: AudioUnitEffect.cpp:1637
AudioUnitEffect::GetChannelCounts
void GetChannelCounts()
Definition: AudioUnitEffect.cpp:2536
TranslatableString
Definition: Types.h:290
AudioUnitEffectsModule::GetOptionalFamilySymbol
EffectFamilySymbol GetOptionalFamilySymbol() override
Definition: AudioUnitEffect.cpp:315
ParameterInfo::idBeg
static const char idBeg
Definition: AudioUnitEffect.cpp:214
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:36
AudioUnitEffect::mPath
PluginPath mPath
Definition: AudioUnitEffect.h:179
CommandParameters::SetParameters
bool SetParameters(const wxString &parms)
Definition: EffectAutomationParameters.h:287
AudioUnitEffectsModule::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: AudioUnitEffect.cpp:271
valueRestorer
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:430
AudioUnitEffectsModule::LoadAudioUnitsOfType
void LoadAudioUnitsOfType(OSType inAUType, PluginPaths &effects)
Definition: AudioUnitEffect.cpp:409
AudioUnitEffect::SetSampleRate
void SetSampleRate(double rate) override
Definition: AudioUnitEffect.cpp:1198
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1177
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
AudioUnitEffectImportDialog::HasPresets
bool HasPresets()
Definition: AudioUnitEffect.cpp:755
BlackList
static const struct @0 BlackList[]
AudioUnitEffect::mDialog
wxDialog * mDialog
Definition: AudioUnitEffect.h:208
AudioUnitEffectOptionsDialog::OnOk
void OnOk(wxCommandEvent &evt)
Definition: AudioUnitEffect.cpp:622
ParameterInfo::name
wxString name
Definition: AudioUnitEffect.cpp:218
AudioUnitEffectsModule::GetPath
PluginPath GetPath() override
Definition: AudioUnitEffect.cpp:266
CFReleaser::operator()
void operator()(const void *p) const
Definition: AudioUnitEffect.cpp:91
AudioUnitEffect::EventListenerCallback
static void EventListenerCallback(void *inCallbackRefCon, void *inObject, const AudioUnitEvent *inEvent, UInt64 inEventHostTime, AudioUnitParameterValue inParameterValue)
Definition: AudioUnitEffect.cpp:2526
PluginPaths
std::vector< PluginPath > PluginPaths
Definition: Types.h:258
AudioUnitEffect::RealtimeSuspend
bool RealtimeSuspend() override
Definition: AudioUnitEffect.cpp:1398
eIsGettingFromDialog
@ eIsGettingFromDialog
Definition: ShuttleGui.h:37
AudioUnitEffect::ExportPresets
void ExportPresets() override
Definition: AudioUnitEffect.cpp:1862
EffectHostInterface
EffectHostInterface is a decorator of a EffectUIClientInterface. It adds virtual (abstract) functions...
Definition: EffectInterface.h:119
fn
static const auto fn
Definition: WaveformView.cpp:1102
AudioUnitEffectOptionsDialog::mUseLatency
bool mUseLatency
Definition: AudioUnitEffect.cpp:525
AudioUnitEffect::ShowOptions
void ShowOptions() override
Definition: AudioUnitEffect.cpp:1957
AudioUnitEffect::IsInteractive
bool IsInteractive() override
Definition: AudioUnitEffect.cpp:951
AudioUnitEffectsModule::AutoRegisterPlugins
bool AutoRegisterPlugins(PluginManagerInterface &pm) override
Definition: AudioUnitEffect.cpp:324
AudioUnitEffect::SetHost
bool SetHost(EffectHostInterface *host) override
Definition: AudioUnitEffect.cpp:1023
AUDIOUNITEFFECTS_VERSION
#define AUDIOUNITEFFECTS_VERSION
Definition: AudioUnitEffect.h:30
AudioUnitEffectImportDialog::mList
wxListCtrl * mList
Definition: AudioUnitEffect.cpp:663
AudioUnitEffect::mIsGraphical
bool mIsGraphical
Definition: AudioUnitEffect.h:210
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: AudacityMessageBox.h:20
AudioUnitEffect.h
ParameterInfo::~ParameterInfo
virtual ~ParameterInfo()
Definition: AudioUnitEffect.cpp:111
AudioUnitEffectsModule::FindAudioUnit
AudioComponent FindAudioUnit(const PluginPath &path, wxString &name)
Definition: AudioUnitEffect.cpp:467
AudioUnitEffect::IsReady
bool IsReady() override
Definition: AudioUnitEffect.cpp:1250
AudioUnitEffect::mInteractive
bool mInteractive
Definition: AudioUnitEffect.h:192
AudioUnitEffect::GetAudioInCount
unsigned GetAudioInCount() override
Definition: AudioUnitEffect.cpp:1178
wxPanelWrapper
Definition: wxPanelWrapper.h:41
AudioUnitEffect::RealtimeProcess
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
Definition: AudioUnitEffect.cpp:1446
Effect
Base class for many of the effects in Audacity.
Definition: Effect.h:71
AudioUnitEffectImportDialog::mParent
wxWindow * mParent
Definition: AudioUnitEffect.cpp:660
EffectTypeGenerate
@ EffectTypeGenerate
Definition: EffectInterface.h:58
AudioUnitEffect::SavePreset
bool SavePreset(const RegistryPath &group)
Definition: AudioUnitEffect.cpp:2068
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1603
AudioUnitEffect::SetRateAndChannels
bool SetRateAndChannels()
Definition: AudioUnitEffect.cpp:2128
AudioUnitEffect::mpControl
AUControl * mpControl
Definition: AudioUnitEffect.h:220
Format
Abstract base class used in importing a file.
DECLARE_BUILTIN_MODULE
DECLARE_BUILTIN_MODULE(AudioUnitEffectsBuiltin)
AudioUnitEffect::GetBlockSize
size_t GetBlockSize() const override
Definition: AudioUnitEffect.cpp:1208
ArrayOf::reinit
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:112
AudioUnitEffectsModule::AudioUnitEffectsModule
AudioUnitEffectsModule(const wxString *path)
Definition: AudioUnitEffect.cpp:249
EffectTypeNone
@ EffectTypeNone
Definition: EffectInterface.h:56
AudioUnitEffect::AudioUnitEffect
AudioUnitEffect(const PluginPath &path, const wxString &name, AudioComponent component, AudioUnitEffect *master=NULL)
Definition: AudioUnitEffect.cpp:838
AudioUnitEffect::mParent
wxWindow * mParent
Definition: AudioUnitEffect.h:207
AUControl::Close
void Close()
AudioUnitEffect::GetLatency
sampleCount GetLatency() override
Definition: AudioUnitEffect.cpp:1213
XO
#define XO(s)
Definition: Internat.h:32
AudioUnitEffect::EventListener
void EventListener(const AudioUnitEvent *inEvent, AudioUnitParameterValue inParameterValue)
Definition: AudioUnitEffect.cpp:2487
AudioUnitEffectsModule::IsPluginValid
bool IsPluginValid(const PluginPath &path, bool bFast) override
Definition: AudioUnitEffect.cpp:373
AudioUnitEffect::GetAutomationParameters
bool GetAutomationParameters(CommandParameters &parms) override
Definition: AudioUnitEffect.cpp:1513
AudioUnitEffectsModule
Definition: AudioUnitEffect.h:233
EffectHostInterface::GetCurrentSettingsGroup
virtual RegistryPath GetCurrentSettingsGroup()=0
AudioUnitEffect::mOutputList
ArrayOf< AudioBufferList > mOutputList
Definition: AudioUnitEffect.h:204
AudioUnitEffect::mUIHost
EffectUIHostInterface * mUIHost
Definition: AudioUnitEffect.h:206
AudioUnitEffect::GetDescription
TranslatableString GetDescription() override
Definition: AudioUnitEffect.cpp:916
AudioUnitEffect::IsLegacy
bool IsLegacy() override
Definition: AudioUnitEffect.cpp:961
AudioUnitEffect::RenderCallback
static OSStatus RenderCallback(void *inRefCon, AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
Definition: AudioUnitEffect.cpp:2473
AudioUnitEffect::ValidateUI
bool ValidateUI() override
Definition: AudioUnitEffect.cpp:1800
AudioUnitEffect::mAudioOuts
unsigned mAudioOuts
Definition: AudioUnitEffect.h:191
AudioUnitEffect::SetBlockSize
size_t SetBlockSize(size_t maxBlockSize) override
Definition: AudioUnitEffect.cpp:1203
AudioUnitEffect::IsDefault
bool IsDefault() override
Definition: AudioUnitEffect.cpp:956
componentManufacturer
OSType componentManufacturer
Definition: AudioUnitEffect.cpp:72
AudioUnitEffectOptionsDialog::~AudioUnitEffectOptionsDialog
virtual ~AudioUnitEffectOptionsDialog()
Definition: AudioUnitEffect.cpp:553
AudioUnitEffect::mUseLatency
bool mUseLatency
Definition: AudioUnitEffect.h:198
wxArrayStringEx
Definition: MemoryX.h:663
AudioUnitEffectsModule::FromOSType
wxString FromOSType(OSType type)
Definition: AudioUnitEffect.cpp:484
desc
const TranslatableString desc
Definition: ExportPCM.cpp:56
AudioUnitEffect::GetMidiInCount
int GetMidiInCount() override
Definition: AudioUnitEffect.cpp:1188
AudioUnitEffect::RealtimeInitialize
bool RealtimeInitialize() override
Definition: AudioUnitEffect.cpp:1354
AudioUnitEffect::CanExportPresets
bool CanExportPresets() override
Definition: AudioUnitEffect.cpp:1857
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:60
AudioUnitEffectImportDialog::Import
TranslatableString Import(const wxString &path, const wxString &name)
Definition: AudioUnitEffect.cpp:760
AudioUnitEffectOptionsDialog::mUIType
TranslatableString mUIType
Definition: AudioUnitEffect.cpp:526
AudioUnitEffect::RealtimeProcessEnd
bool RealtimeProcessEnd() override
Definition: AudioUnitEffect.cpp:1465
AudioUnitEffect::ImportPresets
void ImportPresets() override
Definition: AudioUnitEffect.cpp:1910
AudioUnitEffect::GetAudioOutCount
unsigned GetAudioOutCount() override
Definition: AudioUnitEffect.cpp:1183
AudioUnitEffectsModule::DeleteInstance
void DeleteInstance(ComponentInterface *instance) override
Definition: AudioUnitEffect.cpp:398
AudioUnitEffect::SetHostUI
void SetHostUI(EffectUIHostInterface *host) override
Definition: AudioUnitEffect.cpp:1724
AudioUnitEffect::HideUI
bool HideUI() override
Definition: AudioUnitEffect.cpp:1824
AudioUnitEffect::Import
TranslatableString Import(const wxString &path)
Definition: AudioUnitEffect.cpp:2385
AudioUnitEffect::ShowInterface
bool ShowInterface(wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
Definition: AudioUnitEffect.cpp:1474
AudioUnitEffect::mMasterOut
ArraysOf< float > mMasterOut
Definition: AudioUnitEffect.h:215
AudioUnitEffectImportDialog::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S)
Definition: AudioUnitEffect.cpp:685
ArraysOf::reinit
void reinit(Integral count)
Definition: MemoryX.h:164
AudioUnitEffectsModule::CreateInstance
ComponentInterface * CreateInstance(const PluginPath &path) override
Definition: AudioUnitEffect.cpp:384
ShuttleGui::Style
ShuttleGui & Style(long iStyle)
Definition: ShuttleGui.h:734
AudioUnitEffectOptionsDialog::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S)
Definition: AudioUnitEffect.cpp:557
AudioUnitEffectImportDialog::OnOk
void OnOk(wxCommandEvent &evt)
Definition: AudioUnitEffect.cpp:800
AudioUnitEffectsModule::~AudioUnitEffectsModule
virtual ~AudioUnitEffectsModule()
Definition: AudioUnitEffect.cpp:257
AudioUnitEffect::mSlaves
AudioUnitEffectArray mSlaves
Definition: AudioUnitEffect.h:213
componentType
OSType componentType
Definition: AudioUnitEffect.cpp:73
AudioUnitEffectsModule::DiscoverPluginsAtPath
unsigned DiscoverPluginsAtPath(const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
Definition: AudioUnitEffect.cpp:343
AudioUnitEffectImportDialog::~AudioUnitEffectImportDialog
virtual ~AudioUnitEffectImportDialog()
Definition: AudioUnitEffect.cpp:681
AUDIOUNITEFFECTS_FAMILY
#define AUDIOUNITEFFECTS_FAMILY
Definition: AudioUnitEffect.h:32
AudioUnitEffect::RealtimeAddProcessor
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
Definition: AudioUnitEffect.cpp:1361
AudioUnitEffect::PopulateUI
bool PopulateUI(ShuttleGui &S) override
Definition: AudioUnitEffect.cpp:1729
XXO
#define XXO(s)
Definition: Internat.h:45
ParameterInfo::ParameterInfo
ParameterInfo()
Definition: AudioUnitEffect.cpp:106
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1170
AudioUnitEffect::LoadFactoryPreset
bool LoadFactoryPreset(int id) override
Definition: AudioUnitEffect.cpp:1647
PluginManagerInterface
Definition: PluginInterface.h:55
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:804
PRESET_LOCAL_PATH
#define PRESET_LOCAL_PATH
Definition: AudioUnitEffect.cpp:67
AudioUnitEffect::GetChannelCount
unsigned GetChannelCount()
Definition: AudioUnitEffect.cpp:2298
AudioUnitEffect::mHost
EffectHostInterface * mHost
Definition: AudioUnitEffect.h:189
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1160
AudioUnitEffect::LoadPreset
bool LoadPreset(const RegistryPath &group)
Definition: AudioUnitEffect.cpp:1972
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1196
PRESET_USER_PATH
#define PRESET_USER_PATH
Definition: AudioUnitEffect.cpp:68
PRESET_KEY
#define PRESET_KEY
Definition: AudioUnitEffect.cpp:64
AudioUnitEffectsModule::GetFileExtensions
const FileExtensions & GetFileExtensions() override
Definition: AudioUnitEffect.cpp:297
AudioUnitEffect::CopyParameters
bool CopyParameters(AudioUnit srcUnit, AudioUnit dstUnit)
Definition: AudioUnitEffect.cpp:2259
ChannelNames
enum ChannelName * ChannelNames
AudioUnitEffect::RealtimeFinalize
bool RealtimeFinalize() override
Definition: AudioUnitEffect.cpp:1384
AudioUnitEffect::Render
OSStatus Render(AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
Definition: AudioUnitEffect.cpp:2460
componentSubType
OSType componentSubType
Definition: AudioUnitEffect.cpp:74
name
const TranslatableString name
Definition: Distortion.cpp:98
PluginPath
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Types.h:257
ShuttleGuiBase::GetParent
wxWindow * GetParent()
Definition: ShuttleGui.h:503
AudioUnitEffectsModule::FindPluginPaths
PluginPaths FindPluginPaths(PluginManagerInterface &pm) override
Definition: AudioUnitEffect.cpp:330
AudioUnitEffectOptionsDialog::AudioUnitEffectOptionsDialog
AudioUnitEffectOptionsDialog(wxWindow *parent, EffectHostInterface *host)
Definition: AudioUnitEffect.cpp:535
AudioUnitEffectsModule::GetDescription
TranslatableString GetDescription() override
Definition: AudioUnitEffect.cpp:288
AudioUnitEffect::SupportsRealtime
bool SupportsRealtime() override
Definition: AudioUnitEffect.cpp:966
ParameterInfo
Definition: AudioUnitEffect.cpp:104
CFunique_ptr
std::unique_ptr< T, CFReleaser > CFunique_ptr
Definition: AudioUnitEffect.cpp:96
ParameterInfo::info
AudioUnitParameterInfo info
Definition: AudioUnitEffect.cpp:219
AudioUnitEffect::SetAutomationParameters
bool SetAutomationParameters(CommandParameters &parms) override
Definition: AudioUnitEffect.cpp:1576
EffectClientInterface::EffectDialogFactory
std::function< wxDialog *(wxWindow &parent, EffectHostInterface *, EffectUIClientInterface *) > EffectDialogFactory
Definition: EffectInterface.h:149
ParameterInfo::idSep
static const char idSep
Definition: AudioUnitEffect.cpp:215
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
EffectUIHostInterface
EffectUIHostInterface has nothing in it. It is provided so that an Effect can call SetHostUI passing ...
Definition: EffectInterface.h:216
AudioUnitEffectsModule::Initialize
bool Initialize() override
Definition: AudioUnitEffect.cpp:303
AudioUnitEffect::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: AudioUnitEffect.cpp:894
Identifier::GET
const wxString & GET() const
Definition: Types.h:110
AudioUnitEffect::mSampleRate
double mSampleRate
Definition: AudioUnitEffect.h:195
AudioUnitEffect::Notify
void Notify(AudioUnit unit, AudioUnitParameterID parm)
Definition: AudioUnitEffect.cpp:2449
AudioUnitEffectOptionsDialog
Definition: AudioUnitEffect.cpp:513
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:886
CFReleaser
Definition: AudioUnitEffect.cpp:90
FilePath
wxString FilePath
Definition: Types.h:270
AudioUnitEffectImportDialog::AudioUnitEffectImportDialog
AudioUnitEffectImportDialog(wxWindow *parent, AudioUnitEffect *effect)
Definition: AudioUnitEffect.cpp:672
wxDialogWrapper
Definition: wxPanelWrapper.h:81
AudioUnitEffect::mUnitInitialized
bool mUnitInitialized
Definition: AudioUnitEffect.h:184
ParameterInfo::Get
bool Get(AudioUnit mUnit, AudioUnitParameterID parmID)
Definition: AudioUnitEffect.cpp:122
DECLARE_MODULE_ENTRY
DECLARE_MODULE_ENTRY(AudacityModule)
Definition: AudioUnitEffect.cpp:231
ConfigClientInterface::RemovePrivateConfig
virtual bool RemovePrivateConfig(const RegistryPath &group, const RegistryPath &key)=0
AudioUnitEffectsModule::mPath
wxString mPath
Definition: AudioUnitEffect.h:276
AudioUnitEffect::GetVersion
wxString GetVersion() override
Definition: AudioUnitEffect.cpp:904
EffectHostInterface::GetUserPresetsGroup
virtual RegistryPath GetUserPresetsGroup(const RegistryPath &name)=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
FileNames::SelectFile
AUDACITY_DLL_API FilePath SelectFile(Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
AudioUnitEffect::mUnit
AudioUnit mUnit
Definition: AudioUnitEffect.h:183
AudioUnitEffect::GetFactoryPresets
RegistryPaths GetFactoryPresets() override
Definition: AudioUnitEffect.cpp:1693
ShuttleGuiBase::AddListControlReportMode
wxListCtrl * AddListControlReportMode(std::initializer_list< const ListControlColumn > columns={}, long listControlStyles=0)
Definition: ShuttleGui.cpp:795
sampleCount
Definition: Types.h:589
AudioUnitEffect::GetTailSize
size_t GetTailSize() override
Definition: AudioUnitEffect.cpp:1235
AudioUnitEffect::mUIType
wxString mUIType
Definition: AudioUnitEffect.h:209
AudioUnitEffect::SaveUserPreset
bool SaveUserPreset(const RegistryPath &name) override
Definition: AudioUnitEffect.cpp:1642
EffectTypeAnalyze
@ EffectTypeAnalyze
Definition: EffectInterface.h:60
AudioUnitEffect::HasOptions
bool HasOptions() override
Definition: AudioUnitEffect.cpp:1952
AudioUnitEffect::mComponent
AudioComponent mComponent
Definition: AudioUnitEffect.h:182
ConfigClientInterface::SetSharedConfig
virtual bool SetSharedConfig(const RegistryPath &group, const RegistryPath &key, const wxString &value)=0
AudioUnitEffect::ProcessInitialize
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: AudioUnitEffect.cpp:1255
AudioUnitEffect::mMaster
AudioUnitEffect * mMaster
Definition: AudioUnitEffect.h:212
PRESET_FORMAT
#define PRESET_FORMAT
Definition: AudioUnitEffect.cpp:61
AudioUnitEffect::ProcessFinalize
bool ProcessFinalize() override
Definition: AudioUnitEffect.cpp:1308
AudioUnitEffect::mInputList
ArrayOf< AudioBufferList > mInputList
Definition: AudioUnitEffect.h:203
AudioUnitEffectOptionsDialog::mHost
EffectHostInterface * mHost
Definition: AudioUnitEffect.cpp:523
AudioUnitEffectImportDialog::mEffect
AudioUnitEffect * mEffect
Definition: AudioUnitEffect.cpp:661
AudioUnitEffect::mMasterIn
ArraysOf< float > mMasterIn
Definition: AudioUnitEffect.h:215
ComponentInterface
ComponentInterface provides name / vendor / version functions to identify plugins....
Definition: ComponentInterface.h:121
AudioUnitEffectsModule::ToOSType
OSType ToOSType(const wxString &type)
Definition: AudioUnitEffect.cpp:494
AudioUnitEffect::mLatencyDone
bool mLatencyDone
Definition: AudioUnitEffect.h:193
TranslatableString::MSGID
Identifier MSGID() const
Definition: Types.h:335
AudioUnitEffect::ProcessBlock
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: AudioUnitEffect.cpp:1318
ShuttleGui::AddStandardButtons
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxWindow *extra=NULL)
Definition: ShuttleGui.cpp:2406
AudioUnitEffect::mVendor
wxString mVendor
Definition: AudioUnitEffect.h:181
AudioUnitEffect::mNumChannels
unsigned mNumChannels
Definition: AudioUnitEffect.h:214
AudioUnitEffect::CloseUI
bool CloseUI() override
Definition: AudioUnitEffect.cpp:1835
AudioUnitEffect::BypassEffect
bool BypassEffect(bool bypass)
Definition: AudioUnitEffect.cpp:2696
AudioUnitEffect::GetVendor
VendorSymbol GetVendor() override
Definition: AudioUnitEffect.cpp:899
AudioUnitEffect::SupportsAutomation
bool SupportsAutomation() override
Definition: AudioUnitEffect.cpp:971
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
RegistryPath
wxString RegistryPath
Definition: Types.h:261
ComponentInterface::GetName
TranslatableString GetName()
Definition: PluginManager.cpp:3233
AudioUnitEffect::mNumSamples
size_t mNumSamples
Definition: AudioUnitEffect.h:216
AudioUnitEffect::~AudioUnitEffect
virtual ~AudioUnitEffect()
Definition: AudioUnitEffect.cpp:867
ShuttleGuiBase::AddVariableText
wxStaticText * AddVariableText(const TranslatableString &Str, bool bCenter=false, int PositionFlags=0, int wrapWidth=0)
Definition: ShuttleGui.cpp:456
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
ModuleInterface::RegistrationCallback
std::function< const PluginID &(ModuleInterface *, ComponentInterface *) > RegistrationCallback
Definition: ModuleInterface.h:121
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:915
Destroy_ptr
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:365
AudioUnitEffectsModule::GetVersion
wxString GetVersion() override
Definition: AudioUnitEffect.cpp:282
EffectType
EffectType
Definition: EffectInterface.h:55
safenew
#define safenew
Definition: MemoryX.h:8
AudioUnitEffect::RealtimeProcessStart
bool RealtimeProcessStart() override
Definition: AudioUnitEffect.cpp:1434
AudioUnitEffect::GetType
EffectType GetType() override
Definition: AudioUnitEffect.cpp:926
AudioUnitEffect::GetPath
PluginPath GetPath() override
Definition: AudioUnitEffect.cpp:889
AudioUnitEffect::RealtimeResume
bool RealtimeResume() override
Definition: AudioUnitEffect.cpp:1416
anonymous_namespace{Menus.cpp}::Options
std::vector< CommandFlagOptions > & Options()
Definition: Menus.cpp:526
END_EVENT_TABLE
END_EVENT_TABLE()
ShuttleGuiBase::TieChoice
wxChoice * TieChoice(const TranslatableString &Prompt, TranslatableString &Selected, const TranslatableStrings &choices)
Definition: ShuttleGui.cpp:1701
ArrayOf
This simplifies arrays of arrays, each array separately allocated with NEW[] But it might be better t...
Definition: MemoryX.h:82
AudioUnitEffectsModule::GetVendor
VendorSymbol GetVendor() override
Definition: AudioUnitEffect.cpp:277
AudioUnitEffect::Export
TranslatableString Export(const wxString &path)
Definition: AudioUnitEffect.cpp:2308
AudioUnitEffectImportDialog
Definition: AudioUnitEffect.cpp:648
EffectHostInterface::SetDuration
virtual void SetDuration(double seconds)=0
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638
EffectHostInterface::GetFactoryDefaultsGroup
virtual RegistryPath GetFactoryDefaultsGroup()=0
AudioUnitEffect::SetChannelCount
void SetChannelCount(unsigned numChannels)
Definition: AudioUnitEffect.cpp:2303
AudioUnitEffect::LoadFactoryDefaults
bool LoadFactoryDefaults() override
Definition: AudioUnitEffect.cpp:1688
AudioUnitEffect::IsGraphicalUI
bool IsGraphicalUI() override
Definition: AudioUnitEffect.cpp:1795
AudioUnitEffect::mName
wxString mName
Definition: AudioUnitEffect.h:180
AudioUnitEffect::GetMidiOutCount
int GetMidiOutCount() override
Definition: AudioUnitEffect.cpp:1193
AudioUnitEffectsModule::Terminate
void Terminate() override
Definition: AudioUnitEffect.cpp:309
AudioUnitEffect::mEventListenerRef
AUEventListenerRef mEventListenerRef
Definition: AudioUnitEffect.h:218