Skip to main content

secs_types/
settings_edit.rs

1//! Wire-compatible edits from the calibration screen. Rules live in secs-service.
2use serde::{Deserialize, Serialize};
3use ts_rs::TS;
4
5use crate::{
6    calibration::{Mode, RcBand, RcHiBasis, SampleRatePolicy},
7    chain::BandType,
8};
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
11#[ts(export)]
12pub enum SubModeChoice {
13    #[serde(rename = "auto")]
14    Auto,
15    #[serde(rename = "fixed")]
16    Fixed,
17    #[serde(rename = "bundle:A")]
18    BundleA,
19    #[serde(rename = "bundle:B")]
20    BundleB,
21}
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
24#[serde(rename_all = "lowercase")]
25#[ts(export)]
26pub enum SubLayout {
27    Values,
28    Dba,
29    Multi,
30}
31
32#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
33#[serde(rename_all = "lowercase")]
34#[ts(export)]
35pub enum SubBand {
36    Hp,
37    Lp,
38}
39
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
41#[serde(untagged)]
42#[ts(export)]
43pub enum BandTypeChoice {
44    Band(BandType),
45    Off(BandOff),
46}
47
48/// The "off" choice of a sub's HP or LP filter type.
49#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
50#[serde(rename_all = "lowercase")]
51#[ts(export)]
52pub enum BandOff {
53    Off,
54}
55
56/// Partial<Omit<SubEntry, "mode" | "bundle">>; absent fields are unchanged.
57#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS, Default)]
58#[ts(export)]
59pub struct SubPatch {
60    #[serde(default, skip_serializing_if = "Option::is_none")]
61    #[ts(optional)]
62    pub gain_db: Option<f64>,
63    #[serde(default, skip_serializing_if = "Option::is_none")]
64    #[ts(optional)]
65    pub delay_ms: Option<f64>,
66    #[serde(default, skip_serializing_if = "Option::is_none")]
67    #[ts(optional)]
68    pub polarity: Option<f64>,
69    #[serde(default, skip_serializing_if = "Option::is_none")]
70    #[ts(optional)]
71    pub allpass: Option<Vec<(f64, f64)>>,
72    #[serde(default, skip_serializing_if = "Option::is_none")]
73    #[ts(optional)]
74    pub mimo_support: Option<bool>,
75    #[serde(default, skip_serializing_if = "Option::is_none")]
76    #[ts(optional)]
77    pub hp_hz: Option<f64>,
78    #[serde(default, skip_serializing_if = "Option::is_none")]
79    #[ts(optional)]
80    pub lp_hz: Option<f64>,
81    #[serde(default, skip_serializing_if = "Option::is_none")]
82    #[ts(optional)]
83    pub peq: Option<Vec<(f64, f64, f64)>>,
84    #[serde(default, skip_serializing_if = "Option::is_none")]
85    #[ts(optional)]
86    pub hp_type: Option<String>,
87    #[serde(default, skip_serializing_if = "Option::is_none")]
88    #[ts(optional)]
89    pub lp_type: Option<String>,
90    #[serde(default, skip_serializing_if = "Option::is_none")]
91    #[ts(optional)]
92    pub dba_row: Option<String>,
93}
94
95#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
96#[serde(tag = "kind", rename_all = "snake_case")]
97#[ts(export)]
98pub enum SettingEdit {
99    Mode {
100        mode: Mode,
101    },
102    SampleRatePolicy {
103        policy: SampleRatePolicy,
104    },
105    UltraMs {
106        ms: f64,
107    },
108    LowProtect {
109        on: bool,
110    },
111    LfAlign {
112        on: bool,
113    },
114    ModeDecay {
115        on: bool,
116    },
117    HfPhase {
118        on: bool,
119    },
120    /// The common input high-pass in Hz, `None` to turn it off (ADR 0031).
121    InputHp {
122        hz: Option<f64>,
123    },
124    RcLo {
125        hz: f64,
126    },
127    RcHi {
128        hz: Option<f64>,
129    },
130    RcHiBasis {
131        basis: RcHiBasis,
132    },
133    RcHiTransition {
134        factor: u8,
135    },
136    /// Replaces the whole list of extra correction bands (ADR 0024); an
137    /// empty list removes them. Rejected, not clamped, when a band breaks
138    /// `CALIBRATION_LIMITS.rc_band` or the list is longer than `rc_bands_max`.
139    RcBands {
140        bands: Vec<RcBand>,
141    },
142    RoomVolume {
143        m3: f64,
144    },
145    RoomDims {
146        dims: [f64; 3],
147    },
148    BoostMax {
149        db: f64,
150    },
151    Xo {
152        group: String,
153        hz: f64,
154    },
155    XoRecInclude {
156        on: bool,
157    },
158    XoPeq {
159        #[serde(default, skip_serializing_if = "Option::is_none")]
160        #[ts(optional)]
161        on: Option<bool>,
162        #[serde(default, skip_serializing_if = "Option::is_none")]
163        #[ts(optional)]
164        lo: Option<f64>,
165        #[serde(default, skip_serializing_if = "Option::is_none")]
166        #[ts(optional)]
167        hi: Option<f64>,
168    },
169    Infra {
170        role: Option<String>,
171        hz: f64,
172        #[serde(rename = "type")]
173        typ: BandType,
174        subs: Vec<String>,
175    },
176    InfraBoost {
177        db: f64,
178    },
179    SubMode {
180        role: String,
181        mode: SubModeChoice,
182    },
183    SubLayout {
184        bundle: String,
185        layout: SubLayout,
186    },
187    RearTrim {
188        bundle: String,
189        ms: f64,
190    },
191    Sub {
192        role: String,
193        patch: SubPatch,
194    },
195    SubBandType {
196        role: String,
197        band: SubBand,
198        #[serde(rename = "type")]
199        typ: BandTypeChoice,
200    },
201    MainDelay {
202        ms: f64,
203    },
204    MimoOn {
205        on: bool,
206    },
207    Fsiso {
208        hz: f64,
209    },
210    MimoLow {
211        hz: Option<f64>,
212    },
213    MimoMax {
214        count: f64,
215    },
216    MimoFir {
217        on: bool,
218    },
219    /// Experimental closed-form derivatives (D43, D44); an absent part keeps its value.
220    AnalyticDerivatives {
221        #[serde(default, skip_serializing_if = "Option::is_none")]
222        #[ts(optional)]
223        peq: Option<bool>,
224        #[serde(default, skip_serializing_if = "Option::is_none")]
225        #[ts(optional)]
226        mimo_iir: Option<bool>,
227    },
228}
229
230#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
231#[ts(export)]
232pub struct CalibrationSettingsEditParams {
233    pub edit: SettingEdit,
234}