Mercurial > hg > qm-dsp
diff 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 |
line wrap: on
line diff
--- 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);