address review: settle clip effect smoothers on a bounded silent lead-in

This commit is contained in:
Dylan M. Taylor
2026-11-03 19:14:33 +00:00
parent 292071eeff
commit 170d123bc6
2 changed files with 16 additions and 1 deletions
+14
View File
@@ -135,6 +135,9 @@ pub fn fold_down_stereo(fmt: ChannelFormat, ch: &[Vec<f32>]) -> Vec<Vec<f32>> {
const CLIP_FX_BLOCK: usize = 4096;
/// Most a clip effect keeps rendering past its clip's end in [`render_clips`], in seconds.
const MAX_CLIP_FX_TAIL_SECONDS: f64 = 10.0;
/// Silent lead-in run before a clip with effects so smoothed parameters (EQ) settle, in seconds
/// (the smoothers settle within ~0.3 s).
const CLIP_FX_SETTLE_SECONDS: f64 = 1.0;
/// A tail block whose peak is below this (-180 dBFS) ends a clip effect's tail.
const CLIP_FX_TAIL_FLOOR: f32 = 1e-9;
@@ -162,6 +165,17 @@ pub fn render_clips(s: &Session, track: TrackId, range: Range) -> Vec<Vec<f32>>
let first = offset(c.start);
let clip_end = offset(c.end());
let tail_end = offset(c.end().saturating_add(max_tail));
// Smoothed parameters start at their defaults; settle them on silence, as the
// full-span render did, so the clip opens at the configured setting.
let mut lead = first.min(usize::try_from(s.sample_rate.samples(CLIP_FX_SETTLE_SECONDS).max(0)).unwrap_or(0));
while lead > 0 {
let n = lead.min(CLIP_FX_BLOCK);
for ch in &mut block {
ch.fill(0.0);
}
fx.process(&mut block, n);
lead -= n;
}
let mut done = first;
while done < len {
let n = (len - done).min(CLIP_FX_BLOCK);
+2 -1
View File
@@ -1236,7 +1236,8 @@ fn render_clips_full_span(s: &Session, track: TrackId, range: Range) -> Vec<Vec<
#[test]
fn consolidate_clip_effects_cover_the_clip_and_its_tail() {
let fx_sets: [&[(&str, f64)]; 2] = [&[("comp.lookahead", 5.0), ("comp.threshold", -20.0), ("gain", -6.0)], &[("eq.hpf_on", 1.0), ("gain", 3.0)]];
let fx_sets: [&[(&str, f64)]; 3] =
[&[("comp.lookahead", 5.0), ("comp.threshold", -20.0), ("gain", -6.0)], &[("eq.hpf_on", 1.0), ("gain", 3.0)], &[("eq.low_shelf_gain", 12.0)]];
for (k, params) in fx_sets.iter().enumerate() {
let mut s = Session::default();
let t = s.add_track(TrackKind::Audio, ChannelFormat::Mono, None);