1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::cli::MicrophoneControls;
use anyhow::Result;
use goxlr_ipc::client::Client;
use goxlr_ipc::GoXLRCommand;
use goxlr_types::MicrophoneType;

pub async fn apply_microphone_controls(
    microphone_controls: &MicrophoneControls,
    client: &mut Client,
    serial: &str,
) -> Result<()> {
    if let Some(gain) = microphone_controls.condenser_gain {
        client
            .command(
                serial,
                GoXLRCommand::SetMicrophoneGain(MicrophoneType::Condenser, gain),
            )
            .await?;
    }
    if let Some(gain) = microphone_controls.dynamic_gain {
        client
            .command(
                serial,
                GoXLRCommand::SetMicrophoneGain(MicrophoneType::Dynamic, gain),
            )
            .await?;
    }
    if let Some(gain) = microphone_controls.jack_gain {
        client
            .command(
                serial,
                GoXLRCommand::SetMicrophoneGain(MicrophoneType::Jack, gain),
            )
            .await?;
    }
    Ok(())
}