mirror of
https://github.com/mii443/maudio-router.git
synced 2025-08-22 16:05:35 +00:00
fix resampling
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
virtual_devices:
|
||||
- name: "mic"
|
||||
channels: 2
|
||||
sample_rate: 192000
|
||||
sample_rate: 96000
|
||||
routes:
|
||||
input:
|
||||
- name: "Mic"
|
||||
@ -15,4 +15,4 @@ routes:
|
||||
virtual_device: "mic"
|
||||
device:
|
||||
local:
|
||||
name: "VoiceMeeter Input (VB-Audio VoiceMeeter VAIO)"
|
||||
name: "CABLE Input (VB-Audio Virtual Cable)"
|
@ -25,20 +25,10 @@ pub fn resampling(
|
||||
if adjustment_factor == 1.0 {
|
||||
adjusted_complex_data = complex_data;
|
||||
} else if adjustment_factor > 1.0 {
|
||||
adjusted_complex_data = vec![Complex::new(0.0, 0.0); new_size];
|
||||
let step = complex_data.len() as f64 / new_size as f64;
|
||||
for (i, sample) in adjusted_complex_data.iter_mut().enumerate() {
|
||||
let idx = (i as f64 * step).floor() as usize;
|
||||
*sample = complex_data
|
||||
.get(idx)
|
||||
.cloned()
|
||||
.unwrap_or(Complex::new(0.0, 0.0));
|
||||
}
|
||||
adjusted_complex_data = complex_data.into_iter().collect();
|
||||
adjusted_complex_data.resize(new_size, Complex::new(0.0, 0.0));
|
||||
} else {
|
||||
adjusted_complex_data = complex_data
|
||||
.into_iter()
|
||||
.step_by(adjustment_factor.recip().round() as usize)
|
||||
.collect();
|
||||
adjusted_complex_data = complex_data.into_iter().collect();
|
||||
adjusted_complex_data.resize(new_size, Complex::new(0.0, 0.0));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user