Audacity 3.2.0
TimeScale.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 TimeScale.cpp
6
7 Clayton Otey
8
9**********************************************************************/
10#if USE_SBSMS
11#include "TimeScale.h"
12#include "EffectEditor.h"
13#include "LoadEffects.h"
14
15#include <wx/slider.h>
16
17#include "ShuttleGui.h"
18#include "../widgets/valnum.h"
19
20enum
21{
28};
29
31
32BEGIN_EVENT_TABLE(EffectTimeScale, wxEvtHandler)
42
43std::unique_ptr<EffectEditor> EffectTimeScale::PopulateOrExchange(
45 const EffectOutputs *)
46{
47 mUIParent = S.GetParent();
48 S.SetBorder(5);
49 S.AddSpace(0, 5);
50
51 S.StartMultiColumn(2, wxALIGN_CENTER);
52 {
53 // Rate Start
54 S.StartStatic(XO("Initial Tempo Change (%)"));
55 {
56 S.StartMultiColumn(1, wxCENTER);
57 {
58 m_pTextCtrl_RatePercentChangeStart = S.Id(ID_RatePercentChangeStart)
59 .Validator<FloatingPointValidator<double>>(
60 3, &m_RatePercentChangeStart,
61 NumValidatorStyle::NO_TRAILING_ZEROES,
62 RatePercentStart.min, RatePercentStart.max )
63 .AddTextBox( {}, L"", 12);
64 }
65 S.EndMultiColumn();
66 S.StartHorizontalLay(wxEXPAND, 0);
67 {
68 m_pSlider_RatePercentChangeStart = S.Id(ID_RatePercentChangeStart)
69 .Style(wxSL_HORIZONTAL)
70 .AddSlider( {}, RatePercentStart.def, RatePercentStart.max, RatePercentStart.min);
71 }
72 S.EndHorizontalLay();
73 }
74 S.EndStatic();
75
76 S.StartStatic(XO("Final Tempo Change (%)"));
77 {
78 S.StartMultiColumn(1, wxCENTER);
79 {
80 m_pTextCtrl_RatePercentChangeEnd = S.Id(ID_RatePercentChangeEnd)
81 .Validator<FloatingPointValidator<double>>(
82 3, &m_RatePercentChangeEnd,
83 NumValidatorStyle::NO_TRAILING_ZEROES,
84 RatePercentEnd.min, RatePercentEnd.max )
85 .AddTextBox( {}, L"", 12);
86 }
87 S.EndMultiColumn();
88 S.StartHorizontalLay(wxEXPAND, 0);
89 {
90 m_pSlider_RatePercentChangeEnd = S.Id(ID_RatePercentChangeEnd)
91 .Style(wxSL_HORIZONTAL)
92 .AddSlider( {}, RatePercentEnd.def, RatePercentEnd.max, RatePercentEnd.min);
93 }
94 S.EndHorizontalLay();
95 }
96 S.EndStatic();
97
98 // Pitch Start
99 S.StartStatic(XO("Initial Pitch Shift"));
100 {
101 S.StartMultiColumn(2, wxCENTER);
102 {
103 m_pTextCtrl_PitchHalfStepsStart = S.Id(ID_PitchHalfStepsStart)
104 .Validator<FloatingPointValidator<double>>(
105 3, &m_PitchHalfStepsStart,
106 NumValidatorStyle::NO_TRAILING_ZEROES,
107 HalfStepsStart.min, HalfStepsStart.max )
108 .AddTextBox(XXO("(&semitones) [-12 to 12]:"), L"", 12);
109
110
111 m_pTextCtrl_PitchPercentChangeStart = S.Id(ID_PitchPercentChangeStart)
112 .Validator<FloatingPointValidator<double>>(
113 3, &m_PitchPercentChangeStart,
114 NumValidatorStyle::NO_TRAILING_ZEROES,
115 PitchPercentStart.min, PitchPercentStart.max )
116 .AddTextBox(XXO("(%) [-50 to 100]:"), L"", 12);
117 }
118 S.EndMultiColumn();
119 }
120 S.EndStatic();
121
122 // Pitch End
123 S.StartStatic(XO("Final Pitch Shift"));
124 {
125 S.StartMultiColumn(2, wxCENTER);
126 {
127 m_pTextCtrl_PitchHalfStepsEnd = S.Id(ID_PitchHalfStepsEnd)
128 .Validator<FloatingPointValidator<double>>(
129 3, &m_PitchHalfStepsEnd,
130 NumValidatorStyle::NO_TRAILING_ZEROES,
131 HalfStepsEnd.min, HalfStepsEnd.max )
132 .AddTextBox(XXO("(s&emitones) [-12 to 12]:"), L"", 12);
133
134 m_pTextCtrl_PitchPercentChangeEnd = S.Id(ID_PitchPercentChangeEnd)
135 .Validator<FloatingPointValidator<double>>(
136 3, &m_PitchPercentChangeEnd,
137 NumValidatorStyle::NO_TRAILING_ZEROES,
138 PitchPercentStart.min, PitchPercentStart.max)
139 .AddTextBox(XXO("(%) [-50 to 100]:"), L"", 12);
140 }
141 S.EndMultiColumn();
142 }
143 S.EndStatic();
144 }
145 S.EndMultiColumn();
146
147 return nullptr;
148}
149
151{
152 if (!mUIParent->TransferDataToWindow())
153 {
154 return false;
155 }
156
159
160 return true;
161}
162
164{
165 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
166 {
167 return false;
168 }
169
170 return true;
171}
172
174{
175 m_pTextCtrl_RatePercentChangeStart->GetValidator()->TransferToWindow();
176}
177
179{
180 m_pTextCtrl_RatePercentChangeEnd->GetValidator()->TransferToWindow();
181}
182
184{
186}
187
189{
191}
192
194{
195 m_pTextCtrl_PitchHalfStepsStart->GetValidator()->TransferToWindow();
196}
197
199{
200 m_pTextCtrl_PitchHalfStepsEnd->GetValidator()->TransferToWindow();
201}
202
204{
205 m_pTextCtrl_PitchPercentChangeStart->GetValidator()->TransferToWindow();
206}
207
209{
210 m_pTextCtrl_PitchPercentChangeEnd->GetValidator()->TransferToWindow();
211}
212
213void EffectTimeScale::OnText_RatePercentChangeStart(wxCommandEvent & WXUNUSED(evt))
214{
216 mUIParent, mUIParent->TransferDataFromWindow()))
217 {
218 return;
219 }
220
222}
223
224void EffectTimeScale::OnText_RatePercentChangeEnd(wxCommandEvent & WXUNUSED(evt))
225{
227 mUIParent, mUIParent->TransferDataFromWindow()))
228 {
229 return;
230 }
231
233}
234
236{
237 m_RatePercentChangeStart = (double) evt.GetInt();
238
240}
241
243{
244 m_RatePercentChangeEnd = (double) evt.GetInt();
245
247}
248
249void EffectTimeScale::OnText_PitchHalfStepsStart(wxCommandEvent & WXUNUSED(evt))
250{
252 mUIParent, mUIParent->TransferDataFromWindow()))
253 {
254 return;
255 }
256
259}
260
261void EffectTimeScale::OnText_PitchHalfStepsEnd(wxCommandEvent & WXUNUSED(evt))
262{
264 mUIParent, mUIParent->TransferDataFromWindow()))
265 {
266 return;
267 }
268
271}
272
273void EffectTimeScale::OnText_PitchPercentChangeStart(wxCommandEvent & WXUNUSED(evt))
274{
276 mUIParent, mUIParent->TransferDataFromWindow()))
277 {
278 return;
279 }
280
283}
284
285void EffectTimeScale::OnText_PitchPercentChangeEnd(wxCommandEvent & WXUNUSED(evt))
286{
288 mUIParent, mUIParent->TransferDataFromWindow()))
289 {
290 return;
291 }
292
295}
296
297#endif
END_EVENT_TABLE()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
@ ID_RatePercentChangeEnd
Definition: TimeScale.cpp:23
@ ID_PitchHalfStepsEnd
Definition: TimeScale.cpp:25
@ ID_RatePercentChangeStart
Definition: TimeScale.cpp:22
@ ID_PitchPercentChangeEnd
Definition: TimeScale.cpp:27
@ ID_PitchHalfStepsStart
Definition: TimeScale.cpp:24
@ ID_PitchPercentChangeStart
Definition: TimeScale.cpp:26
#define S(N)
Definition: ToChars.cpp:64
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
Performs effect computation.
Hold values to send to effect output meters.
wxTextCtrl * m_pTextCtrl_PitchHalfStepsEnd
Definition: TimeScale.h:62
void Update_Slider_RatePercentChangeEnd()
Definition: TimeScale.cpp:188
void OnSlider_RatePercentChangeStart(wxCommandEvent &evt)
Definition: TimeScale.cpp:235
wxSlider * m_pSlider_RatePercentChangeStart
Definition: TimeScale.h:59
void Update_Text_PitchHalfStepsEnd()
Definition: TimeScale.cpp:198
void Update_Text_PitchHalfStepsStart()
Definition: TimeScale.cpp:193
wxTextCtrl * m_pTextCtrl_RatePercentChangeStart
Definition: TimeScale.h:57
void OnText_PitchPercentChangeEnd(wxCommandEvent &evt)
Definition: TimeScale.cpp:285
wxTextCtrl * m_pTextCtrl_RatePercentChangeEnd
Definition: TimeScale.h:58
void OnText_PitchHalfStepsStart(wxCommandEvent &evt)
Definition: TimeScale.cpp:249
void OnText_PitchPercentChangeStart(wxCommandEvent &evt)
Definition: TimeScale.cpp:273
void Update_Slider_RatePercentChangeStart()
Definition: TimeScale.cpp:183
void OnSlider_RatePercentChangeEnd(wxCommandEvent &evt)
Definition: TimeScale.cpp:242
void OnText_PitchHalfStepsEnd(wxCommandEvent &evt)
Definition: TimeScale.cpp:261
void Update_Text_PitchPercentChangeStart()
Definition: TimeScale.cpp:203
wxSlider * m_pSlider_RatePercentChangeEnd
Definition: TimeScale.h:60
void Update_Text_RatePercentChangeEnd()
Definition: TimeScale.cpp:178
wxWeakRef< wxWindow > mUIParent
Definition: TimeScale.h:55
wxTextCtrl * m_pTextCtrl_PitchHalfStepsStart
Definition: TimeScale.h:61
void Update_Text_RatePercentChangeStart()
Definition: TimeScale.cpp:173
void OnText_RatePercentChangeStart(wxCommandEvent &evt)
Definition: TimeScale.cpp:213
bool TransferDataFromWindow(EffectSettings &settings) override
Definition: TimeScale.cpp:163
void Update_Text_PitchPercentChangeEnd()
Definition: TimeScale.cpp:208
bool TransferDataToWindow(const EffectSettings &settings) override
Definition: TimeScale.cpp:150
wxTextCtrl * m_pTextCtrl_PitchPercentChangeStart
Definition: TimeScale.h:63
void OnText_RatePercentChangeEnd(wxCommandEvent &evt)
Definition: TimeScale.cpp:224
wxTextCtrl * m_pTextCtrl_PitchPercentChangeEnd
Definition: TimeScale.h:64
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
double m_PitchHalfStepsStart
Definition: TimeScaleBase.h:60
double m_RatePercentChangeStart
Definition: TimeScaleBase.h:58
static double HalfStepsToPercentChange(double halfSteps)
double m_PitchPercentChangeStart
Definition: TimeScaleBase.h:62
double m_RatePercentChangeEnd
Definition: TimeScaleBase.h:59
double m_PitchPercentChangeEnd
Definition: TimeScaleBase.h:63
double m_PitchHalfStepsEnd
Definition: TimeScaleBase.h:61
static double PercentChangeToHalfSteps(double percentChange)
BuiltinEffectsModule::Registration< EffectTimeScale > reg
Definition: TimeScale.cpp:30
STL namespace.
Externalized state of a plug-in.