What is the difference in between the different STFT implementations? (Overlap-shift with zero-padding, overlap-add, overlap-save, etc) I'm trying to understand STFT overlapping, why segments are concatenated and what are the consequences of this.

My implementation (from other questions and repositories found) of the STFT in Python is:

def stft(x, L, overlap, window): # Linear Spectrum (LS) [V]
opoints = int(L*overlap)
hopsize = L - opoints
X = np.array([(2 * np.abs(np.fft.fft(window*x[i:i+L])[:L//2])) / np.sum(window)
             for i in range(0,len(x)-L,hopsize)])
return X


where, x is the time-domain signal sampled at 44.1kHz, L is the FFT window size (4096), overlap is the overlapping factor [0, 1), and window is the window funtion used (Hanning). The absolute value of half the complex dft is scaled by 2/sum(win) so that the units of the linear spectrum are the same as for the input signal (V).

I used to understand the frequency resolution is fs/L and the width of the time slices or time resolution is L/fs, so that the number of time windows is N/L. However, if using overlapping (overlap!=0), the number of time windows increases ~(N/hopsize)-1.


Why are overlapped segments concatenated instead of added and what are the consequences of this regarding the time axis? (See picture below)
Is compressing the concatenated segments into the original duration of the signal correct? (i.e 3 segments of 1 second into 2 seconds, see picture below)




EDIT1:

Now, I do understand:


Overlap-shift and compression of the time axis of the overlapped segment into the original duration is one way to make a smoother spectrograph image
Overlap is needed in order to avoid lossy signals caused by the window


However, from @user31990 comment I still need to clarify:


What's the difference between the different methods/implementations?


Implementations I've found/understood:


Overlap and concatenate side-by-side the overlapped blocks (increasing the number of time windows and compressing the x time axis to the original duration)
Overlap adding the segments of the block that are overlapped together (the number of time windows doesn't increase = N/L)
Overlap save (zero-pad the beginning of the block and discard the transformed segment, the number of time windows doesn't increase)
Overlap shift with zero-pad


I don't totally understand the overlap shift with zero-pad, what is it doing?



My implementation is an example of the overlap and concatenate method.


Are This and Google's pytfd stft implementations examples of the overlap shift with zero-pad method?


EDIT2:

I was confused about the methods, question is answered/solved.

Zero-padding is a method that can be used: 1. To obtain an FFT of size N of a window whose size is smaller 2. To increment the size of the FFT, interpolating values in the frequency axis and obtaining smoother data.

Overlap-add and overlap-save are methods for the synthesis of an IFFT output in order to recover the original signal x.
Compressing the time axis of the overlapped windows into the original duration is one way to make a smoother spectrograph image.

Also, bell-shaped windows are lossy near the edges (after re-quantization), but a 50% overlap of Von Hann windows recovers all that information in each overlap.