Audacity 3.2.0
StatefulEffectBase.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Effect.h
6
7 Dominic Mazzoni
8 Vaughan Johnson
9
10 Paul Licameli split from Effect.h
11
12**********************************************************************/
13
14#ifndef __AUDACITY_STATEFUL_EFFECT_BASE__
15#define __AUDACITY_STATEFUL_EFFECT_BASE__
16
17#include "EffectPlugin.h"
18
19class sampleCount;
20
23class AUDACITY_DLL_API StatefulEffectBase {
24public:
26 class AUDACITY_DLL_API Instance : public virtual EffectInstanceEx {
27 public:
28 explicit Instance(StatefulEffectBase &effect);
29 ~Instance() override;
30
31 bool Init() override;
32
33 size_t GetBlockSize() const override;
34 size_t SetBlockSize(size_t maxBlockSize) override;
35
36 bool RealtimeInitialize(EffectSettings &settings, double sampleRate)
37 override;
38 bool RealtimeAddProcessor(EffectSettings &settings,
39 EffectOutputs *pOutputs,
40 unsigned numChannels, float sampleRate) override;
41 bool RealtimeSuspend() override;
42 bool RealtimeResume() override;
43 bool RealtimeProcessStart(MessagePackage &package) override;
44 size_t RealtimeProcess(size_t group, EffectSettings &settings,
45 const float *const *inBuf, float *const *outBuf, size_t numSamples)
46 override;
47 bool RealtimeProcessEnd(EffectSettings &settings) noexcept override;
48 bool RealtimeFinalize(EffectSettings &settings) noexcept override;
49
50 unsigned GetAudioInCount() const override;
51 unsigned GetAudioOutCount() const override;
52
53 bool NeedsDither() const override;
54
55 bool ProcessInitialize(EffectSettings &settings,
56 double sampleRate, ChannelNames chanMap) override;
57
58 bool ProcessFinalize() noexcept override;
59
60 protected:
62 StatefulEffectBase &GetEffect() const { return mEffect; }
63 };
64
69 virtual bool Init();
70
74 virtual bool Process(EffectInstance &instance, EffectSettings &settings) = 0;
75
80 virtual bool RealtimeInitialize(EffectSettings &settings, double sampleRate);
81
86 virtual bool RealtimeAddProcessor(EffectSettings &settings,
87 EffectOutputs *pOutputs, unsigned numChannels, float sampleRate);
88
93 virtual bool RealtimeSuspend();
94
99 virtual bool RealtimeResume();
100
102
107 virtual bool RealtimeProcessStart(MessagePackage &package);
108
113 virtual size_t RealtimeProcess(size_t group, EffectSettings &settings,
114 const float *const *inBuf, float *const *outBuf, size_t numSamples);
115
120 virtual bool RealtimeProcessEnd(EffectSettings &settings) noexcept;
121
126 virtual bool RealtimeFinalize(EffectSettings &settings) noexcept;
127
132 virtual size_t SetBlockSize(size_t maxBlockSize);
133
138 virtual size_t GetBlockSize() const;
139
144 virtual unsigned GetAudioInCount() const;
145
150 virtual unsigned GetAudioOutCount() const;
151
155 virtual sampleCount GetLatency() const;
156
160 virtual bool NeedsDither() const;
161
165 virtual bool ProcessInitialize(EffectSettings &settings, double sampleRate,
166 ChannelNames chanMap = nullptr);
167
171 virtual bool ProcessFinalize() noexcept;
172
173private:
174
175 size_t mEffectBlockSize{ 0 };
176};
177
178#endif
ChannelName
static Settings & settings()
Definition: TrackInfo.cpp:87
Performs effect computation.
Definition: EffectPlugin.h:143
Performs effect computation.
Hold values to send to effect output meters.
Calls through to members of StatefulEffectBase.
virtual bool Process(EffectInstance &instance, EffectSettings &settings)=0
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Externalized state of a plug-in.