changeset 95:e51152b7ee06

* Fixes to problems shown by vamp-plugin-tester
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 23 Mar 2009 16:29:12 +0000
parents f46864eba7fd
children b3a809bb964e
files libmain.cpp plugins/BarBeatTrack.cpp plugins/ChromagramPlugin.cpp plugins/ConstantQSpectrogram.cpp plugins/KeyDetect.cpp plugins/KeyDetect.h plugins/MFCCPlugin.cpp plugins/OnsetDetect.cpp
diffstat 8 files changed, 20 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libmain.cpp	Tue Mar 17 15:20:40 2009 +0000
+++ b/libmain.cpp	Mon Mar 23 16:29:12 2009 +0000
@@ -50,7 +50,7 @@
     case  7: return similarityPluginAdapter.getDescriptor();
     case  8: return mfccPluginAdapter.getDescriptor();
     case  9: return barBeatTrackPluginAdapter.getDescriptor();
-    case 10: return adaptiveSpectrogramAdapter.getDescriptor();
+//    case 10: return adaptiveSpectrogramAdapter.getDescriptor();
     default: return 0;
     }
 }
--- a/plugins/BarBeatTrack.cpp	Tue Mar 17 15:20:40 2009 +0000
+++ b/plugins/BarBeatTrack.cpp	Mon Mar 23 16:29:12 2009 +0000
@@ -29,7 +29,7 @@
 	df = new DetectionFunction(config);
         // decimation factor aims at resampling to c. 3KHz; must be power of 2
         int factor = MathUtilities::nextPowerOfTwo(rate / 3000);
-        std::cerr << "BarBeatTrackerData: factor = " << factor << std::endl;
+//        std::cerr << "BarBeatTrackerData: factor = " << factor << std::endl;
         downBeat = new DownBeat(rate, factor, config.stepSize);
     }
     ~BarBeatTrackerData() {
@@ -184,6 +184,7 @@
 BarBeatTracker::getPreferredStepSize() const
 {
     size_t step = size_t(m_inputSampleRate * m_stepSecs + 0.0001);
+    if (step < 1) step = 1;
 //    std::cerr << "BarBeatTracker::getPreferredStepSize: input sample rate is " << m_inputSampleRate << ", step size is " << step << std::endl;
     return step;
 }
--- a/plugins/ChromagramPlugin.cpp	Tue Mar 17 15:20:40 2009 +0000
+++ b/plugins/ChromagramPlugin.cpp	Mon Mar 23 16:29:12 2009 +0000
@@ -222,6 +222,7 @@
 
     m_step = m_chromagram->getHopSize();
     m_block = m_chromagram->getFrameSize();
+    if (m_step < 1) m_step = 1;
 
     if (blockSize != m_block) {
         std::cerr << "ChromagramPlugin::initialise: ERROR: supplied block size " << blockSize << " differs from required block size " << m_block << ", initialise failing" << std::endl;
@@ -257,6 +258,7 @@
 	Chromagram chroma(m_config);
 	m_step = chroma.getHopSize();
 	m_block = chroma.getFrameSize();
+        if (m_step < 1) m_step = 1;
     }
 
     return m_step;
@@ -269,6 +271,7 @@
 	Chromagram chroma(m_config);
 	m_step = chroma.getHopSize();
 	m_block = chroma.getFrameSize();
+        if (m_step < 1) m_step = 1;
     }
 
     return m_block;
--- a/plugins/ConstantQSpectrogram.cpp	Tue Mar 17 15:20:40 2009 +0000
+++ b/plugins/ConstantQSpectrogram.cpp	Mon Mar 23 16:29:12 2009 +0000
@@ -280,7 +280,7 @@
     d.hasFixedBinCount = true;
     d.binCount = m_bins;
 
-    std::cerr << "Bin count " << d.binCount << std::endl;
+//    std::cerr << "Bin count " << d.binCount << std::endl;
     
     const char *names[] =
 	{ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
--- a/plugins/KeyDetect.cpp	Tue Mar 17 15:20:40 2009 +0000
+++ b/plugins/KeyDetect.cpp	Mon Mar 23 16:29:12 2009 +0000
@@ -166,7 +166,8 @@
     m_inputFrame = new double[m_blockSize];
 
     m_prevKey = -1;
-	
+    m_first = true;
+
     return true;
 }
 
@@ -187,6 +188,7 @@
     }
 
     m_prevKey = -1;
+    m_first = true;
 }
 
 
@@ -290,7 +292,7 @@
     int prevTonic = m_prevKey;
     if (prevTonic > 12) prevTonic -= 12;
 
-    if (tonic != prevTonic) {
+    if (m_first || (tonic != prevTonic)) {
         Feature feature;
         feature.hasTimestamp = true;
         feature.timestamp = now;
@@ -300,7 +302,7 @@
         returnFeatures[0].push_back(feature); // tonic
     }
 
-    if (minor != (m_getKeyMode->isModeMinor(m_prevKey))) {
+    if (m_first || (minor != (m_getKeyMode->isModeMinor(m_prevKey)))) {
         Feature feature;
         feature.hasTimestamp = true;
         feature.timestamp = now;
@@ -309,7 +311,7 @@
         returnFeatures[1].push_back(feature); // mode
     }
 
-    if (key != m_prevKey) {
+    if (m_first || (key != m_prevKey)) {
         Feature feature;
         feature.hasTimestamp = true;
         feature.timestamp = now;
@@ -319,6 +321,7 @@
     }
 
     m_prevKey = key;
+    m_first = false;
 
     Feature ksf;
     ksf.values.reserve(25);
--- a/plugins/KeyDetect.h	Tue Mar 17 15:20:40 2009 +0000
+++ b/plugins/KeyDetect.h	Mon Mar 23 16:29:12 2009 +0000
@@ -57,6 +57,7 @@
     GetKeyMode* m_getKeyMode;
     double* m_inputFrame;
     int m_prevKey;
+    bool m_first;
 };
 
 
--- a/plugins/MFCCPlugin.cpp	Tue Mar 17 15:20:40 2009 +0000
+++ b/plugins/MFCCPlugin.cpp	Mon Mar 23 16:29:12 2009 +0000
@@ -173,8 +173,8 @@
     if (channels < getMinChannelCount() ||
 	channels > getMaxChannelCount()) return false;
 
-    std::cerr << "MFCCPlugin::initialise: step " << stepSize << ", block "
-	      << blockSize << std::endl;
+//    std::cerr << "MFCCPlugin::initialise: step " << stepSize << ", block "
+//	      << blockSize << std::endl;
 
     m_step = stepSize;
     m_block = blockSize;
@@ -281,6 +281,8 @@
     feature.label = "";
     ++m_count;
 
+    delete[] output;
+
     FeatureSet returnFeatures;
     returnFeatures[0].push_back(feature);
     return returnFeatures;
--- a/plugins/OnsetDetect.cpp	Tue Mar 17 15:20:40 2009 +0000
+++ b/plugins/OnsetDetect.cpp	Mon Mar 23 16:29:12 2009 +0000
@@ -272,6 +272,7 @@
 OnsetDetector::getPreferredStepSize() const
 {
     size_t step = size_t(m_inputSampleRate * m_preferredStepSecs + 0.0001);
+    if (step < 1) step = 1;
 //    std::cerr << "OnsetDetector::getPreferredStepSize: input sample rate is " << m_inputSampleRate << ", step size is " << step << std::endl;
     return step;
 }