Mercurial > hg > svapp
diff framework/Align.h @ 670:0960e27c3232 tuning-difference
Experiment with optionally taking tuning difference into account for alignment
author | Chris Cannam |
---|---|
date | Wed, 15 May 2019 17:52:22 +0100 |
parents | 06db8f3ceb95 |
children | b6cafe05017d |
line wrap: on
line diff
--- a/framework/Align.h Tue May 14 14:51:09 2019 +0100 +++ b/framework/Align.h Wed May 15 17:52:22 2019 +0100 @@ -19,10 +19,13 @@ #include <QString> #include <QObject> #include <QProcess> +#include <QMutex> #include <set> class Model; class AlignmentModel; +class SparseTimeValueModel; +class AggregateWaveModel; class Document; class Align : public QObject @@ -30,7 +33,7 @@ Q_OBJECT public: - Align() : m_error("") { } + Align() { } /** * Align the "other" model to the reference, attaching an @@ -38,6 +41,17 @@ * configured in the user preferences (either a plugin transform * or an external process) and is done asynchronously. * + * The return value indicates whether the alignment procedure + * started successfully. If it is true, then an AlignmentModel has + * been constructed and attached to the toAlign model, and you can + * query that model to discover the alignment progress, eventual + * outcome, and any error message generated during alignment. (The + * AlignmentModel is subsequently owned by the toAlign model.) + * Conversely if alignModel returns false, no AlignmentModel has + * been created, and the error return argument will contain an + * error report about whatever problem prevented this from + * happening. + * * A single Align object may carry out many simultanous alignment * calls -- you do not need to create a new Align object each * time, nor to wait for an alignment to be complete before @@ -50,24 +64,25 @@ */ bool alignModel(Document *doc, Model *reference, - Model *other); // via user preference + Model *toAlign, + QString &error); bool alignModelViaTransform(Document *doc, Model *reference, - Model *other); + Model *toAlign, + QString &error); bool alignModelViaProgram(Document *doc, Model *reference, - Model *other, - QString program); + Model *toAlign, + QString program, + QString &error); /** * Return true if the alignment facility is available (relevant * plugin installed, etc). */ static bool canAlign(); - - QString getError() const { return m_error; } signals: /** @@ -79,13 +94,22 @@ private slots: void alignmentCompletionChanged(); + void tuningDifferenceCompletionChanged(); void alignmentProgramFinished(int, QProcess::ExitStatus); private: static QString getAlignmentTransformName(); - - QString m_error; - std::map<QProcess *, AlignmentModel *> m_processModels; + static QString getTuningDifferenceTransformName(); + + bool beginTransformDrivenAlignment(AggregateWaveModel *, + AlignmentModel *, + float tuningFrequency = 0.f); + + QMutex m_mutex; + std::map<QProcess *, AlignmentModel *> m_pendingProcesses; + std::map<SparseTimeValueModel *, + std::pair<AggregateWaveModel *, + AlignmentModel *>> m_pendingTuningDiffs; }; #endif