Mercurial > hg > tony
comparison src/Analyser.cpp @ 396:f76adae8fe5e
(Very slowly) perform local reanalysis when dragging a note up or down
author | Chris Cannam |
---|---|
date | Tue, 11 Nov 2014 14:11:07 +0000 |
parents | 56109ef020b4 |
children | 6f7133733032 |
comparison
equal
deleted
inserted
replaced
395:a3e47dea8d7e | 396:f76adae8fe5e |
---|---|
406 qobject_cast<TimeValueLayer *>(m_layers[PitchTrack]); | 406 qobject_cast<TimeValueLayer *>(m_layers[PitchTrack]); |
407 if (pitchLayer) { | 407 if (pitchLayer) { |
408 pitchLayer->setBaseColour(cdb->getColourIndex(tr("Black"))); | 408 pitchLayer->setBaseColour(cdb->getColourIndex(tr("Black"))); |
409 PlayParameters *params = pitchLayer->getPlayParameters(); | 409 PlayParameters *params = pitchLayer->getPlayParameters(); |
410 if (params) params->setPlayPan(1); | 410 if (params) params->setPlayPan(1); |
411 } | 411 connect(pitchLayer, SIGNAL(modelCompletionChanged()), |
412 connect(pitchLayer, SIGNAL(modelCompletionChanged()), | 412 this, SLOT(layerCompletionChanged())); |
413 this, SLOT(layerCompletionChanged())); | 413 } |
414 | 414 |
415 FlexiNoteLayer *flexiNoteLayer = | 415 FlexiNoteLayer *flexiNoteLayer = |
416 qobject_cast<FlexiNoteLayer *>(m_layers[Notes]); | 416 qobject_cast<FlexiNoteLayer *>(m_layers[Notes]); |
417 if (flexiNoteLayer) { | 417 if (flexiNoteLayer) { |
418 flexiNoteLayer->setBaseColour(cdb->getColourIndex(tr("Bright Blue"))); | 418 flexiNoteLayer->setBaseColour(cdb->getColourIndex(tr("Bright Blue"))); |
419 PlayParameters *params = flexiNoteLayer->getPlayParameters(); | 419 PlayParameters *params = flexiNoteLayer->getPlayParameters(); |
420 if (params) params->setPlayPan(1); | 420 if (params) params->setPlayPan(1); |
421 } | 421 connect(flexiNoteLayer, SIGNAL(modelCompletionChanged()), |
422 connect(flexiNoteLayer, SIGNAL(modelCompletionChanged()), | 422 this, SLOT(layerCompletionChanged())); |
423 this, SLOT(layerCompletionChanged())); | 423 connect(flexiNoteLayer, SIGNAL(reAnalyseRegion(int, int, float, float)), |
424 this, SLOT(reAnalyseRegion(int, int, float, float))); | |
425 } | |
424 | 426 |
425 return ""; | 427 return ""; |
428 } | |
429 | |
430 void | |
431 Analyser::reAnalyseRegion(int frame0, int frame1, float freq0, float freq1) | |
432 { | |
433 cerr << "Analyser::reAnalyseRegion(" << frame0 << ", " << frame1 | |
434 << ", " << freq0 << ", " << freq1 << ")" << endl; | |
435 showPitchCandidates(true); | |
436 (void)reAnalyseSelection(Selection(frame0, frame1), | |
437 FrequencyRange(freq0, freq1)); | |
426 } | 438 } |
427 | 439 |
428 QString | 440 QString |
429 Analyser::reAnalyseSelection(Selection sel, FrequencyRange range) | 441 Analyser::reAnalyseSelection(Selection sel, FrequencyRange range) |
430 { | 442 { |
431 QMutexLocker locker(&m_asyncMutex); | 443 QMutexLocker locker(&m_asyncMutex); |
432 | 444 |
433 if (sel == m_reAnalysingSelection || sel.isEmpty()) return ""; | 445 if (!m_reAnalysingSelection.isEmpty()) { |
446 if (sel == m_reAnalysingSelection && range == m_reAnalysingRange) { | |
447 cerr << "selection & range are same as current analysis, ignoring" << endl; | |
448 return ""; | |
449 } | |
450 } | |
451 | |
452 if (sel.isEmpty()) return ""; | |
434 | 453 |
435 if (m_currentAsyncHandle) { | 454 if (m_currentAsyncHandle) { |
436 m_document->cancelAsyncLayerCreation(m_currentAsyncHandle); | 455 m_document->cancelAsyncLayerCreation(m_currentAsyncHandle); |
437 } | 456 } |
438 | 457 |
442 discardPitchCandidates(); | 461 discardPitchCandidates(); |
443 CommandHistory::getInstance()->endCompoundOperation(); | 462 CommandHistory::getInstance()->endCompoundOperation(); |
444 } | 463 } |
445 | 464 |
446 m_reAnalysingSelection = sel; | 465 m_reAnalysingSelection = sel; |
466 m_reAnalysingRange = range; | |
447 | 467 |
448 m_preAnalysis = Clipboard(); | 468 m_preAnalysis = Clipboard(); |
449 Layer *myLayer = m_layers[PitchTrack]; | 469 Layer *myLayer = m_layers[PitchTrack]; |
450 if (myLayer) { | 470 if (myLayer) { |
451 myLayer->copy(m_pane, sel, m_preAnalysis); | 471 myLayer->copy(m_pane, sel, m_preAnalysis); |