Skip to content

Commit

Permalink
Unpause on first beat after tap-in
Browse files Browse the repository at this point in the history
Before this patch it unpaused on the fourth tap, which is counter
intuitive.

Signed-off-by: Petr Horacek <petr@zlosynth.com>
  • Loading branch information
phoracek committed Nov 17, 2023
1 parent 978989c commit f819114
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions control/src/cache/interval_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct IntervalDetector {
trigger_age: [u32; 3],
pub tempo: Option<u32>,
pub just_detected: bool,
pub first_beat_after_detection: bool,
}

impl IntervalDetector {
Expand Down Expand Up @@ -51,6 +52,10 @@ impl IntervalDetector {
*x = x.saturating_add(1);
}
self.just_detected = false;

if let Some(tempo) = self.tempo {
self.first_beat_after_detection = self.trigger_age[2] == tempo;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion control/src/cache/reconcile/speed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Store {
self.cache.requests.reset_impulse =
just_triggered_clock || just_triggered_tap || just_triggered_position_reset;

if just_triggered_tap {
if self.cache.tap_detector.first_beat_after_detection() {
self.cache.attributes.paused_delay = false;
self.cache.display.reset_paused();
}
Expand Down
3 changes: 3 additions & 0 deletions control/src/cache/tap_clock_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ impl TapClockDetector {
pub fn detected_tempo(&self) -> Option<u32> {
self.detector.tempo
}
pub fn first_beat_after_detection(&self) -> bool {
self.detector.first_beat_after_detection
}
}

0 comments on commit f819114

Please sign in to comment.