# HG changeset patch # User Chris Cannam # Date 1394209282 0 # Node ID d2f7a8295671a2b955d47bb05ff4cd06b94e9d41 # Parent 3bf29717cc01997c9db70c6efd6d199c34c25d11# Parent 32d91b97af7c34b628d819f8fe80073d41cd07f0 Merge diff -r 32d91b97af7c -r d2f7a8295671 ConstrainedHarmonicPeak.cpp --- a/ConstrainedHarmonicPeak.cpp Fri Mar 07 15:58:49 2014 +0000 +++ b/ConstrainedHarmonicPeak.cpp Fri Mar 07 16:21:22 2014 +0000 @@ -10,7 +10,7 @@ ConstrainedHarmonicPeak::ConstrainedHarmonicPeak(float inputSampleRate) : Plugin(inputSampleRate), - m_blockSize(0), + m_fftSize(0), m_minFreq(0), m_maxFreq(inputSampleRate/2), m_harmonics(5) @@ -199,7 +199,7 @@ return false; } - m_blockSize = blockSize; + m_fftSize = blockSize; return true; } @@ -243,18 +243,18 @@ { FeatureSet fs; - int hs = m_blockSize/2; + int hs = m_fftSize/2; double *mags = new double[hs+1]; for (int i = 0; i <= hs; ++i) { - mags[i] = sqrtf(inputBuffers[0][i*2] * inputBuffers[0][i*2] + - inputBuffers[0][i*2+1] * inputBuffers[0][i*2+1]); + mags[i] = sqrt(inputBuffers[0][i*2] * inputBuffers[0][i*2] + + inputBuffers[0][i*2+1] * inputBuffers[0][i*2+1]); } // bin freq is bin * samplerate / fftsize - int minbin = int(floor((m_minFreq * m_blockSize) / m_inputSampleRate)); - int maxbin = int(ceil((m_maxFreq * m_blockSize) / m_inputSampleRate)); + int minbin = int(floor((m_minFreq * m_fftSize) / m_inputSampleRate)); + int maxbin = int(ceil((m_maxFreq * m_fftSize) / m_inputSampleRate)); if (minbin > hs) minbin = hs; if (maxbin > hs) maxbin = hs; if (maxbin <= minbin) return fs; @@ -295,7 +295,7 @@ double interpolated = findInterpolatedPeak(hps, maxidx, maxbin - minbin + 1); interpolated = interpolated + minbin; - double freq = interpolated * m_inputSampleRate / m_blockSize; + double freq = interpolated * m_inputSampleRate / m_fftSize; Feature f; f.values.push_back(freq); diff -r 32d91b97af7c -r d2f7a8295671 ConstrainedHarmonicPeak.h --- a/ConstrainedHarmonicPeak.h Fri Mar 07 15:58:49 2014 +0000 +++ b/ConstrainedHarmonicPeak.h Fri Mar 07 16:21:22 2014 +0000 @@ -43,7 +43,7 @@ FeatureSet getRemainingFeatures(); protected: - int m_blockSize; + int m_fftSize; float m_minFreq; float m_maxFreq; int m_harmonics;