Audacity 3.2.0
LoudnessBase.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 LoudnessBase.h
6
7 Max Maisel (based on Normalize effect)
8
9**********************************************************************/
10#pragma once
11
12#include "MemoryX.h"
13#include "SettingsVisitor.h"
14#include "StatefulEffect.h"
15
16class WaveChannel;
17class EBUR128;
19
20class BUILTIN_EFFECTS_API LoudnessBase : public StatefulEffect
21{
22public:
24 {
27 nAlgos
28 };
29
31 {
32 return &e;
33 }
35
37 virtual ~LoudnessBase();
38
39 // ComponentInterface implementation
40
41 ComponentInterfaceSymbol GetSymbol() const override;
42 TranslatableString GetDescription() const override;
43 ManualPageID ManualPage() const override;
44
45 // EffectDefinitionInterface implementation
46
47 EffectType GetType() const override;
48
49 // Effect implementation
50
51 bool Process(EffectInstance& instance, EffectSettings& settings) override;
52 bool UpdateProgress();
53
54private:
55 // LoudnessBase implementation
56
57 void AllocBuffers(TrackList& outputs);
58 void FreeBuffers();
59 static bool
60 GetTrackRMS(WaveChannel& track, double curT0, double curT1, float& rms);
61 [[nodiscard]] bool ProcessOne(
62 WaveChannel& track, size_t nChannels, double curT0, double curT1,
63 float mult, EBUR128* pLoudnessProcessor);
64 void LoadBufferBlock(
65 WaveChannel& track, size_t nChannels, sampleCount pos, size_t len);
66 bool AnalyseBufferBlock(EBUR128& loudnessProcessor);
67 bool ProcessBufferBlock(float mult);
68 [[nodiscard]] bool StoreBufferBlock(
69 WaveChannel& track, size_t nChannels, sampleCount pos, size_t len);
70
71protected:
73 double mLUFSLevel;
74 double mRMSLevel;
77
79 int mSteps;
81 double mTrackLen;
82 double mCurRate;
83
84 Floats mTrackBuffer[2]; // MM: must be increased once surround channels are
85 // supported
89
90 const EffectParameterMethods& Parameters() const override;
91
92 static constexpr EffectParameter StereoInd {
93 &LoudnessBase::mStereoInd, L"StereoIndependent", false, false, true, 1
94 };
95 static constexpr EffectParameter LUFSLevel {
96 &LoudnessBase::mLUFSLevel, L"LUFSLevel", -23.0, -145.0, 0.0, 1
97 };
98 static constexpr EffectParameter RMSLevel {
99 &LoudnessBase::mRMSLevel, L"RMSLevel", -20.0, -145.0, 0.0, 1
100 };
101 static constexpr EffectParameter DualMono {
102 &LoudnessBase::mDualMono, L"DualMono", true, false, true, 1
103 };
104 static constexpr EffectParameter NormalizeTo { &LoudnessBase::mNormalizeTo,
105 L"NormalizeTo",
106 (int)kLoudness,
107 0,
108 nAlgos - 1,
109 1 };
110};
EffectType
static Settings & settings()
Definition: TrackInfo.cpp:51
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Implements EBU-R128 loudness measurement.
Definition: EBUR128.h:22
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual ManualPageID ManualPage() const
Name of a page in the Audacity alpha manual, default is empty.
virtual const EffectParameterMethods & Parameters() const
Definition: Effect.cpp:96
TranslatableString GetDescription() const override
Definition: Effect.cpp:64
ComponentInterfaceSymbol GetSymbol() const override
Definition: Effect.cpp:49
Performs effect computation.
Interface for manipulations of an Effect's settings.
An Effect to bring the loudness level up to a chosen level.
Definition: LoudnessBase.h:21
bool mProcStereo
Definition: LoudnessBase.h:88
double mProgressVal
Definition: LoudnessBase.h:78
double mLUFSLevel
Definition: LoudnessBase.h:73
static LoudnessBase * FetchParameters(LoudnessBase &e, EffectSettings &)
Definition: LoudnessBase.h:30
static const ComponentInterfaceSymbol Symbol
Definition: LoudnessBase.h:34
double mCurRate
Definition: LoudnessBase.h:82
TranslatableString mProgressMsg
Definition: LoudnessBase.h:80
double mTrackLen
Definition: LoudnessBase.h:81
size_t mTrackBufferCapacity
Definition: LoudnessBase.h:87
size_t mTrackBufferLen
Definition: LoudnessBase.h:86
double mRMSLevel
Definition: LoudnessBase.h:74
virtual bool Process(EffectInstance &instance, EffectSettings &settings)=0
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
Holds a msgid for the translation catalog; may also bind format arguments.
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Externalized state of a plug-in.