Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/faderframe-mix-intelligence/src/finding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => &[
Expand Down
5 changes: 5 additions & 0 deletions crates/faderframe-mix-intelligence/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions crates/faderframe-mix-intelligence/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ fn input<'a>(
rules,
cancel: None,
related: Vec::new(),
same_part: Vec::new(),
}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/faderframe-mix-intelligence/src/tests_more.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TrackId> = selected.iter().map(|i| TrackId(*i)).collect();
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
Expand Down
14 changes: 14 additions & 0 deletions crates/faderframe-project/src/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,12 @@ pub enum Command {
track: TrackId,
role: Option<faderframe_core::TrackRole>,
},
/// 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,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -1289,6 +1297,7 @@ impl Command {
// Moves nothing: tempo changes from now on keep its place.
| SetTrackTimeBase { .. }
| SetTrackRole { .. }
| SetTrackMixPart { .. }
| SetClipLink { .. }
| SetAlbum { .. }
| SetLyrics { .. }
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions crates/faderframe-project/src/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,12 @@ pub struct Track {
/// sets it.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub role: Option<faderframe_core::TrackRole>,
/// 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<crate::modulation::Modulator>,
Expand Down Expand Up @@ -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,
Expand Down
68 changes: 68 additions & 0 deletions crates/faderframe-session/src/mix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TrackProfile>)>,
/// Tracks playing one part together ([`parts`]): never compared with
/// each other for masking (phase and timing still are).
part_pairs: Vec<(TrackId, TrackId)>,
}

impl Shared {
Expand Down Expand Up @@ -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<TrackId>, Option<TrackRole>)> {
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<TrackId> = 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<Option<TrackRole>> = 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<Planned>,
base: Project,
Expand Down Expand Up @@ -1120,6 +1159,7 @@ fn source_worker(
rules: &shared.rules,
cancel: Some(&progress.render.cancel),
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.
Expand Down Expand Up @@ -1975,6 +2015,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();
Expand Down Expand Up @@ -2068,6 +2134,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.
Expand Down Expand Up @@ -3286,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)
Expand Down
1 change: 1 addition & 0 deletions crates/faderframe-session/src/mix/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ fn diagnose_signals<'a>(
rules: &shared.rules,
cancel: Some(cancel),
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<TrackId> = planned
Expand Down
2 changes: 2 additions & 0 deletions crates/faderframe-session/src/self_freeze/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ fn normalized(t: &Track, midi: bool) -> Track {
ripple_excluded: _,
time_base: _,
role: _,
mix_part: _,
modulators,
containers,
no_self_freeze: _,
Expand Down Expand Up @@ -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: _,
Expand Down
68 changes: 68 additions & 0 deletions crates/faderframe-session/tests/mix_apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Finding> = 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"
);
}
39 changes: 39 additions & 0 deletions crates/faderframe-session/tests/mix_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
}
Loading