comparison dsp/chromagram/ConstantQ.cpp @ 38:3dff6e3e2121

* Ouch! We overrun the FFTRe/Im vectors with the very first dereference I assume the kernel matrix column values are supposed to index the FFT bins from the end, not from the end plus one
author cannam
date Thu, 31 Jan 2008 13:01:48 +0000
parents 8bb764969d50
children 114e833c07ac
comparison
equal deleted inserted replaced
37:c964f60a7e7a 38:3dff6e3e2121
146 { 146 {
147 const unsigned row = cqbin[i]; 147 const unsigned row = cqbin[i];
148 const unsigned col = fftbin[i]; 148 const unsigned col = fftbin[i];
149 const double & r1 = real[i]; 149 const double & r1 = real[i];
150 const double & i1 = imag[i]; 150 const double & i1 = imag[i];
151 const double & r2 = fftdata[ (2*m_FFTLength) - 2*col]; 151 const double & r2 = fftdata[ (2*m_FFTLength) - 2*col - 2 ];
152 const double & i2 = fftdata[ (2*m_FFTLength) - 2*col+1]; 152 const double & i2 = fftdata[ (2*m_FFTLength) - 2*col - 2 + 1 ];
153 // add the multiplication 153 // add the multiplication
154 m_CQdata[ 2*row ] += (r1*r2 - i1*i2); 154 m_CQdata[ 2*row ] += (r1*r2 - i1*i2);
155 m_CQdata[ 2*row+1] += (r1*i2 + i1*r2); 155 m_CQdata[ 2*row+1] += (r1*i2 + i1*r2);
156 } 156 }
157 157
207 { 207 {
208 const unsigned row = cqbin[i]; 208 const unsigned row = cqbin[i];
209 const unsigned col = fftbin[i]; 209 const unsigned col = fftbin[i];
210 const double & r1 = real[i]; 210 const double & r1 = real[i];
211 const double & i1 = imag[i]; 211 const double & i1 = imag[i];
212 const double & r2 = FFTRe[ m_FFTLength - col]; 212 const double & r2 = FFTRe[ m_FFTLength - col - 1 ];
213 const double & i2 = FFTIm[ m_FFTLength - col]; 213 const double & i2 = FFTIm[ m_FFTLength - col - 1 ];
214 // add the multiplication 214 // add the multiplication
215 CQRe[ row ] += (r1*r2 - i1*i2); 215 CQRe[ row ] += (r1*r2 - i1*i2);
216 CQIm[ row ] += (r1*i2 + i1*r2); 216 CQIm[ row ] += (r1*i2 + i1*r2);
217 } 217 }
218 } 218 }