3 #[derive(Debug,Clone,Copy,PartialEq)]
10 pub fn generate_window(mode: WindowType, scale: f32, size: usize, half: bool, dst: &mut [f32]) {
12 WindowType::Square => {
13 for n in 0..size { dst[n] = scale; }
17 consts::PI / ((2 * size) as f32)
19 consts::PI / (size as f32)
22 dst[n] = (((n as f32) + 0.5) * param).sin() * scale;
25 WindowType::KaiserBessel(alpha) => {
26 let dlen = if half { size as f32 } else { (size as f32) * 0.5 };
27 let alpha2 = f64::from((alpha * consts::PI / dlen) * (alpha * consts::PI / dlen));
29 let mut kb: Vec<f64> = Vec::with_capacity(size);
32 let b = bessel_i0(((n * (size - n)) as f64) * alpha2);
38 dst[n] = (kb[n] / sum).sqrt() as f32;
44 fn bessel_i0(inval: f64) -> f64 {
45 let mut val: f64 = 1.0;
46 for n in (1..64).rev() {
47 val *= inval / f64::from(n * n);