Audacity 3.2.0
PhaserBase.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Phaser
6
7 Effect programming:
8 Nasca Octavian Paul (Paul Nasca)
9
10 UI programming:
11 Dominic Mazzoni (with the help of wxDesigner)
12 Vaughan Johnson (Preview)
13
14**********************************************************************/
15#pragma once
16
17#include "PerTrackEffect.h"
18#include "SampleCount.h"
19#include "ShuttleAutomation.h"
20
21#define NUM_STAGES 24
22
24{
25public:
26 // state variables
29 double old[NUM_STAGES]; // must be as large as MAX_STAGES
30 double gain;
31 double fbout;
32 double outgain;
33 double lfoskip;
34 double phase;
36};
37
39{
40 /*
41 Phaser Parameters
42
43 mFreq - Phaser's LFO frequency
44 mPhase - Phaser's LFO startphase (radians), needed for stereo Phasers
45 mDepth - Phaser depth (0 - no depth, 255 - max depth)
46 mStages - Phaser stages (recomanded from 2 to 16-24, and EVEN NUMBER)
47 mDryWet - Dry/wet mix, (0 - dry, 128 - dry=wet, 255 - wet)
48 mFeedback - Phaser FeedBack (0 - no feedback, 100 = 100% Feedback,
49 -100 = -100% FeedBack)
50 */
51
52 static constexpr int stagesDefault = 2;
53 static constexpr int dryWetDefault = 128;
54 static constexpr double freqDefault = 0.4;
55 static constexpr double phaseDefault = 0.0;
56 static constexpr int depthDefault = 100;
57 static constexpr int feedbackDefault = 0;
58 static constexpr double outGainDefault = -6.0;
59
62 double mFreq { freqDefault };
63 double mPhase { phaseDefault };
67};
68
69class BUILTIN_EFFECTS_API PhaserBase :
70 public EffectWithSettings<EffectPhaserSettings, PerTrackEffect>
71{
72public:
74
75 PhaserBase();
76 virtual ~PhaserBase();
77
78 // ComponentInterface implementation
79
80 ComponentInterfaceSymbol GetSymbol() const override;
81 TranslatableString GetDescription() const override;
82 ManualPageID ManualPage() const override;
83
84 // EffectDefinitionInterface implementation
85
86 EffectType GetType() const override;
87 RealtimeSince RealtimeSupport() const override;
88
89protected:
90 // PhaserBase implementation
91
92 struct BUILTIN_EFFECTS_API Instance :
95 {
96 explicit Instance(const PerTrackEffect& effect)
97 : PerTrackEffect::Instance { effect }
98 {
99 }
100
101 bool ProcessInitialize(
103 ChannelNames chanMap) override;
104
105 size_t ProcessBlock(
106 EffectSettings& settings, const float* const* inBlock,
107 float* const* outBlock, size_t blockLen) override;
108
109 bool RealtimeInitialize(EffectSettings& settings, double) override;
110
111 bool RealtimeAddProcessor(
113 unsigned numChannels, float sampleRate) override;
114
115 bool RealtimeFinalize(EffectSettings& settings) noexcept override;
116
117 size_t RealtimeProcess(
118 size_t group, EffectSettings& settings, const float* const* inbuf,
119 float* const* outbuf, size_t numSamples) override;
120
121 unsigned GetAudioInCount() const override;
122 unsigned GetAudioOutCount() const override;
123
124 void InstanceInit(
126
127 size_t InstanceProcess(
129 const float* const* inBlock, float* const* outBlock, size_t blockLen);
130
132 double hz, double slope, double gain, double samplerate, int type,
133 double& a0, double& a1, double& a2, double& b0, double& b1,
134 double& b2);
135
136 float DoFilter(EffectPhaserState& data, float in);
137
139 std::vector<PhaserBase::Instance> mSlaves;
140 };
141
142 std::shared_ptr<EffectInstance> MakeInstance() const override;
143
144 const EffectParameterMethods& Parameters() const override;
145
146 static constexpr EffectParameter Stages {
148 L"Stages",
150 2,
152 1
153 };
154
155 static constexpr EffectParameter DryWet {
157 L"DryWet",
159 0,
160 255,
161 1
162 };
163
165 L"Freq",
167 0.001,
168 4.0,
169 10.0 };
170
172 L"Phase",
174 0.0,
175 360.0,
176 1 };
177
179 L"Depth",
181 0,
182 255,
183 1 };
184
185 static constexpr EffectParameter Feedback {
187 L"Feedback",
189 -100,
190 100,
191 1
192 };
193
194 static constexpr EffectParameter OutGain {
196 L"Gain",
198 -30.0,
199 30.0,
200 1
201 };
202};
EffectType
ChannelName
#define NUM_STAGES
Definition: PhaserBase.h:21
static Settings & settings()
Definition: TrackInfo.cpp:51
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
RealtimeSince
In which versions of Audacity was an effect realtime capable?
Inherit to add a state variable to an EffectInstance subclass.
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
double old[NUM_STAGES]
Definition: PhaserBase.h:29
sampleCount skipcount
Definition: PhaserBase.h:28
Base class for many of the effects in Audacity.
An Effect that changes frequencies in a time varying manner.
Definition: PhaserBase.h:71
static const ComponentInterfaceSymbol Symbol
Definition: PhaserBase.h:73
Holds a msgid for the translation catalog; may also bind format arguments.
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
static constexpr int depthDefault
Definition: PhaserBase.h:56
static constexpr int stagesDefault
Definition: PhaserBase.h:52
static constexpr double outGainDefault
Definition: PhaserBase.h:58
static constexpr double phaseDefault
Definition: PhaserBase.h:55
static constexpr int dryWetDefault
Definition: PhaserBase.h:53
static constexpr int feedbackDefault
Definition: PhaserBase.h:57
static constexpr double freqDefault
Definition: PhaserBase.h:54
Externalized state of a plug-in.
EffectPhaserState mState
Definition: PhaserBase.h:138
Instance(const PerTrackEffect &effect)
Definition: PhaserBase.h:96
std::vector< PhaserBase::Instance > mSlaves
Definition: PhaserBase.h:139
float DoFilter(EffectPhaserState &data, float in)
void Coefficients(double hz, double slope, double gain, double samplerate, int type, double &a0, double &a1, double &a2, double &b0, double &b1, double &b2)