1
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 - 请告诉我这是否是将汉宁窗应用于信号的正确方法?

4

1 回答 1

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;
}
于 2012-07-22T14:50:26.183 回答