bypass/
bypass.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
18    // Set all stereo bus faders to unity gain
19    for m in 0..9 {
20        command.set_output_fader(m, Value::Unity).send(&device)?;
21    }
22
23    // Set:
24    // Daw 1 -> Line out 1, Daw 2 -> Line out 2
25    // Daw 3 -> Line out 3, Daw 4 -> Line out 4
26    // Daw 5 -> Line out 5, Daw 6 -> Line out 6
27    // Daw 7 -> Line out 7, Daw 8 -> Line out 8
28    // Daw 9 -> SPDIF out 1, Daw 10 -> SPDIF out 2
29    // Daw 11 -> ADAT out 1, Daw 12 -> ADAT out 2
30    // Daw 13 -> ADAT out 3, Daw 14 -> ADAT out 4
31    // Daw 15 -> ADAT out 5, Daw 16 -> ADAT out 6
32    // Daw 17 -> ADAT out 7, Daw 18 -> ADAT out 8
33    // Everything else muted
34
35    let mut daw_channel_left = 16;
36    let mut daw_channel_right;
37
38    for m in 0..9 {
39        daw_channel_left += 2;
40        daw_channel_right = daw_channel_left + 1;
41        for c in 0..35 {
42            if c == daw_channel_left {
43                command
44                    .set_input_fader(c, m, Channel::Left, Value::Unity)
45                    .send(&device)?;
46                command
47                    .set_input_fader(c, m, Channel::Right, Value::Muted)
48                    .send(&device)?;
49            } else if c == daw_channel_right {
50                command
51                    .set_input_fader(c, m, Channel::Left, Value::Muted)
52                    .send(&device)?;
53                command
54                    .set_input_fader(c, m, Channel::Right, Value::Unity)
55                    .send(&device)?;
56            } else {
57                command
58                    .set_input_fader(c, m, Channel::Left, Value::Muted)
59                    .send(&device)?;
60                command
61                    .set_input_fader(c, m, Channel::Right, Value::Muted)
62                    .send(&device)?;
63            }
64        }
65    }
66
67    Ok(())
68}