# How can the FFT analyze a wave in which the components are changing?

Based on what I've read about Fourier Transforms, it seems that they are designed to work on waves whose components are constant. For example, a simple square wave is

$\sin(\theta) + 1/3sin(3\theta) + 1/5sin(5\theta)+ 1/7sin(7\theta)$

However, there are times when a Fourier Transform is used to compute a spectrogram for a file such as a song in which the frequencies that the instruments are playing often change or disappear completely. How does a Fourier Transform know that a given frequency does not exist for a certain period of time? Does it have to break the file down into components and analyze each of those? The presence of time, frequency, and amplitude on a spectrogram suggests that it works, but I don't fully understand how. Thanks in advance for your help.

• There is always a trade-off between how much time vs. frequency resolution, which is primarily determined by the number of samples in each block of your FFT. The more samples in each block, the more frequency resolution you have (your resulting FFT has more bins), but the trade-off is more time smearing, since the block represents a longer length of signal at the sampling rate. If you think of a spectrogram as an image with X being time and Y being frequency, there is always a trade-off between how many X "pixels" you have vs. how many Y "pixels" you have for a given length of signal. – Zuofu Aug 9 '15 at 19:38