summaryrefslogtreecommitdiff
path: root/libs/ardour/tempo.cc
diff options
context:
space:
mode:
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;
}