Skip to main content

secs_engine/
lib.rs

1#![forbid(unsafe_code)]
2#![deny(unsafe_op_in_unsafe_fn)]
3//! The correction design of SECS 2, translated function by function.
4//!
5//! Upstream sources: `correction_engine.py`, the compute half of
6//! `calibration.py`, `mimo.py`, `mimo_iir.py`, `scorecard.py`.
7//!
8//! The interface is one call: measurements, settings, tuning and a compute
9//! context in, an immutable result out. Internally the work is cut into deep
10//! modules (docs/ARCHITECTURE.md, "Engine"):
11//!
12//! - **measurement**: the one time-axis convention (earliest arrival at the
13//!   main position is zero, lift, shift), windows, a proper low-rate
14//!   projection for MIMO.
15//! - **target**: target curve and level reference, evaluated once per grid.
16//! - **filters**: RBJ/LR/BW/all-pass responses and the single PEQ fitter with
17//!   named limit bundles (RC, sub bus, bundle, XO, MIMO path).
18//! - **ba**: bass alignment (auto, fixed, bundles, DBA and multi-sub layouts,
19//!   infra sub, two-way level match, bus level, bus PEQ, bus delay/polarity).
20//! - **xo**: crossover groups, XO target PEQ, the recommendation.
21//! - **rc**: per-channel room correction (magnitude design, common excess
22//!   phase, FIR realisation ladder, PEQ refit, touch-up), Schroeder range.
23//! - **decay**: late-energy windows, mode T60, late peaks, "do no harm" guards.
24//! - **chain**: the DSP topology as one value; the response simulator here and
25//!   the CamillaDSP writer in `secs-camilla` read the same value.
26//! - **mimo**: support planning, regularised ideal supports (the λ search of
27//!   the ideal FIR goes through the `RidgeBackend` seam: CPU `RidgeSweep`
28//!   here, CUDA f64 in `secs-gpu`, ADR 0008), IIR or FIR realisation (IIR
29//!   always runs on the CPU).
30//! - **scorecard**: typed metrics before and after.
31//!
32//! Engine knobs that SECS 2 hid in environment variables are fields of an
33//! explicit tuning value. Defects fixed on the way are listed in
34//! docs/DEVIATIONS.md.
35
36pub mod grid;
37pub mod input;
38
39// The stages are private: `design` is the one entry point and the values it
40// returns are re-exported below. Helpers only the oracle tests call yet keep
41// the dead-code allowance.
42#[allow(dead_code)]
43mod ba;
44#[allow(dead_code)]
45mod calibration;
46#[allow(dead_code)]
47mod chain;
48#[allow(dead_code)]
49mod decay;
50#[allow(dead_code)]
51mod design;
52pub mod display;
53pub mod export_view;
54#[allow(dead_code)]
55mod fit;
56#[allow(dead_code)]
57mod levels;
58mod low_protect;
59#[allow(dead_code)]
60mod measurement;
61mod memory;
62#[allow(dead_code)]
63pub mod mimo;
64mod normalize;
65#[allow(dead_code)]
66mod notes;
67pub mod pair_phase;
68pub mod polarity;
69pub mod preview;
70#[allow(dead_code)]
71mod rc;
72mod replay;
73mod replay_mimo;
74#[allow(dead_code)]
75mod scorecard;
76#[allow(dead_code)]
77mod setup;
78#[allow(dead_code)]
79pub mod xo;
80
81mod error;
82#[cfg(test)]
83pub mod test_support;
84#[cfg(feature = "test-support")]
85#[doc(hidden)]
86pub mod testkit;
87#[cfg(test)]
88mod tests;
89
90pub use ba::{LayoutInfo, ManualPlan};
91pub use calibration::{
92    Calibration, CalibrationRequest, EngineInputs, ProjectView, calibrate, calibrate_with,
93    engine_inputs,
94};
95pub use chain::{BaRow, StageResponses, input_response, stage_responses};
96pub use design::{
97    Design, DesignRequest, DesignSpectra, FitStage, FitterFactory, MainDesign, RoleLateEnergy,
98    RoleScores, SubDesign, design, late_energy, production_fitters, production_fitters_with,
99};
100pub use error::EngineError;
101pub use export_view::{ExportView, export_view};
102pub use fit::{FitRequest, Fitter, PeqDerivatives, fit_peq_with};
103pub use input::{EngineConfig, Measurement, MeasurementSet, Samples, Tuning};
104pub use measurement::{Spectra, long_spectra};
105pub use mimo::{
106    IirDerivatives, IirSolveOptions, IirSolver, IirSupport, MimoDesign, MimoIir, MimoKey,
107    MimoRequest, MimoRoleLateEnergy, MimoRoleScore, MimoRun, design_mimo, design_mimo_iir,
108    design_mimo_iir_with_options,
109};
110pub use normalize::normalize_measurements;
111pub use notes::{GuardCause, MimoNote, Note};
112pub use replay::{DesignReplay, ExportAxis};
113pub use scorecard::Metrics;
114pub use secs_dsp::resample::{MAX_RESAMPLE_RATE, MIN_RESAMPLE_RATE};
115pub use setup::SubFilter;
116
117/// Complex spectrum value.
118pub type C = secs_dsp::Complex64;