changeset 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
files framework/Align.cpp framework/Align.h framework/Document.cpp
diffstat 3 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/framework/Align.cpp	Fri Nov 14 17:24:40 2014 +0000
+++ b/framework/Align.cpp	Thu Nov 20 14:08:01 2014 +0000
@@ -28,6 +28,23 @@
 #include "transform/FeatureExtractionModelTransformer.h"
 
 #include <QProcess>
+#include <QSettings>
+
+bool
+Align::alignModel(Model *ref, Model *other)
+{
+    QSettings settings;
+    settings.beginGroup("Preferences");
+    bool useProgram = settings.value("use-external-alignment", false).toBool();
+    QString program = settings.value("external-alignment-program", "").toString();
+    settings.endGroup();
+
+    if (useProgram && (program != "")) {
+        return alignModelViaProgram(ref, other, program);
+    } else {
+        return alignModelViaTransform(ref, other);
+    }
+}
 
 bool
 Align::alignModelViaTransform(Model *ref, Model *other)
@@ -115,7 +132,7 @@
 }
 
 bool
-Align::alignModelViaProgram(Model *ref, Model *other)
+Align::alignModelViaProgram(Model *ref, Model *other, QString program)
 {
     WaveFileModel *reference = qobject_cast<WaveFileModel *>(ref);
     WaveFileModel *rm = qobject_cast<WaveFileModel *>(other);
@@ -135,7 +152,6 @@
     }
 
     QProcess process;
-    QString program = "/home/cannam/code/tido-audio/aligner/vect-align.sh";
     QStringList args;
     args << refPath << otherPath;
     process.start(program, args);
--- a/framework/Align.h	Fri Nov 14 17:24:40 2014 +0000
+++ b/framework/Align.h	Thu Nov 20 14:08:01 2014 +0000
@@ -25,8 +25,10 @@
 public:
     Align() : m_error("") { }
 
+    bool alignModel(Model *reference, Model *other); // via user preference
+    
     bool alignModelViaTransform(Model *reference, Model *other);
-    bool alignModelViaProgram(Model *reference, Model *other);
+    bool alignModelViaProgram(Model *reference, Model *other, QString program);
 
     QString getError() const { return m_error; }
 
--- a/framework/Document.cpp	Fri Nov 14 17:24:40 2014 +0000
+++ b/framework/Document.cpp	Thu Nov 20 14:08:01 2014 +0000
@@ -1087,7 +1087,7 @@
     }
 
     Align a;
-    if (!a.alignModelViaTransform(m_mainModel, rm)) {
+    if (!a.alignModel(m_mainModel, rm)) {
         cerr << "Alignment failed: " << a.getError() << endl;
         emit alignmentFailed(a.getError());
     }