Audacity 3.2.0
Normalize.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Normalize.h
6
7 Dominic Mazzoni
8 Vaughan Johnson (Preview)
9
10**********************************************************************/
11
12#ifndef __AUDACITY_EFFECT_NORMALIZE__
13#define __AUDACITY_EFFECT_NORMALIZE__
14
15#include "StatefulEffect.h"
16#include "Biquad.h"
17#include "ShuttleAutomation.h"
18#include <wx/weakref.h>
19#include <functional>
20
21class wxCheckBox;
22class wxStaticText;
23class wxTextCtrl;
24class ShuttleGui;
25class WaveChannel;
26
27class EffectNormalize final : public StatefulEffect
28{
29public:
30 static inline EffectNormalize *
33
35 virtual ~EffectNormalize();
36
37 // ComponentInterface implementation
38
39 ComponentInterfaceSymbol GetSymbol() const override;
40 TranslatableString GetDescription() const override;
41 ManualPageID ManualPage() const override;
42
43 // EffectDefinitionInterface implementation
44
45 EffectType GetType() const override;
46
47 // Effect implementation
48
49 bool CheckWhetherSkipEffect(const EffectSettings &settings) const override;
50 bool Process(EffectInstance &instance, EffectSettings &settings) override;
51 std::unique_ptr<EffectEditor> PopulateOrExchange(
52 ShuttleGui & S, EffectInstance &instance,
53 EffectSettingsAccess &access, const EffectOutputs *pOutputs) override;
54 bool TransferDataToWindow(const EffectSettings &settings) override;
56
57private:
58 // EffectNormalize implementation
59
60 bool ProcessOne(WaveChannel &track,
61 const TranslatableString &msg, double& progress, float offset);
62 using ProgressReport = std::function<bool(double fraction)>;
63 static bool AnalyseTrack(const WaveChannel &track,
64 const ProgressReport &report,
65 bool gain, bool dc, double curT0, double curT1,
66 float &offset, float &extent);
67 static bool AnalyseTrackData(const WaveChannel &track,
68 const ProgressReport &report, double curT0, double curT1,
69 float &offset);
70 static double AnalyseDataDC(float *buffer, size_t len, double sum);
71 void ProcessData(float *buffer, size_t len, float offset);
72
73 void OnUpdateUI(wxCommandEvent & evt);
74 void UpdateUI();
75
76private:
77 wxWeakRef<wxWindow> mUIParent{};
78
79 double mPeakLevel;
80 bool mGain;
81 bool mDC;
83
84 double mCurT0;
85 double mCurT1;
86 float mMult;
87
88 wxCheckBox *mGainCheckBox;
89 wxCheckBox *mDCCheckBox;
90 wxTextCtrl *mLevelTextCtrl;
91 wxStaticText *mLeveldB;
92 wxStaticText *mWarning;
93 wxCheckBox *mStereoIndCheckBox;
95
96 const EffectParameterMethods& Parameters() const override;
97 DECLARE_EVENT_TABLE()
98
100 L"PeakLevel", -1.0, -145.0, 0.0, 1 };
102 L"RemoveDcOffset", true, false, true, 1 };
104 L"ApplyGain", true, false, true, 1 };
106 L"StereoIndependent", false, false, true, 1 };
107};
108
109#endif
EffectType
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:69
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Performs effect computation.
An Effect to bring the peak level up to a chosen level.
Definition: Normalize.h:28
static constexpr EffectParameter RemoveDC
Definition: Normalize.h:101
static EffectNormalize * FetchParameters(EffectNormalize &e, EffectSettings &)
Definition: Normalize.h:31
bool TransferDataFromWindow(EffectSettings &settings) override
Definition: Normalize.cpp:287
static double AnalyseDataDC(float *buffer, size_t len, double sum)
Definition: Normalize.cpp:458
wxStaticText * mWarning
Definition: Normalize.h:92
static bool AnalyseTrackData(const WaveChannel &track, const ProgressReport &report, double curT0, double curT1, float &offset)
Definition: Normalize.cpp:334
double mCurT0
Definition: Normalize.h:84
EffectType GetType() const override
Type determines how it behaves.
Definition: Normalize.cpp:81
wxStaticText * mLeveldB
Definition: Normalize.h:91
static constexpr EffectParameter StereoInd
Definition: Normalize.h:105
bool Process(EffectInstance &instance, EffectSettings &settings) override
Definition: Normalize.cpp:93
std::unique_ptr< EffectEditor > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
Definition: Normalize.cpp:220
bool TransferDataToWindow(const EffectSettings &settings) override
Definition: Normalize.cpp:275
const EffectParameterMethods & Parameters() const override
Definition: Normalize.cpp:34
static constexpr EffectParameter PeakLevel
Definition: Normalize.h:99
wxWeakRef< wxWindow > mUIParent
Definition: Normalize.h:77
double mPeakLevel
Definition: Normalize.h:79
wxCheckBox * mGainCheckBox
Definition: Normalize.h:88
wxCheckBox * mDCCheckBox
Definition: Normalize.h:89
ComponentInterfaceSymbol GetSymbol() const override
Definition: Normalize.cpp:64
double mCurT1
Definition: Normalize.h:85
virtual ~EffectNormalize()
Definition: Normalize.cpp:58
static const ComponentInterfaceSymbol Symbol
Definition: Normalize.h:32
void OnUpdateUI(wxCommandEvent &evt)
Definition: Normalize.cpp:473
static constexpr EffectParameter ApplyGain
Definition: Normalize.h:103
bool ProcessOne(WaveChannel &track, const TranslatableString &msg, double &progress, float offset)
Definition: Normalize.cpp:400
TranslatableString GetDescription() const override
Definition: Normalize.cpp:69
wxTextCtrl * mLevelTextCtrl
Definition: Normalize.h:90
wxCheckBox * mStereoIndCheckBox
Definition: Normalize.h:93
static bool AnalyseTrack(const WaveChannel &track, const ProgressReport &report, bool gain, bool dc, double curT0, double curT1, float &offset, float &extent)
Definition: Normalize.cpp:299
void ProcessData(float *buffer, size_t len, float offset)
Definition: Normalize.cpp:465
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
After Init(), tell whether Process() should be skipped.
Definition: Normalize.cpp:88
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
Definition: Normalize.cpp:74
std::function< bool(double fraction)> ProgressReport
Definition: Normalize.h:62
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:630
Holds a msgid for the translation catalog; may also bind format arguments.
Externalized state of a plug-in.