mirror of
https://github.com/mii443/maudio-router.git
synced 2025-08-22 16:05:35 +00:00
ASIO test
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
1096
Cargo.lock
generated
Normal file
1096
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "maudio-router"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
cpal = { git = "https://github.com/RustAudio/cpal.git", features = ["asio"] }
|
23
src/main.rs
Normal file
23
src/main.rs
Normal file
@ -0,0 +1,23 @@
|
||||
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||
|
||||
fn main() {
|
||||
let host;
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
host = cpal::host_from_id(cpal::HostId::Asio).expect("failed to initialise ASIO host");
|
||||
}
|
||||
|
||||
let device = host.devices().unwrap().find(|d| d.name().unwrap() == "Voicemeeter Insert Virtual ASIO").unwrap();
|
||||
|
||||
let stream = device.build_input_stream(
|
||||
&device.default_input_config().unwrap().config(),
|
||||
move |data: &[f32], _: &_| {
|
||||
println!("{:?}", data.iter().map(|d| d.clone()).sum::<f32>());
|
||||
},
|
||||
move |err| eprintln!("error: {}", err),
|
||||
None
|
||||
).unwrap();
|
||||
|
||||
stream.play().unwrap();
|
||||
std::thread::sleep(std::time::Duration::from_secs(10));
|
||||
}
|
Reference in New Issue
Block a user