summaryrefslogtreecommitdiff
path: root/libs/ardour/tempo.cc
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-08-24 03:23:04 +1000
committernick_m <mainsbridge@gmail.com>2016-08-24 03:23:04 +1000
commit9a66e1e2c6e952bf1cc1b78e57d462467cc64cfa (patch)
tree074a322e16e7dfdf765a962a5e5c8d0bd83a32e4 /libs/ardour/tempo.cc
parent0a975eba29b6cd0b849e24e8d15e8454510357f8 (diff)
Round to bar correctly in TempoMap::exact_beat_at_frame_locked().
Diffstat (limited to 'libs/ardour/tempo.cc')
-rw-r--r--libs/ardour/tempo.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index d8db6a5616..35a19b13db 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -3071,8 +3071,18 @@ TempoMap::exact_beat_at_frame_locked (const Metrics& metrics, const framepos_t&
Timecode::BBT_Time bbt = bbt_at_beat_locked (metrics, beat);
bbt.beats = 1;
bbt.ticks = 0;
- beat = beat_at_bbt_locked (metrics, bbt);
+
+ const double prev_b = beat_at_bbt_locked (_metrics, bbt);
+ ++bbt.bars;
+ const double next_b = beat_at_bbt_locked (_metrics, bbt);
+
+ if ((beat - prev_b) > (next_b - prev_b) / 2.0) {
+ beat = next_b;
+ } else {
+ beat = prev_b;
+ }
}
+
return beat;
}