fix BBT_Time::round_up_to_beat_div() (partially)

Math is now correct for cases where "beats" in BBT are quarters.
Incorrect for others
This commit is contained in:
Paul Davis 2023-09-22 22:54:37 -06:00
parent 44d32d6325
commit 14e7f62891
1 changed files with 4 additions and 4 deletions

View File

@ -59,14 +59,14 @@ BBT_Time::round_up_to_bar() const
BBT_Time
BBT_Time::round_up_to_beat_div (int beat_div) const
{
/* XXX this doesn't work where "beats" are not quarters, because
/* XXX this doesn't work where "beats" are not quarters, because
we could have B|b|0 and this is not on a beat_div, even though it is
an integer beat position (think triplets.
*/
int32_t div_ticks = ticks_per_beat / beat_div;
int32_t ticks_remainder = ticks % div_ticks;
int32_t rounded_up = ticks + div_ticks - ticks_remainder;
const int32_t div_ticks = ticks_per_beat / beat_div;
int32_t rounded_up = ticks + div_ticks - 1;
rounded_up -= rounded_up % div_ticks;
if (rounded_up == ticks_per_beat) {
return BBT_Time (bars, beats+1, 0);