Mercurial > hg > qm-dsp
comparison dsp/chromagram/ConstantQ.cpp @ 24:2b74bd60c61f
* Various fixes to segmentation code
author | cannam |
---|---|
date | Thu, 10 Jan 2008 15:14:53 +0000 |
parents | 8bdbda7fb893 |
children | 8bb764969d50 |
comparison
equal
deleted
inserted
replaced
23:eea2a08a75a9 | 24:2b74bd60c61f |
---|---|
168 m_CQThresh = Config.CQThresh;// ConstantQ threshold for kernel generation | 168 m_CQThresh = Config.CQThresh;// ConstantQ threshold for kernel generation |
169 | 169 |
170 m_dQ = 1/(pow(2,(1/(double)m_BPO))-1); // Work out Q value for Filter bank | 170 m_dQ = 1/(pow(2,(1/(double)m_BPO))-1); // Work out Q value for Filter bank |
171 m_uK = (unsigned int) ceil(m_BPO * log(m_FMax/m_FMin)/log(2.0)); // No. of constant Q bins | 171 m_uK = (unsigned int) ceil(m_BPO * log(m_FMax/m_FMin)/log(2.0)); // No. of constant Q bins |
172 | 172 |
173 std::cerr << "ConstantQ::initialise: rate = " << m_FS << ", fmin = " << m_FMin << ", fmax = " << m_FMax << ", bpo = " << m_BPO << ", K = " << m_uK << ", Q = " << m_dQ << std::endl; | 173 // std::cerr << "ConstantQ::initialise: rate = " << m_FS << ", fmin = " << m_FMin << ", fmax = " << m_FMax << ", bpo = " << m_BPO << ", K = " << m_uK << ", Q = " << m_dQ << std::endl; |
174 | 174 |
175 // work out length of fft required for this constant Q Filter bank | 175 // work out length of fft required for this constant Q Filter bank |
176 m_FFTLength = (int) pow(2, nextpow2(ceil( m_dQ*m_FS/m_FMin ))); | 176 m_FFTLength = (int) pow(2, nextpow2(ceil( m_dQ*m_FS/m_FMin ))); |
177 | 177 |
178 m_hop = m_FFTLength/8; // <------ hop size is window length divided by 32 | 178 m_hop = m_FFTLength/8; // <------ hop size is window length divided by 32 |
179 | 179 |
180 std::cerr << "ConstantQ::initialise: -> fft length = " << m_FFTLength << ", hop = " << m_hop << std::endl; | 180 // std::cerr << "ConstantQ::initialise: -> fft length = " << m_FFTLength << ", hop = " << m_hop << std::endl; |
181 | 181 |
182 // allocate memory for cqdata | 182 // allocate memory for cqdata |
183 m_CQdata = new double [2*m_uK]; | 183 m_CQdata = new double [2*m_uK]; |
184 } | 184 } |
185 | 185 |
206 { | 206 { |
207 const unsigned row = cqbin[i]; | 207 const unsigned row = cqbin[i]; |
208 const unsigned col = fftbin[i]; | 208 const unsigned col = fftbin[i]; |
209 const double & r1 = real[i]; | 209 const double & r1 = real[i]; |
210 const double & i1 = imag[i]; | 210 const double & i1 = imag[i]; |
211 const double & r2 = FFTRe[ m_FFTLength- col]; | 211 const double & r2 = FFTRe[ m_FFTLength - col]; |
212 const double & i2 = FFTIm[ m_FFTLength - col]; | 212 const double & i2 = FFTIm[ m_FFTLength - col]; |
213 // add the multiplication | 213 // add the multiplication |
214 CQRe[ row ] += (r1*r2 - i1*i2); | 214 CQRe[ row ] += (r1*r2 - i1*i2); |
215 CQIm[ row ] += (r1*i2 + i1*r2); | 215 CQIm[ row ] += (r1*i2 + i1*r2); |
216 } | 216 } |