State

Struct State 

Source
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: u32

48V phantom power button.

§line: u32

Channel 1-2 line mode button.

§mute: u32

Main mix mute button.

§mono: u32

Main mix mono button.

Implementations§

Source§

impl State

Source

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}
Source

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§

Source§

impl Default for State

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.