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