13#ifndef AUDACITY_AUDIOUNIT_WRAPPER_H
14#define AUDACITY_AUDIOUNIT_WRAPPER_H
21#include <unordered_map>
52 std::make_shared<StringSet>() };
59 using Pair = std::pair<const wxString &, AudioUnitParameterValue>;
60 using Map = std::map<AudioUnitParameterID, std::optional<Pair>>;
110 AudioUnitScope inScope = kAudioUnitScope_Global,
111 AudioUnitElement inElement = 0)
const
115 inID, property, inScope, inElement);
122 AudioUnitScope inScope = kAudioUnitScope_Global,
123 AudioUnitElement inElement = 0)
const
126 inID, pObject, inScope, inElement);
132 AudioUnitScope inScope = kAudioUnitScope_Global,
133 AudioUnitElement inElement = 0)
const
137 inID, property, inScope, inElement);
143 std::function< bool(
const ParameterInfo &
pi, AudioUnitParameterID ID) >;
160 const wxCFStringRef &cfname,
bool binary)
const;
168 const wxString &group,
const wxMemoryBuffer &buf)
const;
172 bool fetchValues,
bool fetchPreset =
false)
const;
212 static std::optional<AudioUnitParameterID>
ParseKey(
const wxString &
key);
std::unique_ptr< T, AudioUnitCleaner< T, fn > > AudioUnitCleanup
RAII for cleaning up AU plugin state.
static Settings & settings()
Encapsulates parameter information for an AudioUnit.
ParameterInfo(AudioUnit mUnit, AudioUnitParameterID parmID)
Make a structure holding a key for the config file and a value.
static constexpr char idSep
static constexpr char idBeg
static std::optional< AudioUnitParameterID > ParseKey(const wxString &key)
Recover the parameter ID from the key, if well formed.
static constexpr char idEnd
std::optional< wxString > mName
AudioUnitUtils::ParameterInfo mInfo
EffectDefinitionInterface is a ComponentInterface that adds some basic read-only information about ef...
Holds a msgid for the translation catalog; may also bind format arguments.
OSStatus GetFixedSizeProperty(AudioUnit unit, AudioUnitPropertyID inID, T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0)
OSStatus SetProperty(AudioUnit unit, AudioUnitPropertyID inID, const T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0)
OSStatus GetVariableSizeProperty(AudioUnit unit, AudioUnitPropertyID inID, PackedArray::Ptr< T > &pObject, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0)
constexpr auto sampleRate
Represents a cached copy of the state stored in an AudioUnit, but can outlive the original AudioUnit.
AudioUnitEffectSettings()=default
const wxString & Intern(const wxString &name)
std::set< wxString > StringSet
Shared set of strings to optimize memory usage by avoiding repeated allocations.
std::pair< const wxString &, AudioUnitParameterValue > Pair
const std::shared_ptr< StringSet > mSharedNames
AudioUnitEffectSettings(Map map)
void ResetValues()
Associate nullopt with all keys already present in the map.
std::optional< SInt32 > mPresetNumber
Optionally store a preset.
std::map< AudioUnitParameterID, std::optional< Pair > > Map
Manages and interacts with an AudioUnit, providing operations on audio effects.
bool LoadPreset(const EffectDefinitionInterface &effect, const RegistryPath &group, EffectSettings &settings) const
AudioUnitWrapper(AudioComponent component, Parameters *pParameters)
bool StoreSettings(const EffectDefinitionInterface &effect, const AudioUnitEffectSettings &settings) const
bool LoadFactoryPreset(const EffectDefinitionInterface &effect, int id, EffectSettings *pSettings) const
OSStatus GetFixedSizeProperty(AudioUnitPropertyID inID, T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0) const
std::function< bool(const ParameterInfo &pi, AudioUnitParameterID ID) > ParameterVisitor
Return value: if true, continue visiting.
static bool MoveSettingsContents(AudioUnitEffectSettings &&src, AudioUnitEffectSettings &dst, bool merge)
Copy, then clear the optionals in src.
OSStatus GetVariableSizeProperty(AudioUnitPropertyID inID, PackedArray::Ptr< T > &pObject, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0) const
AudioUnit GetAudioUnit() const
TranslatableString InterpretBlob(AudioUnitEffectSettings &settings, const wxString &group, const wxMemoryBuffer &buf) const
Interpret the dump made before by MakeBlob.
const Parameters & GetParameters() const
bool SetRateAndChannels(double sampleRate, const wxString &identifier)
AudioComponent GetComponent() const
AudioUnitCleanup< AudioUnit, AudioComponentInstanceDispose > mUnit
OSStatus SetProperty(AudioUnitPropertyID inID, const T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0) const
static AudioUnitEffectSettings & GetSettings(EffectSettings &settings)
const AudioComponent mComponent
Parameters mOwnParameters
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.
void ForEachParameter(ParameterVisitor visitor) const
bool FetchSettings(AudioUnitEffectSettings &settings, bool fetchValues, bool fetchPreset=false) const
May allocate memory, so should be called only in the main thread.
Externalized state of a plug-in.