Timeline types stage 1: make lightningbeam-core Beats/Seconds-typed
Type ClipInstance.timeline_start/timeline_duration/loop_before as Beats and thread Beats/Seconds through core so the compiler catches the seconds-vs-beats mismatches behind the audio-clip placement/drag/trim bugs. Fixes latent mixups surfaced by the types: - add/remove/split clip instance: the audio "effective duration" fallback was the content-seconds span treated as beats (clips stopped early off 60 BPM); now converted via the tempo map at the clip's start. - trim validation: extend-left/right clamped a content-seconds delta against a timeline-beats gap (and moved trim_start + timeline_start by the same raw amount, assuming 1:1). Now the gap is converted to content seconds and the timeline moves by the beats-equivalent. - split content-split point mixed beats into a seconds trim value. - set_keyframe: visibility-start fallback returned beats where seconds expected. - hit_test: timeline_time (s) compared against beats without conversion. Typed backend boundaries that were passing beats/seconds as bare f64: add_audio_clip (start/dur Beats, offset Seconds), move_clip/extend_clip (Beats), set_offset (Seconds). Command enum transport stays f64. Serialization is unchanged (Beats/Seconds are #[serde(transparent)]). lightningbeam-core builds; 299 core tests pass. The editor call sites (recording/drop/paste/drag placement) are updated in stage 2.
This commit is contained in:
@@ -159,7 +159,7 @@ mod tests {
|
||||
fn test_add_effect() {
|
||||
let (mut document, layer_id, def) = create_test_setup();
|
||||
|
||||
let instance = def.create_instance(0.0, 10.0);
|
||||
let instance = def.create_instance(daw_backend::Beats(0.0), daw_backend::Beats(10.0));
|
||||
let instance_id = instance.id;
|
||||
|
||||
let mut action = AddEffectAction::new(layer_id, instance);
|
||||
@@ -181,7 +181,7 @@ mod tests {
|
||||
fn test_add_effect_rollback() {
|
||||
let (mut document, layer_id, def) = create_test_setup();
|
||||
|
||||
let instance = def.create_instance(0.0, 10.0);
|
||||
let instance = def.create_instance(daw_backend::Beats(0.0), daw_backend::Beats(10.0));
|
||||
|
||||
let mut action = AddEffectAction::new(layer_id, instance);
|
||||
action.execute(&mut document).unwrap();
|
||||
@@ -201,19 +201,19 @@ mod tests {
|
||||
let (mut document, layer_id, def) = create_test_setup();
|
||||
|
||||
// Add first effect
|
||||
let instance1 = def.create_instance(0.0, 10.0);
|
||||
let instance1 = def.create_instance(daw_backend::Beats(0.0), daw_backend::Beats(10.0));
|
||||
let id1 = instance1.id;
|
||||
let mut action1 = AddEffectAction::new(layer_id, instance1);
|
||||
action1.execute(&mut document).unwrap();
|
||||
|
||||
// Add second effect
|
||||
let instance2 = def.create_instance(0.0, 10.0);
|
||||
let instance2 = def.create_instance(daw_backend::Beats(0.0), daw_backend::Beats(10.0));
|
||||
let id2 = instance2.id;
|
||||
let mut action2 = AddEffectAction::new(layer_id, instance2);
|
||||
action2.execute(&mut document).unwrap();
|
||||
|
||||
// Insert third effect at index 1 (between first and second)
|
||||
let instance3 = def.create_instance(0.0, 10.0);
|
||||
let instance3 = def.create_instance(daw_backend::Beats(0.0), daw_backend::Beats(10.0));
|
||||
let id3 = instance3.id;
|
||||
let mut action3 = AddEffectAction::at_index(layer_id, instance3, 1);
|
||||
action3.execute(&mut document).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user