Audacity  3.0.3
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 "Effect.h"
16 
17 class wxSlider;
18 class wxCheckBox;
19 class wxTextCtrl;
20 class ShuttleGui;
21 
23 {
24 public:
25  float samplerate;
26  double treble;
27  double bass;
28  double gain;
29  double slope, hzBass, hzTreble;
34 };
35 
36 class EffectBassTreble final : public Effect
37 {
38 public:
40 
42  virtual ~EffectBassTreble();
43 
44  // ComponentInterface implementation
45 
48  ManualPageID ManualPage() override;
49 
50  // EffectDefinitionInterface implementation
51 
52  EffectType GetType() override;
53  bool SupportsRealtime() override;
54 
55  // EffectClientInterface implementation
56 
57  unsigned GetAudioInCount() override;
58  unsigned GetAudioOutCount() override;
59  bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
60  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
61  bool RealtimeInitialize() override;
62  bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override;
63  bool RealtimeFinalize() override;
64  size_t RealtimeProcess(int group,
65  float **inbuf,
66  float **outbuf,
67  size_t numSamples) override;
68  bool DefineParams( ShuttleParams & S ) override;
69  bool GetAutomationParameters(CommandParameters & parms) override;
70  bool SetAutomationParameters(CommandParameters & parms) override;
71 
72 
73  // Effect Implementation
74 
75  void PopulateOrExchange(ShuttleGui & S) override;
76  bool TransferDataToWindow() override;
77  bool TransferDataFromWindow() override;
78 
79  bool CheckWhetherSkipEffect() override;
80 
81 private:
82  // EffectBassTreble implementation
83 
84  void InstanceInit(EffectBassTrebleState & data, float sampleRate);
85  size_t InstanceProcess(EffectBassTrebleState & data, float **inBlock, float **outBlock, size_t blockLen);
86 
87  void Coefficients(double hz, double slope, double gain, double samplerate, int type,
88  double& a0, double& a1, double& a2, double& b0, double& b1, double& b2);
89  float DoFilter(EffectBassTrebleState & data, float in);
90 
91  void OnBassText(wxCommandEvent & evt);
92  void OnTrebleText(wxCommandEvent & evt);
93  void OnGainText(wxCommandEvent & evt);
94  void OnBassSlider(wxCommandEvent & evt);
95  void OnTrebleSlider(wxCommandEvent & evt);
96  void OnGainSlider(wxCommandEvent & evt);
97  void OnLinkCheckbox(wxCommandEvent & evt);
98 
99  // Auto-adjust gain to reduce variation in peak level
100  void UpdateGain(double oldVal, int control );
101 
102 private:
104  std::vector<EffectBassTrebleState> mSlaves;
105 
106  double mBass;
107  double mTreble;
108  double mGain;
109  bool mLink;
110 
111  wxSlider *mBassS;
112  wxSlider *mTrebleS;
113  wxSlider *mGainS;
114 
115  wxTextCtrl *mBassT;
116  wxTextCtrl *mTrebleT;
117  wxTextCtrl *mGainT;
118 
119  wxCheckBox *mLinkCheckBox;
120 
121  DECLARE_EVENT_TABLE()
122 };
123 
124 #endif
EffectBassTreble::GetType
EffectType GetType() override
Definition: BassTreble.cpp:108
EffectBassTreble::GetAudioOutCount
unsigned GetAudioOutCount() override
Definition: BassTreble.cpp:130
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
EffectBassTrebleState
Definition: BassTreble.h:23
EffectBassTrebleState::xn2Treble
double xn2Treble
Definition: BassTreble.h:33
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
EffectBassTrebleState::slope
double slope
Definition: BassTreble.h:29
EffectBassTreble::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: BassTreble.cpp:305
EffectBassTreble::RealtimeAddProcessor
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
Definition: BassTreble.cpp:156
EffectBassTreble::mTrebleT
wxTextCtrl * mTrebleT
Definition: BassTreble.h:116
EffectBassTrebleState::b0Treble
double b0Treble
Definition: BassTreble.h:31
EffectBassTrebleState::b2Treble
double b2Treble
Definition: BassTreble.h:31
EffectBassTrebleState::yn1Bass
double yn1Bass
Definition: BassTreble.h:32
EffectBassTreble::mLinkCheckBox
wxCheckBox * mLinkCheckBox
Definition: BassTreble.h:119
EffectBassTrebleState::yn2Treble
double yn2Treble
Definition: BassTreble.h:33
Effect.h
EffectBassTreble::GetAutomationParameters
bool GetAutomationParameters(CommandParameters &parms) override
Definition: BassTreble.cpp:189
Effect
Base class for many of the effects in Audacity.
Definition: Effect.h:72
EffectBassTrebleState::a2Bass
double a2Bass
Definition: BassTreble.h:30
EffectBassTreble::mTrebleS
wxSlider * mTrebleS
Definition: BassTreble.h:112
EffectBassTrebleState::yn2Bass
double yn2Bass
Definition: BassTreble.h:32
EffectBassTreble::ProcessInitialize
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: BassTreble.cpp:135
EffectBassTrebleState::gain
double gain
Definition: BassTreble.h:28
EffectBassTreble::RealtimeFinalize
bool RealtimeFinalize() override
Definition: BassTreble.cpp:167
EffectBassTrebleState::b0Bass
double b0Bass
Definition: BassTreble.h:30
EffectBassTreble::RealtimeProcess
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
Definition: BassTreble.cpp:174
EffectBassTrebleState::a2Treble
double a2Treble
Definition: BassTreble.h:31
EffectBassTreble::GetAudioInCount
unsigned GetAudioInCount() override
Definition: BassTreble.cpp:125
ShuttleParams
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:62
EffectBassTrebleState::b1Treble
double b1Treble
Definition: BassTreble.h:31
EffectBassTreble::EffectBassTreble
EffectBassTreble()
Definition: BassTreble.cpp:75
EffectBassTrebleState::bass
double bass
Definition: BassTreble.h:27
EffectBassTreble::OnGainText
void OnGainText(wxCommandEvent &evt)
Definition: BassTreble.cpp:474
EffectBassTrebleState::samplerate
float samplerate
Definition: BassTreble.h:25
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
EffectBassTrebleState::hzTreble
double hzTreble
Definition: BassTreble.h:29
EffectBassTreble::OnLinkCheckbox
void OnLinkCheckbox(wxCommandEvent &evt)
Definition: BassTreble.cpp:512
EffectBassTrebleState::b2Bass
double b2Bass
Definition: BassTreble.h:30
EffectBassTreble::RealtimeInitialize
bool RealtimeInitialize() override
Definition: BassTreble.cpp:147
EffectBassTrebleState::xn1Treble
double xn1Treble
Definition: BassTreble.h:33
EffectBassTreble::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: BassTreble.h:39
EffectBassTreble::mGainT
wxTextCtrl * mGainT
Definition: BassTreble.h:117
EffectBassTreble::InstanceInit
void InstanceInit(EffectBassTrebleState &data, float sampleRate)
Definition: BassTreble.cpp:318
EffectBassTreble::CheckWhetherSkipEffect
bool CheckWhetherSkipEffect() override
Definition: BassTreble.cpp:214
EffectBassTreble::OnBassSlider
void OnBassSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:484
EffectBassTreble::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: BassTreble.cpp:181
EffectBassTreble::mSlaves
std::vector< EffectBassTrebleState > mSlaves
Definition: BassTreble.h:104
EffectBassTreble::OnTrebleText
void OnTrebleText(wxCommandEvent &evt)
Definition: BassTreble.cpp:461
EffectBassTreble::DoFilter
float DoFilter(EffectBassTrebleState &data, float in)
Definition: BassTreble.cpp:425
EffectBassTreble::mGain
double mGain
Definition: BassTreble.h:108
EffectBassTreble::ProcessBlock
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: BassTreble.cpp:142
EffectBassTreble::mLink
bool mLink
Definition: BassTreble.h:109
EffectBassTreble::SetAutomationParameters
bool SetAutomationParameters(CommandParameters &parms) override
Definition: BassTreble.cpp:199
EffectBassTrebleState::a0Treble
double a0Treble
Definition: BassTreble.h:31
EffectBassTrebleState::b1Bass
double b1Bass
Definition: BassTreble.h:30
EffectBassTreble::mBass
double mBass
Definition: BassTreble.h:106
EffectBassTrebleState::yn1Treble
double yn1Treble
Definition: BassTreble.h:33
EffectBassTreble::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: BassTreble.cpp:222
EffectBassTrebleState::xn1Bass
double xn1Bass
Definition: BassTreble.h:32
ChannelNames
enum ChannelName * ChannelNames
EffectBassTreble::OnGainSlider
void OnGainSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:504
EffectBassTreble::SupportsRealtime
bool SupportsRealtime() override
Definition: BassTreble.cpp:113
EffectBassTreble::~EffectBassTreble
virtual ~EffectBassTreble()
Definition: BassTreble.cpp:85
EffectBassTrebleState::a1Treble
double a1Treble
Definition: BassTreble.h:31
EffectBassTreble
A high shelf and low shelf filter.
Definition: BassTreble.h:37
EffectBassTrebleState::xn2Bass
double xn2Bass
Definition: BassTreble.h:32
EffectBassTreble::OnTrebleSlider
void OnTrebleSlider(wxCommandEvent &evt)
Definition: BassTreble.cpp:494
EffectBassTreble::mBassS
wxSlider * mBassS
Definition: BassTreble.h:111
EffectBassTreble::mBassT
wxTextCtrl * mBassT
Definition: BassTreble.h:115
EffectBassTreble::TransferDataToWindow
bool TransferDataToWindow() override
Definition: BassTreble.cpp:290
EffectBassTreble::Coefficients
void Coefficients(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:397
TaggedIdentifier< ManualPageIDTag >
EffectBassTreble::mTreble
double mTreble
Definition: BassTreble.h:107
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
EffectBassTreble::OnBassText
void OnBassText(wxCommandEvent &evt)
Definition: BassTreble.cpp:448
EffectBassTreble::mGainS
wxSlider * mGainS
Definition: BassTreble.h:113
EffectBassTreble::UpdateGain
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:517
EffectBassTreble::ManualPage
ManualPageID ManualPage() override
Definition: BassTreble.cpp:101
EffectBassTrebleState::a1Bass
double a1Bass
Definition: BassTreble.h:30
EffectBassTreble::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: BassTreble.cpp:91
EffectBassTreble::InstanceProcess
size_t InstanceProcess(EffectBassTrebleState &data, float **inBlock, float **outBlock, size_t blockLen)
Definition: BassTreble.cpp:359
EffectBassTrebleState::a0Bass
double a0Bass
Definition: BassTreble.h:30
EffectBassTrebleState::hzBass
double hzBass
Definition: BassTreble.h:29
EffectType
EffectType
Definition: EffectInterface.h:55
EffectBassTreble::GetDescription
TranslatableString GetDescription() override
Definition: BassTreble.cpp:96
EffectBassTreble::mMaster
EffectBassTrebleState mMaster
Definition: BassTreble.h:103
EffectBassTrebleState::treble
double treble
Definition: BassTreble.h:26
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631