# 18.4.3.2 Algorithms (STFT)

A STFT devides an input signal, {ix(n)}, into N sections according to the sliding window, and performs FFT on each sections. It can be defined as

$STFT\left \{x[n]\right \} \equiv X(m, \omega)=\sum_{n=-\infty}^\infty x[n]\omega [n-m]e^{-j\omega n}$

where $\omega (n)$ represents the sliding window that emphasizes local frequency components within it.

STFT is computed in the following procedure:

1. Devide the input signal into N section. Each time n points are taken, where n is equal to the Window length specified.
2. The chosen Window Type is used to multiply the extracted data, point-by-point.
3. Zeros will be padded on both sides of the window, if the Window length is less than the size of the FFT Length.
4. FFT is computed on the FFT section.
5. Move the window according to the user-specified Overlap size, and repeat steps 1 through 4 until the end of the input signal is reached.

The result of STFT is a matrix that has N columns and M rows, where

$N=floor(\frac{DataSize-Window Size}{WindowSize-OverlapSize})+1\,\!$

and

$M= \begin{cases} FFTLength/2+1, & \mbox{if input signal is real} \\ FFTLength, & \mbox{if input signal is not real} \end{cases}$

jth column in the matrix represents the FFT result of the jth section of the input signal and the X value of this column is the center time of the jth section. The Y values are the frequency obtained from the sampling interval $\Delta t$ and the number of input data points N. The ith frequency is given by:

$f_i=\frac i{N\Delta t}$

About the automatic computation of the sampling interval:

When <Auto> is selected for Sampling Interval, the sampling interval needed in the computation is computed automatically by Origin.

The automatically computed sampling interval is the average increment of the time sequence, which is usually from the X column associated with the input signal. If there is no associated X column, the row numbers will be used. Note that if Origin fails to get the average increment, the sampling interval will be set to 1.

Windows

Specifies the window type used by FFT. The default option is Hanning.

• Rectangle
Rectangular window:
$w[n] = \begin{cases} 1, & \mbox{if }0 \leq n \leq N-1 \\ 0, & \mbox{otherwise } \end{cases}$
• Welch
Welch window
$w[n]=1-\left[ \frac{n-\frac 12(N-1)}{\frac 12(N+1)}\right] ^2\,\!$
• Triangular
Triangular window
$w[n]=\frac 2N\left[ \frac N2-\left| n-\frac N2\right| \right] \,\!$
• Bartlett
Bartlett window
$w[n]=\frac 2{N-1}\left[ \frac{N-1}2-\left| n-\frac{N-1}2\right| \right] \,\!$
• Hanning
Hann Window
$w[n]=\frac 12\left[ 1-\cos (\frac{2\pi n}{N-1})\right] \,\!$
• Hamming
Hamming window:
$w[n]=0.54-0.46\cos (\frac{2\pi n}{N-1}) \,\!$
• Blackman
Blackman window
$w[n]=0.42-0.5\cos (\frac{w\pi n}{N-1})+0.08\cos (\frac{4\pi n}{N-1}) \,\!$
• Gaussian
Gaussian window:
$w[n]=exp(0.5\left( \frac{Alpha(n-\frac N2)}{\frac N2}\right) ^2) \,\!$
where Alpha is specified by the Alpha parameter.
• Kaiser
Kaiser window:
$w[n]=I(beta*\sqrt{1-(\frac{2n}{N-1}-1)^2}) / I(beta) \,\!$
where I(ix) denotes Bessel Function and beta is specified by the Beta parameter.

Results

1. Complex Result
Complex FFT result on each FFT section. And it is shifted so that beginning part is the result of negative frequencies.
2. Amplitude Result
One-sided for real input signal and two-sided for complex input signal. The definition is similar to FFT tool's amplitude. And for the two-sided result shift is used so that the beginning part is the result of negative frequencies.
3. Amplitude in dB
$20\text{log}(\text{Amplitude})$

Time
Each FFT section's time in the STFT result corresponds to the center of the time interval for each section's signal. e.g. for a section interval (ti, ti+(N-1)*dt), its FFT section's time in the STFT result is: ti+(N-1)*dt/2.