comparison framework/Align.cpp @ 422:33fae747db7e alignment_view

User preference for alignment program
author Chris Cannam
date Thu, 20 Nov 2014 14:08:01 +0000
parents 662aef012679
children f32a64149602
comparison
equal deleted inserted replaced
420:662aef012679 422:33fae747db7e
26 #include "transform/TransformFactory.h" 26 #include "transform/TransformFactory.h"
27 #include "transform/ModelTransformerFactory.h" 27 #include "transform/ModelTransformerFactory.h"
28 #include "transform/FeatureExtractionModelTransformer.h" 28 #include "transform/FeatureExtractionModelTransformer.h"
29 29
30 #include <QProcess> 30 #include <QProcess>
31 #include <QSettings>
32
33 bool
34 Align::alignModel(Model *ref, Model *other)
35 {
36 QSettings settings;
37 settings.beginGroup("Preferences");
38 bool useProgram = settings.value("use-external-alignment", false).toBool();
39 QString program = settings.value("external-alignment-program", "").toString();
40 settings.endGroup();
41
42 if (useProgram && (program != "")) {
43 return alignModelViaProgram(ref, other, program);
44 } else {
45 return alignModelViaTransform(ref, other);
46 }
47 }
31 48
32 bool 49 bool
33 Align::alignModelViaTransform(Model *ref, Model *other) 50 Align::alignModelViaTransform(Model *ref, Model *other)
34 { 51 {
35 RangeSummarisableTimeValueModel *reference = qobject_cast 52 RangeSummarisableTimeValueModel *reference = qobject_cast
113 130
114 return true; 131 return true;
115 } 132 }
116 133
117 bool 134 bool
118 Align::alignModelViaProgram(Model *ref, Model *other) 135 Align::alignModelViaProgram(Model *ref, Model *other, QString program)
119 { 136 {
120 WaveFileModel *reference = qobject_cast<WaveFileModel *>(ref); 137 WaveFileModel *reference = qobject_cast<WaveFileModel *>(ref);
121 WaveFileModel *rm = qobject_cast<WaveFileModel *>(other); 138 WaveFileModel *rm = qobject_cast<WaveFileModel *>(other);
122 139
123 if (!rm) return false; // but this should have been tested already 140 if (!rm) return false; // but this should have been tested already
133 m_error = "Failed to find local filepath for wave-file model"; 150 m_error = "Failed to find local filepath for wave-file model";
134 return false; 151 return false;
135 } 152 }
136 153
137 QProcess process; 154 QProcess process;
138 QString program = "/home/cannam/code/tido-audio/aligner/vect-align.sh";
139 QStringList args; 155 QStringList args;
140 args << refPath << otherPath; 156 args << refPath << otherPath;
141 process.start(program, args); 157 process.start(program, args);
142 158
143 process.waitForFinished(60000); //!!! nb timeout, but we can do better than blocking anyway 159 process.waitForFinished(60000); //!!! nb timeout, but we can do better than blocking anyway