Mercurial > hg > qm-dsp
changeset 469:8d84e5d16314
Fix error in lower bins
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Thu, 30 May 2019 14:10:15 +0100 |
parents | a72d98f8baa3 |
children | dd132354ea02 |
files | dsp/chromagram/ConstantQ.cpp |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/dsp/chromagram/ConstantQ.cpp Thu May 30 11:35:35 2019 +0100 +++ b/dsp/chromagram/ConstantQ.cpp Thu May 30 14:10:15 2019 +0100 @@ -128,6 +128,9 @@ // Computing a hamming window const unsigned hammingLength = (int) ceil( m_dQ * m_FS / ( m_FMin * pow(2,((double)(k))/(double)m_BPO))); +// cerr << "k = " << k << ", q = " << m_dQ << ", m_FMin = " << m_FMin << ", hammingLength = " << hammingLength << " (rounded up from " << (m_dQ * m_FS / ( m_FMin * pow(2,((double)(k))/(double)m_BPO))) << ")" << endl; + + unsigned origin = m_FFTLength/2 - hammingLength/2; for (unsigned i=0; i<hammingLength; i++) @@ -159,7 +162,7 @@ const double squaredBin = squaredModule( transfHammingWindowRe[ j ], transfHammingWindowIm[ j ]); if (squaredBin <= squareThreshold) continue; - // Insert non-zero position indexes, doubled because they are floats + // Insert non-zero position indexes sk->is.push_back(j); sk->js.push_back(k); @@ -271,6 +274,7 @@ { const unsigned row = cqbin[i]; const unsigned col = fftbin[i]; + if (col == 0) continue; const double & r1 = real[i]; const double & i1 = imag[i]; const double & r2 = fftdata[ (2*m_FFTLength) - 2*col - 2 ]; @@ -340,10 +344,11 @@ { const unsigned row = cqbin[i]; const unsigned col = fftbin[i]; + if (col == 0) continue; const double & r1 = real[i]; const double & i1 = imag[i]; - const double & r2 = FFTRe[ m_FFTLength - col - 1 ]; - const double & i2 = FFTIm[ m_FFTLength - col - 1 ]; + const double & r2 = FFTRe[ m_FFTLength - col ]; + const double & i2 = FFTIm[ m_FFTLength - col ]; // add the multiplication CQRe[ row ] += (r1*r2 - i1*i2); CQIm[ row ] += (r1*i2 + i1*r2);