11#ifndef __AUDACITY_AUDIO_UNIT_UTILS__
12#define __AUDACITY_AUDIO_UNIT_UTILS__
15#include <AudioUnit/AudioUnit.h>
25template<
typename Ptr, OSStatus(*
fn)(Ptr),
26 typename T = std::remove_pointer_t<Ptr> >
34 void *pProperty, UInt32
size, AudioUnitScope inScope,
35 AudioUnitElement inElement);
42 AudioUnitScope inScope = kAudioUnitScope_Global,
43 AudioUnitElement inElement = 0)
46 &property,
sizeof(property), inScope, inElement);
55 size_t minSize,
void *&pObject,
size_t &
size,
56 AudioUnitScope inScope, AudioUnitElement inElement);
64 AudioUnitScope inScope = kAudioUnitScope_Global,
65 AudioUnitElement inElement = 0)
83 const void *pProperty, UInt32
size, AudioUnitScope inScope,
84 AudioUnitElement inElement);
89 OSStatus
SetProperty(AudioUnit unit, AudioUnitPropertyID inID,
91 AudioUnitScope inScope = kAudioUnitScope_Global,
92 AudioUnitElement inElement = 0)
95 &property,
sizeof(property), inScope, inElement);
115 Buffer(UInt32 numberChannels, UInt32 dataByteSize,
void *data)
117 mNumberChannels = numberChannels;
118 mDataByteSize = dataByteSize;
125 : AURenderCallbackStruct{} {
127 inputProcRefCon = inProcRefCon;
134 : AudioUnitParameter{} {
135 mAudioUnit = audioUnit;
143 if (flags & kAudioUnitParameterFlag_CFNameRelease) {
144 if (flags & kAudioUnitParameterFlag_HasCFNameString)
146 CFRelease(cfNameString);
147 if (flags & kAudioUnitParameterUnit_CustomUnit)
156 : AudioUnitParameterNameInfo{} {
158 inDesiredLength = desiredLength;
167 Property(AudioUnit audioUnit, AudioUnitPropertyID propertyID,
168 AudioUnitScope
scope)
169 : AudioUnitProperty{} {
170 mAudioUnit = audioUnit;
171 mPropertyID = propertyID;
186 AudioFormatID formatID, AudioFormatFlags formatFlags,
187 UInt32 bytesPerPacket, UInt32 framesPerPacket,
188 UInt32 bytesPerFrame, UInt32 channelsPerFrame,
189 UInt32 bitsPerChannel)
190 : AudioStreamBasicDescription{} {
192 mFormatID = formatID;
193 mFormatFlags = formatFlags;
194 mBytesPerPacket = bytesPerPacket;
195 mFramesPerPacket = framesPerPacket;
196 mBytesPerFrame = bytesPerFrame;
197 mChannelsPerFrame = channelsPerFrame;
198 mBitsPerChannel = bitsPerChannel;
216 static constexpr auto array_member = &AudioBufferList::mBuffers;
225 static_assert(offsetof(header_type, p1) ==
226 offsetof(AudioUnitCocoaViewInfo, mCocoaAUViewBundleLocation));
230 static constexpr auto array_member =
231 &AudioUnitCocoaViewInfo::mCocoaAUViewClass;
std::unique_ptr< T, AudioUnitCleaner< T, fn > > AudioUnitCleanup
RAII for cleaning up AU plugin state.
Wrap resource pointers from Apple Core SDK for RAII.
Smart pointer for a header contiguous with an array holding a dynamically determined number of elemen...
OSStatus GetFixedSizeProperty(AudioUnit unit, AudioUnitPropertyID inID, T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0)
OSStatus SetPropertyPtr(AudioUnit unit, AudioUnitPropertyID inID, const void *pProperty, UInt32 size, AudioUnitScope inScope, AudioUnitElement inElement)
Type-erased function to set an AudioUnit property.
OSStatus GetVariableSizePropertyPtr(AudioUnit unit, AudioUnitPropertyID inID, size_t minSize, void *&pObject, size_t &size, AudioUnitScope inScope, AudioUnitElement inElement)
Type-erased function to get an AudioUnit property of variable size.
OSStatus GetFixedSizePropertyPtr(AudioUnit unit, AudioUnitPropertyID inID, void *pProperty, UInt32 size, AudioUnitScope inScope, AudioUnitElement inElement)
Type-erased function to get an AudioUnit property of fixed size.
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
static CommandContext::TargetFactory::SubstituteInUnique< InteractiveOutputTargets > scope
Generates deleters for std::unique_ptr that clean up AU plugin state.
auto operator()(T *p) noexcept
Buffer(UInt32 numberChannels, UInt32 dataByteSize, void *data)
Parameter(AudioUnit audioUnit, AudioUnitScope scope)
This constructor leaves the parameter ID and element fields as 0.
ParameterNameInfo(AudioUnitParameterID id, SInt32 desiredLength)
Property(AudioUnit audioUnit, AudioUnitPropertyID propertyID, AudioUnitScope scope)
RenderCallback(AURenderCallback inProc, void *inProcRefCon)
StreamBasicDescription(Float64 sampleRate, AudioFormatID formatID, AudioFormatFlags formatFlags, UInt32 bytesPerPacket, UInt32 framesPerPacket, UInt32 bytesPerFrame, UInt32 channelsPerFrame, UInt32 bitsPerChannel)
UserPreset(CFStringRef name)
Smart pointer type that deallocates with Deleter.
CF_ptr< CFStringRef > element_type