Audacity 3.2.0
Compressor.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Compressor.h
6
7 Dominic Mazzoni
8
9**********************************************************************/
10
11#ifndef __AUDACITY_EFFECT_COMPRESSOR__
12#define __AUDACITY_EFFECT_COMPRESSOR__
13
14#include "TwoPassSimpleMono.h"
15#include "../ShuttleAutomation.h"
16#include "MemoryX.h"
17#include "../widgets/wxPanelWrapper.h"
18
19class wxCheckBox;
20class wxSlider;
21class wxStaticText;
23class ShuttleGui;
24
27
29{
30public:
31 static inline EffectCompressor *
33
35
37 virtual ~EffectCompressor();
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 std::unique_ptr<EffectUIValidator> PopulateOrExchange(
52 ShuttleGui & S, EffectInstance &instance, EffectSettingsAccess &access)
53 override;
55 bool TransferDataToWindow(const EffectSettings &settings) override;
57
58protected:
59 // EffectTwoPassSimpleMono implementation
60
61 bool InitPass1() override;
62 bool InitPass2() override;
63 bool NewTrackPass1() override;
64 bool ProcessPass2(float *buffer, size_t len) override;
66 (float *buffer1, size_t len1, float *buffer2, size_t len2) override;
67
68private:
69 // EffectCompressor implementation
70
71 void FreshenCircle();
72 float AvgCircle(float x);
73 void Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len);
74 float DoCompression(float x, double env);
75
76 void OnSlider(wxCommandEvent & evt);
77 void UpdateUI();
78
79private:
80 double mRMSSum;
82 size_t mCirclePos;
84
88 double mRatio;
89 bool mNormalize; //MJS
91
92 double mDecayTime; // The "Release" time.
96 double mThreshold;
100 double mGain;
104
105 double mMax; //MJS
106
108
109 wxStaticText *mThresholdLabel;
111 wxStaticText *mThresholdText;
112
113 wxStaticText *mNoiseFloorLabel;
115 wxStaticText *mNoiseFloorText;
116
117 wxStaticText *mRatioLabel;
118 wxSlider *mRatioSlider;
119 wxStaticText *mRatioText;
120
121 wxStaticText *mAttackLabel;
122 wxSlider *mAttackSlider;
123 wxStaticText *mAttackText;
124
125 wxStaticText *mDecayLabel;
126 wxSlider *mDecaySlider;
127 wxStaticText *mDecayText;
128
129 wxCheckBox *mGainCheckBox;
130 wxCheckBox *mPeakCheckBox;
131
132 const EffectParameterMethods& Parameters() const override;
133 DECLARE_EVENT_TABLE()
134
136 L"Threshold", -12.0, -60.0, -1.0, 1 };
138 L"NoiseFloor", -40.0, -80.0, -20.0, 0.2 };
140 L"Ratio", 2.0, 1.1, 10.0, 10 };
142 L"AttackTime", 0.2, 0.1, 5.0, 100 };
144 L"ReleaseTime", 1.0, 1.0, 30.0, 10 };
146 L"Normalize", true, false, true, 1 };
148 L"UsePeak", false, false, true, 1 };
149};
150
152{
153public:
154 EffectCompressorPanel(wxWindow *parent, wxWindowID winid,
155 double & threshold,
156 double & noiseFloor,
157 double & ratio);
158
159private:
160 void OnPaint(wxPaintEvent & evt);
161 void OnSize(wxSizeEvent & evt);
162
163private:
164 double & threshold;
165 double & noiseFloor;
166 double & ratio;
167
168 DECLARE_EVENT_TABLE()
169};
170
171#endif
172
EffectType
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:87
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
An Effect derived from EffectTwoPassSimpleMono.
Definition: Compressor.h:29
wxStaticText * mRatioText
Definition: Compressor.h:119
const EffectParameterMethods & Parameters() const override
Definition: Compressor.cpp:59
bool TwoBufferProcessPass1(float *buffer1, size_t len1, float *buffer2, size_t len2) override
Definition: Compressor.cpp:372
wxStaticText * mRatioLabel
Definition: Compressor.h:117
wxCheckBox * mPeakCheckBox
Definition: Compressor.h:130
double mThresholdDB
Definition: Compressor.h:86
static constexpr EffectParameter Ratio
Definition: Compressor.h:139
bool InitPass1() override
Definition: Compressor.cpp:339
bool TransferDataFromWindow(EffectSettings &settings) override
Update the given settings from controls.
Definition: Compressor.cpp:293
wxStaticText * mAttackLabel
Definition: Compressor.h:121
static EffectCompressor * FetchParameters(EffectCompressor &e, EffectSettings &)
Definition: Compressor.h:32
static constexpr EffectParameter Threshold
Definition: Compressor.h:135
wxSlider * mDecaySlider
Definition: Compressor.h:126
float AvgCircle(float x)
Definition: Compressor.cpp:434
EffectType GetType() const override
Type determines how it behaves.
Definition: Compressor.cpp:118
bool DoTransferDataFromWindow()
Definition: Compressor.cpp:298
static const ComponentInterfaceSymbol Symbol
Definition: Compressor.h:34
bool TransferDataToWindow(const EffectSettings &settings) override
Update controls for the settings.
Definition: Compressor.cpp:278
Doubles mCircle
Definition: Compressor.h:83
void Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len)
Definition: Compressor.cpp:449
size_t mCirclePos
Definition: Compressor.h:82
double mAttackFactor
Definition: Compressor.h:93
wxStaticText * mDecayText
Definition: Compressor.h:127
double mNoiseFloor
Definition: Compressor.h:98
double mAttackTime
Definition: Compressor.h:85
wxSlider * mAttackSlider
Definition: Compressor.h:122
size_t mCircleSize
Definition: Compressor.h:81
static constexpr EffectParameter UsePeak
Definition: Compressor.h:147
wxSlider * mNoiseFloorSlider
Definition: Compressor.h:114
float DoCompression(float x, double env)
Definition: Compressor.cpp:562
wxSlider * mThresholdSlider
Definition: Compressor.h:110
ComponentInterfaceSymbol GetSymbol() const override
Definition: Compressor.cpp:101
wxStaticText * mDecayLabel
Definition: Compressor.h:125
double mDecayTime
Definition: Compressor.h:92
TranslatableString GetDescription() const override
Definition: Compressor.cpp:106
std::unique_ptr< EffectUIValidator > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
Add controls to effect panel; always succeeds.
Definition: Compressor.cpp:159
double mDecayFactor
Definition: Compressor.h:95
static constexpr EffectParameter NoiseFloor
Definition: Compressor.h:137
static constexpr EffectParameter ReleaseTime
Definition: Compressor.h:143
double mNoiseFloorDB
Definition: Compressor.h:87
static constexpr EffectParameter AttackTime
Definition: Compressor.h:141
void OnSlider(wxCommandEvent &evt)
Definition: Compressor.cpp:580
EffectCompressorPanel * mPanel
Definition: Compressor.h:107
wxStaticText * mNoiseFloorText
Definition: Compressor.h:115
wxStaticText * mAttackText
Definition: Compressor.h:123
bool ProcessPass2(float *buffer, size_t len) override
Definition: Compressor.cpp:414
double mCompression
Definition: Compressor.h:97
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
Definition: Compressor.cpp:111
wxSlider * mRatioSlider
Definition: Compressor.h:118
virtual ~EffectCompressor()
Definition: Compressor.cpp:95
wxCheckBox * mGainCheckBox
Definition: Compressor.h:129
double mAttackInverseFactor
Definition: Compressor.h:94
double mThreshold
Definition: Compressor.h:96
wxStaticText * mThresholdText
Definition: Compressor.h:111
bool InitPass2() override
Definition: Compressor.cpp:361
wxStaticText * mNoiseFloorLabel
Definition: Compressor.h:113
wxStaticText * mThresholdLabel
Definition: Compressor.h:109
bool NewTrackPass1() override
Definition: Compressor.cpp:314
static constexpr EffectParameter Normalize
Definition: Compressor.h:145
EffectCompressorPanel(wxWindow *parent, wxWindowID winid, double &threshold, double &noiseFloor, double &ratio)
Definition: Compressor.cpp:624
void OnSize(wxSizeEvent &evt)
Definition: Compressor.cpp:729
void OnPaint(wxPaintEvent &evt)
Definition: Compressor.cpp:635
Performs effect computation.
Interface for manipulations of an Effect's settings.
An Effect base class that implements a two pass process by using EffectSimpleMono.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
Holds a msgid for the translation catalog; may also bind format arguments.
Externalized state of a plug-in.