comparison align/TransformAligner.cpp @ 769:a316cb6fed81 pitch-align

Fixes to notification and completion in aligners
author Chris Cannam
date Thu, 28 May 2020 17:04:36 +0100
parents 1b1960009be6
children
comparison
equal deleted inserted replaced
768:1b1960009be6 769:a316cb6fed81
242 << m_tuningDiffOutputModel << ", completion = " << completion 242 << m_tuningDiffOutputModel << ", completion = " << completion
243 << ", done = " << done << endl; 243 << ", done = " << done << endl;
244 244
245 if (!done) { 245 if (!done) {
246 // This will be the completion the alignment model reports, 246 // This will be the completion the alignment model reports,
247 // before the alignment actually begins. It goes up from 0 to 247 // before the alignment actually begins
248 // 99 (not 100!) and then back to 0 again when we start 248 alignmentModel->setCompletion(completion / 2);
249 // calculating the actual path in the following phase
250 int clamped = (completion == 100 ? 99 : completion);
251 alignmentModel->setCompletion(clamped);
252 return; 249 return;
253 } 250 }
254 251
255 m_tuningFrequency = 440.f; 252 m_tuningFrequency = 440.f;
256 253
342 } 339 }
343 340
344 pathOutputModel->setCompletion(0); 341 pathOutputModel->setCompletion(0);
345 alignmentModel->setPathFrom(m_pathOutputModel); 342 alignmentModel->setPathFrom(m_pathOutputModel);
346 343
347 connect(alignmentModel.get(), SIGNAL(completionChanged(ModelId)), 344 connect(pathOutputModel.get(), SIGNAL(completionChanged(ModelId)),
348 this, SLOT(alignmentCompletionChanged(ModelId))); 345 this, SLOT(alignmentCompletionChanged(ModelId)));
349 346
350 return true; 347 return true;
351 } 348 }
352 349
353 void 350 void
354 TransformAligner::alignmentCompletionChanged(ModelId alignmentModelId) 351 TransformAligner::alignmentCompletionChanged(ModelId pathOutputModelId)
355 { 352 {
356 if (alignmentModelId != m_alignmentModel) { 353 if (pathOutputModelId != m_pathOutputModel) {
357 SVCERR << "WARNING: TransformAligner::alignmentCompletionChanged: Model " 354 SVCERR << "WARNING: TransformAligner::alignmentCompletionChanged: Model "
358 << alignmentModelId 355 << pathOutputModelId
359 << " is not ours! (ours is " 356 << " is not ours! (ours is "
360 << m_alignmentModel << ")" << endl; 357 << m_pathOutputModel << ")" << endl;
361 return; 358 return;
362 } 359 }
363 360
364 auto alignmentModel = ModelById::getAs<AlignmentModel>(m_alignmentModel); 361 auto pathOutputModel =
365 362 ModelById::getAs<SparseTimeValueModel>(m_pathOutputModel);
366 if (alignmentModel && alignmentModel->isReady()) { 363 if (!pathOutputModel) {
367 364 SVCERR << "WARNING: TransformAligner::alignmentCompletionChanged: Path output model "
365 << m_pathOutputModel << " no longer exists" << endl;
366 return;
367 }
368
369 int completion = 0;
370 bool done = pathOutputModel->isReady(&completion);
371
372 if (m_withTuningDifference) {
373 if (auto alignmentModel =
374 ModelById::getAs<AlignmentModel>(m_alignmentModel)) {
375 if (!done) {
376 int adjustedCompletion = 50 + completion/2;
377 if (adjustedCompletion > 99) {
378 adjustedCompletion = 99;
379 }
380 alignmentModel->setCompletion(adjustedCompletion);
381 } else {
382 alignmentModel->setCompletion(100);
383 }
384 }
385 }
386
387 if (done) {
368 m_incomplete = false; 388 m_incomplete = false;
369 389
370 ModelById::release(m_pathOutputModel); 390 ModelById::release(m_pathOutputModel);
371 m_pathOutputModel = {}; 391 m_pathOutputModel = {};
372 392
373 disconnect(alignmentModel.get(),
374 SIGNAL(completionChanged(ModelId)),
375 this, SLOT(alignmentCompletionChanged(ModelId)));
376 emit complete(m_alignmentModel); 393 emit complete(m_alignmentModel);
377 } 394 }
378 } 395 }