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
3 changes: 2 additions & 1 deletion crates/faderframe-engine/src/nodes/crosstalk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl Processor<EngineContext> for Crosstalk {
let params = &cx.data.params;
let static_mute = params.get(self.slots.mute) >= 0.5;
let solo_mute = params.get(self.slots.solo_mute) >= 0.5;
let solo_gain = params.get(self.slots.solo_gain).clamp(0.0, 1.0);
let auto = cx.data.timeline.automation(self.donor);
let mute_lane = auto.and_then(|a| a.mute.as_ref());
let vca_mute = auto.map_or(&[][..], |a| a.vca_mute.as_slice());
Expand All @@ -85,7 +86,7 @@ impl Processor<EngineContext> for Crosstalk {
let target = if mute || solo_mute || vca_muted {
0.0
} else {
1.0
solo_gain
};
let from = if self.gate.is_nan() {
target
Expand Down
8 changes: 7 additions & 1 deletion crates/faderframe-engine/src/nodes/strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,12 @@ impl Processor<EngineContext> for ChannelStrip {
let downmix = self.shared.downmix(params);
let static_mute = params.get(self.slots.mute) >= 0.5 && !self.solo_safe;
let solo_muted = params.get(self.slots.solo_mute) >= 0.5 && !self.solo_safe;
// Dim solo (never on a solo-safe strip).
let solo_gain = if self.solo_safe {
1.0
} else {
params.get(self.slots.solo_gain).clamp(0.0, 1.0)
};
let polarity = if params.get(self.slots.phase) >= 0.5 {
-1.0
} else {
Expand Down Expand Up @@ -626,7 +632,7 @@ impl Processor<EngineContext> for ChannelStrip {
let audible = if mute || solo_muted || vca_muted {
0.0
} else {
polarity
polarity * solo_gain
};
let (fader_m, pan_m) = if travel == 0.0 && pan_mod == 0.0 {
(fader, pan)
Expand Down
15 changes: 13 additions & 2 deletions crates/faderframe-engine/src/slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub struct StripSlots {
/// 1.0 = silenced because other tracks are soloed or a VCA is muted
/// (kept apart from `mute` so mute automation never overrides them).
pub solo_mute: ParamSlot,
/// Linear gain dim solo leaves it while other tracks are soloed (1.0
/// otherwise).
pub solo_gain: ParamSlot,
/// Linear gain of the track's VCAs whose faders are not automated
/// (automated ones come with the timeline snapshot).
pub vca: ParamSlot,
Expand All @@ -35,7 +38,7 @@ pub struct StripSlots {
pub surround: [ParamSlot; SURROUND_VALUES],
}

const STRIP_SLOT_COUNT: u32 = 9 + SURROUND_VALUES as u32;
const STRIP_SLOT_COUNT: u32 = 10 + SURROUND_VALUES as u32;

/// Parameter slots every strip and fold reads (one set per session).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -344,7 +347,8 @@ impl SlotRegistry {
pan_mode: ParamSlot(base + 6),
pan_left: ParamSlot(base + 7),
pan_right: ParamSlot(base + 8),
surround: std::array::from_fn(|i| ParamSlot(base + 9 + i as u32)),
solo_gain: ParamSlot(base + 9),
surround: std::array::from_fn(|i| ParamSlot(base + 10 + i as u32)),
};
self.strips.insert(track, s);
Ok(s)
Expand Down Expand Up @@ -621,6 +625,9 @@ impl SlotRegistry {
skip: gliding,
};
let solo = project.solo_audible();
// Dim solo: the tracks solo leaves out play this much down instead
// of muted (MIDI tracks keep playing their instruments, which dim).
let dim = project.solo_dim_gain();
if let Some(c) = &project.console {
let slot = self.console_drive()?;
table.set(slot, c.drive_db as f32);
Expand All @@ -637,6 +644,8 @@ impl SlotRegistry {
}
let folder_muted = project.folder_chain(t).iter().any(|f| f.mute);
let solo_out = solo.as_ref().is_some_and(|set| !set.contains(&t.id));
let solo_dimmed = solo_out && dim.is_some();
let solo_out = solo_out && !solo_dimmed;
if t.kind == faderframe_project::TrackKind::Midi {
let slot = self.midi_mute(t.id)?;
let muted = t.mute || folder_muted || solo_out;
Expand Down Expand Up @@ -677,6 +686,7 @@ impl SlotRegistry {
let solo_muted = vca_muted || folder_muted || solo_out;
table.set(s.mute, if t.mute { 1.0 } else { 0.0 });
table.set(s.solo_mute, if solo_muted { 1.0 } else { 0.0 });
table.set(s.solo_gain, dim.filter(|_| solo_dimmed).unwrap_or(1.0));
table.set(s.phase, if t.phase_invert { 1.0 } else { 0.0 });
if t.delay_ms != 0.0 || self.delays.contains_key(&t.id) {
let slot = self.track_delay(t.id)?;
Expand Down Expand Up @@ -727,6 +737,7 @@ impl SlotRegistry {
table.set(s.pan_right, 1.0);
table.set(s.phase, 0.0);
table.set(s.solo_mute, 0.0);
table.set(s.solo_gain, 1.0);
table.set(s.vca, 1.0);
for (slot, v) in s
.surround
Expand Down
49 changes: 49 additions & 0 deletions crates/faderframe-engine/tests/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,55 @@ fn mute_and_solo_are_applied_with_ramps() {
assert!(approx(solo[1][1000], 0.1, 1e-5), "{}", solo[1][1000]);
}

/// Dim solo: while A is soloed, B plays 20 dB down instead of muted (a
/// tenth of its level), ramped; back to muting, B goes silent, and solo
/// off brings it back whole.
#[test]
fn dim_solo_plays_the_others_down_instead_of_muting_them() {
let mut tp = TestProject::new(SR);
let a = tp.track(TrackKind::Audio, "A", ChannelLayout::Stereo);
let b = tp.track(TrackKind::Audio, "B", ChannelLayout::Stereo);
let sa = tp.dc(2, 0.1, SR as usize);
let sb = tp.dc(2, 0.2, SR as usize);
tp.clip(a, sa, MusicalTime::ZERO, SR as i64);
tp.clip(b, sb, MusicalTime::ZERO, SR as i64);
let mut r = OfflineRenderer::new(&tp.project, &tp.sources, config(), 256, 2).unwrap();
r.play_from(0).unwrap();
r.render(1024);
let mut h = History::default();
let mut edit = |tp: &mut TestProject, r: &mut OfflineRenderer, c: Command| {
let impact = h.apply(&mut tp.project, c).unwrap();
r.controller.sync(&tp.project, &tp.sources, impact).unwrap();
r.render(1024)
};
edit(&mut tp, &mut r, Command::SetSoloDim { db: Some(-20.0) });
let dimmed = edit(
&mut tp,
&mut r,
Command::SetTrackSolo { track: a, on: true },
);
assert!(
approx(dimmed[0][1000], 0.1 + 0.02, 1e-5),
"{}",
dimmed[0][1000]
);
assert!(
dimmed[0][..256].windows(2).all(|w| w[1] <= w[0] + 1e-7),
"the dim ramps down"
);
let muted = edit(&mut tp, &mut r, Command::SetSoloDim { db: None });
assert!(approx(muted[0][1000], 0.1, 1e-5), "{}", muted[0][1000]);
let back = edit(
&mut tp,
&mut r,
Command::SetTrackSolo {
track: a,
on: false,
},
);
assert!(approx(back[0][1000], 0.3, 1e-5), "{}", back[0][1000]);
}

#[test]
fn post_fader_send_feeds_aux_return() {
let mut tp = TestProject::new(SR);
Expand Down
19 changes: 19 additions & 0 deletions crates/faderframe-project/src/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,11 @@ pub enum Command {
},
/// The project's pan law: how mono pan and each channel of dual pan
/// spread a source (never balance).
/// Dim solo's level ([`crate::Project::solo_dim_db`]; `None`: solo
/// mutes).
SetSoloDim {
db: Option<f32>,
},
SetPanLaw {
law: faderframe_core::PanLaw,
},
Expand Down Expand Up @@ -1102,6 +1107,8 @@ impl Command {
MoveTrack { .. } => "Move Track".into(),
SetCrosstalk { .. } => "Analogue Crosstalk".into(),
SetPanLaw { .. } => "Pan Law".into(),
SetSoloDim { db: Some(_) } => "Dim Solo".into(),
SetSoloDim { db: None } => "Solo Mutes".into(),
SetDownmix { .. } => "Surround Downmix".into(),
SetSpeakerLayouts { .. } => "Speaker Layouts".into(),
SetConsole { console: Some(c) } => format!("Console: {}", c.name()),
Expand Down Expand Up @@ -1238,6 +1245,7 @@ impl Command {
| SetTrackPanMode { .. }
| SetTrackDualPan { .. }
| SetPanLaw { .. }
| SetSoloDim { .. }
| SetDownmix { .. }
| SetTrackSurround { .. }
| SetTrackMute { .. }
Expand Down Expand Up @@ -2291,6 +2299,17 @@ impl Command {
let old = std::mem::replace(&mut p.pan_law, law);
SetPanLaw { law: old }
}
SetSoloDim { db } => {
let db = db.map(|d| {
if d.is_finite() {
d.clamp(-60.0, 0.0)
} else {
-15.0
}
});
let old = std::mem::replace(&mut p.solo_dim_db, db);
SetSoloDim { db: old }
}
SetDownmix { downmix } => {
let old = std::mem::replace(&mut p.downmix, downmix.clamped());
SetDownmix { downmix: old }
Expand Down
26 changes: 26 additions & 0 deletions crates/faderframe-project/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ pub struct Project {
skip_serializing_if = "faderframe_core::pan::PanLaw::is_default"
)]
pub pan_law: faderframe_core::PanLaw,
/// Dim solo: while tracks are soloed the others play this many dB
/// down (negative) instead of muted; `None`: solo mutes them.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub solo_dim_db: Option<f32>,
/// How surround beds fold into stereo and mono. Files from before the
/// setting fold every speaker where it stands
/// ([`faderframe_core::surround::Downmix::BY_PLACE`]); new projects use
Expand Down Expand Up @@ -316,6 +320,7 @@ impl Project {
play_start: None,
crosstalk: false,
pan_law: faderframe_core::PanLaw::default(),
solo_dim_db: None,
downmix: faderframe_core::surround::Downmix::STANDARD,
speaker_layouts: Vec::new(),
console: None,
Expand Down Expand Up @@ -838,6 +843,27 @@ impl Project {
from == to || self.reaches(to, from, None)
}

/// Dim solo's levels to choose from (dB).
pub const SOLO_DIM_CHOICES: [f32; 5] = [-3.0, -5.0, -10.0, -15.0, -20.0];

/// Tracks solo silences: those [`Self::solo_audible`] leaves out, unless
/// solo dims them ([`Self::solo_dim_db`]); `None` when it silences
/// nothing.
pub fn solo_silenced_except(&self) -> Option<HashSet<TrackId>> {
if self.solo_dim_db.is_some() {
None
} else {
self.solo_audible()
}
}

/// The gain (linear) of a track that solo leaves out while dimming:
/// `None` when solo mutes instead.
pub fn solo_dim_gain(&self) -> Option<f32> {
self.solo_dim_db
.map(|db| faderframe_core::db_to_gain(db.clamp(-60.0, 0.0)))
}

/// Tracks audible under the current solo state, or `None` when nothing
/// is soloed.
///
Expand Down
23 changes: 23 additions & 0 deletions crates/faderframe-session/src/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,29 @@ impl GroupMenuEntry {
}

impl Session {
/// The Solo Mode entries (a solo button's menu, a track's): solo
/// mutes the other tracks, or dims them by one of
/// [`faderframe_project::Project::SOLO_DIM_CHOICES`].
pub fn solo_mode_menu(&self) -> Vec<GroupMenuEntry> {
use faderframe_project::{Command, Project};
let now = self.project().solo_dim_db;
let entry = |label: String, db: Option<f32>, separated: bool| GroupMenuEntry {
label,
action: Some(Action::Edit(Command::SetSoloDim { db })),
checked: Some(now == db),
separated,
};
std::iter::once(entry("Solo Mutes the Others".into(), None, false))
.chain(Project::SOLO_DIM_CHOICES.iter().enumerate().map(|(i, db)| {
entry(
format!("Dim Solo: the Others {db:+.0} dB"),
Some(*db),
i == 0,
)
}))
.collect()
}

/// Group and VCA entries of a track's menu.
pub fn group_menu(&self, track: TrackId) -> Vec<GroupMenuEntry> {
let p = &self.project;
Expand Down
2 changes: 1 addition & 1 deletion crates/faderframe-session/src/self_freeze/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl Drop for Job {
/// tracks keying it muted (they still key: sidechains tap them before
/// their faders). Nothing else of the project's mix is built.
pub(crate) fn trimmed(project: &Project, track: TrackId, closure: &[TrackId]) -> Project {
let solo = project.solo_audible();
let solo = project.solo_silenced_except();
let muted: Vec<(TrackId, bool)> = closure
.iter()
.filter_map(|id| project.track(*id))
Expand Down
4 changes: 2 additions & 2 deletions crates/faderframe-session/src/self_freeze/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ fn warm_up_of<'a>(tracks: impl IntoIterator<Item = &'a Track>, ms: u32) -> u32 {
impl ChainView {
/// `track`'s chain in `project`, rendered at `rate`.
pub(crate) fn of(project: &Project, track: TrackId, rate: u32) -> Self {
let solo = project.solo_audible();
let solo = project.solo_silenced_except();
let closure: Vec<&Track> = chain_closure(project, track)
.into_iter()
.filter_map(|id| project.track(id))
Expand Down Expand Up @@ -458,7 +458,7 @@ impl ChainView {
if self.warm_up_ms != warm_up {
return false;
}
let solo = project.solo_audible();
let solo = project.solo_silenced_except();
self.tracks.iter().all(|p| {
let Some(t) = project.track(p.track.id) else {
return false;
Expand Down
25 changes: 25 additions & 0 deletions crates/faderframe-view-arranger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2909,6 +2909,22 @@ impl ArrangerView {
Some(HeaderLayout::new(self.header_rect(model, t, row.y)))
}

/// A solo button's menu: the solo mode (mute or dim the others), then
/// MIDI learn of the track's solo.
fn solo_menu(model: &Session, track: TrackId, at: Point) -> HostRequest<Action> {
let target = faderframe_project::MappingTarget::TrackSolo { track };
let mut items: Vec<MenuItem<Action>> =
model.solo_mode_menu().into_iter().map(entry_item).collect();
items.push(MenuItem::disabled(model.mapping_target_label(&target)).separated());
items.extend(
model
.midi_learn_menu(target)
.into_iter()
.map(|(label, action)| MenuItem::new(label, action)),
);
HostRequest::ContextMenu { at, items }
}

fn track_menu(model: &Session, t: &Track, at: Point) -> HostRequest<Action> {
let mut items = vec![
MenuItem::new("Add Audio Track (Mono)", Action::AddTrack(TrackKind::Audio)),
Expand Down Expand Up @@ -2941,6 +2957,10 @@ impl ArrangerView {
);
// Groups and VCAs.
items.extend(model.group_menu(t.id).into_iter().map(entry_item));
items.push(MenuItem::submenu(
"Solo Mode",
model.solo_mode_menu().into_iter().map(entry_item).collect(),
));
// A sample of the selection (audio tracks), and its slices.
items.extend(sample_items(model, t.id, None));
items.extend(slice_items(model, t.id, None));
Expand Down Expand Up @@ -5316,6 +5336,11 @@ impl CanvasView<Session, Action> for ArrangerView {
items: scratch::arrangement_menu(model),
});
}
// The solo button: the solo mode, then its MIDI learn
// (as in the mixer).
Some(Hit::Header(id, HeaderPart::Solo)) => {
cx.request(Self::solo_menu(model, id, pos));
}
Some(Hit::Header(id, _)) => {
if let Some(t) = model.project().track(id) {
cx.request(Self::track_menu(model, t, pos));
Expand Down
36 changes: 36 additions & 0 deletions crates/faderframe-view-arranger/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3150,3 +3150,39 @@ fn an_automation_lane_is_sized_by_its_bottom_edge() {
);
}
}

/// A track header's solo button has the solo menu (as the mixer's): the
/// solo mode first, then its MIDI learn; the rest of the header keeps the
/// track menu.
#[test]
fn a_header_solo_button_has_the_solo_menu() {
let s = session();
let track = ArrangerView::lane_tracks(&s)[0].id;
let mut view = ArrangerView::new(Theme::default());
let size = Size::new(1400.0, 1400.0);
view.paint(&mut RecordingPainter::new(), size, &s, &Theme::default());
let l = view.header_layout(&s, track, size).unwrap();
let menu = |view: &mut ArrangerView, at: Point| {
let ev = ViewEvent::PointerDown {
pos: at,
button: PointerButton::Secondary,
modifiers: Modifiers::NONE,
clicks: 1,
};
let (_, req) = run(view, ev, size, &s);
let Some(HostRequest::ContextMenu { items, .. }) = req.into_iter().next() else {
panic!("a menu")
};
items
};
let items = menu(&mut view, l.solo.center());
assert_eq!(items[0].label, "Solo Mutes the Others");
assert!(items.iter().any(|i| i.label.starts_with("Dim Solo")));
assert!(items.iter().any(|i| i.label.starts_with("MIDI Learn")));
let items = menu(&mut view, l.name.center());
assert!(
items.iter().any(|i| i.label == "Solo Mode"),
"the track menu"
);
assert_ne!(items[0].label, "Solo Mutes the Others");
}
Loading