Audacity  3.0.3
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 "Effect.h"
17 
18 class wxSlider;
19 class wxChoice;
20 class wxTextCtrl;
21 class NumericTextCtrl;
22 class ShuttleGui;
23 
24 class EffectChangeSpeed final : public Effect
25 {
26 public:
28 
30  virtual ~EffectChangeSpeed();
31 
32  // ComponentInterface implementation
33 
36  ManualPageID ManualPage() override;
37 
38  // EffectDefinitionInterface implementation
39 
40  EffectType GetType() override;
41 
42  // EffectClientInterface implementation
43 
44  bool DefineParams( ShuttleParams & S ) override;
45  bool GetAutomationParameters(CommandParameters & parms) override;
46  bool SetAutomationParameters(CommandParameters & parms) override;
47  bool LoadFactoryDefaults() override;
48 
49  // Effect implementation
50 
51  bool CheckWhetherSkipEffect() override;
52  double CalcPreviewInputLength(double previewLength) override;
53  bool Startup() override;
54  bool Init() override;
55  bool Process() override;
56  void PopulateOrExchange(ShuttleGui & S) override;
57  bool TransferDataFromWindow() override;
58  bool TransferDataToWindow() override;
59 
60 private:
61  // EffectChangeSpeed implementation
62 
63  bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end);
65 
66  // handlers
67  void OnText_PercentChange(wxCommandEvent & evt);
68  void OnText_Multiplier(wxCommandEvent & evt);
69  void OnSlider_PercentChange(wxCommandEvent & evt);
70  void OnChoice_Vinyl(wxCommandEvent & evt);
71  void OnTimeCtrl_ToLength(wxCommandEvent & evt);
72  void OnTimeCtrlUpdate(wxCommandEvent & evt);
73 
74  // helper functions
75  void Update_Text_PercentChange(); // Update control per current m_PercentChange.
76  void Update_Text_Multiplier(); // Update control per current m_PercentChange.
77  void Update_Slider_PercentChange(); // Update control per current m_PercentChange.
78  void Update_Vinyl(); // Update Vinyl controls for NEW percent change.
79  void Update_TimeCtrl_ToLength(); // Update target length controls for NEW percent change.
80  void UpdateUI(); // Enable / disable OK / preview.
81 
82 private:
83  // track related
85  double mMaxNewLength;
86  double mCurT0;
87  double mCurT1;
88 
89  // control values
90  double m_PercentChange; // percent change to apply to tempo
91  // -100% is meaningless, but sky's the upper limit.
92  // Slider is (-100, 200], but textCtrls can set higher.
93  int mFromVinyl; // from standard vinyl speed (RPM) enum
94  double mFactor; // scale factor calculated from percent change
95  double mFromLength; // current selection length
96  int mTimeCtrlFormat; // time control format index number
97  double mMultiplier;
98 
100 
101  // controls
103  wxTextCtrl * mpTextCtrl_Multiplier;
105  wxChoice * mpChoice_FromVinyl;
106  wxChoice * mpChoice_ToVinyl;
109  double mRate;
110 
111  // private effect parameters
112  int mToVinyl; // to standard vinyl speed (rpm)
113  double mToLength; // target length of selection
114  NumericFormatSymbol mFormat; // time control format
115 
116  DECLARE_EVENT_TABLE()
117 };
118 
119 #endif // __AUDACITY_EFFECT_CHANGESPEED__
EffectChangeSpeed::mpChoice_FromVinyl
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:105
EffectChangeSpeed::OnTimeCtrlUpdate
void OnTimeCtrlUpdate(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:718
EffectChangeSpeed::ProcessOne
bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end)
Definition: ChangeSpeed.cpp:481
EffectChangeSpeed::Update_Text_Multiplier
void Update_Text_Multiplier()
Definition: ChangeSpeed.cpp:737
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
EffectChangeSpeed::Startup
bool Startup() override
Definition: ChangeSpeed.cpp:181
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
EffectChangeSpeed::ProcessLabelTrack
bool ProcessLabelTrack(LabelTrack *t)
Definition: ChangeSpeed.cpp:470
EffectChangeSpeed::GetAutomationParameters
bool GetAutomationParameters(CommandParameters &parms) override
Definition: ChangeSpeed.cpp:145
EffectChangeSpeed::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: ChangeSpeed.h:27
Effect.h
EffectChangeSpeed::mToVinyl
int mToVinyl
Definition: ChangeSpeed.h:112
EffectChangeSpeed::mbLoopDetect
bool mbLoopDetect
Definition: ChangeSpeed.h:99
Effect
Base class for many of the effects in Audacity.
Definition: Effect.h:72
EffectChangeSpeed::mpToLengthCtrl
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:108
EffectChangeSpeed::~EffectChangeSpeed
virtual ~EffectChangeSpeed()
Definition: ChangeSpeed.cpp:110
EffectChangeSpeed::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: ChangeSpeed.cpp:116
ShuttleParams
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:62
LabelTrack
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:88
EffectChangeSpeed::Init
bool Init() override
Definition: ChangeSpeed.cpp:222
NumericTextCtrl
Definition: NumericTextCtrl.h:172
EffectChangeSpeed::mpTextCtrl_PercentChange
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:102
EffectChangeSpeed::ManualPage
ManualPageID ManualPage() override
Definition: ChangeSpeed.cpp:126
EffectChangeSpeed::Update_Vinyl
void Update_Vinyl()
Definition: ChangeSpeed.cpp:759
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
EffectChangeSpeed::Update_Slider_PercentChange
void Update_Slider_PercentChange()
Definition: ChangeSpeed.cpp:744
EffectChangeSpeed::CheckWhetherSkipEffect
bool CheckWhetherSkipEffect() override
Definition: ChangeSpeed.cpp:171
EffectChangeSpeed::mCurTrackNum
int mCurTrackNum
Definition: ChangeSpeed.h:84
EffectChangeSpeed::mToLength
double mToLength
Definition: ChangeSpeed.h:113
EffectChangeSpeed::SetAutomationParameters
bool SetAutomationParameters(CommandParameters &parms) override
Definition: ChangeSpeed.cpp:152
EffectChangeSpeed::mCurT0
double mCurT0
Definition: ChangeSpeed.h:86
EffectChangeSpeed::m_PercentChange
double m_PercentChange
Definition: ChangeSpeed.h:90
EffectChangeSpeed::mCurT1
double mCurT1
Definition: ChangeSpeed.h:87
EffectChangeSpeed::mMaxNewLength
double mMaxNewLength
Definition: ChangeSpeed.h:85
EffectChangeSpeed::mpChoice_ToVinyl
wxChoice * mpChoice_ToVinyl
Definition: ChangeSpeed.h:106
EffectChangeSpeed::mRate
double mRate
Definition: ChangeSpeed.h:109
EffectChangeSpeed::mFormat
NumericFormatSymbol mFormat
Definition: ChangeSpeed.h:114
EffectChangeSpeed::EffectChangeSpeed
EffectChangeSpeed()
Definition: ChangeSpeed.cpp:95
EffectChangeSpeed::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: ChangeSpeed.cpp:450
EffectChangeSpeed::OnText_Multiplier
void OnText_Multiplier(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:621
EffectChangeSpeed::LoadFactoryDefaults
bool LoadFactoryDefaults() override
Definition: ChangeSpeed.cpp:161
EffectChangeSpeed::OnTimeCtrl_ToLength
void OnTimeCtrl_ToLength(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:697
EffectChangeSpeed
An Effect that affects both pitch & speed.
Definition: ChangeSpeed.h:25
EffectChangeSpeed::OnSlider_PercentChange
void OnSlider_PercentChange(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:638
EffectChangeSpeed::Update_Text_PercentChange
void Update_Text_PercentChange()
Definition: ChangeSpeed.cpp:731
EffectChangeSpeed::GetType
EffectType GetType() override
Definition: ChangeSpeed.cpp:134
EffectChangeSpeed::mMultiplier
double mMultiplier
Definition: ChangeSpeed.h:97
EffectChangeSpeed::mFromLength
double mFromLength
Definition: ChangeSpeed.h:95
EffectChangeSpeed::OnText_PercentChange
void OnText_PercentChange(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:605
EffectChangeSpeed::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: ChangeSpeed.cpp:293
EffectChangeSpeed::OnChoice_Vinyl
void OnChoice_Vinyl(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:657
EffectChangeSpeed::mpFromLengthCtrl
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:107
TaggedIdentifier< ManualPageIDTag >
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
EffectChangeSpeed::mFactor
double mFactor
Definition: ChangeSpeed.h:94
EffectChangeSpeed::GetDescription
TranslatableString GetDescription() override
Definition: ChangeSpeed.cpp:121
EffectChangeSpeed::Process
bool Process() override
Definition: ChangeSpeed.cpp:230
EffectChangeSpeed::CalcPreviewInputLength
double CalcPreviewInputLength(double previewLength) override
Definition: ChangeSpeed.cpp:176
EffectType
EffectType
Definition: EffectInterface.h:55
EffectChangeSpeed::mFromVinyl
int mFromVinyl
Definition: ChangeSpeed.h:93
EffectChangeSpeed::TransferDataToWindow
bool TransferDataToWindow() override
Definition: ChangeSpeed.cpp:414
EffectChangeSpeed::mpTextCtrl_Multiplier
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:103
EffectChangeSpeed::UpdateUI
void UpdateUI()
Definition: ChangeSpeed.cpp:826
EffectChangeSpeed::mTimeCtrlFormat
int mTimeCtrlFormat
Definition: ChangeSpeed.h:96
EffectChangeSpeed::Update_TimeCtrl_ToLength
void Update_TimeCtrl_ToLength()
Definition: ChangeSpeed.cpp:812
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
EffectChangeSpeed::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: ChangeSpeed.cpp:140
EffectChangeSpeed::mpSlider_PercentChange
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:104