Mercurial > hg > qm-dsp
diff dsp/onsets/DetectionFunction.cpp @ 55:7fe29d8a7eaf
* Various fixes related to the bar estimator code
author | cannam |
---|---|
date | Tue, 10 Feb 2009 16:37:11 +0000 |
parents | 5bec06ecc88a |
children | 6cb2b3cd5356 |
line wrap: on
line diff
--- a/dsp/onsets/DetectionFunction.cpp Tue Feb 10 12:52:43 2009 +0000 +++ b/dsp/onsets/DetectionFunction.cpp Tue Feb 10 16:37:11 2009 +0000 @@ -83,18 +83,35 @@ delete m_window; } -double DetectionFunction::process( double *TDomain ) +double DetectionFunction::process( const double *TDomain ) { m_window->cut( TDomain, m_DFWindowedFrame ); - - m_phaseVoc->process( m_dataLength, m_DFWindowedFrame, m_magnitude, m_thetaAngle ); + + // 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(m_dataLength); + + if (actualLength != 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 < m_dataLength/2; ++i) { + m_magnitude[i] = 0; + m_thetaAngle[0] = 0; + } + } + + m_phaseVoc->process(actualLength, m_DFWindowedFrame, m_magnitude, m_thetaAngle); if (m_whiten) whiten(); return runDF(); } -double DetectionFunction::process( double *magnitudes, double *phases ) +double DetectionFunction::process( const double *magnitudes, const double *phases ) { for (size_t i = 0; i < m_halfLength; ++i) { m_magnitude[i] = magnitudes[i];