Understanding overlapping in STFT I understand the concept of the STFT. In order to avoid spectral leakage, you use a Hann window that overlaps by 50%. However, the problem that I have, is that the example code online does not account for this.

What I mean is, if the signal is overlapping by 50%, why doesn't anyone add the frequency content of the overlapping sections?

https://kevinsprojects.wordpress.com/2014/12/13/short-time-fourier-transform-using-python-and-numpy/

This is an example of what I mean. It looks like he is grabbing the overlap, but he is not adding the overlap pieces together. I don't see how the frequency content is being saved. He windows a function, does the FFT, then moves over and does the FFT again with the overlapping piece. I feel like he should be adding the overlapping pieces together. Is there something I am missing?

Thank you: John

Edit: I see the first answer, but it is still not hitting home. Hanning windows make the left and right information approach zero. So when it is overlapped, this removes this problem. However, when the FFT is taken, the information of the transform is put side-by-side. Wouldn't this mean, First Window=> upper time series information lower amplitude, Second window =>lower time series information lower amplitude.... This does not seem to solve the issue. You are still losing information with each window... is this not the case?
I understand the concept of the STFT. In order to avoid spectral leakage, you use a hann window that overlaps by 50%.


I'm sorry but you have a misunderstanding of spectral leakage in addition to how a spectogram should be computed. To be exact you cannot avoid spectral leakage completely; all you can do is to make a compromise between the spectral resolution and the spectral leakage: A window that yields less spectral leakage should have smaller side lobes (in its window Fourier transform), but that window will unavoidably smear the input signal spectrum because of the increased main lobe width (of the window Fourier transform) and therefore limit the spectral resolution per given window length. 

So you should optimize between spectral leakage and spectral resolution. In order to increase spectral resolution for a given accepted leakage level you can increase the window length. But then this will decrease the time localization of the STFT. And in order to accomadate for this latter side effect, you can use overlapping windows so that the next window does not start from the end of the current window, but begins somewhere in the middle; an accepted choice is 50% overlapping. But you can also use other percentages according to your application as @StanleyPawlukiewicz states in his answer. 

Note that 50% overlapp is also an optimal choice to reduce the variance of the estimate of the power density spectrum computed by the periodogram averaging applied in overlapping windowed analysis segments (the Welch's method)