mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
Fix bbt_subtract math
When r.ticks is already negative, add the negative value (not subtract), likewise handle negative beat offset correctly.
This commit is contained in:
parent
080bfdc2d0
commit
ab3a7dc721
1 changed files with 4 additions and 9 deletions
|
|
@ -327,18 +327,13 @@ Meter::bbt_subtract (Temporal::BBT_Time const & bbt, Temporal::BBT_Offset const
|
||||||
const int32_t tpg = ticks_per_grid ();
|
const int32_t tpg = ticks_per_grid ();
|
||||||
|
|
||||||
if (r.ticks < 0) {
|
if (r.ticks < 0) {
|
||||||
r.beats -= (r.ticks / tpg);
|
r.beats += floor ((double) r.ticks / tpg);
|
||||||
r.ticks = tpg + (r.ticks % Temporal::Beats::PPQN);
|
r.ticks = tpg + (r.ticks % Temporal::Beats::PPQN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r.beats < 0) {
|
if (r.beats <= 0) {
|
||||||
|
r.bars += floor ((r.beats - 1.0) / _divisions_per_bar);
|
||||||
r.beats += 1;
|
r.beats = _divisions_per_bar + (r.beats % _divisions_per_bar);
|
||||||
|
|
||||||
r.bars -= r.beats / _divisions_per_bar;
|
|
||||||
r.beats = r.beats % _divisions_per_bar;
|
|
||||||
|
|
||||||
r.beats -= 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r.bars <= 0) {
|
if (r.bars <= 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue