Audacity 3.2.0
Public Types | Public Member Functions | Public Attributes | 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 AudioUnitWrapper
using Parameters = PackedArray::Ptr< const AudioUnitParameterID >
 
using ParameterVisitor = std::function< bool(const ParameterInfo &pi, AudioUnitParameterID ID) >
 Return value: if true, continue visiting. 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...
 
bool SupportsRealtime () const override
 Whether the effect supports realtime previewing (while audio is playing). 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...
 
unsigned GetAudioInCount () const override
 How many input buffers to allocate at once. More...
 
unsigned GetAudioOutCount () const override
 How many output buffers to allocate at once. More...
 
int GetMidiInCount () const override
 Function that has not yet found a use. More...
 
int GetMidiOutCount () const override
 Function that has not yet found a use. More...
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
sampleCount GetLatency () override
 
bool ProcessInitialize (EffectSettings &settings, sampleCount totalLen, ChannelNames chanMap) override
 
bool ProcessFinalize () override
 
size_t ProcessBlock (EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen) override
 Called for destructive effect computation. More...
 
bool RealtimeInitialize (EffectSettings &settings) override
 
bool RealtimeAddProcessor (EffectSettings &settings, unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize (EffectSettings &settings) noexcept override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () noexcept override
 
bool RealtimeProcessStart (EffectSettings &settings) override
 
size_t RealtimeProcess (int group, EffectSettings &settings, const float *const *inbuf, float *const *outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd (EffectSettings &settings) noexcept override
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal) override
 
bool InitializeInstance ()
 
bool InitializePlugin ()
 
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
std::shared_ptr< EffectInstanceDoMakeInstance ()
 
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 CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets (const EffectSettings &settings) const override
 
void ImportPresets (EffectSettings &settings) override
 
bool HasOptions () override
 
void ShowOptions () override
 
AudioUnitEffectSettingsGetSettings (EffectSettings &) const
 This function will be rewritten when the effect is really stateless. More...
 
const AudioUnitEffectSettingsGetSettings (const EffectSettings &) const
 This function will be rewritten when the effect is really stateless. More...
 
- Public Member Functions inherited from StatefulPerTrackEffect
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
virtual sampleCount GetLatency ()
 
virtual bool ProcessInitialize (EffectSettings &settings, sampleCount totalLen, ChannelNames chanMap=nullptr)
 
virtual bool ProcessFinalize ()
 
virtual size_t ProcessBlock (EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen)
 Called for destructive effect computation. More...
 
- Public Member Functions inherited from StatefulEffectBase
virtual bool Init ()
 Call once to set up state for whole list of tracks to be processed. More...
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 Actually do the effect here. More...
 
virtual void SetSampleRate (double rate)
 
virtual bool RealtimeInitialize (EffectSettings &settings)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume () noexcept
 
virtual bool RealtimeProcessStart (EffectSettings &settings)
 
virtual size_t RealtimeProcess (int group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
 
virtual bool RealtimeProcessEnd (EffectSettings &settings) noexcept
 
virtual bool RealtimeFinalize (EffectSettings &settings) noexcept
 
virtual size_t SetBlockSize (size_t maxBlockSize)
 
virtual size_t GetBlockSize () const
 
virtual bool Init ()
 Call once to set up state for whole list of tracks to be processed. More...
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 Actually do the effect here. More...
 
virtual void SetSampleRate (double rate)
 
virtual bool RealtimeInitialize (EffectSettings &settings)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume () noexcept
 
virtual bool RealtimeProcessStart (EffectSettings &settings)
 
virtual size_t RealtimeProcess (int group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
 
virtual bool RealtimeProcessEnd (EffectSettings &settings) noexcept
 
virtual bool RealtimeFinalize (EffectSettings &settings) noexcept
 
virtual size_t SetBlockSize (size_t maxBlockSize)
 
virtual size_t GetBlockSize () const
 
- 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...
 
bool SupportsRealtime () const override
 Whether the effect supports realtime previewing (while audio is playing). 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...
 
unsigned GetAudioInCount () const override
 How many input buffers to allocate at once. More...
 
unsigned GetAudioOutCount () const override
 How many output buffers to allocate at once. More...
 
virtual const EffectParameterMethodsParameters () const
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false) override
 
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, EffectInstance &instance, 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, 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
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, EffectInstance &instance, EffectSettingsAccess &access, bool forceModal=false)=0
 Usually applies factory to self and given access. 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...
 
virtual unsigned GetAudioInCount () const =0
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const =0
 How many output buffers to allocate at once. More...
 
virtual int GetMidiInCount () const
 Function that has not yet found a use. More...
 
virtual int GetMidiOutCount () const
 Function that has not yet found a use. 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 EffectSettings MakeSettings () const
 
virtual bool CopySettingsContents (const EffectSettings &src, EffectSettings &dst) const
 Update one settings object from another. 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 bool SupportsRealtime () const =0
 Whether the effect supports realtime previewing (while audio is playing). More...
 
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
 
- Public 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
 
bool StoreSettings (const AudioUnitEffectSettings &settings) const
 
bool CreateAudioUnit ()
 
AudioUnit GetAudioUnit () const
 
AudioComponent GetComponent () const
 
const ParametersGetParameters () const
 

Public Attributes

AudioUnitEffectArray mSlaves
 

Private Member Functions

bool SetRateAndChannels ()
 
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
 
OSStatus Render (AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
 
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
 
bool BypassEffect (bool bypass)
 

Static Private Member Functions

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

Private Attributes

AudioUnitEffectSettings mSettings
 
const PluginPath mPath
 
const wxString mName
 
const wxString mVendor
 
AudioUnitCleanup< AudioUnit, AudioUnitUninitialize > mInitialization
 
unsigned mAudioIns { 2 }
 
unsigned mAudioOuts { 2 }
 
bool mInteractive { false }
 
bool mLatencyDone { false }
 
UInt32 mBlockSize { 0 }
 
Float64 mSampleRate { 44100.0 }
 
bool mUseLatency { true }
 
AudioTimeStamp mTimeStamp {}
 
PackedArray::Ptr< AudioBufferList > mInputList
 
PackedArray::Ptr< AudioBufferList > mOutputList
 
wxWindow * mParent {}
 
wxString mUIType
 
bool mIsGraphical { false }
 
AudioUnitEffect *const mMaster
 

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
 
virtual bool ValidateUI (EffectSettings &settings)=0
 
virtual bool CloseUI ()=0
 
- Protected Attributes inherited from StatefulEffectBase
double mSampleRate {}
 
- 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 }
 
- Protected Attributes inherited from EffectUIClientInterface
friend EffectUIValidator
 
friend DefaultEffectUIValidator
 
- Protected Attributes inherited from AudioUnitWrapper
const AudioComponent mComponent
 
AudioUnitCleanup< AudioUnit, AudioComponentInstanceDispose > mUnit
 
Parameters mOwnParameters
 
ParametersmParameters
 
- Static Protected Attributes inherited from EffectBase
static int nEffectsDone = 0
 

Detailed Description

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

Definition at line 42 of file AudioUnitEffect.h.

Member Typedef Documentation

◆ Parameters

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

Definition at line 47 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 , mMaster{ master }
103{
104}
const TranslatableString name
Definition: Distortion.cpp:82
AudioUnitEffect *const mMaster
const wxString mName
const wxString mVendor
const PluginPath mPath
Common base class for AudioUnitEffect and its Instance.

◆ ~AudioUnitEffect()

AudioUnitEffect::~AudioUnitEffect ( )
virtual

Definition at line 106 of file AudioUnitEffect.cpp.

107{
108}

Member Function Documentation

◆ BypassEffect()

bool AudioUnitEffect::BypassEffect ( bool  bypass)
private

Definition at line 1332 of file AudioUnitEffect.cpp.

1333{
1334 UInt32 value = (bypass ? 1 : 0);
1335 return !SetProperty(kAudioUnitProperty_BypassEffect, value);
1336}
OSStatus SetProperty(AudioUnitPropertyID inID, const T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0) const

References AudioUnitWrapper::SetProperty().

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

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

◆ CanExportPresets()

bool AudioUnitEffect::CanExportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 877 of file AudioUnitEffect.cpp.

878{
879 return true;
880}

◆ CloseUI()

bool AudioUnitEffect::CloseUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 866 of file AudioUnitEffect.cpp.

867{
868#ifdef __WXMAC__
869#ifdef __WX_EVTLOOP_BUSY_WAITING__
870 wxEventLoop::SetBusyWaiting(false);
871#endif
872#endif
873 mParent = nullptr;
874 return true;
875}
wxWindow * mParent

References mParent.

◆ DoMakeInstance()

std::shared_ptr< EffectInstance > AudioUnitEffect::DoMakeInstance ( )

Definition at line 256 of file AudioUnitEffect.cpp.

257{
258 if (mMaster)
259 // This is a slave
261 return std::make_shared<AudioUnitInstance>(*this, mComponent, mParameters);
262}
Parameters & mParameters
const AudioComponent mComponent

References InitializeInstance(), AudioUnitWrapper::mComponent, mMaster, and AudioUnitWrapper::mParameters.

Referenced by MakeInstance().

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

◆ Export()

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

Definition at line 1115 of file AudioUnitEffect.cpp.

1117{
1118 // Create the file
1119 wxFFile f(path, wxT("wb"));
1120 if (!f.IsOpened())
1121 return XO("Couldn't open \"%s\"").Format(path);
1122
1123 // First set the name of the preset
1124 wxCFStringRef cfname(wxFileName(path).GetName());
1125
1126 const auto &[data, message] = MakeBlob(settings, cfname, false);
1127 if (!data || !message.empty())
1128 return message;
1129
1130 // Write XML data
1131 auto length = CFDataGetLength(data.get());
1132 if (f.Write(CFDataGetBytePtr(data.get()), length) != length || f.Error())
1133 return XO("Failed to write XML preset to \"%s\"").Format(path);
1134
1135 f.Close();
1136 return {};
1137}
#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(), 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 882 of file AudioUnitEffect.cpp.

883{
884 // Generate the user domain path
885 wxFileName fn;
886 fn.SetPath(PRESET_USER_PATH);
887 fn.AppendDir(mVendor);
888 fn.AppendDir(mName);
889 fn.Normalize();
890 FilePath path = fn.GetFullPath();
891
892 if (!fn.Mkdir(fn.GetFullPath(), 0755, wxPATH_MKDIR_FULL)) {
893 wxLogError(wxT("Couldn't create the \"%s\" directory"), fn.GetPath());
894 return;
895 }
896
897 // Ask the user for the name to use
898 //
899 // Passing a valid parent will cause some effects dialogs to malfunction
900 // upon returning from the SelectFile().
901 path = SelectFile(FileNames::Operation::_None,
902 XO("Export Audio Unit Preset As %s:").Format(fn.GetFullPath()),
903 fn.GetFullPath(),
904 wxEmptyString,
905 wxT("aupreset"),
906 {
907 { XO("Standard Audio Unit preset file"), { wxT("aupreset") }, true },
908 },
909 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
910 NULL);
911
912 // User canceled...
913 if (path.empty())
914 return;
915
916 auto msg = Export(GetSettings(settings), path);
917 if (!msg.empty())
919 XO("Could not export \"%s\" preset\n\n%s").Format(path, msg),
920 XO("Export Audio Unit Presets"),
921 wxOK | wxCENTRE,
922 mParent);
923}
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
AudioUnitEffectSettings & GetSettings(EffectSettings &) const
This function will be rewritten when the effect is really stateless.
Abstract base class used in importing a file.

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

Here is the call graph for this function:

◆ GetAudioInCount()

unsigned AudioUnitEffect::GetAudioInCount ( ) const
overridevirtual

How many input buffers to allocate at once.

If the effect ALWAYS processes channels independently, this can return 1

Implements EffectInstanceFactory.

Definition at line 410 of file AudioUnitEffect.cpp.

411{
412 return mAudioIns;
413}

References mAudioIns.

◆ GetAudioOutCount()

unsigned AudioUnitEffect::GetAudioOutCount ( ) const
overridevirtual

How many output buffers to allocate at once.

Implements EffectInstanceFactory.

Definition at line 415 of file AudioUnitEffect.cpp.

416{
417 return mAudioOuts;
418}

References mAudioOuts.

◆ GetBlockSize()

size_t AudioUnitEffect::GetBlockSize ( ) const
overridevirtual

Default implementation returns mEffectBlockSize

Reimplemented from StatefulEffectBase.

Definition at line 440 of file AudioUnitEffect.cpp.

441{
442 return mBlockSize;
443}

References mBlockSize.

◆ GetChannelCounts()

void AudioUnitEffect::GetChannelCounts ( )
private

Definition at line 1233 of file AudioUnitEffect.cpp.

1234{
1235 // Does AU have channel info
1237 if (GetVariableSizeProperty(kAudioUnitProperty_SupportedNumChannels, info)) {
1238 // None supplied. Apparently all FX type units can do any number of INs
1239 // and OUTs as long as they are the same number. In this case, we'll
1240 // just say stereo.
1241 //
1242 // We should probably check to make sure we're dealing with an FX type.
1243 mAudioIns = 2;
1244 mAudioOuts = 2;
1245 return;
1246 }
1247
1248 // This is where it gets weird...not sure what is the best
1249 // way to do this really. If we knew how many ins/outs we
1250 // really needed, we could make a better choice.
1251
1252 bool haven2m = false; // nothing -> mono
1253 bool haven2s = false; // nothing -> stereo
1254 bool havem2n = false; // mono -> nothing
1255 bool haves2n = false; // stereo -> nothing
1256 bool havem2m = false; // mono -> mono
1257 bool haves2s = false; // stereo -> stereo
1258 bool havem2s = false; // mono -> stereo
1259 bool haves2m = false; // stereo -> mono
1260
1261 mAudioIns = 2;
1262 mAudioOuts = 2;
1263
1264 // Look only for exact channel constraints
1265 for (auto &ci : info) {
1266 int ic = ci.inChannels;
1267 int oc = ci.outChannels;
1268
1269 if (ic < 0 && oc >= 0)
1270 ic = 2;
1271 else if (ic >= 0 && oc < 0)
1272 oc = 2;
1273 else if (ic < 0 && oc < 0) {
1274 ic = 2;
1275 oc = 2;
1276 }
1277
1278 if (ic == 2 && oc == 2)
1279 haves2s = true;
1280 else if (ic == 1 && oc == 1)
1281 havem2m = true;
1282 else if (ic == 1 && oc == 2)
1283 havem2s = true;
1284 else if (ic == 2 && oc == 1)
1285 haves2m = true;
1286 else if (ic == 0 && oc == 2)
1287 haven2s = true;
1288 else if (ic == 0 && oc == 1)
1289 haven2m = true;
1290 else if (ic == 1 && oc == 0)
1291 havem2n = true;
1292 else if (ic == 2 && oc == 0)
1293 haves2n = true;
1294 }
1295
1296 if (haves2s) {
1297 mAudioIns = 2;
1298 mAudioOuts = 2;
1299 }
1300 else if (havem2m) {
1301 mAudioIns = 1;
1302 mAudioOuts = 1;
1303 }
1304 else if (havem2s) {
1305 mAudioIns = 1;
1306 mAudioOuts = 2;
1307 }
1308 else if (haves2m) {
1309 mAudioIns = 2;
1310 mAudioOuts = 1;
1311 }
1312 else if (haven2m) {
1313 mAudioIns = 0;
1314 mAudioOuts = 1;
1315 }
1316 else if (haven2s) {
1317 mAudioIns = 0;
1318 mAudioOuts = 2;
1319 }
1320 else if (haves2n) {
1321 mAudioIns = 2;
1322 mAudioOuts = 0;
1323 }
1324 else if (havem2n) {
1325 mAudioIns = 1;
1326 mAudioOuts = 0;
1327 }
1328
1329 return;
1330}
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(), mAudioIns, and mAudioOuts.

Referenced by InitializeInstance().

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

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

References XO.

◆ GetFactoryPresets()

RegistryPaths AudioUnitEffect::GetFactoryPresets ( ) const
overridevirtual

Report names of factory presets.

Implements EffectSettingsManager.

Definition at line 770 of file AudioUnitEffect.cpp.

771{
772 RegistryPaths presets;
773
774 // Retrieve the list of factory presets
775 CF_ptr<CFArrayRef> array;
776 if (!GetFixedSizeProperty(kAudioUnitProperty_FactoryPresets, array))
777 for (CFIndex i = 0, cnt = CFArrayGetCount(array.get()); i < cnt; ++i)
778 presets.push_back(wxCFStringRef::AsString(
779 static_cast<const AUPreset*>(CFArrayGetValueAtIndex(array.get(), i))
780 ->presetName));
781 return presets;
782}
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 171 of file AudioUnitEffect.cpp.

172{
174}
#define AUDIOUNITEFFECTS_FAMILY

References AUDIOUNITEFFECTS_FAMILY.

◆ GetLatency()

sampleCount AudioUnitEffect::GetLatency ( )
overridevirtual

Called for destructive, non-realtime effect computation Default implementation returns zero

Reimplemented from StatefulPerTrackEffect.

Definition at line 445 of file AudioUnitEffect.cpp.

446{
447 // Retrieve the latency (can be updated via an event)
448 if (mUseLatency && !mLatencyDone) {
449 Float64 latency = 0.0;
450 if (!GetFixedSizeProperty(kAudioUnitProperty_Latency, latency)) {
451 mLatencyDone = true;
452 return sampleCount{ latency * mSampleRate };
453 }
454 }
455 return 0;
456}
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18

References AudioUnitWrapper::GetFixedSizeProperty(), mLatencyDone, mSampleRate, and mUseLatency.

Here is the call graph for this function:

◆ GetMidiInCount()

int AudioUnitEffect::GetMidiInCount ( ) const
overridevirtual

Function that has not yet found a use.

Reimplemented from EffectInstanceFactory.

Definition at line 420 of file AudioUnitEffect.cpp.

421{
422 return 0;
423}

◆ GetMidiOutCount()

int AudioUnitEffect::GetMidiOutCount ( ) const
overridevirtual

Function that has not yet found a use.

Reimplemented from EffectInstanceFactory.

Definition at line 425 of file AudioUnitEffect.cpp.

426{
427 return 0;
428}

◆ GetPath()

PluginPath AudioUnitEffect::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 114 of file AudioUnitEffect.cpp.

115{
116 return mPath;
117}

References mPath.

◆ GetSettings() [1/2]

const AudioUnitEffectSettings & AudioUnitEffect::GetSettings ( const EffectSettings ) const
inline

This function will be rewritten when the effect is really stateless.

Definition at line 191 of file AudioUnitEffect.h.

192 { return mSettings; }
AudioUnitEffectSettings mSettings

References mSettings.

◆ GetSettings() [2/2]

AudioUnitEffectSettings & AudioUnitEffect::GetSettings ( EffectSettings ) const
inline

This function will be rewritten when the effect is really stateless.

Definition at line 188 of file AudioUnitEffect.h.

189 { return const_cast<AudioUnitEffect*>(this)->mSettings; }
An Effect class that handles a wide range of effects. ??Mac only??

References mSettings.

Referenced by ExportPresets(), ImportPresets(), LoadFactoryPreset(), LoadPreset(), LoadSettings(), MigrateOldConfigFile(), RealtimeAddProcessor(), SaveSettings(), and SaveUserPreset().

Here is the caller graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol AudioUnitEffect::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 119 of file AudioUnitEffect.cpp.

120{
121 return mName;
122}

References mName.

Referenced by SetRateAndChannels().

Here is the caller graph for this function:

◆ GetType()

EffectType AudioUnitEffect::GetType ( ) const
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 151 of file AudioUnitEffect.cpp.

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

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

Referenced by ShowClientInterface().

Here is the caller graph for this function:

◆ GetVendor()

VendorSymbol AudioUnitEffect::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 124 of file AudioUnitEffect.cpp.

125{
126 return { mVendor };
127}

References mVendor.

◆ GetVersion()

wxString AudioUnitEffect::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 129 of file AudioUnitEffect.cpp.

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

References AudioUnitWrapper::mComponent.

◆ HasOptions()

bool AudioUnitEffect::HasOptions ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 961 of file AudioUnitEffect.cpp.

962{
963 return true;
964}

◆ Import()

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

Definition at line 1139 of file AudioUnitEffect.cpp.

1141{
1142 // Open the preset
1143 wxFFile f(path, wxT("r"));
1144 if (!f.IsOpened())
1145 return XO("Couldn't open \"%s\"").Format(path);
1146
1147 // Load it into the buffer
1148 size_t len = f.Length();
1149 wxMemoryBuffer buf(len);
1150 if (f.Read(buf.GetData(), len) != len || f.Error())
1151 return XO("Unable to read the preset from \"%s\"").Format(path);
1152
1153 const auto error = InterpretBlob(settings, path, buf);
1154 if (!error.empty())
1155 return error;
1156
1157 return {};
1158}
TranslatableString InterpretBlob(AudioUnitEffectSettings &settings, const wxString &group, const wxMemoryBuffer &buf) const
Interpret the dump made before by MakeBlob.

References AudioUnitWrapper::InterpretBlob(), settings(), 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 925 of file AudioUnitEffect.cpp.

926{
927 // Generate the user domain path
928 wxFileName fn;
929 fn.SetPath(PRESET_USER_PATH);
930 fn.AppendDir(mVendor);
931 fn.AppendDir(mName);
932 fn.Normalize();
933 FilePath path = fn.GetFullPath();
934
935 // Ask the user for the name to use
936 //
937 // Passing a valid parent will cause some effects dialogs to malfunction
938 // upon returning from the SelectFile().
939 path = SelectFile(FileNames::Operation::_None,
940 XO("Import Audio Unit Preset As %s:").Format(fn.GetFullPath()),
941 fn.GetFullPath(), wxEmptyString, wxT("aupreset"),
942 {
943 { XO("Standard Audio Unit preset file"), { wxT("aupreset") }, true },
944 },
945 wxFD_OPEN | wxRESIZE_BORDER,
946 nullptr);
947
948 // User canceled...
949 if (path.empty())
950 return;
951
952 auto msg = Import(GetSettings(settings), path);
953 if (!msg.empty())
955 XO("Could not import \"%s\" preset\n\n%s").Format(path, msg),
956 XO("Import Audio Unit Presets"),
957 wxOK | wxCENTRE,
958 mParent);
959}
TranslatableString Import(AudioUnitEffectSettings &settings, const wxString &path) const

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

Here is the call graph for this function:

◆ InitializeInstance()

bool AudioUnitEffect::InitializeInstance ( )

Definition at line 234 of file AudioUnitEffect.cpp.

235{
236 if (!CreateAudioUnit())
237 return false;
238
239 mSampleRate = 44100;
242
243 // Retrieve the desired number of frames per slice
245 kAudioUnitProperty_MaximumFramesPerSlice, mBlockSize))
246 // Call failed? Then supply a default:
247 mBlockSize = 512;
248 return true;
249}

References AudioUnitWrapper::CreateAudioUnit(), GetChannelCounts(), AudioUnitWrapper::GetFixedSizeProperty(), mBlockSize, mSampleRate, and SetRateAndChannels().

Referenced by DoMakeInstance(), and InitializePlugin().

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

◆ InitializePlugin()

bool AudioUnitEffect::InitializePlugin ( )

Definition at line 268 of file AudioUnitEffect.cpp.

269{
270 // To implement the services of EffectPlugin -- such as, a query of the
271 // set of effect parameters, so that we can implement MakeSettings -- we
272 // also need what is called an AudioComponentInstance, also called an
273 // AudioUnit.
274 // It's not just for implementing EffectInstance. AudioUnits is unlike other
275 // third party effect families that distinguish the notions of plug-in and
276 // instance.
277
278 // When AudioUnitEffect implements its own proper Instance class, this
279 // should call CreateAudioUnit() directly and not do the rest of
280 // InitializeInstance.
281 if (!InitializeInstance())
282 return false;
283
284 // Determine interactivity
286 if (!mInteractive) {
287 // Check for a Cocoa UI
288 // This could retrieve a variable-size property, but we only look at
289 // the first element.
290 AudioUnitCocoaViewInfo cocoaViewInfo;
292 !GetFixedSizeProperty(kAudioUnitProperty_CocoaUI, cocoaViewInfo);
293 if (!mInteractive) {
294 // Check for a Carbon UI
295 // This could retrieve a variable sized array but we only need the
296 // first
297 AudioComponentDescription compDesc;
299 kAudioUnitProperty_GetUIComponentList, compDesc);
300 }
301 }
302
303 // Consult preferences
304 // Decide mUseLatency, which affects GetLatency(), which is actually used
305 // so far only in destructive effect processing
307 mUseLatency, true);
308 // Decide whether to build plain or fancy user interfaces
310 mUIType, FullValue.MSGID().GET() /* Config stores un-localized string */);
311
312 return true;
313}
constexpr auto OptionsKey
constexpr auto UseLatencyKey
constexpr auto UITypeKey
static const auto FullValue
size_t Count(const Ptr< Type, BaseDeleter > &p)
Find out how many elements were allocated with a Ptr.
Definition: PackedArray.h:143
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)

References PackedArray::Count(), FullValue, PluginSettings::GetConfig(), AudioUnitWrapper::GetFixedSizeProperty(), InitializeInstance(), mInteractive, AudioUnitWrapper::mParameters, mUIType, mUseLatency, OptionsKey, PluginSettings::Shared, UITypeKey, and UseLatencyKey.

Referenced by AudioUnitEffectsModule::DiscoverPluginsAtPath().

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

182{
183 return false;
184}

◆ IsGraphicalUI()

bool AudioUnitEffect::IsGraphicalUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 853 of file AudioUnitEffect.cpp.

854{
855 return mUIType != wxT("Plain");
856}

References mUIType.

◆ IsInteractive()

bool AudioUnitEffect::IsInteractive ( ) const
overridevirtual

Whether the effect needs a dialog for entry of settings.

Implements EffectDefinitionInterface.

Definition at line 176 of file AudioUnitEffect.cpp.

177{
178 return mInteractive;
179}

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

752{
753 // Retrieve the list of factory presets
754 CF_ptr<CFArrayRef> array;
755 if (GetFixedSizeProperty(kAudioUnitProperty_FactoryPresets, array) ||
756 id < 0 || id >= CFArrayGetCount(array.get()))
757 return false;
758
759 // Mutate the scratch pad AudioUnit in the effect
760 if (!SetProperty(kAudioUnitProperty_PresentPreset,
761 *static_cast<const AUPreset*>(CFArrayGetValueAtIndex(array.get(), id)))) {
762 // Repopulate the AudioUnitEffectSettings from the change of state in
763 // the AudioUnit
765 return true;
766 }
767 return false;
768}
bool FetchSettings(AudioUnitEffectSettings &settings) const

References AudioUnitWrapper::FetchSettings(), AudioUnitWrapper::GetFixedSizeProperty(), GetSettings(), 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 1001 of file AudioUnitEffect.cpp.

1003{
1004 if (MigrateOldConfigFile(group, settings))
1005 return true;
1006
1007 // Retrieve the preset
1008 wxString parms;
1009 if (!GetConfig(*this, PluginSettings::Private, group, PRESET_KEY, parms,
1010 wxEmptyString)) {
1011 // Commented "CurrentSettings" gets tried a lot and useless messages appear
1012 // in the log
1013 //wxLogError(wxT("Preset key \"%s\" not found in group \"%s\""), PRESET_KEY, group);
1014 return false;
1015 }
1016
1017 // Decode it, complementary to what SaveBlobToConfig did
1018 auto error =
1019 InterpretBlob(GetSettings(settings), group, wxBase64Decode(parms));
1020 if (!error.empty()) {
1021 wxLogError(error.Debug());
1022 return false;
1023 }
1024
1025 return true;
1026}
#define PRESET_KEY
bool MigrateOldConfigFile(const RegistryPath &group, EffectSettings &settings) const

References PluginSettings::GetConfig(), GetSettings(), AudioUnitWrapper::InterpretBlob(), MigrateOldConfigFile(), PRESET_KEY, PluginSettings::Private, 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

Restore settings from keys and values.

Returns
true on success

Implements EffectSettingsManager.

Definition at line 669 of file AudioUnitEffect.cpp.

671{
672 // First clean all settings, in case any are not defined in parms
673 auto &mySettings = GetSettings(settings);
674 mySettings.ResetValues();
675
676 auto &map = mySettings.values;
677 const auto end = map.end();
678
679 // Load settings from CommandParameters
680 ForEachParameter([this, &parms, &map, end](
681 const ParameterInfo &pi, AudioUnitParameterID ID
682 ){
683 if (pi.mName) {
684 double d = 0.0;
685 if (auto iter = map.find(ID);
686 iter != end && parms.Read(*pi.mName, &d))
687 iter->second = d;
688 }
689 return true;
690 });
691 return true;
692}
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
void ForEachParameter(ParameterVisitor visitor) const

References PackedArray::end(), AudioUnitWrapper::ForEachParameter(), GetSettings(), AudioUnitWrapper::ParameterInfo::mName, 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 738 of file AudioUnitEffect.cpp.

740{
741 // To do: externalize state so const_cast isn't needed
742 return const_cast<AudioUnitEffect*>(this)->LoadPreset(name, settings);
743}
bool 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

Implements EffectInstanceFactory.

Definition at line 251 of file AudioUnitEffect.cpp.

252{
253 return const_cast<AudioUnitEffect*>(this)->DoMakeInstance();
254}
std::shared_ptr< EffectInstance > DoMakeInstance()

References DoMakeInstance().

Here is the call graph for this function:

◆ MigrateOldConfigFile()

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

Definition at line 981 of file AudioUnitEffect.cpp.

983{
984 // Migration of very old format configuration file, should not normally
985 // happen and perhaps this code can be abandoned
986 // Attempt to load old preset parameters and resave using new method
987 constexpr auto oldKey = L"Parameters";
988 wxString parms;
990 group, oldKey, parms, wxEmptyString)) {
992 if (eap.SetParameters(parms))
993 if (LoadSettings(eap, settings))
994 if (SavePreset(group, GetSettings(settings)))
995 RemoveConfig(*this, PluginSettings::Private, group, oldKey);
996 return true;
997 }
998 return false;
999}
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
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(), 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 846 of file AudioUnitEffect.cpp.

848{
849 mParent = S.GetParent();
850 return AudioUnitValidator::Create(*this, S, mUIType, instance, access);
851}
#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:

◆ ProcessBlock()

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

Called for destructive effect computation.

Reimplemented from StatefulPerTrackEffect.

Definition at line 510 of file AudioUnitEffect.cpp.

512{
513 // mAudioIns and mAudioOuts don't change after plugin initialization,
514 // so ProcessInitialize() made sufficient allocations
516 for (size_t i = 0; i < mAudioIns; ++i)
517 mInputList[i] = { 1, static_cast<UInt32>(sizeof(float) * blockLen),
518 const_cast<float*>(inBlock[i]) };
519
520 // See previous comment
522 for (size_t i = 0; i < mAudioOuts; ++i)
523 mOutputList[i] = { 1, static_cast<UInt32>(sizeof(float) * blockLen),
524 outBlock[i] };
525
526 AudioUnitRenderActionFlags flags = 0;
527 OSStatus result;
528
529 result = AudioUnitRender(mUnit.get(),
530 &flags,
531 &mTimeStamp,
532 0,
533 blockLen,
534 mOutputList.get());
535 if (result != noErr) {
536 wxLogError("Render failed: %d %4.4s\n",
537 static_cast<int>(result), reinterpret_cast<char *>(&result));
538 return 0;
539 }
540
541 mTimeStamp.mSampleTime += blockLen;
542 return blockLen;
543}
AudioTimeStamp mTimeStamp
PackedArray::Ptr< AudioBufferList > mOutputList
PackedArray::Ptr< AudioBufferList > mInputList
AudioUnitCleanup< AudioUnit, AudioComponentInstanceDispose > mUnit

References PackedArray::Count(), mAudioIns, mAudioOuts, mInputList, mOutputList, mTimeStamp, and AudioUnitWrapper::mUnit.

Here is the call graph for this function:

◆ ProcessFinalize()

bool AudioUnitEffect::ProcessFinalize ( )
overridevirtual

Called at end of destructive processing, for each (mono/stereo) track Default implementation does nothing, returns true This may be called during stack unwinding:

Reimplemented from StatefulPerTrackEffect.

Definition at line 503 of file AudioUnitEffect.cpp.

504{
505 mOutputList.reset();
506 mInputList.reset();
507 return true;
508}

References mInputList, and mOutputList.

◆ ProcessInitialize()

bool AudioUnitEffect::ProcessInitialize ( EffectSettings settings,
sampleCount  totalLen,
ChannelNames  chanMap 
)
overridevirtual

Called at start of destructive processing, for each (mono/stereo) track Default implementation does nothing, returns true

Reimplemented from StatefulPerTrackEffect.

Definition at line 470 of file AudioUnitEffect.cpp.

472{
473 mInputList =
474 PackedArray::AllocateCount<AudioBufferList>(mAudioIns)(mAudioIns);
476 PackedArray::AllocateCount<AudioBufferList>(mAudioOuts)(mAudioOuts);
477
478 memset(&mTimeStamp, 0, sizeof(AudioTimeStamp));
479 mTimeStamp.mSampleTime = 0; // This is a double-precision number that should
480 // accumulate the number of frames processed so far
481 mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
482
483 if (!SetRateAndChannels())
484 return false;
485
486 if (SetProperty(kAudioUnitProperty_SetRenderCallback,
488 kAudioUnitScope_Input)) {
489 wxLogError("Setting input render callback failed.\n");
490 return false;
491 }
492
493 if (AudioUnitReset(mUnit.get(), kAudioUnitScope_Global, 0))
494 return false;
495
496 if (!BypassEffect(false))
497 return false;
498
499 mLatencyDone = false;
500 return true;
501}
static OSStatus RenderCallback(void *inRefCon, AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
bool BypassEffect(bool bypass)

References BypassEffect(), mAudioIns, mAudioOuts, mInputList, mLatencyDone, mOutputList, mTimeStamp, AudioUnitWrapper::mUnit, RenderCallback(), AudioUnitWrapper::SetProperty(), and SetRateAndChannels().

Referenced by RealtimeInitialize().

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

◆ RealtimeAddProcessor()

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

Default implementation does nothing, returns true

Reimplemented from StatefulEffectBase.

Definition at line 550 of file AudioUnitEffect.cpp.

552{
553 auto slave = std::make_unique<AudioUnitEffect>(
555 if (!slave->InitializeInstance())
556 return false;
557
558 slave->SetBlockSize(mBlockSize);
559 slave->SetSampleRate(sampleRate);
560
561 if (!slave->StoreSettings(GetSettings(settings)))
562 return false;
563
564 auto pSlave = slave.get();
565 mSlaves.push_back(std::move(slave));
566
567 return pSlave->ProcessInitialize(settings, 0, nullptr);
568}
AudioUnitEffectArray mSlaves

References GetSettings(), mBlockSize, AudioUnitWrapper::mComponent, mName, AudioUnitWrapper::mParameters, mPath, mSlaves, and settings().

Here is the call graph for this function:

◆ RealtimeFinalize()

bool AudioUnitEffect::RealtimeFinalize ( EffectSettings settings)
overridevirtualnoexcept

Default implementation does nothing, returns false

Reimplemented from StatefulEffectBase.

Definition at line 570 of file AudioUnitEffect.cpp.

571{
572return GuardedCall<bool>([&]{
573 for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
574 {
575 mSlaves[i]->ProcessFinalize();
576 }
577 mSlaves.clear();
578 return ProcessFinalize();
579});
580}
bool ProcessFinalize() override

◆ RealtimeInitialize()

bool AudioUnitEffect::RealtimeInitialize ( EffectSettings settings)
overridevirtual

Default implementation does nothing, returns false

Reimplemented from StatefulEffectBase.

Definition at line 545 of file AudioUnitEffect.cpp.

546{
547 return ProcessInitialize(settings, 0, nullptr);
548}
bool ProcessInitialize(EffectSettings &settings, sampleCount totalLen, ChannelNames chanMap) override

References ProcessInitialize(), and settings().

Here is the call graph for this function:

◆ RealtimeProcess()

size_t AudioUnitEffect::RealtimeProcess ( int  group,
EffectSettings settings,
const float *const *  inBuf,
float *const *  outBuf,
size_t  numSamples 
)
overridevirtual

Default implementation does nothing, returns 0

Reimplemented from StatefulEffectBase.

Definition at line 625 of file AudioUnitEffect.cpp.

627{
628 wxASSERT(numSamples <= mBlockSize);
629 return mSlaves[group]->ProcessBlock(settings, inbuf, outbuf, numSamples);
630}

References mBlockSize, mSlaves, and settings().

Here is the call graph for this function:

◆ RealtimeProcessEnd()

bool AudioUnitEffect::RealtimeProcessEnd ( EffectSettings settings)
overridevirtualnoexcept

Default implementation does nothing, returns true

Reimplemented from StatefulEffectBase.

Definition at line 632 of file AudioUnitEffect.cpp.

633{
634 return true;
635}

◆ RealtimeProcessStart()

bool AudioUnitEffect::RealtimeProcessStart ( EffectSettings settings)
overridevirtual

Default implementation does nothing, returns true

Reimplemented from StatefulEffectBase.

Definition at line 620 of file AudioUnitEffect.cpp.

621{
622 return true;
623}

◆ RealtimeResume()

bool AudioUnitEffect::RealtimeResume ( )
overridevirtualnoexcept

Default implementation does nothing, returns true

Reimplemented from StatefulEffectBase.

Definition at line 600 of file AudioUnitEffect.cpp.

601{
602return GuardedCall<bool>([&]{
603 if (!BypassEffect(false))
604 {
605 return false;
606 }
607
608 for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
609 {
610 if (!mSlaves[i]->BypassEffect(false))
611 {
612 return false;
613 }
614 }
615
616 return true;
617});
618}

References BypassEffect(), and mSlaves.

Here is the call graph for this function:

◆ RealtimeSuspend()

bool AudioUnitEffect::RealtimeSuspend ( )
overridevirtual

Default implementation does nothing, returns true

Reimplemented from StatefulEffectBase.

Definition at line 582 of file AudioUnitEffect.cpp.

583{
584 if (!BypassEffect(true))
585 {
586 return false;
587 }
588
589 for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
590 {
591 if (!mSlaves[i]->BypassEffect(true))
592 {
593 return false;
594 }
595 }
596
597 return true;
598}

References BypassEffect(), and mSlaves.

Here is the call graph for this function:

◆ Render()

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

Definition at line 1170 of file AudioUnitEffect.cpp.

1175{
1176 size_t i = 0;
1177 auto size =
1178 std::min<size_t>(ioData->mNumberBuffers, PackedArray::Count(mInputList));
1179 for (; i < size; ++i)
1180 ioData->mBuffers[i].mData = mInputList[i].mData;
1181 // Some defensive code here just in case SDK requests from us an unexpectedly
1182 // large number of buffers:
1183 for (; i < ioData->mNumberBuffers; ++i)
1184 ioData->mBuffers[i].mData = nullptr;
1185 return 0;
1186}
for(int ii=0, nn=names.size();ii< nn;++ii)

References PackedArray::Count(), for(), mInputList, and size.

Referenced by RenderCallback().

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

◆ RenderCallback()

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

Definition at line 1189 of file AudioUnitEffect.cpp.

1195{
1196 return static_cast<AudioUnitEffect *>(inRefCon)->Render(inActionFlags,
1197 inTimeStamp, inBusNumber, inNumFrames, ioData);
1198}
OSStatus Render(AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)

References Render().

Referenced by ProcessInitialize().

Here is the call graph for this function:
Here is the caller 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 1028 of file AudioUnitEffect.cpp.

1030{
1031 wxCFStringRef cfname(wxFileNameFromPath(group));
1032 const auto &[data, _] = MakeBlob(settings, cfname, true);
1033 if (!data)
1034 return false;
1035
1036 // Nothing to do if we don't have any data
1037 if (const auto length = CFDataGetLength(data.get())) {
1038 auto error =
1039 SaveBlobToConfig(group, {}, CFDataGetBytePtr(data.get()), length);
1040 if (!error.empty())
1041 return false;
1042 }
1043 return true;
1044}
#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.

Returns
true on success

Implements EffectSettingsManager.

Definition at line 648 of file AudioUnitEffect.cpp.

650{
651 auto &map = GetSettings(settings).values;
652 const auto end = map.end();
653
654 // Save settings into CommandParameters
655 // Assume settings is an up-to-date cache of AudioUnit state
656 ForEachParameter([this, &parms, &map, end](
657 const ParameterInfo &pi, AudioUnitParameterID ID
658 ){
659 if (pi.mName) {
660 // Write names, not numbers, as keys in the config file
661 if (auto iter = map.find(ID); iter != end)
662 parms.Write(*pi.mName, iter->second);
663 }
664 return true;
665 });
666 return true;
667}

References PackedArray::end(), AudioUnitWrapper::ForEachParameter(), GetSettings(), AudioUnitWrapper::ParameterInfo::mName, settings(), and AudioUnitEffectSettings::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 745 of file AudioUnitEffect.cpp.

747{
749}

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

Here is the call graph for this function:

◆ SetBlockSize()

size_t AudioUnitEffect::SetBlockSize ( size_t  maxBlockSize)
overridevirtual

Default implementation assigns mEffectBlockSize, returns it

Reimplemented from StatefulEffectBase.

Definition at line 435 of file AudioUnitEffect.cpp.

436{
437 return mBlockSize;
438}

References mBlockSize.

◆ SetRateAndChannels()

bool AudioUnitEffect::SetRateAndChannels ( )
private

Definition at line 1046 of file AudioUnitEffect.cpp.

1047{
1048 mInitialization.reset();
1050 // Float64 mSampleRate;
1052
1053 // UInt32 mFormatID;
1054 kAudioFormatLinearPCM,
1055
1056 // UInt32 mFormatFlags;
1057 (kAudioFormatFlagsNativeFloatPacked |
1058 kAudioFormatFlagIsNonInterleaved),
1059
1060 // UInt32 mBytesPerPacket;
1061 sizeof(float),
1062
1063 // UInt32 mFramesPerPacket;
1064 1,
1065
1066 // UInt32 mBytesPerFrame;
1067 sizeof(float),
1068
1069 // UInt32 mChannelsPerFrame;
1070 0,
1071
1072 // UInt32 mBitsPerChannel;
1073 sizeof(float) * 8,
1074 };
1075
1076 const struct Info{
1077 unsigned nChannels;
1078 AudioUnitScope scope;
1079 const char *const msg; // used only in log messages
1080 } infos[]{
1081 { 1, kAudioUnitScope_Global, "global" },
1082 { mAudioIns, kAudioUnitScope_Input, "input" },
1083 { mAudioOuts, kAudioUnitScope_Output, "output" },
1084 };
1085 for (const auto &[nChannels, scope, msg] : infos) {
1086 if (nChannels) {
1087 if (SetProperty(kAudioUnitProperty_SampleRate, mSampleRate, scope)) {
1088 wxLogError("%ls Didn't accept sample rate on %s\n",
1089 // Exposing internal name only in logging
1090 GetSymbol().Internal().wx_str(), msg);
1091 return false;
1092 }
1093 if (scope != kAudioUnitScope_Global) {
1094 streamFormat.mChannelsPerFrame = nChannels;
1095 if (SetProperty(kAudioUnitProperty_StreamFormat,
1096 streamFormat, scope)) {
1097 wxLogError("%ls didn't accept stream format on %s\n",
1098 // Exposing internal name only in logging
1099 GetSymbol().Internal().wx_str(), msg);
1100 return false;
1101 }
1102 }
1103 }
1104 }
1105
1106 if (AudioUnitInitialize(mUnit.get())) {
1107 wxLogError("Couldn't initialize audio unit\n");
1108 return false;
1109 }
1110
1111 mInitialization.reset(mUnit.get());
1112 return true;
1113}
@ Internal
Indicates internal failure from Audacity.
static TransactionScope::Factory::Scope scope
ComponentInterfaceSymbol GetSymbol() const override
AudioUnitCleanup< AudioUnit, AudioUnitUninitialize > mInitialization

References GetSymbol(), Internal, mAudioIns, mAudioOuts, mInitialization, mSampleRate, AudioUnitWrapper::mUnit, scope, and AudioUnitWrapper::SetProperty().

Referenced by InitializeInstance(), and ProcessInitialize().

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

◆ SetSampleRate()

void AudioUnitEffect::SetSampleRate ( double  rate)
overridevirtual

Default implementation assigns mSampleRate

Reimplemented from StatefulEffectBase.

Definition at line 430 of file AudioUnitEffect.cpp.

431{
432 mSampleRate = rate;
433}

References mSampleRate.

◆ ShowClientInterface()

int AudioUnitEffect::ShowClientInterface ( wxWindow &  parent,
wxDialog &  dialog,
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 637 of file AudioUnitEffect.cpp.

639{
640 if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal) {
641 dialog.Show();
642 return 0;
643 }
644
645 return dialog.ShowModal();
646}
EffectType GetType() const override
Type determines how it behaves.
bool SupportsRealtime() const override
Whether the effect supports realtime previewing (while audio is playing).

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

Here is the call graph for this function:

◆ ShowOptions()

void AudioUnitEffect::ShowOptions ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 966 of file AudioUnitEffect.cpp.

967{
969 if (dlg.ShowModal()) {
970 // Save changed values to the config file
974 }
975}

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

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

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

Here is the call graph for this function:

◆ SupportsRealtime()

bool AudioUnitEffect::SupportsRealtime ( ) const
overridevirtual

Whether the effect supports realtime previewing (while audio is playing).

Implements EffectDefinitionInterface.

Definition at line 186 of file AudioUnitEffect.cpp.

187{
188 // TODO reenable after achieving statelessness
189 return false;
190
191// return GetType() == EffectTypeProcess;
192}

Referenced by ShowClientInterface().

Here is the caller graph for this function:

Member Data Documentation

◆ mAudioIns

unsigned AudioUnitEffect::mAudioIns { 2 }
private

◆ mAudioOuts

unsigned AudioUnitEffect::mAudioOuts { 2 }
private

◆ mBlockSize

UInt32 AudioUnitEffect::mBlockSize { 0 }
private

◆ mInitialization

AudioUnitCleanup<AudioUnit, AudioUnitUninitialize> AudioUnitEffect::mInitialization
private

Definition at line 199 of file AudioUnitEffect.h.

Referenced by SetRateAndChannels().

◆ mInputList

PackedArray::Ptr<AudioBufferList> AudioUnitEffect::mInputList
private

Definition at line 214 of file AudioUnitEffect.h.

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

◆ mInteractive

bool AudioUnitEffect::mInteractive { false }
private

Definition at line 205 of file AudioUnitEffect.h.

Referenced by InitializePlugin(), and IsInteractive().

◆ mIsGraphical

bool AudioUnitEffect::mIsGraphical { false }
private

Definition at line 219 of file AudioUnitEffect.h.

◆ mLatencyDone

bool AudioUnitEffect::mLatencyDone { false }
private

Definition at line 206 of file AudioUnitEffect.h.

Referenced by GetLatency(), and ProcessInitialize().

◆ mMaster

AudioUnitEffect* const AudioUnitEffect::mMaster
private

Definition at line 221 of file AudioUnitEffect.h.

Referenced by DoMakeInstance().

◆ mName

const wxString AudioUnitEffect::mName
private

Definition at line 196 of file AudioUnitEffect.h.

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

◆ mOutputList

PackedArray::Ptr<AudioBufferList> AudioUnitEffect::mOutputList
private

Definition at line 215 of file AudioUnitEffect.h.

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

◆ mParent

wxWindow* AudioUnitEffect::mParent {}
private

Definition at line 217 of file AudioUnitEffect.h.

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

◆ mPath

const PluginPath AudioUnitEffect::mPath
private

Definition at line 195 of file AudioUnitEffect.h.

Referenced by GetPath(), and RealtimeAddProcessor().

◆ mSampleRate

Float64 AudioUnitEffect::mSampleRate { 44100.0 }
private

◆ mSettings

AudioUnitEffectSettings AudioUnitEffect::mSettings
private

Definition at line 184 of file AudioUnitEffect.h.

Referenced by GetSettings().

◆ mSlaves

AudioUnitEffectArray AudioUnitEffect::mSlaves

◆ mTimeStamp

AudioTimeStamp AudioUnitEffect::mTimeStamp {}
private

Definition at line 212 of file AudioUnitEffect.h.

Referenced by ProcessBlock(), and ProcessInitialize().

◆ mUIType

wxString AudioUnitEffect::mUIType
private

Definition at line 218 of file AudioUnitEffect.h.

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

◆ mUseLatency

bool AudioUnitEffect::mUseLatency { true }
private

Definition at line 210 of file AudioUnitEffect.h.

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

◆ mVendor

const wxString AudioUnitEffect::mVendor
private

Definition at line 197 of file AudioUnitEffect.h.

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


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