Audacity  2.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 <wx/bitmap.h>
15 #include <wx/checkbox.h>
16 #include <wx/event.h>
17 #include <wx/gdicmn.h>
18 #include <wx/slider.h>
19 #include <wx/string.h>
20 #include <wx/stattext.h>
21 #include <wx/window.h>
22 #include "../widgets/wxPanelWrapper.h"
23 
24 #include "TwoPassSimpleMono.h"
25 #include "../SampleFormat.h"
26 
28 class ShuttleGui;
29 
30 #define COMPRESSOR_PLUGIN_SYMBOL XO("Compressor")
31 
33 {
34 public:
35 
37  virtual ~EffectCompressor();
38 
39  // IdentInterface implementation
40 
41  wxString GetSymbol() override;
42  wxString GetDescription() override;
43  wxString ManualPage() override;
44 
45  // EffectIdentInterface implementation
46 
47  EffectType GetType() override;
48 
49  // EffectClientInterface implementation
50 
51  bool GetAutomationParameters(EffectAutomationParameters & parms) override;
52  bool SetAutomationParameters(EffectAutomationParameters & parms) override;
53 
54  // Effect implementation
55 
56  bool Startup() override;
57  void PopulateOrExchange(ShuttleGui & S) override;
58  bool TransferDataToWindow() override;
59  bool TransferDataFromWindow() override;
60 
61 protected:
62  // EffectTwoPassSimpleMono implementation
63 
64  bool InitPass1() override;
65  bool InitPass2() override;
66  bool NewTrackPass1() override;
67  bool ProcessPass2(float *buffer, size_t len) override;
69  (float *buffer1, size_t len1, float *buffer2, size_t len2) override;
70 
71 private:
72  // EffectCompressor implementation
73 
74  void FreshenCircle();
75  float AvgCircle(float x);
76  void Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len);
77  float DoCompression(float x, double env);
78 
79  void OnSlider(wxCommandEvent & evt);
80  void UpdateUI();
81 
82 private:
83  double mRMSSum;
84  size_t mCircleSize;
85  size_t mCirclePos;
87 
88  double mAttackTime;
89  double mThresholdDB;
90  double mNoiseFloorDB;
91  double mRatio;
92  bool mNormalize; //MJS
93  bool mUsePeak;
94 
95  double mDecayTime; // The "Release" time.
96  double mAttackFactor;
98  double mDecayFactor;
99  double mThreshold;
100  double mCompression;
101  double mNoiseFloor;
103  double mGain;
104  double mLastLevel;
106  size_t mFollowLen;
107 
108  double mMax; //MJS
109 
111 
112  wxStaticText *mThresholdLabel;
113  wxSlider *mThresholdSlider;
114  wxStaticText *mThresholdText;
115 
116  wxStaticText *mNoiseFloorLabel;
117  wxSlider *mNoiseFloorSlider;
118  wxStaticText *mNoiseFloorText;
119 
120  wxStaticText *mRatioLabel;
121  wxSlider *mRatioSlider;
122  wxStaticText *mRatioText;
123 
124  wxStaticText *mAttackLabel;
125  wxSlider *mAttackSlider;
126  wxStaticText *mAttackText;
127 
128  wxStaticText *mDecayLabel;
129  wxSlider *mDecaySlider;
130  wxStaticText *mDecayText;
131 
132  wxCheckBox *mGainCheckBox;
133  wxCheckBox *mPeakCheckBox;
134 
135  DECLARE_EVENT_TABLE()
136 };
137 
139 {
140 public:
141  EffectCompressorPanel(wxWindow *parent,
142  double & threshold,
143  double & noiseFloor,
144  double & ratio);
145 
146 private:
147  void OnPaint(wxPaintEvent & evt);
148  void OnSize(wxSizeEvent & evt);
149 
150 private:
151  double & threshold;
152  double & noiseFloor;
153  double & ratio;
154 
155  DECLARE_EVENT_TABLE()
156 };
157 
158 #endif
159 
wxSlider * mRatioSlider
Definition: Compressor.h:121
double mLastLevel
Definition: Compressor.h:104
double & threshold
Definition: Compressor.h:151
wxSlider * mThresholdSlider
Definition: Compressor.h:113
double mAttackInverseFactor
Definition: Compressor.h:97
double mAttackTime
Definition: Compressor.h:88
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
bool Startup() override
Definition: Compressor.cpp:160
double & noiseFloor
Definition: Compressor.h:152
bool InitPass1() override
Definition: Compressor.cpp:349
wxString GetSymbol() override
Definition: Compressor.cpp:100
wxStaticText * mThresholdText
Definition: Compressor.h:114
double mThreshold
Definition: Compressor.h:99
wxStaticText * mThresholdLabel
Definition: Compressor.h:112
Floats mFollow1
Definition: Compressor.h:105
wxStaticText * mRatioLabel
Definition: Compressor.h:120
double mDecayTime
Definition: Compressor.h:95
An Effect derived from EffectTwoPassSimpleMono.
Definition: Compressor.h:32
int mNoiseCounter
Definition: Compressor.h:102
double mNoiseFloorDB
Definition: Compressor.h:90
void OnPaint(wxPaintEvent &evt)
Definition: Compressor.cpp:659
double mThresholdDB
Definition: Compressor.h:89
wxSlider * mNoiseFloorSlider
Definition: Compressor.h:117
double mCompression
Definition: Compressor.h:100
Definition: wxPanelWrapper.h:19
double mNoiseFloor
Definition: Compressor.h:101
wxString GetDescription() override
Definition: Compressor.cpp:105
wxStaticText * mAttackLabel
Definition: Compressor.h:124
wxStaticText * mDecayLabel
Definition: Compressor.h:128
bool SetAutomationParameters(EffectAutomationParameters &parms) override
Definition: Compressor.cpp:137
bool GetAutomationParameters(EffectAutomationParameters &parms) override
Definition: Compressor.cpp:124
Definition: Compressor.h:138
wxCheckBox * mGainCheckBox
Definition: Compressor.h:132
bool TwoBufferProcessPass1(float *buffer1, size_t len1, float *buffer2, size_t len2) override
Definition: Compressor.cpp:387
bool mUsePeak
Definition: Compressor.h:93
bool InitPass2() override
Definition: Compressor.cpp:376
wxStaticText * mRatioText
Definition: Compressor.h:122
void OnSlider(wxCommandEvent &evt)
Definition: Compressor.cpp:595
void OnSize(wxSizeEvent &evt)
Definition: Compressor.cpp:753
wxStaticText * mNoiseFloorLabel
Definition: Compressor.h:116
virtual ~EffectCompressor()
Definition: Compressor.cpp:94
wxStaticText * mDecayText
Definition: Compressor.h:130
double mGain
Definition: Compressor.h:103
wxSlider * mDecaySlider
Definition: Compressor.h:129
bool TransferDataToWindow() override
Definition: Compressor.cpp:289
Floats mFollow2
Definition: Compressor.h:105
EffectCompressor()
Definition: Compressor.cpp:76
EffectCompressorPanel * mPanel
Definition: Compressor.h:110
void UpdateUI()
Definition: Compressor.cpp:601
wxStaticText * mNoiseFloorText
Definition: Compressor.h:118
float AvgCircle(float x)
Definition: Compressor.cpp:449
float DoCompression(float x, double env)
Definition: Compressor.cpp:577
double mDecayFactor
Definition: Compressor.h:98
EffectType GetType() override
Definition: Compressor.cpp:117
size_t mCircleSize
Definition: Compressor.h:84
size_t mCirclePos
Definition: Compressor.h:85
double mAttackFactor
Definition: Compressor.h:96
bool NewTrackPass1() override
Definition: Compressor.cpp:324
Doubles mCircle
Definition: Compressor.h:86
wxCheckBox * mPeakCheckBox
Definition: Compressor.h:133
bool mNormalize
Definition: Compressor.h:92
wxSlider * mAttackSlider
Definition: Compressor.h:125
size_t mFollowLen
Definition: Compressor.h:106
bool TransferDataFromWindow() override
Definition: Compressor.cpp:304
EffectCompressorPanel(wxWindow *parent, double &threshold, double &noiseFloor, double &ratio)
Definition: Compressor.cpp:648
wxStaticText * mAttackText
Definition: Compressor.h:126
void Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len)
Definition: Compressor.cpp:464
double mMax
Definition: Compressor.h:108
double mRatio
Definition: Compressor.h:91
void PopulateOrExchange(ShuttleGui &S) override
Definition: Compressor.cpp:193
wxString ManualPage() override
Definition: Compressor.cpp:110
bool ProcessPass2(float *buffer, size_t len) override
Definition: Compressor.cpp:429
double & ratio
Definition: Compressor.h:153
void FreshenCircle()
Definition: Compressor.cpp:440
An Effect base class that implements a two pass process by using EffectSimpleMono.
Definition: TwoPassSimpleMono.h:20
double mRMSSum
Definition: Compressor.h:83