Skip to content

Window functions code & examples

Table of Contents

Hann window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_hann(output.size());
plot_save("window_hann", output, options + ", title='Hann window'");
Result window_hann

Hamming window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_hamming(output.size());
plot_save("window_hamming", output, options + ", title='Hamming window'");
Result window_hamming

Blackman window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_blackman(output.size());
plot_save("window_blackman", output, options + ", title='Blackman window'");
Result window_blackman

Blackman-Harris window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_blackman_harris(output.size());
plot_save("window_blackman_harris", output, options + ", title='Blackman-Harris window'");
Result window_blackman_harris

Gaussian window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_gaussian(output.size());
plot_save("window_gaussian", output, options + ", title='Gaussian window'");
Result window_gaussian

Triangular window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_triangular(output.size());
plot_save("window_triangular", output, options + ", title='Triangular window'");
Result window_triangular

Bartlett window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_bartlett(output.size());
plot_save("window_bartlett", output, options + ", title='Bartlett window'");
Result window_bartlett

Cosine window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_cosine(output.size());
plot_save("window_cosine", output, options + ", title='Cosine window'");
Result window_cosine

Cosine window (numpy compatible)

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_cosine_np(output.size());
plot_save("window_cosine_np", output, options + ", title='Cosine window (numpy compatible)'");
Result window_cosine_np

Bartlett-Hann window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_bartlett_hann(output.size());
plot_save("window_bartlett_hann", output, options + ", title='Bartlett-Hann window'");
Result window_bartlett_hann

Bohman window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_bohman(output.size());
plot_save("window_bohman", output, options + ", title='Bohman window'");
Result window_bohman

Lanczos window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_lanczos(output.size());
plot_save("window_lanczos", output, options + ", title='Lanczos window'");
Result window_lanczos

Flat top window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_flattop(output.size());
plot_save("window_flattop", output, options + ", title='Flat top window'");
Result window_flattop

Kaiser window

Code

1
2
3
4
5
6
const std::string options = "freqresp=True, dots=True, padwidth=1024, "
                            "log_freq=False, horizontal=False, normalized_freq=True";
univector<fbase, 64> output;

output = window_kaiser(output.size(), 2.5);
plot_save("window_kaiser", output, options + ", title='Kaiser window'");
Result window_kaiser