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