# HG changeset patch # User Chris Cannam # Date 1245679803 0 # Node ID 17c7b66583291e21092d04ac2330091e2946b87b # Parent 10b78483a5aee50c9b3b48c8fc8ee8868792ab41 * 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! diff -r 10b78483a5ae -r 17c7b6658329 dsp/tempotracking/DownBeat.cpp --- a/dsp/tempotracking/DownBeat.cpp Tue Jun 16 11:55:44 2009 +0000 +++ b/dsp/tempotracking/DownBeat.cpp Mon Jun 22 14:10:03 2009 +0000 @@ -226,18 +226,17 @@ dbcand[beat] = 0; } - // look for beat transition which leads to greatest spectral change - for (int beat = 0; beat < timesig; ++beat) { - int count = 0; - for (int example = beat - 1; example < m_beatsd.size(); example += timesig) { - if (example < 0) continue; - dbcand[beat] += (m_beatsd[example]) / timesig; - ++count; - } - if (count > 0) m_beatsd[beat] /= count; + // look for beat transition which leads to greatest spectral change + for (int beat = 0; beat < timesig; ++beat) { + int count = 0; + for (int example = beat; example < m_beatsd.size(); example += timesig) { + if (example < 0) continue; + dbcand[beat] += (m_beatsd[example]) / timesig; + ++count; + } + if (count > 0) dbcand[beat] /= count; // std::cerr << "dbcand[" << beat << "] = " << dbcand[beat] << std::endl; - } - + } // first downbeat is beat at index of maximum value of dbcand int dbind = MathUtilities::getMax(dbcand);