Audacity  2.2.2
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 IdentInterfaceSymbol{ XO("Compressor") }
31 
33 {
34 public:
35 
37  virtual ~EffectCompressor();
38 
39  // IdentInterface implementation
40 
42  wxString GetDescription() override;
43  wxString ManualPage() override;
44 
45  // EffectDefinitionInterface implementation
46 
47  EffectType GetType() override;
48 
49  // EffectClientInterface implementation
50 
51  bool DefineParams( ShuttleParams & S ) override;
52  bool GetAutomationParameters(CommandParameters & parms) override;
53  bool SetAutomationParameters(CommandParameters & parms) override;
54 
55  // Effect implementation
56 
57  bool Startup() override;
58  void PopulateOrExchange(ShuttleGui & S) override;
59  bool TransferDataToWindow() override;
60  bool TransferDataFromWindow() override;
61 
62 protected:
63  // EffectTwoPassSimpleMono implementation
64 
65  bool InitPass1() override;
66  bool InitPass2() override;
67  bool NewTrackPass1() override;
68  bool ProcessPass2(float *buffer, size_t len) override;
70  (float *buffer1, size_t len1, float *buffer2, size_t len2) override;
71 
72 private:
73  // EffectCompressor implementation
74 
75  void FreshenCircle();
76  float AvgCircle(float x);
77  void Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len);
78  float DoCompression(float x, double env);
79 
80  void OnSlider(wxCommandEvent & evt);
81  void UpdateUI();
82 
83 private:
84  double mRMSSum;
85  size_t mCircleSize;
86  size_t mCirclePos;
88 
89  double mAttackTime;
90  double mThresholdDB;
91  double mNoiseFloorDB;
92  double mRatio;
93  bool mNormalize; //MJS
94  bool mUsePeak;
95 
96  double mDecayTime; // The "Release" time.
97  double mAttackFactor;
99  double mDecayFactor;
100  double mThreshold;
101  double mCompression;
102  double mNoiseFloor;
104  double mGain;
105  double mLastLevel;
107  size_t mFollowLen;
108 
109  double mMax; //MJS
110 
112 
113  wxStaticText *mThresholdLabel;
114  wxSlider *mThresholdSlider;
115  wxStaticText *mThresholdText;
116 
117  wxStaticText *mNoiseFloorLabel;
118  wxSlider *mNoiseFloorSlider;
119  wxStaticText *mNoiseFloorText;
120 
121  wxStaticText *mRatioLabel;
122  wxSlider *mRatioSlider;
123  wxStaticText *mRatioText;
124 
125  wxStaticText *mAttackLabel;
126  wxSlider *mAttackSlider;
127  wxStaticText *mAttackText;
128 
129  wxStaticText *mDecayLabel;
130  wxSlider *mDecaySlider;
131  wxStaticText *mDecayText;
132 
133  wxCheckBox *mGainCheckBox;
134  wxCheckBox *mPeakCheckBox;
135 
136  DECLARE_EVENT_TABLE()
137 };
138 
140 {
141 public:
142  EffectCompressorPanel(wxWindow *parent, wxWindowID winid,
143  double & threshold,
144  double & noiseFloor,
145  double & ratio);
146 
147 private:
148  void OnPaint(wxPaintEvent & evt);
149  void OnSize(wxSizeEvent & evt);
150 
151 private:
152  double & threshold;
153  double & noiseFloor;
154  double & ratio;
155 
156  DECLARE_EVENT_TABLE()
157 };
158 
159 #endif
160 
wxSlider * mRatioSlider
Definition: Compressor.h:122
wxSlider * mThresholdSlider
Definition: Compressor.h:114
double mAttackInverseFactor
Definition: Compressor.h:98
double mAttackTime
Definition: Compressor.h:89
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
bool Startup() override
Definition: Compressor.cpp:169
bool InitPass1() override
Definition: Compressor.cpp:358
wxStaticText * mThresholdText
Definition: Compressor.h:115
wxStaticText * mThresholdLabel
Definition: Compressor.h:113
wxStaticText * mRatioLabel
Definition: Compressor.h:121
double mDecayTime
Definition: Compressor.h:96
An Effect derived from EffectTwoPassSimpleMono.
Definition: Compressor.h:32
double mNoiseFloorDB
Definition: Compressor.h:91
void OnPaint(wxPaintEvent &evt)
Definition: Compressor.cpp:668
double mThresholdDB
Definition: Compressor.h:90
EffectCompressorPanel(wxWindow *parent, wxWindowID winid, double &threshold, double &noiseFloor, double &ratio)
Definition: Compressor.cpp:657
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:60
wxSlider * mNoiseFloorSlider
Definition: Compressor.h:118
double mCompression
Definition: Compressor.h:101
double mNoiseFloor
Definition: Compressor.h:102
wxString GetDescription() override
Definition: Compressor.cpp:104
wxStaticText * mAttackLabel
Definition: Compressor.h:125
wxStaticText * mDecayLabel
Definition: Compressor.h:129
wxCheckBox * mGainCheckBox
Definition: Compressor.h:133
bool TwoBufferProcessPass1(float *buffer1, size_t len1, float *buffer2, size_t len2) override
Definition: Compressor.cpp:396
IdentInterfaceSymbol GetSymbol() override
Definition: Compressor.cpp:99
bool InitPass2() override
Definition: Compressor.cpp:385
wxStaticText * mRatioText
Definition: Compressor.h:123
void OnSlider(wxCommandEvent &evt)
Definition: Compressor.cpp:604
void OnSize(wxSizeEvent &evt)
Definition: Compressor.cpp:762
wxStaticText * mNoiseFloorLabel
Definition: Compressor.h:117
virtual ~EffectCompressor()
Definition: Compressor.cpp:93
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
wxStaticText * mDecayText
Definition: Compressor.h:131
wxSlider * mDecaySlider
Definition: Compressor.h:130
bool TransferDataToWindow() override
Definition: Compressor.cpp:298
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
EffectCompressorPanel * mPanel
Definition: Compressor.h:111
wxStaticText * mNoiseFloorText
Definition: Compressor.h:119
float AvgCircle(float x)
Definition: Compressor.cpp:458
bool SetAutomationParameters(CommandParameters &parms) override
Definition: Compressor.cpp:146
float DoCompression(float x, double env)
Definition: Compressor.cpp:586
double mDecayFactor
Definition: Compressor.h:99
EffectType GetType() override
Definition: Compressor.cpp:116
size_t mCircleSize
Definition: Compressor.h:85
EffectType
size_t mCirclePos
Definition: Compressor.h:86
double mAttackFactor
Definition: Compressor.h:97
bool NewTrackPass1() override
Definition: Compressor.cpp:333
Doubles mCircle
Definition: Compressor.h:87
wxCheckBox * mPeakCheckBox
Definition: Compressor.h:134
wxSlider * mAttackSlider
Definition: Compressor.h:126
bool TransferDataFromWindow() override
Definition: Compressor.cpp:313
wxStaticText * mAttackText
Definition: Compressor.h:127
bool DefineParams(ShuttleParams &S) override
Definition: Compressor.cpp:122
void Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len)
Definition: Compressor.cpp:473
void PopulateOrExchange(ShuttleGui &S) override
Definition: Compressor.cpp:202
wxString ManualPage() override
Definition: Compressor.cpp:109
bool ProcessPass2(float *buffer, size_t len) override
Definition: Compressor.cpp:438
bool GetAutomationParameters(CommandParameters &parms) override
Definition: Compressor.cpp:133
An Effect base class that implements a two pass process by using EffectSimpleMono.