From f7ebae85a7228c4b2d753d7c574574ec767d60f7 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 17 Nov 2014 19:53:30 -0500 Subject: [PATCH] Fix "maybe" rounding bug. Introduced in d63161426f256c293c92b73f1be4b375f962d298. --- libs/ardour/tempo.cc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 6f667a93b6..e775092066 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -1243,7 +1243,6 @@ TempoMap::round_to_beat_subdivision (framepos_t fr, int sub_num, RoundMode dir) BBTPointList::const_iterator i = bbt_before_or_at (fr); BBT_Time the_beat; uint32_t ticks_one_subdivisions_worth; - uint32_t difference; bbt_time (fr, the_beat, i); @@ -1283,20 +1282,12 @@ TempoMap::round_to_beat_subdivision (framepos_t fr, int sub_num, RoundMode dir) /* round to previous (or same iff dir == RoundDownMaybe) */ - uint32_t mod = the_beat.ticks % ticks_one_subdivisions_worth; + uint32_t difference = the_beat.ticks % ticks_one_subdivisions_worth; - if (mod == 0 && dir == RoundDownMaybe) { - /* right on the subdivision, which is fine, so do nothing */ - - } else if (mod == 0) { - /* right on the subdivision, so the difference is just the subdivision ticks */ + if (difference == 0 && dir == RoundDownAlways) { + /* right on the subdivision, but force-rounding down, + so the difference is just the subdivision ticks */ difference = ticks_one_subdivisions_worth; - } else { - /* not on subdivision, compute distance to previous subdivision, which - is just the modulus. - */ - - difference = mod; } if (the_beat.ticks < difference) {