From eccfc1db1088a787c42eda838f39b44b40f73f27 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 7 Jan 2021 16:31:30 -0700 Subject: [PATCH] libtemporal: fix grid generation if we pass additional markers before reaching the end --- libs/temporal/tempo.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 9e3b19d1fa..faea80500e 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -1801,7 +1801,27 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u limit = end; } - if (start >= limit) { + if (start >= end) { + break; + } + + if (start >= limit && nxt_t == _tempos.end() && nxt_m == _meters.end() && nxt_b == _bartimes.end()) { + + /* reached the end, no more tempos, meters or bartimes + to consider, so just finish up. + */ + + const superclock_t step = metric.superclocks_per_grid_at (start); + + while (start < end) { + const Temporal::Beats beats = metric.quarters_at_superclock (start); + ret.push_back (TempoMapPoint (*this, metric, start, beats, bbt)); + DEBUG_TRACE (DEBUG::Grid, string_compose ("G %1\t %2\n", metric, ret.back())); + start += step; + bbt = metric.bbt_at (start); + } + + /* all done, leave outer loop */ break; }