I a recent topic, it has been told that zero-padding in the STFT can improve it, and avoid some circular convolution related things.
Here is my Python code for STFT :
fftsize = 8192; overlap = 4; hop = fftsize / overlap # ie hop = 2048 here w = scipy.hamming(fftsize) # hamming window # x is the input signal, I assume it is already of length 2^k, ie no zero padding required for x # STFT x_stft = scipy.array([scipy.fft(w*x[i:i+fftsize]) for i in range(0, len(x)-fftsize, hop)]) # ISTFT y = scipy.zeros(len(x)) for n,i in enumerate(range(0, len(x)-fftsize, hop)): y[i:i+fftsize] += scipy.real(scipy.ifft(x_stft[n])) * w # overlap-add
How can I do the zero padding with this code ? Which array should I enlarge ?
PS : in order to simplify the code, I haven't normalized the window, so for perfect reconstruction, one has to add a multiplying constant, etc. (it's not important here)