4
$\begingroup$

It is my rough understanding that a typical spectrogram discards phase information by squaring only the real-valued part (magnitude) of the STFT (I know it's not quite this simple, but feel free to correct me if I'm wildly wrong here).

While many software libraries (e.g., scipy) will, by default, produce a spectrogram of magnitude, they often also make it possible to instead compose a separate spectrogram for phase. My question is quite simple: if I had both of these matrices, could I reconstruct the original signal?

I suspect the answer to this question is 'not quite'. If so, what part of the process is problematic and are there any changes that could be made to make this goal achievable? I am currently using STFT.real and STFT.imag (where STFT is a 2D matrix for the short time Fourier transform of some signal) and plotting of them separately. While I can reconstruct the original signal using this approach (which I need to be able to do), these plots are not as easy to read as actual spectrograms.

(For instance, I know that squaring the magnitude is clearly a problem for reconstruction as it destroys negative numbers).

$\endgroup$
2
  • $\begingroup$ One useful link here: Reconstruction of audio signal from Spectrogram. $\endgroup$
    – Gilles
    Commented Feb 19, 2018 at 17:31
  • $\begingroup$ @Gilles. Thank you -- I saw that prior to posting. My position is somewhat different because I do not need to try and infer phase. It's acceptable to me to have another distinct matrix that saves all of the phase information. $\endgroup$
    – lnNoam
    Commented Feb 19, 2018 at 17:36

1 Answer 1

4
$\begingroup$

Real/imaginary or modulus/phase are two representations of a complex number that carry the same level of information. Then, a STFT is a redundant mapping from a space of functions over a 1D variable (time) onto a space of functions over a 2D variable (time and frequency). Under mild conditions on the window, there are an infinity of inverses, due to the redundancy. In the continuous setting, the analysis ($a$) and synthesis ($s$) windows only need to overall a little (more pedantic: $0 < \int a(t).s(t)dt <+\infty$). In the discrete form, this can be a little more involved, yet there are several optimized inverses for "almost" every sound redundant analysis filter-bank).

So, if for each point of the $(t,f)$ plane, you have the magnitude in the phase, you can recover the waveform (apart possibly at the extremeties). A side effect of the huge redundancy, inversion even remains (approximately) possible under mild conditions if you only have the modulus or the phase.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.