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
impl Asio
Sourcepub fn new() -> Self
pub fn new() -> Self
Initialise the ASIO API.
Examples found in repository?
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
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}Sourcepub fn driver_names(&self) -> Vec<String>
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?
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
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}Sourcepub fn loaded_driver(&self) -> Option<Driver>
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.
Sourcepub fn load_driver(&self, driver_name: &str) -> Result<Driver, LoadDriverError>
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?
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
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}