Audacity  2.2.2
BassTreble.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4  Audacity(R) is copyright (c) 1999-2016 Audacity Team.
5  License: GPL v2. See License.txt.
6 
7  BassTreble.h (two shelf filters)
8  Steve Daulton
9 
10 **********************************************************************/
11 
12 #ifndef __AUDACITY_EFFECT_BASS_TREBLE__
13 #define __AUDACITY_EFFECT_BASS_TREBLE__
14 
15 #include <wx/event.h>
16 #include <wx/slider.h>
17 #include <wx/stattext.h>
18 #include <wx/string.h>
19 #include <wx/textctrl.h>
20 #include <wx/checkbox.h>
21 
22 #include "Effect.h"
23 
24 class ShuttleGui;
25 
26 #define BASSTREBLE_PLUGIN_SYMBOL XO("Bass and Treble")
27 
29 {
30 public:
31  float samplerate;
32  double treble;
33  double bass;
34  double gain;
35  double slope, hzBass, hzTreble;
40 };
41 
42 class EffectBassTreble final : public Effect
43 {
44 public:
46  virtual ~EffectBassTreble();
47 
48  // IdentInterface implementation
49 
50  wxString GetSymbol() override;
51  wxString GetDescription() override;
52  wxString ManualPage() override;
53 
54  // EffectIdentInterface implementation
55 
56  EffectType GetType() override;
57  bool SupportsRealtime() override;
58 
59  // EffectClientInterface implementation
60 
61  unsigned GetAudioInCount() override;
62  unsigned GetAudioOutCount() override;
63  bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
64  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
65  bool RealtimeInitialize() override;
66  bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override;
67  bool RealtimeFinalize() override;
68  size_t RealtimeProcess(int group,
69  float **inbuf,
70  float **outbuf,
71  size_t numSamples) override;
72  bool GetAutomationParameters(EffectAutomationParameters & parms) override;
73  bool SetAutomationParameters(EffectAutomationParameters & parms) override;
74 
75 
76  // Effect Implementation
77 
78  void PopulateOrExchange(ShuttleGui & S) override;
79  bool TransferDataToWindow() override;
80  bool TransferDataFromWindow() override;
81 
82  bool CheckWhetherSkipEffect() override;
83 
84 private:
85  // EffectBassTreble implementation
86 
87  void InstanceInit(EffectBassTrebleState & data, float sampleRate);
88  size_t InstanceProcess(EffectBassTrebleState & data, float **inBlock, float **outBlock, size_t blockLen);
89 
90  void Coefficents(double hz, double slope, double gain, double samplerate, int type,
91  double& a0, double& a1, double& a2, double& b0, double& b1, double& b2);
92  float DoFilter(EffectBassTrebleState & data, float in);
93 
94  void OnBassText(wxCommandEvent & evt);
95  void OnTrebleText(wxCommandEvent & evt);
96  void OnGainText(wxCommandEvent & evt);
97  void OnBassSlider(wxCommandEvent & evt);
98  void OnTrebleSlider(wxCommandEvent & evt);
99  void OnGainSlider(wxCommandEvent & evt);
100  void OnLinkCheckbox(wxCommandEvent & evt);
101 
102  // Auto-adjust gain to reduce variation in peak level
103  void UpdateGain(double oldVal, int control );
104 
105 private:
107  std::vector<EffectBassTrebleState> mSlaves;
108 
109  double mBass;
110  double mTreble;
111  double mGain;
112  bool mLink;
113 
114  wxSlider *mBassS;
115  wxSlider *mTrebleS;
116  wxSlider *mGainS;
117 
118  wxTextCtrl *mBassT;
119  wxTextCtrl *mTrebleT;
120  wxTextCtrl *mGainT;
121 
122  wxCheckBox *mLinkCheckBox;
123 
124  DECLARE_EVENT_TABLE()
125 };
126 
127 #endif
bool RealtimeFinalize() override
Definition: BassTreble.cpp:158
wxTextCtrl * mGainT
Definition: BassTreble.h:120
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
Definition: BassTreble.cpp:165
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
bool TransferDataFromWindow() override
Definition: BassTreble.cpp:286
bool GetAutomationParameters(EffectAutomationParameters &parms) override
Definition: BassTreble.cpp:173
void OnLinkCheckbox(wxCommandEvent &evt)
Definition: BassTreble.cpp:493
wxSlider * mGainS
Definition: BassTreble.h:116
A high shelf and low shelf filter.
Definition: BassTreble.h:42
bool CheckWhetherSkipEffect() override
Definition: BassTreble.cpp:198
Base class for many of the effects in Audacity.
Definition: Effect.h:61
bool TransferDataToWindow() override
Definition: BassTreble.cpp:271
std::vector< EffectBassTrebleState > mSlaves
Definition: BassTreble.h:107
wxString GetDescription() override
Definition: BassTreble.cpp:87
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
Definition: BassTreble.cpp:147
EffectType GetType() override
Definition: BassTreble.cpp:99
wxString GetSymbol() override
Definition: BassTreble.cpp:82
wxSlider * mTrebleS
Definition: BassTreble.h:115
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:498
wxTextCtrl * mTrebleT
Definition: BassTreble.h:119
bool RealtimeInitialize() override
Definition: BassTreble.cpp:138
void InstanceInit(EffectBassTrebleState &data, float sampleRate)
Definition: BassTreble.cpp:299
wxString ManualPage() override
Definition: BassTreble.cpp:92
float DoFilter(EffectBassTrebleState &data, float in)
Definition: BassTreble.cpp:406
bool SetAutomationParameters(EffectAutomationParameters &parms) override
Definition: BassTreble.cpp:183
unsigned GetAudioOutCount() override
Definition: BassTreble.cpp:121
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: BassTreble.cpp:126
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: BassTreble.cpp:133
unsigned GetAudioInCount() override
Definition: BassTreble.cpp:116
void OnGainText(wxCommandEvent &evt)
Definition: BassTreble.cpp:455
wxSlider * mBassS
Definition: BassTreble.h:114
size_t InstanceProcess(EffectBassTrebleState &data, float **inBlock, float **outBlock, size_t blockLen)
Definition: BassTreble.cpp:340
EffectBassTrebleState mMaster
Definition: BassTreble.h:106
void OnGainSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:485
bool SupportsRealtime() override
Definition: BassTreble.cpp:104
virtual ~EffectBassTreble()
Definition: BassTreble.cpp:76
void OnBassSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:465
wxTextCtrl * mBassT
Definition: BassTreble.h:118
wxCheckBox * mLinkCheckBox
Definition: BassTreble.h:122
void Coefficents(double hz, double slope, double gain, double samplerate, int type, double &a0, double &a1, double &a2, double &b0, double &b1, double &b2)
Definition: BassTreble.cpp:378
void OnBassText(wxCommandEvent &evt)
Definition: BassTreble.cpp:429
void OnTrebleSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:475
void PopulateOrExchange(ShuttleGui &S) override
Definition: BassTreble.cpp:206
void OnTrebleText(wxCommandEvent &evt)
Definition: BassTreble.cpp:442