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,26 +1583,42 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u
* in effect at that time. * 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);
for (Tempos::iterator tt = _tempos.begin(); tt != _tempos.end() && tt->sclock() < start; ++tt) { t = tt; } if (new_bbt != bbt) {
for (Meters::iterator mm = _meters.begin(); mm != _meters.end() && mm->sclock() < start; ++mm) { m = mm; }
for (MusicTimes::iterator bb = _bartimes.begin(); bb != _bartimes.end() && bb->sclock() < start; ++bb) { b = bb; }
/* reset metric */ bbt = new_bbt;
metric = TempoMetric (*t, *m); /* rounded up, determine new starting superclock position */
/* recompute superclock position */ DEBUG_TRACE (DEBUG::TemporalMap, string_compose ("new bbt for start (rounded up) = %1\n", bbt));
superclock_t new_start = metric.superclock_at (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; }
for (MusicTimes::iterator bb = _bartimes.begin(); bb != _bartimes.end() && bb->sclock() < start; ++bb) { b = bb; }
if (new_start < start) { /* reset metric */
abort ();
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));
} }
start = new_start;
} else { } else {
/* this rounding cannot change the meter in effect, because it /* this rounding cannot change the meter in effect, because it
@ -1616,20 +1632,26 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u
++bar.bars; ++bar.bars;
} }
bbt = bar; if (bar != bbt) {
for (Tempos::iterator tt = _tempos.begin(); tt != _tempos.end() && tt->bbt() < bbt; ++tt) { t = tt; } bbt = bar;
for (Meters::iterator mm = _meters.begin(); mm != _meters.end() && mm->bbt() < bbt; ++mm) { m = mm; }
for (MusicTimes::iterator bb = _bartimes.begin(); bb != _bartimes.end() && bb->bbt() < bbt; ++bb) { b = bb; }
/* t, m and b are now all iterators for the tempo, meter and for (Tempos::iterator tt = _tempos.begin(); tt != _tempos.end() && tt->bbt() < bbt; ++tt) { t = tt; }
* position markers BEFORE pos. b may be _bartimes.end(), but for (Meters::iterator mm = _meters.begin(); mm != _meters.end() && mm->bbt() < bbt; ++mm) { m = mm; }
* the other two are guaranteed to be valid references into for (MusicTimes::iterator bb = _bartimes.begin(); bb != _bartimes.end() && bb->bbt() < bbt; ++bb) { b = bb; }
* the tempos and meters
*/
metric = TempoMetric (*t, *m); /* t, m and b are now all iterators for the tempo, meter and
start = metric.superclock_at (bbt); * position markers BEFORE pos. b may be _bartimes.end(), but
* the other two are guaranteed to be valid references into
* the tempos and meters
*/
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* /* advance t, m and b so that the point to the *next*