Audacity 3.2.0
Loudness.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Loudness.cpp
6
7 Max Maisel
8
9***********************************************************************/
10#include "Loudness.h"
11#include "EffectEditor.h"
12
13#include <wx/simplebook.h>
14#include <wx/valgen.h>
15
16#include "Internat.h"
17#include "Prefs.h"
18#include "ShuttleGui.h"
19#include "../widgets/valnum.h"
20#include "ProgressDialog.h"
21
22#include "LoadEffects.h"
23
25 { XO("perceived loudness") }, { XO("RMS") }
26};
27
28BEGIN_EVENT_TABLE(EffectLoudness, wxEvtHandler)
29 EVT_CHOICE(wxID_ANY, EffectLoudness::OnChoice)
30 EVT_CHECKBOX(wxID_ANY, EffectLoudness::OnUpdateUI)
31 EVT_TEXT(wxID_ANY, EffectLoudness::OnUpdateUI)
33
35
36std::unique_ptr<EffectEditor> EffectLoudness::PopulateOrExchange(
38 const EffectOutputs *)
39{
40 mUIParent = S.GetParent();
41 S.StartVerticalLay(0);
42 {
43 S.StartMultiColumn(2, wxALIGN_CENTER);
44 {
45 S.StartVerticalLay(false);
46 {
47 S.StartHorizontalLay(wxALIGN_LEFT, false);
48 {
49 S.AddVariableText(XO("&Normalize"), false,
50 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
51
52 mChoice = S
53 .Validator<wxGenericValidator>( &mNormalizeTo )
54 .AddChoice( {},
57 S
58 .AddVariableText(XO("t&o"), false,
59 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
60
61 // Use a notebook so we can have two controls but show only one
62 // They target different variables with their validators
63 mBook =
64 S
65 .StartSimplebook();
66 {
67 S.StartNotebookPage({});
68 {
69 S.StartHorizontalLay(wxALIGN_LEFT, false);
70 {
71 S
72 /* i18n-hint: LUFS is a particular method for measuring loudnesss */
73 .Name( XO("Loudness LUFS") )
74 .Validator<FloatingPointValidator<double>>(
75 2, &mLUFSLevel,
76 NumValidatorStyle::ONE_TRAILING_ZERO,
78 .AddTextBox( {}, L"", 10);
79
80 /* i18n-hint: LUFS is a particular method for measuring loudnesss */
81 S
82 .AddVariableText(XO("LUFS"), false,
83 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
84 }
85 S.EndHorizontalLay();
86 }
87 S.EndNotebookPage();
88
89 S.StartNotebookPage({});
90 {
91 S.StartHorizontalLay(wxALIGN_LEFT, false);
92 {
93 S
94 .Name( XO("RMS dB") )
95 .Validator<FloatingPointValidator<double>>(
96 2, &mRMSLevel,
97 NumValidatorStyle::ONE_TRAILING_ZERO,
99 .AddTextBox( {}, L"", 10);
100
101 S
102 .AddVariableText(XO("dB"), false,
103 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
104 }
105 S.EndHorizontalLay();
106 }
107 S.EndNotebookPage();
108 }
109 S.EndSimplebook();
110
111 mWarning =
112 S
113 .AddVariableText( {}, false,
114 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
115 }
116 S.EndHorizontalLay();
117
119 .Validator<wxGenericValidator>( &mStereoInd )
120 .AddCheckBox(XXO("Normalize &stereo channels independently"),
121 mStereoInd );
122
124 .Validator<wxGenericValidator>( &mDualMono )
125 .AddCheckBox(XXO("&Treat mono as dual-mono (recommended)"),
126 mDualMono );
127 }
128 S.EndVerticalLay();
129 }
130 S.EndMultiColumn();
131 }
132 S.EndVerticalLay();
133 return nullptr;
134}
135
137{
138 if (!mUIParent->TransferDataToWindow())
139 {
140 return false;
141 }
142
143 // adjust controls which depend on mchoice
144 wxCommandEvent dummy;
145 OnChoice(dummy);
146 return true;
147}
148
150{
151 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
152 {
153 return false;
154 }
155 return true;
156}
157
158void EffectLoudness::OnChoice(wxCommandEvent & WXUNUSED(evt))
159{
160 mChoice->GetValidator()->TransferFromWindow();
161 mBook->SetSelection( mNormalizeTo );
162 UpdateUI();
164}
165
166void EffectLoudness::OnUpdateUI(wxCommandEvent & WXUNUSED(evt))
167{
168 UpdateUI();
169}
170
172{
173 if (!mUIParent->TransferDataFromWindow())
174 {
175 mWarning->SetLabel(_("(Maximum 0dB)"));
176 // TODO: recalculate layout here
178 return;
179 }
180 mWarning->SetLabel(wxT(""));
182}
wxT("CloseDown"))
END_EVENT_TABLE()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define _(s)
Definition: Internat.h:73
static const EnumValueSymbol kNormalizeTargetStrings[LoudnessBase::nAlgos]
Definition: Loudness.cpp:24
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
#define S(N)
Definition: ToChars.cpp:64
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
Performs effect computation.
wxCheckBox * mDualMonoCheckBox
Definition: Loudness.h:50
wxSimplebook * mBook
Definition: Loudness.h:46
wxCheckBox * mStereoIndCheckBox
Definition: Loudness.h:49
wxWeakRef< wxWindow > mUIParent
Definition: Loudness.h:44
wxChoice * mChoice
Definition: Loudness.h:47
void UpdateUI()
Definition: Loudness.cpp:171
void OnUpdateUI(wxCommandEvent &evt)
Definition: Loudness.cpp:166
bool TransferDataToWindow(const EffectSettings &settings) override
Definition: Loudness.cpp:136
bool TransferDataFromWindow(EffectSettings &settings) override
Definition: Loudness.cpp:149
std::unique_ptr< EffectEditor > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
Definition: Loudness.cpp:36
wxStaticText * mWarning
Definition: Loudness.h:48
void OnChoice(wxCommandEvent &evt)
Definition: Loudness.cpp:158
Hold values to send to effect output meters.
static constexpr EffectParameter LUFSLevel
Definition: LoudnessBase.h:95
double mLUFSLevel
Definition: LoudnessBase.h:73
static constexpr EffectParameter RMSLevel
Definition: LoudnessBase.h:98
double mRMSLevel
Definition: LoudnessBase.h:74
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< EffectLoudness > reg
Definition: Loudness.cpp:34
const Type min
Minimum value.
const Type max
Maximum value.
Externalized state of a plug-in.