我是靠谱客的博主 传统硬币,这篇文章主要介绍常见窗函数C 实现窗函数的作用1.blackman 窗函数实现2.Blackman-Harris window3.Blackman-Nuttall window4.Flat-Top window5.Hann window6. Nuttall window,现在分享给大家,希望可以做个参考。
窗函数的作用
在信号处理中,我们通常对信号进行截断分析,如果信号截断为非周期截断,那么频谱将发生泄露。通过加窗,可以减少频谱的泄露。我们可以这么想象,窗函数可以将一个非周期的信号,强行变成一个周期的信号。
1.blackman 窗函数实现
复制代码
1
2
3
4
5
6
7
8
9
10
11void dsps_wind_blackman_f32(float *window, int len) { const float a0 = 0.42; const float a1 = 0.5; const float a2 = 0.08; float len_mult = 1/(float)(len-1); for (int i = 0; i < len; i++) { window[i] = a0 - a1 * cosf(i * 2 * M_PI * len_mult) + a2 * cosf(i * 4 * M_PI * len_mult); } }
2.Blackman-Harris window
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16void dsps_wind_blackman_harris_f32(float *window, int len) { const float a0=0.35875; const float a1=0.48829; const float a2=0.14128; const float a3=0.01168; float len_mult = 1/(float)(len-1); for (int i = 0; i < len; i++) { window[i] = a0 - a1 * cosf(i * 2 * M_PI * len_mult) + a2 * cosf(i * 4 * M_PI * len_mult) - a3 * cosf(i * 6 * M_PI * len_mult); } }
3.Blackman-Nuttall window
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15void dsps_wind_blackman_nuttall_f32(float *window, int len) { const float a0=0.3635819; const float a1=0.4891775; const float a2=0.1365995; const float a3=0.0106411; float len_mult = 1/(float)(len-1); for (int i = 0; i < len; i++) { window[i] = a0 - a1 * cosf(i * 2 * M_PI * len_mult) + a2 * cosf(i * 4 * M_PI * len_mult) - a3 * cosf(i * 6 * M_PI * len_mult); } }
4.Flat-Top window
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17void dsps_wind_flat_top_f32(float *window, int len) { const float a0=0.21557895; const float a1=0.41663158; const float a2=0.277263158; const float a3=0.083578947; const float a4=0.006947368; float len_mult = 1/(float)(len-1); for (int i = 0; i < len; i++) { window[i] = a0 - a1 * cosf(i * 2 * M_PI * len_mult) + a2 * cosf(i * 4 * M_PI * len_mult) - a3 * cosf(i * 6 * M_PI * len_mult) + a4 * cosf(i * 8 * M_PI * len_mult); } }
5.Hann window
复制代码
1
2
3
4
5
6
7void dsps_wind_hann_f32(float *window, int len) { float len_mult = 1/(float)(len-1); for (int i = 0; i < len; i++) { window[i] = 0.5 * (1 - cosf(i * 2 * M_PI * len_mult)); } }
6. Nuttall window
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15void dsps_wind_nuttall_f32(float *window, int len) { const float a0=0.355768; const float a1=0.487396; const float a2=0.144232; const float a3=0.012604; float len_mult = 1/(float)(len-1); for (int i = 0; i < len; i++) { window[i] = a0 - a1 * cosf(i * 2 * M_PI * len_mult) + a2 * cosf(i * 4 * M_PI * len_mult) - a3 * cosf(i * 6 * M_PI * len_mult); } }
最后
以上就是传统硬币最近收集整理的关于常见窗函数C 实现窗函数的作用1.blackman 窗函数实现2.Blackman-Harris window3.Blackman-Nuttall window4.Flat-Top window5.Hann window6. Nuttall window的全部内容,更多相关常见窗函数C内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复