FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
meters: drop to silence right after Stop (#3011)
Tex Jerniganc5da984f6b09
diff --git a/crates/ui-egui/src/panels/mixer.rs b/crates/ui-egui/src/panels/mixer.rsindex 1d5046b38..aea3b830e 100644--- a/crates/ui-egui/src/panels/mixer.rs+++ b/crates/ui-egui/src/panels/mixer.rs@@ -87,7 +87,7 @@ pub const INPUT_METER: u64 = u64::MAX - 1;/// Per-strip meter state, `strip id → [level, peak]` per channel (dBFS; 2 channels, or 6 for 5.1/// strips), fed by the playing mix ([`filmcraft_render::mixer::LiveMix`]) with fast attack and a-/// 20 dB/s fall. [`INPUT_METER`] holds the voice-over input.+/// 20 dB/s fall (peak holds 6 dB/s) while live, dropping within a quarter second after Stop. [`INPUT_METER`] holds the voice-over input.pub fn poll_meters(app: &mut FilmcraftApp, ui: &egui::Ui) -> HashMap<u64, Vec<[f32; 2]>> {let id = egui::Id::new("mixer-meters");let frame = ui.ctx().cumulative_frame_nr();@@ -102,15 +102,18 @@ pub fn poll_meters(app: &mut FilmcraftApp, ui: &egui::Ui) -> HashMap<u64, Vec<[fif !input.is_empty() {fresh.push((INPUT_METER, input));}+ // scrubbing plays through the same mixer, so its grains move the meters too+ let live = app.playback.playing || app.session.voiceover.recording() || app.scrub.is_open();+ // Once stopped, bars and peak holds drop within a quarter second instead of easing down for+ // seconds, which read as audio still playing.+ let (level_fall, peak_fall) = if live { (20.0, 6.0) } else { (360.0, 360.0) };let dt = ui.input(|i| i.stable_dt).min(0.1);for v in st.values_mut() {for m in v.iter_mut() {- m[0] = (m[0] - 20.0 * dt).max(-90.0);- m[1] = (m[1] - 6.0 * dt).max(-90.0);+ m[0] = (m[0] - level_fall * dt).max(-90.0);+ m[1] = (m[1] - peak_fall * dt).max(-90.0);}}- // scrubbing plays through the same mixer, so its grains move the meters too- let live = app.playback.playing || app.session.voiceover.recording() || app.scrub.is_open();if live {for (k, p) in fresh {let e = st.entry(k).or_default();diff --git a/crates/ui-egui/tests/it/mixer_ui.rs b/crates/ui-egui/tests/it/mixer_ui.rsindex 603578392..3166d6ca9 100644--- a/crates/ui-egui/tests/it/mixer_ui.rs+++ b/crates/ui-egui/tests/it/mixer_ui.rs@@ -478,6 +478,13 @@ fn paused_meters_repaint_without_input_and_settle_after_release() {d.ok("ui.playback", json!({"action": "stop"}));assert!(!d.harness.state().playback.playing);d.snapshot(&format!("meters-{workspace}-paused-start"), None);+ // A slow release after Stop reads as audio still playing: silent within 0.4 s.+ for _ in 0..4 {+ d.harness.step();+ }+ let (_, meters): (u64, std::collections::HashMap<u64, Vec<[f32; 2]>>) =+ d.harness.ctx.data(|data| data.get_temp(egui::Id::new("mixer-meters"))).unwrap();+ assert!(meters.values().flatten().all(|meter| *meter == [-90.0; 2]), "{workspace}: still falling 0.4 s after Stop: {meters:?}");// Harness::run follows immediate repaint requests, adding no mouse or keyboard input.let steps = d.harness.run();// Inspect both values that drive the bars: a silent level alone must not strand its