Mercurial > hg > svapp
comparison framework/Align.cpp @ 428:b23db4cef02f alignment_view
Emit a signal when alignment completes
author | Chris Cannam |
---|---|
date | Fri, 21 Nov 2014 13:15:57 +0000 |
parents | 5882462fa747 |
children | adfb2948fabf |
comparison
equal
deleted
inserted
replaced
427:a67245dce0d4 | 428:b23db4cef02f |
---|---|
44 } else { | 44 } else { |
45 return alignModelViaTransform(ref, other); | 45 return alignModelViaTransform(ref, other); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 QString | |
50 Align::getAlignmentTransformName() | |
51 { | |
52 QSettings settings; | |
53 settings.beginGroup("Alignment"); | |
54 TransformId id = | |
55 settings.value("transform-id", | |
56 "vamp:match-vamp-plugin:match:path").toString(); | |
57 settings.endGroup(); | |
58 return id; | |
59 } | |
60 | |
61 bool | |
62 Align::canAlign() | |
63 { | |
64 TransformId id = getAlignmentTransformName(); | |
65 TransformFactory *factory = TransformFactory::getInstance(); | |
66 return factory->haveTransform(id); | |
67 } | |
68 | |
49 bool | 69 bool |
50 Align::alignModelViaTransform(Model *ref, Model *other) | 70 Align::alignModelViaTransform(Model *ref, Model *other) |
51 { | 71 { |
52 RangeSummarisableTimeValueModel *reference = qobject_cast | 72 RangeSummarisableTimeValueModel *reference = qobject_cast |
53 <RangeSummarisableTimeValueModel *>(ref); | 73 <RangeSummarisableTimeValueModel *>(ref); |
85 (rm, -1)); | 105 (rm, -1)); |
86 | 106 |
87 Model *aggregateModel = new AggregateWaveModel(components); | 107 Model *aggregateModel = new AggregateWaveModel(components); |
88 ModelTransformer::Input aggregate(aggregateModel); | 108 ModelTransformer::Input aggregate(aggregateModel); |
89 | 109 |
90 TransformId id = "vamp:match-vamp-plugin:match:path"; //!!! configure | 110 TransformId id = getAlignmentTransformName(); |
91 | 111 |
92 TransformFactory *tf = TransformFactory::getInstance(); | 112 TransformFactory *tf = TransformFactory::getInstance(); |
93 | 113 |
94 Transform transform = tf->getDefaultTransformFor | 114 Transform transform = tf->getDefaultTransformFor |
95 (id, aggregateModel->getSampleRate()); | 115 (id, aggregateModel->getSampleRate()); |
124 path->setCompletion(0); | 144 path->setCompletion(0); |
125 | 145 |
126 AlignmentModel *alignmentModel = new AlignmentModel | 146 AlignmentModel *alignmentModel = new AlignmentModel |
127 (reference, other, aggregateModel, path); | 147 (reference, other, aggregateModel, path); |
128 | 148 |
149 connect(alignmentModel, SIGNAL(completionChanged()), | |
150 this, SLOT(alignmentCompletionChanged())); | |
151 | |
129 rm->setAlignment(alignmentModel); | 152 rm->setAlignment(alignmentModel); |
130 | 153 |
131 return true; | 154 return true; |
155 } | |
156 | |
157 void | |
158 Align::alignmentCompletionChanged() | |
159 { | |
160 AlignmentModel *am = qobject_cast<AlignmentModel *>(sender()); | |
161 if (!am) return; | |
162 if (am->isReady()) { | |
163 disconnect(am, SIGNAL(completionChanged()), | |
164 this, SLOT(alignmentCompletionChanged())); | |
165 emit alignmentComplete(am); | |
166 } | |
132 } | 167 } |
133 | 168 |
134 bool | 169 bool |
135 Align::alignModelViaProgram(Model *ref, Model *other, QString program) | 170 Align::alignModelViaProgram(Model *ref, Model *other, QString program) |
136 { | 171 { |
242 cerr << "Align::alignmentProgramFinished: Setting alignment path (" | 277 cerr << "Align::alignmentProgramFinished: Setting alignment path (" |
243 << path->getPoints().size() << " point(s))" << endl; | 278 << path->getPoints().size() << " point(s))" << endl; |
244 | 279 |
245 alignmentModel->setPathFrom(path); | 280 alignmentModel->setPathFrom(path); |
246 | 281 |
282 emit alignmentComplete(alignmentModel); | |
283 | |
247 } else { | 284 } else { |
248 cerr << "ERROR: Align::alignmentProgramFinished: Aligner program " | 285 cerr << "ERROR: Align::alignmentProgramFinished: Aligner program " |
249 << "failed: exit code " << exitCode << ", status " << status | 286 << "failed: exit code " << exitCode << ", status " << status |
250 << endl; | 287 << endl; |
251 m_error = "Aligner process returned non-zero exit status"; | 288 m_error = "Aligner process returned non-zero exit status"; |