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 "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<EffectEditor> PopulateOrExchange(
52 ShuttleGui & S, EffectInstance &instance,
53 EffectSettingsAccess &access, const EffectOutputs *pOutputs) 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 wxWeakRef<wxWindow> mUIParent{};
81
82 double mRMSSum;
84 size_t mCirclePos;
86
90 double mRatio;
91 bool mNormalize; //MJS
93
94 double mDecayTime; // The "Release" time.
98 double mThreshold;
102 double mGain;
106
107 double mMax; //MJS
108
110
111 wxStaticText *mThresholdLabel;
113 wxStaticText *mThresholdText;
114
115 wxStaticText *mNoiseFloorLabel;
117 wxStaticText *mNoiseFloorText;
118
119 wxStaticText *mRatioLabel;
120 wxSlider *mRatioSlider;
121 wxStaticText *mRatioText;
122
123 wxStaticText *mAttackLabel;
124 wxSlider *mAttackSlider;
125 wxStaticText *mAttackText;
126
127 wxStaticText *mDecayLabel;
128 wxSlider *mDecaySlider;
129 wxStaticText *mDecayText;
130
131 wxCheckBox *mGainCheckBox;
132 wxCheckBox *mPeakCheckBox;
133
134 const EffectParameterMethods& Parameters() const override;
135 DECLARE_EVENT_TABLE()
136
138 L"Threshold", -12.0, -60.0, -1.0, 1 };
140 L"NoiseFloor", -40.0, -80.0, -20.0, 0.2 };
142 L"Ratio", 2.0, 1.1, 10.0, 10 };
144 L"AttackTime", 0.2, 0.1, 5.0, 100 };
146 L"ReleaseTime", 1.0, 1.0, 30.0, 10 };
148 L"Normalize", true, false, true, 1 };
150 L"UsePeak", false, false, true, 1 };
151};
152
154{
155public:
156 EffectCompressorPanel(wxWindow *parent, wxWindowID winid,
157 double & threshold,
158 double & noiseFloor,
159 double & ratio);
160
161private:
162 void OnPaint(wxPaintEvent & evt);
163 void OnSize(wxSizeEvent & evt);
164
165private:
166 double & threshold;
167 double & noiseFloor;
168 double & ratio;
169
170 DECLARE_EVENT_TABLE()
171};
172
173#endif
174
EffectType
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:69
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:121
const EffectParameterMethods & Parameters() const override
Definition: Compressor.cpp:60
bool TwoBufferProcessPass1(float *buffer1, size_t len1, float *buffer2, size_t len2) override
Definition: Compressor.cpp:379
wxStaticText * mRatioLabel
Definition: Compressor.h:119
wxCheckBox * mPeakCheckBox
Definition: Compressor.h:132
double mThresholdDB
Definition: Compressor.h:88
static constexpr EffectParameter Ratio
Definition: Compressor.h:141
bool InitPass1() override
Definition: Compressor.cpp:346
bool TransferDataFromWindow(EffectSettings &settings) override
Definition: Compressor.cpp:296
wxStaticText * mAttackLabel
Definition: Compressor.h:123
static EffectCompressor * FetchParameters(EffectCompressor &e, EffectSettings &)
Definition: Compressor.h:32
static constexpr EffectParameter Threshold
Definition: Compressor.h:137
wxSlider * mDecaySlider
Definition: Compressor.h:128
float AvgCircle(float x)
Definition: Compressor.cpp:441
EffectType GetType() const override
Type determines how it behaves.
Definition: Compressor.cpp:119
bool DoTransferDataFromWindow()
Definition: Compressor.cpp:305
static const ComponentInterfaceSymbol Symbol
Definition: Compressor.h:34
bool TransferDataToWindow(const EffectSettings &settings) override
Definition: Compressor.cpp:281
Doubles mCircle
Definition: Compressor.h:85
void Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len)
Definition: Compressor.cpp:456
size_t mCirclePos
Definition: Compressor.h:84
wxWeakRef< wxWindow > mUIParent
Definition: Compressor.h:80
double mAttackFactor
Definition: Compressor.h:95
wxStaticText * mDecayText
Definition: Compressor.h:129
double mNoiseFloor
Definition: Compressor.h:100
double mAttackTime
Definition: Compressor.h:87
wxSlider * mAttackSlider
Definition: Compressor.h:124
size_t mCircleSize
Definition: Compressor.h:83
static constexpr EffectParameter UsePeak
Definition: Compressor.h:149
wxSlider * mNoiseFloorSlider
Definition: Compressor.h:116
float DoCompression(float x, double env)
Definition: Compressor.cpp:569
wxSlider * mThresholdSlider
Definition: Compressor.h:112
ComponentInterfaceSymbol GetSymbol() const override
Definition: Compressor.cpp:102
wxStaticText * mDecayLabel
Definition: Compressor.h:127
double mDecayTime
Definition: Compressor.h:94
TranslatableString GetDescription() const override
Definition: Compressor.cpp:107
double mDecayFactor
Definition: Compressor.h:97
static constexpr EffectParameter NoiseFloor
Definition: Compressor.h:139
static constexpr EffectParameter ReleaseTime
Definition: Compressor.h:145
double mNoiseFloorDB
Definition: Compressor.h:89
static constexpr EffectParameter AttackTime
Definition: Compressor.h:143
std::unique_ptr< EffectEditor > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
Definition: Compressor.cpp:160
void OnSlider(wxCommandEvent &evt)
Definition: Compressor.cpp:587
EffectCompressorPanel * mPanel
Definition: Compressor.h:109
wxStaticText * mNoiseFloorText
Definition: Compressor.h:117
wxStaticText * mAttackText
Definition: Compressor.h:125
bool ProcessPass2(float *buffer, size_t len) override
Definition: Compressor.cpp:421
double mCompression
Definition: Compressor.h:99
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
Definition: Compressor.cpp:112
wxSlider * mRatioSlider
Definition: Compressor.h:120
virtual ~EffectCompressor()
Definition: Compressor.cpp:96
wxCheckBox * mGainCheckBox
Definition: Compressor.h:131
double mAttackInverseFactor
Definition: Compressor.h:96
double mThreshold
Definition: Compressor.h:98
wxStaticText * mThresholdText
Definition: Compressor.h:113
bool InitPass2() override
Definition: Compressor.cpp:368
wxStaticText * mNoiseFloorLabel
Definition: Compressor.h:115
wxStaticText * mThresholdLabel
Definition: Compressor.h:111
bool NewTrackPass1() override
Definition: Compressor.cpp:321
static constexpr EffectParameter Normalize
Definition: Compressor.h:147
EffectCompressorPanel(wxWindow *parent, wxWindowID winid, double &threshold, double &noiseFloor, double &ratio)
Definition: Compressor.cpp:631
void OnSize(wxSizeEvent &evt)
Definition: Compressor.cpp:734
void OnPaint(wxPaintEvent &evt)
Definition: Compressor.cpp:642
Performs effect computation.
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
An Effect base class that implements a two pass process.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:630
Holds a msgid for the translation catalog; may also bind format arguments.
Externalized state of a plug-in.