Mercurial > hg > svapp
comparison framework/Align.cpp @ 649:284cb118368e single-point
Further updates for new API - but we still need some more support in the API itself
author | Chris Cannam |
---|---|
date | Tue, 19 Mar 2019 13:06:58 +0000 |
parents | e2715204feaa |
children | ed9cb577eb7c |
comparison
equal
deleted
inserted
replaced
648:eec0c50bb44f | 649:284cb118368e |
---|---|
134 | 134 |
135 SparseTimeValueModel *path = dynamic_cast<SparseTimeValueModel *> | 135 SparseTimeValueModel *path = dynamic_cast<SparseTimeValueModel *> |
136 (transformOutput); | 136 (transformOutput); |
137 | 137 |
138 if (!path) { | 138 if (!path) { |
139 cerr << "Align::alignModel: ERROR: Failed to create alignment path (no MATCH plugin?)" << endl; | 139 SVCERR << "Align::alignModel: ERROR: Failed to create alignment path (no MATCH plugin?)" << endl; |
140 delete transformOutput; | 140 delete transformOutput; |
141 delete aggregateModel; | 141 delete aggregateModel; |
142 m_error = message; | 142 m_error = message; |
143 return false; | 143 return false; |
144 } | 144 } |
187 // the path in CSV form through stdout. | 187 // the path in CSV form through stdout. |
188 | 188 |
189 ReadOnlyWaveFileModel *roref = qobject_cast<ReadOnlyWaveFileModel *>(reference); | 189 ReadOnlyWaveFileModel *roref = qobject_cast<ReadOnlyWaveFileModel *>(reference); |
190 ReadOnlyWaveFileModel *rorm = qobject_cast<ReadOnlyWaveFileModel *>(rm); | 190 ReadOnlyWaveFileModel *rorm = qobject_cast<ReadOnlyWaveFileModel *>(rm); |
191 if (!roref || !rorm) { | 191 if (!roref || !rorm) { |
192 cerr << "ERROR: Align::alignModelViaProgram: Can't align non-read-only models via program (no local filename available)" << endl; | 192 SVCERR << "ERROR: Align::alignModelViaProgram: Can't align non-read-only models via program (no local filename available)" << endl; |
193 return false; | 193 return false; |
194 } | 194 } |
195 | 195 |
196 QString refPath = roref->getLocalFilename(); | 196 QString refPath = roref->getLocalFilename(); |
197 QString otherPath = rorm->getLocalFilename(); | 197 QString otherPath = rorm->getLocalFilename(); |
217 process->start(program, args); | 217 process->start(program, args); |
218 | 218 |
219 bool success = process->waitForStarted(); | 219 bool success = process->waitForStarted(); |
220 | 220 |
221 if (!success) { | 221 if (!success) { |
222 cerr << "ERROR: Align::alignModelViaProgram: Program did not start" | 222 SVCERR << "ERROR: Align::alignModelViaProgram: Program did not start" |
223 << endl; | 223 << endl; |
224 m_error = "Alignment program could not be started"; | 224 m_error = "Alignment program could not be started"; |
225 m_processModels.erase(process); | 225 m_processModels.erase(process); |
226 rm->setAlignment(nullptr); // deletes alignmentModel as well | 226 rm->setAlignment(nullptr); // deletes alignmentModel as well |
227 delete process; | 227 delete process; |
228 } | 228 } |
231 } | 231 } |
232 | 232 |
233 void | 233 void |
234 Align::alignmentProgramFinished(int exitCode, QProcess::ExitStatus status) | 234 Align::alignmentProgramFinished(int exitCode, QProcess::ExitStatus status) |
235 { | 235 { |
236 cerr << "Align::alignmentProgramFinished" << endl; | 236 SVCERR << "Align::alignmentProgramFinished" << endl; |
237 | 237 |
238 QProcess *process = qobject_cast<QProcess *>(sender()); | 238 QProcess *process = qobject_cast<QProcess *>(sender()); |
239 | 239 |
240 if (m_processModels.find(process) == m_processModels.end()) { | 240 if (m_processModels.find(process) == m_processModels.end()) { |
241 cerr << "ERROR: Align::alignmentProgramFinished: Process " << process | 241 SVCERR << "ERROR: Align::alignmentProgramFinished: Process " << process |
242 << " not found in process model map!" << endl; | 242 << " not found in process model map!" << endl; |
243 return; | 243 return; |
244 } | 244 } |
245 | 245 |
246 AlignmentModel *alignmentModel = m_processModels[process]; | 246 AlignmentModel *alignmentModel = m_processModels[process]; |
247 | 247 |
263 format.setAllowQuoting(false); | 263 format.setAllowQuoting(false); |
264 format.setSeparator(','); | 264 format.setSeparator(','); |
265 | 265 |
266 CSVFileReader reader(process, format, alignmentModel->getSampleRate()); | 266 CSVFileReader reader(process, format, alignmentModel->getSampleRate()); |
267 if (!reader.isOK()) { | 267 if (!reader.isOK()) { |
268 cerr << "ERROR: Align::alignmentProgramFinished: Failed to parse output" | 268 SVCERR << "ERROR: Align::alignmentProgramFinished: Failed to parse output" |
269 << endl; | 269 << endl; |
270 m_error = QString("Failed to parse output of program: %1") | 270 m_error = QString("Failed to parse output of program: %1") |
271 .arg(reader.getError()); | 271 .arg(reader.getError()); |
272 goto done; | 272 goto done; |
273 } | 273 } |
274 | 274 |
275 Model *csvOutput = reader.load(); | 275 Model *csvOutput = reader.load(); |
276 | 276 |
277 SparseTimeValueModel *path = qobject_cast<SparseTimeValueModel *>(csvOutput); | 277 SparseTimeValueModel *path = qobject_cast<SparseTimeValueModel *>(csvOutput); |
278 if (!path) { | 278 if (!path) { |
279 cerr << "ERROR: Align::alignmentProgramFinished: Output did not convert to sparse time-value model" | 279 SVCERR << "ERROR: Align::alignmentProgramFinished: Output did not convert to sparse time-value model" |
280 << endl; | 280 << endl; |
281 m_error = QString("Output of program did not produce sparse time-value model"); | 281 m_error = QString("Output of program did not produce sparse time-value model"); |
282 goto done; | 282 goto done; |
283 } | 283 } |
284 | 284 |
285 if (path->getPoints().empty()) { | 285 if (path->isEmpty()) { |
286 cerr << "ERROR: Align::alignmentProgramFinished: Output contained no mappings" | 286 SVCERR << "ERROR: Align::alignmentProgramFinished: Output contained no mappings" |
287 << endl; | 287 << endl; |
288 m_error = QString("Output of alignment program contained no mappings"); | 288 m_error = QString("Output of alignment program contained no mappings"); |
289 goto done; | 289 goto done; |
290 } | 290 } |
291 | 291 /* |
292 cerr << "Align::alignmentProgramFinished: Setting alignment path (" | 292 SVCERR << "Align::alignmentProgramFinished: Setting alignment path (" |
293 << path->getPoints().size() << " point(s))" << endl; | 293 << path->getAllEvents().size() << " point(s))" << endl; |
294 | 294 */ |
295 alignmentModel->setPathFrom(path); | 295 alignmentModel->setPathFrom(path); |
296 | 296 |
297 emit alignmentComplete(alignmentModel); | 297 emit alignmentComplete(alignmentModel); |
298 | 298 |
299 } else { | 299 } else { |
300 cerr << "ERROR: Align::alignmentProgramFinished: Aligner program " | 300 SVCERR << "ERROR: Align::alignmentProgramFinished: Aligner program " |
301 << "failed: exit code " << exitCode << ", status " << status | 301 << "failed: exit code " << exitCode << ", status " << status |
302 << endl; | 302 << endl; |
303 m_error = "Aligner process returned non-zero exit status"; | 303 m_error = "Aligner process returned non-zero exit status"; |
304 } | 304 } |
305 | 305 |
306 done: | 306 done: |
307 m_processModels.erase(process); | 307 m_processModels.erase(process); |