Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

M7.7: ui: Clip/Track Fx Editor windows (Parametric EQ, Graphic EQ 10/20/30, Multiband Compressor, Dynamics), folder submenus

Brandon Thomas8961f2eab94a
diff --git a/crates/ui-egui/src/panels/audio_fx_editor.rs b/crates/ui-egui/src/panels/audio_fx_editor.rs
new file mode 100644
index 000000000..b5a7c705b
--- /dev/null
+++ b/crates/ui-egui/src/panels/audio_fx_editor.rs
@@ -0,0 +1,546 @@
+//! Clip / Track Fx Editor windows: graphical editors for the audio effects that need one
+//! (Parametric Equalizer curve, Graphic Equalizer 10/20/30 bands, Multiband Compressor,
+//! Dynamics). Opened from Effect Controls ("Custom Setup ▸ Edit…") and from a track's effect
+//! slot in the Audio Track Mixer.
+//!
+//! Curves are computed by the real DSP (`render::audio_fx::configured` →
+//! `AudioEffect::response_db` / `transfer_db`), so what is drawn is what is heard. Drags preview
+//! locally and commit one `effects.setParam` / `mixer.setInsert` on release (one undo step).
+//!
+//! Automation ids (`<fx>` = effect id): `fxEditor.<fx>.plot`, `fxEditor.<fx>.node.<band>` (EQ
+//! nodes: hp, low, b1, b2, mid, b4, b5, high, lp), `fxEditor.<fx>.toggle.<param>` (on/off,
+//! solo, bypass…), `fxEditor.<fx>.param.<param>` (sliders), `fxEditor.<fx>.xo1…3` (crossover
+//! handles), `fxEditor.<fx>.reset`, `fxEditor.<fx>.close`.
+
+use std::collections::HashMap;
+
+use egui::{Align2, Color32, Pos2, Rect, Sense, Stroke, pos2, vec2};
+use filmcraft_project::{ClipId, EffectInstance, ParamKind, ParamValue, TrackId};
+use filmcraft_time::Tick;
+use serde::{Deserialize, Serialize};
+use serde_json::{Value, json};
+
+use crate::FilmcraftApp;
+use crate::theme::Tokens;
+
+/// What an editor window edits.
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
+pub enum FxTarget {
+ /// Clip effect `index` of clip `clip` (Clip Fx Editor).
+ Clip { clip: u64, index: usize },
+ /// Insert `slot` of mixer strip `strip` (track id; Track Fx Editor).
+ Insert { strip: u64, slot: usize },
+}
+
+/// Effects that have a graphical editor.
+pub fn has_editor(effect: &str) -> bool {
+ matches!(effect, "parametric_eq" | "graphic_eq" | "graphic_eq_20" | "graphic_eq_30" | "multiband_compressor" | "dynamics_rack")
+}
+
+/// Open (or raise) the editor for a target.
+pub fn open(app: &mut FilmcraftApp, target: FxTarget) {
+ if !app.ui.audio_fx_editors.contains(&target) {
+ app.ui.audio_fx_editors.push(target);
+ }
+}
+
+/// The edited effect instance (current project state), its media time at the playhead, and a
+/// display label.
+fn resolve(app: &FilmcraftApp, target: &FxTarget) -> Option<(EffectInstance, Tick, String)> {
+ let seq = app.session.active_sequence()?;
+ let ph = app.session.playhead();
+ match target {
+ FxTarget::Clip { clip, index } => {
+ let (tid, it) = seq.find_item(ClipId(*clip))?;
+ let e = it.effects.get(*index)?.clone();
+ let track = seq.track(tid).map(|t| t.name.clone()).unwrap_or_default();
+ let mt = it.source_time_at(ph.clamp(it.start, it.end() - Tick(1)));
+ Some((e, mt, format!("{track}, {}", it.name)))
+ }
+ FxTarget::Insert { strip, slot } => {
+ let tr = seq.strip(TrackId(*strip))?;
+ let e = tr.effects.get(*slot)?.clone();
+ Some((e, ph, tr.name.clone()))
+ }
+ }
+}
+
+fn key(target: &FxTarget) -> String {
+ match target {
+ FxTarget::Clip { clip, index } => format!("clip-{clip}-{index}"),
+ FxTarget::Insert { strip, slot } => format!("insert-{strip}-{slot}"),
+ }
+}
+
+/// Command that sets one parameter on the target.
+fn set_cmd(target: &FxTarget, pid: &str, v: Value) -> (String, Value) {
+ match target {
+ FxTarget::Clip { clip, index } => ("effects.setParam".into(), json!({"clip": clip, "effect": index, "param": pid, "value": v})),
+ FxTarget::Insert { strip, slot } => ("mixer.setInsert".into(), json!({"strip": strip, "slot": slot, "params": {pid: v}})),
+ }
+}
+
+/// Per-window editing context.
+struct Ed<'a> {
+ t: Tokens,
+ fx: &'a str,
+ target: &'a FxTarget,
+ inst: EffectInstance,
+ mt: Tick,
+ /// Uncommitted values (live drags), by parameter id.
+ drafts: HashMap<String, f64>,
+ acts: Vec<(String, Value)>,
+ autos: Vec<(String, Rect, String)>,
+}
+
+impl Ed<'_> {
+ fn v(&self, pid: &str) -> f64 {
+ self.drafts.get(pid).copied().unwrap_or_else(|| self.inst.f64_at(pid, self.mt))
+ }
+ fn on(&self, pid: &str) -> bool {
+ self.v(pid) >= 0.5
+ }
+ fn range(&self, pid: &str) -> (f64, f64, &'static str) {
+ match self.inst.def().and_then(|d| d.param(pid)).map(|p| &p.kind) {
+ Some(ParamKind::Float { min, max, unit, .. }) => (*min, *max, unit),
+ _ => (0.0, 1.0, ""),
+ }
+ }
+ fn commit(&mut self, pid: &str, v: f64) {
+ let is_bool = matches!(self.inst.def().and_then(|d| d.param(pid)).map(|p| &p.kind), Some(ParamKind::Bool));
+ let val = if is_bool { json!(v >= 0.5) } else { json!(v) };
+ self.acts.push(set_cmd(self.target, pid, val));
+ // keep showing the new value until the project catches up this frame
+ self.drafts.insert(pid.to_string(), v);
+ }
+ fn auto(&mut self, id: String, r: Rect, label: &str) {
+ self.autos.push((id, r, label.to_string()));
+ }
+ /// The effect as currently edited (drafts applied), for curve evaluation.
+ fn preview(&self) -> EffectInstance {
+ let mut e = self.inst.clone();
+ for (k, v) in &self.drafts {
+ if let Some(p) = e.params.get_mut(k) {
+ p.keyframes.clear();
+ p.value = match p.value {
+ ParamValue::Bool(_) => ParamValue::Bool(*v >= 0.5),
+ ParamValue::Choice(_) => ParamValue::Choice(*v as u32),
+ _ => ParamValue::Float(*v),
+ };
+ } else if let Some(d) = e.def().and_then(|d| d.param(k)) {
+ let mut p = filmcraft_project::Param::new(d.default.clone());
+ p.value = ParamValue::Float(*v);
+ e.params.insert(k.clone(), p);
+ }
+ }
+ e
+ }
+ /// A labelled slider; drags preview, release commits.
+ fn slider(&mut self, ui: &mut egui::Ui, pid: &str, label: &str, log: bool) {
+ let (min, max, unit) = self.range(pid);
+ let mut v = self.v(pid);
+ let r = ui.add(egui::Slider::new(&mut v, min..=max).text(format!("{label} {unit}").trim().to_string()).logarithmic(log && min > 0.0).max_decimals(2));
+ self.auto(format!("fxEditor.{}.param.{pid}", self.fx), r.rect, label);
+ if r.dragged() {
+ self.drafts.insert(pid.to_string(), v);
+ }
+ if r.drag_stopped() || (r.changed() && !r.dragged()) {
+ self.commit(pid, v);
+ }
+ }
+ /// A toggle button for a Bool parameter.
+ fn toggle(&mut self, ui: &mut egui::Ui, pid: &str, label: &str) {
+ let on = self.on(pid);
+ let r = ui.selectable_label(on, label);
+ self.auto(format!("fxEditor.{}.toggle.{pid}", self.fx), r.rect, label);
+ if r.clicked() {
+ self.commit(pid, if on { 0.0 } else { 1.0 });
+ }
+ }
+}
+
+/// Show every open editor window.
+pub fn show(app: &mut FilmcraftApp, ctx: &egui::Context) {
+ let targets = app.ui.audio_fx_editors.clone();
+ let mut close = Vec::new();
+ for target in targets {
+ let Some((inst, mt, place)) = resolve(app, &target) else {
+ close.push(target);
+ continue;
+ };
+ if !has_editor(&inst.effect) {
+ close.push(target);
+ continue;
+ }
+ let name = inst.def().map(|d| d.name).unwrap_or("Effect");
+ let kind = if matches!(target, FxTarget::Clip { .. }) { "Clip Fx Editor" } else { "Track Fx Editor" };
+ let title = format!("{kind} - {name}: {place}");
+ let k = key(&target);
+ let drafts_id = egui::Id::new(("fx-editor-drafts", &k));
+ let drafts: HashMap<String, f64> = ctx.data(|d| d.get_temp(drafts_id)).unwrap_or_default();
+ let fx_id = inst.effect.clone();
+ let mut ed = Ed { t: app.tokens, fx: &fx_id, target: &target, inst, mt, drafts, acts: Vec::new(), autos: Vec::new() };
+ let mut open = true;
+ let mut closed = false;
+ egui::Window::new(title).id(egui::Id::new(("fx-editor", &k))).open(&mut open).collapsible(false).resizable(false).show(ctx, |ui| {
+ match ed.fx {
+ "parametric_eq" => parametric(ui, &mut ed),
+ "graphic_eq" | "graphic_eq_20" | "graphic_eq_30" => graphic(ui, &mut ed),
+ "multiband_compressor" => multiband(ui, &mut ed),
+ _ => dynamics(ui, &mut ed),
+ }
+ ui.separator();
+ ui.horizontal(|ui| {
+ let r = ui.button("Close");
+ ed.auto(format!("fxEditor.{}.close", ed.fx), r.rect, "Close");
+ if r.clicked() {
+ closed = true;
+ }
+ });
+ });
+ // drafts that were committed are dropped once the project shows them
+ let committed: Vec<String> = ed
+ .acts
+ .iter()
+ .filter_map(|(_, p)| {
+ p.get("param")
+ .and_then(Value::as_str)
+ .map(str::to_string)
+ .or_else(|| p.get("params").and_then(Value::as_object).and_then(|o| o.keys().next().cloned()))
+ })
+ .collect();
+ let mut keep = ed.drafts.clone();
+ for c in &committed {
+ keep.remove(c);
+ }
+ ctx.data_mut(|d| d.insert_temp(drafts_id, keep));
+ for (id, r, label) in std::mem::take(&mut ed.autos) {
+ app.auto.add(&id, r, &label);
+ }
+ for (cmd, p) in std::mem::take(&mut ed.acts) {
+ if let Err(e) = app.session.execute(&cmd, p) {
+ app.ui.status = e.to_string();
+ }
+ }
+ if !open || closed {
+ close.push(target);
+ }
+ }
+ app.ui.audio_fx_editors.retain(|t| !close.contains(t));
+}
+
+// ------------------------------------------------------------------------------- plotting
+
+const F_MIN: f64 = 20.0;
+const F_MAX: f64 = 20000.0;
+
+fn fx_of(x: f32, r: Rect) -> f64 {
+ let u = ((x - r.min.x) / r.width()).clamp(0.0, 1.0) as f64;
+ F_MIN * (F_MAX / F_MIN).powf(u)
+}
+fn x_of(f: f64, r: Rect) -> f32 {
+ r.min.x + ((f.clamp(F_MIN, F_MAX) / F_MIN).ln() / (F_MAX / F_MIN).ln()) as f32 * r.width()
+}
+fn y_of(db: f64, r: Rect, range: f64) -> f32 {
+ r.center().y - (db.clamp(-range, range) / range) as f32 * r.height() * 0.5
+}
+fn db_of(y: f32, r: Rect, range: f64) -> f64 {
+ ((r.center().y - y) / (r.height() * 0.5)) as f64 * range
+}
+
+/// Frequency-response plot with a log-frequency grid; returns the plot rect and response.
+fn response_plot(ui: &mut egui::Ui, ed: &mut Ed, size: egui::Vec2, range: f64) -> (Rect, egui::Response) {
+ let (r, resp) = ui.allocate_exact_size(size, Sense::click_and_drag());
+ let p = ui.painter_at(r);
+ let t = &ed.t;
+ p.rect_filled(r, 2.0, Color32::from_gray(0x18));
+ for f in [50.0, 100.0, 200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0] {
+ let x = x_of(f, r);
+ p.line_segment([pos2(x, r.min.y), pos2(x, r.max.y)], Stroke::new(1.0, Color32::from_gray(0x2c)));
+ let label = if f >= 1000.0 { format!("{}k", f / 1000.0) } else { format!("{f}") };
+ p.text(pos2(x + 2.0, r.max.y - 2.0), Align2::LEFT_BOTTOM, label, Tokens::ui(9.0), t.text_faint);
+ }
+ let step = if range > 30.0 { 12.0 } else { 6.0 };
+ let mut d = -range;
+ while d <= range + 1e-9 {
+ let y = y_of(d, r, range);
+ let col = if d.abs() < 1e-9 { Color32::from_gray(0x44) } else { Color32::from_gray(0x2c) };
+ p.line_segment([pos2(r.min.x, y), pos2(r.max.x, y)], Stroke::new(1.0, col));
+ p.text(pos2(r.min.x + 2.0, y - 1.0), Align2::LEFT_BOTTOM, format!("{d:+.0}"), Tokens::ui(9.0), t.text_faint);
+ d += step;
+ }
+ // curve from the DSP
+ if let Some(dsp) = filmcraft_render::audio_fx::configured(&ed.preview(), ed.mt, 48000) {
+ let pts: Vec<Pos2> = (0..=240)
+ .filter_map(|i| {
+ let x = r.min.x + r.width() * i as f32 / 240.0;
+ dsp.response_db(fx_of(x, r)).map(|db| pos2(x, y_of(db, r, range)))
+ })
+ .collect();
+ p.add(egui::Shape::line(pts, Stroke::new(1.5, Color32::from_rgb(0x4d, 0xa3, 0xff))));
+ }
+ ed.auto(format!("fxEditor.{}.plot", ed.fx), r, "Response");
+ (r, resp)
+}
+
+// ------------------------------------------------------------------------- parametric EQ
+
+/// (node label, parameter prefix, has gain)
+const PEQ_NODES: [(&str, &str, bool); 9] = [
+ ("HP", "hp", false),
+ ("L", "low", true),
+ ("1", "b1", true),
+ ("2", "b2", true),
+ ("3", "mid", true),
+ ("4", "b4", true),
+ ("5", "b5", true),
+ ("H", "high", true),
+ ("LP", "lp", false),
+];
+
+fn parametric(ui: &mut egui::Ui, ed: &mut Ed) {
+ let range = 30.0;
+ let (r, _) = response_plot(ui, ed, vec2(620.0, 260.0), range);
+ for (label, pre, gain) in PEQ_NODES {
+ let (on_id, f_id, g_id, q_id) = (format!("{pre}_on"), format!("{pre}_freq"), format!("{pre}_gain"), format!("{pre}_q"));
+ let f = ed.v(&f_id);
+ let g = if gain { ed.v(&g_id) } else { 0.0 };
+ let c = pos2(x_of(f, r), y_of(g, r, range));
+ let nr = Rect::from_center_size(c, vec2(16.0, 16.0));
+ let id = egui::Id::new(("peq-node", ed.target.clone(), pre));
+ let resp = ui.interact(nr, id, Sense::click_and_drag());
+ let on = ed.on(&on_id);
+ let col = if on { Color32::from_rgb(0xe8, 0xe8, 0xe8) } else { Color32::from_gray(0x70) };
+ ui.painter().circle_stroke(c, 7.0, Stroke::new(1.5, col));
+ ui.painter().text(c, Align2::CENTER_CENTER, label, Tokens::ui(8.5), col);
+ ed.auto(format!("fxEditor.{}.node.{pre}", ed.fx), nr, label);
+ if resp.dragged()
+ && let Some(pos) = resp.interact_pointer_pos()
+ {
+ ed.drafts.insert(f_id.clone(), fx_of(pos.x, r).round());
+ if gain {
+ let (lo, hi, _) = ed.range(&g_id);
+ ed.drafts.insert(g_id.clone(), (db_of(pos.y, r, range) * 10.0).round().clamp(lo * 10.0, hi * 10.0) / 10.0);
+ }
+ }
+ if resp.drag_stopped() {
+ let fv = ed.v(&f_id);
+ ed.commit(&f_id, fv);
+ if gain {
+ let gv = ed.v(&g_id);
+ ed.commit(&g_id, gv);
+ }
+ }
+ // scroll over a node changes its Q
+ if gain && resp.hovered() {
+ let s = ui.input(|i| i.smooth_scroll_delta.y);
+ if s.abs() > 0.5 {
+ let (lo, hi, _) = ed.range(&q_id);
+ let q = (ed.v(&q_id) * if s > 0.0 { 1.1 } else { 1.0 / 1.1 }).clamp(lo, hi);
+ ed.commit(&q_id, (q * 100.0).round() / 100.0);
+ }
+ }
+ if resp.double_clicked() {
+ ed.commit(&on_id, if on { 0.0 } else { 1.0 });
+ }
+ }
+ ui.horizontal(|ui| {
+ for (label, pre, _) in PEQ_NODES {
+ ed.toggle(ui, &format!("{pre}_on"), label);
+ }
+ });
+ ed.slider(ui, "master_gain", "Master Gain", false);
+}
+
+// --------------------------------------------------------------------------- graphic EQ
+
+fn graphic(ui: &mut egui::Ui, ed: &mut Ed) {
+ let n = match ed.fx {
+ "graphic_eq" => 10,
+ "graphic_eq_20" => 20,
+ _ => 30,
+ };
+ let labels: &[&str] = match n {
+ 10 => &filmcraft_project::effect::GEQ10_LABELS,
+ 20 => &filmcraft_project::effect::GEQ20_LABELS,
+ _ => &filmcraft_project::effect::GEQ30_LABELS,
+ };
+ let w = (n as f32 * 26.0).max(420.0);
+ response_plot(ui, ed, vec2(w, 140.0), 24.0);
+ ui.add_space(4.0);
+ let colw = w / n as f32;
+ let (area, _) = ui.allocate_exact_size(vec2(w, 170.0), Sense::hover());
+ for (i, label) in labels.iter().enumerate() {
+ let pid = format!("b{}", i + 1);
+ let x = area.min.x + colw * (i as f32 + 0.5);
+ let track = Rect::from_center_size(pos2(x, area.min.y + 70.0), vec2(6.0, 130.0));
+ ui.painter().rect_filled(track, 2.0, Color32::from_gray(0x30));
+ ui.painter().line_segment([pos2(x - 5.0, track.center().y), pos2(x + 5.0, track.center().y)], Stroke::new(1.0, Color32::from_gray(0x60)));
+ let v = ed.v(&pid);
+ let ky = track.center().y - (v / 24.0) as f32 * track.height() * 0.5;
+ let knob = Rect::from_center_size(pos2(x, ky), vec2(colw.min(18.0), 8.0));
+ let id = egui::Id::new(("geq-band", ed.target.clone(), i));
+ let resp = ui.interact(knob.union(track).expand(3.0), id, Sense::click_and_drag());
+ ui.painter().rect_filled(knob, 2.0, if resp.hovered() || resp.dragged() { Color32::from_gray(0xf0) } else { Color32::from_gray(0xc0) });
+ ui.painter().text(pos2(x, area.max.y - 22.0), Align2::CENTER_CENTER, format!("{v:+.0}"), Tokens::ui(8.5), ed.t.text_dim);
+ let short = label.replace(" Hz", "").replace(" kHz", "k");
+ ui.painter().text(pos2(x, area.max.y - 8.0), Align2::CENTER_CENTER, short, Tokens::ui(8.5), ed.t.text_faint);
+ ed.auto(format!("fxEditor.{}.param.{pid}", ed.fx), track.union(knob), label);
+ if resp.dragged()
+ && let Some(pos) = resp.interact_pointer_pos()
+ {
+ let db = (((track.center().y - pos.y) / (track.height() * 0.5)) as f64 * 24.0).clamp(-24.0, 24.0);
+ ed.drafts.insert(pid.clone(), (db * 2.0).round() / 2.0);
+ }
+ if resp.drag_stopped() {
+ let nv = ed.v(&pid);
+ ed.commit(&pid, nv);
+ }
+ if resp.double_clicked() {
+ ed.commit(&pid, 0.0);
+ }
+ }
+ ui.horizontal(|ui| {
+ ed.slider(ui, "gain", "Master Gain", false);
+ let r = ui.button("Reset");
+ ed.auto(format!("fxEditor.{}.reset", ed.fx), r.rect, "Reset");
+ if r.clicked() {
+ for i in 0..n {
+ let pid = format!("b{}", i + 1);
+ if ed.v(&pid) != 0.0 {
+ ed.commit(&pid, 0.0);
+ }
+ }
+ }
+ });
+}
+
+// --------------------------------------------------------------------- transfer curves
+
+fn transfer_plot(ui: &mut egui::Ui, ed: &mut Ed, size: f32, band: usize, auto: String) {
+ let (r, _) = ui.allocate_exact_size(vec2(size, size), Sense::hover());
+ let p = ui.painter_at(r);
+ p.rect_filled(r, 2.0, Color32::from_gray(0x18));
+ let lo = -60.0;
+ let map = |x: f64, y: f64| pos2(r.min.x + ((x - lo) / -lo) as f32 * r.width(), r.max.y - (((y - lo) / -lo).clamp(-0.05, 1.05)) as f32 * r.height());
+ for d in [-48.0, -36.0, -24.0, -12.0] {
+ p.line_segment([map(d, lo), map(d, 0.0)], Stroke::new(1.0, Color32::from_gray(0x2c)));
+ p.line_segment([map(lo, d), map(0.0, d)], Stroke::new(1.0, Color32::from_gray(0x2c)));
+ }
+ p.line_segment([map(lo, lo), map(0.0, 0.0)], Stroke::new(1.0, Color32::from_gray(0x44)));
+ if let Some(dsp) = filmcraft_render::audio_fx::configured(&ed.preview(), ed.mt, 48000) {
+ let pts: Vec<Pos2> = (0..=120)
+ .filter_map(|i| {
+ let x = lo + -lo * i as f64 / 120.0;
+ dsp.transfer_db(band, x as f32).map(|y| map(x, y as f64))
+ })
+ .collect();
+ p.add(egui::Shape::line(pts, Stroke::new(1.5, Color32::from_rgb(0xff, 0xb3, 0x47))));
+ }
+ p.text(r.left_top() + vec2(3.0, 2.0), Align2::LEFT_TOP, "out", Tokens::ui(8.5), ed.t.text_faint);
+ p.text(r.right_bottom() - vec2(3.0, 2.0), Align2::RIGHT_BOTTOM, "in", Tokens::ui(8.5), ed.t.text_faint);
+ ed.auto(auto, r, "Transfer curve");
+}
+
+// ------------------------------------------------------------------- multiband compressor
+
+fn multiband(ui: &mut egui::Ui, ed: &mut Ed) {
+ // Spectrum strip with draggable crossover handles.
+ let (r, _) = ui.allocate_exact_size(vec2(640.0, 70.0), Sense::hover());
+ ui.painter().rect_filled(r, 2.0, Color32::from_gray(0x18));
+ let cols =
+ [Color32::from_rgb(0x3d, 0x6e, 0xb4), Color32::from_rgb(0x3d, 0xa0, 0x6e), Color32::from_rgb(0xb4, 0x9a, 0x3d), Color32::from_rgb(0xb4, 0x4f, 0x3d)];
+ let xo = [ed.v("xo1"), ed.v("xo2"), ed.v("xo3")];
+ let edges = [r.min.x, x_of(xo[0], r), x_of(xo[1], r), x_of(xo[2], r), r.max.x];
+ for b in 0..4 {
+ let br = Rect::from_min_max(pos2(edges[b], r.min.y), pos2(edges[b + 1], r.max.y));
+ ui.painter().rect_filled(br.shrink2(vec2(0.0, 8.0)), 0.0, cols[b].gamma_multiply(0.35));
+ ui.painter().text(br.center(), Align2::CENTER_CENTER, format!("Band {}", b + 1), Tokens::ui(10.0), ed.t.text);
+ }
+ for (k, pid) in ["xo1", "xo2", "xo3"].iter().enumerate() {
+ let x = edges[k + 1];
+ let hr = Rect::from_center_size(pos2(x, r.center().y), vec2(10.0, r.height()));
+ let resp = ui.interact(hr, egui::Id::new(("mb-xo", ed.target.clone(), k)), Sense::drag());
+ ui.painter().line_segment([pos2(x, r.min.y), pos2(x, r.max.y)], Stroke::new(if resp.hovered() || resp.dragged() { 2.5 } else { 1.5 }, Color32::WHITE));
+ ui.painter().text(pos2(x + 3.0, r.min.y + 2.0), Align2::LEFT_TOP, format!("{:.0} Hz", xo[k]), Tokens::ui(9.0), ed.t.text_dim);
+ ed.auto(format!("fxEditor.{}.{pid}", ed.fx), hr, "Crossover");
+ if resp.dragged()
+ && let Some(pos) = resp.interact_pointer_pos()
+ {
+ let (lo, hi, _) = ed.range(pid);
+ ed.drafts.insert(pid.to_string(), fx_of(pos.x, r).clamp(lo, hi).round());
+ }
+ if resp.drag_stopped() {
+ let v = ed.v(pid);
+ ed.commit(pid, v);
+ }
+ }
+ ui.add_space(4.0);
+ ui.horizontal_top(|ui| {
+ for b in 1..=4 {
+ ui.vertical(|ui| {
+ ui.set_width(150.0);
+ ui.label(egui::RichText::new(format!("Band {b}")).strong());
+ transfer_plot(ui, ed, 110.0, b - 1, format!("fxEditor.{}.curve.{b}", ed.fx));
+ ui.horizontal(|ui| {
+ ed.toggle(ui, &format!("b{b}_solo"), "Solo");
+ ed.toggle(ui, &format!("b{b}_bypass"), "Bypass");
+ });
+ ed.slider(ui, &format!("b{b}_threshold"), "Thr", false);
+ ed.slider(ui, &format!("b{b}_ratio"), "Ratio", false);
+ ed.slider(ui, &format!("b{b}_attack"), "Att", true);
+ ed.slider(ui, &format!("b{b}_release"), "Rel", true);
+ ed.slider(ui, &format!("b{b}_gain"), "Gain", false);
+ });
+ }
+ });
+ ui.separator();
+ ui.horizontal(|ui| {
+ ed.slider(ui, "output", "Output Gain", false);
+ ed.toggle(ui, "lim_on", "Limiter");
+ ed.toggle(ui, "link", "Link Channels");
+ });
+ ui.horizontal(|ui| {
+ ed.slider(ui, "lim_threshold", "Limiter Threshold", false);
+ ed.slider(ui, "lim_release", "Limiter Release", true);
+ });
+}
+
+// ------------------------------------------------------------------------------- dynamics
+
+fn dynamics(ui: &mut egui::Ui, ed: &mut Ed) {
+ ui.horizontal_top(|ui| {
+ transfer_plot(ui, ed, 220.0, 0, format!("fxEditor.{}.curve", ed.fx));
+ ui.vertical(|ui| {
+ ui.set_width(330.0);
+ ed.toggle(ui, "gate_on", "Auto Gate");
+ ed.slider(ui, "gate_threshold", "Threshold", false);
+ ed.slider(ui, "gate_attack", "Attack", true);
+ ed.slider(ui, "gate_release", "Release", true);
+ ed.slider(ui, "gate_hold", "Hold", false);
+ ui.separator();
+ ed.toggle(ui, "comp_on", "Compressor");
+ ed.slider(ui, "comp_threshold", "Threshold", false);
+ ed.slider(ui, "comp_ratio", "Ratio", false);
+ ed.slider(ui, "comp_attack", "Attack", true);
+ ed.slider(ui, "comp_release", "Release", true);
+ ui.horizontal(|ui| {
+ ed.toggle(ui, "comp_auto", "Auto Makeup");
+ });
+ ed.slider(ui, "comp_makeup", "Makeup", false);
+ });
+ ui.vertical(|ui| {
+ ui.set_width(330.0);
+ ed.toggle(ui, "exp_on", "Expander");
+ ed.slider(ui, "exp_threshold", "Threshold", false);
+ ed.slider(ui, "exp_ratio", "Ratio", false);
+ ui.separator();
+ ed.toggle(ui, "lim_on", "Limiter");
+ ed.slider(ui, "lim_threshold", "Threshold", false);
+ ed.slider(ui, "lim_release", "Release", true);
+ ed.toggle(ui, "soft_clip", "Soft Clip");
+ ui.separator();
+ ed.slider(ui, "output", "Output Gain", false);
+ });
+ });
+}
diff --git a/crates/ui-egui/src/panels/dialogs.rs b/crates/ui-egui/src/panels/dialogs.rs
index 217c3353d..626bffb9e 100644
--- a/crates/ui-egui/src/panels/dialogs.rs
+++ b/crates/ui-egui/src/panels/dialogs.rs
@@ -8,6 +8,7 @@ pub fn show(app: &mut FilmcraftApp, ctx: &egui::Context) {
crate::panels::color_dialogs::show(app, ctx);
crate::panels::clip_dialogs::show(app, ctx);
crate::panels::presets::save_dialog(app, ctx);
+ crate::panels::audio_fx_editor::show(app, ctx);
crate::panels::multicam::show_dialog(app, ctx);
crate::panels::monitor_view::dialogs(app, ctx);
let Some(d) = app.dialog else { return };
diff --git a/crates/ui-egui/src/panels/effect_controls.rs b/crates/ui-egui/src/panels/effect_controls.rs
index 813f029a0..b72b83d59 100644
--- a/crates/ui-egui/src/panels/effect_controls.rs
+++ b/crates/ui-egui/src/panels/effect_controls.rs
@@ -141,6 +141,9 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
if !open {
continue;
}
+ if crate::panels::audio_fx_editor::has_editor(&e.effect) {
+ custom_setup_row(app, bui, body, clip, idx, &e.effect);
+ }
for pd in &def.params {
param_row(app, bui, body, clip, idx, e, None, pd, mt_now, &mut actions, &lane, &lx, &it);
if app.ui.expanded_fx.contains(&graph_key(clip, idx, pd.id))
@@ -170,6 +173,22 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
}
}
+/// Premiere's "Custom Setup ▸ Edit…" row: opens the effect's Clip Fx Editor window.
+fn custom_setup_row(app: &mut FilmcraftApp, ui: &mut egui::Ui, body: Rect, clip: ClipId, idx: usize, effect: &str) {
+ let t = app.tokens;
+ let (r, _) = ui.allocate_exact_size(vec2(body.width(), ROW_H), Sense::hover());
+ ui.painter().text(pos2(r.min.x + 42.0, r.center().y), Align2::LEFT_CENTER, "Custom Setup", Tokens::ui(12.0), t.text_dim);
+ let br = Rect::from_min_size(pos2(r.min.x + 160.0, r.min.y + 2.0), vec2(60.0, ROW_H - 4.0));
+ let resp = ui.interact(br, egui::Id::new(("fx-custom-setup", clip.0, idx)), Sense::click());
+ ui.painter().rect_filled(br, 3.0, if resp.hovered() { t.hover } else { t.field_bg });
+ ui.painter().rect_stroke(br, 3.0, Stroke::new(1.0, t.field_border), egui::StrokeKind::Inside);
+ ui.painter().text(br.center(), Align2::CENTER_CENTER, "Edit…", Tokens::ui(11.5), t.text);
+ app.auto.add(&format!("effectControls.effect.{effect}.edit"), br, "Edit…");
+ if resp.clicked() {
+ crate::panels::audio_fx_editor::open(app, crate::panels::audio_fx_editor::FxTarget::Clip { clip: clip.0, index: idx });
+ }
+}
+
fn seq_name(app: &FilmcraftApp) -> String {
app.session.state.active_sequence.and_then(|s| app.session.project.item(s)).map(|i| i.name.clone()).unwrap_or_default()
}
diff --git a/crates/ui-egui/src/panels/effects.rs b/crates/ui-egui/src/panels/effects.rs
index e6a9a737e..58c682077 100644
--- a/crates/ui-egui/src/panels/effects.rs
+++ b/crates/ui-egui/src/panels/effects.rs
@@ -45,8 +45,12 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
if !open {
continue;
}
- let mut subs: Vec<&str> = items.iter().filter_map(|d| d.category.get(1).copied()).collect();
+ // Sub-folders in definition order; loose items (no sub-folder, e.g. Audio Effects ▸
+ // Balance / Mute / Volume) come last, outside any folder.
+ let sub = |d: &filmcraft_project::EffectDef| d.category.get(1).copied().unwrap_or("");
+ let mut subs: Vec<&str> = items.iter().map(|d| sub(d)).collect();
subs.dedup();
+ subs.sort_by_key(|s| s.is_empty());
let mut seen = Vec::new();
for s in subs {
if seen.contains(&s) {
@@ -54,10 +58,10 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
}
seen.push(s);
let key = format!("{top}/{s}");
- if !folder_row(app, ui, &key, 1, &filter) {
+ if !s.is_empty() && !folder_row(app, ui, &key, 1, &filter) {
continue;
}
- for d in items.iter().filter(|d| d.category.get(1) == Some(&s)) {
+ for d in items.iter().filter(|d| sub(d) == s) {
let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 20.0), Sense::click_and_drag());
if resp.hovered() {
ui.painter().rect_filled(r, 0.0, t.hover);
diff --git a/crates/ui-egui/src/panels/mixer.rs b/crates/ui-egui/src/panels/mixer.rs
index 1a1cfbf39..9496d7865 100644
--- a/crates/ui-egui/src/panels/mixer.rs
+++ b/crates/ui-egui/src/panels/mixer.rs
@@ -285,6 +285,7 @@ fn strip(app: &mut FilmcraftApp, ui: &mut egui::Ui, cx: &mut Ctx, id: TrackId, s
// ---- effect and send slots
if app.ui.mixer_fx_open {
+ let mut open_editor = None;
for k in 0..filmcraft_project::mixer::MAX_INSERTS {
let r = Rect::from_min_size(pos2(x + 4.0, y), vec2(w - 8.0, SLOT_H - 2.0));
let fx = tr.effects.get(k);
@@ -299,6 +300,14 @@ fn strip(app: &mut FilmcraftApp, ui: &mut egui::Ui, cx: &mut Ctx, id: TrackId, s
ui.set_min_width(180.0);
match fx {
Some(e) => {
+ if crate::panels::audio_fx_editor::has_editor(&e.effect) {
+ let r0 = ui.button("Edit…");
+ app.auto.add(&format!("{ap}.fx.{k}.edit"), r0.rect, "Edit…");
+ if r0.clicked() {
+ open_editor = Some(crate::panels::audio_fx_editor::FxTarget::Insert { strip: id.0, slot: k });
+ }
+ ui.separator();
+ }
let on = e.enabled;
let r1 = ui.selectable_label(!on, "Bypass");
app.auto.add(&format!("{ap}.fx.{k}.bypass"), r1.rect, "Bypass");
@@ -318,11 +327,32 @@ fn strip(app: &mut FilmcraftApp, ui: &mut egui::Ui, cx: &mut Ctx, id: TrackId, s
}
}
None if can_add => {
- for d in insert_effects() {
- let r = ui.button(d.name);
- app.auto.add(&format!("{ap}.fx.{k}.{}", d.id), r.rect, d.name);
- if r.clicked() {
- cx.cmd("mixer.addInsert", json!({"strip": sid, "effect": d.id}));
+ // Premiere's effect-slot menu: one submenu per Audio Effects folder.
+ let fx = insert_effects();
+ let mut folders: Vec<&str> = Vec::new();
+ for d in &fx {
+ let f = d.category.get(1).copied().unwrap_or("");
+ if !folders.contains(&f) {
+ folders.push(f);
+ }
+ }
+ for folder in folders {
+ let items: Vec<_> = fx.iter().filter(|d| d.category.get(1).copied().unwrap_or("") == folder).collect();
+ let mut add = |ui: &mut egui::Ui| {
+ for d in &items {
+ let r = ui.button(d.name);
+ app.auto.add(&format!("{ap}.fx.{k}.{}", d.id), r.rect, d.name);
+ if r.clicked() {
+ cx.cmd("mixer.addInsert", json!({"strip": sid, "effect": d.id}));
+ ui.close();
+ }
+ }
+ };
+ if folder.is_empty() {
+ add(ui);
+ } else {
+ let mr = ui.menu_button(folder, |ui| add(ui));
+ app.auto.add(&format!("{ap}.fx.{k}.folder.{folder}"), mr.response.rect, folder);
}
}
}
@@ -331,8 +361,17 @@ fn strip(app: &mut FilmcraftApp, ui: &mut egui::Ui, cx: &mut Ctx, id: TrackId, s
}
}
});
+ if resp.double_clicked()
+ && let Some(e) = fx
+ && crate::panels::audio_fx_editor::has_editor(&e.effect)
+ {
+ open_editor = Some(crate::panels::audio_fx_editor::FxTarget::Insert { strip: id.0, slot: k });
+ }
y += SLOT_H;
}
+ if let Some(target) = open_editor {
+ crate::panels::audio_fx_editor::open(app, target);
+ }
y += 4.0;
for k in 0..filmcraft_project::mixer::MAX_SENDS {
let r = Rect::from_min_size(pos2(x + 4.0, y), vec2(w - 8.0, SLOT_H - 2.0));
diff --git a/crates/ui-egui/src/panels/mod.rs b/crates/ui-egui/src/panels/mod.rs
index f959783c0..0783d5e94 100644
--- a/crates/ui-egui/src/panels/mod.rs
+++ b/crates/ui-egui/src/panels/mod.rs
@@ -1,6 +1,7 @@
//! Panel bodies. `show` dispatches on [`PanelKind`]; drag-and-drop between panels (project items,
//! effects) is carried in egui temp data so the timeline/monitors can accept drops.
+pub mod audio_fx_editor;
pub mod clip_dialogs;
pub mod color_dialogs;
pub mod dialogs;
diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs
index ba71b96ea..be6bc9d21 100644
--- a/crates/ui-egui/src/state.rs
+++ b/crates/ui-egui/src/state.rs
@@ -423,6 +423,9 @@ pub struct UiState {
/// Effect presets: the preset being renamed / the Save Preset dialog (open when Some).
#[serde(default)]
pub save_preset: Option<SavePresetDraft>,
+ /// Open Clip / Track Fx Editor windows (graphical audio-effect editors).
+ #[serde(default)]
+ pub audio_fx_editors: Vec<crate::panels::audio_fx_editor::FxTarget>,
/// Synchronize / Merge Clips / Create Multi-Camera Source Sequence dialog (open when Some).
#[serde(default)]
pub sync_dialog: Option<SyncDraft>,
@@ -709,6 +712,7 @@ impl Default for UiState {
color_dialog: None,
mask_pen: None,
save_preset: None,
+ audio_fx_editors: Vec::new(),
sync_dialog: None,
multicam_record: true,
guide_dialog: None,
diff --git a/crates/ui-egui/tests/audio_fx_editor_ui.rs b/crates/ui-egui/tests/audio_fx_editor_ui.rs
new file mode 100644
index 000000000..1d7d80d74
--- /dev/null
+++ b/crates/ui-egui/tests/audio_fx_editor_ui.rs
@@ -0,0 +1,239 @@
+//! Headless UI tests of the Clip / Track Fx Editor windows (Parametric Equalizer, Graphic
+//! Equalizer, Multiband Compressor, Dynamics): opened from Effect Controls ("Custom Setup ▸
+//! Edit…") and from a mixer effect slot, driven by automation id and by pointer drags.
+//!
+//! Set `FILMCRAFT_UI_SNAPSHOT_DIR=<dir>` to also write PNGs of the windows (`fx-editor-*.png`).
+
+use std::sync::mpsc::{Sender, channel};
+
+use egui_kittest::Harness;
+use filmcraft_engine::Session;
+use filmcraft_ui_egui::FilmcraftApp;
+use filmcraft_ui_egui::control::ControlRequest;
+use serde_json::{Value, json};
+
+struct Driver {
+ harness: Harness<'static, FilmcraftApp>,
+ tx: Sender<ControlRequest>,
+ snapshots: Option<std::path::PathBuf>,
+}
+
+impl Driver {
+ fn demo() -> Self {
+ let mut session = Session::default();
+ session.execute("file.openDemoProject", json!({})).expect("demo project");
+ let (tx, rx) = channel();
+ let app = FilmcraftApp::new(session).with_control(rx);
+ let snapshots = std::env::var_os("FILMCRAFT_UI_SNAPSHOT_DIR").map(std::path::PathBuf::from);
+ let mut b = Harness::builder().with_size(egui::vec2(1600.0, 980.0)).with_max_steps(10_000);
+ if snapshots.is_some() {
+ b = b.wgpu();
+ }
+ let harness = b.build_eframe(move |_cc| app);
+ let mut d = Driver { harness, tx, snapshots };
+ d.frames(4);
+ d
+ }
+
+ fn frames(&mut self, n: usize) {
+ for _ in 0..n {
+ let ctx = self.harness.ctx.clone();
+ let mut raw = std::mem::take(self.harness.input_mut());
+ eframe::App::raw_input_hook(self.harness.state_mut(), &ctx, &mut raw);
+ *self.harness.input_mut() = raw;
+ self.harness.step();
+ }
+ }
+
+ fn call(&mut self, method: &str, params: Value) -> Value {
+ let (req, reply) = ControlRequest::new(method, params.clone());
+ self.tx.send(req).unwrap();
+ for _ in 0..600 {
+ self.frames(1);
+ if let Ok(v) = reply.try_recv() {
+ return v;
+ }
+ }
+ panic!("no reply to {method} {params}");
+ }
+
+ fn ok(&mut self, method: &str, params: Value) -> Value {
+ let v = self.call(method, params.clone());
+ assert_eq!(v["ok"], json!(true), "{method} {params} failed: {v}");
+ v["result"].clone()
+ }
+
+ fn exec(&mut self, command: &str, params: Value) -> Value {
+ self.ok("engine.execute", json!({"command": command, "params": params}))
+ }
+
+ fn click(&mut self, id: &str) {
+ self.ok("ui.click", json!({"id": id}));
+ self.frames(2);
+ }
+
+ fn element(&mut self, id: &str) -> Option<[f32; 4]> {
+ let v = self.ok("ui.elements", json!({"prefix": id}));
+ v.as_array()?.iter().find(|e| e["id"] == id).map(|e| {
+ let r = &e["rect"];
+ [r[0].as_f64().unwrap() as f32, r[1].as_f64().unwrap() as f32, r[2].as_f64().unwrap() as f32, r[3].as_f64().unwrap() as f32]
+ })
+ }
+
+ fn ids(&mut self, prefix: &str) -> Vec<String> {
+ let v = self.ok("ui.elements", json!({"prefix": prefix}));
+ v.as_array().unwrap().iter().filter_map(|e| e["id"].as_str().map(str::to_string)).collect()
+ }
+
+ /// Press on `id`, move by (dx, dy) over several frames, release.
+ fn drag(&mut self, id: &str, dx: f32, dy: f32, steps: usize) {
+ let r = self.element(id).unwrap_or_else(|| panic!("no element {id}"));
+ let mut p = egui::pos2(r[0] + r[2] / 2.0, r[1] + r[3] / 2.0);
+ let push = |d: &mut Self, e: egui::Event| d.harness.input_mut().events.push(e);
+ push(self, egui::Event::PointerMoved(p));
+ self.frames(1);
+ push(self, egui::Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() });
+ self.frames(1);
+ for _ in 0..steps {
+ p.x += dx / steps as f32;
+ p.y += dy / steps as f32;
+ push(self, egui::Event::PointerMoved(p));
+ self.frames(1);
+ }
+ push(self, egui::Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() });
+ self.frames(3);
+ }
+
+ fn snapshot(&mut self, name: &str) {
+ let Some(dir) = self.snapshots.clone() else { return };
+ self.frames(2);
+ match self.harness.render() {
+ Ok(img) => {
+ std::fs::create_dir_all(&dir).unwrap();
+ img.save(dir.join(format!("{name}.png"))).unwrap();
+ }
+ Err(e) => eprintln!("snapshot {name} skipped: {e}"),
+ }
+ }
+
+ fn undo_len(&mut self) -> usize {
+ self.exec("history.list", json!({}))["undo"].as_array().unwrap().len()
+ }
+
+ /// Audio clip on A1 (id) with `effect` applied and selected; Effect Controls showing it.
+ fn audio_clip_with(&mut self, effect: &str) -> u64 {
+ self.ok("ui.set", json!({"workspace": "Effects"}));
+ let seq = self.exec("sequence.inspect", json!({}));
+ let clip = &seq["audio"][0]["items"][0];
+ let (id, start) = (clip["clip"].as_u64().unwrap(), clip["start"].as_i64().unwrap());
+ self.exec("playhead.set", json!({"time": start}));
+ // only the audio clip (Effect Controls prefers a linked video clip)
+ self.exec("sequence.linkedSelection", json!({"on": false}));
+ self.exec("timeline.select", json!({"clips": [id]}));
+ self.exec("effects.apply", json!({"clips": [id], "effect": effect}));
+ self.frames(3);
+ // fold the fixed effects so the applied one's rows are on screen
+ for fx in ["volume", "channel_volume", "panner"] {
+ self.click(&format!("effectControls.effect.{fx}"));
+ }
+ id
+ }
+
+ fn clip_param(&mut self, clip: u64, effect: &str, param: &str) -> Value {
+ let seq = self.exec("sequence.inspect", json!({}));
+ let items = seq["audio"][0]["items"].as_array().unwrap().clone();
+ let it = items.iter().find(|i| i["clip"] == clip).unwrap().clone();
+ let fx = it["effects"].as_array().unwrap().iter().find(|e| e["effect"] == effect).unwrap().clone();
+ fx["params"][param]["value"].clone()
+ }
+}
+
+/// A parameter value from `sequence.inspect` (`"Float(3.5)"`, `"Bool(true)"`) or
+/// `mixer.inspect` (plain JSON).
+fn num(v: &Value) -> f64 {
+ v.as_f64()
+ .or_else(|| v.as_str().and_then(|s| s.trim_start_matches("Float(").trim_start_matches("Choice(").trim_end_matches(')').parse().ok()))
+ .unwrap_or(f64::NAN)
+}
+
+fn truthy(v: &Value) -> bool {
+ v.as_bool().unwrap_or(false) || v.as_str() == Some("Bool(true)")
+}
+
+#[test]
+fn parametric_eq_editor_from_effect_controls() {
+ let mut d = Driver::demo();
+ let clip = d.audio_clip_with("parametric_eq");
+ d.click("effectControls.effect.parametric_eq.edit");
+ d.frames(3);
+ let ids = d.ids("fxEditor.parametric_eq.");
+ for id in ["plot", "node.hp", "node.low", "node.mid", "node.lp", "toggle.hp_on", "param.master_gain", "close"] {
+ assert!(ids.iter().any(|i| *i == format!("fxEditor.parametric_eq.{id}")), "{id} missing from {ids:?}");
+ }
+ // band toggle by id
+ d.click("fxEditor.parametric_eq.toggle.hp_on");
+ assert!(truthy(&d.clip_param(clip, "parametric_eq", "hp_on")));
+ // dragging band 3 up boosts it — one undo step for the whole drag
+ let undo0 = d.undo_len();
+ d.drag("fxEditor.parametric_eq.node.mid", 0.0, -60.0, 6);
+ let g = num(&d.clip_param(clip, "parametric_eq", "mid_gain"));
+ assert!(g > 3.0, "mid gain after drag: {g}");
+ assert_eq!(d.undo_len(), undo0 + 2, "frequency + gain committed on release");
+ d.snapshot("fx-editor-parametric-eq");
+ d.click("fxEditor.parametric_eq.close");
+ assert!(d.ids("fxEditor.parametric_eq.").is_empty(), "window closed");
+}
+
+#[test]
+fn graphic_eq_and_dynamics_editors() {
+ let mut d = Driver::demo();
+ let clip = d.audio_clip_with("graphic_eq_30");
+ d.click("effectControls.effect.graphic_eq_30.edit");
+ d.frames(3);
+ let ids = d.ids("fxEditor.graphic_eq_30.param.");
+ assert_eq!(ids.iter().filter(|i| i.starts_with("fxEditor.graphic_eq_30.param.b")).count(), 30, "{ids:?}");
+ d.drag("fxEditor.graphic_eq_30.param.b17", 0.0, -40.0, 5);
+ let g = num(&d.clip_param(clip, "graphic_eq_30", "b17"));
+ assert!(g > 3.0, "1 kHz band after drag: {g}");
+ d.click("fxEditor.graphic_eq_30.reset");
+ assert_eq!(num(&d.clip_param(clip, "graphic_eq_30", "b17")), 0.0);
+ d.snapshot("fx-editor-graphic-eq-30");
+ d.click("fxEditor.graphic_eq_30.close");
+ // Dynamics: the transfer curve and section toggles
+ d.exec("effects.apply", json!({"clips": [clip], "effect": "dynamics_rack"}));
+ d.frames(3);
+ d.click("effectControls.effect.graphic_eq_30");
+ d.click("effectControls.effect.dynamics_rack.edit");
+ d.frames(3);
+ assert!(d.element("fxEditor.dynamics_rack.curve").is_some());
+ d.click("fxEditor.dynamics_rack.toggle.lim_on");
+ assert!(truthy(&d.clip_param(clip, "dynamics_rack", "lim_on")));
+ d.snapshot("fx-editor-dynamics");
+}
+
+#[test]
+fn track_fx_editor_from_the_mixer_slot() {
+ let mut d = Driver::demo();
+ d.exec("mixer.addInsert", json!({"strip": "A1", "effect": "multiband_compressor"}));
+ d.ok("ui.set", json!({"workspace": "Audio"}));
+ d.frames(3);
+ d.click("mixer.showEffects");
+ d.click("mixer.A1.fx.0");
+ d.click("mixer.A1.fx.0.edit");
+ d.frames(3);
+ let ids = d.ids("fxEditor.multiband_compressor.");
+ for id in ["xo1", "xo2", "xo3", "curve.1", "curve.4", "toggle.b2_solo", "param.b3_threshold", "toggle.lim_on"] {
+ assert!(ids.iter().any(|i| *i == format!("fxEditor.multiband_compressor.{id}")), "{id} missing from {ids:?}");
+ }
+ d.click("fxEditor.multiband_compressor.toggle.b2_solo");
+ let m = d.exec("mixer.inspect", json!({}));
+ let a1 = m["strips"].as_array().unwrap().iter().find(|s| s["ref"] == "A1").unwrap().clone();
+ assert!(truthy(&a1["inserts"][0]["params"]["b2_solo"]), "solo set on the insert: {a1}");
+ // dragging the mid crossover to the right raises it
+ d.drag("fxEditor.multiband_compressor.xo2", 60.0, 0.0, 5);
+ let m = d.exec("mixer.inspect", json!({}));
+ let a1 = m["strips"].as_array().unwrap().iter().find(|s| s["ref"] == "A1").unwrap().clone();
+ let xo2 = num(&a1["inserts"][0]["params"]["xo2"]);
+ assert!(xo2 > 2200.0, "crossover after drag: {xo2} ({a1})");
+ d.snapshot("fx-editor-multiband");
+}
diff --git a/crates/ui-egui/tests/mixer_ui.rs b/crates/ui-egui/tests/mixer_ui.rs
index dac7dbdd6..7c72924df 100644
--- a/crates/ui-egui/tests/mixer_ui.rs
+++ b/crates/ui-egui/tests/mixer_ui.rs
@@ -187,6 +187,7 @@ fn track_mixer_controls_by_id_and_by_drag() {
// effects and sends
d.click("mixer.showEffects");
d.click("mixer.A1.fx.0");
+ d.click("mixer.A1.fx.0.folder.Reverb");
d.click("mixer.A1.fx.0.studio_reverb");
assert_eq!(d.strip("A1")["inserts"][0]["effect"], "studio_reverb");
d.exec("mixer.addSubmix", json!({"name": "Reverb Bus"}));