Audacity 3.2.0
ScienFilter.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5EffectScienFilter.h
6
7Norm C
8Mitch Golden
9Vaughan Johnson (Preview)
10
11***********************************************************************/
12
13#ifndef __AUDACITY_EFFECT_SCIENFILTER__
14#define __AUDACITY_EFFECT_SCIENFILTER__
15
16#include <wx/setup.h> // for wxUSE_* macros
17
18#include "Biquad.h"
19
21#include "ShuttleAutomation.h"
22#include "wxPanelWrapper.h"
23#include <float.h> // for FLT_MAX
24
25class wxBitmap;
26class wxChoice;
27class wxSlider;
28class wxStaticText;
29class wxTextCtrl;
30class RulerPanel;
31class ShuttleGui;
32
34
36{
37public:
38 static inline EffectScienFilter *
41
43 virtual ~EffectScienFilter();
44
45 // ComponentInterface implementation
46
47 ComponentInterfaceSymbol GetSymbol() const override;
48 TranslatableString GetDescription() const override;
49 ManualPageID ManualPage() const override;
50
51 // EffectDefinitionInterface implementation
52
53 EffectType GetType() const override;
54
55 unsigned GetAudioInCount() const override;
56 unsigned GetAudioOutCount() const override;
58 ChannelNames chanMap) override;
60 const float *const *inBlock, float *const *outBlock, size_t blockLen)
61 override;
62
63 // Effect implementation
64
65 bool Init() override;
66 std::unique_ptr<EffectEditor> PopulateOrExchange(
67 ShuttleGui & S, EffectInstance &instance,
68 EffectSettingsAccess &access, const EffectOutputs *pOutputs) override;
69 bool TransferDataToWindow(const EffectSettings &settings) override;
71
72private:
73 // EffectScienFilter implementation
74
76 void CalcFilter();
77 float FilterMagnAtFreq(float Freq);
78 void EnableDisableRippleCtl (int FilterType);
79
80 void OnSize( wxSizeEvent & evt );
81 void OnSlider( wxCommandEvent & evt );
82
83 void OnOrder( wxCommandEvent & evt );
84 void OnCutoff( wxCommandEvent & evt );
85 void OnRipple( wxCommandEvent & evt );
86 void OnStopbandRipple( wxCommandEvent & evt );
87 void OnFilterType( wxCommandEvent & evt );
88 void OnFilterSubtype( wxCommandEvent & evt );
89
90 void OnSliderDBMAX( wxCommandEvent & evt );
91 void OnSliderDBMIN( wxCommandEvent & evt );
92
93 wxWeakRef<wxWindow> mUIParent{};
94
95 float mCutoff;
96 float mRipple;
98 int mFilterType; // Butterworth etc.
99 int mFilterSubtype; // lowpass, highpass
103
104 double mdBMax;
105 double mdBMin;
107
108 double mLoFreq;
109 double mNyquist;
110
112 wxSlider *mdBMinSlider;
113 wxSlider *mdBMaxSlider;
114
115 wxStaticText *mRippleCtlP;
116 wxTextCtrl *mRippleCtl;
117 wxStaticText *mRippleCtlU;
118
119 wxTextCtrl *mCutoffCtl;
120
121 wxStaticText *mStopbandRippleCtlP;
123 wxStaticText *mStopbandRippleCtlU;
124
125 wxChoice *mFilterTypeCtl;
128
131
132 const EffectParameterMethods& Parameters() const override;
133 DECLARE_EVENT_TABLE()
134
136
138 {
142 };
144
146 {
150 nTypes
151 };
153
154 static_assert(nSubTypes == WXSIZEOF(kSubTypeStrings), "size mismatch");
155
157 L"FilterType", kButterworth, 0, nTypes - 1, 1, kTypeStrings, nTypes };
159 L"FilterSubtype", kLowPass, 0, nSubTypes - 1, 1, kSubTypeStrings, nSubTypes };
161 L"Order", 1, 1, 10, 1 };
163 L"Cutoff", 1000.0f, 1.0, FLT_MAX, 1 };
165 L"PassbandRipple", 1.0f, 0.0, 100.0, 1 };
167 L"StopbandRipple", 30.0f, 0.0, 100.0, 1 };
168};
169
171{
172public:
174 wxWindow *parent, wxWindowID winid,
175 EffectScienFilter *effect, double lo, double hi);
176 virtual ~EffectScienFilterPanel();
177
178 // We don't need or want to accept focus.
179 bool AcceptsFocus() const;
180 // So that wxPanel is not included in Tab traversal - see wxWidgets bug 15581
181 bool AcceptsFocusFromKeyboard() const;
182
183 void SetFreqRange(double lo, double hi);
184 void SetDbRange(double min, double max);
185
186private:
187 void OnPaint(wxPaintEvent & evt);
188 void OnSize(wxSizeEvent & evt);
189
190private:
192 wxWindow *mParent;
193
194 double mLoFreq;
195 double mHiFreq;
196
197 double mDbMin;
198 double mDbMax;
199
200 std::unique_ptr<wxBitmap> mBitmap;
201 wxRect mEnvRect;
204
205 friend class EffectScienFilter;
206
207 DECLARE_EVENT_TABLE()
208};
209
210#endif
int min(int a, int b)
EffectType
ChannelName
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:47
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Performs effect computation.
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
An Effect that applies 'classical' IIR filters.
Definition: ScienFilter.h:36
void OnFilterSubtype(wxCommandEvent &evt)
EffectScienFilterPanel * mPanel
Definition: ScienFilter.h:111
TranslatableString GetDescription() const override
void OnSliderDBMAX(wxCommandEvent &evt)
static const EnumValueSymbol kSubTypeStrings[nSubTypes]
Definition: ScienFilter.h:143
wxStaticText * mRippleCtlU
Definition: ScienFilter.h:117
void OnStopbandRipple(wxCommandEvent &evt)
bool ProcessInitialize(EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
void OnCutoff(wxCommandEvent &evt)
static const EnumValueSymbol kTypeStrings[nTypes]
Definition: ScienFilter.h:152
ArrayOf< Biquad > mpBiquad
Definition: ScienFilter.h:102
wxTextCtrl * mRippleCtl
Definition: ScienFilter.h:116
void EnableDisableRippleCtl(int FilterType)
wxChoice * mFilterSubTypeCtl
Definition: ScienFilter.h:126
virtual ~EffectScienFilter()
static constexpr EffectParameter Stopband
Definition: ScienFilter.h:166
unsigned GetAudioOutCount() const override
How many output buffers to allocate at once.
static constexpr EffectParameter Cutoff
Definition: ScienFilter.h:162
size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen) override
Called for destructive effect computation.
void OnSlider(wxCommandEvent &evt)
static constexpr EnumParameter Subtype
Definition: ScienFilter.h:158
bool TransferDataFromWindow(EffectSettings &settings) override
wxTextCtrl * mCutoffCtl
Definition: ScienFilter.h:119
wxSlider * mdBMaxSlider
Definition: ScienFilter.h:113
wxChoice * mFilterTypeCtl
Definition: ScienFilter.h:125
void OnFilterType(wxCommandEvent &evt)
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
wxChoice * mFilterOrderCtl
Definition: ScienFilter.h:127
wxWeakRef< wxWindow > mUIParent
Definition: ScienFilter.h:93
wxStaticText * mStopbandRippleCtlP
Definition: ScienFilter.h:121
const EffectParameterMethods & Parameters() const override
std::unique_ptr< EffectEditor > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
static constexpr EnumParameter Type
Definition: ScienFilter.h:156
static constexpr EffectParameter Passband
Definition: ScienFilter.h:164
RulerPanel * mdBRuler
Definition: ScienFilter.h:129
EffectType GetType() const override
Type determines how it behaves.
static constexpr EffectParameter Order
Definition: ScienFilter.h:160
wxTextCtrl * mStopbandRippleCtl
Definition: ScienFilter.h:122
bool TransferGraphLimitsFromWindow()
static const ComponentInterfaceSymbol Symbol
Definition: ScienFilter.h:40
bool TransferDataToWindow(const EffectSettings &settings) override
void OnSliderDBMIN(wxCommandEvent &evt)
bool Init() override
void OnOrder(wxCommandEvent &evt)
void OnRipple(wxCommandEvent &evt)
RulerPanel * mfreqRuler
Definition: ScienFilter.h:130
wxStaticText * mRippleCtlP
Definition: ScienFilter.h:115
float FilterMagnAtFreq(float Freq)
unsigned GetAudioInCount() const override
How many input buffers to allocate at once.
static EffectScienFilter * FetchParameters(EffectScienFilter &e, EffectSettings &)
Definition: ScienFilter.h:39
ComponentInterfaceSymbol GetSymbol() const override
wxStaticText * mStopbandRippleCtlU
Definition: ScienFilter.h:123
void OnSize(wxSizeEvent &evt)
wxSlider * mdBMinSlider
Definition: ScienFilter.h:112
EffectScienFilterPanel is used with EffectScienFilter and controls a graph for EffectScienFilter.
Definition: ScienFilter.h:171
void OnPaint(wxPaintEvent &evt)
EffectScienFilterPanel(wxWindow *parent, wxWindowID winid, EffectScienFilter *effect, double lo, double hi)
void OnSize(wxSizeEvent &evt)
virtual ~EffectScienFilterPanel()
void SetDbRange(double min, double max)
bool AcceptsFocus() const
bool AcceptsFocusFromKeyboard() const
EffectScienFilter * mEffect
Definition: ScienFilter.h:191
std::unique_ptr< wxBitmap > mBitmap
Definition: ScienFilter.h:200
void SetFreqRange(double lo, double hi)
RulerPanel class allows you to work with a Ruler like any other wxWindow.
Definition: RulerPanel.h:19
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Base class for many of the effects in Audacity.
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.