13
0

triggerbox: try to avoid tempo that results in fractional bar cnts

If minibpm's estimate of tempo implies that the clip has a duration measured in
fractional bars, use the estimate as a starting point to get to a tempo that
will lead to an integer number of bars (and quarters)
This commit is contained in:
Paul Davis 2021-12-15 14:58:03 -07:00
parent ed6121d76e
commit 1ecdc5c515

View File

@ -826,6 +826,14 @@ AudioTrigger::determine_tempo ()
const double quarters = (seconds / 60.) * _apparent_tempo;
_barcnt = quarters / metric.meter().divisions_per_bar();
if ((_apparent_tempo != 0.) && (rint (_barcnt) != _barcnt)) {
/* fractional barcnt */
int intquarters = floor (quarters);
double at = _apparent_tempo;
_apparent_tempo = intquarters / (seconds/60.);
DEBUG_TRACE (DEBUG::Triggers, string_compose ("adjusted barcnt of %1 and q = %2 to %3, old %4 new at = %5\n", _barcnt, quarters, intquarters, at, _apparent_tempo));
}
/* use initial tempo in map (assumed for now to be the only one */
const samplecnt_t one_bar = tm->bbt_duration_at (timepos_t (AudioTime), BBT_Offset (1, 0, 0)).samples();