汉宁(冯汉恩)的窗口

时间:2012-07-22 13:04:30

标签: java android signal-processing

public short[] HanningWindow(short[] signal_in ,int pos ,int size)
{
    for (int i= pos; i < pos+size; i++)
    {
        signal_in[i] = (short) ((signal_in[i]) * ( 0.5 * (1-Math.cos( (2 * Math.PI * i) /    (size - 1))))) ;
    }
    return signal_in;
}

我正在尝试使用它

pos = (ring+delay*frame_rate*frame_size)%(frame_size*(frame_rate+1));
num = record.read(lin,pos,frame_size);           

GGSpecSub tempSpecSub = new GGSpecSub();
lin = tempSpecSub.HanningWindow(lin, pos, frame_size);

这是我第一次使用实时DSP - 请告诉我这是否是将汉宁窗口应用于信号的正确方法?

1 个答案:

答案 0 :(得分:3)

不,它需要更像这样:

public short[] HanningWindow(short[] signal_in, int pos, int size)
{
    for (int i = pos; i < pos + size; i++)
    {
        int j = i - pos; // j = index into Hann window function
        signal_in[i] = (short) (signal_in[i] * 0.5 * (1.0 - Math.cos(2.0 * Math.PI * j / size)));
    }
    return signal_in;
}