diff --git a/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp b/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp index 4585ddc236ac..ffc130d7b0a2 100644 --- a/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp +++ b/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp @@ -117,32 +117,31 @@ void ConstantQ::sparsekernel() FFT m_FFT(m_FFTLength); - for (unsigned k = m_uK; k--; ) - { - for (unsigned u=0; u < m_FFTLength; u++) - { + for (unsigned k = m_uK; k--;) { + for (unsigned u=0; u < m_FFTLength; u++) { hammingWindowRe[u] = 0; hammingWindowIm[u] = 0; } - // Computing a hamming window - const unsigned hammingLength = (int) ceil( m_dQ * m_FS / ( m_FMin * pow(2,((double)(k))/(double)m_BPO))); + const double samplesPerCycle = + 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; - + // Computing a hamming window + const unsigned hammingLength = (int) ceil( + m_dQ * samplesPerCycle); unsigned origin = m_FFTLength/2 - hammingLength/2; - for (unsigned i=0; iis.push_back(j); - sk->js.push_back(k); - - // take conjugate, normalise and add to array sparkernel - sk->real.push_back( transfHammingWindowRe[ j ]/m_FFTLength); - sk->imag.push_back(-transfHammingWindowIm[ j ]/m_FFTLength); - } + //do fft of hammingWindow + m_FFT.process( 0, hammingWindowRe, hammingWindowIm, transfHammingWindowRe, transfHammingWindowIm ); + + + for (unsigned j=0; j<( m_FFTLength ); j++) { + // perform thresholding + const double squaredBin = squaredModule( transfHammingWindowRe[ j ], transfHammingWindowIm[ j ]); + if (squaredBin <= squareThreshold) { + continue; + } + // Insert non-zero position indexes + sk->is.push_back(j); + sk->js.push_back(k); + + // take conjugate, normalise and add to array sparkernel + sk->real.push_back( transfHammingWindowRe[ j ]/m_FFTLength); + sk->imag.push_back(-transfHammingWindowIm[ j ]/m_FFTLength); + } } @@ -259,10 +259,9 @@ double* ConstantQ::process( const double* fftdata ) SparseKernel *sk = m_sparseKernel; - for (unsigned row=0; row<2*m_uK; row++) - { - m_CQdata[ row ] = 0; - m_CQdata[ row+1 ] = 0; + for (unsigned row=0; row<2*m_uK; row++) { + m_CQdata[ row ] = 0; + m_CQdata[ row+1 ] = 0; } const unsigned *fftbin = &(sk->is[0]); const unsigned *cqbin = &(sk->js[0]); @@ -270,18 +269,19 @@ double* ConstantQ::process( const double* fftdata ) const double *imag = &(sk->imag[0]); const unsigned int sparseCells = sk->real.size(); - for (unsigned i = 0; i 0.66) { + std::cout << "I"; + } else if (value > 0.33) { + std::cout << "i"; + } else { + std::cout << ";"; + } + } + else + { + if (ii == 3 || ii == 9 || ii == 18 || ii == 24 || ii == 30 || + ii == 4 || ii == 10 || ii == 19 || ii == 25 || ii == 31 || + ii == 5 || ii == 11 || ii == 20 || ii == 26 || ii == 32) { + // Mark black keys + std::cout << "-"; + } + else { + std::cout << "_"; + } + } + if (ii % 3 == 2) { + std::cout << " "; + } + } +*/ + + + for( k = 0; k < kBinsPerOctave; k++ ) { // The Cromagram has the center of C at bin 0, while the major diff --git a/lib/qm-dsp/dsp/transforms/FFT.cpp b/lib/qm-dsp/dsp/transforms/FFT.cpp index da476b8a8b98..6f96b0ee47f7 100644 --- a/lib/qm-dsp/dsp/transforms/FFT.cpp +++ b/lib/qm-dsp/dsp/transforms/FFT.cpp @@ -10,8 +10,8 @@ #include "maths/MathUtilities.h" -#include "kiss_fft.h" -#include "kiss_fftr.h" +#include "ext/kissfft/kiss_fft.h" +#include "ext/kissfft/tools/kiss_fftr.h" #include diff --git a/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.c b/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.c index b8e238b1e2e9..8adb0f0b7478 100644 --- a/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.c +++ b/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.c @@ -13,7 +13,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */ #include "kiss_fftr.h" -#include "_kiss_fft_guts.h" +#include "../_kiss_fft_guts.h" struct kiss_fftr_state{ kiss_fft_cfg substate; diff --git a/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.h b/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.h index 72e5a57714df..81d8a8ec1712 100644 --- a/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.h +++ b/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.h @@ -1,7 +1,7 @@ #ifndef KISS_FTR_H #define KISS_FTR_H -#include "kiss_fft.h" +#include "../kiss_fft.h" #ifdef __cplusplus extern "C" { #endif diff --git a/mixxx-changes.patch b/mixxx-changes.patch new file mode 100644 index 000000000000..96d1fcdaa895 --- /dev/null +++ b/mixxx-changes.patch @@ -0,0 +1,289 @@ +diff --git a/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp b/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp +index 4585ddc..ffc130d 100644 +--- a/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp ++++ b/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp +@@ -117,32 +117,31 @@ void ConstantQ::sparsekernel() + + FFT m_FFT(m_FFTLength); + +- for (unsigned k = m_uK; k--; ) +- { +- for (unsigned u=0; u < m_FFTLength; u++) +- { ++ for (unsigned k = m_uK; k--;) { ++ for (unsigned u=0; u < m_FFTLength; u++) { + hammingWindowRe[u] = 0; + hammingWindowIm[u] = 0; + } + +- // Computing a hamming window +- const unsigned hammingLength = (int) ceil( m_dQ * m_FS / ( m_FMin * pow(2,((double)(k))/(double)m_BPO))); ++ const double samplesPerCycle = ++ 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; +- ++ // Computing a hamming window ++ const unsigned hammingLength = (int) ceil( ++ m_dQ * samplesPerCycle); + + unsigned origin = m_FFTLength/2 - hammingLength/2; + +- for (unsigned i=0; iis.push_back(j); +- sk->js.push_back(k); +- +- // take conjugate, normalise and add to array sparkernel +- sk->real.push_back( transfHammingWindowRe[ j ]/m_FFTLength); +- sk->imag.push_back(-transfHammingWindowIm[ j ]/m_FFTLength); +- } ++ //do fft of hammingWindow ++ m_FFT.process( 0, hammingWindowRe, hammingWindowIm, transfHammingWindowRe, transfHammingWindowIm ); ++ ++ ++ for (unsigned j=0; j<( m_FFTLength ); j++) { ++ // perform thresholding ++ const double squaredBin = squaredModule( transfHammingWindowRe[ j ], transfHammingWindowIm[ j ]); ++ if (squaredBin <= squareThreshold) { ++ continue; ++ } ++ // Insert non-zero position indexes ++ sk->is.push_back(j); ++ sk->js.push_back(k); ++ ++ // take conjugate, normalise and add to array sparkernel ++ sk->real.push_back( transfHammingWindowRe[ j ]/m_FFTLength); ++ sk->imag.push_back(-transfHammingWindowIm[ j ]/m_FFTLength); ++ } + + } + +@@ -259,10 +259,9 @@ double* ConstantQ::process( const double* fftdata ) + + SparseKernel *sk = m_sparseKernel; + +- for (unsigned row=0; row<2*m_uK; row++) +- { +- m_CQdata[ row ] = 0; +- m_CQdata[ row+1 ] = 0; ++ for (unsigned row=0; row<2*m_uK; row++) { ++ m_CQdata[ row ] = 0; ++ m_CQdata[ row+1 ] = 0; + } + const unsigned *fftbin = &(sk->is[0]); + const unsigned *cqbin = &(sk->js[0]); +@@ -270,18 +269,19 @@ double* ConstantQ::process( const double* fftdata ) + const double *imag = &(sk->imag[0]); + const unsigned int sparseCells = sk->real.size(); + +- for (unsigned i = 0; i 0.66) { ++ std::cout << "I"; ++ } else if (value > 0.33) { ++ std::cout << "i"; ++ } else { ++ std::cout << ";"; ++ } ++ } ++ else ++ { ++ if (ii == 3 || ii == 9 || ii == 18 || ii == 24 || ii == 30 || ++ ii == 4 || ii == 10 || ii == 19 || ii == 25 || ii == 31 || ++ ii == 5 || ii == 11 || ii == 20 || ii == 26 || ii == 32) { ++ // Mark black keys ++ std::cout << "-"; ++ } ++ else { ++ std::cout << "_"; ++ } ++ } ++ if (ii % 3 == 2) { ++ std::cout << " "; ++ } ++ } ++*/ ++ ++ ++ + for( k = 0; k < kBinsPerOctave; k++ ) + { + // The Cromagram has the center of C at bin 0, while the major +diff --git a/lib/qm-dsp/dsp/transforms/FFT.cpp b/lib/qm-dsp/dsp/transforms/FFT.cpp +index da476b8..6f96b0e 100644 +--- a/lib/qm-dsp/dsp/transforms/FFT.cpp ++++ b/lib/qm-dsp/dsp/transforms/FFT.cpp +@@ -10,8 +10,8 @@ + + #include "maths/MathUtilities.h" + +-#include "kiss_fft.h" +-#include "kiss_fftr.h" ++#include "ext/kissfft/kiss_fft.h" ++#include "ext/kissfft/tools/kiss_fftr.h" + + #include + +diff --git a/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.c b/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.c +index b8e238b..8adb0f0 100644 +--- a/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.c ++++ b/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.c +@@ -13,7 +13,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + */ + + #include "kiss_fftr.h" +-#include "_kiss_fft_guts.h" ++#include "../_kiss_fft_guts.h" + + struct kiss_fftr_state{ + kiss_fft_cfg substate; +diff --git a/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.h b/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.h +index 72e5a57..81d8a8e 100644 +--- a/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.h ++++ b/lib/qm-dsp/ext/kissfft/tools/kiss_fftr.h +@@ -1,7 +1,7 @@ + #ifndef KISS_FTR_H + #define KISS_FTR_H + +-#include "kiss_fft.h" ++#include "../kiss_fft.h" + #ifdef __cplusplus + extern "C" { + #endif