changeset 130:2053a308bb4d kissfft

Frame length no longer needs to be a power of two
author Chris Cannam
date Tue, 15 Oct 2013 11:52:00 +0100
parents 6ec45e85ed81
children a586888bc06c
files dsp/onsets/DetectionFunction.cpp dsp/onsets/DetectionFunction.h
diffstat 2 files changed, 2 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/dsp/onsets/DetectionFunction.cpp	Tue Oct 15 11:38:18 2013 +0100
+++ b/dsp/onsets/DetectionFunction.cpp	Tue Oct 15 11:52:00 2013 +0100
@@ -63,9 +63,7 @@
     m_magPeaks = new double[ m_halfLength ];
     memset(m_magPeaks,0, m_halfLength*sizeof(double));
 
-    // See note in processTimeDomain below
-    int actualLength = MathUtilities::previousPowerOfTwo(m_dataLength);
-    m_phaseVoc = new PhaseVocoder(actualLength, m_stepSize);
+    m_phaseVoc = new PhaseVocoder(m_dataLength, m_stepSize);
 
     m_magnitude = new double[ m_halfLength ];
     m_thetaAngle = new double[ m_halfLength ];
@@ -96,23 +94,6 @@
 {
     m_window->cut(samples, m_windowed);
 
-    // Our own FFT implementation supports power-of-two sizes only.
-    // If we have to use this implementation (as opposed to the
-    // version of process() below that operates on frequency domain
-    // data directly), we will have to use the next smallest power of
-    // two from the block size.  Results may vary accordingly!
-
-    int actualLength = MathUtilities::previousPowerOfTwo((int)m_dataLength);
-
-    if (actualLength != (int)m_dataLength) {
-        // Pre-fill mag and phase vectors with zero, as the FFT output
-        // will not fill the arrays
-        for (int i = actualLength/2; i < (int)m_dataLength/2; ++i) {
-            m_magnitude[i] = 0;
-            m_thetaAngle[0] = 0;
-        }
-    }
-
     m_phaseVoc->processTimeDomain(m_windowed, 
                                   m_magnitude, m_thetaAngle, m_unwrapped);
 
--- a/dsp/onsets/DetectionFunction.h	Tue Oct 15 11:38:18 2013 +0100
+++ b/dsp/onsets/DetectionFunction.h	Tue Oct 15 11:52:00 2013 +0100
@@ -29,7 +29,7 @@
 
 struct DFConfig{
     unsigned int stepSize; // DF step in samples
-    unsigned int frameLength; // DF analysis window - usually 2*step
+    unsigned int frameLength; // DF analysis window - usually 2*step. Must be even!
     int DFType; // type of detection function ( see defines )
     double dbRise; // only used for broadband df (and required for it)
     bool adaptiveWhitening; // perform adaptive whitening