Audacity 3.2.0
Loudness.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Loudness.h
6
7 Max Maisel (based on Normalize effect)
8
9**********************************************************************/
10
11#ifndef __AUDACITY_EFFECT_LOUDNESS__
12#define __AUDACITY_EFFECT_LOUDNESS__
13
14#include <wx/checkbox.h>
15#include <wx/choice.h>
16#include <wx/event.h>
17#include <wx/stattext.h>
18#include <wx/string.h>
19#include <wx/textctrl.h>
20
21#include "Effect.h"
22#include "Biquad.h"
23#include "EBUR128.h"
24#include "../ShuttleAutomation.h"
25#include "Track.h"
26
27class wxChoice;
28class wxSimplebook;
29class ShuttleGui;
30
31class EffectLoudness final : public StatefulEffect
32{
33public:
35 {
38 nAlgos
39 };
40
41 static inline EffectLoudness *
44
46 virtual ~EffectLoudness();
47
48 // ComponentInterface implementation
49
50 ComponentInterfaceSymbol GetSymbol() const override;
51 TranslatableString GetDescription() const override;
52 ManualPageID ManualPage() const override;
53
54 // EffectDefinitionInterface implementation
55
56 EffectType GetType() const override;
57
58 // Effect implementation
59
60 bool Process(EffectInstance &instance, EffectSettings &settings) override;
61 std::unique_ptr<EffectUIValidator> PopulateOrExchange(
62 ShuttleGui & S, EffectInstance &instance, EffectSettingsAccess &access)
63 override;
64 bool TransferDataToWindow(const EffectSettings &settings) override;
65
66private:
67 // EffectLoudness implementation
68
69 void AllocBuffers();
70 void FreeBuffers();
71 bool GetTrackRMS(WaveTrack* track, float& rms);
72 bool ProcessOne(TrackIterRange<WaveTrack> range, bool analyse);
74 sampleCount pos, size_t len);
75 bool AnalyseBufferBlock();
76 bool ProcessBufferBlock();
78 sampleCount pos, size_t len);
79
80 bool UpdateProgress();
81 void OnChoice(wxCommandEvent & evt);
82 void OnUpdateUI(wxCommandEvent & evt);
83 void UpdateUI();
84
85private:
87 double mLUFSLevel;
88 double mRMSLevel;
91
92 double mCurT0;
93 double mCurT1;
95 int mSteps;
97 double mTrackLen;
98 double mCurRate;
99
100 float mMult;
101 float mRatio;
102 float mRMS[2];
103 std::unique_ptr<EBUR128> mLoudnessProcessor;
104
105 wxSimplebook *mBook;
106 wxChoice *mChoice;
107 wxStaticText *mWarning;
109 wxCheckBox *mDualMonoCheckBox;
110
111 Floats mTrackBuffer[2]; // MM: must be increased once surround channels are supported
115
116 const EffectParameterMethods& Parameters() const override;
117 DECLARE_EVENT_TABLE()
118
120 L"StereoIndependent", false, false, true, 1 };
122 L"LUFSLevel", -23.0, -145.0, 0.0, 1 };
124 L"RMSLevel", -20.0, -145.0, 0.0, 1 };
126 L"DualMono", true, false, true, 1 };
128 L"NormalizeTo", (int)kLoudness , 0 , nAlgos-1, 1 };
129};
130
131#endif
EffectType
#define S(N)
Definition: ToChars.cpp:64
declares abstract base class Track, TrackList, and iterators over TrackList
static Settings & settings()
Definition: TrackInfo.cpp:87
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Performs effect computation.
An Effect to bring the loudness level up to a chosen level.
Definition: Loudness.h:32
double mCurRate
Definition: Loudness.h:98
bool UpdateProgress()
Definition: Loudness.cpp:479
bool Process(EffectInstance &instance, EffectSettings &settings) override
Actually do the effect here.
Definition: Loudness.cpp:97
size_t mTrackBufferCapacity
Definition: Loudness.h:113
wxCheckBox * mDualMonoCheckBox
Definition: Loudness.h:109
wxSimplebook * mBook
Definition: Loudness.h:105
bool mStereoInd
Definition: Loudness.h:86
double mTrackLen
Definition: Loudness.h:97
float mRMS[2]
Definition: Loudness.h:102
static const ComponentInterfaceSymbol Symbol
Definition: Loudness.h:43
wxCheckBox * mStereoIndCheckBox
Definition: Loudness.h:108
std::unique_ptr< EBUR128 > mLoudnessProcessor
Definition: Loudness.h:103
static EffectLoudness * FetchParameters(EffectLoudness &e, EffectSettings &)
Definition: Loudness.h:42
wxChoice * mChoice
Definition: Loudness.h:106
void UpdateUI()
Definition: Loudness.cpp:499
ComponentInterfaceSymbol GetSymbol() const override
Definition: Loudness.cpp:73
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
Definition: Loudness.cpp:83
int mNormalizeTo
Definition: Loudness.h:90
bool GetTrackRMS(WaveTrack *track, float &rms)
Definition: Loudness.cpp:356
bool ProcessBufferBlock()
Definition: Loudness.cpp:453
double mCurT1
Definition: Loudness.h:93
void OnUpdateUI(wxCommandEvent &evt)
Definition: Loudness.cpp:494
const EffectParameterMethods & Parameters() const override
Definition: Loudness.cpp:42
bool AnalyseBufferBlock()
Definition: Loudness.cpp:438
TranslatableString GetDescription() const override
Definition: Loudness.cpp:78
bool TransferDataToWindow(const EffectSettings &settings) override
Update controls for the settings.
Definition: Loudness.cpp:313
float mRatio
Definition: Loudness.h:101
EffectType GetType() const override
Type determines how it behaves.
Definition: Loudness.cpp:90
static constexpr EffectParameter StereoInd
Definition: Loudness.h:119
static constexpr EffectParameter LUFSLevel
Definition: Loudness.h:121
void StoreBufferBlock(TrackIterRange< WaveTrack > range, sampleCount pos, size_t len)
Definition: Loudness.cpp:467
bool mProcStereo
Definition: Loudness.h:114
static constexpr EffectParameter RMSLevel
Definition: Loudness.h:123
static constexpr EffectParameter DualMono
Definition: Loudness.h:125
virtual ~EffectLoudness()
Definition: Loudness.cpp:67
void FreeBuffers()
Definition: Loudness.cpp:350
void AllocBuffers()
Definition: Loudness.cpp:325
double mProgressVal
Definition: Loudness.h:94
size_t mTrackBufferLen
Definition: Loudness.h:112
wxStaticText * mWarning
Definition: Loudness.h:107
double mRMSLevel
Definition: Loudness.h:88
bool mDualMono
Definition: Loudness.h:89
static constexpr EffectParameter NormalizeTo
Definition: Loudness.h:127
std::unique_ptr< EffectUIValidator > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
Add controls to effect panel; always succeeds.
Definition: Loudness.cpp:215
void OnChoice(wxCommandEvent &evt)
Definition: Loudness.cpp:486
TranslatableString mProgressMsg
Definition: Loudness.h:96
double mCurT0
Definition: Loudness.h:92
bool ProcessOne(TrackIterRange< WaveTrack > range, bool analyse)
Definition: Loudness.cpp:370
void LoadBufferBlock(TrackIterRange< WaveTrack > range, sampleCount pos, size_t len)
Definition: Loudness.cpp:423
Floats mTrackBuffer[2]
Definition: Loudness.h:111
double mLUFSLevel
Definition: Loudness.h:87
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:631
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
Externalized state of a plug-in.
Range between two TrackIters, usable in range-for statements, and with Visit member functions.
Definition: Track.h:1161