pub struct State {
pub mic: [u32; 8],
pub spdif: [u32; 2],
pub adat: [u32; 8],
pub daw: [u32; 18],
pub bus: [u32; 18],
pub phantom: u32,
pub line: u32,
pub mute: u32,
pub mono: u32,
/* private fields */
}Expand description
State of the Presonus STUDIO1824c audio interface.
Fields§
§mic: [u32; 8]Microphone input meters.
spdif: [u32; 2]S/PDIF input meters.
adat: [u32; 8]ADAT input meters.
daw: [u32; 18]DAW input meters.
bus: [u32; 18]Stereo busses meters.
phantom: u3248V phantom power button.
line: u32Channel 1-2 line mode button.
mute: u32Main mix mute button.
mono: u32Main mix mono button.
Implementations§
Source§impl State
impl State
Sourcepub fn new() -> Self
pub fn new() -> Self
Initialize the State struct.
Examples found in repository?
examples/examples.rs (line 17)
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}Sourcepub fn poll(&mut self, device: &Device) -> Result<(), TransferError>
pub fn poll(&mut self, device: &Device) -> Result<(), TransferError>
Read state from device
§Examples
use baton_studio::{gain_to_db, State};
use nusb::MaybeFuture;
// Open the 1824c usb device.
let my_1824c = nusb::list_devices()
.wait()?
.find(|dev| dev.vendor_id() == 0x194f && dev.product_id() == 0x010d)
.ok_or(std::io::Error::new(std::io::ErrorKind::NotFound, "device not found"))?
.open()
.wait()?;
let mut state = State::new();
state.poll(&my_1824c)?;
let fader_value = gain_to_db(state.mic[0]);
Examples found in repository?
examples/examples.rs (line 39)
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}Trait Implementations§
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more