mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 19:56:31 +01:00
temporal: new non-iterative implementation of Meter::bbt_delta()
This commit is contained in:
parent
b4ca9f2f38
commit
d6e331fe6c
1 changed files with 10 additions and 28 deletions
|
|
@ -360,50 +360,32 @@ Meter::bbt_delta (BBT_Time const & later, BBT_Time const & earlier) const
|
||||||
|
|
||||||
assert (later > earlier);
|
assert (later > earlier);
|
||||||
|
|
||||||
#if 0 // more efficient but broken
|
#if 1 // more efficient than iterative method below
|
||||||
|
|
||||||
BBT_Offset d;
|
BBT_Offset d;
|
||||||
BBT_Time a (earlier);
|
BBT_Time a (earlier);
|
||||||
BBT_Time b (later);
|
BBT_Time b (later);
|
||||||
|
|
||||||
if (a.ticks == ticks_per_grid()) {
|
if (a.ticks > b.ticks) {
|
||||||
|
d.ticks = b.ticks + (ticks_per_grid() - a.ticks);
|
||||||
/* Next tick is the next beat */
|
|
||||||
|
|
||||||
a.beats++;
|
|
||||||
d.beats++;
|
|
||||||
|
|
||||||
if (a.beats == _divisions_per_bar) {
|
if (a.beats == _divisions_per_bar) {
|
||||||
a.beats = 1;
|
a.beats = 1;
|
||||||
a.bars++;
|
a.bars++;
|
||||||
d.bars++;
|
} else {
|
||||||
|
a.beats++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
d.ticks = b.ticks - a.ticks;
|
||||||
/* tick delta is just the remainder to the next beat */
|
|
||||||
|
|
||||||
d.ticks = ticks_per_grid() - earlier.ticks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a.beats == _divisions_per_bar) {
|
if (a.beats > b.beats) {
|
||||||
|
d.beats = b.beats + (_divisions_per_bar - a.beats);
|
||||||
/* next beat is the next bar */
|
|
||||||
|
|
||||||
|
|
||||||
a.beats = 1;
|
|
||||||
a.bars++;
|
a.bars++;
|
||||||
d.bars++;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
d.beats = b.beats - a.beats;
|
||||||
/* beat delta is just the remainder to the next bar */
|
|
||||||
|
|
||||||
d.beats = _divisions_per_bar - earlier.beats;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count bars */
|
d.bars = b.bars - a.bars;
|
||||||
|
|
||||||
d.bars = b.bars - a.bars;
|
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue