2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
Compressor.h
|
|
|
|
|
|
|
|
Dominic Mazzoni
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_EFFECT_COMPRESSOR__
|
|
|
|
#define __AUDACITY_EFFECT_COMPRESSOR__
|
|
|
|
|
|
|
|
#include <wx/bitmap.h>
|
|
|
|
#include <wx/checkbox.h>
|
2015-04-17 03:53:42 +00:00
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
#include <wx/slider.h>
|
|
|
|
#include <wx/string.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/stattext.h>
|
2015-04-17 03:53:42 +00:00
|
|
|
#include <wx/window.h>
|
2016-06-25 18:18:23 +00:00
|
|
|
#include "../widgets/wxPanelWrapper.h"
|
2015-04-17 03:53:42 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "TwoPassSimpleMono.h"
|
2016-04-14 16:35:15 +00:00
|
|
|
#include "../SampleFormat.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
class EffectCompressorPanel;
|
2015-06-18 14:24:36 +00:00
|
|
|
class ShuttleGui;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-19 03:49:05 +00:00
|
|
|
#define COMPRESSOR_PLUGIN_SYMBOL XO("Compressor")
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class EffectCompressor final : public EffectTwoPassSimpleMono
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2010-01-23 19:44:49 +00:00
|
|
|
public:
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
EffectCompressor();
|
|
|
|
virtual ~EffectCompressor();
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// IdentInterface implementation
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
wxString GetSymbol() override;
|
|
|
|
wxString GetDescription() override;
|
2017-05-20 13:40:09 +00:00
|
|
|
wxString ManualPage() override;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// EffectIdentInterface implementation
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
EffectType GetType() override;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// EffectClientInterface implementation
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
bool GetAutomationParameters(EffectAutomationParameters & parms) override;
|
|
|
|
bool SetAutomationParameters(EffectAutomationParameters & parms) override;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// Effect implementation
|
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
bool Startup() override;
|
|
|
|
void PopulateOrExchange(ShuttleGui & S) override;
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// EffectTwoPassSimpleMono implementation
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
bool InitPass1() override;
|
|
|
|
bool InitPass2() override;
|
|
|
|
bool NewTrackPass1() override;
|
2016-09-06 13:19:27 +00:00
|
|
|
bool ProcessPass2(float *buffer, size_t len) override;
|
|
|
|
bool TwoBufferProcessPass1
|
|
|
|
(float *buffer1, size_t len1, float *buffer2, size_t len2) override;
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// EffectCompressor implementation
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
void FreshenCircle();
|
|
|
|
float AvgCircle(float x);
|
2016-09-06 13:19:27 +00:00
|
|
|
void Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len);
|
2015-04-17 03:53:42 +00:00
|
|
|
float DoCompression(float x, double env);
|
|
|
|
|
|
|
|
void OnSlider(wxCommandEvent & evt);
|
|
|
|
void UpdateUI();
|
|
|
|
|
|
|
|
private:
|
2010-01-23 19:44:49 +00:00
|
|
|
double mRMSSum;
|
2016-04-14 16:35:15 +00:00
|
|
|
size_t mCircleSize;
|
|
|
|
size_t mCirclePos;
|
|
|
|
Doubles mCircle;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
double mAttackTime;
|
|
|
|
double mThresholdDB;
|
|
|
|
double mNoiseFloorDB;
|
|
|
|
double mRatio;
|
|
|
|
bool mNormalize; //MJS
|
|
|
|
bool mUsePeak;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2013-12-23 10:31:47 +00:00
|
|
|
double mDecayTime; // The "Release" time.
|
2010-01-23 19:44:49 +00:00
|
|
|
double mAttackFactor;
|
|
|
|
double mAttackInverseFactor;
|
|
|
|
double mDecayFactor;
|
|
|
|
double mThreshold;
|
|
|
|
double mCompression;
|
|
|
|
double mNoiseFloor;
|
|
|
|
int mNoiseCounter;
|
|
|
|
double mGain;
|
|
|
|
double mLastLevel;
|
2016-04-14 16:35:15 +00:00
|
|
|
Floats mFollow1, mFollow2;
|
2016-09-06 13:19:27 +00:00
|
|
|
size_t mFollowLen;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
double mMax; //MJS
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
EffectCompressorPanel *mPanel;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
wxStaticText *mThresholdLabel;
|
|
|
|
wxSlider *mThresholdSlider;
|
|
|
|
wxStaticText *mThresholdText;
|
|
|
|
|
|
|
|
wxStaticText *mNoiseFloorLabel;
|
|
|
|
wxSlider *mNoiseFloorSlider;
|
|
|
|
wxStaticText *mNoiseFloorText;
|
|
|
|
|
|
|
|
wxStaticText *mRatioLabel;
|
|
|
|
wxSlider *mRatioSlider;
|
|
|
|
wxStaticText *mRatioText;
|
|
|
|
|
|
|
|
wxStaticText *mAttackLabel;
|
|
|
|
wxSlider *mAttackSlider;
|
|
|
|
wxStaticText *mAttackText;
|
|
|
|
|
|
|
|
wxStaticText *mDecayLabel;
|
|
|
|
wxSlider *mDecaySlider;
|
|
|
|
wxStaticText *mDecayText;
|
|
|
|
|
|
|
|
wxCheckBox *mGainCheckBox;
|
|
|
|
wxCheckBox *mPeakCheckBox;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2016-09-18 14:26:29 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2015-04-17 03:53:42 +00:00
|
|
|
};
|
|
|
|
|
2016-06-25 18:18:23 +00:00
|
|
|
class EffectCompressorPanel final : public wxPanelWrapper
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-10-20 16:06:29 +00:00
|
|
|
EffectCompressorPanel(wxWindow *parent, wxWindowID winid,
|
2015-04-17 03:53:42 +00:00
|
|
|
double & threshold,
|
|
|
|
double & noiseFloor,
|
|
|
|
double & ratio);
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
private:
|
2015-04-17 03:53:42 +00:00
|
|
|
void OnPaint(wxPaintEvent & evt);
|
|
|
|
void OnSize(wxSizeEvent & evt);
|
|
|
|
|
|
|
|
private:
|
|
|
|
double & threshold;
|
|
|
|
double & noiseFloor;
|
|
|
|
double & ratio;
|
|
|
|
|
2016-09-18 14:26:29 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|