This commit is contained in:
2026-02-03 13:52:36 +01:00
parent e337eb35e7
commit 9ff024cf9b
3 changed files with 3 additions and 49 deletions

View File

@@ -23,8 +23,6 @@ pub enum DispatchCommand {
Audio { cmd: String, time: Option<f64> }, Audio { cmd: String, time: Option<f64> },
Midi(MidiCommand), Midi(MidiCommand),
FlushMidi, FlushMidi,
Hush,
Panic,
} }
impl Ord for TimedCommand { 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(); let mut heap: BinaryHeap<TimedCommand> = BinaryHeap::new();
heap.push(TimedCommand { heap.push(TimedCommand {
command: DispatchCommand::Hush, command: DispatchCommand::FlushMidi,
target_time_us: 300, target_time_us: 300,
}); });
heap.push(TimedCommand { heap.push(TimedCommand {
command: DispatchCommand::Hush, command: DispatchCommand::FlushMidi,
target_time_us: 100, target_time_us: 100,
}); });
heap.push(TimedCommand { heap.push(TimedCommand {
command: DispatchCommand::Hush, command: DispatchCommand::FlushMidi,
target_time_us: 200, target_time_us: 200,
}); });

View File

@@ -86,10 +86,4 @@ impl LinkState {
self.link.capture_app_session_state(&mut state); self.link.capture_app_session_state(&mut state);
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. /// Timing boundary types for step and pattern scheduling.
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StepTiming { 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. /// Fire when a beat boundary is crossed.
NextBeat, NextBeat,
/// Fire when a bar/quantum boundary is crossed. /// Fire when a bar/quantum boundary is crossed.
@@ -29,18 +25,10 @@ impl StepTiming {
return false; return false;
} }
match self { 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::NextBeat => prev_beat.floor() as i64 != curr_beat.floor() as i64,
Self::NextBar => { Self::NextBar => {
(prev_beat / quantum).floor() as i64 != (curr_beat / quantum).floor() as i64 (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); 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] #[test]
fn test_step_timing_beat_crossed() { fn test_step_timing_beat_crossed() {
// Crossing from beat 0 to beat 1 // Crossing from beat 0 to beat 1
@@ -115,16 +93,6 @@ mod tests {
assert!(StepTiming::NextBar.crossed(7.9, 8.1, 8.0)); 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] #[test]
fn test_substeps_crossed_normal() { fn test_substeps_crossed_normal() {
// One substep crossed at 1x speed // One substep crossed at 1x speed