22#include <wx/simplebook.h>
27#include "../ProjectFileManager.h"
28#include "../ShuttleGui.h"
29#include "../WaveTrack.h"
30#include "../widgets/valnum.h"
31#include "../widgets/ProgressDialog.h"
37 {
XO(
"perceived loudness") },
56{
XO(
"Loudness Normalization") };
79 return XO(
"Sets the loudness of one or more tracks");
84 return L
"Loudness_Normalization";
107 bool bGoodResult =
true;
108 auto topMsg =
XO(
"Normalizing Loudness...\n");
118 double trackStart = track->GetStartTime();
119 double trackEnd = track->GetEndTime();
130 auto trackName = track->GetName();
134 topMsg +
XO(
"Analyzing: %s").Format( trackName );
156 for(
auto channel : range)
219 S.StartVerticalLay(0);
221 S.StartMultiColumn(2, wxALIGN_CENTER);
223 S.StartVerticalLay(
false);
225 S.StartHorizontalLay(wxALIGN_LEFT,
false);
227 S.AddVariableText(
XO(
"&Normalize"),
false,
228 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
236 .AddVariableText(
XO(
"t&o"),
false,
237 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
245 S.StartNotebookPage({});
247 S.StartHorizontalLay(wxALIGN_LEFT,
false);
251 .Name(
XO(
"Loudness LUFS") )
252 .
Validator<FloatingPointValidator<double>>(
254 NumValidatorStyle::ONE_TRAILING_ZERO,
256 .AddTextBox( {}, L
"", 10);
260 .AddVariableText(
XO(
"LUFS"),
false,
261 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
263 S.EndHorizontalLay();
267 S.StartNotebookPage({});
269 S.StartHorizontalLay(wxALIGN_LEFT,
false);
272 .Name(
XO(
"RMS dB") )
273 .
Validator<FloatingPointValidator<double>>(
275 NumValidatorStyle::ONE_TRAILING_ZERO,
277 .AddTextBox( {}, L
"", 10);
280 .AddVariableText(
XO(
"dB"),
false,
281 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
283 S.EndHorizontalLay();
291 .AddVariableText( {},
false,
292 wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
294 S.EndHorizontalLay();
298 .AddCheckBox(
XXO(
"Normalize &stereo channels independently"),
302 .Validator<wxGenericValidator>( &
mDualMono )
303 .AddCheckBox(
XXO(
"&Treat mono as dual-mono (recommended)"),
322 wxCommandEvent dummy;
343 bool stereoTrackFound =
false;
344 double maxSampleRate = 0;
350 maxSampleRate = std::max(maxSampleRate, track->GetRate());
353 if(track->IsLeader())
354 stereoTrackFound =
true;
413 const size_t remainingLen = (
end - s).as_size_t();
414 blockLen = blockLen > remainingLen ? remainingLen : blockLen;
443 for(
auto channel : range)
486 for(
auto channel : range)
503 mChoice->GetValidator()->TransferFromWindow();
516 if (!
mUIParent->TransferDataFromWindow())
XXO("&Cut/Copy/Paste Toolbar")
static const EnumValueSymbol kNormalizeTargetStrings[EffectLoudness::nAlgos]
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
void reinit(Integral count, bool initialize=false)
Generates EffectParameterMethods overrides from variadic template arguments.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Implements EBU-R128 loudness measurement.
std::shared_ptr< TrackList > mOutputTracks
void SetLinearEffectFlag(bool linearEffectFlag)
void ReplaceProcessedTracks(const bool bGoodResult)
void CopyInputTracks(bool allSyncLockSelected=false)
bool TotalProgress(double frac, const TranslatableString &={}) const
int GetNumWaveTracks() const
Performs effect computation.
An Effect to bring the loudness level up to a chosen level.
bool Process(EffectInstance &instance, EffectSettings &settings) override
size_t mTrackBufferCapacity
wxCheckBox * mDualMonoCheckBox
static const ComponentInterfaceSymbol Symbol
wxCheckBox * mStereoIndCheckBox
wxWeakRef< wxWindow > mUIParent
std::unique_ptr< EBUR128 > mLoudnessProcessor
ComponentInterfaceSymbol GetSymbol() const override
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
bool GetTrackRMS(WaveTrack *track, float &rms)
bool ProcessBufferBlock()
void OnUpdateUI(wxCommandEvent &evt)
const EffectParameterMethods & Parameters() const override
bool AnalyseBufferBlock()
TranslatableString GetDescription() const override
bool TransferDataToWindow(const EffectSettings &settings) override
Update controls for the settings.
std::unique_ptr< EffectUIValidator > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
EffectType GetType() const override
Type determines how it behaves.
static constexpr EffectParameter StereoInd
static constexpr EffectParameter LUFSLevel
void StoreBufferBlock(TrackIterRange< WaveTrack > range, sampleCount pos, size_t len)
static constexpr EffectParameter RMSLevel
static constexpr EffectParameter DualMono
virtual ~EffectLoudness()
bool TransferDataFromWindow(EffectSettings &settings) override
Update the given settings from controls.
static constexpr EffectParameter NormalizeTo
void OnChoice(wxCommandEvent &evt)
TranslatableString mProgressMsg
bool ProcessOne(TrackIterRange< WaveTrack > range, bool analyse)
void LoadBufferBlock(TrackIterRange< WaveTrack > range, sampleCount pos, size_t len)
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
virtual void Reset(Effect &effect) const =0
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
static auto SingletonRange(TrackType *pTrack) -> TrackIterRange< TrackType >
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Holds a msgid for the translation catalog; may also bind format arguments.
A Validator is an object which checks whether a wxVariant satisfies a certain criterion....
A Track that contains audio waveform data.
size_t GetBestBlockSize(sampleCount t) const override
This returns a nonnegative number of samples meant to size a memory buffer.
float GetRMS(double t0, double t1, bool mayThrow=true) const
Positions or offsets within audio files need a wide type.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
BuiltinEffectsModule::Registration< EffectLoudness > reg
const Type min
Minimum value.
const Type max
Maximum value.
Externalized state of a plug-in.
Range between two TrackIters, usable in range-for statements, and with Visit member functions.