Skip to content

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

M7: optimize settled mixer DSP and isolate throughput gate

Earl Codcabbda07db8
diff --git a/crates/audio-dsp/src/biquad.rs b/crates/audio-dsp/src/biquad.rs
index 55f0403ad..90f7efd5c 100644
--- a/crates/audio-dsp/src/biquad.rs
+++ b/crates/audio-dsp/src/biquad.rs
@@ -132,6 +132,10 @@ impl Biquad {
pub fn reset(&mut self) {
*self = Biquad::new();
}
+ /// Exact zero state, including the sign of zero, for identity-filter fast paths.
+ pub(crate) fn is_clear(&self) -> bool {
+ self.s1.to_bits() == 0 && self.s2.to_bits() == 0
+ }
/// Filter a buffer in place.
pub fn process(&mut self, c: &Coeffs, buf: &mut [f32]) {
for v in buf {
diff --git a/crates/audio-dsp/src/effects/eq.rs b/crates/audio-dsp/src/effects/eq.rs
index 47a91f906..af975a09b 100644
--- a/crates/audio-dsp/src/effects/eq.rs
+++ b/crates/audio-dsp/src/effects/eq.rs
@@ -110,6 +110,57 @@ impl BandBank {
pub(crate) fn process(&mut self, channels: &mut [&mut [f32]], out_gain: &mut Smoothed) {
let n = block_len(channels);
let nch = channels.len().min(self.state.len());
+ if n == 0 {
+ return;
+ }
+ if !out_gain.is_smoothing()
+ && self.bands.iter().all(|b| !b.dirty && !b.freq.is_smoothing() && !b.gain.is_smoothing() && !b.q.is_smoothing() && !b.mix.is_smoothing())
+ {
+ // Keep the exact per-sample arithmetic and recursive state; only the settled
+ // parameter/smoother bookkeeping is hoisted out of the hot loop.
+ let g = out_gain.value() as f64;
+ for (channel, state) in channels.iter_mut().take(nch).zip(&mut self.state) {
+ for (b, st) in self.bands.iter().zip(state.iter_mut()) {
+ if b.mix.value() <= 0.0 {
+ st.reset();
+ }
+ }
+ // A settled unit transfer with zero state is exactly transparent for finite
+ // f32 input. Do not discard a tail or bypass a non-finite sample. Bounded
+ // coefficients also ensure intermediate f64 products cannot overflow.
+ let transparent = self.bands.iter().zip(state.iter()).all(|(b, st)| {
+ b.mix.value() <= 0.0
+ || (st.is_clear()
+ && b.coeffs.b0 == 1.0
+ && b.coeffs.b1 == b.coeffs.a1
+ && b.coeffs.b2 == b.coeffs.a2
+ && b.coeffs.b1.abs() <= 4.0
+ && b.coeffs.b2.abs() <= 4.0)
+ });
+ if transparent && channel.iter().take(n).all(|x| x.is_finite()) {
+ let active = self.bands.iter().any(|b| b.mix.value() > 0.0);
+ for sample in channel.iter_mut().take(n) {
+ let x = *sample as f64;
+ // An active identity biquad adds +0, which normalizes negative zero.
+ *sample = ((if active { x + 0.0 } else { x }) * g) as f32;
+ }
+ continue;
+ }
+ for sample in channel.iter_mut().take(n) {
+ let mut x = *sample as f64;
+ for (b, st) in self.bands.iter().zip(state.iter_mut()) {
+ let m = b.mix.value() as f64;
+ if m > 0.0 {
+ let y = st.tick(&b.coeffs, x);
+ x += m * (y - x);
+ }
+ }
+ *sample = (x * g) as f32;
+ }
+ }
+ self.counter = (self.counter + (n % COEFF_INTERVAL as usize) as u32) % COEFF_INTERVAL;
+ return;
+ }
for i in 0..n {
if self.counter == 0 {
self.update_coeffs(false);
@@ -376,3 +427,119 @@ mod tests {
assert!((x[4799] - 0.5 * crate::db_to_gain(12.0)).abs() < 1e-4);
}
}
+
+#[cfg(test)]
+impl BandBank {
+ fn process_reference(&mut self, channels: &mut [&mut [f32]], out_gain: &mut Smoothed) {
+ let n = block_len(channels);
+ let nch = channels.len().min(self.state.len());
+ for i in 0..n {
+ if self.counter == 0 {
+ self.update_coeffs(false);
+ }
+ self.counter = (self.counter + 1) % COEFF_INTERVAL;
+ for b in &mut self.bands {
+ b.freq.tick();
+ b.gain.tick();
+ b.q.tick();
+ if b.freq.is_smoothing() || b.gain.is_smoothing() || b.q.is_smoothing() {
+ b.dirty = true;
+ }
+ }
+ let g = out_gain.tick();
+ // Tick the band mixes once per sample (shared by all channels).
+ let mut mixes = [0.0f32; MAX_BANDS];
+ for (m, b) in mixes.iter_mut().zip(self.bands.iter_mut()) {
+ *m = b.mix.tick();
+ }
+ for ch in 0..nch {
+ let mut x = channels[ch][i] as f64;
+ for (k, b) in self.bands.iter().enumerate() {
+ let m = mixes[k] as f64;
+ let st = &mut self.state[ch][k];
+ if m > 0.0 {
+ let y = st.tick(&b.coeffs, x);
+ x += m * (y - x);
+ } else {
+ st.reset();
+ }
+ }
+ channels[ch][i] = (x * g as f64) as f32;
+ }
+ }
+ }
+}
+
+#[cfg(test)]
+mod throughput_tests {
+ use super::*;
+ #[test]
+ fn flat_eq_fast_path_preserves_samples_and_filter_tails() {
+ let mut fast = BandBank::new(48000.0, 2, 1);
+ fast.set_band(0, true, FilterType::Peaking, 1000.0, 0.0, 0.7, true);
+ fast.reset();
+ let mut reference = fast.clone();
+ let mut gain = Smoothed::new(1.0, 0);
+ let mut ref_gain = gain;
+ for input in
+ [vec![-0.0, 0.0, f32::MIN_POSITIVE, f32::from_bits(1), f32::MAX, -f32::MAX, 0.7], vec![0.0; 100], vec![f32::INFINITY, f32::NEG_INFINITY, f32::NAN]]
+ {
+ let mut a = [input.clone(), input];
+ let mut b = a.clone();
+ let [al, ar] = &mut a;
+ let [bl, br] = &mut b;
+ fast.process(&mut [al, ar], &mut gain);
+ reference.process_reference(&mut [bl, br], &mut ref_gain);
+ for (a, b) in a.iter().flatten().zip(b.iter().flatten()) {
+ assert_eq!(a.to_bits(), b.to_bits());
+ }
+ }
+ // A newly flat filter must drain its old state, not drop the tail.
+ fast.reset();
+ fast.set_band(0, true, FilterType::Peaking, 1000.0, 12.0, 0.7, true);
+ fast.update_coeffs(true);
+ fast.process(&mut [&mut [0.5], &mut [0.5]], &mut gain);
+ fast.set_band(0, true, FilterType::Peaking, 1000.0, 0.0, 0.7, true);
+ fast.update_coeffs(true);
+ reference = fast.clone();
+ let mut a = [vec![0.0; 4096], vec![0.0; 4096]];
+ let mut b = a.clone();
+ let [al, ar] = &mut a;
+ let [bl, br] = &mut b;
+ fast.process(&mut [al, ar], &mut gain);
+ reference.process_reference(&mut [bl, br], &mut ref_gain);
+ assert_eq!(a, b);
+ assert!(a[0].iter().any(|x| *x != 0.0));
+ }
+ #[test]
+ fn settled_and_automated_eq_matches_original_loop() {
+ let mut fast = BandBank::new(48000.0, 2, 3);
+ fast.reset();
+ let mut reference = fast.clone();
+ let mut gain = Smoothed::with_ms(1.0, 48000.0, 20.0);
+ let mut ref_gain = gain;
+ for block in 0..500 {
+ if matches!(block, 2 | 90 | 180 | 270 | 360) {
+ let on = block != 180;
+ let db = if block == 270 { 0.0 } else { 9.0 };
+ for bank in [&mut fast, &mut reference] {
+ bank.set_band(0, on, FilterType::Peaking, 1733.0, db, 0.7, false);
+ }
+ gain.set(if block == 360 { 1.0 } else { 0.8 });
+ ref_gain.set(gain.target());
+ }
+ let n = [0, 1, 17, 64, 513][block % 5];
+ let input: Vec<f32> = (0..n).map(|i| if block > 400 { 0.0 } else { ((i + block * 13) as f32 * 0.17).sin() * 0.3 }).collect();
+ let mut a = [input.clone(), input.clone()];
+ let mut b = a.clone();
+ let [al, ar] = &mut a;
+ let [bl, br] = &mut b;
+ fast.process(&mut [al, ar], &mut gain);
+ reference.process_reference(&mut [bl, br], &mut ref_gain);
+ for (a, b) in a.iter().flatten().zip(b.iter().flatten()) {
+ assert_eq!(a.to_bits(), b.to_bits(), "block {block}");
+ }
+ assert_eq!(fast.counter, reference.counter);
+ }
+ }
+}
diff --git a/crates/audio-dsp/src/effects/time.rs b/crates/audio-dsp/src/effects/time.rs
index d10db23dd..c5ce6c0e4 100644
--- a/crates/audio-dsp/src/effects/time.rs
+++ b/crates/audio-dsp/src/effects/time.rs
@@ -5,12 +5,26 @@ use crate::{AudioEffect, ParamSpec, ParamValues, Smoothed, Unit, block_len, flus
/// Fractional read from a circular buffer: `delay` samples behind write position `w`.
#[inline]
fn read_frac(buf: &[f32], w: usize, delay: f32) -> f32 {
- let len = buf.len();
+ read_prepared(buf, w, prepare_delay(buf.len(), delay))
+}
+
+#[inline]
+fn prepare_delay(len: usize, delay: f32) -> (usize, f32) {
let d = delay.clamp(1.0, (len - 2) as f32);
let di = d.floor();
let frac = d - di;
- let i0 = (w + len - di as usize) % len;
- let i1 = (i0 + len - 1) % len;
+ // The delay is bounded by this ring's length, so wrapping needs no integer division.
+ // Keep the fallback for very large rings whose f32 length rounds upward.
+ let distance = di as usize;
+ let distance = if distance <= len { distance } else { distance % len };
+ (distance, frac)
+}
+
+#[inline]
+fn read_prepared(buf: &[f32], w: usize, (distance, frac): (usize, f32)) -> f32 {
+ let len = buf.len();
+ let i0 = if w >= distance { w - distance } else { len - (distance - w) };
+ let i1 = if i0 == 0 { len - 1 } else { i0 - 1 };
buf[i0] + (buf[i1] - buf[i0]) * frac
}
@@ -103,7 +117,7 @@ impl AudioEffect for Delay {
buf[self.w] = flush32(x + fb * yd);
channels[ch][i] = x + mix * (yd - x);
}
- self.w = (self.w + 1) % len;
+ self.w = if self.w + 1 == len { 0 } else { self.w + 1 };
}
}
}
@@ -132,6 +146,7 @@ pub struct Reverb {
len: [Smoothed; FDN],
lp: [f32; FDN],
gains: [f32; FDN],
+ gain_key: ([f32; FDN], f32),
damp: Smoothed,
rt60: Smoothed,
mix: Smoothed,
@@ -162,6 +177,7 @@ impl Reverb {
len: [sm(1.0); FDN],
lp: [0.0; FDN],
gains: [0.0; FDN],
+ gain_key: ([0.0; FDN], 0.0),
damp: sm(0.0),
rt60: sm(1.0),
mix: sm(0.0),
@@ -195,6 +211,11 @@ impl Reverb {
fn update_gains(&mut self) {
let rt = self.rt60.value().max(0.01);
+ let lengths = self.len.map(|l| l.value());
+ if self.gain_key == (lengths, rt) {
+ return;
+ }
+ self.gain_key = (lengths, rt);
for k in 0..FDN {
// Attenuation per pass so the loop decays 60 dB in rt seconds.
self.gains[k] = 10f32.powf(-3.0 * self.len[k].value() / (rt * self.sr));
@@ -222,13 +243,20 @@ impl AudioEffect for Reverb {
let line_len = self.lines[0].len();
let pre_len = self.pre.len();
let hh = 2.0 / FDN as f32;
+ // During a settled block these positions cannot change. Preserve the original path
+ // while smoothing, and preserve the 32-sample gain update grid in both cases.
+ let fixed = self.len.iter().all(|l| !l.is_smoothing());
+ let delays = self.len.map(|l| prepare_delay(line_len, l.value()));
+ let predelay = (!self.pre_len.is_smoothing()).then(|| prepare_delay(pre_len, self.pre_len.value()));
for i in 0..n {
if self.counter == 0 {
self.update_gains();
}
self.counter = (self.counter + 1) % 32;
- for l in &mut self.len {
- l.tick();
+ if !fixed {
+ for l in &mut self.len {
+ l.tick();
+ }
}
self.rt60.tick();
let damp = self.damp.tick();
@@ -241,13 +269,16 @@ impl AudioEffect for Reverb {
}
mono /= nch as f32;
self.pre[self.pre_w] = mono;
- let input = read_frac(&self.pre, self.pre_w, pd);
- self.pre_w = (self.pre_w + 1) % pre_len;
+ let input = match predelay {
+ Some(delay) => read_prepared(&self.pre, self.pre_w, delay),
+ None => read_frac(&self.pre, self.pre_w, pd),
+ };
+ self.pre_w = if self.pre_w + 1 == pre_len { 0 } else { self.pre_w + 1 };
let mut v = [0.0f32; FDN];
let mut sum = 0.0;
for k in 0..FDN {
- let d = read_frac(&self.lines[k], self.w, self.len[k].value());
+ let d = if fixed { read_prepared(&self.lines[k], self.w, delays[k]) } else { read_frac(&self.lines[k], self.w, self.len[k].value()) };
self.lp[k] = flush32(d + (self.lp[k] - d) * damp);
v[k] = self.lp[k] * self.gains[k];
sum += v[k];
@@ -259,7 +290,7 @@ impl AudioEffect for Reverb {
wl += SIGN_L[k] * v[k];
wr += SIGN_R[k] * v[k];
}
- self.w = (self.w + 1) % line_len;
+ self.w = if self.w + 1 == line_len { 0 } else { self.w + 1 };
let (wl, wr) = (wl * 0.35, wr * 0.35);
for (c, ch) in channels.iter_mut().enumerate() {
let x = ch[i];
@@ -370,3 +401,129 @@ mod tests {
}
}
}
+
+#[cfg(test)]
+fn read_frac_reference(buf: &[f32], w: usize, delay: f32) -> f32 {
+ let len = buf.len();
+ let d = delay.clamp(1.0, (len - 2) as f32);
+ let di = d.floor();
+ let frac = d - di;
+ let i0 = (w + len - di as usize) % len;
+ let i1 = (i0 + len - 1) % len;
+ buf[i0] + (buf[i1] - buf[i0]) * frac
+}
+#[cfg(test)]
+impl Reverb {
+ fn update_gains_reference(&mut self) {
+ let rt = self.rt60.value().max(0.01);
+ for k in 0..FDN {
+ // Attenuation per pass so the loop decays 60 dB in rt seconds.
+ self.gains[k] = 10f32.powf(-3.0 * self.len[k].value() / (rt * self.sr));
+ }
+ }
+ fn process_reference(&mut self, channels: &mut [&mut [f32]]) {
+ let n = block_len(channels);
+ let nch = channels.len();
+ if nch == 0 {
+ return;
+ }
+ let line_len = self.lines[0].len();
+ let pre_len = self.pre.len();
+ let hh = 2.0 / FDN as f32;
+ for i in 0..n {
+ if self.counter == 0 {
+ self.update_gains_reference();
+ }
+ self.counter = (self.counter + 1) % 32;
+ for l in &mut self.len {
+ l.tick();
+ }
+ self.rt60.tick();
+ let damp = self.damp.tick();
+ let mix = self.mix.tick();
+ let pd = self.pre_len.tick();
+
+ let mut mono = 0.0;
+ for ch in channels.iter() {
+ mono += ch[i];
+ }
+ mono /= nch as f32;
+ self.pre[self.pre_w] = mono;
+ let input = read_frac_reference(&self.pre, self.pre_w, pd);
+ self.pre_w = (self.pre_w + 1) % pre_len;
+
+ let mut v = [0.0f32; FDN];
+ let mut sum = 0.0;
+ for k in 0..FDN {
+ let d = read_frac_reference(&self.lines[k], self.w, self.len[k].value());
+ self.lp[k] = flush32(d + (self.lp[k] - d) * damp);
+ v[k] = self.lp[k] * self.gains[k];
+ sum += v[k];
+ }
+ let (mut wl, mut wr) = (0.0, 0.0);
+ for k in 0..FDN {
+ let fbk = v[k] - hh * sum;
+ self.lines[k][self.w] = flush32(fbk + input * 0.5);
+ wl += SIGN_L[k] * v[k];
+ wr += SIGN_R[k] * v[k];
+ }
+ self.w = (self.w + 1) % line_len;
+ let (wl, wr) = (wl * 0.35, wr * 0.35);
+ for (c, ch) in channels.iter_mut().enumerate() {
+ let x = ch[i];
+ let wet = if nch == 1 {
+ 0.5 * (wl + wr)
+ } else if c % 2 == 0 {
+ wl
+ } else {
+ wr
+ };
+ ch[i] = x + mix * (wet - x);
+ }
+ }
+ }
+}
+#[cfg(test)]
+mod throughput_tests {
+ use super::*;
+ #[test]
+ fn circular_reads_match_modulo_reference() {
+ for len in [3, 4, 17, 257, 14078] {
+ let buf: Vec<f32> = (0..len).map(|i| (i as f32 * 0.17).sin()).collect();
+ for w in 0..len {
+ for delay in [-10.0, 0.0, 1.0, 1.25, 2.75, len as f32 - 2.0, len as f32, f32::INFINITY] {
+ assert_eq!(read_frac(&buf, w, delay).to_bits(), read_frac_reference(&buf, w, delay).to_bits());
+ }
+ }
+ }
+ }
+ #[test]
+ fn reverb_automation_and_tail_match_original_loop() {
+ let mut fast = Reverb::new(48000.0, 2);
+ let mut reference = Reverb::new(48000.0, 2);
+ for block in 0..800 {
+ if matches!(block, 1 | 80 | 200 | 320 | 440) {
+ for fx in [&mut fast, &mut reference] {
+ fx.set_param("size", (block % 101) as f32);
+ fx.set_param("decay", 0.1 + (block % 20) as f32);
+ fx.set_param("predelay", (block % 200) as f32);
+ }
+ }
+ if block == 600 {
+ fast.reset();
+ reference.reset();
+ }
+ let n = [0, 1, 17, 64, 513][block % 5];
+ let input: Vec<f32> = (0..n).map(|i| if block > 450 { 0.0 } else { ((i + block * 13) as f32 * 0.17).sin() * 0.3 }).collect();
+ let mut a = [input.clone(), input];
+ let mut b = a.clone();
+ let [al, ar] = &mut a;
+ let [bl, br] = &mut b;
+ fast.process(&mut [al, ar]);
+ reference.process_reference(&mut [bl, br]);
+ for (a, b) in a.iter().flatten().zip(b.iter().flatten()) {
+ assert_eq!(a.to_bits(), b.to_bits(), "block {block}");
+ }
+ }
+ }
+}
diff --git a/crates/render/src/mixer.rs b/crates/render/src/mixer.rs
index 91479ede0..33daf00fd 100644
--- a/crates/render/src/mixer.rs
+++ b/crates/render/src/mixer.rs
@@ -635,14 +635,24 @@ fn run_inserts(chain: &mut [Box<dyn AudioEffect>], ins: &[Insert], buf: &mut Bus
return;
}
let n = buf[0].len();
+ // Reapply constant settings once per request (so live edits are picked up), not at every
+ // 64-sample boundary. Animated inserts keep the absolute-grid evaluation below.
+ let refresh: Vec<bool> = ins
+ .iter()
+ .map(|e| {
+ !matches!(e.effect.effect.as_str(), "parametric_eq" | "dynamics" | "studio_reverb") || e.effect.params.values().any(|p| !p.keyframes.is_empty())
+ })
+ .collect();
let mut i = 0usize;
while i < n {
let pos = x0 + i as i64;
let end = (((pos.div_euclid(PARAM_BLOCK) + 1) * PARAM_BLOCK - x0) as usize).min(n);
// parameters of the whole grid block (also when a request starts mid-block)
let t = Tick::from_units(pos.div_euclid(PARAM_BLOCK) * PARAM_BLOCK - lat as i64, sr as i64);
- for (d, e) in chain.iter_mut().zip(ins) {
- (e.map.apply)(d.as_mut(), &e.effect, t);
+ for ((d, e), refresh) in chain.iter_mut().zip(ins).zip(&refresh) {
+ if i == 0 || *refresh {
+ (e.map.apply)(d.as_mut(), &e.effect, t);
+ }
}
let mut ch: Vec<&mut [f32]> = buf.iter_mut().map(|c| &mut c[i..end]).collect();
for d in chain.iter_mut() {
diff --git a/crates/render/src/mixer_tests.rs b/crates/render/src/mixer_tests.rs
index b9705e1e3..fbaab2fe6 100644
--- a/crates/render/src/mixer_tests.rs
+++ b/crates/render/src/mixer_tests.rs
@@ -6,124 +6,21 @@ use filmcraft_frame::{AudioBuffer, VideoFrame};
use filmcraft_media::{AudioStreamInfo, FrameRequest, MediaError, MediaInfo, MediaKind, MediaSource};
use filmcraft_project::mixer::{LANE_MUTE, LANE_PAN, LANE_VOLUME, send_lane};
use filmcraft_project::{
- AudioChannels, AutomationMode, ItemId, ItemKind, Keyframe, Label, MediaClip, MediaRef, ParamValue, Project, SequenceSettings, Track, TrackId, TrackKind,
- TrackSend,
+ AudioChannels, AutomationMode, ItemId, ItemKind, Keyframe, Label, MediaClip, MediaRef, ParamValue, Project, SequenceSettings, TrackKind, TrackSend,
};
use filmcraft_time::{FrameRate, TICKS_PER_SECOND, Tick, TimeRange};
-use crate::SourceMap;
use crate::mixer::{LiveMix, balance, graph_latency, mix_graph, pan_law_mono};
+use crate::{SourceMap, mixer};
-const SR: i64 = 48_000;
-
-/// A synthetic stereo source: `f(sample, channel)`.
-struct FnSource {
- info: MediaInfo,
- f: fn(i64, usize) -> f32,
- ch: usize,
-}
-
-impl MediaSource for FnSource {
- fn info(&self) -> &MediaInfo {
- &self.info
- }
- fn video_frame(&self, _: FrameRequest) -> filmcraft_media::Result<Arc<VideoFrame>> {
- Err(MediaError::Unsupported("audio only".into()))
- }
- fn audio(&self, start: i64, frames: usize, sample_rate: u32) -> filmcraft_media::Result<AudioBuffer> {
- let f = self.f;
- Ok(AudioBuffer { sample_rate, channels: (0..self.ch).map(|c| (0..frames).map(|i| f(start + i as i64, c)).collect()).collect() })
- }
-}
-
-struct Rig {
- p: Project,
- seq: ItemId,
- map: SourceMap,
-}
-
-impl Rig {
- /// A sequence with `n` audio tracks, each holding one 10 s clip of its signal.
- fn new(signals: &[fn(i64, usize) -> f32]) -> Rig {
- Self::with_channels(signals, 2)
- }
- /// Like [`Rig::new`] with `ch`-channel sources.
- fn with_channels(signals: &[fn(i64, usize) -> f32], ch: usize) -> Rig {
- let mut p = Project::new("mix");
- let seq = p.new_sequence("s", SequenceSettings::default(), 0, signals.len(), None);
- let mut map = SourceMap::default();
- for (k, f) in signals.iter().enumerate() {
- let info = MediaInfo {
- name: format!("sig{k}"),
- kind: MediaKind::AudioOnly,
- duration: Tick(10 * TICKS_PER_SECOND),
- video: None,
- audio_streams: vec![AudioStreamInfo { sample_rate: 48_000, channels: ch as u32, codec: "test".into(), bits_per_sample: Some(32) }],
- container: "test".into(),
- start_timecode: None,
- file_size: None,
- };
- let id = p.add_item(
- &info.name.clone(),
- Label::Iris,
- ItemKind::Media(MediaClip {
- media: MediaRef::File { path: format!("/sig{k}.wav") },
- info: info.clone(),
- interpret: Default::default(),
- mark_in: None,
- mark_out: None,
- markers: vec![],
- offline: false,
- proxy: None,
- identity: None,
- }),
- None,
- );
- map.0.insert(id, Arc::new(FnSource { info, f: *f, ch }));
- let ti = p.make_track_item(id, TrackKind::Audio, Tick::ZERO, TimeRange::new(Tick::ZERO, Tick(10 * TICKS_PER_SECOND)), FrameRate::FPS_24).unwrap();
- p.sequence_mut(seq).unwrap().audio_tracks[k].items.push(ti);
- }
- Rig { p, seq, map }
- }
- fn track(&mut self, k: usize) -> &mut Track {
- &mut self.p.sequence_mut(self.seq).unwrap().audio_tracks[k]
- }
- fn add_submix(&mut self, name: &str) -> TrackId {
- let id = TrackId(self.p.alloc_id());
- self.p.sequence_mut(self.seq).unwrap().submix_tracks.push(Track::new(id, TrackKind::Audio, name.into()));
- id
- }
- fn submix(&mut self, id: TrackId) -> &mut Track {
- self.p.sequence_mut(self.seq).unwrap().mix_track_mut(id).unwrap()
- }
- fn mix(&self, start: i64, n: usize) -> [Vec<f32>; 2] {
- let b = mix_graph(&self.p, self.p.sequence(self.seq).unwrap(), start, n, &self.map, None);
- [b.channels[0].clone(), b.channels[1].clone()]
- }
- /// Mix `[start, start + n)` in consecutive requests of the given sizes (cycled).
- fn mix_cut(&self, start: i64, n: usize, sizes: &[usize], live: Option<&LiveMix>) -> [Vec<f32>; 2] {
- let mut out = [Vec::new(), Vec::new()];
- let (mut pos, mut k) = (start, 0);
- while pos < start + n as i64 {
- let m = sizes[k % sizes.len()].min((start + n as i64 - pos) as usize);
- let b = mix_graph(&self.p, self.p.sequence(self.seq).unwrap(), pos, m, &self.map, live);
- out[0].extend_from_slice(&b.channels[0]);
- out[1].extend_from_slice(&b.channels[1]);
- pos += m as i64;
- k += 1;
- }
- out
- }
-}
+#[path = "../tests/support/mixer.rs"]
+mod support;
+use support::{Rig, SR, busy_rig, kf, noise};
fn dc(_: i64, _: usize) -> f32 {
0.5
}
-fn kf(t_samples: i64, v: f64) -> Keyframe {
- Keyframe::new(Tick::from_units(t_samples, SR), ParamValue::Float(v))
-}
-
fn close(a: f32, b: f32, tol: f32) -> bool {
(a - b).abs() <= tol
}
@@ -422,35 +319,6 @@ fn latency_compensation_aligns_paths() {
assert!(close(l[1000], 0.5, 2e-3), "A1 silenced exactly at its content sample: {}", l[1000]);
}
-fn noise(i: i64, c: usize) -> f32 {
- let x = (i as u64).wrapping_mul(0x9E37_79B9_7F4A_7C15) ^ (c as u64 * 0x1234_5678);
- let x = x ^ (x >> 29);
- ((x.wrapping_mul(0xBF58_476D_1CE4_E5B9) >> 40) as f32 / (1u64 << 24) as f32 - 0.5) * 0.4
-}
-
-fn busy_rig(tracks: usize) -> Rig {
- let sig: Vec<fn(i64, usize) -> f32> = vec![noise; tracks];
- let mut r = Rig::new(&sig);
- let bus = r.add_submix("Bus");
- let mut comp = filmcraft_project::find_effect("dynamics").unwrap().instance();
- comp.param_mut("threshold").unwrap().value = ParamValue::Float(-20.0);
- r.submix(bus).effects.push(comp);
- for k in 0..tracks {
- let t = r.track(k);
- for (id, post) in [("parametric_eq", false), ("dynamics", false), ("studio_reverb", true)] {
- let mut e = filmcraft_project::find_effect(id).unwrap().instance();
- e.post_fader = post;
- t.effects.push(e);
- }
- t.pan = (k as f64 * 37.0) % 200.0 - 100.0;
- t.lane_mut(LANE_VOLUME).unwrap().keyframes = vec![kf(0, -6.0), kf(96_000, 0.0)];
- if k % 3 == 0 {
- t.mixer.sends.push(TrackSend::new(bus));
- }
- }
- r
-}
-
#[test]
fn render_and_playback_paths_are_identical() {
// export renders in large batches; playback pulls small device blocks with live meters
@@ -468,6 +336,40 @@ fn render_and_playback_paths_are_identical() {
assert_eq!(busy_rig(4).mix_cut(0, 24_000, &[8_000], None), export);
}
+#[test]
+fn constant_insert_refresh_matches_grid_refresh_and_live_edits() {
+ // A constant keyframe forces the old per-grid refresh path without changing any values.
+ fn key_all(r: &mut Rig) {
+ let seq = r.p.sequence_mut(r.seq).unwrap();
+ for t in seq.audio_tracks.iter_mut().chain(seq.submix_tracks.iter_mut()) {
+ for e in &mut t.effects {
+ for p in e.params.values_mut() {
+ p.keyframes = vec![Keyframe::new(Tick::ZERO, p.value.clone())];
+ }
+ }
+ }
+ }
+ fn render(keyed: bool) -> [Vec<f32>; 2] {
+ let mut r = busy_rig(2);
+ if keyed {
+ key_all(&mut r);
+ }
+ let mut out = r.mix_cut(0, 12_000, &[511, 1, 1024, 63], None);
+ for (slot, id, value) in [(0, "mid_gain", 8.0), (1, "threshold", -30.0), (2, "room", 80.0)] {
+ r.track(0).effects[slot].param_mut(id).unwrap().value = ParamValue::Float(value);
+ }
+ if keyed {
+ key_all(&mut r);
+ }
+ let edited = r.mix_cut(12_000, 24_000, &[17, 512, 63, 1024], None);
+ for (out, more) in out.iter_mut().zip(edited) {
+ out.extend(more);
+ }
+ out
+ }
+ assert_eq!(render(false), render(true));
+}
+
#[test]
fn live_override_holds_and_ramps_back() {
let mut r = Rig::new(&[dc]);
@@ -485,47 +387,6 @@ fn live_override_holds_and_ramps_back() {
assert!(close(b.channels[0][0], 0.5, 1e-6));
}
-/// 24 tracks × 3 inserts (EQ, Dynamics, Studio Reverb) + a compressed submix at 48 kHz, one core.
-#[test]
-// Off Unix there is no per-thread CPU clock (`thread_cpu_secs`), so the timing falls back to wall
-// time, which a loaded CI host (Windows runners run the suite in parallel) can push under the
-// threshold: genuinely timing-flaky there. On Unix it measures this thread's CPU time and stays on.
-#[cfg_attr(not(unix), ignore = "wall-clock timing without a thread CPU clock is load-dependent; run with --ignored")]
-fn perf_24_tracks_3_effects_realtime_factor() {
- let r = busy_rig(24);
- let secs = if cfg!(debug_assertions) { 2.0 } else { 10.0 };
- let n = (secs * SR as f64) as usize;
- let pool = rayon::ThreadPoolBuilder::new().num_threads(1).build().unwrap();
- // warm up (fresh graph + pre-roll), then time steady-state playback-sized blocks
- pool.install(|| r.mix_cut(0, 4_800, &[1024], None));
- // Thread CPU time, not wall clock: the test runs alongside the whole suite (and other builds),
- // and only the work done on this one thread matters.
- let el = pool.install(|| {
- let t0 = thread_cpu_secs();
- let w0 = std::time::Instant::now();
- r.mix_cut(4_800, n, &[1024], None);
- t0.map(|t0| thread_cpu_secs().unwrap_or(t0) - t0).unwrap_or_else(|| w0.elapsed().as_secs_f64())
- });
- let rt = secs / el;
- eprintln!("mixer perf: 24 tracks x 3 inserts + submix, {secs} s of 48 kHz stereo in {el:.3} s of CPU on one core = {rt:.1}x realtime");
- let min = if cfg!(debug_assertions) { 1.0 } else { 4.0 };
- assert!(rt > min, "realtime factor {rt:.2}");
-}
-
-/// CPU seconds used by the calling thread (None where there is no thread clock; callers fall back
-/// to wall time).
-fn thread_cpu_secs() -> Option<f64> {
- #[cfg(unix)]
- {
- let t = rustix::time::clock_gettime(rustix::time::ClockId::ThreadCPUTime);
- Some(t.tv_sec as f64 + t.tv_nsec as f64 * 1e-9)
- }
- #[cfg(not(unix))]
- {
- None
- }
-}
-
#[test]
fn audio_transition_curves() {
use crate::transitions::audio_gains;
diff --git a/crates/render/tests/mixer_perf.rs b/crates/render/tests/mixer_perf.rs
new file mode 100644
index 000000000..5e7baa785
--- /dev/null
+++ b/crates/render/tests/mixer_perf.rs
@@ -0,0 +1,50 @@
+//! Keep the throughput gate in its own executable so parallel correctness tests do not
+//! contend for CPU frequency, caches, or memory bandwidth during its timed workload.
+//! Cargo runs integration-test executables sequentially; the threshold is unchanged.
+
+use filmcraft_render::{SourceMap, mixer};
+
+#[path = "support/mixer.rs"]
+mod support;
+use support::{SR, busy_rig};
+
+/// 24 tracks × 3 inserts (EQ, Dynamics, Studio Reverb) + a compressed submix at 48 kHz, one core.
+#[test]
+// Off Unix there is no per-thread CPU clock (`thread_cpu_secs`), so the timing falls back to wall
+// time, which a loaded CI host (Windows runners run the suite in parallel) can push under the
+// threshold: genuinely timing-flaky there. On Unix it measures this thread's CPU time and stays on.
+#[cfg_attr(not(unix), ignore = "wall-clock timing without a thread CPU clock is load-dependent; run with --ignored")]
+fn perf_24_tracks_3_effects_realtime_factor() {
+ let r = busy_rig(24);
+ let secs = if cfg!(debug_assertions) { 2.0 } else { 10.0 };
+ let n = (secs * SR as f64) as usize;
+ let pool = rayon::ThreadPoolBuilder::new().num_threads(1).build().unwrap();
+ // warm up (fresh graph + pre-roll), then time steady-state playback-sized blocks
+ pool.install(|| r.mix_cut(0, 4_800, &[1024], None));
+ // Thread CPU time, not wall clock: only work done on this one thread matters.
+ // The separate executable also avoids interference from this crate's correctness tests.
+ let el = pool.install(|| {
+ let t0 = thread_cpu_secs();
+ let w0 = std::time::Instant::now();
+ r.mix_cut(4_800, n, &[1024], None);
+ t0.map(|t0| thread_cpu_secs().unwrap_or(t0) - t0).unwrap_or_else(|| w0.elapsed().as_secs_f64())
+ });
+ let rt = secs / el;
+ eprintln!("mixer perf: 24 tracks x 3 inserts + submix, {secs} s of 48 kHz stereo in {el:.3} s of CPU on one core = {rt:.1}x realtime");
+ let min = if cfg!(debug_assertions) { 1.0 } else { 4.0 };
+ assert!(rt > min, "realtime factor {rt:.2}");
+}
+
+/// CPU seconds used by the calling thread (None where there is no thread clock; callers fall back
+/// to wall time).
+fn thread_cpu_secs() -> Option<f64> {
+ #[cfg(unix)]
+ {
+ let t = rustix::time::clock_gettime(rustix::time::ClockId::ThreadCPUTime);
+ Some(t.tv_sec as f64 + t.tv_nsec as f64 * 1e-9)
+ }
+ #[cfg(not(unix))]
+ {
+ None
+ }
+}
diff --git a/crates/render/tests/support/mixer.rs b/crates/render/tests/support/mixer.rs
new file mode 100644
index 000000000..fa91d7cac
--- /dev/null
+++ b/crates/render/tests/support/mixer.rs
@@ -0,0 +1,148 @@
+//! Synthetic mixer fixtures shared by correctness and isolated throughput tests.
+#![allow(dead_code)] // Each test executable uses a different subset of the shared rig.
+
+use std::sync::Arc;
+
+use filmcraft_frame::{AudioBuffer, VideoFrame};
+use filmcraft_media::{AudioStreamInfo, FrameRequest, MediaError, MediaInfo, MediaKind, MediaSource};
+use filmcraft_project::mixer::LANE_VOLUME;
+use filmcraft_project::{ItemId, ItemKind, Keyframe, Label, MediaClip, MediaRef, ParamValue, Project, SequenceSettings, Track, TrackId, TrackKind, TrackSend};
+use filmcraft_time::{FrameRate, TICKS_PER_SECOND, Tick, TimeRange};
+
+use super::{SourceMap, mixer};
+use mixer::{LiveMix, mix_graph};
+
+pub(crate) const SR: i64 = 48_000;
+
+/// A synthetic stereo source: `f(sample, channel)`.
+struct FnSource {
+ info: MediaInfo,
+ f: fn(i64, usize) -> f32,
+ ch: usize,
+}
+
+impl MediaSource for FnSource {
+ fn info(&self) -> &MediaInfo {
+ &self.info
+ }
+ fn video_frame(&self, _: FrameRequest) -> filmcraft_media::Result<Arc<VideoFrame>> {
+ Err(MediaError::Unsupported("audio only".into()))
+ }
+ fn audio(&self, start: i64, frames: usize, sample_rate: u32) -> filmcraft_media::Result<AudioBuffer> {
+ let f = self.f;
+ Ok(AudioBuffer { sample_rate, channels: (0..self.ch).map(|c| (0..frames).map(|i| f(start + i as i64, c)).collect()).collect() })
+ }
+}
+
+pub(crate) struct Rig {
+ pub(crate) p: Project,
+ pub(crate) seq: ItemId,
+ pub(crate) map: SourceMap,
+}
+
+impl Rig {
+ /// A sequence with `n` audio tracks, each holding one 10 s clip of its signal.
+ pub(crate) fn new(signals: &[fn(i64, usize) -> f32]) -> Rig {
+ Self::with_channels(signals, 2)
+ }
+ /// Like [`Rig::new`] with `ch`-channel sources.
+ pub(crate) fn with_channels(signals: &[fn(i64, usize) -> f32], ch: usize) -> Rig {
+ let mut p = Project::new("mix");
+ let seq = p.new_sequence("s", SequenceSettings::default(), 0, signals.len(), None);
+ let mut map = SourceMap::default();
+ for (k, f) in signals.iter().enumerate() {
+ let info = MediaInfo {
+ name: format!("sig{k}"),
+ kind: MediaKind::AudioOnly,
+ duration: Tick(10 * TICKS_PER_SECOND),
+ video: None,
+ audio_streams: vec![AudioStreamInfo { sample_rate: 48_000, channels: ch as u32, codec: "test".into(), bits_per_sample: Some(32) }],
+ container: "test".into(),
+ start_timecode: None,
+ file_size: None,
+ };
+ let id = p.add_item(
+ &info.name.clone(),
+ Label::Iris,
+ ItemKind::Media(MediaClip {
+ media: MediaRef::File { path: format!("/sig{k}.wav") },
+ info: info.clone(),
+ interpret: Default::default(),
+ mark_in: None,
+ mark_out: None,
+ markers: vec![],
+ offline: false,
+ proxy: None,
+ identity: None,
+ }),
+ None,
+ );
+ map.0.insert(id, Arc::new(FnSource { info, f: *f, ch }));
+ let ti = p.make_track_item(id, TrackKind::Audio, Tick::ZERO, TimeRange::new(Tick::ZERO, Tick(10 * TICKS_PER_SECOND)), FrameRate::FPS_24).unwrap();
+ p.sequence_mut(seq).unwrap().audio_tracks[k].items.push(ti);
+ }
+ Rig { p, seq, map }
+ }
+ pub(crate) fn track(&mut self, k: usize) -> &mut Track {
+ &mut self.p.sequence_mut(self.seq).unwrap().audio_tracks[k]
+ }
+ pub(crate) fn add_submix(&mut self, name: &str) -> TrackId {
+ let id = TrackId(self.p.alloc_id());
+ self.p.sequence_mut(self.seq).unwrap().submix_tracks.push(Track::new(id, TrackKind::Audio, name.into()));
+ id
+ }
+ pub(crate) fn submix(&mut self, id: TrackId) -> &mut Track {
+ self.p.sequence_mut(self.seq).unwrap().mix_track_mut(id).unwrap()
+ }
+ pub(crate) fn mix(&self, start: i64, n: usize) -> [Vec<f32>; 2] {
+ let b = mix_graph(&self.p, self.p.sequence(self.seq).unwrap(), start, n, &self.map, None);
+ [b.channels[0].clone(), b.channels[1].clone()]
+ }
+ /// Mix `[start, start + n)` in consecutive requests of the given sizes (cycled).
+ pub(crate) fn mix_cut(&self, start: i64, n: usize, sizes: &[usize], live: Option<&LiveMix>) -> [Vec<f32>; 2] {
+ let mut out = [Vec::new(), Vec::new()];
+ let (mut pos, mut k) = (start, 0);
+ while pos < start + n as i64 {
+ let m = sizes[k % sizes.len()].min((start + n as i64 - pos) as usize);
+ let b = mix_graph(&self.p, self.p.sequence(self.seq).unwrap(), pos, m, &self.map, live);
+ out[0].extend_from_slice(&b.channels[0]);
+ out[1].extend_from_slice(&b.channels[1]);
+ pos += m as i64;
+ k += 1;
+ }
+ out
+ }
+}
+
+pub(crate) fn kf(t_samples: i64, v: f64) -> Keyframe {
+ Keyframe::new(Tick::from_units(t_samples, SR), ParamValue::Float(v))
+}
+
+pub(crate) fn noise(i: i64, c: usize) -> f32 {
+ let x = (i as u64).wrapping_mul(0x9E37_79B9_7F4A_7C15) ^ (c as u64 * 0x1234_5678);
+ let x = x ^ (x >> 29);
+ ((x.wrapping_mul(0xBF58_476D_1CE4_E5B9) >> 40) as f32 / (1u64 << 24) as f32 - 0.5) * 0.4
+}
+
+pub(crate) fn busy_rig(tracks: usize) -> Rig {
+ let sig: Vec<fn(i64, usize) -> f32> = vec![noise; tracks];
+ let mut r = Rig::new(&sig);
+ let bus = r.add_submix("Bus");
+ let mut comp = filmcraft_project::find_effect("dynamics").unwrap().instance();
+ comp.param_mut("threshold").unwrap().value = ParamValue::Float(-20.0);
+ r.submix(bus).effects.push(comp);
+ for k in 0..tracks {
+ let t = r.track(k);
+ for (id, post) in [("parametric_eq", false), ("dynamics", false), ("studio_reverb", true)] {
+ let mut e = filmcraft_project::find_effect(id).unwrap().instance();
+ e.post_fader = post;
+ t.effects.push(e);
+ }
+ t.pan = (k as f64 * 37.0) % 200.0 - 100.0;
+ t.lane_mut(LANE_VOLUME).unwrap().keyframes = vec![kf(0, -6.0), kf(96_000, 0.0)];
+ if k % 3 == 0 {
+ t.mixer.sends.push(TrackSend::new(bus));
+ }
+ }
+ r
+}
diff --git a/docs/AUDIO_PERFORMANCE_EVIDENCE.md b/docs/AUDIO_PERFORMANCE_EVIDENCE.md
new file mode 100644
index 000000000..7ac73392c
--- /dev/null
+++ b/docs/AUDIO_PERFORMANCE_EVIDENCE.md
@@ -0,0 +1,96 @@
+# Audio mixer optimization: correctness and performance evidence
+
+Measured 2026-10-10 against the historical development tree based on `98ba9acbcedcbb630ba2a07b782176b66835edd2`. These results validate that tree and the final audio candidate, not a subsequently rebased submission revision. The final measured audio patch SHA-256 is `ce6b8dd1ef7ee90bf8eec723e0478cfa761ea2a5c8ddcfbcce9af3cd66b43aec`.
+
+## Changes covered
+
+Static mixer inserts refresh settings once per request; keyframed inserts retain their original absolute 64-sample evaluation grid and live edits take effect at the next request. Settled EQ avoids redundant smoothing and safely bypasses exact identity bands while preserving tails, signed zero and non-finite behavior. Delay/reverb uses bounded circular indexing, caches unchanged loop gains on the original update grid, and prepares interpolation positions for settled delays once per block. Moving delays retain sample-by-sample behavior.
+
+## Correctness
+
+The final release suites passed with the existing performance gate enabled and unchanged. Four new DSP tests compare optimized processing with pre-optimization loops or reference indexing:
+
+- `flat_eq_fast_path_preserves_samples_and_filter_tails`
+- `settled_and_automated_eq_matches_original_loop`
+- `circular_reads_match_modulo_reference`
+- `reverb_automation_and_tail_match_original_loop`
+
+The render regression `constant_insert_refresh_matches_grid_refresh_and_live_edits` also passed. Coverage includes bit-exact output, automation, irregular/zero-sized blocks, reset, tails, signed zero, subnormal and non-finite samples, and live parameter edits.
+
+| Platform / final suite | DSP | Oracle integration | Render |
+|---|---:|---:|---:|
+| Linux, Intel Core i7-10700K | 123 passed, 2 ignored | 1 passed | 179 passed, 2 ignored |
+| macOS 27.2, Apple M4 | 123 passed, 2 ignored | 1 passed | 179 passed, 2 ignored |
+| Later Linux/NVIDIA host | 123 passed, 2 ignored | 1 passed | 179 passed, 2 ignored |
+
+Apple's actual command used direct Rust 1.99.0 binaries with the following arguments and environment:
+
+```sh
+RAYON_NUM_THREADS=8 cargo test --release --locked -j6 \
+ -p filmcraft-audio-dsp -p filmcraft-render
+```
+
+The final clean Intel combined suite used one test thread with no filters and no concurrent validation builds. It additionally passed export 72 plus one integration, GPU 37 plus one integration, and 33 goldens. A separate render rerun with two test threads also passed all 179 tests, with two ignored. Release all-target audio-DSP/render Clippy with warnings denied and formatting checks passed. The later NVIDIA suite included the backend fix and therefore 38 GPU tests; its combined total was 448 passed / four ignored.
+
+The retained Intel runner used:
+
+```sh
+RAYON_NUM_THREADS=8 mise exec rust@stable -- cargo test --release -j6 \
+ --no-fail-fast -p filmcraft-audio-dsp -p filmcraft-render \
+ -p filmcraft-export -p filmcraft-gpu -p filmcraft-golden \
+ -- --test-threads=1 --nocapture
+```
+
+## Paired unchanged audio workload
+
+The existing `mixer_tests::perf_24_tracks_3_effects_realtime_factor` renders ten seconds of 48 kHz stereo through 24 tracks with EQ/compression/reverb inserts and a submix. It explicitly creates one Rayon worker. On these platforms it measures that worker's thread CPU time. The release gate remains strictly greater than 4× realtime, equivalent to less than 2.5 CPU seconds. No threshold was lowered and no performance test was filtered from the final audio suites.
+
+The saved before/after executables were invoked separately with:
+
+```sh
+RAYON_NUM_THREADS=8 ./render-test-binary --exact \
+ mixer_tests::perf_24_tracks_3_effects_realtime_factor --nocapture
+```
+
+| CPU | Before CPU seconds, runs 1 / 2 | After CPU seconds, runs 1 / 2 | Before realtime | After realtime | Combined CPU-time speedup |
+|---|---:|---:|---:|---:|---:|
+| Intel Core i7-10700K | 3.923 / 4.031 | 1.312 / 1.306 | 2.5× / 2.5× | 7.6× / 7.7× | 3.04× |
+| Apple M4 | 1.722 / 1.720 | 0.609 / 0.650 | 5.8× / 5.8× | 16.4× / 15.4× | 2.73× |
+
+Combined speedup is summed before CPU seconds divided by summed after CPU seconds. Intel ran before → after → after → before; Apple ran before → after → before → after. Both Intel baseline invocations failed the unchanged gate, both final candidate invocations passed. All four Apple invocations passed. No validation build/test job ran concurrently with either paired sequence. External workload was not fully controlled: Apple's one-minute load was 25.13–25.84. Thread CPU time reduces scheduling interference but is not a guarantee of identical thermal/cache conditions.
+
+The clean Intel full suite measured 1.326 CPU seconds / 7.5× realtime; the two-test-thread render rerun measured 1.675 seconds / 6.0×. The later NVIDIA-host full suite measured 0.940 CPU seconds / 10.6×. The latter is a passing final measurement, not a paired before/after speedup or evidence that the GPU accelerated audio.
+
+## Submission-tree test isolation
+
+The independent audio submission is based on `ab7318e788528515605f02c024dc1170368964f9`. On this newer tree, the same optimized render test executable passed its unchanged timing gate alone but failed when the render correctness suite ran concurrently inside that executable. With production thin LTO, the isolated workload took 2.109 thread-CPU seconds (4.7× realtime), versus 3.843 seconds (2.6×) in the full render suite. The no-LTO executable also passed alone at 1.896 seconds (5.3×), so these observations do not establish LTO as the cause.
+
+The timing gate now lives in `crates/render/tests/mixer_perf.rs`, its own integration-test executable. Cargo runs test executables sequentially, avoiding competition with this crate's correctness tests for CPU frequency, cache and memory bandwidth. The unit tests and timing gate share the original synthetic fixture in `tests/support/mixer.rs`; there is no second, simplified workload. The 24 tracks, insert order, automated faders, submix/sends, 48 kHz stereo, 4,800-sample warmup, 1,024-sample requests, ten-second release workload, one Rayon worker, thread-CPU clock, strict greater-than-4× release threshold, debug behavior and non-Unix behavior are unchanged. This addresses test interference; the DSP and mixer changes above provide the actual throughput improvement. Other external load can still affect a timing gate.
+
+The final submission-tree workspace run passed **2,785 tests, zero failures, 41 existing ignores**, including doc tests. Render contributes 172 passing unit tests / two ignored and the passing standalone timing test; DSP contributes 123 passing unit tests / two ignored and one passing oracle integration test. The test harness used its default parallelism with no filters. To bound whole-workspace linking time, this broad run disabled release LTO while retaining optimization level 3; this is a verification-profile distinction, not a change to the checked-in release profile:
+
+```sh
+CARGO_PROFILE_RELEASE_LTO=false CARGO_BUILD_JOBS=4 RAYON_NUM_THREADS=8 \
+ cargo clippy --workspace --all-targets --release -j4 -- -D warnings
+CARGO_PROFILE_RELEASE_LTO=false CARGO_BUILD_JOBS=4 RAYON_NUM_THREADS=8 \
+ cargo test --workspace --release -j4 --no-fail-fast
+```
+
+The final production thin-LTO render run also passed: 172 unit tests / two existing ignores and the standalone gate at **1.356 thread-CPU seconds, 7.4× realtime**. Formatting, dependency layering, attribution (69 assets) and WASM (44 crates) passed on the final tree:
+
+```sh
+CARGO_BUILD_JOBS=4 RAYON_NUM_THREADS=8 \
+ cargo test --release -j4 -p filmcraft-render --lib --test mixer_perf -- --nocapture
+cargo fmt --all --check
+cargo xtask layers
+cargo xtask assets
+cargo xtask wasm
+```
+
+The production invocation did not set `CARGO_PROFILE_RELEASE_LTO`. These submission-tree results are Linux validation; the historical Apple M4 measurements above do not claim that this newer rebased tree or a sustained audio/video film export was tested on macOS.
+
+## Limitations and source audit
+
+This is a synthetic one-worker mixer workload, not end-to-end film export timing. There are two paired samples per platform and no statistical confidence interval. Earlier candidates and load-contaminated timing failures are retained in the private evidence but are not substituted for final clean results. The first optimization candidate improved performance but narrowly missed the gate in a broader Intel run, motivating the final settled-delay preparation. A later final-candidate run overlapped a queued benchmark rebuild; the clean final suites and paired runs above supersede it for throughput claims.
+
+Values were checked against the final Intel before/after test logs and consolidated audio results, Apple's `tests-candidate2.log`, `before-*.log`, `after-*.log`, `paired.log` and load snapshots, and the later NVIDIA final test log. Apple's actual paired ordering is taken from its execution log; an older consolidated prose summary gave a different ordering. Raw measurements are unchanged. Reports exclude private media identifiers, paths, machine names, account details and operational history.