diff dsp/segmentation/ClusterMeltSegmenter.cpp @ 252:89a2b34a098f

* Adjust MFCC params in segmenter to match timbral MFCC params from Soundbite
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 10 Jan 2008 17:26:15 +0000
parents c3600d3cfe5c
children a251fb0de594
line wrap: on
line diff
--- a/dsp/segmentation/ClusterMeltSegmenter.cpp	Thu Jan 10 16:41:33 2008 +0000
+++ b/dsp/segmentation/ClusterMeltSegmenter.cpp	Thu Jan 10 17:26:15 2008 +0000
@@ -76,14 +76,30 @@
         
     } else if (featureType == FEATURE_TYPE_MFCC) {
 
+        // run internal processing at 22050 or thereabouts
+        int internalRate = 22050;
+        int decimationFactor = samplerate / internalRate;
+        if (decimationFactor < 1) decimationFactor = 1;
+
+        // must be a power of two
+        while (decimationFactor & (decimationFactor - 1)) ++decimationFactor;
+
+        if (decimationFactor > Decimator::getHighestSupportedFactor()) {
+            decimationFactor = Decimator::getHighestSupportedFactor();
+        }
+
+        if (decimationFactor > 1) {
+            decimator = new Decimator(getWindowsize(), decimationFactor);
+        }
+
         MFCCConfig config;
-        config.FS = samplerate;
-        config.fftsize = 1024;
-        config.nceps = 20;
-        config.want_c0 = false;
+        config.FS = samplerate / decimationFactor;
+        config.fftsize = 2048;
+        config.nceps = 19;
+        config.want_c0 = true;
 
         mfcc = new MFCC(config);
-        ncoeff = config.nceps;
+        ncoeff = config.nceps + 1;
     }
 }
 
@@ -235,6 +251,13 @@
     const double *psource = samples;
     int pcount = nsamples;
 
+    if (decimator) {
+        pcount = nsamples / decimator->getFactor();
+        double *decout = new double[pcount];
+        decimator->process(samples, decout);
+        psource = decout;
+    }
+
     int origin = 0;
     int frames = 0;
 
@@ -272,6 +295,8 @@
         cc[i] /= frames;
     }
 
+    if (decimator) delete[] psource;
+
     features.push_back(cc);
 }