From d0fb7ae18a8e70b9d7fdea633112f2705ef747a4 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 22 Nov 2022 18:09:07 -0700 Subject: [PATCH] avoid duplicate BBT points in grid --- libs/temporal/tempo.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 4262ab7e03..5503c022b7 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -2146,14 +2146,20 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u do { const Temporal::Beats beats = metric.quarters_at_superclock (start); - if (bar_mod != 0) { - if (bbt.is_bar() && (bar_mod == 1 || ((bbt.bars % bar_mod == 0)))) { + /* It is possible we already added the current BBT + * point, so check to avoid doubling up + */ + + if (ret.back().bbt() != bbt) { + if (bar_mod != 0) { + if (bbt.is_bar() && (bar_mod == 1 || ((bbt.bars % bar_mod == 0)))) { + ret.push_back (TempoMapPoint (*this, metric, start, beats, bbt)); + DEBUG_TRACE (DEBUG::Grid, string_compose ("Gend %1\t %2\n", metric, ret.back())); + } + } else { ret.push_back (TempoMapPoint (*this, metric, start, beats, bbt)); DEBUG_TRACE (DEBUG::Grid, string_compose ("Gend %1\t %2\n", metric, ret.back())); } - } else { - ret.push_back (TempoMapPoint (*this, metric, start, beats, bbt)); - DEBUG_TRACE (DEBUG::Grid, string_compose ("Gend %1\t %2\n", metric, ret.back())); } start += step;