Audacity 3.2.0
NormalizeBase.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 NormalizeBase.h
6
7 Dominic Mazzoni
8 Vaughan Johnson (Preview)
9
10**********************************************************************/
11#pragma once
12
13#include "SettingsVisitor.h"
14#include "StatefulEffect.h"
15
16class WaveChannel;
17
18class BUILTIN_EFFECTS_API NormalizeBase : public StatefulEffect
19{
20public:
21 static inline NormalizeBase*
23 {
24 return &e;
25 }
27
29 virtual ~NormalizeBase();
30
31 // ComponentInterface implementation
32
33 ComponentInterfaceSymbol GetSymbol() const override;
34 TranslatableString GetDescription() const override;
35 ManualPageID ManualPage() const override;
36
37 // EffectDefinitionInterface implementation
38
39 EffectType GetType() const override;
40
41 // Effect implementation
42
43 bool CheckWhetherSkipEffect(const EffectSettings& settings) const override;
44 bool Process(EffectInstance& instance, EffectSettings& settings) override;
45
46private:
47 // NormalizeBase implementation
48
49 bool ProcessOne(
50 WaveChannel& track, const TranslatableString& msg, double& progress,
51 float offset);
52 using ProgressReport = std::function<bool(double fraction)>;
53 static bool AnalyseTrack(
54 const WaveChannel& track, const ProgressReport& report, bool gain,
55 bool dc, double curT0, double curT1, float& offset, float& extent);
56 static bool AnalyseTrackData(
57 const WaveChannel& track, const ProgressReport& report, double curT0,
58 double curT1, float& offset);
59 static double AnalyseDataDC(float* buffer, size_t len, double sum);
60 void ProcessData(float* buffer, size_t len, float offset);
61
62protected:
63 double mPeakLevel;
64 bool mGain;
65 bool mDC;
67
68 double mCurT0;
69 double mCurT1;
70 float mMult;
71
72 const EffectParameterMethods& Parameters() const override;
73
74 static constexpr EffectParameter PeakLevel {
75 &NormalizeBase::mPeakLevel, L"PeakLevel", -1.0, -145.0, 0.0, 1
76 };
77 static constexpr EffectParameter RemoveDC {
78 &NormalizeBase::mDC, L"RemoveDcOffset", true, false, true, 1
79 };
80 static constexpr EffectParameter ApplyVolume {
81 &NormalizeBase::mGain, L"ApplyVolume", true, false, true, 1
82 };
83 static constexpr EffectParameter StereoInd {
84 &NormalizeBase::mStereoInd, L"StereoIndependent", false, false, true, 1
85 };
86};
EffectType
static Settings & settings()
Definition: TrackInfo.cpp:51
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
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
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
Default implementation returns false.
Definition: Effect.cpp:379
ComponentInterfaceSymbol GetSymbol() const override
Definition: Effect.cpp:49
Performs effect computation.
Interface for manipulations of an Effect's settings.
An Effect to bring the peak level up to a chosen level.
Definition: NormalizeBase.h:19
static NormalizeBase * FetchParameters(NormalizeBase &e, EffectSettings &)
Definition: NormalizeBase.h:22
std::function< bool(double fraction)> ProgressReport
Definition: NormalizeBase.h:52
double mPeakLevel
Definition: NormalizeBase.h:63
static const ComponentInterfaceSymbol Symbol
Definition: NormalizeBase.h:26
virtual bool Process(EffectInstance &instance, EffectSettings &settings)=0
Holds a msgid for the translation catalog; may also bind format arguments.
Externalized state of a plug-in.