Asio

Struct Asio 

Source
pub struct Asio { /* private fields */ }
Expand description

A handle to the ASIO API.

There should only be one instance of this type at any point in time.

Implementations§

Source§

impl Asio

Source

pub fn new() -> Self

Initialise the ASIO API.

Examples found in repository?
examples/test.rs (line 4)
3fn main() {
4    let asio = sys::Asio::new();
5    for driver in asio.driver_names() {
6        println!("Driver: {}", driver);
7        let driver = asio.load_driver(&driver).expect("failed to load drivers");
8        println!(
9            "  Channels: {:?}",
10            driver.channels().expect("failed to get channels")
11        );
12        println!(
13            "  Sample rate: {:?}",
14            driver.sample_rate().expect("failed to get sample rate")
15        );
16    }
17}
More examples
Hide additional examples
examples/enumerate.rs (line 36)
35fn main() {
36    let asio = sys::Asio::new();
37    for name in asio.driver_names() {
38        println!("Driver: {:?}", name);
39        let driver = asio.load_driver(&name).expect("failed to load driver");
40        let channels = driver
41            .channels()
42            .expect("failed to retrieve channel counts");
43        let sample_rate = driver
44            .sample_rate()
45            .expect("failed to retrieve sample rate");
46        let in_fmt = Format {
47            channels: channels.ins as _,
48            sample_rate: sample_rate as _,
49            data_type: SampleFormat::F32,
50        };
51        let out_fmt = Format {
52            channels: channels.outs as _,
53            sample_rate: sample_rate as _,
54            data_type: SampleFormat::F32,
55        };
56        println!("  Input {:?}", in_fmt);
57        println!("  Output {:?}", out_fmt);
58    }
59}
Source

pub fn driver_names(&self) -> Vec<String>

Returns the name for each available driver.

This is used at the start to allow the user to choose which driver they want.

Examples found in repository?
examples/test.rs (line 5)
3fn main() {
4    let asio = sys::Asio::new();
5    for driver in asio.driver_names() {
6        println!("Driver: {}", driver);
7        let driver = asio.load_driver(&driver).expect("failed to load drivers");
8        println!(
9            "  Channels: {:?}",
10            driver.channels().expect("failed to get channels")
11        );
12        println!(
13            "  Sample rate: {:?}",
14            driver.sample_rate().expect("failed to get sample rate")
15        );
16    }
17}
More examples
Hide additional examples
examples/enumerate.rs (line 37)
35fn main() {
36    let asio = sys::Asio::new();
37    for name in asio.driver_names() {
38        println!("Driver: {:?}", name);
39        let driver = asio.load_driver(&name).expect("failed to load driver");
40        let channels = driver
41            .channels()
42            .expect("failed to retrieve channel counts");
43        let sample_rate = driver
44            .sample_rate()
45            .expect("failed to retrieve sample rate");
46        let in_fmt = Format {
47            channels: channels.ins as _,
48            sample_rate: sample_rate as _,
49            data_type: SampleFormat::F32,
50        };
51        let out_fmt = Format {
52            channels: channels.outs as _,
53            sample_rate: sample_rate as _,
54            data_type: SampleFormat::F32,
55        };
56        println!("  Input {:?}", in_fmt);
57        println!("  Output {:?}", out_fmt);
58    }
59}
Source

pub fn loaded_driver(&self) -> Option<Driver>

If a driver has already been loaded, this will return that driver.

Returns None if no driver is currently loaded.

This can be useful to check before calling load_driver as ASIO only supports loading a single driver at a time.

Source

pub fn load_driver(&self, driver_name: &str) -> Result<Driver, LoadDriverError>

Load a driver from the given name.

Driver names compatible with this method can be produced via the asio.driver_names() method.

NOTE: Despite many requests from users, ASIO only supports loading a single driver at a time. Calling this method while a previously loaded Driver instance exists will result in an error. That said, if this method is called with the name of a driver that has already been loaded, that driver will be returned successfully.

Examples found in repository?
examples/test.rs (line 7)
3fn main() {
4    let asio = sys::Asio::new();
5    for driver in asio.driver_names() {
6        println!("Driver: {}", driver);
7        let driver = asio.load_driver(&driver).expect("failed to load drivers");
8        println!(
9            "  Channels: {:?}",
10            driver.channels().expect("failed to get channels")
11        );
12        println!(
13            "  Sample rate: {:?}",
14            driver.sample_rate().expect("failed to get sample rate")
15        );
16    }
17}
More examples
Hide additional examples
examples/enumerate.rs (line 39)
35fn main() {
36    let asio = sys::Asio::new();
37    for name in asio.driver_names() {
38        println!("Driver: {:?}", name);
39        let driver = asio.load_driver(&name).expect("failed to load driver");
40        let channels = driver
41            .channels()
42            .expect("failed to retrieve channel counts");
43        let sample_rate = driver
44            .sample_rate()
45            .expect("failed to retrieve sample rate");
46        let in_fmt = Format {
47            channels: channels.ins as _,
48            sample_rate: sample_rate as _,
49            data_type: SampleFormat::F32,
50        };
51        let out_fmt = Format {
52            channels: channels.outs as _,
53            sample_rate: sample_rate as _,
54            data_type: SampleFormat::F32,
55        };
56        println!("  Input {:?}", in_fmt);
57        println!("  Output {:?}", out_fmt);
58    }
59}

Trait Implementations§

Source§

impl Debug for Asio

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Asio

Source§

fn default() -> Asio

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

Auto Trait Implementations§

§

impl !Freeze for Asio

§

impl RefUnwindSafe for Asio

§

impl Send for Asio

§

impl Sync for Asio

§

impl Unpin for Asio

§

impl UnwindSafe for Asio

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.