valentine

Terminal control panel for the Focusrite Scarlett 18i20 — a from-scratch replacement for Focusrite Control.
Log | Files | Refs | README | LICENSE

commit 537036c0d3f21caf88150c652ed49b2e11559839
parent 41649b95e76d4e15572f71771b4b48abcba2f10c
Author: Matthew Gantenbein <ganten1998@gmail.com>
Date:   Mon,  1 Jun 2026 15:30:13 -0500

feat(spike): adatset — persisting ADAT attenuation listen-test

Sets ADAT via mixer + a given dB and LEAVES it (no revert), so we can hear
whether writing the mix bus actually attenuates ADAT. 'direct' restores
ADAT<-PCM. Isolates the audible effect from all TUI plumbing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Diffstat:
Mspike/Cargo.toml | 4++++
Aspike/src/bin/adatset.rs | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/spike/Cargo.toml b/spike/Cargo.toml @@ -51,3 +51,7 @@ path = "src/bin/adatfader.rs" rusb = { version = "0.9", features = ["vendored"] } anyhow.workspace = true scarlett-core = { path = "../scarlett-core" } + +[[bin]] +name = "adatset" +path = "src/bin/adatset.rs" diff --git a/spike/src/bin/adatset.rs b/spike/src/bin/adatset.rs @@ -0,0 +1,59 @@ +//! Persisting ADAT attenuation test. Sets the ADAT monitor group to a given dB +//! via the exact TUI path (route via mixer + set_group_level) and LEAVES it +//! there so you can listen. This isolates "does the bus write audibly change +//! ADAT?" from all TUI plumbing. +//! +//! cargo run -p spike --bin adatset -- -40 # quiet it, listen +//! cargo run -p spike --bin adatset -- 0 # back to unity (via mixer) +//! cargo run -p spike --bin adatset -- direct # restore ADAT ← PCM direct +//! +//! Run with Focusrite Control quit. + +use scarlett_core::matrix::MonitorGroup; +use scarlett_core::model::S18I20_GEN3; +use scarlett_core::mux::PORT_COUNT_18I20_GEN3; +use scarlett_core::{Scarlett, UsbTransport}; + +fn main() { + if let Err(e) = run() { + eprintln!("\x1b[31mADATSET FAILED:\x1b[0m {e}"); + std::process::exit(1); + } +} + +fn adat() -> &'static MonitorGroup { + scarlett_core::matrix::MONITOR_GROUPS + .iter() + .find(|g| g.name.starts_with("ADAT")) + .unwrap() +} + +fn run() -> Result<(), Box<dyn std::error::Error>> { + let arg = std::env::args().nth(1).unwrap_or_else(|| "-40".into()); + let mut dev = Scarlett::new(UsbTransport::open_default()?); + dev.init()?; + let pc = PORT_COUNT_18I20_GEN3; + let g = adat(); + let inputs = S18I20_GEN3.mixer_inputs() as usize; + + if arg == "direct" { + dev.route_group_direct(pc, g)?; + println!("ADAT restored to direct-from-DAW (ADAT Out ← PCM 13-20). Listen."); + return Ok(()); + } + + let db: f32 = arg.parse().map_err(|_| "pass a dB number, or 'direct'")?; + println!("Routing ADAT via mixer and setting level to {db} dB (persisting)…"); + dev.route_group_via_mixer(pc, g)?; + dev.set_group_level(g, db, inputs)?; + + // Read back so we report the truth. + let raw = dev.get_mix(g.bus_base, inputs)?; + let got = scarlett_core::matrix::mixer_value_to_db( + raw.get(g.mix_in_base as usize).copied().unwrap_or(0), + ); + println!("done. Mix bus {} input {} now reads {got:.1} dB.", g.bus_base, g.mix_in_base + 1); + println!("\n>>> LISTEN NOW: did your ADAT monitoring get quieter? <<<"); + println!("(restore with: cargo run -p spike --bin adatset -- direct)"); + Ok(()) +}