Mercurial > hg > qm-dsp
comparison dsp/chromagram/ConstantQ.cpp @ 245:cdfd0948a852
* First cut at properly integrating the segmenter and making it work right
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Wed, 09 Jan 2008 16:50:04 +0000 |
parents | b7f01ab7045e |
children | 2b74bd60c61f |
comparison
equal
deleted
inserted
replaced
244:f599563a4663 | 245:cdfd0948a852 |
---|---|
7 All rights reserved. | 7 All rights reserved. |
8 */ | 8 */ |
9 | 9 |
10 #include "ConstantQ.h" | 10 #include "ConstantQ.h" |
11 #include "dsp/transforms/FFT.h" | 11 #include "dsp/transforms/FFT.h" |
12 | |
13 #include <iostream> | |
12 | 14 |
13 //--------------------------------------------------------------------------- | 15 //--------------------------------------------------------------------------- |
14 // nextpow2 returns the smallest integer n such that 2^n >= x. | 16 // nextpow2 returns the smallest integer n such that 2^n >= x. |
15 static double nextpow2(double x) { | 17 static double nextpow2(double x) { |
16 double y = ceil(log(x)/log(2.0)); | 18 double y = ceil(log(x)/log(2.0)); |
166 m_CQThresh = Config.CQThresh;// ConstantQ threshold for kernel generation | 168 m_CQThresh = Config.CQThresh;// ConstantQ threshold for kernel generation |
167 | 169 |
168 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 |
169 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 |
170 | 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; | |
174 | |
171 // 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 |
172 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 ))); |
173 | 177 |
174 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 | |
180 std::cerr << "ConstantQ::initialise: -> fft length = " << m_FFTLength << ", hop = " << m_hop << std::endl; | |
175 | 181 |
176 // allocate memory for cqdata | 182 // allocate memory for cqdata |
177 m_CQdata = new double [2*m_uK]; | 183 m_CQdata = new double [2*m_uK]; |
178 } | 184 } |
179 | 185 |