diff vamp/CQVamp.cpp @ 36:cb072f01435b

Get remaining blocks from end of processing; fix some compile warnings, etc
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 06 Nov 2013 16:21:28 +0000
parents 75d528478feb
children a25abb7a21c0
line wrap: on
line diff
--- a/vamp/CQVamp.cpp	Wed Nov 06 14:30:42 2013 +0000
+++ b/vamp/CQVamp.cpp	Wed Nov 06 16:21:28 2013 +0000
@@ -159,6 +159,7 @@
 	m_cq = new ConstantQ
 	    (m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo);
     }
+    m_prevFeature.clear();
 }
 
 size_t
@@ -209,15 +210,36 @@
     for (int i = 0; i < m_blockSize; ++i) data.push_back(inputBuffers[0][i]);
     
     vector<vector<double> > cqout = m_cq->process(data);
+    return convertToFeatures(cqout);
+}
 
+CQVamp::FeatureSet
+CQVamp::getRemainingFeatures()
+{
+    vector<vector<double> > cqout = m_cq->getRemainingBlocks();
+    return convertToFeatures(cqout);
+}
+
+CQVamp::FeatureSet
+CQVamp::convertToFeatures(const vector<vector<double> > &cqout)
+{
+    
     FeatureSet returnFeatures;
 
-    for (int i = 0; i < cqout.size(); ++i) {
+    for (int i = 0; i < (int)cqout.size(); ++i) {
 
 	vector<float> column(m_cq->getTotalBins(), 0.f);
-	for (int j = 0; j < cqout[i].size(); ++j) {
+
+	for (int j = 0; j < (int)cqout[i].size(); ++j) {
 	    column[j] = cqout[i][j];
 	}
+	for (int j = cqout[i].size(); j < m_cq->getTotalBins(); ++j) {
+	    if (j < (int)m_prevFeature.size()) {
+		column[j] = m_prevFeature[j];
+	    }
+	}
+
+	m_prevFeature = column;
 
 	Feature feature;
 	feature.hasTimestamp = false;
@@ -229,9 +251,3 @@
     return returnFeatures;
 }
 
-CQVamp::FeatureSet
-CQVamp::getRemainingFeatures()
-{
-    return FeatureSet();
-}
-