changeset 166:d23dad16d6f9 refactors

Simplify freq handling
author Chris Cannam
date Thu, 05 Feb 2015 11:53:23 +0000
parents 31602361fb65
children 001db4c32eb0 eeed3498fe96
files match-vamp-plugin.n3 src/FeatureExtractor.cpp src/MatchPipeline.cpp src/MatchPipeline.h
diffstat 4 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/match-vamp-plugin.n3	Fri Jan 30 14:54:18 2015 +0000
+++ b/match-vamp-plugin.n3	Thu Feb 05 11:53:23 2015 +0000
@@ -17,7 +17,7 @@
 :library_maker
     foaf:name "Simon Dixon and Chris Cannam" ;
     foaf:logo <http://vamp-plugins.org/rdf/plugins/makers/qm.png> ;
-    foaf:page <http://c4dm.eecs.qmul.ac.uk/> .
+    foaf:page <http://c4dm.eecs.qmul.ac.uk/> ;
     .
 
 plugbase:library a  vamp:PluginLibrary ;
--- a/src/FeatureExtractor.cpp	Fri Jan 30 14:54:18 2015 +0000
+++ b/src/FeatureExtractor.cpp	Thu Feb 05 11:53:23 2015 +0000
@@ -24,7 +24,7 @@
 
 using namespace std;
 
-//#define DEBUG_FEATURE_EXTRACTOR 1
+#define DEBUG_FEATURE_EXTRACTOR 1
 
 FeatureExtractor::FeatureExtractor(Parameters parameters) :
     m_params(parameters)
@@ -76,7 +76,9 @@
     int crossoverMidi = lrint(log(crossoverBin * binWidth / refFreq)/
                               log(2.0) * 12 + 69);
 
+#ifdef DEBUG_FEATURE_EXTRACTOR
     cerr << "FeatureExtractor::makeStandardFrequencyMap: refFreq = " << refFreq << endl;
+#endif
     
     int i = 0;
     while (i <= crossoverBin) {
@@ -91,6 +93,11 @@
         if (target >= m_featureSize) target = m_featureSize - 1;
         m_freqMap[i++] = target;
     }
+
+#ifdef DEBUG_FEATURE_EXTRACTOR
+    cerr << "FeatureExtractor: crossover bin is " << crossoverBin << " for midi "
+         << crossoverMidi << endl;
+#endif
 }
 
 void
--- a/src/MatchPipeline.cpp	Fri Jan 30 14:54:18 2015 +0000
+++ b/src/MatchPipeline.cpp	Thu Feb 05 11:53:23 2015 +0000
@@ -23,7 +23,7 @@
 			     Matcher::Parameters matchParams,
                              double secondReferenceFrequency) :
     m_fe1(feParams),
-    m_fe2(feParams),
+    m_fe2(paramsWithFreq(feParams, secondReferenceFrequency)),
     m_fc1(fcParams),
     m_fc2(fcParams),
     m_pm1(matchParams, dParams, 0),
@@ -33,11 +33,6 @@
     m_lastFrameIn2(0),
     m_frameNo(0)
 {
-    if (secondReferenceFrequency != 0.0) {
-        feParams.referenceFrequency = secondReferenceFrequency;
-        m_fe2 = FeatureExtractor(feParams);
-    }
-    
     m_pm1.setOtherMatcher(&m_pm2);
 }
 
@@ -45,6 +40,14 @@
 {
 }
 
+FeatureExtractor::Parameters
+MatchPipeline::paramsWithFreq(FeatureExtractor::Parameters params, double freq)
+{
+    if (freq == 0.0) return params;
+    params.referenceFrequency = freq;
+    return params;
+}
+
 void
 MatchPipeline::feedFrequencyDomainAudio(const float *arr1, const float *arr2)
 {
--- a/src/MatchPipeline.h	Fri Jan 30 14:54:18 2015 +0000
+++ b/src/MatchPipeline.h	Thu Feb 05 11:53:23 2015 +0000
@@ -115,6 +115,8 @@
     vector<double> m_c1;
     vector<double> m_c2;
     bool aboveThreshold(const vector<double> &f);
+    FeatureExtractor::Parameters paramsWithFreq(FeatureExtractor::Parameters,
+                                                double);
 };
 
 #endif