I was trying to run a modified version of the feedback example specifically for ASIO, the regularl feedback example works with no issues, but when adding ASIO to the equation it is ran to completion but there's no audio playing, either the mic or the headphones, but based on another project I have tried that uses cpal I think the issue stems from the mic.
OS: Windows 11
Audio Interface: UMC22
Branch: master
ASIO SDK version: ASIO-SDK_2.3.4
ASIO Driver (whatever u call this): ASIO4ALL
Script
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use ringbuf::{
traits::{Consumer, Producer, Split},
HeapRb,
};
fn main() {
let host = cpal::host_from_id(cpal::HostId::Asio).unwrap();
let input_device = host
.default_input_device()
.expect("failed to find input device");
let output_device = host
.default_output_device()
.expect("failed to find output device");
let config = input_device.default_input_config().unwrap().config();
let latency_frames = 0.1 * config.sample_rate as f32;
let latency_samples = latency_frames as usize * config.channels as usize;
let ring = HeapRb::<i32>::new(latency_samples * 2);
let (mut producer, mut consumer) = ring.split();
for _ in 0..latency_samples {
producer.try_push(0).unwrap();
}
let input_data_fn = move |data: &[i32], _: &_| {
if producer.push_slice(data) < data.len() {
eprintln!("output stream fell behind");
}
};
let output_data_fn = move |data: &mut [i32], _: &_| {
let read = consumer.pop_slice(data);
if read < data.len() {
data[read..].fill(0);
eprintln!("input stream fell behind");
}
};
let input_stream = input_device
.build_input_stream(config, input_data_fn, |err| eprintln!("{err}"), None)
.unwrap();
let output_stream = output_device
.build_output_stream(config, output_data_fn, |err| eprintln!("{err}"), None)
.unwrap();
input_stream.play().unwrap();
output_stream.play().unwrap();
std::thread::sleep(std::time::Duration::from_secs(10));
drop(input_stream);
drop(output_stream);
}
I was trying to run a modified version of the feedback example specifically for ASIO, the regularl feedback example works with no issues, but when adding ASIO to the equation it is ran to completion but there's no audio playing, either the mic or the headphones, but based on another project I have tried that uses cpal I think the issue stems from the mic.
OS: Windows 11
Audio Interface: UMC22
Branch: master
ASIO SDK version: ASIO-SDK_2.3.4
ASIO Driver (whatever u call this): ASIO4ALL
Script