2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
AutoDuck.h
|
|
|
|
|
|
|
|
Markus Meyer
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_EFFECT_AUTODUCK__
|
|
|
|
#define __AUDACITY_EFFECT_AUTODUCK__
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
#include <wx/bitmap.h>
|
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
#include <wx/string.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/textctrl.h>
|
2015-04-17 03:53:42 +00:00
|
|
|
#include <wx/window.h>
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "Effect.h"
|
2016-06-25 18:18:23 +00:00
|
|
|
#include "../widgets/wxPanelWrapper.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
class EffectAutoDuckPanel;
|
2015-06-18 14:24:36 +00:00
|
|
|
class ShuttleGui;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
#define AUTO_DUCK_PANEL_NUM_CONTROL_POINTS 5
|
|
|
|
|
2015-04-19 03:49:05 +00:00
|
|
|
#define AUTODUCK_PLUGIN_SYMBOL XO("Auto Duck")
|
2015-04-17 03:53:42 +00:00
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class EffectAutoDuck final : public Effect
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-04-17 03:53:42 +00:00
|
|
|
EffectAutoDuck();
|
|
|
|
virtual ~EffectAutoDuck();
|
|
|
|
|
|
|
|
// IdentInterface implementation
|
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
wxString GetSymbol() override;
|
|
|
|
wxString GetDescription() override;
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
// EffectIdentInterface implementation
|
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
EffectType GetType() override;
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
// EffectClientInterface implementation
|
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
bool GetAutomationParameters(EffectAutomationParameters & parms) override;
|
|
|
|
bool SetAutomationParameters(EffectAutomationParameters & parms) override;
|
2015-04-17 03:53:42 +00:00
|
|
|
|
|
|
|
// Effect implementation
|
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
bool Startup() override;
|
|
|
|
bool Init() override;
|
|
|
|
void End() override;
|
|
|
|
bool Process() override;
|
|
|
|
void PopulateOrExchange(ShuttleGui & S) override;
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
private:
|
2015-04-17 03:53:42 +00:00
|
|
|
// EffectAutoDuck implementation
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
bool ApplyDuckFade(int trackNumber, WaveTrack *t, double t0, double t1);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void OnValueChanged(wxCommandEvent & evt);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
private:
|
|
|
|
double mDuckAmountDb;
|
|
|
|
double mInnerFadeDownLen;
|
|
|
|
double mInnerFadeUpLen;
|
|
|
|
double mOuterFadeDownLen;
|
|
|
|
double mOuterFadeUpLen;
|
|
|
|
double mThresholdDb;
|
|
|
|
double mMaximumPause;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
WaveTrack *mControlTrack;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
wxTextCtrl *mDuckAmountDbBox;
|
|
|
|
wxTextCtrl *mInnerFadeDownLenBox;
|
|
|
|
wxTextCtrl *mInnerFadeUpLenBox;
|
|
|
|
wxTextCtrl *mOuterFadeDownLenBox;
|
|
|
|
wxTextCtrl *mOuterFadeUpLenBox;
|
|
|
|
wxTextCtrl *mThresholdDbBox;
|
|
|
|
wxTextCtrl *mMaximumPauseBox;
|
|
|
|
EffectAutoDuckPanel *mPanel;
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE();
|
|
|
|
|
|
|
|
friend class EffectAutoDuckPanel;
|
|
|
|
};
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-06-25 18:18:23 +00:00
|
|
|
class EffectAutoDuckPanel final : public wxPanelWrapper
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-04-17 03:53:42 +00:00
|
|
|
EffectAutoDuckPanel(wxWindow *parent, EffectAutoDuck *effect);
|
2010-01-23 19:44:49 +00:00
|
|
|
virtual ~EffectAutoDuckPanel();
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
private:
|
|
|
|
enum EControlPoint
|
|
|
|
{
|
|
|
|
innerFadeDown = 0,
|
|
|
|
outerFadeDown,
|
|
|
|
innerFadeUp,
|
|
|
|
outerFadeUp,
|
|
|
|
duckAmount,
|
|
|
|
none = 99,
|
|
|
|
};
|
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
bool AcceptsFocus() const override { return false; }
|
2015-11-26 15:21:48 +00:00
|
|
|
// So that wxPanel is not included in Tab traversal - see wxWidgets bug 15581
|
2016-02-24 06:06:47 +00:00
|
|
|
bool AcceptsFocusFromKeyboard() const override { return false; }
|
2015-11-26 15:21:48 +00:00
|
|
|
|
2012-03-21 03:09:06 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
void OnPaint(wxPaintEvent & evt);
|
|
|
|
void OnMouseCaptureChanged(wxMouseCaptureChangedEvent & evt);
|
|
|
|
void OnMouseCaptureLost(wxMouseCaptureLostEvent & evt);
|
|
|
|
void OnLeftDown(wxMouseEvent & evt);
|
|
|
|
void OnLeftUp(wxMouseEvent & evt);
|
|
|
|
void OnMotion(wxMouseEvent & evt);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
void ResetControlPoints();
|
2015-04-17 03:53:42 +00:00
|
|
|
EControlPoint GetNearestControlPoint(const wxPoint & pt);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
private:
|
|
|
|
wxWindow *mParent;
|
|
|
|
EffectAutoDuck *mEffect;
|
|
|
|
wxBitmap *mBackgroundBitmap;
|
2010-01-23 19:44:49 +00:00
|
|
|
EControlPoint mCurrentControlPoint;
|
|
|
|
wxPoint mControlPoints[AUTO_DUCK_PANEL_NUM_CONTROL_POINTS];
|
|
|
|
wxPoint mMoveStartControlPoints[AUTO_DUCK_PANEL_NUM_CONTROL_POINTS];
|
|
|
|
wxPoint mMouseDownPoint;
|
|
|
|
bool mControlPointMoveActivated;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
DECLARE_EVENT_TABLE();
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|