Audacity 3.2.0
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
AudioUnitEffect Class Referencefinal

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 Types

using Parameters = PackedArray::Ptr< const AudioUnitParameterID >
 
- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , Since_3_2 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 

Public Member Functions

 AudioUnitEffect (const PluginPath &path, const wxString &name, AudioComponent component, Parameters *pParameters=nullptr, AudioUnitEffect *master=nullptr)
 
virtual ~AudioUnitEffect ()
 
PluginPath GetPath () const override
 
ComponentInterfaceSymbol GetSymbol () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
TranslatableString GetDescription () const override
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
EffectFamilySymbol GetFamily () const override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () const override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () const override
 Whether the effect sorts "above the line" in the menus. More...
 
RealtimeSince RealtimeSupport () const override
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsAutomation () const override
 Whether the effect has any automatable controls. More...
 
EffectSettings MakeSettings () const override
 
bool CopySettingsContents (const EffectSettings &src, EffectSettings &dst, SettingsCopyDirection) const override
 Update one settings object from another. More...
 
bool SaveSettings (const EffectSettings &settings, CommandParameters &parms) const override
 Store settings as keys and values. More...
 
bool LoadSettings (const CommandParameters &parms, EffectSettings &settings) const override
 May allocate memory, so should be called only in the main thread. More...
 
bool LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 Change settings to a user-named preset. More...
 
bool SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const override
 Save settings in the configuration file as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () const override
 Report names of factory presets. More...
 
bool LoadFactoryPreset (int id, EffectSettings &settings) const override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal) override
 
bool InitializePlugin ()
 
bool FullyInitializePlugin ()
 
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
 Adds controls to a panel that is given as the parent window of S More...
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets (const EffectSettings &settings) const override
 
void ImportPresets (EffectSettings &settings) override
 
bool HasOptions () override
 
void ShowOptions () override
 
- Public Member Functions inherited from PerTrackEffect
 ~PerTrackEffect () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () const override
 
bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings) override
 
bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const override
 
ComponentInterfaceSymbol GetSymbol () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
TranslatableString GetDescription () const override
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
EffectFamilySymbol GetFamily () const override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () const override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () const override
 Whether the effect sorts "above the line" in the menus. More...
 
RealtimeSince RealtimeSupport () const override
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsAutomation () const override
 Whether the effect has any automatable controls. More...
 
bool SaveSettings (const EffectSettings &settings, CommandParameters &parms) const override
 Store settings as keys and values. More...
 
bool LoadSettings (const CommandParameters &parms, EffectSettings &settings) const override
 Restore settings from keys and values. More...
 
bool LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 Change settings to a user-named preset. More...
 
bool SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const override
 Save settings in the configuration file as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () const override
 Report names of factory presets. More...
 
bool LoadFactoryPreset (int id, EffectSettings &settings) const override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
bool LoadFactoryDefaults (EffectSettings &settings) const override
 Change settings back to "factory default". More...
 
virtual const EffectParameterMethodsParameters () const
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal) override
 
EffectUIClientInterfaceGetEffectUIClientInterface () override
 Returns the EffectUIClientInterface instance for this effect. More...
 
std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
 Adds controls to a panel that is given as the parent window of S More...
 
bool IsGraphicalUI () override
 
bool ValidateUI (EffectSettings &) override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets (const EffectSettings &settings) const override
 
void ImportPresets (EffectSettings &settings) override
 
bool HasOptions () override
 
void ShowOptions () override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false) override
 Usually applies factory to self and given access. More...
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
bool LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
bool TransferDataToWindow (const EffectSettings &settings) override
 Update controls for the settings. More...
 
bool TransferDataFromWindow (EffectSettings &settings) override
 Update the given settings from controls. More...
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings)
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
 
bool EnableApply (bool enable=true)
 
wxWindow * GetUIParent ()
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
virtual int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal=false)=0
 
virtual bool IsGraphicalUI ()=0
 
virtual std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)=0
 Adds controls to a panel that is given as the parent window of S More...
 
virtual bool CanExportPresets ()=0
 
virtual void ExportPresets (const EffectSettings &settings) const =0
 
virtual void ImportPresets (EffectSettings &settings)=0
 
virtual bool HasOptions ()=0
 
virtual void ShowOptions ()=0
 
virtual bool ValidateUI (EffectSettings &settings)=0
 
virtual bool CloseUI ()=0
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)=0
 Usually applies factory to self and given access. More...
 
virtual EffectUIClientInterfaceGetEffectUIClientInterface ()=0
 Returns the EffectUIClientInterface instance for this effect. More...
 
virtual void Preview (EffectSettingsAccess &access, bool dryOnly)=0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual bool LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const =0
 
virtual bool IsBatchProcessing () const =0
 
virtual void SetBatchProcessing ()=0
 
virtual void UnsetBatchProcessing ()=0
 
virtual bool DoEffect (EffectSettings &settings, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={}, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 Unfortunately complicated dual-use function. More...
 
virtual bool TransferDataToWindow (const EffectSettings &settings)=0
 Update controls for the settings. More...
 
virtual bool TransferDataFromWindow (EffectSettings &settings)=0
 Update the given settings from controls. More...
 
- Public Member Functions inherited from EffectInstanceFactory
virtual ~EffectInstanceFactory ()
 
virtual std::shared_ptr< EffectInstanceMakeInstance () const =0
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from EffectSettingsManager
virtual ~EffectSettingsManager ()
 
virtual bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings)
 
virtual bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetType () const =0
 Type determines how it behaves. More...
 
virtual EffectType GetClassification () const
 Determines which menu it appears in; default same as GetType(). More...
 
virtual EffectFamilySymbol GetFamily () const =0
 Report identifier and user-visible name of the effect protocol. More...
 
virtual bool IsInteractive () const =0
 Whether the effect needs a dialog for entry of settings. More...
 
virtual bool IsDefault () const =0
 Whether the effect sorts "above the line" in the menus. More...
 
virtual RealtimeSince RealtimeSupport () const =0
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsRealtime () const
 
virtual bool SupportsAutomation () const =0
 Whether the effect has any automatable controls. More...
 
virtual bool EnablesDebug () const
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual ManualPageID ManualPage () const
 Name of a page in the Audacity alpha manual, default is empty. More...
 
virtual FilePath HelpPage () const
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus () const
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 

Private Member Functions

TranslatableString Export (const AudioUnitEffectSettings &settings, const wxString &path) const
 
TranslatableString Import (AudioUnitEffectSettings &settings, const wxString &path) const
 
TranslatableString SaveBlobToConfig (const RegistryPath &group, const wxString &path, const void *blob, size_t len, bool allowEmpty=true) const
 
void GetChannelCounts ()
 
bool MigrateOldConfigFile (const RegistryPath &group, EffectSettings &settings) const
 
bool LoadPreset (const RegistryPath &group, EffectSettings &settings) const
 
bool SavePreset (const RegistryPath &group, const AudioUnitEffectSettings &settings) const
 
- Private Member Functions inherited from AudioUnitWrapper
 AudioUnitWrapper (AudioComponent component, Parameters *pParameters)
 
template<typename T >
OSStatus GetFixedSizeProperty (AudioUnitPropertyID inID, T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0) const
 
template<typename T >
OSStatus GetVariableSizeProperty (AudioUnitPropertyID inID, PackedArray::Ptr< T > &pObject, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0) const
 
template<typename T >
OSStatus SetProperty (AudioUnitPropertyID inID, const T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0) const
 
void ForEachParameter (ParameterVisitor visitor) const
 
std::pair< CF_ptr< CFDataRef >, TranslatableStringMakeBlob (const AudioUnitEffectSettings &settings, const wxCFStringRef &cfname, bool binary) const
 Obtain dump of the setting state of an AudioUnit instance. More...
 
TranslatableString InterpretBlob (AudioUnitEffectSettings &settings, const wxString &group, const wxMemoryBuffer &buf) const
 Interpret the dump made before by MakeBlob. More...
 
bool FetchSettings (AudioUnitEffectSettings &settings) const
 May allocate memory, so should be called only in the main thread. More...
 
bool StoreSettings (const AudioUnitEffectSettings &settings) const
 
bool CreateAudioUnit ()
 
AudioUnit GetAudioUnit () const
 
AudioComponent GetComponent () const
 
const ParametersGetParameters () const
 
bool SetRateAndChannels (double sampleRate, const wxString &identifier)
 

Private Attributes

const PluginPath mPath
 
const wxString mName
 
const wxString mVendor
 
bool mInteractive { false }
 
bool mUseLatency { true }
 
wxWindow * mParent {}
 
wxString mUIType
 
- Private Attributes inherited from AudioUnitWrapper
const AudioComponent mComponent
 
AudioUnitCleanup< AudioUnit, AudioComponentInstanceDispose > mUnit
 
Parameters mOwnParameters
 
ParametersmParameters
 
unsigned mAudioIns { 2 }
 
unsigned mAudioOuts { 2 }
 

Additional Inherited Members

- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
static void IncEffectCounter ()
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 
- Static Public Attributes inherited from EffectPlugin
static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 
- Protected Member Functions inherited from PerTrackEffect
bool DoPass1 () const
 
bool DoPass2 () const
 
bool Process (EffectInstance &instance, EffectSettings &settings) const
 
- Protected Member Functions inherited from Effect
bool EnablePreview (bool enable=true)
 
bool CheckWhetherSkipEffect (const EffectSettings &settings) const override
 Default implementation returns false. More...
 
double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override
 Default implementation returns previewLength More...
 
virtual std::unique_ptr< EffectUIValidatorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)
 Add controls to effect panel; always succeeds. More...
 
bool TotalProgress (double frac, const TranslatableString &={}) const
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={}) const
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={}) const
 
int GetNumWaveTracks () const
 
int GetNumWaveGroups () const
 
void GetBounds (const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
- Protected Member Functions inherited from EffectBase
void Preview (EffectSettingsAccess &access, bool dryOnly) override
 
bool DoEffect (EffectSettings &settings, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent, const EffectDialogFactory &dialogFactory, const EffectSettingsAccessPtr &pAccess) override
 Unfortunately complicated dual-use function. More...
 
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
- Protected Attributes inherited from PerTrackEffect
sampleCount mSampleCnt {}
 
- Protected Attributes inherited from Effect
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWindow * mUIParent {}
 
- Protected Attributes inherited from EffectBase
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0 {}
 
double mT1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 
- Static Protected Attributes inherited from EffectBase
static int nEffectsDone = 0
 
- Private Types inherited from AudioUnitWrapper
using Parameters = PackedArray::Ptr< const AudioUnitParameterID >
 
using ParameterVisitor = std::function< bool(const ParameterInfo &pi, AudioUnitParameterID ID) >
 Return value: if true, continue visiting. More...
 
- Static Private Member Functions inherited from AudioUnitWrapper
static AudioUnitEffectSettingsGetSettings (EffectSettings &settings)
 
static const AudioUnitEffectSettingsGetSettings (const EffectSettings &settings)
 

Detailed Description

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

Definition at line 40 of file AudioUnitEffect.h.

Member Typedef Documentation

◆ Parameters

using AudioUnitEffect::Parameters = PackedArray::Ptr<const AudioUnitParameterID>

Definition at line 45 of file AudioUnitEffect.h.

Constructor & Destructor Documentation

◆ AudioUnitEffect()

AudioUnitEffect::AudioUnitEffect ( const PluginPath path,
const wxString &  name,
AudioComponent  component,
Parameters pParameters = nullptr,
AudioUnitEffect master = nullptr 
)

Definition at line 95 of file AudioUnitEffect.cpp.

98 : AudioUnitWrapper{ component, pParameters }
99 , mPath{ path }
100 , mName{ name.AfterFirst(wxT(':')).Trim(true).Trim(false) }
101 , mVendor{ name.BeforeFirst(wxT(':')).Trim(true).Trim(false) }
102{
103}
wxT("CloseDown"))
const TranslatableString name
Definition: Distortion.cpp:82
const wxString mName
const wxString mVendor
const PluginPath mPath
Common base class for AudioUnitEffect and its Instance.

◆ ~AudioUnitEffect()

AudioUnitEffect::~AudioUnitEffect ( )
virtual

Definition at line 105 of file AudioUnitEffect.cpp.

106{
107}

Member Function Documentation

◆ CanExportPresets()

bool AudioUnitEffect::CanExportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 450 of file AudioUnitEffect.cpp.

451{
452 return true;
453}

◆ CloseUI()

bool AudioUnitEffect::CloseUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 439 of file AudioUnitEffect.cpp.

440{
441#ifdef __WXMAC__
442#ifdef __WX_EVTLOOP_BUSY_WAITING__
443 wxEventLoop::SetBusyWaiting(false);
444#endif
445#endif
446 mParent = nullptr;
447 return true;
448}
wxWindow * mParent

References mParent.

◆ CopySettingsContents()

bool AudioUnitEffect::CopySettingsContents ( const EffectSettings src,
EffectSettings dst,
SettingsCopyDirection  copyDirection 
) const
overridevirtual

Update one settings object from another.

This may run in a worker thread, and should avoid memory allocations. Therefore do not copy the underlying std::any, but copy the contents of the contained objects.

Assume that src and dst were created and previously modified only by this

Default implementation does nothing and returns true

Parameters
srcsettings to copy from
dstsettings to copy into
copyDirectiondirection in which copy is performed
Returns
success

Reimplemented from EffectSettingsManager.

Definition at line 306 of file AudioUnitEffect.cpp.

308{
309 auto &dstSettings = GetSettings(dst);
310 auto &srcSettings = GetSettings(src);
311 dstSettings.pSource = srcSettings.pSource;
312
313 // Do an in-place rewrite of dst, avoiding allocations
314 auto &dstMap = dstSettings.values;
315 auto dstIter = dstMap.begin(), dstEnd = dstMap.end();
316 const auto &srcMap = srcSettings.values;
317 // Iterate the two maps in parallel, assuming correspondence of
318 // keys, because the settings objects ultimately came from MakeSettings()
319 // and copies. Nothing else ever inserts or removes keys.
320 assert(srcMap.size() == dstMap.size());
321 for (auto &[key, oValue] : srcMap) {
322 assert(dstIter != dstEnd);
323 auto &[dstKey, dstOValue] = *dstIter;
324 assert(dstKey == key);
325 if (oValue)
326 dstOValue.emplace(*oValue);
327 else
328 dstOValue.reset();
329 ++dstIter;
330 }
331 assert(dstIter == dstEnd);
332 return true;
333}
static const AudacityProject::AttachedObjects::RegisteredFactory key
static AudioUnitEffectSettings & GetSettings(EffectSettings &settings)

References AudioUnitWrapper::GetSettings(), and key.

Here is the call graph for this function:

◆ Export()

TranslatableString AudioUnitEffect::Export ( const AudioUnitEffectSettings settings,
const wxString &  path 
) const
private

Definition at line 619 of file AudioUnitEffect.cpp.

621{
622 // Create the file
623 wxFFile f(path, wxT("wb"));
624 if (!f.IsOpened())
625 return XO("Couldn't open \"%s\"").Format(path);
626
627 // First set the name of the preset
628 wxCFStringRef cfname(wxFileName(path).GetName());
629
630 const auto &[data, message] = MakeBlob(settings, cfname, false);
631 if (!data || !message.empty())
632 return message;
633
634 // Write XML data
635 auto length = CFDataGetLength(data.get());
636 if (f.Write(CFDataGetBytePtr(data.get()), length) != length || f.Error())
637 return XO("Failed to write XML preset to \"%s\"").Format(path);
638
639 f.Close();
640 return {};
641}
#define XO(s)
Definition: Internat.h:31
static Settings & settings()
Definition: TrackInfo.cpp:87
TranslatableString GetName() const
std::pair< CF_ptr< CFDataRef >, TranslatableString > MakeBlob(const AudioUnitEffectSettings &settings, const wxCFStringRef &cfname, bool binary) const
Obtain dump of the setting state of an AudioUnit instance.

References ComponentInterface::GetName(), AudioUnitWrapper::MakeBlob(), settings(), wxT(), 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 ( const EffectSettings settings) const
overridevirtual

Implements EffectUIClientInterface.

Definition at line 455 of file AudioUnitEffect.cpp.

456{
457 // Generate the user domain path
458 wxFileName fn;
459 fn.SetPath(PRESET_USER_PATH);
460 fn.AppendDir(mVendor);
461 fn.AppendDir(mName);
462 fn.Normalize();
463 FilePath path = fn.GetFullPath();
464
465 if (!fn.Mkdir(fn.GetFullPath(), 0755, wxPATH_MKDIR_FULL)) {
466 wxLogError(wxT("Couldn't create the \"%s\" directory"), fn.GetPath());
467 return;
468 }
469
470 // Ask the user for the name to use
471 //
472 // Passing a valid parent will cause some effects dialogs to malfunction
473 // upon returning from the SelectFile().
474 path = SelectFile(FileNames::Operation::_None,
475 XO("Export Audio Unit Preset As %s:").Format(fn.GetFullPath()),
476 fn.GetFullPath(),
477 wxEmptyString,
478 wxT("aupreset"),
479 {
480 { XO("Standard Audio Unit preset file"), { wxT("aupreset") }, true },
481 },
482 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
483 NULL);
484
485 // User canceled...
486 if (path.empty())
487 return;
488
489 auto msg = Export(GetSettings(settings), path);
490 if (!msg.empty())
492 XO("Could not export \"%s\" preset\n\n%s").Format(path, msg),
493 XO("Export Audio Unit Presets"),
494 wxOK | wxCENTRE,
495 mParent);
496}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
#define PRESET_USER_PATH
wxString FilePath
Definition: Project.h:20
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
static const auto fn
TranslatableString Export(const AudioUnitEffectSettings &settings, const wxString &path) const
Abstract base class used in importing a file.

References AudacityMessageBox(), Export(), fn, AudioUnitWrapper::GetSettings(), mName, mParent, mVendor, PRESET_USER_PATH, SelectFile(), settings(), wxT(), and XO.

Here is the call graph for this function:

◆ FullyInitializePlugin()

bool AudioUnitEffect::FullyInitializePlugin ( )

Definition at line 256 of file AudioUnitEffect.cpp.

257{
258 if (!InitializePlugin())
259 return false;
260
261 // Reading these values from the config file can't be done in the PluginHost
262 // process but isn't needed only for plugin discovery.
263
264 // Consult preferences
265 // Decide mUseLatency, which affects GetLatency(), which is actually used
266 // so far only in destructive effect processing
268 mUseLatency, true);
269 // Decide whether to build plain or fancy user interfaces
271 mUIType, FullValue.MSGID().GET() /* Config stores un-localized string */);
272
273 return true;
274}
constexpr auto OptionsKey
constexpr auto UseLatencyKey
constexpr auto UITypeKey
static const auto FullValue
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)

References FullValue, PluginSettings::GetConfig(), InitializePlugin(), mUIType, mUseLatency, OptionsKey, PluginSettings::Shared, UITypeKey, and UseLatencyKey.

Here is the call graph for this function:

◆ GetChannelCounts()

void AudioUnitEffect::GetChannelCounts ( )
private

Definition at line 665 of file AudioUnitEffect.cpp.

666{
667 // Does AU have channel info
669 if (GetVariableSizeProperty(kAudioUnitProperty_SupportedNumChannels, info)) {
670 // None supplied. Apparently all FX type units can do any number of INs
671 // and OUTs as long as they are the same number. In this case, we'll
672 // just say stereo.
673 //
674 // We should probably check to make sure we're dealing with an FX type.
675 mAudioIns = 2;
676 mAudioOuts = 2;
677 return;
678 }
679
680 // This is where it gets weird...not sure what is the best
681 // way to do this really. If we knew how many ins/outs we
682 // really needed, we could make a better choice.
683
684 bool haven2m = false; // nothing -> mono
685 bool haven2s = false; // nothing -> stereo
686 bool havem2n = false; // mono -> nothing
687 bool haves2n = false; // stereo -> nothing
688 bool havem2m = false; // mono -> mono
689 bool haves2s = false; // stereo -> stereo
690 bool havem2s = false; // mono -> stereo
691 bool haves2m = false; // stereo -> mono
692
693 mAudioIns = 2;
694 mAudioOuts = 2;
695
696 // Look only for exact channel constraints
697 for (auto &ci : info) {
698 int ic = ci.inChannels;
699 int oc = ci.outChannels;
700
701 if (ic < 0 && oc >= 0)
702 ic = 2;
703 else if (ic >= 0 && oc < 0)
704 oc = 2;
705 else if (ic < 0 && oc < 0) {
706 ic = 2;
707 oc = 2;
708 }
709
710 if (ic == 2 && oc == 2)
711 haves2s = true;
712 else if (ic == 1 && oc == 1)
713 havem2m = true;
714 else if (ic == 1 && oc == 2)
715 havem2s = true;
716 else if (ic == 2 && oc == 1)
717 haves2m = true;
718 else if (ic == 0 && oc == 2)
719 haven2s = true;
720 else if (ic == 0 && oc == 1)
721 haven2m = true;
722 else if (ic == 1 && oc == 0)
723 havem2n = true;
724 else if (ic == 2 && oc == 0)
725 haves2n = true;
726 }
727
728 if (haves2s) {
729 mAudioIns = 2;
730 mAudioOuts = 2;
731 }
732 else if (havem2m) {
733 mAudioIns = 1;
734 mAudioOuts = 1;
735 }
736 else if (havem2s) {
737 mAudioIns = 1;
738 mAudioOuts = 2;
739 }
740 else if (haves2m) {
741 mAudioIns = 2;
742 mAudioOuts = 1;
743 }
744 else if (haven2m) {
745 mAudioIns = 0;
746 mAudioOuts = 1;
747 }
748 else if (haven2s) {
749 mAudioIns = 0;
750 mAudioOuts = 2;
751 }
752 else if (haves2n) {
753 mAudioIns = 2;
754 mAudioOuts = 0;
755 }
756 else if (havem2n) {
757 mAudioIns = 1;
758 mAudioOuts = 0;
759 }
760
761 return;
762}
OSStatus GetVariableSizeProperty(AudioUnitPropertyID inID, PackedArray::Ptr< T > &pObject, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0) const
Smart pointer type that deallocates with Deleter.
Definition: PackedArray.h:130

References AudioUnitWrapper::GetVariableSizeProperty(), AudioUnitWrapper::mAudioIns, and AudioUnitWrapper::mAudioOuts.

Referenced by InitializePlugin().

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

◆ GetDescription()

TranslatableString AudioUnitEffect::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 140 of file AudioUnitEffect.cpp.

141{
142 /* i18n-hint: Can mean "not available," "not applicable," "no answer" */
143 return XO("n/a");
144}

References XO.

◆ GetFactoryPresets()

RegistryPaths AudioUnitEffect::GetFactoryPresets ( ) const
overridevirtual

Report names of factory presets.

Implements EffectSettingsManager.

Definition at line 406 of file AudioUnitEffect.cpp.

407{
408 RegistryPaths presets;
409
410 // Retrieve the list of factory presets
411 CF_ptr<CFArrayRef> array;
412 if (!GetFixedSizeProperty(kAudioUnitProperty_FactoryPresets, array))
413 for (CFIndex i = 0, cnt = CFArrayGetCount(array.get()); i < cnt; ++i)
414 presets.push_back(wxCFStringRef::AsString(
415 static_cast<const AUPreset*>(CFArrayGetValueAtIndex(array.get(), i))
416 ->presetName));
417 return presets;
418}
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
OSStatus GetFixedSizeProperty(AudioUnitPropertyID inID, T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0) const

References AudioUnitWrapper::GetFixedSizeProperty().

Here is the call graph for this function:

◆ GetFamily()

EffectFamilySymbol AudioUnitEffect::GetFamily ( ) const
overridevirtual

Report identifier and user-visible name of the effect protocol.

Implements EffectDefinitionInterface.

Definition at line 170 of file AudioUnitEffect.cpp.

171{
173}
#define AUDIOUNITEFFECTS_FAMILY

References AUDIOUNITEFFECTS_FAMILY.

◆ GetPath()

PluginPath AudioUnitEffect::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 113 of file AudioUnitEffect.cpp.

114{
115 return mPath;
116}

References mPath.

◆ GetSymbol()

ComponentInterfaceSymbol AudioUnitEffect::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 118 of file AudioUnitEffect.cpp.

119{
120 return mName;
121}

References mName.

Referenced by InitializePlugin(), and MakeInstance().

Here is the caller graph for this function:

◆ GetType()

EffectType AudioUnitEffect::GetType ( ) const
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 150 of file AudioUnitEffect.cpp.

151{
152 if (mAudioIns == 0 && mAudioOuts == 0)
153 {
154 return EffectTypeNone;
155 }
156
157 if (mAudioIns == 0)
158 {
159 return EffectTypeGenerate;
160 }
161
162 if (mAudioOuts == 0)
163 {
164 return EffectTypeAnalyze;
165 }
166
167 return EffectTypeProcess;
168}
@ EffectTypeAnalyze
@ EffectTypeGenerate
@ EffectTypeNone
@ EffectTypeProcess

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

Referenced by RealtimeSupport(), and ShowClientInterface().

Here is the caller graph for this function:

◆ GetVendor()

VendorSymbol AudioUnitEffect::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 123 of file AudioUnitEffect.cpp.

124{
125 return { mVendor };
126}

References mVendor.

◆ GetVersion()

wxString AudioUnitEffect::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 128 of file AudioUnitEffect.cpp.

129{
130 UInt32 version;
131
132 OSStatus result = AudioComponentGetVersion(mComponent, &version);
133
134 return wxString::Format(wxT("%d.%d.%d"),
135 (version >> 16) & 0xffff,
136 (version >> 8) & 0xff,
137 version & 0xff);
138}
const AudioComponent mComponent

References AudioUnitWrapper::mComponent, and wxT().

Here is the call graph for this function:

◆ HasOptions()

bool AudioUnitEffect::HasOptions ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 534 of file AudioUnitEffect.cpp.

535{
536 return true;
537}

◆ Import()

TranslatableString AudioUnitEffect::Import ( AudioUnitEffectSettings settings,
const wxString &  path 
) const
private

Definition at line 643 of file AudioUnitEffect.cpp.

645{
646 // Open the preset
647 wxFFile f(path, wxT("r"));
648 if (!f.IsOpened())
649 return XO("Couldn't open \"%s\"").Format(path);
650
651 // Load it into the buffer
652 size_t len = f.Length();
653 wxMemoryBuffer buf(len);
654 if (f.Read(buf.GetData(), len) != len || f.Error())
655 return XO("Unable to read the preset from \"%s\"").Format(path);
656 buf.SetDataLen(len);
657
658 const auto error = InterpretBlob(settings, path, buf);
659 if (!error.empty())
660 return error;
661
662 return {};
663}
TranslatableString InterpretBlob(AudioUnitEffectSettings &settings, const wxString &group, const wxMemoryBuffer &buf) const
Interpret the dump made before by MakeBlob.

References AudioUnitWrapper::InterpretBlob(), settings(), wxT(), 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 ( EffectSettings settings)
overridevirtual

Implements EffectUIClientInterface.

Definition at line 498 of file AudioUnitEffect.cpp.

499{
500 // Generate the user domain path
501 wxFileName fn;
502 fn.SetPath(PRESET_USER_PATH);
503 fn.AppendDir(mVendor);
504 fn.AppendDir(mName);
505 fn.Normalize();
506 FilePath path = fn.GetFullPath();
507
508 // Ask the user for the name to use
509 //
510 // Passing a valid parent will cause some effects dialogs to malfunction
511 // upon returning from the SelectFile().
512 path = SelectFile(FileNames::Operation::_None,
513 XO("Import Audio Unit Preset As %s:").Format(fn.GetFullPath()),
514 fn.GetFullPath(), wxEmptyString, wxT("aupreset"),
515 {
516 { XO("Standard Audio Unit preset file"), { wxT("aupreset") }, true },
517 },
518 wxFD_OPEN | wxRESIZE_BORDER,
519 nullptr);
520
521 // User canceled...
522 if (path.empty())
523 return;
524
525 auto msg = Import(GetSettings(settings), path);
526 if (!msg.empty())
528 XO("Could not import \"%s\" preset\n\n%s").Format(path, msg),
529 XO("Import Audio Unit Presets"),
530 wxOK | wxCENTRE,
531 mParent);
532}
TranslatableString Import(AudioUnitEffectSettings &settings, const wxString &path) const

References AudacityMessageBox(), fn, AudioUnitWrapper::GetSettings(), Import(), mName, mParent, mVendor, PRESET_USER_PATH, SelectFile(), settings(), wxT(), and XO.

Here is the call graph for this function:

◆ InitializePlugin()

bool AudioUnitEffect::InitializePlugin ( )

Definition at line 215 of file AudioUnitEffect.cpp.

216{
217 // To implement the services of EffectPlugin -- such as, a query of the
218 // set of effect parameters, so that we can implement MakeSettings -- we
219 // also need what is called an AudioComponentInstance, also called an
220 // AudioUnit.
221 // It's not just for implementing EffectInstance. AudioUnits is unlike other
222 // third party effect families that distinguish the notions of plug-in and
223 // instance.
224
226
227 if (!CreateAudioUnit())
228 return false;
229
230 // Use an arbitrary rate while completing the discovery of channel support
231 if (!SetRateAndChannels(44100.0, GetSymbol().Internal()))
232 return false;
233
234 // Determine interactivity
236 if (!mInteractive) {
237 // Check for a Cocoa UI
238 // This could retrieve a variable-size property, but we only look at
239 // the first element.
240 AudioUnitCocoaViewInfo cocoaViewInfo;
242 !GetFixedSizeProperty(kAudioUnitProperty_CocoaUI, cocoaViewInfo);
243 if (!mInteractive) {
244 // Check for a Carbon UI
245 // This could retrieve a variable sized array but we only need the
246 // first
247 AudioComponentDescription compDesc;
249 kAudioUnitProperty_GetUIComponentList, compDesc);
250 }
251 }
252
253 return true;
254}
@ Internal
Indicates internal failure from Audacity.
ComponentInterfaceSymbol GetSymbol() const override
size_t Count(const Ptr< Type, BaseDeleter > &p)
Find out how many elements were allocated with a Ptr.
Definition: PackedArray.h:143
Parameters & mParameters
bool SetRateAndChannels(double sampleRate, const wxString &identifier)

References PackedArray::Count(), AudioUnitWrapper::CreateAudioUnit(), GetChannelCounts(), AudioUnitWrapper::GetFixedSizeProperty(), GetSymbol(), Internal, mInteractive, AudioUnitWrapper::mParameters, and AudioUnitWrapper::SetRateAndChannels().

Referenced by AudioUnitEffectsModule::DiscoverPluginsAtPath(), and FullyInitializePlugin().

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

◆ IsDefault()

bool AudioUnitEffect::IsDefault ( ) const
overridevirtual

Whether the effect sorts "above the line" in the menus.

Implements EffectDefinitionInterface.

Definition at line 180 of file AudioUnitEffect.cpp.

181{
182 return false;
183}

◆ IsInteractive()

bool AudioUnitEffect::IsInteractive ( ) const
overridevirtual

Whether the effect needs a dialog for entry of settings.

Implements EffectDefinitionInterface.

Definition at line 175 of file AudioUnitEffect.cpp.

176{
177 return mInteractive;
178}

References mInteractive.

◆ LoadFactoryPreset()

bool AudioUnitEffect::LoadFactoryPreset ( int  id,
EffectSettings settings 
) const
overridevirtual

Change settings to the preset whose name is GetFactoryPresets()[id]

Implements EffectSettingsManager.

Definition at line 382 of file AudioUnitEffect.cpp.

383{
384 // Issue 3441: Some factory presets of some effects do not reassign all
385 // controls. So first put controls into a default state, not contaminated
386 // by previous importing or other loading of settings into this wrapper.
388
389 // Retrieve the list of factory presets
390 CF_ptr<CFArrayRef> array;
391 if (GetFixedSizeProperty(kAudioUnitProperty_FactoryPresets, array) ||
392 id < 0 || id >= CFArrayGetCount(array.get()))
393 return false;
394
395 // Mutate the scratch pad AudioUnit in the effect
396 if (!SetProperty(kAudioUnitProperty_PresentPreset,
397 *static_cast<const AUPreset*>(CFArrayGetValueAtIndex(array.get(), id)))) {
398 // Repopulate the AudioUnitEffectSettings from the change of state in
399 // the AudioUnit
401 return true;
402 }
403 return false;
404}
const RegistryPath & FactoryDefaultsGroup()
Component of a configuration key path, for default state of MakeSettings()
bool LoadPreset(const RegistryPath &group, EffectSettings &settings) const
bool FetchSettings(AudioUnitEffectSettings &settings) const
May allocate memory, so should be called only in the main thread.
OSStatus SetProperty(AudioUnitPropertyID inID, const T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0) const

References FactoryDefaultsGroup(), AudioUnitWrapper::FetchSettings(), AudioUnitWrapper::GetFixedSizeProperty(), AudioUnitWrapper::GetSettings(), LoadPreset(), AudioUnitWrapper::SetProperty(), and settings().

Here is the call graph for this function:

◆ LoadPreset()

bool AudioUnitEffect::LoadPreset ( const RegistryPath group,
EffectSettings settings 
) const
private

Definition at line 574 of file AudioUnitEffect.cpp.

576{
577 if (MigrateOldConfigFile(group, settings))
578 return true;
579
580 // Retrieve the preset
581 wxString parms;
582 if (!GetConfig(*this, PluginSettings::Private, group, PRESET_KEY, parms,
583 wxEmptyString)) {
584 // Commented "CurrentSettings" gets tried a lot and useless messages appear
585 // in the log
586 //wxLogError(wxT("Preset key \"%s\" not found in group \"%s\""), PRESET_KEY, group);
587 return false;
588 }
589
590 // Decode it, complementary to what SaveBlobToConfig did
591 auto error =
592 InterpretBlob(GetSettings(settings), group, wxBase64Decode(parms));
593 if (!error.empty()) {
594 wxLogError(error.Debug());
595 return false;
596 }
597
598 return true;
599}
#define PRESET_KEY
bool MigrateOldConfigFile(const RegistryPath &group, EffectSettings &settings) const

References PluginSettings::GetConfig(), AudioUnitWrapper::GetSettings(), AudioUnitWrapper::InterpretBlob(), MigrateOldConfigFile(), PRESET_KEY, PluginSettings::Private, and settings().

Referenced by LoadFactoryPreset(), and LoadUserPreset().

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

◆ LoadSettings()

bool AudioUnitEffect::LoadSettings ( const CommandParameters parms,
EffectSettings settings 
) const
overridevirtual

May allocate memory, so should be called only in the main thread.

Implements EffectSettingsManager.

Definition at line 347 of file AudioUnitEffect.cpp.

349{
350 // First clean all settings, in case any are not defined in parms
351 auto &mySettings = GetSettings(settings);
352 mySettings.ResetValues();
353 auto &map = mySettings.values;
354
355 // Load settings from CommandParameters
356 // Iterate the config only, not using any AudioUnit handles
357 if (auto [index, key, value] = std::tuple(
358 0L, wxString{}, AudioUnitParameterValue{})
359 ; parms.GetFirstEntry(key, index)
360 ) do {
361 if (auto pKey = ParameterInfo::ParseKey(key)
362 ; pKey && parms.Read(key, &value)
363 )
364 map[*pKey].emplace(mySettings.Intern(key), value);
365 } while(parms.GetNextEntry(key, index));
366 return true;
367}
static std::optional< AudioUnitParameterID > ParseKey(const wxString &key)
Recover the parameter ID from the key, if well formed.

References AudioUnitWrapper::GetSettings(), key, AudioUnitWrapper::ParameterInfo::ParseKey(), and settings().

Referenced by MigrateOldConfigFile().

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

◆ LoadUserPreset()

bool AudioUnitEffect::LoadUserPreset ( const RegistryPath name,
EffectSettings settings 
) const
overridevirtual

Change settings to a user-named preset.

Implements EffectSettingsManager.

Definition at line 369 of file AudioUnitEffect.cpp.

371{
372 // To do: externalize state so const_cast isn't needed
373 return const_cast<AudioUnitEffect*>(this)->LoadPreset(name, settings);
374}
An Effect class that handles a wide range of effects. ??Mac only??

References LoadPreset(), name, and settings().

Here is the call graph for this function:

◆ MakeInstance()

std::shared_ptr< EffectInstance > AudioUnitEffect::MakeInstance ( ) const
overridevirtual

Make an object maintaining short-term state of an Effect.

One effect may have multiple instances extant simultaneously. Instances have state, may be implemented in foreign code, and are temporary, whereas EffectSettings represents persistent effect state that can be saved and reloaded from files.

Parameters
settingsmay be assumed to have a lifetime enclosing the instance's
Postcondition
true (no promises that the result isn't null)

Implements EffectInstanceFactory.

Definition at line 205 of file AudioUnitEffect.cpp.

206{
207 return std::make_shared<AudioUnitInstance>(*this, mComponent, mParameters,
209}

References GetSymbol(), Internal, AudioUnitWrapper::mAudioIns, AudioUnitWrapper::mAudioOuts, AudioUnitWrapper::mComponent, AudioUnitWrapper::mParameters, and mUseLatency.

Here is the call graph for this function:

◆ MakeSettings()

EffectSettings AudioUnitEffect::MakeSettings ( ) const
overridevirtual

Produce an object holding new, independent settings

Default implementation returns an empty any

Reimplemented from EffectSettingsManager.

Definition at line 299 of file AudioUnitEffect.cpp.

300{
303 return EffectSettings::Make<AudioUnitEffectSettings>(std::move(settings));
304}

References AudioUnitWrapper::FetchSettings(), and settings().

Here is the call graph for this function:

◆ MigrateOldConfigFile()

bool AudioUnitEffect::MigrateOldConfigFile ( const RegistryPath group,
EffectSettings settings 
) const
private

Definition at line 554 of file AudioUnitEffect.cpp.

556{
557 // Migration of very old format configuration file, should not normally
558 // happen and perhaps this code can be abandoned
559 // Attempt to load old preset parameters and resave using new method
560 constexpr auto oldKey = L"Parameters";
561 wxString parms;
563 group, oldKey, parms, wxEmptyString)) {
565 if (eap.SetParameters(parms))
566 if (LoadSettings(eap, settings))
567 if (SavePreset(group, GetSettings(settings)))
568 RemoveConfig(*this, PluginSettings::Private, group, oldKey);
569 return true;
570 }
571 return false;
572}
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
May allocate memory, so should be called only in the main thread.
bool SavePreset(const RegistryPath &group, const AudioUnitEffectSettings &settings) const
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
bool SetParameters(const wxString &parms)
bool RemoveConfig(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, const RegistryPath &key)

References PluginSettings::GetConfig(), AudioUnitWrapper::GetSettings(), LoadSettings(), PluginSettings::Private, PluginSettings::RemoveConfig(), SavePreset(), CommandParameters::SetParameters(), and settings().

Referenced by LoadPreset().

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

◆ PopulateUI()

std::unique_ptr< EffectUIValidator > AudioUnitEffect::PopulateUI ( ShuttleGui S,
EffectInstance instance,
EffectSettingsAccess access 
)
overridevirtual

Adds controls to a panel that is given as the parent window of S

Parameters
Sinterface for adding controls to a panel in a dialog
instanceguaranteed to have a lifetime containing that of the returned object
accessguaranteed to have a lifetime containing that of the returned object
Returns
null for failure; else an object invoked to retrieve values of UI controls; it might also hold some state needed to implement event handlers of the controls; it will exist only while the dialog continues to exist

Implements EffectUIClientInterface.

Definition at line 424 of file AudioUnitEffect.cpp.

426{
427 mParent = S.GetParent();
428 return AudioUnitValidator::Create(*this, S, mUIType, instance, access);
429}
#define S(N)
Definition: ToChars.cpp:64
static std::unique_ptr< EffectUIValidator > Create(EffectUIClientInterface &effect, ShuttleGui &S, const wxString &uiType, EffectInstance &instance, EffectSettingsAccess &access)

References AudioUnitValidator::Create(), mParent, mUIType, and S.

Here is the call graph for this function:

◆ RealtimeSupport()

auto AudioUnitEffect::RealtimeSupport ( ) const
overridevirtual

Since which version of Audacity has the effect supported realtime?

Implements EffectDefinitionInterface.

Definition at line 185 of file AudioUnitEffect.cpp.

186{
187 return GetType() == EffectTypeProcess
190}
EffectType GetType() const override
Type determines how it behaves.

References EffectTypeProcess, GetType(), EffectDefinitionInterface::Never, and EffectDefinitionInterface::Since_3_2.

Here is the call graph for this function:

◆ SaveBlobToConfig()

TranslatableString AudioUnitEffect::SaveBlobToConfig ( const RegistryPath group,
const wxString &  path,
const void *  blob,
size_t  len,
bool  allowEmpty = true 
) const
private
Parameters
pathonly for formatting error messages
Returns
error message

Definition at line 74 of file AudioUnitEffect.cpp.

77{
78 // Base64 encode the returned binary property list
79 auto parms = wxBase64Encode(blob, len);
80 if (!allowEmpty && parms.IsEmpty())
81 return XO("Failed to encode preset from \"%s\"").Format(path);
82
83 // And write it to the config
84 if (!SetConfig(*this, PluginSettings::Private, group, PRESET_KEY, parms))
85 return XO("Unable to store preset in config file");
86 return {};
87}
bool SetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)

References PRESET_KEY, PluginSettings::Private, PluginSettings::SetConfig(), and XO.

Referenced by SavePreset().

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

◆ SavePreset()

bool AudioUnitEffect::SavePreset ( const RegistryPath group,
const AudioUnitEffectSettings settings 
) const
private

Definition at line 601 of file AudioUnitEffect.cpp.

603{
604 wxCFStringRef cfname(wxFileNameFromPath(group));
605 const auto &[data, _] = MakeBlob(settings, cfname, true);
606 if (!data)
607 return false;
608
609 // Nothing to do if we don't have any data
610 if (const auto length = CFDataGetLength(data.get())) {
611 auto error =
612 SaveBlobToConfig(group, {}, CFDataGetBytePtr(data.get()), length);
613 if (!error.empty())
614 return false;
615 }
616 return true;
617}
#define _(s)
Definition: Internat.h:75
TranslatableString SaveBlobToConfig(const RegistryPath &group, const wxString &path, const void *blob, size_t len, bool allowEmpty=true) const

References _, AudioUnitWrapper::MakeBlob(), SaveBlobToConfig(), and settings().

Referenced by MigrateOldConfigFile(), and SaveUserPreset().

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

◆ SaveSettings()

bool AudioUnitEffect::SaveSettings ( const EffectSettings settings,
CommandParameters parms 
) const
overridevirtual

Store settings as keys and values.

The override may assume parms is initially empty

Returns
true on success

Implements EffectSettingsManager.

Definition at line 335 of file AudioUnitEffect.cpp.

337{
338 // Save settings into CommandParameters
339 // Iterate the map only, not using any AudioUnit handles
340 for (auto &[ID, pPair] : GetSettings(settings).values)
341 if (pPair)
342 // Write names, not numbers, as keys in the config file
343 parms.Write(pPair->first, pPair->second);
344 return true;
345}
const wxChar * values

References AudioUnitWrapper::GetSettings(), settings(), and values.

Here is the call graph for this function:

◆ SaveUserPreset()

bool AudioUnitEffect::SaveUserPreset ( const RegistryPath name,
const EffectSettings settings 
) const
overridevirtual

Save settings in the configuration file as a user-named preset.

Implements EffectSettingsManager.

Definition at line 376 of file AudioUnitEffect.cpp.

378{
380}

References AudioUnitWrapper::GetSettings(), name, SavePreset(), and settings().

Here is the call graph for this function:

◆ ShowClientInterface()

int AudioUnitEffect::ShowClientInterface ( wxWindow &  parent,
wxDialog &  dialog,
EffectUIValidator pValidator,
bool  forceModal 
)
overridevirtual
Returns
0 if destructive effect processing should not proceed (and there may be a non-modal dialog still opened); otherwise, modal dialog return code

Implements EffectUIClientInterface.

Definition at line 287 of file AudioUnitEffect.cpp.

289{
290 if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal) {
291 dialog.Show();
292 return 0;
293 }
294 return dialog.ShowModal();
295}

References EffectTypeAnalyze, GetType(), and EffectDefinitionInterface::SupportsRealtime().

Here is the call graph for this function:

◆ ShowOptions()

void AudioUnitEffect::ShowOptions ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 539 of file AudioUnitEffect.cpp.

540{
542 if (dlg.ShowModal()) {
543 // Save changed values to the config file
547 }
548}

References mParent, mUIType, mUseLatency, OptionsKey, PluginSettings::SetConfig(), PluginSettings::Shared, UITypeKey, and UseLatencyKey.

Here is the call graph for this function:

◆ SupportsAutomation()

bool AudioUnitEffect::SupportsAutomation ( ) const
overridevirtual

Whether the effect has any automatable controls.

Implements EffectDefinitionInterface.

Definition at line 192 of file AudioUnitEffect.cpp.

193{
194 bool supports = false;
196 [&supports](const ParameterInfo &pi, AudioUnitParameterID) {
197 if (pi.mInfo.flags & kAudioUnitParameterFlag_IsWritable)
198 supports = true;
199 // Search only until we find one, that's all we need to know
200 return !supports;
201 });
202 return supports;
203}
void ForEachParameter(ParameterVisitor visitor) const

References AudioUnitWrapper::ForEachParameter(), and AudioUnitWrapper::ParameterInfo::mInfo.

Here is the call graph for this function:

Member Data Documentation

◆ mInteractive

bool AudioUnitEffect::mInteractive { false }
private

Definition at line 141 of file AudioUnitEffect.h.

Referenced by InitializePlugin(), and IsInteractive().

◆ mName

const wxString AudioUnitEffect::mName
private

Definition at line 138 of file AudioUnitEffect.h.

Referenced by ExportPresets(), GetSymbol(), and ImportPresets().

◆ mParent

wxWindow* AudioUnitEffect::mParent {}
private

Definition at line 144 of file AudioUnitEffect.h.

Referenced by CloseUI(), ExportPresets(), ImportPresets(), PopulateUI(), and ShowOptions().

◆ mPath

const PluginPath AudioUnitEffect::mPath
private

Definition at line 137 of file AudioUnitEffect.h.

Referenced by GetPath().

◆ mUIType

wxString AudioUnitEffect::mUIType
private

Definition at line 145 of file AudioUnitEffect.h.

Referenced by FullyInitializePlugin(), PopulateUI(), and ShowOptions().

◆ mUseLatency

bool AudioUnitEffect::mUseLatency { true }
private

Definition at line 142 of file AudioUnitEffect.h.

Referenced by FullyInitializePlugin(), MakeInstance(), and ShowOptions().

◆ mVendor

const wxString AudioUnitEffect::mVendor
private

Definition at line 139 of file AudioUnitEffect.h.

Referenced by ExportPresets(), GetVendor(), and ImportPresets().


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