13
0

Temporal: fix logic during ::get_grid that ignored if rounding did nothing

This commit is contained in:
Paul Davis 2020-12-05 23:04:00 -07:00
parent f1bb135013
commit a0b9030e3c

View File

@ -1583,7 +1583,15 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u
* in effect at that time.
*/
bbt = metric.meter().round_up_to_beat (bbt);
const BBT_Time new_bbt = metric.meter().round_up_to_beat (bbt);
if (new_bbt != bbt) {
bbt = new_bbt;
/* rounded up, determine new starting superclock position */
DEBUG_TRACE (DEBUG::TemporalMap, string_compose ("new bbt for start (rounded up) = %1\n", bbt));
for (Tempos::iterator tt = _tempos.begin(); tt != _tempos.end() && tt->sclock() < start; ++tt) { t = tt; }
for (Meters::iterator mm = _meters.begin(); mm != _meters.end() && mm->sclock() < start; ++mm) { m = mm; }
@ -1593,16 +1601,24 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u
metric = TempoMetric (*t, *m);
DEBUG_TRACE (DEBUG::TemporalMap, string_compose ("metric in effect at %1 = %2\n", start, metric));
/* recompute superclock position */
superclock_t new_start = metric.superclock_at (bbt);
DEBUG_TRACE (DEBUG::TemporalMap, string_compose ("metric says that %1 is at %2\n", bbt, new_start));
if (new_start < start) {
abort ();
}
start = new_start;
} else {
DEBUG_TRACE (DEBUG::TemporalMap, string_compose ("%1 was on a beat, no rounding up necessary\n", bbt));
}
} else {
/* this rounding cannot change the meter in effect, because it
@ -1616,6 +1632,8 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u
++bar.bars;
}
if (bar != bbt) {
bbt = bar;
for (Tempos::iterator tt = _tempos.begin(); tt != _tempos.end() && tt->bbt() < bbt; ++tt) { t = tt; }
@ -1630,6 +1648,10 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u
metric = TempoMetric (*t, *m);
start = metric.superclock_at (bbt);
} else {
DEBUG_TRACE (DEBUG::TemporalMap, string_compose ("%1 was on a bar, no round down to bar necessary\n", bbt));
}
}
/* advance t, m and b so that the point to the *next*