Mercurial > hg > svapp
diff framework/Document.cpp @ 679:1f18e0f64af8
Defer alignment for recorded audio until recording is complete
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2019 20:36:10 +0100 |
parents | 0d4236961c97 |
children | 0736beb8b852 |
line wrap: on
line diff
--- a/framework/Document.cpp Thu Jun 13 11:32:59 2019 +0100 +++ b/framework/Document.cpp Thu Jun 13 20:36:10 2019 +0100 @@ -43,7 +43,7 @@ using std::vector; -//#define DEBUG_DOCUMENT 1 +#define DEBUG_DOCUMENT 1 //!!! still need to handle command history, documentRestored/documentModified @@ -1121,7 +1121,7 @@ { SVDEBUG << "Document::alignModel(" << model << ", " << forceRecalculate << ") (main model is " << m_mainModel << ")" << endl; - + RangeSummarisableTimeValueModel *rm = dynamic_cast<RangeSummarisableTimeValueModel *>(model); if (!rm) { @@ -1161,6 +1161,17 @@ return; } + WritableWaveFileModel *w = + dynamic_cast<WritableWaveFileModel *>(model); + if (w && w->getWriteProportion() < 100) { + SVDEBUG << "Document::alignModel(" << model + << "): model write is not complete, deferring" + << endl; + connect(w, SIGNAL(writeCompleted()), + this, SLOT(performDeferredAlignment())); + return; + } + SVDEBUG << "Document::alignModel: aligning..." << endl; if (rm->getAlignmentReference() != nullptr) { SVDEBUG << "(Note: model " << rm << " is currently aligned to model " @@ -1176,6 +1187,19 @@ } void +Document::performDeferredAlignment() +{ + QObject *s = sender(); + Model *m = dynamic_cast<Model *>(s); + if (!m) { + SVDEBUG << "Document::performDeferredAlignment: sender is not a Model" << endl; + } else { + SVDEBUG << "Document::performDeferredAlignment: aligning..." << endl; + alignModel(m); + } +} + +void Document::alignModels() { for (const ModelRecord &rec: m_models) {