Audacity  2.2.0
Amplify.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Amplify.h
6 
7  Dominic Mazzoni
8 
9  This rewritten class supports a smart Amplify effect - it calculates
10  the maximum amount of gain that can be applied to all tracks without
11  causing clipping and selects this as the default parameter.
12 
13 **********************************************************************/
14 
15 #ifndef __AUDACITY_EFFECT_AMPLIFY__
16 #define __AUDACITY_EFFECT_AMPLIFY__
17 
18 #include <wx/checkbox.h>
19 #include <wx/event.h>
20 #include <wx/slider.h>
21 #include <wx/string.h>
22 #include <wx/textctrl.h>
23 
24 #include "Effect.h"
25 
26 #define AMPLIFY_PLUGIN_SYMBOL XO("Amplify")
27 
28 class ShuttleGui;
29 
30 class EffectAmplify final : public Effect
31 {
32 public:
33  EffectAmplify();
34  virtual ~EffectAmplify();
35 
36  // IdentInterface implementation
37 
38  wxString GetSymbol() override;
39  wxString GetDescription() override;
40  wxString ManualPage() override;
41 
42  // EffectIdentInterface implementation
43 
44  EffectType GetType() override;
45 
46  // EffectClientInterface implementation
47 
48  unsigned GetAudioInCount() override;
49  unsigned GetAudioOutCount() override;
50  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
51  bool GetAutomationParameters(EffectAutomationParameters & parms) override;
52  bool SetAutomationParameters(EffectAutomationParameters & parms) override;
53  bool LoadFactoryDefaults() override;
54 
55  // Effect implementation
56 
57  bool Init() override;
58  void Preview(bool dryOnly) override;
59  void PopulateOrExchange(ShuttleGui & S) override;
60  bool TransferDataToWindow() override;
61  bool TransferDataFromWindow() override;
62 
63 private:
64  // EffectAmplify implementation
65 
66  void OnAmpText(wxCommandEvent & evt);
67  void OnPeakText(wxCommandEvent & evt);
68  void OnAmpSlider(wxCommandEvent & evt);
69  void OnClipCheckBox(wxCommandEvent & evt);
70  void CheckClip();
71 
72 private:
73  double mPeak;
74 
75  double mRatio;
76  double mRatioClip; // maximum value of mRatio which does not cause clipping
77  double mAmp;
78  double mNewPeak;
79  bool mCanClip;
80 
81  wxSlider *mAmpS;
82  wxTextCtrl *mAmpT;
83  wxTextCtrl *mNewPeakT;
84  wxCheckBox *mClip;
85 
86  DECLARE_EVENT_TABLE()
87 };
88 
89 #endif // __AUDACITY_EFFECT_AMPLIFY__
EffectType GetType() override
Definition: Amplify.cpp:100
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
void OnAmpText(wxCommandEvent &evt)
Definition: Amplify.cpp:320
unsigned GetAudioOutCount() override
Definition: Amplify.cpp:112
wxTextCtrl * mNewPeakT
Definition: Amplify.h:83
double mRatio
Definition: Amplify.h:75
bool TransferDataToWindow() override
Definition: Amplify.cpp:271
unsigned GetAudioInCount() override
Definition: Amplify.cpp:107
Base class for many of the effects in Audacity.
Definition: Effect.h:62
wxString GetSymbol() override
Definition: Amplify.cpp:82
wxCheckBox * mClip
Definition: Amplify.h:84
bool Init() override
Definition: Amplify.cpp:164
void PopulateOrExchange(ShuttleGui &S) override
Definition: Amplify.cpp:193
void OnAmpSlider(wxCommandEvent &evt)
Definition: Amplify.cpp:363
void Preview() override
Definition: Effect.cpp:772
bool mCanClip
Definition: Amplify.h:79
void OnPeakText(wxCommandEvent &evt)
Definition: Amplify.cpp:338
bool TransferDataFromWindow() override
Definition: Amplify.cpp:294
wxString ManualPage() override
Definition: Amplify.cpp:93
void CheckClip()
Definition: Amplify.cpp:315
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: Amplify.cpp:117
wxSlider * mAmpS
Definition: Amplify.h:81
double mPeak
Definition: Amplify.h:73
EffectAmplify()
Definition: Amplify.cpp:65
wxString GetDescription() override
Definition: Amplify.cpp:87
void OnClipCheckBox(wxCommandEvent &evt)
Definition: Amplify.cpp:385
An Effect that makes a sound louder or softer.
Definition: Amplify.h:30
double mRatioClip
Definition: Amplify.h:76
bool LoadFactoryDefaults() override
Definition: Amplify.cpp:143
double mAmp
Definition: Amplify.h:77
wxTextCtrl * mAmpT
Definition: Amplify.h:82
bool SetAutomationParameters(EffectAutomationParameters &parms) override
Definition: Amplify.cpp:134
double mNewPeak
Definition: Amplify.h:78
bool GetAutomationParameters(EffectAutomationParameters &parms) override
Definition: Amplify.cpp:127
virtual ~EffectAmplify()
Definition: Amplify.cpp:76