Skip to main content

lib_jsl_dsp/discrete/windows/
flattop.rs

1use super::general_cosine::general_cosine;
2
3/// The Flattop window is defined by a specific set of coefficients that provide a flat top shape to the window, which is useful for certain applications where a flat frequency response is desired. The coefficients are computed using the general cosine function with specific values to achieve the desired shape and spectral properties.
4pub fn flattop(m: usize, sym: bool) -> Vec<f64> {
5    general_cosine(
6        m,
7        &[0.215_578_95, 0.416_631_58, 0.277_263_158, 0.083_578_947, 0.006_947_368],
8        sym,
9    )
10}
11
12#[cfg(test)]
13mod tests {
14    use super::*;
15    use crate::discrete::windows::test_support::assert_window;
16
17    #[test]
18    fn test_flattop() {
19        assert_window(include_str!("../test_data/flattop.csv"), flattop(7, true));
20    }
21}