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