cannot read mic input

This commit is contained in:
mii443
2024-02-14 19:36:39 +09:00
parent 11cce7ee17
commit d25b8c515b
3 changed files with 8 additions and 2 deletions

View File

@ -8,7 +8,7 @@ routes:
virtual_device: "mic"
device:
local:
name: "VoiceMeeter Output (VB-Audio VoiceMeeter VAIO)"
name: "VoiceMeeter Aux Output (VB-Audio VoiceMeeter AUX VAIO)"
output:
- name: "Speaker"
input:

View File

@ -108,10 +108,11 @@ pub fn run(run: Run) {
let config = device.default_input_config().unwrap();
let channels = config.channels();
let virtual_devices = virtual_devices.iter().filter(|device| device.lock().unwrap().name == input_route.virtual_device).map(|d| d.clone()).collect::<Vec<_>>();
let mut stream = device.build_input_stream(
let stream = device.build_input_stream(
&config.into(),
{
move |data, _| {
println!("Reading input stream");
for (i, buffer) in data.chunks(channels as usize).enumerate() {
let buffer = buffer.to_vec();
for virtual_device in &virtual_devices {
@ -123,6 +124,7 @@ pub fn run(run: Run) {
move |err| eprintln!("An error occurred on the input stream: {}", err),
None
).unwrap();
println!("Playing input stream");
stream.play().unwrap();
}
crate::config::Device::Remote { remote } => {
@ -130,4 +132,6 @@ pub fn run(run: Run) {
}
}
}
std::thread::sleep(std::time::Duration::from_secs(10));
}

View File

@ -28,6 +28,7 @@ impl VirtualDevice {
}
pub fn take_output(&mut self, index: usize, channel: u8, take_size: usize) -> Option<Vec<f32>> {
println!("Min index: {}", self.get_min_index());
let mut buffer = Vec::with_capacity(take_size);
let start = self.output_index[index];
let end = start + take_size;
@ -55,6 +56,7 @@ impl VirtualDevice {
}
pub fn write_input(&mut self, channel: u8, buffer: Vec<f32>) {
println!("Writing input to virtual device: {} {:?}", self.name, buffer);
self.output_buffer[channel as usize].extend(buffer);
}
}