change of branch
This commit is contained in:
parent
e0a0dc9ec7
commit
49968f4b82
24 changed files with 1371 additions and 0 deletions
BIN
asio-sys/examples/.test.rs.swp
Normal file
BIN
asio-sys/examples/.test.rs.swp
Normal file
Binary file not shown.
72
asio-sys/examples/enumerate.rs
Normal file
72
asio-sys/examples/enumerate.rs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/* This example aims to produce the same behaviour
|
||||
* as the enumerate example in cpal
|
||||
* by Tom Gowan
|
||||
*/
|
||||
|
||||
extern crate asio_sys as sys;
|
||||
|
||||
// This is the same data that enumerate
|
||||
// is trying to find
|
||||
// Basically these are stubbed versions
|
||||
//
|
||||
// Format that each sample has.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum SampleFormat {
|
||||
// The value 0 corresponds to 0.
|
||||
I16,
|
||||
// The value 0 corresponds to 32768.
|
||||
U16,
|
||||
// The boundaries are (-1.0, 1.0).
|
||||
F32,
|
||||
}
|
||||
// Number of channels.
|
||||
pub type ChannelCount = u16;
|
||||
|
||||
// The number of samples processed per second for a single channel of audio.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct SampleRate(pub u32);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Format {
|
||||
pub channels: ChannelCount,
|
||||
pub sample_rate: SampleRate,
|
||||
pub data_type: SampleFormat,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let driver_list = sys::get_driver_list();
|
||||
|
||||
let format = Format {
|
||||
channels: 0,
|
||||
sample_rate: SampleRate(0),
|
||||
// TODO Not sure about how to set the data type
|
||||
data_type: SampleFormat::F32,
|
||||
};
|
||||
if driver_list.len() > 0 {
|
||||
let format = match sys::get_channels(&driver_list[0]) {
|
||||
Ok(channels) => Format {
|
||||
channels: channels.ins as u16,
|
||||
sample_rate: format.sample_rate,
|
||||
data_type: format.data_type,
|
||||
},
|
||||
Err(e) => {
|
||||
println!("Error retrieving channels: {}", e);
|
||||
format
|
||||
}
|
||||
};
|
||||
|
||||
let format = match sys::get_sample_rate(&driver_list[0]) {
|
||||
Ok(sample_rate) => Format {
|
||||
channels: format.channels,
|
||||
sample_rate: SampleRate(sample_rate.rate),
|
||||
data_type: format.data_type,
|
||||
},
|
||||
Err(e) => {
|
||||
println!("Error retrieving sample rate: {}", e);
|
||||
format
|
||||
}
|
||||
};
|
||||
|
||||
println!("Format {:?}", format);
|
||||
}
|
||||
}
|
||||
16
asio-sys/examples/test.rs
Normal file
16
asio-sys/examples/test.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
extern crate asio_sys as sys;
|
||||
|
||||
fn main() {
|
||||
let driver_list = sys::get_driver_list();
|
||||
|
||||
for driver in &driver_list {
|
||||
println!("Driver: {}", driver);
|
||||
}
|
||||
|
||||
if driver_list.len() > 0 {
|
||||
match sys::get_channels(&driver_list[0]) {
|
||||
Ok(channels) => println!("Channels: {:?}", channels),
|
||||
Err(e) => println!("Error retrieving channels: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue