Audacity  3.0.3
ScienFilter.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 EffectScienFilter.h
6 
7 Norm C
8 Mitch Golden
9 Vaughan 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 
20 #include "Effect.h"
21 
22 class wxBitmap;
23 class wxChoice;
24 class wxSlider;
25 class wxStaticText;
26 class wxTextCtrl;
27 class RulerPanel;
28 class ShuttleGui;
29 
31 
32 class EffectScienFilter final : public Effect
33 {
34 public:
36 
38  virtual ~EffectScienFilter();
39 
40  // ComponentInterface implementation
41 
44  ManualPageID ManualPage() override;
45 
46  // EffectDefinitionInterface implementation
47 
48  EffectType GetType() override;
49 
50  // EffectClientInterface implementation
51 
52  unsigned GetAudioInCount() override;
53  unsigned GetAudioOutCount() override;
54  bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
55  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
56  bool DefineParams( ShuttleParams & S ) override;
57  bool GetAutomationParameters(CommandParameters & parms) override;
58  bool SetAutomationParameters(CommandParameters & parms) override;
59 
60  // Effect implementation
61 
62  bool Startup() override;
63  bool Init() override;
64  void PopulateOrExchange(ShuttleGui & S) override;
65  bool TransferDataToWindow() override;
66  bool TransferDataFromWindow() override;
67 
68 private:
69  // EffectScienFilter implementation
70 
72  void CalcFilter();
73  float FilterMagnAtFreq(float Freq);
74  void EnableDisableRippleCtl (int FilterType);
75 
76  void OnSize( wxSizeEvent & evt );
77  void OnSlider( wxCommandEvent & evt );
78 
79  void OnOrder( wxCommandEvent & evt );
80  void OnCutoff( wxCommandEvent & evt );
81  void OnRipple( wxCommandEvent & evt );
82  void OnStopbandRipple( wxCommandEvent & evt );
83  void OnFilterType( wxCommandEvent & evt );
84  void OnFilterSubtype( wxCommandEvent & evt );
85 
86  void OnSliderDBMAX( wxCommandEvent & evt );
87  void OnSliderDBMIN( wxCommandEvent & evt );
88 
89 private:
90  float mCutoff;
91  float mRipple;
93  int mFilterType; // Butterworth etc.
94  int mFilterSubtype; // lowpass, highpass
95  int mOrder;
98 
99  double mdBMax;
100  double mdBMin;
102 
103  double mLoFreq;
104  double mNyquist;
105 
107  wxSlider *mdBMinSlider;
108  wxSlider *mdBMaxSlider;
109 
110  wxStaticText *mRippleCtlP;
111  wxTextCtrl *mRippleCtl;
112  wxStaticText *mRippleCtlU;
113 
114  wxTextCtrl *mCutoffCtl;
115 
116  wxStaticText *mStopbandRippleCtlP;
117  wxTextCtrl *mStopbandRippleCtl;
118  wxStaticText *mStopbandRippleCtlU;
119 
120  wxChoice *mFilterTypeCtl;
121  wxChoice *mFilterSubTypeCtl;
122  wxChoice *mFilterOrderCtl;
123 
126 
127  DECLARE_EVENT_TABLE()
128 
130 };
131 
133 {
134 public:
136  wxWindow *parent, wxWindowID winid,
137  EffectScienFilter *effect, double lo, double hi);
138  virtual ~EffectScienFilterPanel();
139 
140  // We don't need or want to accept focus.
141  bool AcceptsFocus() const;
142  // So that wxPanel is not included in Tab traversal - see wxWidgets bug 15581
143  bool AcceptsFocusFromKeyboard() const;
144 
145  void SetFreqRange(double lo, double hi);
146  void SetDbRange(double min, double max);
147 
148 private:
149  void OnPaint(wxPaintEvent & evt);
150  void OnSize(wxSizeEvent & evt);
151 
152 private:
154  wxWindow *mParent;
155 
156  double mLoFreq;
157  double mHiFreq;
158 
159  double mDbMin;
160  double mDbMax;
161 
162  std::unique_ptr<wxBitmap> mBitmap;
163  wxRect mEnvRect;
164  int mWidth;
165  int mHeight;
166 
167  friend class EffectScienFilter;
168 
169  DECLARE_EVENT_TABLE()
170 };
171 
172 #endif
EffectScienFilter::TransferDataToWindow
bool TransferDataToWindow() override
Definition: ScienFilter.cpp:545
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
EffectScienFilter::OnCutoff
void OnCutoff(wxCommandEvent &evt)
Definition: ScienFilter.cpp:736
RulerPanel
RulerPanel class allows you to work with a Ruler like any other wxWindow.
Definition: Ruler.h:228
EffectScienFilter
An Effect that applies 'classical' IIR filters.
Definition: ScienFilter.h:33
EffectScienFilter::mdBMax
double mdBMax
Definition: ScienFilter.h:99
EffectScienFilter::mLoFreq
double mLoFreq
Definition: ScienFilter.h:103
EffectScienFilterPanel::mWidth
int mWidth
Definition: ScienFilter.h:164
Effect.h
EffectScienFilter::mOrderIndex
int mOrderIndex
Definition: ScienFilter.h:96
EffectScienFilterPanel::mEnvRect
wxRect mEnvRect
Definition: ScienFilter.h:163
EffectScienFilter::mRippleCtlU
wxStaticText * mRippleCtlU
Definition: ScienFilter.h:112
EffectScienFilter::ProcessInitialize
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: ScienFilter.cpp:220
EffectScienFilter::~EffectScienFilter
virtual ~EffectScienFilter()
Definition: ScienFilter.cpp:178
EffectScienFilter::mFilterType
int mFilterType
Definition: ScienFilter.h:93
EffectScienFilterPanel::mHeight
int mHeight
Definition: ScienFilter.h:165
Biquad.h
EffectScienFilter::OnSliderDBMAX
void OnSliderDBMAX(wxCommandEvent &evt)
Definition: ScienFilter.cpp:771
EffectScienFilter::mpBiquad
ArrayOf< Biquad > mpBiquad
Definition: ScienFilter.h:97
wxPanelWrapper
Definition: wxPanelWrapper.h:41
Effect
Base class for many of the effects in Audacity.
Definition: Effect.h:72
EffectScienFilter::OnSize
void OnSize(wxSizeEvent &evt)
Definition: ScienFilter.cpp:776
EffectScienFilter::mCutoff
float mCutoff
Definition: ScienFilter.h:90
EffectScienFilter::mNyquist
double mNyquist
Definition: ScienFilter.h:104
EffectScienFilter::EnableDisableRippleCtl
void EnableDisableRippleCtl(int FilterType)
Definition: ScienFilter.cpp:784
ShuttleParams
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:62
EffectScienFilter::OnStopbandRipple
void OnStopbandRipple(wxCommandEvent &evt)
Definition: ScienFilter.cpp:756
EffectScienFilter::OnRipple
void OnRipple(wxCommandEvent &evt)
Definition: ScienFilter.cpp:746
EffectScienFilter::ManualPage
ManualPageID ManualPage() override
Definition: ScienFilter.cpp:195
EffectScienFilter::CalcFilter
void CalcFilter()
Definition: ScienFilter.cpp:630
EffectScienFilter::OnSliderDBMIN
void OnSliderDBMIN(wxCommandEvent &evt)
Definition: ScienFilter.cpp:766
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
EffectScienFilter::GetAutomationParameters
bool GetAutomationParameters(CommandParameters &parms) override
Definition: ScienFilter.cpp:249
EffectScienFilter::mFilterOrderCtl
wxChoice * mFilterOrderCtl
Definition: ScienFilter.h:122
EffectScienFilterPanel
EffectScienFilterPanel is used with EffectScienFilter and controls a graph for EffectScienFilter.
Definition: ScienFilter.h:133
EffectScienFilter::mfreqRuler
RulerPanel * mfreqRuler
Definition: ScienFilter.h:125
EffectScienFilter::FilterMagnAtFreq
float FilterMagnAtFreq(float Freq)
Definition: ScienFilter.cpp:646
EffectScienFilter::EffectScienFilter
EffectScienFilter()
Definition: ScienFilter.cpp:158
EffectScienFilter::OnOrder
void OnOrder(wxCommandEvent &evt)
Definition: ScienFilter.cpp:716
EffectScienFilter::GetType
EffectType GetType() override
Definition: ScienFilter.cpp:203
EffectScienFilter::OnSlider
void OnSlider(wxCommandEvent &evt)
EffectScienFilter::mdBMaxSlider
wxSlider * mdBMaxSlider
Definition: ScienFilter.h:108
EffectScienFilterPanel::mDbMax
double mDbMax
Definition: ScienFilter.h:160
EffectScienFilter::mStopbandRippleCtl
wxTextCtrl * mStopbandRippleCtl
Definition: ScienFilter.h:117
EffectScienFilterPanel::mBitmap
std::unique_ptr< wxBitmap > mBitmap
Definition: ScienFilter.h:162
EffectScienFilter::mFilterSubtype
int mFilterSubtype
Definition: ScienFilter.h:94
EffectScienFilter::mFilterSubTypeCtl
wxChoice * mFilterSubTypeCtl
Definition: ScienFilter.h:121
EffectScienFilter::OnFilterSubtype
void OnFilterSubtype(wxCommandEvent &evt)
Definition: ScienFilter.cpp:730
EffectScienFilter::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: ScienFilter.h:35
EffectScienFilter::mStopbandRippleCtlP
wxStaticText * mStopbandRippleCtlP
Definition: ScienFilter.h:116
ChannelNames
enum ChannelName * ChannelNames
EffectScienFilter::SetAutomationParameters
bool SetAutomationParameters(CommandParameters &parms) override
Definition: ScienFilter.cpp:261
EffectScienFilter::GetAudioInCount
unsigned GetAudioInCount() override
Definition: ScienFilter.cpp:210
EffectScienFilter::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: ScienFilter.cpp:239
EffectScienFilter::Init
bool Init() override
Definition: ScienFilter.cpp:334
EffectScienFilter::mdBMin
double mdBMin
Definition: ScienFilter.h:100
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
EffectScienFilter::mPanel
EffectScienFilterPanel * mPanel
Definition: ScienFilter.h:106
EffectScienFilterPanel::mHiFreq
double mHiFreq
Definition: ScienFilter.h:157
EffectScienFilter::mdBMinSlider
wxSlider * mdBMinSlider
Definition: ScienFilter.h:107
EffectScienFilter::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: ScienFilter.cpp:184
EffectScienFilter::mRipple
float mRipple
Definition: ScienFilter.h:91
TaggedIdentifier< ManualPageIDTag >
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
EffectScienFilter::mEditingBatchParams
bool mEditingBatchParams
Definition: ScienFilter.h:101
EffectScienFilterPanel::mEffect
EffectScienFilter * mEffect
Definition: ScienFilter.h:153
EffectScienFilter::GetDescription
TranslatableString GetDescription() override
Definition: ScienFilter.cpp:189
EffectScienFilter::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: ScienFilter.cpp:565
EffectScienFilter::Startup
bool Startup() override
Definition: ScienFilter.cpp:286
EffectScienFilter::ProcessBlock
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: ScienFilter.cpp:228
EffectScienFilter::mCutoffCtl
wxTextCtrl * mCutoffCtl
Definition: ScienFilter.h:114
EffectScienFilter::mRippleCtlP
wxStaticText * mRippleCtlP
Definition: ScienFilter.h:110
EffectScienFilter::mOrder
int mOrder
Definition: ScienFilter.h:95
EffectScienFilter::mStopbandRippleCtlU
wxStaticText * mStopbandRippleCtlU
Definition: ScienFilter.h:118
EffectScienFilterPanel::mParent
wxWindow * mParent
Definition: ScienFilter.h:154
EffectScienFilter::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: ScienFilter.cpp:372
EffectScienFilter::mStopbandRipple
float mStopbandRipple
Definition: ScienFilter.h:92
EffectScienFilterPanel::mLoFreq
double mLoFreq
Definition: ScienFilter.h:156
EffectScienFilter::EffectScienFilterPanel
friend class EffectScienFilterPanel
Definition: ScienFilter.h:129
EffectType
EffectType
Definition: EffectInterface.h:55
EffectScienFilterPanel::mDbMin
double mDbMin
Definition: ScienFilter.h:159
EffectScienFilter::mFilterTypeCtl
wxChoice * mFilterTypeCtl
Definition: ScienFilter.h:120
EffectScienFilter::TransferGraphLimitsFromWindow
bool TransferGraphLimitsFromWindow()
Definition: ScienFilter.cpp:584
ArrayOf< Biquad >
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
EffectScienFilter::OnFilterType
void OnFilterType(wxCommandEvent &evt)
Definition: ScienFilter.cpp:723
EffectScienFilter::mRippleCtl
wxTextCtrl * mRippleCtl
Definition: ScienFilter.h:111
EffectScienFilter::mdBRuler
RulerPanel * mdBRuler
Definition: ScienFilter.h:124
EffectScienFilter::GetAudioOutCount
unsigned GetAudioOutCount() override
Definition: ScienFilter.cpp:215