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    DipLimit {
121        on: bool,
122    },
123    /// The common input high-pass in Hz, `None` to turn it off (ADR 0031).
124    InputHp {
125        hz: Option<f64>,
126    },
127    RcLo {
128        hz: f64,
129    },
130    RcHi {
131        hz: Option<f64>,
132    },
133    RcHiBasis {
134        basis: RcHiBasis,
135    },
136    RcHiTransition {
137        factor: u8,
138    },
139    /// Replaces the whole list of extra correction bands (ADR 0024); an
140    /// empty list removes them. Rejected, not clamped, when a band breaks
141    /// `CALIBRATION_LIMITS.rc_band` or the list is longer than `rc_bands_max`.
142    RcBands {
143        bands: Vec<RcBand>,
144    },
145    RoomVolume {
146        m3: f64,
147    },
148    RoomDims {
149        dims: [f64; 3],
150    },
151    BoostMax {
152        db: f64,
153    },
154    Xo {
155        group: String,
156        hz: f64,
157    },
158    XoRecInclude {
159        on: bool,
160    },
161    XoPeq {
162        #[serde(default, skip_serializing_if = "Option::is_none")]
163        #[ts(optional)]
164        on: Option<bool>,
165        #[serde(default, skip_serializing_if = "Option::is_none")]
166        #[ts(optional)]
167        lo: Option<f64>,
168        #[serde(default, skip_serializing_if = "Option::is_none")]
169        #[ts(optional)]
170        hi: Option<f64>,
171    },
172    Infra {
173        role: Option<String>,
174        hz: f64,
175        #[serde(rename = "type")]
176        typ: BandType,
177        subs: Vec<String>,
178    },
179    InfraBoost {
180        db: f64,
181    },
182    SubMode {
183        role: String,
184        mode: SubModeChoice,
185    },
186    SubLayout {
187        bundle: String,
188        layout: SubLayout,
189    },
190    RearTrim {
191        bundle: String,
192        ms: f64,
193    },
194    Sub {
195        role: String,
196        patch: SubPatch,
197    },
198    SubBandType {
199        role: String,
200        band: SubBand,
201        #[serde(rename = "type")]
202        typ: BandTypeChoice,
203    },
204    MainDelay {
205        ms: f64,
206    },
207    MimoOn {
208        on: bool,
209    },
210    Fsiso {
211        hz: f64,
212    },
213    MimoLow {
214        hz: Option<f64>,
215    },
216    MimoMax {
217        count: f64,
218    },
219    MimoFir {
220        on: bool,
221    },
222    /// Experimental closed-form derivatives (D43, D44); an absent part keeps its value.
223    AnalyticDerivatives {
224        #[serde(default, skip_serializing_if = "Option::is_none")]
225        #[ts(optional)]
226        peq: Option<bool>,
227        #[serde(default, skip_serializing_if = "Option::is_none")]
228        #[ts(optional)]
229        mimo_iir: Option<bool>,
230    },
231}
232
233#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
234#[ts(export)]
235pub struct CalibrationSettingsEditParams {
236    pub edit: SettingEdit,
237}