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 IdentInterfaceSymbol{ 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 
51  wxString GetDescription() override;
52  wxString ManualPage() override;
53 
54  // EffectDefinitionInterface 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 DefineParams( ShuttleParams & S ) override;
73  bool GetAutomationParameters(CommandParameters & parms) override;
74  bool SetAutomationParameters(CommandParameters & parms) override;
75 
76 
77  // Effect Implementation
78 
79  void PopulateOrExchange(ShuttleGui & S) override;
80  bool TransferDataToWindow() override;
81  bool TransferDataFromWindow() override;
82 
83  bool CheckWhetherSkipEffect() override;
84 
85 private:
86  // EffectBassTreble implementation
87 
88  void InstanceInit(EffectBassTrebleState & data, float sampleRate);
89  size_t InstanceProcess(EffectBassTrebleState & data, float **inBlock, float **outBlock, size_t blockLen);
90 
91  void Coefficents(double hz, double slope, double gain, double samplerate, int type,
92  double& a0, double& a1, double& a2, double& b0, double& b1, double& b2);
93  float DoFilter(EffectBassTrebleState & data, float in);
94 
95  void OnBassText(wxCommandEvent & evt);
96  void OnTrebleText(wxCommandEvent & evt);
97  void OnGainText(wxCommandEvent & evt);
98  void OnBassSlider(wxCommandEvent & evt);
99  void OnTrebleSlider(wxCommandEvent & evt);
100  void OnGainSlider(wxCommandEvent & evt);
101  void OnLinkCheckbox(wxCommandEvent & evt);
102 
103  // Auto-adjust gain to reduce variation in peak level
104  void UpdateGain(double oldVal, int control );
105 
106 private:
108  std::vector<EffectBassTrebleState> mSlaves;
109 
110  double mBass;
111  double mTreble;
112  double mGain;
113  bool mLink;
114 
115  wxSlider *mBassS;
116  wxSlider *mTrebleS;
117  wxSlider *mGainS;
118 
119  wxTextCtrl *mBassT;
120  wxTextCtrl *mTrebleT;
121  wxTextCtrl *mGainT;
122 
123  wxCheckBox *mLinkCheckBox;
124 
125  DECLARE_EVENT_TABLE()
126 };
127 
128 #endif
bool RealtimeFinalize() override
Definition: BassTreble.cpp:158
wxTextCtrl * mGainT
Definition: BassTreble.h:121
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
Definition: BassTreble.cpp:165
bool GetAutomationParameters(CommandParameters &parms) override
Definition: BassTreble.cpp:180
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
bool TransferDataFromWindow() override
Definition: BassTreble.cpp:293
void OnLinkCheckbox(wxCommandEvent &evt)
Definition: BassTreble.cpp:500
wxSlider * mGainS
Definition: BassTreble.h:117
bool DefineParams(ShuttleParams &S) override
Definition: BassTreble.cpp:172
A high shelf and low shelf filter.
Definition: BassTreble.h:42
bool CheckWhetherSkipEffect() override
Definition: BassTreble.cpp:205
Base class for many of the effects in Audacity.
Definition: Effect.h:62
bool TransferDataToWindow() override
Definition: BassTreble.cpp:278
std::vector< EffectBassTrebleState > mSlaves
Definition: BassTreble.h:108
wxString GetDescription() override
Definition: BassTreble.cpp:87
bool SetAutomationParameters(CommandParameters &parms) override
Definition: BassTreble.cpp:190
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:60
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
Definition: BassTreble.cpp:147
EffectType GetType() override
Definition: BassTreble.cpp:99
wxSlider * mTrebleS
Definition: BassTreble.h:116
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:505
wxTextCtrl * mTrebleT
Definition: BassTreble.h:120
bool RealtimeInitialize() override
Definition: BassTreble.cpp:138
void InstanceInit(EffectBassTrebleState &data, float sampleRate)
Definition: BassTreble.cpp:306
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
IdentInterfaceSymbol GetSymbol() override
Definition: BassTreble.cpp:82
wxString ManualPage() override
Definition: BassTreble.cpp:92
float DoFilter(EffectBassTrebleState &data, float in)
Definition: BassTreble.cpp:413
unsigned GetAudioOutCount() override
Definition: BassTreble.cpp:121
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
enum ChannelName * ChannelNames
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:462
wxSlider * mBassS
Definition: BassTreble.h:115
size_t InstanceProcess(EffectBassTrebleState &data, float **inBlock, float **outBlock, size_t blockLen)
Definition: BassTreble.cpp:347
EffectType
EffectBassTrebleState mMaster
Definition: BassTreble.h:107
void OnGainSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:492
bool SupportsRealtime() override
Definition: BassTreble.cpp:104
virtual ~EffectBassTreble()
Definition: BassTreble.cpp:76
void OnBassSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:472
wxTextCtrl * mBassT
Definition: BassTreble.h:119
wxCheckBox * mLinkCheckBox
Definition: BassTreble.h:123
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:385
void OnBassText(wxCommandEvent &evt)
Definition: BassTreble.cpp:436
void OnTrebleSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:482
void PopulateOrExchange(ShuttleGui &S) override
Definition: BassTreble.cpp:213
void OnTrebleText(wxCommandEvent &evt)
Definition: BassTreble.cpp:449