use secs_types::target::TargetCurve;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub enum Samples {
F32(Arc<[f32]>),
F64(Arc<[f64]>),
}
impl Samples {
pub fn len(&self) -> usize {
match self {
Self::F32(s) => s.len(),
Self::F64(s) => s.len(),
}
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
pub fn at(&self, i: usize) -> f64 {
match self {
Self::F32(s) => f64::from(s[i]),
Self::F64(s) => s[i],
}
}
}
#[derive(Debug, Clone)]
pub struct Measurement {
pub samples: Samples,
pub sample_rate: u32,
pub t0: f64,
}
#[derive(Debug, Clone, Default)]
pub struct MeasurementSet {
pub positions: Vec<(u32, Vec<(String, Measurement)>)>,
}
impl MeasurementSet {
pub fn get(&self, position: u32, role: &str) -> Option<&Measurement> {
self.positions
.iter()
.find(|(p, _)| *p == position)
.and_then(|(_, roles)| roles.iter().find(|(r, _)| r == role).map(|(_, m)| m))
}
}
pub use secs_types::chain::{Allpass, BandType, Peq};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SubMode {
Auto,
Fixed,
Bundle,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DbaRow {
Front,
Rear,
}
#[derive(Debug, Clone, PartialEq)]
pub struct SubManual {
pub mode: SubMode,
pub bundle: String,
pub gain_db: f64,
pub delay_ms: f64,
pub polarity: i8,
pub allpass: Vec<Allpass>,
pub mimo_support: bool,
pub hp_hz: f64,
pub hp_type: BandType,
pub lp_hz: f64,
pub lp_type: BandType,
pub peq: Vec<Peq>,
pub dba_row: DbaRow,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LayoutKind {
Dba,
Multi,
}
#[derive(Debug, Clone, PartialEq)]
pub struct BundleLayout {
pub kind: LayoutKind,
pub rear_trim_ms: f64,
}
#[derive(Debug, Clone, PartialEq)]
pub struct EngineConfig {
pub mains: Vec<String>,
pub subs: Vec<String>,
pub groups: Vec<(String, Vec<String>)>,
pub target: TargetCurve,
pub xo: Vec<(String, f64)>,
pub main_position: u32,
pub taps: usize,
pub lift_ms: f64,
pub max_boost_db: f64,
pub peq_bands: Option<usize>,
pub max_latency_ms: Option<f64>,
pub rc_range: (f64, Option<f64>),
pub rc_bands: Vec<(f64, f64)>,
pub low_protect: bool,
pub input_hp_hz: Option<f64>,
pub lf_align: bool,
pub mode_decay: bool,
pub hf_phase: bool,
pub room_volume_m3: Option<f64>,
pub rc_hi_basis: secs_types::calibration::RcHiBasis,
pub rc_hi_transition: u8,
pub phase_frac: f64,
pub sub_manual: Vec<(String, SubManual)>,
pub sub_main_delay_ms: f64,
pub bundle_layouts: Vec<(String, BundleLayout)>,
pub infra_boost_max_db: f64,
pub xo_peq_on: bool,
pub xo_peq_lo_hz: f64,
pub xo_peq_hi_hz: f64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PhasePositions {
Common,
Main,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SubAllpass {
None,
Full,
LowQ,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BundleGain {
Auto,
Fixed,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Tuning {
pub boost_ring_ms: Option<f64>,
pub ba_delay_ms: f64,
pub ba_eff_weight: f64,
pub sub_bus_fix: bool,
pub main_weight_lo: f64,
pub phase_positions: PhasePositions,
pub long_boost_db: f64,
pub noboost_ms: f64,
pub xo_stage: bool,
pub sub_allpass: SubAllpass,
pub gd_cuts: bool,
pub bundle_gain: BundleGain,
pub mimo_band_db: f64,
pub mimo_q_max: f64,
pub mimo_in_band: bool,
pub mimo_band_reg: f64,
pub mimo_effort: f64,
pub mimo_worse_db: f64,
pub mimo_gain_max_db: f64,
pub mimo_k_bands: usize,
pub mimo_a_bands: usize,
pub mimo_max_nfev: usize,
}
impl Default for Tuning {
fn default() -> Self {
Self {
boost_ring_ms: Some(30.0),
ba_delay_ms: 12.0,
ba_eff_weight: 1.0,
sub_bus_fix: false,
main_weight_lo: 5.0,
phase_positions: PhasePositions::Common,
long_boost_db: 3.0,
noboost_ms: 1e9,
xo_stage: true,
sub_allpass: SubAllpass::None,
gd_cuts: false,
bundle_gain: BundleGain::Auto,
mimo_band_db: 15.0,
mimo_q_max: 10.0,
mimo_in_band: true,
mimo_band_reg: 0.05,
mimo_effort: 0.05,
mimo_worse_db: 1.0,
mimo_gain_max_db: 20.0,
mimo_k_bands: 9,
mimo_a_bands: 3,
mimo_max_nfev: 150,
}
}
}