Audacity 3.2.0
AmplifyBase.h
Go to the documentation of this file.
1#pragma once
2
3#include "SettingsVisitor.h"
5
6class BUILTIN_EFFECTS_API AmplifyBase : public StatefulPerTrackEffect
7{
8public:
10 {
11 return &e;
12 }
14
16 virtual ~AmplifyBase() override;
17
18 // EffectDefinitionInterface implementation
19
20 ComponentInterfaceSymbol GetSymbol() const override;
21 EffectType GetType() const override;
23 OptionalMessage DoLoadFactoryDefaults(EffectSettings& settings);
24
25 unsigned GetAudioInCount() const override;
26 unsigned GetAudioOutCount() const override;
27 size_t ProcessBlock(
28 EffectSettings& settings, const float* const* inBlock,
29 float* const* outBlock, size_t blockLen) override;
30
31 // Effect implementation
32
33 bool Init() override;
34 std::any BeginPreview(const EffectSettings& settings) override;
35
36protected:
37 // TODO review this
38 struct BUILTIN_EFFECTS_API Instance : StatefulPerTrackEffect::Instance
39 {
41 ~Instance() override;
42 };
43
44protected:
45 void ClampRatio();
46
47 // AmplifyBase implementation
48protected:
49 double mPeak = 1.0;
50
51 double mRatio = 1.0;
52 double mRatioClip =
53 1.0; // maximum value of mRatio which does not cause clipping
54 double mAmp = 0.0;
55 double mNewPeak = 1.0;
56 bool mCanClip = true;
57
58private:
59 const EffectParameterMethods& Parameters() const override;
60
61protected:
62 static constexpr EffectParameter Ratio {
63 &AmplifyBase::mRatio, L"Ratio", 0.9f, 0.003162f, 316.227766f, 1.0f
64 };
65 // Amp is not saved in settings!
66 static constexpr EffectParameter Amp {
67 &AmplifyBase::mAmp, L"", -0.91515f, -50.0f, 50.0f, 10.0f
68 };
69 static constexpr EffectParameter Clipping {
70 &AmplifyBase::mCanClip, L"AllowClipping", false, false, true, 1
71 };
72};
EffectType
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
static Settings & settings()
Definition: TrackInfo.cpp:51
static const ComponentInterfaceSymbol Symbol
Definition: AmplifyBase.h:13
double mRatio
Definition: AmplifyBase.h:51
double mAmp
Definition: AmplifyBase.h:54
static AmplifyBase * FetchParameters(AmplifyBase &e, EffectSettings &)
Definition: AmplifyBase.h:9
bool mCanClip
Definition: AmplifyBase.h:56
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
virtual std::any BeginPreview(const EffectSettings &settings)
Called when Preview() starts, to allow temporary effect state changes.
Definition: EffectBase.cpp:234
virtual EffectType GetType() const =0
Type determines how it behaves.
OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const override
Definition: Effect.cpp:165
virtual const EffectParameterMethods & Parameters() const
Definition: Effect.cpp:96
ComponentInterfaceSymbol GetSymbol() const override
Definition: Effect.cpp:49
Interface for manipulations of an Effect's settings.
virtual unsigned GetAudioOutCount() const
How many output buffers to allocate at once.
virtual unsigned GetAudioInCount() const
How many input buffers to allocate at once.
Instance(StatefulPerTrackEffect &effect)
Base class for many of the effects in Audacity.
virtual size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen)=0
Called for destructive effect computation.
Externalized state of a plug-in.