fn blackman_harris_window(samples: &[f32]) -> Vec<f32> {
    const A0: f32 = 0.35875;
    const A1: f32 = 0.48829;
    const A2: f32 = 0.14128;
    const A3: f32 = 0.01168;
    const TWO_PI: f32 = PI * 2f32;
    const FOUR_PI: f32 = PI * 4f32;
    const SIX_PI: f32 = PI * 6f32;

    let mut windowed = Vec::with_capacity(samples.len());
    let denom = 1f32 / (samples.len() - 1) as f32;
    for n in 0..samples.len() {
        let one_term = A1 * (TWO_PI * (n as f32) * denom).cos();
        let two_term = A2 * (FOUR_PI * (n as f32) * denom).cos();
        let three_term = A3 * (SIX_PI * (n as f32) * denom).cos();
        let weight = A0 - one_term + two_term - three_term;
        windowed.push(weight * samples[n]);
    }
    windowed
}
/// Apply a Blackman-Harris window to a discrete-time signal
Apply a Blackman-Harris window to a discrete-time signal
Apply a Blackman - Harris window to a discrete - time signal
fn blackman_harris_window(samples: &[f32]) -> Vec<f32> {
    const A0: f32 = 0.35875;
    const A1: f32 = 0.48829;
    const A2: f32 = 0.14128;
    const A3: f32 = 0.01168;
    const TWO_PI: f32 = PI * 2f32;
    const FOUR_PI: f32 = PI * 4f32;
    const SIX_PI: f32 = PI * 6f32;
    let mut windowed = Vec::with_capacity(samples.len());
    let denom = 1f32 / (samples.len() - 1) as f32;
    for n in 0..samples.len() {
        let one_term = A1 * (TWO_PI * (n as f32) * denom).cos();
        let two_term = A2 * (FOUR_PI * (n as f32) * denom).cos();
        let three_term = A3 * (SIX_PI * (n as f32) * denom).cos();
        let weight = A0 - one_term + two_term - three_term;
        windowed.push(weight * samples[n]);
    }
    windowed
}
fn blackman_harris_window ( samples : & [ f32 ] ) -> Vec < f32 > { const A0 : f32 = 0.35875 ; const A1 : f32 = 0.48829 ; const A2 : f32 = 0.14128 ; const A3 : f32 = 0.01168 ; const TWO_PI : f32 = PI * 2f32 ; const FOUR_PI : f32 = PI * 4f32 ; const SIX_PI : f32 = PI * 6f32 ; let mut windowed = Vec :: with_capacity ( samples . len ( ) ) ; let denom = 1f32 / ( samples . len ( ) - 1 ) as f32 ; for n in 0 .. samples . len ( ) { let one_term = A1 * ( TWO_PI * ( n as f32 ) * denom ) . cos ( ) ; let two_term = A2 * ( FOUR_PI * ( n as f32 ) * denom ) . cos ( ) ; let three_term = A3 * ( SIX_PI * ( n as f32 ) * denom ) . cos ( ) ; let weight = A0 - one_term + two_term - three_term ; windowed . push ( weight * samples [ n ] ) ; } windowed }
Apply a Blackman-Harris window to a discrete-time signal
Apply a Blackman - Harris window to a discrete - time signal
samples
&[f32]