comparison framework/Align.cpp @ 515:51befd6165a3 alignment-simple

Merge in from SV 3.0-integration branches
author Chris Cannam
date Wed, 02 Mar 2016 17:25:27 +0000
parents adfb2948fabf
children b23bebfdfaba
comparison
equal deleted inserted replaced
459:74d575708e06 515:51befd6165a3
14 */ 14 */
15 15
16 #include "Align.h" 16 #include "Align.h"
17 17
18 #include "data/model/WaveFileModel.h" 18 #include "data/model/WaveFileModel.h"
19 #include "data/model/ReadOnlyWaveFileModel.h"
19 #include "data/model/AggregateWaveModel.h" 20 #include "data/model/AggregateWaveModel.h"
20 #include "data/model/RangeSummarisableTimeValueModel.h" 21 #include "data/model/RangeSummarisableTimeValueModel.h"
21 #include "data/model/SparseTimeValueModel.h" 22 #include "data/model/SparseTimeValueModel.h"
22 #include "data/model/AlignmentModel.h" 23 #include "data/model/AlignmentModel.h"
23 24
171 Align::alignModelViaProgram(Model *ref, Model *other, QString program) 172 Align::alignModelViaProgram(Model *ref, Model *other, QString program)
172 { 173 {
173 WaveFileModel *reference = qobject_cast<WaveFileModel *>(ref); 174 WaveFileModel *reference = qobject_cast<WaveFileModel *>(ref);
174 WaveFileModel *rm = qobject_cast<WaveFileModel *>(other); 175 WaveFileModel *rm = qobject_cast<WaveFileModel *>(other);
175 176
176 if (!rm) return false; // but this should have been tested already 177 if (!reference || !rm) {
178 return false; // but this should have been tested already
179 }
177 180
178 while (!reference->isReady(0) || !rm->isReady(0)) { 181 while (!reference->isReady(0) || !rm->isReady(0)) {
179 qApp->processEvents(); 182 qApp->processEvents();
180 } 183 }
181 184
182 // Run an external program, passing to it paths to the main 185 // Run an external program, passing to it paths to the main
183 // model's audio file and the new model's audio file. It returns 186 // model's audio file and the new model's audio file. It returns
184 // the path in CSV form through stdout. 187 // the path in CSV form through stdout.
185 188
186 QString refPath = reference->getLocalFilename(); 189 ReadOnlyWaveFileModel *roref = qobject_cast<ReadOnlyWaveFileModel *>(reference);
187 QString otherPath = rm->getLocalFilename(); 190 ReadOnlyWaveFileModel *rorm = qobject_cast<ReadOnlyWaveFileModel *>(rm);
191 if (!roref || !rorm) {
192 cerr << "ERROR: Align::alignModelViaProgram: Can't align non-read-only models via program (no local filename available)" << endl;
193 return false;
194 }
195
196 QString refPath = roref->getLocalFilename();
197 QString otherPath = rorm->getLocalFilename();
188 198
189 if (refPath == "" || otherPath == "") { 199 if (refPath == "" || otherPath == "") {
190 m_error = "Failed to find local filepath for wave-file model"; 200 m_error = "Failed to find local filepath for wave-file model";
191 return false; 201 return false;
192 } 202 }