STFT分析与实现

STFT分析与实现

本篇文章是对上篇博文的补充以及个人的初步理解。

MATHEMATICAL DEFINITION OF THE STFT

STFT的通用数学定义如下:

Xm(ω)=n=x(n)w(nmR)ejωn

Xm(ω)=DTFTω(xcotSHIFTmR(ω))

其中,


x(n) = input signal at time n;
w(n) = length M window function;
Xm(ω) = DTFT of windowed data centered about time mR;
R = lop size, in samples, between successive DTFTs.

在上篇文章中,我们提到,如果窗函数在跳跃尺度为R的情况下满足COLA性质,即
m=w(nmR)=1,nZ(wCOLA(R))

那么,
m=Xm(ω)=n=x(n)ejωn=X(ω)

注意上面的 X(ω) 指的是被窗函数截断后,信号的离散时间傅里叶变换。以下的讨论将全部假设窗函数满足COLA(R)性质。例如,跳跃步长为M(M为窗函数长度)的矩形窗函数显然满足COLA(M),这种情况下 no overlap.
The Bartlett window and all windows in the generalized Hamming familyare COLA(M/2) (50% overlap), when the endpoints are handled correctly. Any window that is COLA is also COLA(R/k) , for k=2,3,4,,R , provided R/k is an integer.

The COLA requirement is important for avoiding artifacts. For usage as a spectrum analyzer for measurement and display, the COLA requirement can often be relaxed, as doing so only means we are not weighting all information equally in our analysis. Nothing disastrous happens, for example, if we use 50% overlap with the Blackman window in a short-time spectrum analysis over time–the results look fine; however, in such a case, data falling near the edges of the window will have a slightly muted impact on the results relative to data falling near the window center, because the Blackman window is not COLA at 50% overlap.

STFT COMPUTATION USING FFTS

  1. 用窗函数对输入信号x截取长度为M的样本, NM
    x^m(n)=x(n+mR),n=Mh,...,1,0,1,...,Mh

    我们把 xm 称作输入信号的第m帧(frame),同时把 x^m(n)=x(n+mR) 称作输入信号的标准帧(normalized input frame,time-normalized by translating it to time zero).帧的长度 M=2Mh+1 (为方便讨论,假设M是奇数).从当前帧跳转到下一帧的长度R称步长(hop size, or stpe size)
  2. 将窗函数与截取信号做点乘(point-wise)来获取window data frame
    x^ωm(n)=x^m(n)ω(n),n=Mh,...,1,0,1,...,Mh
  3. hatxωm(n) 补零:
    x^ω,zm(n)=x^ωm(n),|n|Mh=M12

    x^ω,zm(n)=0,otherwise

    where N is chosen to be a power of two larger than M . The number N/M is the zero-padding factor. the zero-padding factor is the interpolation factor for the spectrum, each FFT bin is replaced by N/M bins, interpolating the spectrum using ideal bandlimited interpolation, where the “band” in this case is the M -sample nonzero duration of x~wm in the time domain.
  4. x^ω,zm(n) 做傅里叶变换
    X^w,zm(ωk)=x^ω,zm(n)ejωknT,n[N/2,N/21)

    其中 ωk=2πkfs/N , fs=1/T
  5. STFT计算
    Xw,zm(ωk)=ejωkmRX^w,zm(ωk)

STFT IN MATLAB

    Xtwz = zeros(N,nframes); % pre-allocate STFT output array
    M = length(w);           % M = window length, N = FFT length
    zp = zeros(N-M,1);       % zero padding (to be inserted)
    xoff = 0;                % current offset in input signal x
    Mo2 = (M-1)/2;           % Assume M odd for simplicity here
    for m=1:nframes
      xt = x(xoff+1:xoff+M); % extract frame of input data
      xtw = w .* xt;         % apply window to current frame
      xtwz = [xtw(Mo2+1:M); zp; xtw(1:Mo2)]; % windowed, zero padded
      Xtwz(:,m) = fft(xtwz); % STFT for frame m
      xoff = xoff + R;       % advance in-pointer by hop-size R
    end

对第9行代码的理解:
FFT变换长度为N,窗函数尺度为M
首先要对截取信号进行补零,但为什么不是 xtwz = [xtw(1:Mo2); xtw(Mo2+1:M); zp]?
个人理解:
其实两者均可, 二者的频谱统计是一直的,代码中利用了离散傅里叶变化的性质(简单的说,我们把截断信号看成是补零后,周期为N的周期信号,而我们只需对其中的一个周期做变换即可)

你可能感兴趣的:(数字通信)