13
0

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

View File

@ -64,9 +64,9 @@ BBT_Time::round_up_to_beat_div (int beat_div) const
an integer beat position (think triplets. an integer beat position (think triplets.
*/ */
int32_t div_ticks = ticks_per_beat / beat_div; const int32_t div_ticks = ticks_per_beat / beat_div;
int32_t ticks_remainder = ticks % div_ticks; int32_t rounded_up = ticks + div_ticks - 1;
int32_t rounded_up = ticks + div_ticks - ticks_remainder; rounded_up -= rounded_up % div_ticks;
if (rounded_up == ticks_per_beat) { if (rounded_up == ticks_per_beat) {
return BBT_Time (bars, beats+1, 0); return BBT_Time (bars, beats+1, 0);