X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-core%2Fsrc%2Fdsp%2Fwindow.rs;h=92a26556587dff8528570bd580f795f413f64457;hb=fdb4b2fbe87ca6e15f6d5e8ad040b7c9ee883053;hp=42b6b6d1d556f4918006b15ac51428fd26c2a102;hpb=e07387c7f125550a41faf36a509b252cf71d7f9a;p=nihav.git diff --git a/nihav-core/src/dsp/window.rs b/nihav-core/src/dsp/window.rs index 42b6b6d..92a2655 100644 --- a/nihav-core/src/dsp/window.rs +++ b/nihav-core/src/dsp/window.rs @@ -13,19 +13,18 @@ pub fn generate_window(mode: WindowType, scale: f32, size: usize, half: bool, ds for n in 0..size { dst[n] = scale; } }, WindowType::Sine => { - let param; - if half { - param = consts::PI / ((2 * size) as f32); - } else { - param = consts::PI / (size as f32); - } + let param = if half { + consts::PI / ((2 * size) as f32) + } else { + consts::PI / (size as f32) + }; for n in 0..size { dst[n] = (((n as f32) + 0.5) * param).sin() * scale; } }, WindowType::KaiserBessel(alpha) => { let dlen = if half { size as f32 } else { (size as f32) * 0.5 }; - let alpha2 = ((alpha * consts::PI / dlen) * (alpha * consts::PI / dlen)) as f64; + let alpha2 = f64::from((alpha * consts::PI / dlen) * (alpha * consts::PI / dlen)); let mut kb: Vec = Vec::with_capacity(size); let mut sum = 0.0; @@ -45,7 +44,7 @@ pub fn generate_window(mode: WindowType, scale: f32, size: usize, half: bool, ds fn bessel_i0(inval: f64) -> f64 { let mut val: f64 = 1.0; for n in (1..64).rev() { - val *= inval / ((n * n) as f64); + val *= inval / f64::from(n * n); val += 1.0; } val