Why is stft(istft(x)) ≠ x?
Using PyTorch, I have computed the short-time Fourier transform of the inverse short-time Fourier transform of a tensor.
I have done so as shown below given a tensor x.
For x, the real and imaginary part are equal, or the imaginary part is set to zero -- both produces the same problem.
torch.stft(torchaudio.functional.istft(x, n_fft), n_fft)
As shown in the image, only a single one of the stripes in the tensor remains after applying stft(istft(x)) -- all other stripes vanish.
If stft(istft(x)) (bottom) was equal to x (top), both images would look similar.
Why are they so different?
It seems like stft(istft(x)) can pick up only certain frequencies of x.
x (top) and stft of istft of x (bottom)
I have also tried the same with scipy.signal.istft and scipy.signal.stft which causes the same issue.
Moreover, I have tried it with a wide range of tensors x, e.g., different randomized distributions, images, and other stripes.
Also, I have tried a variety of hyper-parameters for stft/istft.
Only for x generated by a short-time Fourier transform from a sound wave, it works.