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 "../widgets/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 sampleCount totalLen, 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<EffectUIValidator> PopulateOrExchange(
67 ShuttleGui & S, EffectInstance &instance, EffectSettingsAccess &access)
68 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 float mCutoff;
94 float mRipple;
96 int mFilterType; // Butterworth etc.
97 int mFilterSubtype; // lowpass, highpass
98 int mOrder;
101
102 double mdBMax;
103 double mdBMin;
105
106 double mLoFreq;
107 double mNyquist;
108
110 wxSlider *mdBMinSlider;
111 wxSlider *mdBMaxSlider;
112
113 wxStaticText *mRippleCtlP;
114 wxTextCtrl *mRippleCtl;
115 wxStaticText *mRippleCtlU;
116
117 wxTextCtrl *mCutoffCtl;
118
119 wxStaticText *mStopbandRippleCtlP;
121 wxStaticText *mStopbandRippleCtlU;
122
123 wxChoice *mFilterTypeCtl;
126
129
130 const EffectParameterMethods& Parameters() const override;
131 DECLARE_EVENT_TABLE()
132
134
136 {
140 };
142
144 {
148 nTypes
149 };
151
152 static_assert(nSubTypes == WXSIZEOF(kSubTypeStrings), "size mismatch");
153
155 L"FilterType", kButterworth, 0, nTypes - 1, 1, kTypeStrings, nTypes };
157 L"FilterSubtype", kLowPass, 0, nSubTypes - 1, 1, kSubTypeStrings, nSubTypes };
159 L"Order", 1, 1, 10, 1 };
161 L"Cutoff", 1000.0f, 1.0, FLT_MAX, 1 };
163 L"PassbandRipple", 1.0f, 0.0, 100.0, 1 };
165 L"StopbandRipple", 30.0f, 0.0, 100.0, 1 };
166};
167
169{
170public:
172 wxWindow *parent, wxWindowID winid,
173 EffectScienFilter *effect, double lo, double hi);
174 virtual ~EffectScienFilterPanel();
175
176 // We don't need or want to accept focus.
177 bool AcceptsFocus() const;
178 // So that wxPanel is not included in Tab traversal - see wxWidgets bug 15581
179 bool AcceptsFocusFromKeyboard() const;
180
181 void SetFreqRange(double lo, double hi);
182 void SetDbRange(double min, double max);
183
184private:
185 void OnPaint(wxPaintEvent & evt);
186 void OnSize(wxSizeEvent & evt);
187
188private:
190 wxWindow *mParent;
191
192 double mLoFreq;
193 double mHiFreq;
194
195 double mDbMin;
196 double mDbMax;
197
198 std::unique_ptr<wxBitmap> mBitmap;
199 wxRect mEnvRect;
202
203 friend class EffectScienFilter;
204
205 DECLARE_EVENT_TABLE()
206};
207
208#endif
int min(int a, int b)
EffectType
enum ChannelName * ChannelNames
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:87
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Performs effect computation.
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:109
TranslatableString GetDescription() const override
void OnSliderDBMAX(wxCommandEvent &evt)
static const EnumValueSymbol kSubTypeStrings[nSubTypes]
Definition: ScienFilter.h:141
wxStaticText * mRippleCtlU
Definition: ScienFilter.h:115
void OnStopbandRipple(wxCommandEvent &evt)
void OnCutoff(wxCommandEvent &evt)
static const EnumValueSymbol kTypeStrings[nTypes]
Definition: ScienFilter.h:150
ArrayOf< Biquad > mpBiquad
Definition: ScienFilter.h:100
wxTextCtrl * mRippleCtl
Definition: ScienFilter.h:114
void EnableDisableRippleCtl(int FilterType)
wxChoice * mFilterSubTypeCtl
Definition: ScienFilter.h:124
virtual ~EffectScienFilter()
static constexpr EffectParameter Stopband
Definition: ScienFilter.h:164
unsigned GetAudioOutCount() const override
How many output buffers to allocate at once.
static constexpr EffectParameter Cutoff
Definition: ScienFilter.h:160
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:156
bool TransferDataFromWindow(EffectSettings &settings) override
Update the given settings from controls.
wxTextCtrl * mCutoffCtl
Definition: ScienFilter.h:117
wxSlider * mdBMaxSlider
Definition: ScienFilter.h:111
wxChoice * mFilterTypeCtl
Definition: ScienFilter.h:123
bool ProcessInitialize(EffectSettings &settings, sampleCount totalLen, ChannelNames chanMap) override
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:125
wxStaticText * mStopbandRippleCtlP
Definition: ScienFilter.h:119
const EffectParameterMethods & Parameters() const override
static constexpr EnumParameter Type
Definition: ScienFilter.h:154
static constexpr EffectParameter Passband
Definition: ScienFilter.h:162
RulerPanel * mdBRuler
Definition: ScienFilter.h:127
EffectType GetType() const override
Type determines how it behaves.
static constexpr EffectParameter Order
Definition: ScienFilter.h:158
wxTextCtrl * mStopbandRippleCtl
Definition: ScienFilter.h:120
bool TransferGraphLimitsFromWindow()
static const ComponentInterfaceSymbol Symbol
Definition: ScienFilter.h:40
bool TransferDataToWindow(const EffectSettings &settings) override
Update controls for the settings.
void OnSliderDBMIN(wxCommandEvent &evt)
bool Init() override
Call once to set up state for whole list of tracks to be processed.
void OnOrder(wxCommandEvent &evt)
void OnRipple(wxCommandEvent &evt)
RulerPanel * mfreqRuler
Definition: ScienFilter.h:128
wxStaticText * mRippleCtlP
Definition: ScienFilter.h:113
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:121
void OnSize(wxSizeEvent &evt)
std::unique_ptr< EffectUIValidator > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
Add controls to effect panel; always succeeds.
wxSlider * mdBMinSlider
Definition: ScienFilter.h:110
EffectScienFilterPanel is used with EffectScienFilter and controls a graph for EffectScienFilter.
Definition: ScienFilter.h:169
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:189
std::unique_ptr< wxBitmap > mBitmap
Definition: ScienFilter.h:198
void SetFreqRange(double lo, double hi)
RulerPanel class allows you to work with a Ruler like any other wxWindow.
Definition: Ruler.h:228
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
Base class for many of the effects in Audacity.
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:18
@ kLowPass
Definition: Biquad.h:61
@ nSubTypes
Definition: Biquad.h:63
@ kHighPass
Definition: Biquad.h:62
Externalized state of a plug-in.