This commit is contained in:
2026-02-03 13:52:36 +01:00
parent 154cac6547
commit 726ea16e92
3 changed files with 3 additions and 49 deletions

View File

@@ -23,8 +23,6 @@ pub enum DispatchCommand {
Audio { cmd: String, time: Option<f64> },
Midi(MidiCommand),
FlushMidi,
Hush,
Panic,
}
impl Ord for TimedCommand {
@@ -152,12 +150,6 @@ fn dispatch_command(
}
}
}
DispatchCommand::Hush => {
let _ = audio_tx.load().try_send(AudioCommand::Hush);
}
DispatchCommand::Panic => {
let _ = audio_tx.load().try_send(AudioCommand::Panic);
}
}
}
@@ -170,15 +162,15 @@ mod tests {
let mut heap: BinaryHeap<TimedCommand> = BinaryHeap::new();
heap.push(TimedCommand {
command: DispatchCommand::Hush,
command: DispatchCommand::FlushMidi,
target_time_us: 300,
});
heap.push(TimedCommand {
command: DispatchCommand::Hush,
command: DispatchCommand::FlushMidi,
target_time_us: 100,
});
heap.push(TimedCommand {
command: DispatchCommand::Hush,
command: DispatchCommand::FlushMidi,
target_time_us: 200,
});

View File

@@ -86,10 +86,4 @@ impl LinkState {
self.link.capture_app_session_state(&mut state);
state
}
pub fn beat_at_time(&self, time_us: i64, quantum: f64) -> f64 {
let mut state = SessionState::new();
self.link.capture_app_session_state(&mut state);
state.beat_at_time(time_us, quantum)
}
}

View File

@@ -12,10 +12,6 @@ fn beats_to_micros(beats: f64, tempo: f64) -> SyncTime {
/// Timing boundary types for step and pattern scheduling.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StepTiming {
/// Fire at a specific absolute substep number.
Substep(u64),
/// Fire when any substep boundary is crossed (4 substeps per beat).
NextSubstep,
/// Fire when a beat boundary is crossed.
NextBeat,
/// Fire when a bar/quantum boundary is crossed.
@@ -29,18 +25,10 @@ impl StepTiming {
return false;
}
match self {
Self::NextSubstep => {
(prev_beat * 4.0).floor() as i64 != (curr_beat * 4.0).floor() as i64
}
Self::NextBeat => prev_beat.floor() as i64 != curr_beat.floor() as i64,
Self::NextBar => {
(prev_beat / quantum).floor() as i64 != (curr_beat / quantum).floor() as i64
}
Self::Substep(target) => {
let prev_substep = (prev_beat * 4.0).floor() as i64;
let curr_substep = (curr_beat * 4.0).floor() as i64;
prev_substep < *target as i64 && curr_substep >= *target as i64
}
}
}
}
@@ -85,16 +73,6 @@ mod tests {
assert_eq!(beats_to_micros(1.0, 0.0), 0);
}
#[test]
fn test_step_timing_substep_crossed() {
// Crossing from substep 0 to substep 1 (beat 0.0 to 0.26)
assert!(StepTiming::NextSubstep.crossed(0.0, 0.26, 4.0));
// Not crossing (both in same substep)
assert!(!StepTiming::NextSubstep.crossed(0.26, 0.27, 4.0));
// Negative prev_beat returns false
assert!(!StepTiming::NextSubstep.crossed(-1.0, 0.5, 4.0));
}
#[test]
fn test_step_timing_beat_crossed() {
// Crossing from beat 0 to beat 1
@@ -115,16 +93,6 @@ mod tests {
assert!(StepTiming::NextBar.crossed(7.9, 8.1, 8.0));
}
#[test]
fn test_step_timing_at_substep() {
// Crossing to substep 4 (beat 1.0)
assert!(StepTiming::Substep(4).crossed(0.9, 1.1, 4.0));
// Not yet at substep 4
assert!(!StepTiming::Substep(4).crossed(0.5, 0.9, 4.0));
// Already past substep 4
assert!(!StepTiming::Substep(4).crossed(1.5, 2.0, 4.0));
}
#[test]
fn test_substeps_crossed_normal() {
// One substep crossed at 1x speed