comparison dsp/onsets/DetectionFunction.cpp @ 280:9c403afdd9e9

* Various fixes related to the bar estimator code
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 10 Feb 2009 16:37:11 +0000
parents c8908cdc8c32
children 6cb2b3cd5356
comparison
equal deleted inserted replaced
279:c8908cdc8c32 280:9c403afdd9e9
81 delete [] m_thetaAngle; 81 delete [] m_thetaAngle;
82 82
83 delete m_window; 83 delete m_window;
84 } 84 }
85 85
86 double DetectionFunction::process( double *TDomain ) 86 double DetectionFunction::process( const double *TDomain )
87 { 87 {
88 m_window->cut( TDomain, m_DFWindowedFrame ); 88 m_window->cut( TDomain, m_DFWindowedFrame );
89 89
90 m_phaseVoc->process( m_dataLength, m_DFWindowedFrame, m_magnitude, m_thetaAngle ); 90 // Our own FFT implementation supports power-of-two sizes only.
91 // If we have to use this implementation (as opposed to the
92 // version of process() below that operates on frequency domain
93 // data directly), we will have to use the next smallest power of
94 // two from the block size. Results may vary accordingly!
95
96 int actualLength = MathUtilities::previousPowerOfTwo(m_dataLength);
97
98 if (actualLength != m_dataLength) {
99 // Pre-fill mag and phase vectors with zero, as the FFT output
100 // will not fill the arrays
101 for (int i = actualLength/2; i < m_dataLength/2; ++i) {
102 m_magnitude[i] = 0;
103 m_thetaAngle[0] = 0;
104 }
105 }
106
107 m_phaseVoc->process(actualLength, m_DFWindowedFrame, m_magnitude, m_thetaAngle);
91 108
92 if (m_whiten) whiten(); 109 if (m_whiten) whiten();
93 110
94 return runDF(); 111 return runDF();
95 } 112 }
96 113
97 double DetectionFunction::process( double *magnitudes, double *phases ) 114 double DetectionFunction::process( const double *magnitudes, const double *phases )
98 { 115 {
99 for (size_t i = 0; i < m_halfLength; ++i) { 116 for (size_t i = 0; i < m_halfLength; ++i) {
100 m_magnitude[i] = magnitudes[i]; 117 m_magnitude[i] = magnitudes[i];
101 m_thetaAngle[i] = phases[i]; 118 m_thetaAngle[i] = phases[i];
102 } 119 }