ASIO test

This commit is contained in:
mii443
2024-02-12 01:39:12 +09:00
commit 747b2b0a04
4 changed files with 1129 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1096
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

9
Cargo.toml Normal file
View 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
View 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));
}