Audacity  2.2.2
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 IdentInterfaceSymbol{ 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 
39  wxString GetDescription() override;
40  wxString ManualPage() override;
41 
42  // EffectDefinitionInterface 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 DefineParams( ShuttleParams & S ) override;
52  bool GetAutomationParameters(CommandParameters & parms) override;
53  bool SetAutomationParameters(CommandParameters & parms) override;
54  bool LoadFactoryDefaults() override;
55 
56  // Effect implementation
57 
58  bool Init() override;
59  void Preview(bool dryOnly) override;
60  void PopulateOrExchange(ShuttleGui & S) override;
61  bool TransferDataToWindow() override;
62  bool TransferDataFromWindow() override;
63 
64 private:
65  // EffectAmplify implementation
66 
67  void OnAmpText(wxCommandEvent & evt);
68  void OnPeakText(wxCommandEvent & evt);
69  void OnAmpSlider(wxCommandEvent & evt);
70  void OnClipCheckBox(wxCommandEvent & evt);
71  void CheckClip();
72 
73 private:
74  double mPeak;
75 
76  double mRatio;
77  double mRatioClip; // maximum value of mRatio which does not cause clipping
78  double mAmp;
79  double mNewPeak;
80  bool mCanClip;
81 
82  wxSlider *mAmpS;
83  wxTextCtrl *mAmpT;
84  wxTextCtrl *mNewPeakT;
85  wxCheckBox *mClip;
86 
87  DECLARE_EVENT_TABLE()
88 };
89 
90 #endif // __AUDACITY_EFFECT_AMPLIFY__
EffectType GetType() override
Definition: Amplify.cpp:101
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
void OnAmpText(wxCommandEvent &evt)
Definition: Amplify.cpp:335
unsigned GetAudioOutCount() override
Definition: Amplify.cpp:113
wxTextCtrl * mNewPeakT
Definition: Amplify.h:84
double mRatio
Definition: Amplify.h:76
bool TransferDataToWindow() override
Definition: Amplify.cpp:286
unsigned GetAudioInCount() override
Definition: Amplify.cpp:108
Base class for many of the effects in Audacity.
Definition: Effect.h:62
wxCheckBox * mClip
Definition: Amplify.h:85
bool Init() override
Definition: Amplify.cpp:179
bool GetAutomationParameters(CommandParameters &parms) override
Definition: Amplify.cpp:134
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:60
void PopulateOrExchange(ShuttleGui &S) override
Definition: Amplify.cpp:208
void OnAmpSlider(wxCommandEvent &evt)
Definition: Amplify.cpp:378
void Preview() override
Definition: Effect.cpp:771
bool mCanClip
Definition: Amplify.h:80
void OnPeakText(wxCommandEvent &evt)
Definition: Amplify.cpp:353
bool TransferDataFromWindow() override
Definition: Amplify.cpp:309
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
wxString ManualPage() override
Definition: Amplify.cpp:94
void CheckClip()
Definition: Amplify.cpp:330
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: Amplify.cpp:118
wxSlider * mAmpS
Definition: Amplify.h:82
IdentInterfaceSymbol GetSymbol() override
Definition: Amplify.cpp:83
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
double mPeak
Definition: Amplify.h:74
bool SetAutomationParameters(CommandParameters &parms) override
Definition: Amplify.cpp:143
wxString GetDescription() override
Definition: Amplify.cpp:88
EffectType
void OnClipCheckBox(wxCommandEvent &evt)
Definition: Amplify.cpp:400
An Effect that makes a sound louder or softer.
Definition: Amplify.h:30
double mRatioClip
Definition: Amplify.h:77
bool LoadFactoryDefaults() override
Definition: Amplify.cpp:158
double mAmp
Definition: Amplify.h:78
wxTextCtrl * mAmpT
Definition: Amplify.h:83
bool DefineParams(ShuttleParams &S) override
Definition: Amplify.cpp:127
double mNewPeak
Definition: Amplify.h:79
virtual ~EffectAmplify()
Definition: Amplify.cpp:77