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 IdentInterfaceSymbol{ XO("Change Speed") }
29 
30 class EffectChangeSpeed final : public Effect
31 {
32 public:
34  virtual ~EffectChangeSpeed();
35 
36  // IdentInterface implementation
37 
39  wxString GetDescription() override;
40  wxString ManualPage() override;
41 
42  // EffectDefinitionInterface implementation
43 
44  EffectType GetType() override;
45 
46  // EffectClientInterface implementation
47 
48  bool DefineParams( ShuttleParams & S ) override;
49  bool GetAutomationParameters(CommandParameters & parms) override;
50  bool SetAutomationParameters(CommandParameters & parms) override;
51  bool LoadFactoryDefaults() override;
52 
53  // Effect implementation
54 
55  bool CheckWhetherSkipEffect() override;
56  double CalcPreviewInputLength(double previewLength) override;
57  bool Startup() override;
58  bool Init() override;
59  bool Process() override;
60  void PopulateOrExchange(ShuttleGui & S) override;
61  bool TransferDataFromWindow() override;
62  bool TransferDataToWindow() override;
63 
64 private:
65  // EffectChangeSpeed implementation
66 
67  bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end);
69 
70  // handlers
71  void OnText_PercentChange(wxCommandEvent & evt);
72  void OnText_Multiplier(wxCommandEvent & evt);
73  void OnSlider_PercentChange(wxCommandEvent & evt);
74  void OnChoice_Vinyl(wxCommandEvent & evt);
75  void OnTimeCtrl_ToLength(wxCommandEvent & evt);
76  void OnTimeCtrlUpdate(wxCommandEvent & evt);
77 
78  // helper functions
79  void Update_Text_PercentChange(); // Update control per current m_PercentChange.
80  void Update_Text_Multiplier(); // Update control per current m_PercentChange.
81  void Update_Slider_PercentChange(); // Update control per current m_PercentChange.
82  void Update_Vinyl(); // Update Vinyl controls for NEW percent change.
83  void Update_TimeCtrl_ToLength(); // Update target length controls for NEW percent change.
84  void UpdateUI(); // Enable / disable OK / preview.
85 
86 private:
87  // track related
89  double mMaxNewLength;
90  double mCurT0;
91  double mCurT1;
92 
93  // control values
94  double m_PercentChange; // percent change to apply to tempo
95  // -100% is meaningless, but sky's the upper limit.
96  // Slider is (-100, 200], but textCtrls can set higher.
97  int mFromVinyl; // from standard vinyl speed (RPM) enum
98  double mFactor; // scale factor calculated from percent change
99  double mFromLength; // current selection length
100  int mTimeCtrlFormat; // time control format index number
101  double mMultiplier;
102 
104 
105  // controls
107  wxTextCtrl * mpTextCtrl_Multiplier;
109  wxChoice * mpChoice_FromVinyl;
110  wxChoice * mpChoice_ToVinyl;
113  double mRate;
114 
115  // private effect parameters
116  int mToVinyl; // to standard vinyl speed (rpm)
117  double mToLength; // target length of selection
118  NumericFormatId mFormat; // time control format
119 
120  DECLARE_EVENT_TABLE()
121 };
122 
123 #endif // __AUDACITY_EFFECT_CHANGESPEED__
bool GetAutomationParameters(CommandParameters &parms) override
wxString ManualPage() override
void Update_Slider_PercentChange()
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
bool TransferDataToWindow() override
void OnTimeCtrlUpdate(wxCommandEvent &evt)
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:107
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:108
void Update_TimeCtrl_ToLength()
Base class for many of the effects in Audacity.
Definition: Effect.h:62
double m_PercentChange
Definition: ChangeSpeed.h:94
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:109
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:60
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:106
bool TransferDataFromWindow() override
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:113
void PopulateOrExchange(ShuttleGui &S) override
void Update_Text_PercentChange()
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:111
bool Init() override
virtual ~EffectChangeSpeed()
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
void OnChoice_Vinyl(wxCommandEvent &evt)
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
bool SetAutomationParameters(CommandParameters &parms) override
void OnTimeCtrl_ToLength(wxCommandEvent &evt)
NumericFormatId mFormat
Definition: ChangeSpeed.h:118
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
wxChoice * mpChoice_ToVinyl
Definition: ChangeSpeed.h:110
void OnText_Multiplier(wxCommandEvent &evt)
double CalcPreviewInputLength(double previewLength) override
EffectType GetType() override
EffectType
double mMaxNewLength
Definition: ChangeSpeed.h:89
IdentInterfaceSymbol GetSymbol() override
bool CheckWhetherSkipEffect() override
bool Startup() override
void OnSlider_PercentChange(wxCommandEvent &evt)
bool ProcessLabelTrack(LabelTrack *t)
void OnText_PercentChange(wxCommandEvent &evt)
bool DefineParams(ShuttleParams &S) override
bool LoadFactoryDefaults() override
wxString GetDescription() override
void Update_Text_Multiplier()
bool Process() override
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:112