Audacity  2.2.2
ChangeSpeed.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ChangeSpeed.h
6 
7  Vaughan Johnson, Dominic Mazzoni
8 
9  Change Speed effect, that affects both pitch & tempo.
10 
11 **********************************************************************/
12 
13 #ifndef __AUDACITY_EFFECT_CHANGESPEED__
14 #define __AUDACITY_EFFECT_CHANGESPEED__
15 
16 #include <wx/choice.h>
17 #include <wx/event.h>
18 #include <wx/slider.h>
19 #include <wx/string.h>
20 #include <wx/textctrl.h>
21 
22 #include "../widgets/NumericTextCtrl.h"
23 
24 #include "Effect.h"
25 
26 class ShuttleGui;
27 
28 #define CHANGESPEED_PLUGIN_SYMBOL XO("Change Speed")
29 
30 class EffectChangeSpeed final : public Effect
31 {
32 public:
34  virtual ~EffectChangeSpeed();
35 
36  // IdentInterface implementation
37 
38  wxString GetSymbol() override;
39  wxString GetDescription() override;
40  wxString ManualPage() override;
41 
42  // EffectIdentInterface implementation
43 
44  EffectType GetType() override;
45 
46  // EffectClientInterface implementation
47 
48  bool GetAutomationParameters(EffectAutomationParameters & parms) override;
49  bool SetAutomationParameters(EffectAutomationParameters & parms) override;
50  bool LoadFactoryDefaults() override;
51 
52  // Effect implementation
53 
54  bool CheckWhetherSkipEffect() override;
55  double CalcPreviewInputLength(double previewLength) override;
56  bool Startup() override;
57  bool Init() override;
58  bool Process() override;
59  void PopulateOrExchange(ShuttleGui & S) override;
60  bool TransferDataFromWindow() override;
61  bool TransferDataToWindow() override;
62 
63 private:
64  // EffectChangeSpeed implementation
65 
66  bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end);
68 
69  // handlers
70  void OnText_PercentChange(wxCommandEvent & evt);
71  void OnText_Multiplier(wxCommandEvent & evt);
72  void OnSlider_PercentChange(wxCommandEvent & evt);
73  void OnChoice_Vinyl(wxCommandEvent & evt);
74  void OnTimeCtrl_ToLength(wxCommandEvent & evt);
75  void OnTimeCtrlUpdate(wxCommandEvent & evt);
76 
77  // helper functions
78  void Update_Text_PercentChange(); // Update control per current m_PercentChange.
79  void Update_Text_Multiplier(); // Update control per current m_PercentChange.
80  void Update_Slider_PercentChange(); // Update control per current m_PercentChange.
81  void Update_Vinyl(); // Update Vinyl controls for NEW percent change.
82  void Update_TimeCtrl_ToLength(); // Update target length controls for NEW percent change.
83  void UpdateUI(); // Enable / disable OK / preview.
84 
85 private:
86  // track related
88  double mMaxNewLength;
89  double mCurT0;
90  double mCurT1;
91 
92  // control values
93  double m_PercentChange; // percent change to apply to tempo
94  // -100% is meaningless, but sky's the upper limit.
95  // Slider is (-100, 200], but textCtrls can set higher.
96  int mFromVinyl; // from standard vinyl speed (RPM) enum
97  double mFactor; // scale factor calculated from percent change
98  double mFromLength; // current selection length
99  int mTimeCtrlFormat; // time control format index number
100  double mMultiplier;
101 
103 
104  // controls
106  wxTextCtrl * mpTextCtrl_Multiplier;
108  wxChoice * mpChoice_FromVinyl;
109  wxChoice * mpChoice_ToVinyl;
112  double mRate;
113 
114  // private effect parameters
115  int mToVinyl; // to standard vinyl speed (rpm)
116  double mToLength; // target length of selection
117  wxString mFormat; // time control format
118 
119  DECLARE_EVENT_TABLE()
120 };
121 
122 #endif // __AUDACITY_EFFECT_CHANGESPEED__
wxString ManualPage() override
void Update_Slider_PercentChange()
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
bool TransferDataToWindow() override
void OnTimeCtrlUpdate(wxCommandEvent &evt)
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:106
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:107
void Update_TimeCtrl_ToLength()
Base class for many of the effects in Audacity.
Definition: Effect.h:62
double m_PercentChange
Definition: ChangeSpeed.h:93
bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end)
An Effect that affects both pitch & speed.
Definition: ChangeSpeed.h:30
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:108
wxString GetSymbol() override
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:105
bool TransferDataFromWindow() override
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:114
void PopulateOrExchange(ShuttleGui &S) override
void Update_Text_PercentChange()
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:110
bool Init() override
virtual ~EffectChangeSpeed()
void OnChoice_Vinyl(wxCommandEvent &evt)
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
void OnTimeCtrl_ToLength(wxCommandEvent &evt)
wxChoice * mpChoice_ToVinyl
Definition: ChangeSpeed.h:109
void OnText_Multiplier(wxCommandEvent &evt)
double CalcPreviewInputLength(double previewLength) override
EffectType GetType() override
double mMaxNewLength
Definition: ChangeSpeed.h:88
bool CheckWhetherSkipEffect() override
bool GetAutomationParameters(EffectAutomationParameters &parms) override
bool Startup() override
void OnSlider_PercentChange(wxCommandEvent &evt)
bool ProcessLabelTrack(LabelTrack *t)
void OnText_PercentChange(wxCommandEvent &evt)
bool LoadFactoryDefaults() override
wxString GetDescription() override
void Update_Text_Multiplier()
bool Process() override
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:111
bool SetAutomationParameters(EffectAutomationParameters &parms) override