ot_tools_io/projects/settings/
mixer.rs

1/*
2SPDX-License-Identifier: GPL-3.0-or-later
3Copyright © 2024 Mike Robeson [dijksterhuis]
4*/
5
6//! Current settings for the Project Mixer
7
8use crate::projects::parse_hashmap_string_value;
9use crate::projects::ProjectParseError;
10use serde::{Deserialize, Serialize};
11use std::collections::HashMap;
12
13/// Global `MIXER` UI menu.
14
15#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
16pub struct MixerMenu {
17    /// Controls the incoming gain of external audio signal through AB inputs. -64 to +63 range.
18    /// See Manual section 8.8 MIXER MENU
19    pub gain_ab: u8,
20
21    /// Controls the incoming gain of external audio signal through CD inputs. -64 to +63 range.
22    /// See Manual section 8.8 MIXER MENU
23    pub gain_cd: u8,
24
25    /// Routes audio from AB inputs directly to mixer outputs. 0 to 127 range.
26    /// See Manual section 8.8 MIXER MENU
27    pub dir_ab: u8,
28
29    /// Routes audio from CD inputs directly to mixer outputs. 0 to 127 range.
30    /// See Manual section 8.8 MIXER MENU
31    pub dir_cd: u8,
32
33    /// How much to mix the master / cue outputs on the headphones output. 0 to 127 range with 64 the default (equal mix)
34    /// See Manual section 8.8 MIXER MENU
35    pub phones_mix: u8,
36
37    /// Mix between Main and Cue for headphones out.
38    /// See Manual section 8.8 MIXER MENU
39    pub main_to_cue: u8,
40
41    /// Final gain / output level of the main outputs. -64 to 63 range. 0 is default.
42    /// See Manual section 8.8 MIXER MENU
43    pub main_level: u8,
44
45    /// Final gain / output level of the cue outputs. -64 to 63 range. 0 is default.
46    /// See Manual section 8.8 MIXER MENU
47    pub cue_level: u8,
48}
49
50impl TryFrom<&HashMap<String, String>> for MixerMenu {
51    type Error = ProjectParseError;
52    fn try_from(value: &HashMap<String, String>) -> Result<Self, Self::Error> {
53        let gain_ab = parse_hashmap_string_value::<u8>(value, "gain_ab", None)?;
54        let gain_cd = parse_hashmap_string_value::<u8>(value, "gain_cd", None)?;
55        let dir_ab = parse_hashmap_string_value::<u8>(value, "dir_ab", None)?;
56        let dir_cd = parse_hashmap_string_value::<u8>(value, "dir_cd", None)?;
57        let phones_mix = parse_hashmap_string_value::<u8>(value, "phones_mix", None)?;
58        let main_to_cue = parse_hashmap_string_value::<u8>(value, "main_to_cue", None)?;
59        let main_level = parse_hashmap_string_value::<u8>(value, "main_level", None)?;
60        let cue_level = parse_hashmap_string_value::<u8>(value, "cue_level", None)?;
61        Ok(Self {
62            gain_ab,
63            gain_cd,
64            dir_ab,
65            dir_cd,
66            phones_mix,
67            main_to_cue,
68            main_level,
69            cue_level,
70        })
71    }
72}
73
74impl Default for MixerMenu {
75    // TODO: Check values
76    fn default() -> Self {
77        Self {
78            gain_ab: 64,
79            gain_cd: 64,
80            dir_ab: 0,
81            dir_cd: 0,
82            phones_mix: 64,
83            main_to_cue: 64,
84            main_level: 64,
85            cue_level: 64,
86        }
87    }
88}