comparison dsp/chromagram/ConstantQ.cpp @ 73:dcb555b90924

* Key detector: when returning key strengths, use the peak value of the three underlying chromagram correlations (from 36-bin chromagram) corresponding to each key, instead of the mean. Rationale: This is the same method as used when returning the key value, and it's nice to have the same results in both returned value and plot. The peak performed better than the sum with a simple test set of triads, so it seems reasonable to change the plot to match the key output rather than the other way around. * FFT: kiss_fftr returns only the non-conjugate bins, synthesise the rest rather than leaving them (perhaps dangerously) undefined. Fixes an uninitialised data error in chromagram that could cause garbage results from key detector. * Constant Q: remove precalculated values again, I reckon they're not proving such a good tradeoff.
author cannam
date Fri, 05 Jun 2009 15:12:39 +0000
parents 6cb2b3cd5356
children e5907ae6de17
comparison
equal deleted inserted replaced
72:d0b35b1e3a98 73:dcb555b90924
9 9
10 #include "ConstantQ.h" 10 #include "ConstantQ.h"
11 #include "dsp/transforms/FFT.h" 11 #include "dsp/transforms/FFT.h"
12 12
13 #include <iostream> 13 #include <iostream>
14
15 #ifdef NOT_DEFINED
16 // see note in CQprecalc
14 17
15 #include "CQprecalc.cpp" 18 #include "CQprecalc.cpp"
16 19
17 static bool push_precalculated(int uk, int fftlength, 20 static bool push_precalculated(int uk, int fftlength,
18 std::vector<unsigned> &is, 21 std::vector<unsigned> &is,
36 push_84_65536(is, js, real, imag); 39 push_84_65536(is, js, real, imag);
37 return true; 40 return true;
38 } 41 }
39 return false; 42 return false;
40 } 43 }
44 #endif
41 45
42 //--------------------------------------------------------------------------- 46 //---------------------------------------------------------------------------
43 // nextpow2 returns the smallest integer n such that 2^n >= x. 47 // nextpow2 returns the smallest integer n such that 2^n >= x.
44 static double nextpow2(double x) { 48 static double nextpow2(double x) {
45 double y = ceil(log(x)/log(2.0)); 49 double y = ceil(log(x)/log(2.0));
68 { 72 {
69 // std::cerr << "ConstantQ: initialising sparse kernel, uK = " << m_uK << ", FFTLength = " << m_FFTLength << "..."; 73 // std::cerr << "ConstantQ: initialising sparse kernel, uK = " << m_uK << ", FFTLength = " << m_FFTLength << "...";
70 74
71 SparseKernel *sk = new SparseKernel(); 75 SparseKernel *sk = new SparseKernel();
72 76
77 #ifdef NOT_DEFINED
73 if (push_precalculated(m_uK, m_FFTLength, 78 if (push_precalculated(m_uK, m_FFTLength,
74 sk->is, sk->js, sk->real, sk->imag)) { 79 sk->is, sk->js, sk->real, sk->imag)) {
80 // std::cerr << "using precalculated kernel" << std::endl;
75 m_sparseKernel = sk; 81 m_sparseKernel = sk;
76 return; 82 return;
77 } 83 }
78 84 #endif
85
79 //generates spectral kernel matrix (upside down?) 86 //generates spectral kernel matrix (upside down?)
80 // initialise temporal kernel with zeros, twice length to deal w. complex numbers 87 // initialise temporal kernel with zeros, twice length to deal w. complex numbers
81 88
82 double* hammingWindowRe = new double [ m_FFTLength ]; 89 double* hammingWindowRe = new double [ m_FFTLength ];
83 double* hammingWindowIm = new double [ m_FFTLength ]; 90 double* hammingWindowIm = new double [ m_FFTLength ];