Audacity 3.2.0
EqualizationBase.h
Go to the documentation of this file.
1#pragma once
2
5#include "SampleFormat.h"
6#include "StatefulEffect.h"
7#include "WaveTrack.h"
8
10
11class BUILTIN_EFFECTS_API EqualizationBase : public StatefulEffect
12{
13public:
14 static inline EqualizationParameters*
16 {
17 return &e.mParameters;
18 }
20
21 EqualizationBase(int Options = kEqLegacy);
22
23 virtual ~EqualizationBase();
24
25 // ComponentInterface implementation
26
27 TranslatableString GetDescription() const override;
28 ManualPageID ManualPage() const override;
29 bool
31 bool VisitSettings(
32 ConstSettingsVisitor& visitor,
33 const EffectSettings& settings) const override;
34
35 // EffectDefinitionInterface implementation
36
37 EffectType GetType() const override;
39 OptionalMessage DoLoadFactoryDefaults(EffectSettings& settings);
40
41 RegistryPaths GetFactoryPresets() const override;
43 LoadFactoryPreset(int id, EffectSettings& settings) const override;
44
45 // Effect implementation
46
47 bool Init() override;
48 bool Process(EffectInstance& instance, EffectSettings& settings) override;
49
50protected:
51 // EqualizationBase implementation
52
53 struct Task
54 {
55 Task(size_t M, size_t idealBlockLen, WaveChannel& channel)
56 : buffer { idealBlockLen }
57 , idealBlockLen { idealBlockLen }
58 , output { channel }
59 , leftTailRemaining { (M - 1) / 2 }
60 {
61 memset(lastWindow, 0, windowSize * sizeof(float));
62 }
63
64 void AccumulateSamples(constSamplePtr buffer, size_t len)
65 {
66 auto leftTail = std::min(len, leftTailRemaining);
67 leftTailRemaining -= leftTail;
68 len -= leftTail;
69 buffer += leftTail * sizeof(float);
70 output.Append(buffer, floatSample, len);
71 }
72
73 static constexpr auto windowSize = EqualizationFilter::windowSize;
74 Floats window1 { windowSize };
75 Floats window2 { windowSize };
76
78 const size_t idealBlockLen;
79
80 // These pointers are swapped after each FFT window
81 float* thisWindow { window1.get() };
82 float* lastWindow { window2.get() };
83
84 // a new WaveChannel to hold all of the output,
85 // including 'tails' each end
87
89 };
90
91 bool ProcessOne(
92 Task& task, int count, const WaveChannel& t, sampleCount start,
93 sampleCount len);
94
96 EqualizationCurvesList mCurvesList { mParameters };
97 const int mOptions;
98
99 const EffectParameterMethods& Parameters() const override;
100};
int min(int a, int b)
EffectType
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
const int kEqLegacy
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
const char * constSamplePtr
Definition: SampleFormat.h:58
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.
OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const override
Definition: Effect.cpp:165
bool VisitSettings(SettingsVisitor &visitor, EffectSettings &settings) override
Definition: Effect.cpp:102
virtual const EffectParameterMethods & Parameters() const
Definition: Effect.cpp:96
TranslatableString GetDescription() const override
Definition: Effect.cpp:64
OptionalMessage LoadFactoryPreset(int id, EffectSettings &settings) const override
Definition: Effect.cpp:160
RegistryPaths GetFactoryPresets() const override
Report names of factory presets.
Definition: Effect.cpp:155
Performs effect computation.
Interface for manipulations of an Effect's settings.
EqualizationFilter mParameters
static EqualizationParameters * FetchParameters(EqualizationBase &e, EffectSettings &)
static const ComponentInterfaceSymbol Symbol
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
virtual bool Process(EffectInstance &instance, EffectSettings &settings)=0
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.
Task(size_t M, size_t idealBlockLen, WaveChannel &channel)
void AccumulateSamples(constSamplePtr buffer, size_t len)
Maintains a list of preset curves for Equalization effects.
static constexpr size_t windowSize
Parameters of the Equalization effects that persist in configuration files.