Audacity 3.2.0
ScienFilterBase.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ScienFilterBase.h
6
7Norm C
8Mitch Golden
9Vaughan Johnson (Preview)
10
11***********************************************************************/
12#pragma once
13
14#include "Biquad.h"
15#include "ShuttleAutomation.h"
17#include <cfloat> // for FLT_MAX
18
19class BUILTIN_EFFECTS_API ScienFilterBase : public StatefulPerTrackEffect
20{
21public:
22 static inline ScienFilterBase*
24 {
25 return &e;
26 }
28
30 virtual ~ScienFilterBase();
31
32 // ComponentInterface implementation
33
34 ComponentInterfaceSymbol GetSymbol() const override;
35 TranslatableString GetDescription() const override;
36 ManualPageID ManualPage() const override;
37
38 // EffectDefinitionInterface implementation
39
40 EffectType GetType() const override;
41
42 unsigned GetAudioInCount() const override;
43 unsigned GetAudioOutCount() const override;
46 ChannelNames chanMap) override;
47 size_t ProcessBlock(
48 EffectSettings& settings, const float* const* inBlock,
49 float* const* outBlock, size_t blockLen) override;
50
51 // Effect implementation
52
53 bool Init() override;
54
55protected:
56 // ScienFilterBase implementation
57
58 void CalcFilter();
59 float FilterMagnAtFreq(float Freq);
60
61 float mCutoff;
62 float mRipple;
64 int mFilterType; // Butterworth etc.
65 int mFilterSubtype; // lowpass, highpass
66 int mOrder;
69
70 double mdBMax;
71 double mdBMin;
73
74 double mLoFreq;
75 double mNyquist;
76
77 const EffectParameterMethods& Parameters() const override;
78
80 {
81 kLowPass = Biquad::kLowPass,
82 kHighPass = Biquad::kHighPass,
83 nSubTypes = Biquad::nSubTypes
84 };
85 static const EnumValueSymbol kSubTypeStrings[nSubTypes];
86
87 enum kTypes
88 {
92 nTypes
93 };
94 static const EnumValueSymbol kTypeStrings[nTypes];
95
96 static_assert(nSubTypes == WXSIZEOF(kSubTypeStrings), "size mismatch");
97
99 L"FilterType",
100 kButterworth,
101 0,
102 nTypes - 1,
103 1,
104 kTypeStrings,
105 nTypes };
107 L"FilterSubtype",
108 kLowPass,
109 0,
110 nSubTypes - 1,
111 1,
112 kSubTypeStrings,
113 nSubTypes };
114 static constexpr EffectParameter Order {
115 &ScienFilterBase::mOrder, L"Order", 1, 1, 10, 1
116 };
117 static constexpr EffectParameter Cutoff {
118 &ScienFilterBase::mCutoff, L"Cutoff", 1000.0f, 1.0, FLT_MAX, 1
119 };
120 static constexpr EffectParameter Passband {
121 &ScienFilterBase::mRipple, L"PassbandRipple", 1.0f, 0.0, 100.0, 1
122 };
123 static constexpr EffectParameter Stopband {
124 &ScienFilterBase::mStopbandRipple, L"StopbandRipple", 30.0f, 0.0, 100.0, 1
125 };
126};
EffectType
ChannelName
@ nTypes
static Settings & settings()
Definition: TrackInfo.cpp:51
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual ManualPageID ManualPage() const
Name of a page in the Audacity alpha manual, default is empty.
virtual const EffectParameterMethods & Parameters() const
Definition: Effect.cpp:96
TranslatableString GetDescription() const override
Definition: Effect.cpp:64
ComponentInterfaceSymbol GetSymbol() const override
Definition: Effect.cpp:49
Interface for manipulations of an Effect's settings.
An Effect that applies 'classical' IIR filters.
static ScienFilterBase * FetchParameters(ScienFilterBase &e, EffectSettings &)
ArrayOf< Biquad > mpBiquad
static const ComponentInterfaceSymbol Symbol
virtual unsigned GetAudioOutCount() const
How many output buffers to allocate at once.
virtual unsigned GetAudioInCount() const
How many input buffers to allocate at once.
Base class for many of the effects in Audacity.
bool ProcessInitialize(EffectSettings &settings, double sampleRate, ChannelNames chanMap=nullptr) override
virtual size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen)=0
Called for destructive effect computation.
Holds a msgid for the translation catalog; may also bind format arguments.
@ kLowPass
Definition: Biquad.h:61
@ nSubTypes
Definition: Biquad.h:63
@ kHighPass
Definition: Biquad.h:62
Externalized state of a plug-in.