tukey窗口也称作锥形余弦窗( cosine-tapered window),tukey的Python使用
tukey窗口有两个参数:长度len 和 窗口形状
窗口形状:
0 矩形窗
(0,1) 锥形余弦窗 指定上升和下降区间占整个长度的百分比
1 汉宁窗 相当于截取y=cos(x) 在0~2pi之间的区域,然后倒转回来
void tukey(unsigned int len, unsigned int m)
{
double up_down = (double)m / 100; // 递增和递减区间所占比例 入参m放大了100倍
double hoop = 1 / (double)(len-1); // 步长
int i;
double x = 0;
double left = up_down / 2;
double right = 1 - left;
double win;
for (i = 0; i < len; i++) {
if (x < left) {
win = (1 + cos(2 * PI * (x - left) / up_down)) / 2;
} else if ((x >= left) && (x <= right)) {
win = 1;
} else {
win = (1 + cos(2 * PI * (x - 1 + left) / up_down)) / 2;
}
printf("%x ", win);
x += hoop;
}
}