comparison src/ConstantQ.cpp @ 164:1081c73fbbe3

Various changes to make the code compatible with MSVC++ (though we don't provide projects for it yet)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 08 Aug 2014 10:07:25 +0100
parents b34df30fd7e4
children 5b1a1bbd6e7f
comparison
equal deleted inserted replaced
162:7c444fea4338 164:1081c73fbbe3
38 #include "dsp/FFT.h" 38 #include "dsp/FFT.h"
39 39
40 #include <algorithm> 40 #include <algorithm>
41 #include <iostream> 41 #include <iostream>
42 #include <stdexcept> 42 #include <stdexcept>
43
44 #include <cmath>
43 45
44 using std::vector; 46 using std::vector;
45 using std::cerr; 47 using std::cerr;
46 using std::endl; 48 using std::endl;
47 49
87 } 89 }
88 90
89 void 91 void
90 ConstantQ::initialise() 92 ConstantQ::initialise()
91 { 93 {
92 m_octaves = int(ceil(log2(m_maxFrequency / m_minFrequency))); 94 m_octaves = int(ceil(log(m_maxFrequency / m_minFrequency) / log(2)));
93 95
94 if (m_octaves < 1) { 96 if (m_octaves < 1) {
95 m_kernel = 0; // incidentally causing isValid() to return false 97 m_kernel = 0; // incidentally causing isValid() to return false
96 return; 98 return;
97 } 99 }
196 // octave latencies below. In theory this is hard, in practice if 198 // octave latencies below. In theory this is hard, in practice if
197 // we ensure it for the last octave we should be OK. 199 // we ensure it for the last octave we should be OK.
198 double finalOctLat = latencies[m_octaves-1]; 200 double finalOctLat = latencies[m_octaves-1];
199 double finalOctFact = pow(2, m_octaves-1); 201 double finalOctFact = pow(2, m_octaves-1);
200 totalLatency = 202 totalLatency =
201 int(round(finalOctLat + 203 int(finalOctLat +
202 finalOctFact * 204 finalOctFact *
203 ceil((totalLatency - finalOctLat) / finalOctFact))); 205 ceil((totalLatency - finalOctLat) / finalOctFact) + .5);
204 206
205 #ifdef DEBUG_CQ 207 #ifdef DEBUG_CQ
206 cerr << "total latency = " << totalLatency << endl; 208 cerr << "total latency = " << totalLatency << endl;
207 #endif 209 #endif
208 210
246 << m_bigBlockSize << ") / " << factor << " = " 248 << m_bigBlockSize << ") / " << factor << " = "
247 << octaveLatency << endl; 249 << octaveLatency << endl;
248 #endif 250 #endif
249 251
250 m_buffers.push_back 252 m_buffers.push_back
251 (RealSequence(int(round(octaveLatency)), 0.0)); 253 (RealSequence(int(octaveLatency + 0.5), 0.0));
252 } 254 }
253 255
254 m_fft = new FFTReal(m_p.fftSize); 256 m_fft = new FFTReal(m_p.fftSize);
255 } 257 }
256 258