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; }
18 param = consts::PI / ((2 * size) as f32);
20 param = consts::PI / (size as f32);
23 dst[n] = (((n as f32) + 0.5) * param).sin() * scale;
26 WindowType::KaiserBessel(alpha) => {
27 let dlen = if half { size as f32 } else { (size as f32) * 0.5 };
28 let alpha2 = ((alpha * consts::PI / dlen) * (alpha * consts::PI / dlen)) as f64;
30 let mut kb: Vec<f64> = Vec::with_capacity(size);
33 let b = bessel_i0(((n * (size - n)) as f64) * alpha2);
39 dst[n] = (kb[n] / sum).sqrt() as f32;
45 fn bessel_i0(inval: f64) -> f64 {
46 let mut val: f64 = 1.0;
47 for n in (1..64).rev() {
48 val *= inval / ((n * n) as f64);