Audacity  2.2.0
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 WX_DECLARE_OBJARRAY(EffectBassTrebleState, EffectBassTrebleStateArray);
43 
44 class EffectBassTreble final : public Effect
45 {
46 public:
48  virtual ~EffectBassTreble();
49 
50  // IdentInterface implementation
51 
52  wxString GetSymbol() override;
53  wxString GetDescription() override;
54  wxString ManualPage() override;
55 
56  // EffectIdentInterface implementation
57 
58  EffectType GetType() override;
59  bool SupportsRealtime() override;
60 
61  // EffectClientInterface implementation
62 
63  unsigned GetAudioInCount() override;
64  unsigned GetAudioOutCount() override;
65  bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
66  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
67  bool RealtimeInitialize() override;
68  bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override;
69  bool RealtimeFinalize() override;
70  size_t RealtimeProcess(int group,
71  float **inbuf,
72  float **outbuf,
73  size_t numSamples) override;
74  bool GetAutomationParameters(EffectAutomationParameters & parms) override;
75  bool SetAutomationParameters(EffectAutomationParameters & parms) override;
76 
77 
78  // Effect Implementation
79 
80  void PopulateOrExchange(ShuttleGui & S) override;
81  bool TransferDataToWindow() override;
82  bool TransferDataFromWindow() override;
83 
84  bool CheckWhetherSkipEffect() override;
85 
86 private:
87  // EffectBassTreble implementation
88 
89  void InstanceInit(EffectBassTrebleState & data, float sampleRate);
90  size_t InstanceProcess(EffectBassTrebleState & data, float **inBlock, float **outBlock, size_t blockLen);
91 
92  void Coefficents(double hz, double slope, double gain, double samplerate, int type,
93  double& a0, double& a1, double& a2, double& b0, double& b1, double& b2);
94  float DoFilter(EffectBassTrebleState & data, float in);
95 
96  void OnBassText(wxCommandEvent & evt);
97  void OnTrebleText(wxCommandEvent & evt);
98  void OnGainText(wxCommandEvent & evt);
99  void OnBassSlider(wxCommandEvent & evt);
100  void OnTrebleSlider(wxCommandEvent & evt);
101  void OnGainSlider(wxCommandEvent & evt);
102  void OnLinkCheckbox(wxCommandEvent & evt);
103 
104  // Auto-adjust gain to reduce variation in peak level
105  void UpdateGain(double oldVal, int control );
106 
107 private:
109  EffectBassTrebleStateArray mSlaves;
110 
111  double mBass;
112  double mTreble;
113  double mGain;
114  bool mLink;
115 
116  wxSlider *mBassS;
117  wxSlider *mTrebleS;
118  wxSlider *mGainS;
119 
120  wxTextCtrl *mBassT;
121  wxTextCtrl *mTrebleT;
122  wxTextCtrl *mGainT;
123 
124  wxCheckBox *mLinkCheckBox;
125 
126  DECLARE_EVENT_TABLE()
127 };
128 
129 #endif
double treble
Definition: BassTreble.h:32
bool RealtimeFinalize() override
Definition: BassTreble.cpp:161
EffectBassTreble()
Definition: BassTreble.cpp:69
double a2Bass
Definition: BassTreble.h:36
wxTextCtrl * mGainT
Definition: BassTreble.h:122
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
Definition: BassTreble.cpp:168
WX_DECLARE_OBJARRAY(EffectBassTrebleState, EffectBassTrebleStateArray)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:369
EffectBassTrebleStateArray mSlaves
Definition: BassTreble.h:109
bool TransferDataFromWindow() override
Definition: BassTreble.cpp:289
float samplerate
Definition: BassTreble.h:31
bool GetAutomationParameters(EffectAutomationParameters &parms) override
Definition: BassTreble.cpp:176
void OnLinkCheckbox(wxCommandEvent &evt)
Definition: BassTreble.cpp:496
double mBass
Definition: BassTreble.h:111
wxSlider * mGainS
Definition: BassTreble.h:118
double xn1Treble
Definition: BassTreble.h:39
double a2Treble
Definition: BassTreble.h:37
A high shelf and low shelf filter.
Definition: BassTreble.h:44
double a1Bass
Definition: BassTreble.h:36
bool CheckWhetherSkipEffect() override
Definition: BassTreble.cpp:201
Base class for many of the effects in Audacity.
Definition: Effect.h:62
bool TransferDataToWindow() override
Definition: BassTreble.cpp:274
double xn1Bass
Definition: BassTreble.h:38
double mGain
Definition: BassTreble.h:113
wxString GetDescription() override
Definition: BassTreble.cpp:90
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
Definition: BassTreble.cpp:150
double b1Treble
Definition: BassTreble.h:37
double mTreble
Definition: BassTreble.h:112
double a0Bass
Definition: BassTreble.h:36
double b0Bass
Definition: BassTreble.h:36
EffectType GetType() override
Definition: BassTreble.cpp:102
double b1Bass
Definition: BassTreble.h:36
wxString GetSymbol() override
Definition: BassTreble.cpp:85
wxSlider * mTrebleS
Definition: BassTreble.h:117
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:501
double yn1Treble
Definition: BassTreble.h:39
wxTextCtrl * mTrebleT
Definition: BassTreble.h:121
double b0Treble
Definition: BassTreble.h:37
double yn2Treble
Definition: BassTreble.h:39
double xn2Bass
Definition: BassTreble.h:38
bool mLink
Definition: BassTreble.h:114
bool RealtimeInitialize() override
Definition: BassTreble.cpp:141
void InstanceInit(EffectBassTrebleState &data, float sampleRate)
Definition: BassTreble.cpp:302
double xn2Treble
Definition: BassTreble.h:39
wxString ManualPage() override
Definition: BassTreble.cpp:95
float DoFilter(EffectBassTrebleState &data, float in)
Definition: BassTreble.cpp:409
bool SetAutomationParameters(EffectAutomationParameters &parms) override
Definition: BassTreble.cpp:186
unsigned GetAudioOutCount() override
Definition: BassTreble.cpp:124
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: BassTreble.cpp:129
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: BassTreble.cpp:136
unsigned GetAudioInCount() override
Definition: BassTreble.cpp:119
double hzTreble
Definition: BassTreble.h:35
void OnGainText(wxCommandEvent &evt)
Definition: BassTreble.cpp:458
wxSlider * mBassS
Definition: BassTreble.h:116
size_t InstanceProcess(EffectBassTrebleState &data, float **inBlock, float **outBlock, size_t blockLen)
Definition: BassTreble.cpp:343
EffectBassTrebleState mMaster
Definition: BassTreble.h:108
double bass
Definition: BassTreble.h:33
void OnGainSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:488
bool SupportsRealtime() override
Definition: BassTreble.cpp:107
virtual ~EffectBassTreble()
Definition: BassTreble.cpp:79
void OnBassSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:468
double yn2Bass
Definition: BassTreble.h:38
wxTextCtrl * mBassT
Definition: BassTreble.h:120
Definition: BassTreble.h:28
wxCheckBox * mLinkCheckBox
Definition: BassTreble.h:124
double b2Bass
Definition: BassTreble.h:36
double a0Treble
Definition: BassTreble.h:37
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:381
void OnBassText(wxCommandEvent &evt)
Definition: BassTreble.cpp:432
double hzBass
Definition: BassTreble.h:35
void OnTrebleSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:478
double slope
Definition: BassTreble.h:35
void PopulateOrExchange(ShuttleGui &S) override
Definition: BassTreble.cpp:209
double a1Treble
Definition: BassTreble.h:37
void OnTrebleText(wxCommandEvent &evt)
Definition: BassTreble.cpp:445
double yn1Bass
Definition: BassTreble.h:38
double b2Treble
Definition: BassTreble.h:37
double gain
Definition: BassTreble.h:34