From d2e981dc0f9470d5e75660a3e7e6aa9d0e6d8461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kozio=C5=82?= Date: Sat, 14 Nov 2026 12:36:53 +0100 Subject: [PATCH 1/2] Mix Intelligence: a bus marked One Part is analysed in place of its tracks Doubled guitars routed into one bus were compared with each other ("Guitar L may mask Guitar R") and each on its own with the rest of the mix, so an EQ cut went onto one of them. A bus can now be marked One Part (Track::mix_part, Command::SetTrackMixPart; a switch beside its role in the Roles panel). In masking such a bus stands for the analysed tracks feeding it: it is compared with the rest of the mix (its EQ cuts go on it, and it takes their role when they share one), and they are not compared, nor with each other. Measuring sources, where no bus is measured, only their pairs are left out. Without the mark nothing changes. Co-Authored-By: Claude Opus 5.5 --- .../src/finding.rs | 4 +- crates/faderframe-project/src/edit.rs | 14 ++++ crates/faderframe-project/src/track.rs | 7 ++ crates/faderframe-session/src/mix.rs | 68 ++++++++++++++++++- crates/faderframe-session/src/mix/capture.rs | 5 +- .../faderframe-session/src/self_freeze/key.rs | 2 + crates/faderframe-session/tests/mix_apply.rs | 68 +++++++++++++++++++ crates/faderframe-view-mix/src/lib.rs | 34 +++++++++- docs/ARCHITECTURE.md | 8 ++- 9 files changed, 204 insertions(+), 6 deletions(-) diff --git a/crates/faderframe-mix-intelligence/src/finding.rs b/crates/faderframe-mix-intelligence/src/finding.rs index 9a69077f..61eecfb8 100644 --- a/crates/faderframe-mix-intelligence/src/finding.rs +++ b/crates/faderframe-mix-intelligence/src/finding.rs @@ -467,7 +467,9 @@ impl RuleId { track's.", "A track is not compared with a bus or return it reaches (that carries the \ track itself, or its effect); a bus summing other tracks is not compared \ - either — its tracks are.", + either — its tracks are — unless it is marked One Part (Roles): then the \ + bus is compared in their place and its tracks are not, nor with each \ + other (doubled guitars, stacked vocals).", "Phase interaction between the tracks is not measured.", ], RuleId::MasterTruePeak => &[ diff --git a/crates/faderframe-project/src/edit.rs b/crates/faderframe-project/src/edit.rs index 6f303a03..a6892048 100644 --- a/crates/faderframe-project/src/edit.rs +++ b/crates/faderframe-project/src/edit.rs @@ -449,6 +449,12 @@ pub enum Command { track: TrackId, role: Option, }, + /// Whether Mix Intelligence analyses a bus as one part + /// ([`Track::mix_part`]). + SetTrackMixPart { + track: TrackId, + on: bool, + }, /// Freeze (`Some`) or unfreeze a track. SetTrackFreeze { track: TrackId, @@ -1091,6 +1097,8 @@ impl Command { } => "Include in Ripple".into(), SetTrackTimeBase { base, .. } => format!("Time Base: {}", base.label()), SetTrackRole { .. } => "Set Track Role".into(), + SetTrackMixPart { on: true, .. } => "Analyse as One Part".into(), + SetTrackMixPart { on: false, .. } => "Analyse Its Tracks".into(), SetTrackFreeze { freeze: Some(_), .. } => "Freeze Track".into(), @@ -1289,6 +1297,7 @@ impl Command { // Moves nothing: tempo changes from now on keep its place. | SetTrackTimeBase { .. } | SetTrackRole { .. } + | SetTrackMixPart { .. } | SetClipLink { .. } | SetAlbum { .. } | SetLyrics { .. } @@ -2119,6 +2128,11 @@ impl Command { let old = std::mem::replace(&mut t.role, role); SetTrackRole { track, role: old } } + SetTrackMixPart { track, on } => { + let t = track_mut(p, track)?; + let old = std::mem::replace(&mut t.mix_part, on); + SetTrackMixPart { track, on: old } + } SetTrackFreeze { track, freeze } => { let t = track_mut(p, track)?; let old = std::mem::replace(&mut t.freeze, freeze); diff --git a/crates/faderframe-project/src/track.rs b/crates/faderframe-project/src/track.rs index e1dfc60b..0eb58781 100644 --- a/crates/faderframe-project/src/track.rs +++ b/crates/faderframe-project/src/track.rs @@ -625,6 +625,12 @@ pub struct Track { /// sets it. #[serde(default, skip_serializing_if = "Option::is_none")] pub role: Option, + /// A bus Mix Intelligence analyses as one part: in masking it stands + /// for the tracks it sums (doubled guitars, stacked vocals), which are + /// then not compared themselves, nor with each other. + /// [`crate::Command::SetTrackMixPart`] sets it. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub mix_part: bool, /// Sources that move the track's parameters (LFOs, followers, …). #[serde(default, skip_serializing_if = "Vec::is_empty")] pub modulators: Vec, @@ -765,6 +771,7 @@ impl Track { ripple_excluded: false, time_base: TimeBase::Musical, role: None, + mix_part: false, modulators: Vec::new(), containers: Default::default(), no_self_freeze: false, diff --git a/crates/faderframe-session/src/mix.rs b/crates/faderframe-session/src/mix.rs index 30c7b817..5a181350 100644 --- a/crates/faderframe-session/src/mix.rs +++ b/crates/faderframe-session/src/mix.rs @@ -485,6 +485,9 @@ struct Shared { /// `u64::MAX`), shown for a signal still being measured again while /// the tracks a change reached are shown already. previous: Vec<(u64, Arc)>, + /// Tracks playing one part together ([`parts`]): never compared with + /// each other for masking. + part_pairs: Vec<(TrackId, TrackId)>, } impl Shared { @@ -910,6 +913,42 @@ fn eq_slot( } } +/// Buses Mix Intelligence analyses as one part ([`Track::mix_part`]): each +/// with the analysed tracks (`planned`, compared) feeding it, and their +/// role when they share one. +fn parts( + project: &Project, + planned: &[Planned], +) -> Vec<(TrackId, Vec, Option)> { + let edges = project.routing_edges(); + let mut out = Vec::new(); + for bus in project + .tracks + .iter() + .filter(|t| t.kind == TrackKind::Bus && t.mix_part) + { + let mut members: Vec = edges + .iter() + .filter(|(from, to)| { + *to == bus.id && planned.iter().any(|p| p.track == *from && p.compare) + }) + .map(|(from, _)| *from) + .collect(); + members.sort_unstable(); + members.dedup(); + if members.is_empty() { + continue; + } + let roles: Vec> = members + .iter() + .map(|m| planned.iter().find(|p| p.track == *m).and_then(|p| p.role)) + .collect(); + let role = roles[0].filter(|_| roles.windows(2).all(|w| w[0] == w[1])); + out.push((bus.id, members, role)); + } + out +} + fn job_worker( planned: Vec, base: Project, @@ -1119,7 +1158,7 @@ fn source_worker( sections: shared.sections.clone(), rules: &shared.rules, cancel: Some(&progress.render.cancel), - related: Vec::new(), + related: shared.part_pairs.clone(), }; let mut report = faderframe_mix_intelligence::diagnose(&input).map_err(|e| e.to_string())?; // DC offsets in the material itself. @@ -1975,6 +2014,32 @@ impl Session { }); } } + // Buses analysed as one part (doubled guitars, backing vocals: see + // [`parts`]) are one sound in masking: the bus is compared with + // the rest of the mix, so its EQ goes there, and the tracks are not + // (with each other least of all). Measuring sources (no bus), the + // tracks stay compared, never with each other. + let mut part_pairs = Vec::new(); + for (bus, members, role) in parts(&base, &planned) { + for (i, &x) in members.iter().enumerate() { + for &y in &members[i + 1..] { + part_pairs.push((x, y)); + } + } + let Some(at) = planned.iter().position(|p| p.track == bus) else { + continue; + }; + let focus = planned + .iter() + .any(|p| p.focus && members.contains(&p.track)); + for p in planned.iter_mut().filter(|p| members.contains(&p.track)) { + p.compare = false; + } + let b = &mut planned[at]; + b.compare = true; + b.focus |= focus; + b.role = b.role.or(role); + } // Sections in the range (seconds from its start; samples for the // master's loudness per section). let mut sections = Vec::new(); @@ -2068,6 +2133,7 @@ impl Session { extra: extra_plan, held: self.mix.held.snapshot(), previous: Vec::new(), + part_pairs, }; // The last analysis' signals of the same range and settings: shown // for those being measured again while the changed tracks are shown. diff --git a/crates/faderframe-session/src/mix/capture.rs b/crates/faderframe-session/src/mix/capture.rs index e56c6318..769d16b8 100644 --- a/crates/faderframe-session/src/mix/capture.rs +++ b/crates/faderframe-session/src/mix/capture.rs @@ -519,7 +519,10 @@ fn diagnose_signals<'a>( sections: shared.sections.clone(), rules: &shared.rules, cancel: Some(cancel), - related: related(base, &ids), + related: related(base, &ids) + .into_iter() + .chain(shared.part_pairs.iter().copied()) + .collect(), }; let mut report = faderframe_mix_intelligence::diagnose(&input).map_err(|e| e.to_string())?; let focus: Vec = planned diff --git a/crates/faderframe-session/src/self_freeze/key.rs b/crates/faderframe-session/src/self_freeze/key.rs index 87e6d2b2..b9ab5d51 100644 --- a/crates/faderframe-session/src/self_freeze/key.rs +++ b/crates/faderframe-session/src/self_freeze/key.rs @@ -148,6 +148,7 @@ fn normalized(t: &Track, midi: bool) -> Track { ripple_excluded: _, time_base: _, role: _, + mix_part: _, modulators, containers, no_self_freeze: _, @@ -221,6 +222,7 @@ fn same_track(kept: &Track, t: &Track, midi: bool) -> bool { ripple_excluded: _, time_base: _, role: _, + mix_part: _, modulators, containers, no_self_freeze: _, diff --git a/crates/faderframe-session/tests/mix_apply.rs b/crates/faderframe-session/tests/mix_apply.rs index 26ab8a35..3085dfdb 100644 --- a/crates/faderframe-session/tests/mix_apply.rs +++ b/crates/faderframe-session/tests/mix_apply.rs @@ -237,3 +237,71 @@ fn an_experiment_applied_before_other_edits_is_taken_back_alone() { assert!(s.dispatch(Action::Mix(MixOp::Undo(step))).is_err()); s.wait_for_mix(); } + +/// A bus analysed as one part (doubled guitars into one bus): in masking +/// the bus stands for its tracks — they are not compared, with each other +/// least of all — and an EQ cut it gets goes on the bus. Off, the tracks +/// are compared as before. +#[test] +fn a_bus_analysed_as_one_part_stands_for_its_tracks() { + use faderframe_project::OutputRouting; + let mut p = Project::new("Doubles", SR); + let a = sine(&mut p, "Guitar L", 80.0, 0.3, 0.0, 8.0); + let b = sine(&mut p, "Guitar R", 84.0, 0.3, 0.0, 8.0); + let other = sine(&mut p, "Keys", 82.0, 0.3, 0.0, 8.0); + let bus: TrackId = p.ids.allocate(); + let mut t = Track::new(bus, TrackKind::Bus, "Guitars", TrackColor::palette(2)); + t.mix_part = true; + p.tracks.push(t); + for g in [a, b] { + p.track_mut(g).unwrap().output = OutputRouting::Track { track: bus }; + } + let mut s = Session::new(p, None, EngineConfig::default()).unwrap(); + analyse(&mut s, MixScope::Project, SignalPoint::Processed); + let masking: Vec = s + .mix_findings() + .into_iter() + .filter(|f| f.rule == RuleId::SpectralMasking) + .cloned() + .collect(); + assert!(!masking.is_empty(), "the part against the keys"); + for f in &masking { + assert!( + !f.tracks.contains(&a) && !f.tracks.contains(&b), + "its tracks are not compared: {:?}", + f.tracks + ); + assert!( + f.tracks.contains(&bus) && f.tracks.contains(&other), + "{:?}", + f.tracks + ); + for r in &f.recommendations { + if let Experiment::EqCut { track, .. } = r.experiment { + assert!(track == bus || track == other, "an EQ on {track:?}"); + } + } + } + assert!( + masking.iter().any(|f| f + .recommendations + .iter() + .any(|r| matches!(r.experiment, Experiment::EqCut { track, .. } if track == bus))), + "an EQ cut on the bus" + ); + // Off: the guitars are compared again, with each other too. + s.dispatch(Action::Edit(Command::SetTrackMixPart { + track: bus, + on: false, + })) + .unwrap(); + analyse(&mut s, MixScope::Project, SignalPoint::Processed); + assert!( + s.mix_findings() + .into_iter() + .any(|f| f.rule == RuleId::SpectralMasking + && f.tracks.contains(&a) + && f.tracks.contains(&b)), + "the doubles against each other" + ); +} diff --git a/crates/faderframe-view-mix/src/lib.rs b/crates/faderframe-view-mix/src/lib.rs index d77703c3..1fa1cd52 100644 --- a/crates/faderframe-view-mix/src/lib.rs +++ b/crates/faderframe-view-mix/src/lib.rs @@ -63,6 +63,8 @@ pub enum Hit { Match, Reject, Role(TrackId), + /// A bus analysed as one part, or its tracks (a switch). + Part(TrackId), Levels, } @@ -1724,7 +1726,10 @@ impl MixView { w, "What each track plays. The analysis weighs pairs by roles (a lead vocal over its \ accompaniment, a kick against its bass; parts of one drum kit are not compared). \ - Track names are never read as roles; tracks without one are analysed neutrally.", + Track names are never read as roles; tracks without one are analysed neutrally. \ + A bus marked One Part (doubled guitars, stacked vocals) is compared with the rest \ + in their place, and its EQ goes there; its tracks are not compared, nor with each \ + other.", th.fonts.small, th.ui.text_dim, ); @@ -1737,15 +1742,33 @@ impl MixView { &TextStyle::new(th.fonts.small, th.ui.text), ); let label = role.map_or("No role", TrackRole::label); + let bus = model + .project() + .track(t) + .filter(|t| t.kind == faderframe_project::TrackKind::Bus); + // A bus: its role, and the One Part switch beside it. + let role_w = if bus.is_some() { w * 0.3 } else { w * 0.5 }; self.button( p, - Rect::new(x + w * 0.5, y + 2.0, w * 0.5, 20.0), + Rect::new(x + w * 0.5, y + 2.0, role_w, 20.0), label, Hit::Role(t), role.is_some(), true, "Choose what the track plays", ); + if let Some(b) = bus { + self.button( + p, + Rect::new(x + w * 0.8 + 4.0, y + 2.0, w * 0.2 - 4.0, 20.0), + "One Part", + Hit::Part(t), + b.mix_part, + true, + "Analyse the bus as one part: in masking it stands for the tracks it sums \ + (doubled guitars, stacked vocals), and their EQ goes on it", + ); + } p.hline(r.x, r.right(), r.bottom(), th.ui.border.with_alpha(0.4)); y += 26.0; } @@ -2248,6 +2271,13 @@ impl MixView { cx.emit(Action::Mix(MixOp::LoudnessMatch(!on))); } Hit::Reject => cx.emit(Action::Mix(MixOp::Reject)), + Hit::Part(t) => { + let on = model.project().track(t).is_some_and(|t| t.mix_part); + cx.emit(Action::Edit(faderframe_project::Command::SetTrackMixPart { + track: t, + on: !on, + })); + } Hit::Role(t) => { let now = model.project().track(t).and_then(|t| t.role); cx.request(HostRequest::ContextMenu { diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index dd7d35b9..7fd3096e 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -12132,7 +12132,13 @@ and FNV fingerprints keep ids and cache keys stable). Three layers: importance, confidence = signal × roles × amount × level × resolution. Track roles (`Track::role`, `Command::SetTrackRole`, set only by the user; names are never taken for roles) weigh the pair (drum-kit pairs - are not compared, kick/bass and foreground targets weigh most). + are not compared, kick/bass and foreground targets weigh most). A bus + marked One Part (`Track::mix_part`, `Command::SetTrackMixPart`, the + Roles panel) stands for the tracks it sums: it is compared in their + place, so its EQ cuts go on it, and they are not compared, nor with each + other (`session::mix::parts`; measuring sources, where no bus is + measured, only their pairs are left out); it takes their role when they + share one. *Levels*: master true peak over −1 dBTP, overs, a track over full scale alone, non-finite samples, adjacent sections 8 LU apart. *Stereo*: fold-down loss against the sum without cancellation (`(√L+√R)²/4`: a From afffc079090f5619ef8667539a159a0193df64fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kozio=C5=82?= Date: Sat, 14 Nov 2026 13:03:16 +0100 Subject: [PATCH 2/2] Mix Intelligence: One Part leaves masking alone, never phase The pairs of a One Part bus's tracks went into the related pairs, which the phase and timing stage skips too: two microphones on a snare in such a bus were no longer checked for polarity. DiagnoseInput gets same_part, read by masking only; phase and timing pairs are chosen as before. Co-Authored-By: Claude Opus 5.5 --- .../faderframe-mix-intelligence/src/rules.rs | 5 +++ .../faderframe-mix-intelligence/src/tests.rs | 1 + .../src/tests_more.rs | 4 ++ crates/faderframe-session/src/mix.rs | 6 ++- crates/faderframe-session/src/mix/capture.rs | 6 +-- crates/faderframe-session/tests/mix_phase.rs | 39 +++++++++++++++++++ 6 files changed, 55 insertions(+), 6 deletions(-) diff --git a/crates/faderframe-mix-intelligence/src/rules.rs b/crates/faderframe-mix-intelligence/src/rules.rs index d9efb752..ad405408 100644 --- a/crates/faderframe-mix-intelligence/src/rules.rs +++ b/crates/faderframe-mix-intelligence/src/rules.rs @@ -86,6 +86,10 @@ pub struct DiagnoseInput<'a> { /// Pairs never compared for masking (either order): a track and a bus /// or return its signal reaches (that one carries it). pub related: Vec<(TrackId, TrackId)>, + /// Pairs playing one part (the tracks a bus marked One Part sums: two + /// microphones on a kick, doubled guitars): not compared for masking, + /// still for phase and timing. + pub same_part: Vec<(TrackId, TrackId)>, } /// One subject's levels and stereo picture (facts, no judgement). @@ -576,6 +580,7 @@ fn masking( if input .related .iter() + .chain(&input.same_part) .any(|&(x, y)| (x, y) == (a.track, b.track) || (y, x) == (a.track, b.track)) { continue; diff --git a/crates/faderframe-mix-intelligence/src/tests.rs b/crates/faderframe-mix-intelligence/src/tests.rs index 4ebba14b..5e85dd62 100644 --- a/crates/faderframe-mix-intelligence/src/tests.rs +++ b/crates/faderframe-mix-intelligence/src/tests.rs @@ -84,6 +84,7 @@ fn input<'a>( rules, cancel: None, related: Vec::new(), + same_part: Vec::new(), } } diff --git a/crates/faderframe-mix-intelligence/src/tests_more.rs b/crates/faderframe-mix-intelligence/src/tests_more.rs index 019562b7..6d86d743 100644 --- a/crates/faderframe-mix-intelligence/src/tests_more.rs +++ b/crates/faderframe-mix-intelligence/src/tests_more.rs @@ -52,6 +52,7 @@ fn run_pairs(tracks: &[T], selected: &[u64]) -> Report { rules: &rules, cancel: None, related: Vec::new(), + same_part: Vec::new(), }; let mut report = diagnose(&input).unwrap_or_default(); let selected: Vec = selected.iter().map(|i| TrackId(*i)).collect(); @@ -483,6 +484,7 @@ fn run_with_master(tracks: &[T], master: Option<&T>, signal: SignalPoint) -> Rep rules: &rules, cancel: None, related: Vec::new(), + same_part: Vec::new(), }; diagnose(&input).unwrap_or_default() } @@ -585,6 +587,7 @@ fn flatten_report(source: &[f32], processed: &[f32], sends: bool) -> Report { rules: &rules, cancel: None, related: Vec::new(), + same_part: Vec::new(), }; let mut report = diagnose(&input).unwrap_or_default(); let extra = ExtraInput { @@ -724,6 +727,7 @@ fn diagnose_two(a: &T, b: &T, rules: &Rules) -> Report { rules, cancel: None, related: Vec::new(), + same_part: Vec::new(), }; diagnose(&input).unwrap_or_default() } diff --git a/crates/faderframe-session/src/mix.rs b/crates/faderframe-session/src/mix.rs index 5a181350..66cb0a90 100644 --- a/crates/faderframe-session/src/mix.rs +++ b/crates/faderframe-session/src/mix.rs @@ -486,7 +486,7 @@ struct Shared { /// the tracks a change reached are shown already. previous: Vec<(u64, Arc)>, /// Tracks playing one part together ([`parts`]): never compared with - /// each other for masking. + /// each other for masking (phase and timing still are). part_pairs: Vec<(TrackId, TrackId)>, } @@ -1158,7 +1158,8 @@ fn source_worker( sections: shared.sections.clone(), rules: &shared.rules, cancel: Some(&progress.render.cancel), - related: shared.part_pairs.clone(), + related: Vec::new(), + same_part: shared.part_pairs.clone(), }; let mut report = faderframe_mix_intelligence::diagnose(&input).map_err(|e| e.to_string())?; // DC offsets in the material itself. @@ -3352,6 +3353,7 @@ mod tests { rules: &rules, cancel: None, related: Vec::new(), + same_part: Vec::new(), }; let _ = faderframe_mix_intelligence::diagnose(&input).unwrap_or_else(|e| panic!("{e}")); (t0.elapsed().as_secs_f64(), tracks.len() + 1) diff --git a/crates/faderframe-session/src/mix/capture.rs b/crates/faderframe-session/src/mix/capture.rs index 769d16b8..9a566b32 100644 --- a/crates/faderframe-session/src/mix/capture.rs +++ b/crates/faderframe-session/src/mix/capture.rs @@ -519,10 +519,8 @@ fn diagnose_signals<'a>( sections: shared.sections.clone(), rules: &shared.rules, cancel: Some(cancel), - related: related(base, &ids) - .into_iter() - .chain(shared.part_pairs.iter().copied()) - .collect(), + related: related(base, &ids), + same_part: shared.part_pairs.clone(), }; let mut report = faderframe_mix_intelligence::diagnose(&input).map_err(|e| e.to_string())?; let focus: Vec = planned diff --git a/crates/faderframe-session/tests/mix_phase.rs b/crates/faderframe-session/tests/mix_phase.rs index 66b759e6..ccacc955 100644 --- a/crates/faderframe-session/tests/mix_phase.rs +++ b/crates/faderframe-session/tests/mix_phase.rs @@ -396,3 +396,42 @@ fn a_panned_copy_is_the_same_audio_not_masking() { ); } } + +/// Two microphones on one snare summed in a bus marked One Part: in masking +/// the bus stands for them (they are not compared with each other), but +/// their phase is still measured — an inverted bottom microphone is found. +#[test] +fn microphones_in_a_one_part_bus_are_still_checked_for_phase() { + use faderframe_project::{OutputRouting, TrackColor, TrackKind}; + let mut p = Project::new("Phase", SR); + let a = generated(&mut p, "Snare Top", drums(7), Some(TrackRole::Snare)); + let b = generated(&mut p, "Snare Bottom", drums(7), Some(TrackRole::Snare)); + { + let t = track_mut(&mut p, b); + t.phase_invert = true; + t.volume_db = -3.0; + } + let bus: TrackId = p.ids.allocate(); + let mut t = Track::new(bus, TrackKind::Bus, "Snare", TrackColor::palette(2)); + t.mix_part = true; + p.tracks.push(t); + for m in [a, b] { + track_mut(&mut p, m).output = OutputRouting::Track { track: bus }; + } + let mut s = Session::new(p, None, EngineConfig::default()).unwrap(); + analyse(&mut s, SignalPoint::Processed); + let found = of_rule(&s, RuleId::PolarityInverted); + assert_eq!( + found.len(), + 1, + "{:#?}", + s.mix_results().unwrap().report.findings + ); + assert_eq!(found[0].subject, Subject::Tracks { a, b }); + assert!( + !of_rule(&s, RuleId::SpectralMasking) + .iter() + .any(|f| f.tracks.contains(&a) && f.tracks.contains(&b)), + "not compared for masking" + ); +}