Mercurial > hg > qm-dsp
comparison dsp/tempotracking/DownBeat.cpp @ 76:4fada56adbb8
* Fix DownBeat off-by-one and another stupid error, both of which I
introduced and poor Matthew has had to waste his time fixing... sorry!
author | cannam |
---|---|
date | Mon, 22 Jun 2009 14:10:03 +0000 |
parents | c3cdb404f807 |
children | e2bff5365828 |
comparison
equal
deleted
inserted
replaced
75:20cf21c76689 | 76:4fada56adbb8 |
---|---|
224 | 224 |
225 for (int beat = 0; beat < timesig; ++beat) { | 225 for (int beat = 0; beat < timesig; ++beat) { |
226 dbcand[beat] = 0; | 226 dbcand[beat] = 0; |
227 } | 227 } |
228 | 228 |
229 // look for beat transition which leads to greatest spectral change | 229 // look for beat transition which leads to greatest spectral change |
230 for (int beat = 0; beat < timesig; ++beat) { | 230 for (int beat = 0; beat < timesig; ++beat) { |
231 int count = 0; | 231 int count = 0; |
232 for (int example = beat - 1; example < m_beatsd.size(); example += timesig) { | 232 for (int example = beat; example < m_beatsd.size(); example += timesig) { |
233 if (example < 0) continue; | 233 if (example < 0) continue; |
234 dbcand[beat] += (m_beatsd[example]) / timesig; | 234 dbcand[beat] += (m_beatsd[example]) / timesig; |
235 ++count; | 235 ++count; |
236 } | 236 } |
237 if (count > 0) m_beatsd[beat] /= count; | 237 if (count > 0) dbcand[beat] /= count; |
238 // std::cerr << "dbcand[" << beat << "] = " << dbcand[beat] << std::endl; | 238 // std::cerr << "dbcand[" << beat << "] = " << dbcand[beat] << std::endl; |
239 } | 239 } |
240 | |
241 | 240 |
242 // first downbeat is beat at index of maximum value of dbcand | 241 // first downbeat is beat at index of maximum value of dbcand |
243 int dbind = MathUtilities::getMax(dbcand); | 242 int dbind = MathUtilities::getMax(dbcand); |
244 | 243 |
245 // remaining downbeats are at timesig intervals from the first | 244 // remaining downbeats are at timesig intervals from the first |