comparison dsp/tempotracking/DownBeat.cpp @ 301:17c7b6658329

* 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 Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 22 Jun 2009 14:10:03 +0000
parents 1c9258dd155e
children e2bff5365828
comparison
equal deleted inserted replaced
300:10b78483a5ae 301:17c7b6658329
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