examples/
examples.rs

1use baton_studio::*;
2use nusb::MaybeFuture;
3use std::error::Error;
4
5fn main() -> Result<(), Box<dyn Error>> {
6    let device = nusb::list_devices()
7        .wait()?
8        .find(|dev| dev.vendor_id() == 0x194f && dev.product_id() == 0x010d)
9        .ok_or(std::io::Error::new(
10            std::io::ErrorKind::NotFound,
11            "device not found",
12        ))?
13        .open()
14        .wait()?;
15
16    let mut command = Command::new();
17    let mut state = State::new();
18
19    command.set_button(Button::Mute, true);
20    command.send(&device).unwrap();
21
22    command.set_button(Button::Phantom, true).send(&device)?;
23
24    command
25        .set_input_fader(0, 0, Channel::Left, Value::DB(-3.0))
26        .send(&device)?;
27
28    command
29        .set_input_fader(0, 0, Channel::Left, Value::Unity)
30        .send(&device)?;
31
32    command.set_output_fader(0, Value::DB(-2.4)).send(&device)?;
33
34    command
35        .set_output_fader(1, Value::Muted)
36        .send(&device)
37        .unwrap();
38
39    state.poll(&device)?;
40
41    let mic = gain_to_db(state.mic[7]);
42    println!("mic: {} dBFS", mic);
43
44    Ok(())
45}