comparison framework/Align.h @ 683:0736beb8b852 by-id

Toward updating Document for ModelById
author Chris Cannam
date Wed, 03 Jul 2019 13:01:26 +0100
parents 4d26b66931f8
children e0b0f3e163ca
comparison
equal deleted inserted replaced
682:161063152ddd 683:0736beb8b852
2 2
3 /* 3 /*
4 Sonic Visualiser 4 Sonic Visualiser
5 An audio file viewer and annotation editor. 5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London. 6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam and QMUL.
8 7
9 This program is free software; you can redistribute it and/or 8 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as 9 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the 10 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 11 License, or (at your option) any later version. See the file
20 #include <QObject> 19 #include <QObject>
21 #include <QProcess> 20 #include <QProcess>
22 #include <QMutex> 21 #include <QMutex>
23 #include <set> 22 #include <set>
24 23
25 class Model; 24 #include "data/model/Model.h"
25
26 class AlignmentModel; 26 class AlignmentModel;
27 class SparseTimeValueModel; 27 class SparseTimeValueModel;
28 class AggregateWaveModel; 28 class AggregateWaveModel;
29 class Document; 29 class Document;
30 30
61 * long as the alignment takes. The usual expectation is that the 61 * long as the alignment takes. The usual expectation is that the
62 * Align object will simply share the process or document 62 * Align object will simply share the process or document
63 * lifespan. 63 * lifespan.
64 */ 64 */
65 bool alignModel(Document *doc, 65 bool alignModel(Document *doc,
66 Model *reference, 66 ModelId reference,
67 Model *toAlign, 67 ModelId toAlign,
68 QString &error); 68 QString &error);
69 69
70 bool alignModelViaTransform(Document *doc, 70 bool alignModelViaTransform(Document *doc,
71 Model *reference, 71 ModelId reference,
72 Model *toAlign, 72 ModelId toAlign,
73 QString &error); 73 QString &error);
74 74
75 bool alignModelViaProgram(Document *doc, 75 bool alignModelViaProgram(Document *doc,
76 Model *reference, 76 ModelId reference,
77 Model *toAlign, 77 ModelId toAlign,
78 QString program, 78 QString program,
79 QString &error); 79 QString &error);
80 80
81 /** 81 /**
82 * Return true if the alignment facility is available (relevant 82 * Return true if the alignment facility is available (relevant
88 /** 88 /**
89 * Emitted when an alignment is successfully completed. The 89 * Emitted when an alignment is successfully completed. The
90 * reference and other models can be queried from the alignment 90 * reference and other models can be queried from the alignment
91 * model. 91 * model.
92 */ 92 */
93 void alignmentComplete(AlignmentModel *alignment); 93 void alignmentComplete(ModelId alignmentModel); // an AlignmentModel
94 94
95 private slots: 95 private slots:
96 void alignmentCompletionChanged(); 96 void alignmentCompletionChanged();
97 void tuningDifferenceCompletionChanged(); 97 void tuningDifferenceCompletionChanged();
98 void alignmentProgramFinished(int, QProcess::ExitStatus); 98 void alignmentProgramFinished(int, QProcess::ExitStatus);
99 void aggregateModelAboutToBeDeleted();
100 99
101 private: 100 private:
102 static QString getAlignmentTransformName(); 101 static QString getAlignmentTransformName();
103 static QString getTuningDifferenceTransformName(); 102 static QString getTuningDifferenceTransformName();
104 103
105 bool beginTransformDrivenAlignment(AggregateWaveModel *, 104 bool beginTransformDrivenAlignment(ModelId, // an AggregateWaveModel
106 AlignmentModel *, 105 ModelId, // an AlignmentModel
107 float tuningFrequency = 0.f); 106 float tuningFrequency = 0.f);
108 107
109 QMutex m_mutex; 108 QMutex m_mutex;
110 109
111 struct TuningDiffRec { 110 struct TuningDiffRec {
112 AggregateWaveModel *input; 111 ModelId input; // an AggregateWaveModel
113 AlignmentModel *alignment; 112 ModelId alignment; // an AlignmentModel
114 SparseTimeValueModel *preparatory; 113 ModelId preparatory; // a SparseTimeValueModel
115 }; 114 };
116 115
117 // tuning-difference output model -> data needed for subsequent alignment 116 // tuning-difference output model (a SparseTimeValueModel) -> data
118 std::map<SparseTimeValueModel *, TuningDiffRec> m_pendingTuningDiffs; 117 // needed for subsequent alignment
118 std::map<ModelId, TuningDiffRec> m_pendingTuningDiffs;
119 119
120 // external alignment subprocess -> model into which to stuff the results 120 // external alignment subprocess -> model into which to stuff the
121 std::map<QProcess *, AlignmentModel *> m_pendingProcesses; 121 // results (an AlignmentModel)
122 std::map<QProcess *, ModelId> m_pendingProcesses;
122 }; 123 };
123 124
124 #endif 125 #endif
125 126