Audacity 3.2.0
Normalize.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Normalize.cpp
6
7 Dominic Mazzoni
8 Vaughan Johnson (Preview)
9
10*******************************************************************//*******************************************************************/
16#include "Normalize.h"
17#include "EffectEditor.h"
18#include "LoadEffects.h"
19
20#include <wx/checkbox.h>
21#include <wx/stattext.h>
22#include <wx/valgen.h>
23
24#include "Prefs.h"
25#include "ShuttleGui.h"
26#include "../widgets/valnum.h"
27#include "ProgressDialog.h"
28
30
31BEGIN_EVENT_TABLE(EffectNormalize, wxEvtHandler)
32 EVT_CHECKBOX(wxID_ANY, EffectNormalize::OnUpdateUI)
33 EVT_TEXT(wxID_ANY, EffectNormalize::OnUpdateUI)
35
36std::unique_ptr<EffectEditor> EffectNormalize::PopulateOrExchange(
38 const EffectOutputs *)
39{
40 mUIParent = S.GetParent();
41 mCreating = true;
42
43 S.StartVerticalLay(0);
44 {
45 S.StartMultiColumn(2, wxALIGN_CENTER);
46 {
47 S.StartVerticalLay(false);
48 {
49 mDCCheckBox = S.Validator<wxGenericValidator>(&mDC)
50 .AddCheckBox(XXO("&Remove DC offset (center on 0.0 vertically)"),
51 mDC);
52
53 S.StartHorizontalLay(wxALIGN_LEFT, false);
54 {
55 mGainCheckBox = S
56 .MinSize()
57 .Validator<wxGenericValidator>(&mGain)
58 .AddCheckBox(XXO("&Normalize peak amplitude to "),
59 mGain);
60
61 mLevelTextCtrl = S
62 .Name(XO("Peak amplitude dB"))
63 .Validator<FloatingPointValidator<double>>(
64 2,
65 &mPeakLevel,
66 NumValidatorStyle::ONE_TRAILING_ZERO,
67 PeakLevel.min,
68 PeakLevel.max )
69 .AddTextBox( {}, L"", 10);
70 mLeveldB = S.AddVariableText(XO("dB"), false,
71 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
72 mWarning = S.AddVariableText( {}, false,
73 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
74 }
75 S.EndHorizontalLay();
76
77 mStereoIndCheckBox = S
78 .Validator<wxGenericValidator>(&mStereoInd)
79 .AddCheckBox(XXO("N&ormalize stereo channels independently"),
80 mStereoInd);
81 }
82 S.EndVerticalLay();
83 }
84 S.EndMultiColumn();
85 }
86 S.EndVerticalLay();
87 mCreating = false;
88 return nullptr;
89}
90
92{
93 if (!mUIParent->TransferDataToWindow())
94 {
95 return false;
96 }
97
98 UpdateUI();
99
100 return true;
101}
102
104{
105 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
106 {
107 return false;
108 }
109
110 return true;
111}
112
113// NormalizeBase implementation
114
115void EffectNormalize::OnUpdateUI(wxCommandEvent & WXUNUSED(evt))
116{
117 UpdateUI();
118}
119
121{
122
123 if (!mUIParent->TransferDataFromWindow())
124 {
125 mWarning->SetLabel(_("(Maximum 0dB)"));
127 return;
128 }
129 mWarning->SetLabel(wxT(""));
130
131 // Disallow level stuff if not normalizing
132 mLevelTextCtrl->Enable(mGain);
133 mLeveldB->Enable(mGain);
134 mStereoIndCheckBox->Enable(mGain);
135
136 // Disallow OK/Preview if doing nothing
138}
wxT("CloseDown"))
END_EVENT_TABLE()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define _(s)
Definition: Internat.h:73
#define S(N)
Definition: ToChars.cpp:64
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
Performs effect computation.
bool TransferDataFromWindow(EffectSettings &settings) override
Definition: Normalize.cpp:103
wxStaticText * mWarning
Definition: Normalize.h:48
wxStaticText * mLeveldB
Definition: Normalize.h:47
bool TransferDataToWindow(const EffectSettings &settings) override
Definition: Normalize.cpp:91
wxWeakRef< wxWindow > mUIParent
Definition: Normalize.h:42
void OnUpdateUI(wxCommandEvent &evt)
Definition: Normalize.cpp:115
wxTextCtrl * mLevelTextCtrl
Definition: Normalize.h:46
wxCheckBox * mStereoIndCheckBox
Definition: Normalize.h:49
Hold values to send to effect output meters.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
A Validator is an object which checks whether a wxVariant satisfies a certain criterion....
Definition: Validators.h:54
BuiltinEffectsModule::Registration< EffectNormalize > reg
Definition: Normalize.cpp:29
STL namespace.
Externalized state of a plug-in.