comparison dsp/tempotracking/DownBeat.cpp @ 289:befe5aa6b450

* Refactor FFT a little bit so as to separate construction and processing rather than have a single static method -- will make it easier to use a different implementation * pull in KissFFT implementation (not hooked up yet)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 13 May 2009 09:19:12 +0000
parents 5e125f030287
children c3cdb404f807
comparison
equal deleted inserted replaced
288:86c70067c723 289:befe5aa6b450
41 (int((m_rate / decimationFactor) * 1.3)); 41 (int((m_rate / decimationFactor) * 1.3));
42 // std::cerr << "rate = " << m_rate << ", bfs = " << m_beatframesize << std::endl; 42 // std::cerr << "rate = " << m_rate << ", bfs = " << m_beatframesize << std::endl;
43 m_beatframe = new double[m_beatframesize]; 43 m_beatframe = new double[m_beatframesize];
44 m_fftRealOut = new double[m_beatframesize]; 44 m_fftRealOut = new double[m_beatframesize];
45 m_fftImagOut = new double[m_beatframesize]; 45 m_fftImagOut = new double[m_beatframesize];
46 m_fft = new FFTReal(m_beatframesize);
46 } 47 }
47 48
48 DownBeat::~DownBeat() 49 DownBeat::~DownBeat()
49 { 50 {
50 delete m_decimator1; 51 delete m_decimator1;
52 if (m_buffer) free(m_buffer); 53 if (m_buffer) free(m_buffer);
53 delete[] m_decbuf; 54 delete[] m_decbuf;
54 delete[] m_beatframe; 55 delete[] m_beatframe;
55 delete[] m_fftRealOut; 56 delete[] m_fftRealOut;
56 delete[] m_fftImagOut; 57 delete[] m_fftImagOut;
58 delete m_fft;
57 } 59 }
58 60
59 void 61 void
60 DownBeat::setBeatsPerBar(int bpb) 62 DownBeat::setBeatsPerBar(int bpb)
61 { 63 {
184 m_beatframe[j] = 0.0; 186 m_beatframe[j] = 0.0;
185 } 187 }
186 188
187 // Now FFT beat frame 189 // Now FFT beat frame
188 190
189 FFT::process(m_beatframesize, false, 191 m_fft->process(false, m_beatframe, m_fftRealOut, m_fftImagOut);
190 m_beatframe, 0, m_fftRealOut, m_fftImagOut);
191 192
192 // Calculate magnitudes 193 // Calculate magnitudes
193 194
194 for (size_t j = 0; j < m_beatframesize/2; ++j) { 195 for (size_t j = 0; j < m_beatframesize/2; ++j) {
195 newspec[j] = sqrt(m_fftRealOut[j] * m_fftRealOut[j] + 196 newspec[j] = sqrt(m_fftRealOut[j] * m_fftRealOut[j] +