Mercurial > hg > cepstral-pitchtracker
diff CepstralPitchTracker.cpp @ 47:f72a470fe4b5
Pull out mean filter, test it
author | Chris Cannam |
---|---|
date | Tue, 11 Sep 2012 16:37:47 +0100 |
parents | 822cf7b8e070 |
children | d84049e20c61 |
line wrap: on
line diff
--- a/CepstralPitchTracker.cpp Wed Aug 15 14:53:28 2012 +0100 +++ b/CepstralPitchTracker.cpp Tue Sep 11 16:37:47 2012 +0100 @@ -23,6 +23,7 @@ */ #include "CepstralPitchTracker.h" +#include "MeanFilter.h" #include "vamp-sdk/FFT.h" @@ -256,24 +257,6 @@ fs[1].push_back(nf); } -void -CepstralPitchTracker::filter(const double *cep, double *data) -{ - for (int i = 0; i < m_bins; ++i) { - double v = 0; - int n = 0; - // average according to the vertical filter length - for (int j = -m_vflen/2; j <= m_vflen/2; ++j) { - int ix = i + m_binFrom + j; - if (ix >= 0 && ix < (int)m_blockSize) { - v += cep[ix]; - ++n; - } - } - data[i] = v / n; - } -} - double CepstralPitchTracker::cubicInterpolate(const double y[4], double x) { @@ -380,7 +363,7 @@ int n = m_bins; double *data = new double[n]; - filter(rawcep, data); + MeanFilter(m_vflen).filterSubsequence(rawcep, data, m_blockSize, n, m_binFrom); delete[] rawcep; double maxval = 0.0;