25#include <wx/checkbox.h>
29#include "../widgets/valnum.h"
51 EVT_TEXT(ID_FromBPM, EffectChangeTempo::OnText_FromBPM)
52 EVT_TEXT(ID_ToBPM, EffectChangeTempo::OnText_ToBPM)
53 EVT_TEXT(
ID_ToLength, EffectChangeTempo::OnText_ToLength)
60 mUIParent =
S.GetParent();
62 enum { precision = 2 };
64 S.StartVerticalLay(0);
67 S.StartMultiColumn(2, wxCENTER);
70 .Validator<FloatingPointValidator<double>>(
71 3, &m_PercentChange, NumValidatorStyle::THREE_TRAILING_ZEROES,
72 Percentage.min, Percentage.max )
73 .AddTextBox(
XXO(
"Percent C&hange:"), L
"", 12);
78 S.StartHorizontalLay(wxEXPAND);
81 .Name(
XO(
"Percent Change"))
82 .Style(wxSL_HORIZONTAL)
83 .AddSlider( {}, 0, (int)
kSliderMax, (
int)Percentage.min);
87 S.StartStatic(
XO(
"Beats per minute"));
89 S.StartHorizontalLay(wxALIGN_CENTER);
91 m_pTextCtrl_FromBPM =
S.Id(ID_FromBPM)
93 .Name(
XO(
"Beats per minute, from"))
94 .
Validator<FloatingPointValidator<double>>(
96 NumValidatorStyle::THREE_TRAILING_ZEROES
97 | NumValidatorStyle::ZERO_AS_BLANK)
99 .AddTextBox(
XXC(
"&from",
"change tempo"),
wxT(
""), 12);
101 m_pTextCtrl_ToBPM =
S.Id(ID_ToBPM)
103 .Name(
XO(
"Beats per minute, to"))
104 .
Validator<FloatingPointValidator<double>>(
106 NumValidatorStyle::THREE_TRAILING_ZEROES
107 | NumValidatorStyle::ZERO_AS_BLANK)
109 .AddTextBox(
XXC(
"&to",
"change tempo"),
wxT(
""), 12);
111 S.EndHorizontalLay();
116 S.StartStatic(
XO(
"Length (seconds)"));
118 S.StartHorizontalLay(wxALIGN_CENTER);
120 m_pTextCtrl_FromLength =
S.Id(ID_FromLength)
123 .Validator<FloatingPointValidator<double>>(
124 precision, &m_FromLength,
125 NumValidatorStyle::TWO_TRAILING_ZEROES)
127 .AddTextBox(
XXC(
"from",
"change tempo"),
wxT(
""), 12);
129 .Validator<FloatingPointValidator<double>>(
130 2, &m_ToLength, NumValidatorStyle::TWO_TRAILING_ZEROES,
132 RoundValue( precision,
133 (m_FromLength * 100.0) / (100.0 + Percentage.max) ),
134 RoundValue( precision,
135 (m_FromLength * 100.0) / (100.0 + Percentage.min) ) )
137 .AddTextBox(
XXC(
"t&o",
"change tempo"),
wxT(
""), 12);
139 S.EndHorizontalLay();
144 S.StartMultiColumn(2);
146 mUseSBSMSCheckBox =
S.Validator<wxGenericValidator>(&mUseSBSMS)
147 .AddCheckBox(
XXO(
"&Use high quality stretching (slow)"),
159bool EffectChangeTempo::TransferDataToWindow(
const EffectSettings &)
162 m_FromLength = mT1 - mT0;
164 m_bLoopDetect =
true;
166 if (!mUIParent->TransferDataToWindow())
172 Update_Slider_PercentChange();
174 Update_Text_ToLength();
176 m_bLoopDetect =
false;
179 m_pTextCtrl_ToLength->SetName(
180 wxString::Format(
_(
"Length in seconds from %s, to"),
181 m_pTextCtrl_FromLength->GetValue() ) );
188 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
198void EffectChangeTempo::OnText_PercentChange(wxCommandEvent & WXUNUSED(evt))
203 m_pTextCtrl_PercentChange->GetValidator()->TransferFromWindow();
205 m_bLoopDetect =
true;
206 Update_Slider_PercentChange();
208 Update_Text_ToLength();
209 m_bLoopDetect =
false;
212void EffectChangeTempo::OnSlider_PercentChange(wxCommandEvent & WXUNUSED(evt))
217 m_PercentChange = (double)(m_pSlider_PercentChange->GetValue());
219 if (m_PercentChange > 0.0)
220 m_PercentChange = pow(m_PercentChange,
kSliderWarp);
222 m_bLoopDetect =
true;
223 Update_Text_PercentChange();
225 Update_Text_ToLength();
226 m_bLoopDetect =
false;
229void EffectChangeTempo::OnText_FromBPM(wxCommandEvent & WXUNUSED(evt))
234 m_pTextCtrl_FromBPM->GetValidator()->TransferFromWindow();
236 m_bLoopDetect =
true;
240 m_bLoopDetect =
false;
243void EffectChangeTempo::OnText_ToBPM(wxCommandEvent & WXUNUSED(evt))
248 m_pTextCtrl_ToBPM->GetValidator()->TransferFromWindow();
250 m_bLoopDetect =
true;
253 if (m_FromBPM != 0.0 && m_ToBPM != 0.0)
255 m_PercentChange = ((m_ToBPM * 100.0) / m_FromBPM) - 100.0;
257 Update_Text_PercentChange();
258 Update_Slider_PercentChange();
260 Update_Text_ToLength();
263 m_bLoopDetect =
false;
266void EffectChangeTempo::OnText_ToLength(wxCommandEvent & WXUNUSED(evt))
271 m_pTextCtrl_ToLength->GetValidator()->TransferFromWindow();
273 if (m_ToLength != 0.0)
275 m_PercentChange = ((m_FromLength * 100.0) / m_ToLength) - 100.0;
278 m_bLoopDetect =
true;
280 Update_Text_PercentChange();
281 Update_Slider_PercentChange();
285 m_bLoopDetect =
false;
290void EffectChangeTempo::Update_Text_PercentChange()
292 m_pTextCtrl_PercentChange->GetValidator()->TransferToWindow();
295void EffectChangeTempo::Update_Slider_PercentChange()
297 double unwarped = m_PercentChange;
300 unwarped = pow(m_PercentChange, (1.0 /
kSliderWarp));
303 m_pSlider_PercentChange->SetValue((
int)(unwarped + 0.5));
306void EffectChangeTempo::Update_Text_ToBPM()
309 m_ToBPM = (((m_FromBPM * (100.0 + m_PercentChange)) / 100.0));
310 m_pTextCtrl_ToBPM->GetValidator()->TransferToWindow();
313void EffectChangeTempo::Update_Text_ToLength()
316 m_ToLength = (m_FromLength * 100.0) / (100.0 + m_PercentChange);
317 m_pTextCtrl_ToLength->GetValidator()->TransferToWindow();
static const double kSliderMax
static const double kSliderWarp
XXO("&Cut/Copy/Paste Toolbar")
A SoundTouchBase provides speeding up or slowing down tempo without changing pitch.
Performs effect computation.
Hold values to send to effect output meters.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
A Validator is an object which checks whether a wxVariant satisfies a certain criterion....
BuiltinCommandsModule::Registration< CompareAudioCommand > reg
Externalized state of a plug-in.