This commit is contained in:
2021-11-13 12:22:41 +01:00
parent 2014e03a15
commit 035405bfcc
9 changed files with 169 additions and 29 deletions

View File

@@ -182,7 +182,11 @@ impl BeatTracker {
if let Some((period_length, crossing)) = self.get_correlation_data() {
let last_update_timestamp = self.audio_capture_thread.get_last_update();
let mut dt = (now - last_update_timestamp).as_millis() as i64;
let mut dt = if now > last_update_timestamp {
(now - last_update_timestamp).as_millis() as i64
} else {
-1 * (last_update_timestamp - now).as_millis() as i64
};
dt += ((POINT_BUFFER_SIZE - crossing) * MILLIS_PER_POINT) as i64;
let mut prev = now - Duration::from_millis(dt as u64);