Audacity 3.2.0
AudioUnitInstance.h
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file AudioUnitInstance.h
6
7 Dominic Mazzoni
8 Leland Lucius
9
10**********************************************************************/
11
12#ifndef __AUDACITY_AUDIO_UNIT_INSTANCE__
13#define __AUDACITY_AUDIO_UNIT_INSTANCE__
14
15#include "PerTrackEffect.h"
16#include "AudioUnitWrapper.h"
17struct AudioUnitEvent;
18
20 , public AudioUnitWrapper
21{
22public:
23 using Instance::mProcessor;
24
26 AudioComponent component, Parameters &parameters,
27 const wxString &identifier,
28 unsigned audioIns, unsigned audioOuts, bool useLatency);
29
30 void EventListener(const AudioUnitEvent *inEvent,
31 AudioUnitParameterValue inParameterValue);
32
33 // Override the virtual function to allocate an empty message
34 std::unique_ptr<Message> MakeMessage() const override;
35
36 // A non-virtual overload makes a non-empty message
37 std::unique_ptr<Message>
38 MakeMessage(AudioUnitParameterID id, AudioUnitParameterValue value) const;
39
40private:
41 size_t InitialBlockSize() const;
43 const override;
44
45 size_t GetBlockSize() const override;
46 size_t SetBlockSize(size_t maxBlockSize) override;
47
48 unsigned GetAudioInCount() const override;
49 unsigned GetAudioOutCount() const override;
50
52 ChannelNames chanMap) override;
53 bool ProcessFinalize() noexcept override;
55 const float *const *inBlock, float *const *outBlock, size_t blockLen)
56 override;
57
59 override;
61 unsigned numChannels, float sampleRate) override;
62 bool RealtimeFinalize(EffectSettings &settings) noexcept override;
63 bool RealtimeSuspend() override;
64 bool RealtimeResume() override;
65
66 bool UsesMessages() const noexcept override;
67 bool RealtimeProcessStart(MessagePackage &package) override;
68 size_t RealtimeProcess(size_t group, EffectSettings &settings,
69 const float *const *inbuf, float *const *outbuf, size_t numSamples)
70 override;
71 bool RealtimeProcessEnd(EffectSettings &settings) noexcept override;
72
73 static OSStatus RenderCallback(void *inRefCon,
74 AudioUnitRenderActionFlags *inActionFlags,
75 const AudioTimeStamp *inTimeStamp,
76 UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData);
77 OSStatus Render(AudioUnitRenderActionFlags *inActionFlags,
78 const AudioTimeStamp *inTimeStamp,
79 UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData);
80
81 bool BypassEffect(bool bypass);
82
83private:
85 bool mRecruited{ false };
86 std::vector<std::unique_ptr<AudioUnitInstance>> mSlaves;
87
89 AudioTimeStamp mTimeStamp{};
92
93
94 const wxString &mIdentifier; // for debug messages only
95 const size_t mBlockSize;
96 const bool mUseLatency;
97};
98#endif
std::unique_ptr< T, AudioUnitCleaner< T, fn > > AudioUnitCleanup
RAII for cleaning up AU plugin state.
ChannelName
static Settings & settings()
Definition: TrackInfo.cpp:51
std::vector< std::unique_ptr< AudioUnitInstance > > mSlaves
bool mRecruited
Whether the master instance is now allocated to a group number.
size_t SetBlockSize(size_t maxBlockSize) override
PackedArray::Ptr< AudioBufferList > mInputList
AudioUnitCleanup< AudioUnit, AudioUnitUninitialize > mInitialization
size_t RealtimeProcess(size_t group, EffectSettings &settings, const float *const *inbuf, float *const *outbuf, size_t numSamples) override
bool RealtimeInitialize(EffectSettings &settings, double sampleRate) override
bool RealtimeSuspend() override
bool RealtimeFinalize(EffectSettings &settings) noexcept override
const size_t mBlockSize
bool RealtimeResume() override
std::unique_ptr< Message > MakeMessage() const override
Called on the main thread, in which the result may be cloned.
bool ProcessInitialize(EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
bool RealtimeProcessEnd(EffectSettings &settings) noexcept override
settings can be updated to let a dialog change appearance at idle
AudioTimeStamp mTimeStamp
bool UsesMessages() const noexcept override
OSStatus Render(AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
const wxString & mIdentifier
void EventListener(const AudioUnitEvent *inEvent, AudioUnitParameterValue inParameterValue)
bool ProcessFinalize() noexcept override
bool BypassEffect(bool bypass)
bool RealtimeAddProcessor(EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate) override
PackedArray::Ptr< AudioBufferList > mOutputList
bool RealtimeProcessStart(MessagePackage &package) override
settings are possibly changed, since last call, by an asynchronous dialog
AudioUnitInstance(const PerTrackEffect &effect, AudioComponent component, Parameters &parameters, const wxString &identifier, unsigned audioIns, unsigned audioOuts, bool useLatency)
size_t InitialBlockSize() const
SampleCount GetLatency(const EffectSettings &settings, double sampleRate) const override
static OSStatus RenderCallback(void *inRefCon, AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
size_t GetBlockSize() const override
size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen) override
Called for destructive effect computation.
unsigned GetAudioOutCount() const override
How many output buffers to allocate at once.
unsigned GetAudioInCount() const override
How many input buffers to allocate at once.
uint64_t SampleCount
Hold values to send to effect output meters.
Base class for many of the effects in Audacity.
Manages and interacts with an AudioUnit, providing operations on audio effects.
Externalized state of a plug-in.