22#ifdef EXPERIMENTAL_SCOREALIGN
35#include <wx/stattext.h>
36#include <wx/statusbr.h>
43#include "audioreader.h"
44#include "scorealign.h"
45#include "scorealign-glue.h"
47static std::unique_ptr<ScoreAlignDialog> gScoreAlignDialog{};
51ScoreAlignDialog::ScoreAlignDialog(ScoreAlignParams &
params)
53 wxDefaultPosition, wxDefaultSize,
54 wxDEFAULT_DIALOG_STYLE)
56 gScoreAlignDialog.reset(
this);
58 gPrefs->
Read(
wxT(
"/Tracks/Synchronize/FramePeriod"), &p.mFramePeriod,
59 float(SA_DFT_FRAME_PERIOD));
60 gPrefs->
Read(
wxT(
"/Tracks/Synchronize/WindowSize"), &p.mWindowSize,
61 float(SA_DFT_WINDOW_SIZE));
63 &p.mSilenceThreshold,
float(SA_DFT_SILENCE_THRESHOLD));
65 &p.mForceFinalAlignment,
float(SA_DFT_FORCE_FINAL_ALIGNMENT));
67 &p.mIgnoreSilence,
float(SA_DFT_IGNORE_SILENCE));
68 gPrefs->
Read(
wxT(
"/Tracks/Synchronize/PresmoothTime"), &p.mPresmoothTime,
69 float(SA_DFT_PRESMOOTH_TIME));
70 gPrefs->
Read(
wxT(
"/Tracks/Synchronize/LineTime"), &p.mLineTime,
71 float(SA_DFT_LINE_TIME));
72 gPrefs->
Read(
wxT(
"/Tracks/Synchronize/SmoothTime"), &p.mSmoothTime,
73 float(SA_DFT_SMOOTH_TIME));
85 S.StartVerticalLay(
true);
86 S.StartStatic(
XO(
"Align MIDI to Audio"));
87 S.StartMultiColumn(3, wxEXPAND | wxALIGN_CENTER_VERTICAL);
90 mFramePeriodLabel =
S.AddVariableText(
91 XO(
"Frame Period:"),
true, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
92 mFramePeriodSlider =
S.Id(ID_FRAMEPERIOD)
93 .Name(
XO(
"Frame Period"))
94 .Style(wxSL_HORIZONTAL)
95 .MinSize( { 300, -1 } )
97 (int) (p.mFramePeriod * 100 + 0.5), 50, 5);
98 mFramePeriodText =
S.AddVariableText(
99 SA_DFT_FRAME_PERIOD_TEXT,
true, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
101 mWindowSizeLabel =
S.AddVariableText(
102 XO(
"Window Size:"),
true, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
103 mWindowSizeSlider =
S.Id(ID_WINDOWSIZE)
104 .Name(
XO(
"Window Size"))
105 .Style(wxSL_HORIZONTAL)
107 (int) (p.mWindowSize * 100 + 0.5), 100, 5);
108 mWindowSizeText =
S.AddVariableText(
109 SA_DFT_WINDOW_SIZE_TEXT,
true, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
111 mForceFinalAlignmentCheckBox =
S.Id(ID_FORCEFINALALIGNMENT)
112 .Name(
XO(
"Force Final Alignment"))
114 XO(
"Force Final Alignment"),
115 p.mForceFinalAlignment);
116 mIgnoreSilenceCheckBox =
S.Id(ID_IGNORESILENCE)
117 .Name(
XO(
"Ignore Silence at Beginnings and Endings"))
119 XO(
"Ignore Silence at Beginnings and Endings"),
122 S.AddVariableText({},
true, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
124 mSilenceThresholdLabel =
S.AddVariableText(
XO(
"Silence Threshold:"),
125 true, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
126 mSilenceThresholdSlider =
S.Id(ID_SILENCETHRESHOLD)
127 .Name(
XO(
"Silence Threshold"))
128 .Style(wxSL_HORIZONTAL)
130 (int) (p.mSilenceThreshold * 1000 + 0.5), 500);
131 mSilenceThresholdText =
S.AddVariableText(
132 SA_DFT_SILENCE_THRESHOLD_TEXT,
133 true, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
135 mPresmoothLabel =
S.AddVariableText(
140 XO(
"Presmooth Time:"),
true, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
141 mPresmoothSlider =
S.Id(ID_PRESMOOTH)
146 .Name(
XO(
"Presmooth Time"))
147 .Style(wxSL_HORIZONTAL)
149 (int) (p.mPresmoothTime * 100 + 0.5), 500);
150 mPresmoothText =
S.AddVariableText(
151 SA_DFT_PRESMOOTH_TIME_TEXT,
true, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
157 mLineTimeLabel =
S.AddVariableText(
XO(
"Line Time:"),
true,
158 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
159 mLineTimeSlider =
S.Id(ID_LINETIME)
164 .Name(
XO(
"Line Time"))
165 .Style(wxSL_HORIZONTAL)
167 (int) (p.mLineTime * 100 + 0.5), 500);
168 mLineTimeText =
S.AddVariableText(
169 SA_DFT_LINE_TIME_TEXT,
true, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
175 mSmoothTimeLabel =
S.AddVariableText(
176 XO(
"Smooth Time:"),
true, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
177 mSmoothTimeSlider =
S.Id(ID_SMOOTHTIME)
182 .Name(
XO(
"Smooth Time"))
183 .Style(wxSL_HORIZONTAL)
185 (int) (p.mSmoothTime * 100 + 0.5), 500);
186 mSmoothTimeText =
S.AddVariableText(
187 SA_DFT_SMOOTH_TIME_TEXT,
true, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
192 mDefaultButton =
safenew wxButton(
this, ID_DEFAULT,
_(
"Use Defaults"));
193 mDefaultButton->SetName(
_(
"Restore Defaults"));
201 TransferDataFromWindow();
203 params.mStatus = p.mStatus = ShowModal();
205 if (p.mStatus == wxID_OK) {
207 gPrefs->
Write(
wxT(
"/Tracks/Synchronize/FramePeriod"), p.mFramePeriod);
208 gPrefs->
Write(
wxT(
"/Tracks/Synchronize/WindowSize"), p.mWindowSize);
210 p.mSilenceThreshold);
212 p.mForceFinalAlignment);
218 gPrefs->
Write(
wxT(
"/Tracks/Synchronize/SmoothTime"), p.mSmoothTime);
225ScoreAlignDialog::~ScoreAlignDialog()
240void ScoreAlignDialog::OnSlider(wxCommandEvent & event)
242 TransferDataFromWindow();
246void ScoreAlignDialog::OnDefault(wxCommandEvent & event)
248 mFramePeriodSlider->SetValue((
int) (SA_DFT_FRAME_PERIOD * 100 + 0.5));
249 mWindowSizeSlider->SetValue((
int) (SA_DFT_WINDOW_SIZE * 100 + 0.5));
250 mSilenceThresholdSlider->SetValue(
251 (
int) (SA_DFT_SILENCE_THRESHOLD * 1000 + 0.5));
252 mForceFinalAlignmentCheckBox->SetValue(SA_DFT_FORCE_FINAL_ALIGNMENT);
253 mIgnoreSilenceCheckBox->SetValue(SA_DFT_IGNORE_SILENCE);
254 mPresmoothSlider->SetValue((
int) (SA_DFT_PRESMOOTH_TIME * 100 + 0.5));
255 mLineTimeSlider->SetValue((
int) (SA_DFT_LINE_TIME * 100 + 0.5));
256 mSmoothTimeSlider->SetValue((
int) (SA_DFT_SMOOTH_TIME * 100 + 0.5));
258 TransferDataFromWindow();
262bool ScoreAlignDialog::TransferDataFromWindow()
264 p.mFramePeriod = (double) mFramePeriodSlider->GetValue() / 100.0;
265 p.mWindowSize = (double) mWindowSizeSlider->GetValue() / 100.0;
266 p.mSilenceThreshold = (double) mSilenceThresholdSlider->GetValue() / 1000.0;
267 p.mForceFinalAlignment = (double) mForceFinalAlignmentCheckBox->GetValue();
268 p.mIgnoreSilence = (double) mIgnoreSilenceCheckBox->GetValue();
269 p.mPresmoothTime = (double) mPresmoothSlider->GetValue() / 100.0;
270 p.mLineTime = (double) mLineTimeSlider->GetValue() / 100.0;
271 p.mSmoothTime = (double) mSmoothTimeSlider->GetValue() / 100.0;
273 mFramePeriodText->SetLabel(wxString::Format(
_(
"%.2f secs"),
275 mWindowSizeText->SetLabel(wxString::Format(
_(
"%.2f secs"), p.mWindowSize));
276 mSilenceThresholdText->SetLabel(wxString::Format(
_(
"%.3f"),
277 p.mSilenceThreshold));
278 mPresmoothText->SetLabel(p.mPresmoothTime > 0 ?
279 wxString::Format(
_(
"%.2f secs"),
280 p.mPresmoothTime) :
wxT(
"(off)"));
281 mLineTimeText->SetLabel(p.mLineTime > 0 ?
282 wxString::Format(
_(
"%.2f secs"), p.mLineTime) :
284 mSmoothTimeText->SetLabel(wxString::Format(
_(
"%.2f secs"), p.mSmoothTime));
289void CloseScoreAlignDialog()
291 gScoreAlignDialog.reset();
298 EVT_BUTTON(ID_DEFAULT, ScoreAlignDialog::OnDefault)
299 EVT_SLIDER(ID_FRAMEPERIOD, ScoreAlignDialog::OnSlider)
300 EVT_SLIDER(ID_WINDOWSIZE, ScoreAlignDialog::OnSlider)
301 EVT_SLIDER(ID_SILENCETHRESHOLD, ScoreAlignDialog::OnSlider)
302 EVT_CHECKBOX(ID_FORCEFINALALIGNMENT, ScoreAlignDialog::OnSlider)
303 EVT_CHECKBOX(ID_IGNORESILENCE, ScoreAlignDialog::OnSlider)
304 EVT_SLIDER(ID_PRESMOOTH, ScoreAlignDialog::OnSlider)
305 EVT_SLIDER(ID_LINETIME, ScoreAlignDialog::OnSlider)
306 EVT_SLIDER(ID_SMOOTHTIME, ScoreAlignDialog::OnSlider)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
EffectDistortionSettings params
audacity::BasicSettings * gPrefs
ScoreAlignDialog is \TODO.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0