# What is the advantage of overlapping windows while evaluating Spectrogram?

I've seen many documents that refer to calculate spectrogram through overlapping windows but haven't found clear documents on why this is done and how to calculate the number of points that need to be overlapped? What will happen if I don't overlap the successive windows?

Microcontrollers have a tiny RAM and low processing speed (84 Mhz in my application). So reducing the number of elements in the spectrogram will bring a great advantage.

• Overlapping windows improve the perceived time-resolution and, based on Welch's method, reduce the variance of the PSD estimate. The improved time-resolution can be useful to help in locating certain (short-duration) events. The reduced variance is always beneficial I'd say. Jul 28, 2021 at 16:48

1. The main purpose of windowing is to manage the amount of spectral leakage. If you don't know what this is, just search this forum or ask a separate question.
2. In order to reduce spectral leakage the window must fade out at the ends of the window.
3. Overlap is needed to make sure all samples are weighed equally (at least roughly). Any window weighs the samples in the middle higher than the one at the edges. Hence a sample at the edge must be weighted higher in the next (or previous) window. This is can be conveniently done by overlapping the windows.

how to calculate the number of points that need to be overlapped?

For many "normal" windows (hanning, hamming, etc.) 50% overlap works fine for most applications.

What will happen if I don't overlap the successive windows?

This depends very much on the signal, but here is an example. Let's say you have non-overlapping Hanning windows of length 128 centered around n = 64, 192, 320, etc.

If your input is a unit impulse at n = 64 you are in the middle of the first window, the weight is one and you get a flat spectrum at 0 dB. If your input is a unit impulse at n = 128, you are at the very last sample of the first window, the weight here is tiny (0.00059297) and so your spectrum is down by more than -64 dB which is clearly wrong. Due to not overlapping you are "missing" the main event in the signal as it falls "between windows".

50% overlap fixes this, since the n=128 is right in the center of the next overlapping window.

• My signal is of very low frequency (near infrasonic), and if filtered through an analog low pass and digital bandpass of a high order. So any impulse or high-frequency audio signal won't be present in the waveshape. So, I guess 20-25% overlap may work fine. Jul 28, 2021 at 17:40
• If you have low bandwidth reducing the sample rate will probably give you more bang for the buck. Jul 28, 2021 at 18:12

If there no overlap, then invertibility is lost, and so is information.

If there is overlap, but it is little, then analysis information is lost (but not synthesis, which is more fundamental). Namely, from 0 to 0.5 times the sampling frequency, if "hop length" is 2, then analysis information for frequencies bewteen 0.25 and 0.5 is aliased. If hop length is 4, then 0.125 to 0.5 is aliased, and so on.

"Analysis information" is the very goal of transforming data in the first place (if all we cared for was preserving the input, simply don't do a transform). For STFT, it refers to time-frequency modulation information: a row captures (within the window's resolution) the instantaneous frequency and amplitude of the signal over time. The lesser the overlap (greater hop length), the less dynamics are captured.

The good news is, if all you seek is the spectrogram, i.e. absolute value of STFT (amplitude), then loss of this information is fairly minimal: taking absolute value globally shifts frequencies of every row toward low frequencies, and most often very low frequencies, which permits a generous hop length. This is proven for the wavelet transform, but the arguments will approximately hold for most STFT windowings.

Worth noting, strict invertibility is likewise lost for the spectrogram for any hop length other than 1; the extent of loss can be estimated via inversion algorithms like Griffin-Lim. However, if we cannot invert the raw STFT, it literally means we completely threw away segments of data; this is 100% irrecoverable unlike the modulus.

If processing power is a limitation, options are: 1) use a wider window, which increases frequency resolution at expense of time resolution but also permits greater hop size; 2) overlap-add.