Update
This commit is contained in:
@@ -188,11 +188,11 @@ impl BeatTracker {
|
||||
let mut prev = now - Duration::from_millis(dt as u64);
|
||||
|
||||
let period_millis = (period_length * MILLIS_PER_POINT) as u64;
|
||||
|
||||
|
||||
let period = Duration::from_millis(period_millis);
|
||||
|
||||
let mut next = prev + period;
|
||||
|
||||
|
||||
if let Some((_, old_next)) = self.current_beats {
|
||||
while next < old_next + Duration::from_millis(period_millis / 2) {
|
||||
prev += period;
|
||||
@@ -209,12 +209,16 @@ impl BeatTracker {
|
||||
|
||||
let (prev, next) = self.current_beats.unwrap();
|
||||
|
||||
let fractional = if prev < now {
|
||||
(now - prev).as_millis() as f64 / (next - prev).as_millis() as f64
|
||||
let mut relative_millis = if prev < now {
|
||||
(now - prev).as_millis() as f64
|
||||
} else {
|
||||
-1.0 * (prev - now).as_millis() as f64 / (next - prev).as_millis() as f64
|
||||
-1.0 * (prev - now).as_millis() as f64
|
||||
};
|
||||
|
||||
relative_millis += self.config.zero_crossing_beat_delay as f64;
|
||||
|
||||
let fractional = relative_millis / (next - prev).as_millis() as f64;
|
||||
|
||||
Some(self.beat_count as f64 + fractional)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user