Fix recording start position: pass beats, not seconds, to the backend
The reported bug (a second recording lands early and overlaps the first) survived the timeline type refactor: start_recording/create_midi_clip/ start_midi_recording took f64 and wrapped Beats(x) internally, so the type boundary stopped at the method and the timeline handed them *shared.playback_time (seconds). At 120 BPM a 5s playhead (=10 beats) was recorded at beat 5 = 2.5s. Type all three backend methods to take Beats so the caller must convert; the timeline now converts the seconds playhead once (start_beats) and passes it to every recording command and the placeholder clip. TUI debug caller updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
0050c18623
commit
b5766672ee
@@ -1127,6 +1127,9 @@ impl TimelinePane {
|
||||
|
||||
shared.recording_layer_ids.clear();
|
||||
|
||||
// The backend records in the beats domain; start_time is the seconds playhead.
|
||||
let start_beats = shared.action_executor.document().tempo_map().seconds_to_beats(Seconds(start_time));
|
||||
|
||||
// Step 4: Dispatch recording for each candidate
|
||||
for &(layer_id, ref cat, _) in &candidates {
|
||||
match cat {
|
||||
@@ -1150,7 +1153,7 @@ impl TimelinePane {
|
||||
}
|
||||
if let Some(controller_arc) = shared.audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.start_recording(track_id, start_time);
|
||||
controller.start_recording(track_id, start_beats);
|
||||
println!("🎤 Started audio recording on track {:?} at {:.2}s", track_id, start_time);
|
||||
}
|
||||
shared.recording_layer_ids.push(layer_id);
|
||||
@@ -1162,8 +1165,8 @@ impl TimelinePane {
|
||||
if let Some(&track_id) = shared.layer_to_track_map.get(&layer_id) {
|
||||
if let Some(controller_arc) = shared.audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
let clip_id = controller.create_midi_clip(track_id, start_time, 0.0);
|
||||
controller.start_midi_recording(track_id, clip_id, start_time);
|
||||
let clip_id = controller.create_midi_clip(track_id, start_beats, Beats::ZERO);
|
||||
controller.start_midi_recording(track_id, clip_id, start_beats);
|
||||
shared.recording_clips.insert(layer_id, clip_id);
|
||||
println!("🎹 Started MIDI recording on track {:?} at {:.2}s, clip_id={}",
|
||||
track_id, start_time, clip_id);
|
||||
@@ -1174,8 +1177,6 @@ impl TimelinePane {
|
||||
*shared.recording_clips.get(&layer_id).unwrap_or(&0), daw_backend::Beats::ZERO);
|
||||
let doc_clip_id = shared.action_executor.document_mut().add_audio_clip(doc_clip);
|
||||
|
||||
let start_beats = shared.action_executor.document().tempo_map()
|
||||
.seconds_to_beats(Seconds(start_time));
|
||||
let clip_instance = ClipInstance::new(doc_clip_id)
|
||||
.with_timeline_start(start_beats);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user