Audacity 3.2.0
Public Types | Public Member Functions | Private Member Functions | Static 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 , After_3_1 , 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) 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...
 
OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 
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...
 
OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const override
 
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, const EffectOutputs *pOutputs) 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
 
OptionalMessage 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...
 
OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 
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...
 
OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const override
 
OptionalMessage LoadFactoryDefaults (EffectSettings &settings) const override
 
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, const EffectOutputs *pOutputs) 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
 
OptionalMessage 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
 
OptionalMessage 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
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
void SetTracks (TrackList *pTracks)
 
- 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, const EffectOutputs *pOutputs)=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 OptionalMessage 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 OptionalMessage 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
 
virtual std::unique_ptr< EffectOutputsMakeOutputs () const
 Produce an object to hold values to send to effect output meters. More...
 
- 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
 
OptionalMessage 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
 
bool LoadPreset (const EffectDefinitionInterface &effect, const RegistryPath &group, EffectSettings &settings) const
 
bool LoadFactoryPreset (const EffectDefinitionInterface &effect, int id, EffectSettings *pSettings) const
 
std::pair< CF_ptr< CFDataRef >, TranslatableStringMakeBlob (const EffectDefinitionInterface &effect, 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, bool fetchValues, bool fetchPreset=false) const
 May allocate memory, so should be called only in the main thread. More...
 
bool StoreSettings (const EffectDefinitionInterface &effect, const AudioUnitEffectSettings &settings) const
 
bool CreateAudioUnit ()
 
AudioUnit GetAudioUnit () const
 
AudioComponent GetComponent () const
 
const ParametersGetParameters () const
 
bool SetRateAndChannels (double sampleRate, const wxString &identifier)
 

Static Private Member Functions

static RegistryPath ChoosePresetKey (const EffectSettings &settings)
 
static RegistryPath FindPresetKey (const CommandParameters &parms)
 
- Static Private Member Functions inherited from AudioUnitWrapper
static AudioUnitEffectSettingsGetSettings (EffectSettings &settings)
 
static const AudioUnitEffectSettingsGetSettings (const EffectSettings &settings)
 
static bool MoveSettingsContents (AudioUnitEffectSettings &&src, AudioUnitEffectSettings &dst, bool merge)
 Copy, then clear the optionals in src. More...
 

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 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, const EffectOutputs *pOutputs)
 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...
 
- 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...
 

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 94 of file AudioUnitEffect.cpp.

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

◆ ~AudioUnitEffect()

AudioUnitEffect::~AudioUnitEffect ( )
virtual

Definition at line 104 of file AudioUnitEffect.cpp.

105{
106}

Member Function Documentation

◆ CanExportPresets()

bool AudioUnitEffect::CanExportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 460 of file AudioUnitEffect.cpp.

461{
462 return true;
463}

◆ ChoosePresetKey()

RegistryPath AudioUnitEffect::ChoosePresetKey ( const EffectSettings settings)
staticprivate

Definition at line 314 of file AudioUnitEffect.cpp.

316{
317 // Find a key to use for the preset that does not collide with any
318 // parameter name
319 wxString result = PresetStr;
320
321 // That string probably works but be sure
322 const auto &map = GetSettings(settings).values;
323 using Pair = decltype(*map.begin());
324 while (std::any_of(map.begin(), map.end(), [&](Pair &pair){
325 return pair.second && pair.second->first == result;
326 }))
327 result += "_";
328
329 return result;
330}
constexpr auto PresetStr
static Settings & settings()
Definition: TrackInfo.cpp:87
std::pair< const char *, const char * > Pair
static AudioUnitEffectSettings & GetSettings(EffectSettings &settings)

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

Referenced by SaveSettings().

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

◆ CloseUI()

bool AudioUnitEffect::CloseUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 449 of file AudioUnitEffect.cpp.

450{
451#ifdef __WXMAC__
452#ifdef __WX_EVTLOOP_BUSY_WAITING__
453 wxEventLoop::SetBusyWaiting(false);
454#endif
455#endif
456 mParent = nullptr;
457 return true;
458}
wxWindow * mParent

References mParent.

◆ CopySettingsContents()

bool AudioUnitEffect::CopySettingsContents ( const EffectSettings src,
EffectSettings dst 
) 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 305 of file AudioUnitEffect.cpp.

307{
308 // Not needed -- rely on EffectInstance::Message instead
309 return true;
310}

◆ Export()

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

Definition at line 617 of file AudioUnitEffect.cpp.

619{
620 // Create the file
621 wxFFile f(path, wxT("wb"));
622 if (!f.IsOpened())
623 return XO("Couldn't open \"%s\"").Format(path);
624
625 // First set the name of the preset
626 wxCFStringRef cfname(wxFileName(path).GetName());
627
628 const auto &[data, message] = MakeBlob(*this, settings, cfname, false);
629 if (!data || !message.empty())
630 return message;
631
632 // Write XML data
633 auto length = CFDataGetLength(data.get());
634 if (f.Write(CFDataGetBytePtr(data.get()), length) != length || f.Error())
635 return XO("Failed to write XML preset to \"%s\"").Format(path);
636
637 f.Close();
638 return {};
639}
XO("Cut/Copy/Paste")
TranslatableString GetName() const
std::pair< CF_ptr< CFDataRef >, TranslatableString > MakeBlob(const EffectDefinitionInterface &effect, 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 465 of file AudioUnitEffect.cpp.

466{
467 // Generate the user domain path
468 wxFileName fn;
469 fn.SetPath(PRESET_USER_PATH);
470 fn.AppendDir(mVendor);
471 fn.AppendDir(mName);
472 fn.Normalize();
473 FilePath path = fn.GetFullPath();
474
475 if (!fn.Mkdir(fn.GetFullPath(), 0755, wxPATH_MKDIR_FULL)) {
476 wxLogError(wxT("Couldn't create the \"%s\" directory"), fn.GetPath());
477 return;
478 }
479
480 // Ask the user for the name to use
481 //
482 // Passing a valid parent will cause some effects dialogs to malfunction
483 // upon returning from the SelectFile().
484 path = SelectFile(FileNames::Operation::_None,
485 XO("Export Audio Unit Preset As %s:").Format(fn.GetFullPath()),
486 fn.GetFullPath(),
487 wxEmptyString,
488 wxT("aupreset"),
489 {
490 { XO("Standard Audio Unit preset file"), { wxT("aupreset") }, true },
491 },
492 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
493 NULL);
494
495 // User canceled...
496 if (path.empty())
497 return;
498
499 auto msg = Export(GetSettings(settings), path);
500 if (!msg.empty())
502 XO("Could not export \"%s\" preset\n\n%s").Format(path, msg),
503 XO("Export Audio Unit Presets"),
504 wxOK | wxCENTRE,
505 mParent);
506}
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:21
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:

◆ FindPresetKey()

RegistryPath AudioUnitEffect::FindPresetKey ( const CommandParameters parms)
staticprivate

Definition at line 332 of file AudioUnitEffect.cpp.

333{
334 RegistryPath result;
335 auto len = strlen(PresetStr);
336 if (auto [index, key] = std::tuple(0L, wxString{})
337 ; parms.GetFirstEntry(key, index)
338 ) do {
339 if (key.StartsWith(PresetStr)
340 && key.Mid(len).find_first_not_of("_") == wxString::npos
341 && key.length() > result.length())
342 result = key;
343 } while(parms.GetNextEntry(key, index));
344 return result;
345}
static const AudacityProject::AttachedObjects::RegisteredFactory key
wxString RegistryPath
Definition: Identifier.h:218

References key, and PresetStr.

Referenced by LoadSettings().

Here is the caller graph for this function:

◆ FullyInitializePlugin()

bool AudioUnitEffect::FullyInitializePlugin ( )

Definition at line 255 of file AudioUnitEffect.cpp.

256{
257 if (!InitializePlugin())
258 return false;
259
260 // Reading these values from the config file can't be done in the PluginHost
261 // process but isn't needed only for plugin discovery.
262
263 // Consult preferences
264 // Decide mUseLatency, which affects GetLatency(), which is actually used
265 // so far only in destructive effect processing
267 mUseLatency, true);
268 // Decide whether to build plain or fancy user interfaces
270 mUIType, FullValue.MSGID().GET() /* Config stores un-localized string */);
271
272 return true;
273}
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 663 of file AudioUnitEffect.cpp.

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

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

References XO().

Here is the call graph for this function:

◆ GetFactoryPresets()

RegistryPaths AudioUnitEffect::GetFactoryPresets ( ) const
overridevirtual

Report names of factory presets.

Implements EffectSettingsManager.

Definition at line 415 of file AudioUnitEffect.cpp.

416{
417 RegistryPaths presets;
418
419 // Retrieve the list of factory presets
420 CF_ptr<CFArrayRef> array;
421 if (!GetFixedSizeProperty(kAudioUnitProperty_FactoryPresets, array))
422 for (CFIndex i = 0, cnt = CFArrayGetCount(array.get()); i < cnt; ++i)
423 presets.push_back(wxCFStringRef::AsString(
424 static_cast<const AUPreset*>(CFArrayGetValueAtIndex(array.get(), i))
425 ->presetName));
426 return presets;
427}
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 169 of file AudioUnitEffect.cpp.

170{
172}
#define AUDIOUNITEFFECTS_FAMILY

References AUDIOUNITEFFECTS_FAMILY.

◆ GetPath()

PluginPath AudioUnitEffect::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 112 of file AudioUnitEffect.cpp.

113{
114 return mPath;
115}

References mPath.

◆ GetSymbol()

ComponentInterfaceSymbol AudioUnitEffect::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 117 of file AudioUnitEffect.cpp.

118{
119 return mName;
120}

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 149 of file AudioUnitEffect.cpp.

150{
151 if (mAudioIns == 0 && mAudioOuts == 0)
152 {
153 return EffectTypeNone;
154 }
155
156 if (mAudioIns == 0)
157 {
158 return EffectTypeGenerate;
159 }
160
161 if (mAudioOuts == 0)
162 {
163 return EffectTypeAnalyze;
164 }
165
166 return EffectTypeProcess;
167}
@ 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 122 of file AudioUnitEffect.cpp.

123{
124 return { mVendor };
125}

References mVendor.

◆ GetVersion()

wxString AudioUnitEffect::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 127 of file AudioUnitEffect.cpp.

128{
129 UInt32 version;
130
131 OSStatus result = AudioComponentGetVersion(mComponent, &version);
132
133 return wxString::Format(wxT("%d.%d.%d"),
134 (version >> 16) & 0xffff,
135 (version >> 8) & 0xff,
136 version & 0xff);
137}
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 548 of file AudioUnitEffect.cpp.

549{
550 return true;
551}

◆ Import()

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

Definition at line 641 of file AudioUnitEffect.cpp.

643{
644 // Open the preset
645 wxFFile f(path, wxT("r"));
646 if (!f.IsOpened())
647 return XO("Couldn't open \"%s\"").Format(path);
648
649 // Load it into the buffer
650 size_t len = f.Length();
651 wxMemoryBuffer buf(len);
652 if (f.Read(buf.GetData(), len) != len || f.Error())
653 return XO("Unable to read the preset from \"%s\"").Format(path);
654 buf.SetDataLen(len);
655
656 const auto error = InterpretBlob(settings, path, buf);
657 if (!error.empty())
658 return error;
659
660 return {};
661}
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()

OptionalMessage AudioUnitEffect::ImportPresets ( EffectSettings settings)
overridevirtual
Returns
nullopt for failure

Implements EffectUIClientInterface.

Definition at line 508 of file AudioUnitEffect.cpp.

509{
510 // Generate the user domain path
511 wxFileName fn;
512 fn.SetPath(PRESET_USER_PATH);
513 fn.AppendDir(mVendor);
514 fn.AppendDir(mName);
515 fn.Normalize();
516 FilePath path = fn.GetFullPath();
517
518 // Ask the user for the name to use
519 //
520 // Passing a valid parent will cause some effects dialogs to malfunction
521 // upon returning from the SelectFile().
522 path = SelectFile(FileNames::Operation::_None,
523 XO("Import Audio Unit Preset As %s:").Format(fn.GetFullPath()),
524 fn.GetFullPath(), wxEmptyString, wxT("aupreset"),
525 {
526 { XO("Standard Audio Unit preset file"), { wxT("aupreset") }, true },
527 },
528 wxFD_OPEN | wxRESIZE_BORDER,
529 nullptr);
530
531 // User canceled...
532 if (path.empty())
533 return {};
534
535 auto msg = Import(GetSettings(settings), path);
536 if (!msg.empty()) {
538 XO("Could not import \"%s\" preset\n\n%s").Format(path, msg),
539 XO("Import Audio Unit Presets"),
540 wxOK | wxCENTRE,
541 mParent);
542 return {};
543 }
544
545 return { nullptr };
546}
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 214 of file AudioUnitEffect.cpp.

215{
216 // To implement the services of EffectPlugin -- such as, a query of the
217 // set of effect parameters, so that we can implement MakeSettings -- we
218 // also need what is called an AudioComponentInstance, also called an
219 // AudioUnit.
220 // It's not just for implementing EffectInstance. AudioUnits is unlike other
221 // third party effect families that distinguish the notions of plug-in and
222 // instance.
223
225
226 if (!CreateAudioUnit())
227 return false;
228
229 // Use an arbitrary rate while completing the discovery of channel support
230 if (!SetRateAndChannels(44100.0, GetSymbol().Internal()))
231 return false;
232
233 // Determine interactivity
235 if (!mInteractive) {
236 // Check for a Cocoa UI
237 // This could retrieve a variable-size property, but we only look at
238 // the first element.
239 AudioUnitCocoaViewInfo cocoaViewInfo;
241 !GetFixedSizeProperty(kAudioUnitProperty_CocoaUI, cocoaViewInfo);
242 if (!mInteractive) {
243 // Check for a Carbon UI
244 // This could retrieve a variable sized array but we only need the
245 // first
246 AudioComponentDescription compDesc;
248 kAudioUnitProperty_GetUIComponentList, compDesc);
249 }
250 }
251
252 return true;
253}
@ 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 179 of file AudioUnitEffect.cpp.

180{
181 return false;
182}

◆ IsInteractive()

bool AudioUnitEffect::IsInteractive ( ) const
overridevirtual

Whether the effect needs a dialog for entry of settings.

Implements EffectDefinitionInterface.

Definition at line 174 of file AudioUnitEffect.cpp.

175{
176 return mInteractive;
177}

References mInteractive.

◆ LoadFactoryPreset()

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

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

Returns
nullopt for failure

Implements EffectSettingsManager.

Definition at line 408 of file AudioUnitEffect.cpp.

409{
411 return { nullptr };
412 return {};
413}
bool LoadFactoryPreset(const EffectDefinitionInterface &effect, int id, EffectSettings *pSettings) const

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

Here is the call graph for this function:

◆ LoadPreset()

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

Definition at line 588 of file AudioUnitEffect.cpp.

590{
591 if (MigrateOldConfigFile(group, settings))
592 return { nullptr };
593
594 if (AudioUnitWrapper::LoadPreset(*this, group, settings))
595 return { nullptr };
596 return {};
597}
bool MigrateOldConfigFile(const RegistryPath &group, EffectSettings &settings) const
bool LoadPreset(const EffectDefinitionInterface &effect, const RegistryPath &group, EffectSettings &settings) const

References AudioUnitWrapper::LoadPreset(), MigrateOldConfigFile(), and settings().

Referenced by 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 365 of file AudioUnitEffect.cpp.

367{
368 // First clean all settings, in case any are not defined in parms
369 auto &mySettings = GetSettings(settings);
370 mySettings.ResetValues();
371 auto &map = mySettings.values;
372
373 // Reload preset first
374 if (auto presetKey = FindPresetKey(parms); !presetKey.empty()) {
375 SInt32 value = 0;
376 if (parms.Read(presetKey, &value))
378 }
379
380 // Load settings from CommandParameters
381 // Iterate the config only, not using any AudioUnit handles
382 if (auto [index, key, value] = std::tuple(
383 0L, wxString{}, AudioUnitParameterValue{})
384 ; parms.GetFirstEntry(key, index)
385 ) do {
386 if (auto pKey = ParameterInfo::ParseKey(key)
387 ; pKey && parms.Read(key, &value)
388 )
389 map[*pKey].emplace(mySettings.Intern(key), value);
390 } while(parms.GetNextEntry(key, index));
391 return true;
392}
static RegistryPath FindPresetKey(const CommandParameters &parms)
static std::optional< AudioUnitParameterID > ParseKey(const wxString &key)
Recover the parameter ID from the key, if well formed.

References FindPresetKey(), AudioUnitWrapper::GetSettings(), key, AudioUnitWrapper::LoadFactoryPreset(), 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()

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

Change settings to a user-named preset

Returns
nullopt for failure

Implements EffectSettingsManager.

Definition at line 394 of file AudioUnitEffect.cpp.

396{
397 // To do: externalize state so const_cast isn't needed
398 return const_cast<AudioUnitEffect*>(this)->LoadPreset(name, settings);
399}
An Effect class that handles a wide range of effects. ??Mac only??
OptionalMessage LoadPreset(const RegistryPath &group, EffectSettings &settings) const

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 204 of file AudioUnitEffect.cpp.

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

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 298 of file AudioUnitEffect.cpp.

299{
301 FetchSettings(settings, true);
302 return EffectSettings::Make<AudioUnitEffectSettings>(std::move(settings));
303}
bool FetchSettings(AudioUnitEffectSettings &settings, bool fetchValues, bool fetchPreset=false) const
May allocate memory, so should be called only in the main thread.

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 568 of file AudioUnitEffect.cpp.

570{
571 // Migration of very old format configuration file, should not normally
572 // happen and perhaps this code can be abandoned
573 // Attempt to load old preset parameters and resave using new method
574 constexpr auto oldKey = L"Parameters";
575 wxString parms;
577 group, oldKey, parms, wxEmptyString)) {
579 if (eap.SetParameters(parms))
580 if (LoadSettings(eap, settings))
581 if (SavePreset(group, GetSettings(settings)))
582 RemoveConfig(*this, PluginSettings::Private, group, oldKey);
583 return true;
584 }
585 return false;
586}
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,
const EffectOutputs pOutputs 
)
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
pOutputsnull, or else points to outputs with 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 433 of file AudioUnitEffect.cpp.

436{
437 mParent = S.GetParent();
438 return AudioUnitValidator::Create(*this, S, mUIType, instance, access);
439}
#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 184 of file AudioUnitEffect.cpp.

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

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

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 73 of file AudioUnitEffect.cpp.

76{
77 // Base64 encode the returned binary property list
78 auto parms = wxBase64Encode(blob, len);
79 if (!allowEmpty && parms.IsEmpty())
80 return XO("Failed to encode preset from \"%s\"").Format(path);
81
82 // And write it to the config
83 if (!SetConfig(*this, PluginSettings::Private, group, PRESET_KEY, parms))
84 return XO("Unable to store preset in config file");
85 return {};
86}
#define PRESET_KEY
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 599 of file AudioUnitEffect.cpp.

601{
602 wxCFStringRef cfname(wxFileNameFromPath(group));
603 const auto &[data, _] = MakeBlob(*this, settings, cfname, true);
604 if (!data)
605 return false;
606
607 // Nothing to do if we don't have any data
608 if (const auto length = CFDataGetLength(data.get())) {
609 auto error =
610 SaveBlobToConfig(group, {}, CFDataGetBytePtr(data.get()), length);
611 if (!error.empty())
612 return false;
613 }
614 return true;
615}
#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 347 of file AudioUnitEffect.cpp.

349{
350 const auto &mySettings = GetSettings(settings);
351 if (mySettings.mPresetNumber) {
352 const auto key = ChoosePresetKey(settings);
353 parms.Write(key, *mySettings.mPresetNumber);
354 }
355
356 // Save settings into CommandParameters
357 // Iterate the map only, not using any AudioUnit handles
358 for (auto &[ID, pPair] : mySettings.values)
359 if (pPair)
360 // Write names, not numbers, as keys in the config file
361 parms.Write(pPair->first, pPair->second);
362 return true;
363}
static RegistryPath ChoosePresetKey(const EffectSettings &settings)

References ChoosePresetKey(), AudioUnitWrapper::GetSettings(), key, and settings().

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 401 of file AudioUnitEffect.cpp.

403{
405}

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 286 of file AudioUnitEffect.cpp.

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

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

Here is the call graph for this function:

◆ ShowOptions()

void AudioUnitEffect::ShowOptions ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 553 of file AudioUnitEffect.cpp.

554{
556 if (dlg.ShowModal()) {
557 // Save changed values to the config file
561 }
562}

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 191 of file AudioUnitEffect.cpp.

192{
193 bool supports = false;
195 [&supports](const ParameterInfo &pi, AudioUnitParameterID) {
196 if (pi.mInfo.flags & kAudioUnitParameterFlag_IsWritable)
197 supports = true;
198 // Search only until we find one, that's all we need to know
199 return !supports;
200 });
201 return supports;
202}
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 146 of file AudioUnitEffect.h.

Referenced by InitializePlugin(), and IsInteractive().

◆ mName

const wxString AudioUnitEffect::mName
private

Definition at line 143 of file AudioUnitEffect.h.

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

◆ mParent

wxWindow* AudioUnitEffect::mParent {}
private

Definition at line 149 of file AudioUnitEffect.h.

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

◆ mPath

const PluginPath AudioUnitEffect::mPath
private

Definition at line 142 of file AudioUnitEffect.h.

Referenced by GetPath().

◆ mUIType

wxString AudioUnitEffect::mUIType
private

Definition at line 150 of file AudioUnitEffect.h.

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

◆ mUseLatency

bool AudioUnitEffect::mUseLatency { true }
private

Definition at line 147 of file AudioUnitEffect.h.

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

◆ mVendor

const wxString AudioUnitEffect::mVendor
private

Definition at line 144 of file AudioUnitEffect.h.

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


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