FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Show Parametric EQ in Effect Controls on linked A/V clips.
Vikram Bhaskaran995053922ed8
diff --git a/crates/engine/src/audio_effects_tests.rs b/crates/engine/src/audio_effects_tests.rsindex b85463e4c..e3992640a 100644--- a/crates/engine/src/audio_effects_tests.rs+++ b/crates/engine/src/audio_effects_tests.rs@@ -111,3 +111,19 @@ fn shared_names_resolve_by_track_kind() {let it = s.active_sequence().unwrap().find_item(ClipId(v)).unwrap().1.clone();assert!(it.effects.iter().any(|e| e.effect == "invert"));}++/// #696: applying an audio effect to the video side of an A/V pair lands on the linked audio.+#[test]+fn audio_effect_on_video_clip_applies_to_linked_audio() {+ let mut s = demo();+ let seq = s.active_sequence().unwrap();+ let v = seq.video_tracks[0].items[0].clone();+ let a = seq.audio_tracks[0].items.iter().find(|i| i.link == v.link).expect("linked audio").clone();+ let n0 = a.effects.len();+ s.execute("effects.apply", json!({"clips": [v.id.0], "effect": "parametric_eq"})).unwrap();+ let a = s.active_sequence().unwrap().find_item(a.id).unwrap().1.clone();+ let v = s.active_sequence().unwrap().find_item(v.id).unwrap().1.clone();+ assert_eq!(a.effects.len(), n0 + 1);+ assert_eq!(a.effects.last().unwrap().effect, "parametric_eq");+ assert!(v.effects.iter().all(|e| e.effect != "parametric_eq"), "EQ stays off the picture clip");+}diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rsindex 72a32cb8d..067ed2c7e 100644--- a/crates/engine/src/commands.rs+++ b/crates/engine/src/commands.rs@@ -411,6 +411,35 @@ pub(crate) fn slip_together(q: &mut filmcraft_project::Sequence, ctx: &mut edit:Ok(())}+/// Clips an audio effect should land on: audio ids as given, plus the linked audio of any video+/// clip in the list (so applying Parametric EQ to an A/V pair hits the sound).+pub fn audio_effect_targets(s: &Session, clips: &[ClipId]) -> Vec<ClipId> {+ let Some(seq) = s.active_sequence() else { return clips.to_vec() };+ let mut out = Vec::new();+ for c in clips {+ let Some((tid, it)) = seq.find_item(*c) else { continue };+ let kind = seq.track(tid).map(|t| t.kind);+ if kind == Some(TrackKind::Audio) {+ if !out.contains(c) {+ out.push(*c);+ }+ continue;+ }+ if kind != Some(TrackKind::Video) {+ continue;+ }+ let Some(link) = it.link else { continue };+ for t in &seq.audio_tracks {+ for i in &t.items {+ if i.link == Some(link) && !out.contains(&i.id) {+ out.push(i.id);+ }+ }+ }+ }+ out+}+/// Expand a clip selection with linked partners (when linked selection is on).pub fn with_links(s: &Session, clips: &[ClipId]) -> Vec<ClipId> {let Some(seq) = s.active_sequence() else { return clips.to_vec() };@@ -2558,6 +2587,12 @@ fn build() -> Vec<CommandSpec> {return Err(bad("effects.apply", "select clips first"));}let is_audio = def.kind == filmcraft_project::EffectKind::Audio;+ // Audio effects belong on audio clips. A video clip in an A/V pair is retargeted to+ // its linked audio so double-click / drop on the picture still applies Parametric EQ.+ let clips = if is_audio { audio_effect_targets(s, &clips) } else { clips };+ if clips.is_empty() {+ return Err(bad("effects.apply", "audio effects need an audio clip (or a video clip with linked audio)"));+ }let (fw, fh) = s.active_sequence().map(|q| (q.settings.width, q.settings.height)).unwrap_or((1920, 1080));let label = format!("Apply {}", def.name);s.edit_sequence(&label, |q, _, _| {diff --git a/crates/ui-egui/src/panels/effect_controls.rs b/crates/ui-egui/src/panels/effect_controls.rsindex 6b071c4ca..e83560506 100644--- a/crates/ui-egui/src/panels/effect_controls.rs+++ b/crates/ui-egui/src/panels/effect_controls.rs@@ -62,7 +62,8 @@ fn selected_clip(app: &FilmcraftApp) -> Option<(ClipId, TrackItem, TrackKind)> {selected_clips(app).into_iter().next()}-/// The selected clip (video first) and, for a video clip, the selected audio linked to it.+/// The selected clip (video first) and the audio linked to it when that audio is selected or+/// linked selection is on — so clip audio FX (Parametric EQ, Custom Setup) stay visible on A/V pairs.fn selected_clips(app: &FilmcraftApp) -> Vec<(ClipId, TrackItem, TrackKind)> {let Some(seq) = app.session.active_sequence() else { return Vec::new() };let picked: Vec<(ClipId, &TrackItem, TrackKind)> = app@@ -77,10 +78,19 @@ fn selected_clips(app: &FilmcraftApp) -> Vec<(ClipId, TrackItem, TrackKind)> {.collect();let Some(&(clip, it, kind)) = picked.iter().find(|p| p.2 == TrackKind::Video).or(picked.first()) else { return Vec::new() };let mut out = vec![(clip, it.clone(), kind)];- if kind == TrackKind::Video- && let Some(&(ac, ai, ak)) = picked.iter().find(|p| p.2 == TrackKind::Audio && p.1.link.is_some() && p.1.link == it.link)- {- out.push((ac, ai.clone(), ak));+ if kind == TrackKind::Video {+ let linked = picked.iter().find(|p| p.2 == TrackKind::Audio && p.1.link.is_some() && p.1.link == it.link).copied().or_else(|| {+ if !app.session.state.linked_selection {+ return None;+ }+ let link = it.link?;+ seq.audio_tracks.iter().find_map(|t| {+ t.items.iter().find(|i| i.link == Some(link)).map(|i| (i.id, i, TrackKind::Audio))+ })+ });+ if let Some((ac, ai, ak)) = linked {+ out.push((ac, ai.clone(), ak));+ }}out}diff --git a/crates/ui-egui/tests/clip_audio_ui.rs b/crates/ui-egui/tests/clip_audio_ui.rsindex 3ca87a33b..f7f401140 100644--- a/crates/ui-egui/tests/clip_audio_ui.rs+++ b/crates/ui-egui/tests/clip_audio_ui.rs@@ -143,6 +143,21 @@ fn effect_controls_show_the_audio_of_a_video_clip() {d.rect("effectControls.effect.motion");}+/// #696: Parametric EQ on a linked A/V pair shows in Effect Controls (and Custom Setup) while the+/// video clip is selected — Effect Controls used to keep only the picture clip.+#[test]+fn effect_controls_show_audio_fx_on_a_linked_pair() {+ let (mut d, pair) = Driver::demo(&["EffectControls"]);+ d.exec("timeline.select", json!({"clips": [pair.video]}));+ d.exec("effects.apply", json!({"clips": [pair.video], "effect": "parametric_eq"}));+ assert_eq!(d.item(pair.audio).effects.last().map(|e| e.effect.as_str()), Some("parametric_eq"));+ for fx in ["motion", "opacity", "time_remap", "volume", "channel_volume", "panner"] {+ d.click(&format!("effectControls.effect.{fx}"));+ }+ d.rect("effectControls.effect.parametric_eq");+ d.rect("effectControls.effect.parametric_eq.edit");+}+#[test]fn properties_show_the_audio_of_a_video_clip() {let (mut d, pair) = Driver::demo(&["Properties"]);