- Home /
How to choose FFT Window type
Hi. I noticed there are this types on the FFTwindow function from Unity
Rectangular W[n] = 1.0. Triangle W[n] = TRI(2n/N). Hamming W[n] = 0.54 - (0.46 COS(n/N) ). Hanning W[n] = 0.5 (1.0 - COS(n/N) ). Blackman W[n] = 0.42 - (0.5 COS(n/N) ) + (0.08 COS(2.0 n/N) ). BlackmanHarris W[n] = 0.35875 - (0.48829 COS(1.0 n/N)) + (0.14128 COS(2.0 n/N)) - (0.01168 COS(3.0 * n/N)).
How do I know which one is the best to use in my case and why? I did some research but it still not very clear to me, they all seem to be ok to use in different situations. If anyone know a good article or something about this topic would be very useful too!
Answer by aldonaletto · Apr 19, 2019 at 01:31 PM
The FFT gets a subset of samples (a number of consecutive audio samples) and calculates how much of each harmonic is present in that subset. But the FFT "thinks" that all samples outside the subset are 0, which seems like a big rectangular pulse (as wide as the number of samples) multiplied by the signal, and the harmonics of such "pulse" are mixed with the audio signal.
The windowing function is a trick that greatly reduces these spurious harmonics: the samples are multiplied by special factors that vary along the window, and the resulting FFT gets much cleaner. Since these factors are calculated on-the-fly, a more complex windowing function can slow down the FFT - that's why Unity allows selection of the window type.
Rectangular means no correction window at all, which's fast but dirty. Triangle is a triangular window, cleans reasonably the FFT at very low cost. Hamming, Hanning, Blackman and BlackmanHarris windows are progressively more slower and cleaner alternatives (evaluating COS is usually a slow operation).
If you're going to use the FFT for precise operations like evaluating the pitch of a given sound, select the more complex windows - Blackman or BlackmanHarris. For less stringent operations like spectrum displays, evaluation of audio ranges (treble, bass, mid etc.) and other applications where precision is not required, try triangle, Hamming or Hanning windows (even the rectangular window may be good enough in many cases).
Answer by elix · Apr 19, 2019 at 12:45 PM
It's depends on continuity of the data. When start and end data are seamless,Rectangular is best to use. Other situation, may be Hamming.
Your answer
Follow this Question
Related Questions
Music works but not when accessed by another script in JavaScript 1 Answer
Play Audio Through Scenes 0 Answers
Audio cuts out once a certain number of sounds are played 0 Answers
Background music 0 Answers
Audio Needs to stop 1 Answer