Mercurial > hg > qm-dsp
changeset 27:b678e72323df
* Adjust MFCC params in segmenter to match timbral MFCC params from Soundbite
author | cannam |
---|---|
date | Thu, 10 Jan 2008 17:26:15 +0000 |
parents | d096a79fa772 |
children | e5d2028c594c |
files | dsp/segmentation/ClusterMeltSegmenter.cpp qm-dsp.pro |
diffstat | 2 files changed, 31 insertions(+), 6 deletions(-) [+] |
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); }