Audacity  2.2.0
AutoDuck.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  AutoDuck.h
6 
7  Markus Meyer
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_EFFECT_AUTODUCK__
12 #define __AUDACITY_EFFECT_AUTODUCK__
13 
14 #include <wx/bitmap.h>
15 #include <wx/event.h>
16 #include <wx/gdicmn.h>
17 #include <wx/string.h>
18 #include <wx/textctrl.h>
19 #include <wx/window.h>
20 
21 #include "Effect.h"
22 #include "../widgets/wxPanelWrapper.h"
23 
25 class ShuttleGui;
26 
27 #define AUTO_DUCK_PANEL_NUM_CONTROL_POINTS 5
28 
29 #define AUTODUCK_PLUGIN_SYMBOL XO("Auto Duck")
30 
31 class EffectAutoDuck final : public Effect
32 {
33 public:
35  virtual ~EffectAutoDuck();
36 
37  // IdentInterface implementation
38 
39  wxString GetSymbol() override;
40  wxString GetDescription() override;
41  wxString ManualPage() override;
42 
43  // EffectIdentInterface implementation
44 
45  EffectType GetType() override;
46 
47  // EffectClientInterface implementation
48 
49  bool GetAutomationParameters(EffectAutomationParameters & parms) override;
50  bool SetAutomationParameters(EffectAutomationParameters & parms) override;
51 
52  // Effect implementation
53 
54  bool Startup() override;
55  bool Init() override;
56  void End() override;
57  bool Process() override;
58  void PopulateOrExchange(ShuttleGui & S) override;
59  bool TransferDataToWindow() override;
60  bool TransferDataFromWindow() override;
61 
62 private:
63  // EffectAutoDuck implementation
64 
65  bool ApplyDuckFade(int trackNumber, WaveTrack *t, double t0, double t1);
66 
67  void OnValueChanged(wxCommandEvent & evt);
68 
69 private:
70  double mDuckAmountDb;
75  double mThresholdDb;
76  double mMaximumPause;
77 
79 
80  wxTextCtrl *mDuckAmountDbBox;
81  wxTextCtrl *mInnerFadeDownLenBox;
82  wxTextCtrl *mInnerFadeUpLenBox;
83  wxTextCtrl *mOuterFadeDownLenBox;
84  wxTextCtrl *mOuterFadeUpLenBox;
85  wxTextCtrl *mThresholdDbBox;
86  wxTextCtrl *mMaximumPauseBox;
88 
89  DECLARE_EVENT_TABLE()
90 
91  friend class EffectAutoDuckPanel;
92 };
93 
94 class EffectAutoDuckPanel final : public wxPanelWrapper
95 {
96 public:
97  EffectAutoDuckPanel(wxWindow *parent, EffectAutoDuck *effect);
98  virtual ~EffectAutoDuckPanel();
99 
100 private:
102  {
103  innerFadeDown = 0,
108  none = 99,
109  };
110 
111  bool AcceptsFocus() const override { return false; }
112  // So that wxPanel is not included in Tab traversal - see wxWidgets bug 15581
113  bool AcceptsFocusFromKeyboard() const override { return false; }
114 
115 
116  void OnPaint(wxPaintEvent & evt);
117  void OnMouseCaptureChanged(wxMouseCaptureChangedEvent & evt);
118  void OnMouseCaptureLost(wxMouseCaptureLostEvent & evt);
119  void OnLeftDown(wxMouseEvent & evt);
120  void OnLeftUp(wxMouseEvent & evt);
121  void OnMotion(wxMouseEvent & evt);
122 
123  void ResetControlPoints();
124  EControlPoint GetNearestControlPoint(const wxPoint & pt);
125 
126 private:
127  wxWindow *mParent;
129  std::unique_ptr<wxBitmap> mBackgroundBitmap;
131  wxPoint mControlPoints[AUTO_DUCK_PANEL_NUM_CONTROL_POINTS];
132  wxPoint mMoveStartControlPoints[AUTO_DUCK_PANEL_NUM_CONTROL_POINTS];
135 
136  DECLARE_EVENT_TABLE()
137 };
138 
139 #endif
Implements the Auto Ducking effect.
Definition: AutoDuck.h:31
EffectAutoDuck()
Definition: AutoDuck.cpp:88
void OnValueChanged(wxCommandEvent &evt)
Definition: AutoDuck.cpp:581
#define AUTO_DUCK_PANEL_NUM_CONTROL_POINTS
Definition: AutoDuck.h:27
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
bool AcceptsFocus() const override
Definition: AutoDuck.h:111
wxString ManualPage() override
Definition: AutoDuck.cpp:121
wxTextCtrl * mInnerFadeUpLenBox
Definition: AutoDuck.h:82
EffectType GetType() override
Definition: AutoDuck.cpp:128
wxPoint mMouseDownPoint
Definition: AutoDuck.h:133
double mInnerFadeDownLen
Definition: AutoDuck.h:71
EControlPoint
Definition: AutoDuck.h:101
Definition: AutoDuck.h:106
wxWindow * mParent
Definition: AutoDuck.h:127
bool TransferDataFromWindow() override
Definition: AutoDuck.cpp:504
EffectAutoDuck * mEffect
Definition: AutoDuck.h:128
wxTextCtrl * mThresholdDbBox
Definition: AutoDuck.h:85
Base class for many of the effects in Audacity.
Definition: Effect.h:62
Definition: wxPanelWrapper.h:19
double mMaximumPause
Definition: AutoDuck.h:76
double mOuterFadeUpLen
Definition: AutoDuck.h:74
bool mControlPointMoveActivated
Definition: AutoDuck.h:134
void PopulateOrExchange(ShuttleGui &S) override
Definition: AutoDuck.cpp:424
double mDuckAmountDb
Definition: AutoDuck.h:70
double mThresholdDb
Definition: AutoDuck.h:75
std::unique_ptr< wxBitmap > mBackgroundBitmap
Definition: AutoDuck.h:129
bool ApplyDuckFade(int trackNumber, WaveTrack *t, double t0, double t1)
Definition: AutoDuck.cpp:517
bool Startup() override
Definition: AutoDuck.cpp:171
wxTextCtrl * mInnerFadeDownLenBox
Definition: AutoDuck.h:81
wxTextCtrl * mOuterFadeUpLenBox
Definition: AutoDuck.h:84
friend class EffectAutoDuckPanel
Definition: AutoDuck.h:91
bool SetAutomationParameters(EffectAutomationParameters &parms) override
Definition: AutoDuck.cpp:148
A Track that contains audio waveform data.
Definition: WaveTrack.h:76
wxTextCtrl * mDuckAmountDbBox
Definition: AutoDuck.h:80
Definition: AutoDuck.h:104
wxString GetDescription() override
Definition: AutoDuck.cpp:116
virtual ~EffectAutoDuck()
Definition: AutoDuck.cpp:105
EControlPoint mCurrentControlPoint
Definition: AutoDuck.h:130
bool GetAutomationParameters(EffectAutomationParameters &parms) override
Definition: AutoDuck.cpp:135
Definition: AutoDuck.h:94
bool AcceptsFocusFromKeyboard() const override
Definition: AutoDuck.h:113
wxTextCtrl * mOuterFadeDownLenBox
Definition: AutoDuck.h:83
void End() override
Definition: AutoDuck.cpp:259
EffectAutoDuckPanel * mPanel
Definition: AutoDuck.h:87
bool TransferDataToWindow() override
Definition: AutoDuck.cpp:492
wxString GetSymbol() override
Definition: AutoDuck.cpp:111
bool Process() override
Definition: AutoDuck.cpp:264
bool Init() override
Definition: AutoDuck.cpp:204
Definition: AutoDuck.h:105
const WaveTrack * mControlTrack
Definition: AutoDuck.h:78
wxTextCtrl * mMaximumPauseBox
Definition: AutoDuck.h:86
double mOuterFadeDownLen
Definition: AutoDuck.h:73
double mInnerFadeUpLen
Definition: AutoDuck.h:72
Definition: AutoDuck.h:107