Type the rest of the audio-controller boundary (no more bare-f64 wrapping)
Push Beats/Seconds through the remaining controller methods that took a bare f64 and let the audio thread wrap it in a newtype, so the caller's domain is now compiler-checked (the seam that hid the recording bug): - seek -> Seconds - set_trim_start/set_trim_end -> Seconds / Option<Seconds> (metatrack, always seconds) - add_midi_note, add_loaded_midi_clip, update_midi_clip_notes -> Beats - add_automation_point, remove_automation_point, automation_add_keyframe, automation_remove_keyframe -> Beats Command enums stay raw f64 transport; only the public signatures + call sites change. No behavior change — every caller already passed the right domain, this just makes it enforced. Two deliberate exceptions, documented in place: - trim_clip stays f64: the TrimClip handler interprets it as Seconds for a sampled-audio clip but Beats for a MIDI clip, so no single newtype fits; callers pass the clip's own trim value, which matches its content domain. - The piano-roll MIDI note model stays f64 internally (a beats-only subsystem with no seconds anywhere); it's converted to Beats at the update_midi_clip_notes boundary in UpdateMidiNotesAction, same as trim_start f64 -> Seconds at add_audio_clip.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
//! project scrub. Wired to the audio controller exactly like `TimelinePane`'s header.
|
||||
|
||||
use eframe::egui;
|
||||
use daw_backend::Seconds;
|
||||
|
||||
use super::{icons, Palette};
|
||||
use crate::panes::SharedPaneState;
|
||||
@@ -32,7 +33,7 @@ pub fn render(ui: &mut egui::Ui, rect: egui::Rect, shared: &mut SharedPaneState,
|
||||
if let Some(controller_arc) = shared.audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
if *shared.is_playing {
|
||||
controller.seek(*shared.playback_time);
|
||||
controller.seek(Seconds(*shared.playback_time));
|
||||
controller.play();
|
||||
} else {
|
||||
controller.pause();
|
||||
@@ -101,7 +102,7 @@ pub fn render(ui: &mut egui::Ui, rect: egui::Rect, shared: &mut SharedPaneState,
|
||||
*shared.playback_time = new_time;
|
||||
if let Some(controller_arc) = shared.audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.seek(new_time);
|
||||
controller.seek(Seconds(new_time));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ impl PianoRollPane {
|
||||
*shared.playback_time = nt;
|
||||
if let Some(ctrl) = shared.audio_controller.as_ref() {
|
||||
if let Ok(mut c) = ctrl.lock() {
|
||||
c.seek(nt);
|
||||
c.seek(Seconds(nt));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1764,7 +1764,7 @@ impl PianoRollPane {
|
||||
let seek_time = snap_to_value(time.max(0.0), self.snap_value, tempo_map);
|
||||
*shared.playback_time = seek_time;
|
||||
if let Some(ctrl) = shared.audio_controller.as_ref() {
|
||||
if let Ok(mut c) = ctrl.lock() { c.seek(seek_time); }
|
||||
if let Ok(mut c) = ctrl.lock() { c.seek(Seconds(seek_time)); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1110,7 +1110,7 @@ impl TimelinePane {
|
||||
|
||||
if let Some(controller_arc) = shared.audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.seek(seek_to);
|
||||
controller.seek(Seconds(seek_to));
|
||||
controller.set_metronome_enabled(true);
|
||||
if !*shared.is_playing {
|
||||
controller.play();
|
||||
@@ -5006,7 +5006,7 @@ impl TimelinePane {
|
||||
*playback_time = kf_time;
|
||||
if let Some(controller_arc) = audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.seek(kf_time);
|
||||
controller.seek(Seconds(kf_time));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5034,7 +5034,7 @@ impl TimelinePane {
|
||||
// Seek immediately so it works while playing
|
||||
if let Some(controller_arc) = audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.seek(new_time);
|
||||
controller.seek(Seconds(new_time));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5046,7 +5046,7 @@ impl TimelinePane {
|
||||
*playback_time = new_time;
|
||||
if let Some(controller_arc) = audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.seek(new_time);
|
||||
controller.seek(Seconds(new_time));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5206,7 +5206,7 @@ impl PaneRenderer for TimelinePane {
|
||||
*shared.playback_time = 0.0;
|
||||
if let Some(controller_arc) = shared.audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.seek(0.0);
|
||||
controller.seek(Seconds(0.0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5215,7 +5215,7 @@ impl PaneRenderer for TimelinePane {
|
||||
*shared.playback_time = (*shared.playback_time - 0.1).max(0.0);
|
||||
if let Some(controller_arc) = shared.audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.seek(*shared.playback_time);
|
||||
controller.seek(Seconds(*shared.playback_time));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5251,7 +5251,7 @@ impl PaneRenderer for TimelinePane {
|
||||
*shared.playback_time = (*shared.playback_time + 0.1).min(self.duration);
|
||||
if let Some(controller_arc) = shared.audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.seek(*shared.playback_time);
|
||||
controller.seek(Seconds(*shared.playback_time));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5260,7 +5260,7 @@ impl PaneRenderer for TimelinePane {
|
||||
*shared.playback_time = self.duration;
|
||||
if let Some(controller_arc) = shared.audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.seek(self.duration);
|
||||
controller.seek(Seconds(self.duration));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5692,7 +5692,7 @@ impl PaneRenderer for TimelinePane {
|
||||
self.automation_cache.remove(&layer_id);
|
||||
} else if let Some(&track_id) = shared.layer_to_track_map.get(&layer_id) {
|
||||
// time is already in beats (all automation x-axes use beats)
|
||||
controller.automation_add_keyframe(track_id, node_id, time, value, "linear".to_string(), (0.0, 0.0), (0.0, 0.0));
|
||||
controller.automation_add_keyframe(track_id, node_id, Beats(time), value, "linear".to_string(), (0.0, 0.0), (0.0, 0.0));
|
||||
// Optimistic cache update (beats)
|
||||
if let Some(lanes) = self.automation_cache.get_mut(&layer_id) {
|
||||
if let Some(lane) = lanes.iter_mut().find(|l| l.node_id == node_id) {
|
||||
@@ -5740,8 +5740,8 @@ impl PaneRenderer for TimelinePane {
|
||||
self.automation_cache.remove(&layer_id);
|
||||
} else if let Some(&track_id) = shared.layer_to_track_map.get(&layer_id) {
|
||||
// old_time / new_time are already in beats
|
||||
controller.automation_remove_keyframe(track_id, node_id, old_time);
|
||||
controller.automation_add_keyframe(track_id, node_id, new_time, new_value, interpolation.clone(), ease_out, ease_in);
|
||||
controller.automation_remove_keyframe(track_id, node_id, Beats(old_time));
|
||||
controller.automation_add_keyframe(track_id, node_id, Beats(new_time), new_value, interpolation.clone(), ease_out, ease_in);
|
||||
// Optimistic cache update (beats)
|
||||
if let Some(lanes) = self.automation_cache.get_mut(&layer_id) {
|
||||
if let Some(lane) = lanes.iter_mut().find(|l| l.node_id == node_id) {
|
||||
@@ -5769,7 +5769,7 @@ impl PaneRenderer for TimelinePane {
|
||||
}
|
||||
} else if let Some(&track_id) = shared.layer_to_track_map.get(&layer_id) {
|
||||
// time is already in beats
|
||||
controller.automation_remove_keyframe(track_id, node_id, time);
|
||||
controller.automation_remove_keyframe(track_id, node_id, Beats(time));
|
||||
// Optimistic cache update (beats)
|
||||
if let Some(lanes) = self.automation_cache.get_mut(&layer_id) {
|
||||
if let Some(lane) = lanes.iter_mut().find(|l| l.node_id == node_id) {
|
||||
|
||||
Reference in New Issue
Block a user