13
0

use a simpler (and likely correct) round-to-nearest-bar implementation

git-svn-id: svn://localhost/ardour2/branches/3.0@6119 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2009-11-18 14:40:46 +00:00
parent 51bdbf6925
commit 0f313672f5

View File

@ -1235,25 +1235,25 @@ TempoMap::round_to_type (nframes64_t frame, int dir, BBTPointType type)
/* "true" rounding */
/* round to nearest beat */
if (bbt.ticks >= (Meter::ticks_per_beat/2)) {
try {
bbt = bbt_add (bbt, one_beat, metric);
}
catch (...) {
return frame;
}
}
float midbar_beats;
float midbar_ticks;
/* round to nearest bar */
if (bbt.beats >= metric.meter().beats_per_bar()/2) {
try {
bbt = bbt_add (bbt, one_bar, metric);
}
catch (...) {
return frame;
}
}
midbar_beats = metric.meter().beats_per_bar() / 2;
midbar_ticks = Meter::ticks_per_beat * fmod (midbar_beats, 1.0f);
midbar_beats = floor (midbar_beats);
BBT_Time midbar (bbt.bars, lrintf (midbar_beats), lrintf (midbar_ticks));
if (bbt < midbar) {
/* round down */
bbt.beats = 1;
bbt.ticks = 0;
} else {
/* round up */
bbt.bars++;
bbt.beats = 1;
bbt.ticks = 0;
}
}
/* force beats & ticks to their values at the start of a bar */
bbt.beats = 1;