0
votes

I used the Short Time Fourier Transform on a random wav file and performed some changes on the magnitude spectrum. To "hear" what I did, I'm trying to reverse the process by using the inverse STFT.

In Python the spectrum looks like this. Magnitude Spectrum in Python

However, if I'm trying to convert the whole thing back into a wav and look at its spectrum it looks like this: Magnitude Spectrum after ISTFT

I'm just using the magnitude for the Inverse FFT. What am I doing wrong? Do I need the phase signal as well? And can I use the same phase signal even if I manipulated the magnitude?

# ....read wav-file, perform STFT on it and manipulate the magnitude spectrum
# Then (as follows) I'm trying to write it back
fs = 41000.0 # Frequency Spectrum

filteredwrite = istft(magnitude)

from scipy.io.wavfile import read, write
write('../data/mxx.wav', fs, filteredwrite.astype(x.dtype))

The Fourier functions work properly if I'm doing ifft(fft(F)) - nothing wrong here.

1

1 Answers

1
votes

The phase is required to reconstruct the original signal because the relative phases of the component frequencies determine the superposition of those waves.