Audacity  2.2.2
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 IdentInterfaceSymbol{ XO("Auto Duck") }
30 
31 class EffectAutoDuck final : public Effect
32 {
33 public:
35  virtual ~EffectAutoDuck();
36 
37  // IdentInterface implementation
38 
40  wxString GetDescription() override;
41  wxString ManualPage() override;
42 
43  // EffectDefinitionInterface implementation
44 
45  EffectType GetType() override;
46 
47  // EffectClientInterface implementation
48 
49  bool DefineParams( ShuttleParams & S ) override;
50  bool GetAutomationParameters(CommandParameters & parms) override;
51  bool SetAutomationParameters(CommandParameters & parms) override;
52 
53  // Effect implementation
54 
55  bool Startup() override;
56  bool Init() override;
57  void End() override;
58  bool Process() override;
59  void PopulateOrExchange(ShuttleGui & S) override;
60  bool TransferDataToWindow() override;
61  bool TransferDataFromWindow() override;
62 
63 private:
64  // EffectAutoDuck implementation
65 
66  bool ApplyDuckFade(int trackNum, WaveTrack *t, double t0, double t1);
67 
68  void OnValueChanged(wxCommandEvent & evt);
69 
70 private:
71  double mDuckAmountDb;
76  double mThresholdDb;
77  double mMaximumPause;
78 
80 
81  wxTextCtrl *mDuckAmountDbBox;
82  wxTextCtrl *mInnerFadeDownLenBox;
83  wxTextCtrl *mInnerFadeUpLenBox;
84  wxTextCtrl *mOuterFadeDownLenBox;
85  wxTextCtrl *mOuterFadeUpLenBox;
86  wxTextCtrl *mThresholdDbBox;
87  wxTextCtrl *mMaximumPauseBox;
89 
90  DECLARE_EVENT_TABLE()
91 
92  friend class EffectAutoDuckPanel;
93 };
94 
95 class EffectAutoDuckPanel final : public wxPanelWrapper
96 {
97 public:
99  wxWindow *parent, wxWindowID winid, EffectAutoDuck *effect);
100  virtual ~EffectAutoDuckPanel();
101 
102 private:
104  {
105  innerFadeDown = 0,
110  none = 99,
111  };
112 
113  bool AcceptsFocus() const override { return false; }
114  // So that wxPanel is not included in Tab traversal - see wxWidgets bug 15581
115  bool AcceptsFocusFromKeyboard() const override { return false; }
116 
117 
118  void OnPaint(wxPaintEvent & evt);
119  void OnMouseCaptureChanged(wxMouseCaptureChangedEvent & evt);
120  void OnMouseCaptureLost(wxMouseCaptureLostEvent & evt);
121  void OnLeftDown(wxMouseEvent & evt);
122  void OnLeftUp(wxMouseEvent & evt);
123  void OnMotion(wxMouseEvent & evt);
124 
125  void ResetControlPoints();
126  EControlPoint GetNearestControlPoint(const wxPoint & pt);
127 
128 private:
129  wxWindow *mParent;
131  std::unique_ptr<wxBitmap> mBackgroundBitmap;
133  wxPoint mControlPoints[AUTO_DUCK_PANEL_NUM_CONTROL_POINTS];
134  wxPoint mMoveStartControlPoints[AUTO_DUCK_PANEL_NUM_CONTROL_POINTS];
137 
138  DECLARE_EVENT_TABLE()
139 };
140 
141 #endif
Implements the Auto Ducking effect.
Definition: AutoDuck.h:31
bool DefineParams(ShuttleParams &S) override
Definition: AutoDuck.cpp:128
void OnValueChanged(wxCommandEvent &evt)
Definition: AutoDuck.cpp:585
#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:409
bool AcceptsFocus() const override
Definition: AutoDuck.h:113
bool GetAutomationParameters(CommandParameters &parms) override
Definition: AutoDuck.cpp:139
wxString ManualPage() override
Definition: AutoDuck.cpp:115
wxTextCtrl * mInnerFadeUpLenBox
Definition: AutoDuck.h:83
EffectType GetType() override
Definition: AutoDuck.cpp:122
wxPoint mMouseDownPoint
Definition: AutoDuck.h:135
IdentInterfaceSymbol GetSymbol() override
Definition: AutoDuck.cpp:105
double mInnerFadeDownLen
Definition: AutoDuck.h:72
wxWindow * mParent
Definition: AutoDuck.h:129
bool TransferDataFromWindow() override
Definition: AutoDuck.cpp:508
EffectAutoDuck * mEffect
Definition: AutoDuck.h:130
wxTextCtrl * mThresholdDbBox
Definition: AutoDuck.h:86
Base class for many of the effects in Audacity.
Definition: Effect.h:62
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:60
double mMaximumPause
Definition: AutoDuck.h:77
double mOuterFadeUpLen
Definition: AutoDuck.h:75
Definition: Dither.h:18
bool mControlPointMoveActivated
Definition: AutoDuck.h:136
void PopulateOrExchange(ShuttleGui &S) override
Definition: AutoDuck.cpp:428
double mDuckAmountDb
Definition: AutoDuck.h:71
double mThresholdDb
Definition: AutoDuck.h:76
std::unique_ptr< wxBitmap > mBackgroundBitmap
Definition: AutoDuck.h:131
bool Startup() override
Definition: AutoDuck.cpp:175
wxTextCtrl * mInnerFadeDownLenBox
Definition: AutoDuck.h:82
wxTextCtrl * mOuterFadeUpLenBox
Definition: AutoDuck.h:85
friend class EffectAutoDuckPanel
Definition: AutoDuck.h:92
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
wxTextCtrl * mDuckAmountDbBox
Definition: AutoDuck.h:81
wxString GetDescription() override
Definition: AutoDuck.cpp:110
virtual ~EffectAutoDuck()
Definition: AutoDuck.cpp:99
bool ApplyDuckFade(int trackNum, WaveTrack *t, double t0, double t1)
Definition: AutoDuck.cpp:521
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
bool SetAutomationParameters(CommandParameters &parms) override
Definition: AutoDuck.cpp:152
EControlPoint mCurrentControlPoint
Definition: AutoDuck.h:132
bool AcceptsFocusFromKeyboard() const override
Definition: AutoDuck.h:115
wxTextCtrl * mOuterFadeDownLenBox
Definition: AutoDuck.h:84
EffectType
void End() override
Definition: AutoDuck.cpp:263
EffectAutoDuckPanel * mPanel
Definition: AutoDuck.h:88
bool TransferDataToWindow() override
Definition: AutoDuck.cpp:496
bool Process() override
Definition: AutoDuck.cpp:268
bool Init() override
Definition: AutoDuck.cpp:208
const WaveTrack * mControlTrack
Definition: AutoDuck.h:79
wxTextCtrl * mMaximumPauseBox
Definition: AutoDuck.h:87
double mOuterFadeDownLen
Definition: AutoDuck.h:74
double mInnerFadeUpLen
Definition: AutoDuck.h:73