diff src/MatchVampPlugin.cpp @ 156:d6df9fe7b12f refactors

Implement distance metric selection (euclidean or cosine)
author Chris Cannam
date Thu, 29 Jan 2015 10:25:47 +0000
parents 246de093f0f1
children d6c1556fadd0
line wrap: on
line diff
--- a/src/MatchVampPlugin.cpp	Fri Jan 23 09:20:04 2015 +0000
+++ b/src/MatchVampPlugin.cpp	Thu Jan 29 10:25:47 2015 +0000
@@ -215,6 +215,20 @@
     desc.isQuantized = false;
     list.push_back(desc);
 
+    desc.identifier = "metric";
+    desc.name = "Distance metric";
+    desc.description = "Metric for distance calculations.";
+    desc.minValue = 0;
+    desc.maxValue = 1;
+    desc.defaultValue = (int)m_defaultDParams.metric;
+    desc.isQuantized = true;
+    desc.quantizeStep = 1;
+    desc.valueNames.clear();
+    desc.valueNames.push_back("Euclidean");
+    desc.valueNames.push_back("Cosine");
+    list.push_back(desc);
+    desc.valueNames.clear();
+
     desc.identifier = "noise";
     desc.name = "Mix in Noise";
     desc.description = "Whether to mix in a small constant white noise term when calculating feature distance. This can improve alignment against sources containing cleanly synthesised audio.";
@@ -293,6 +307,8 @@
         return m_smooth ? 1.0 : 0.0;
     } else if (name == "silencethreshold") {
         return m_fcParams.silenceThreshold;
+    } else if (name == "metric") {
+        return (int)m_dParams.metric;
     } else if (name == "noise") {
         return m_dParams.noise;
     }
@@ -323,6 +339,8 @@
         m_smooth = (value > 0.5);
     } else if (name == "silencethreshold") {
         m_fcParams.silenceThreshold = value;
+    } else if (name == "metric") {
+        m_dParams.metric = (DistanceMetric::Metric)(int(value + 0.1));
     } else if (name == "noise") {
         m_dParams.noise = (DistanceMetric::NoiseAddition)(int(value + 0.1));
     }