So I've been working with FFT, and I'm currently trying to get a sound waveform from a file with FFT, (modify it eventually), but then output that modified waveform back to a file. I've gotten the FFT of the soundwave and then used an inverse FFT function on it, but the output file doesn't sound right at all. I haven't done any filtering on the waveform - I'm just testing out getting the frequency data and then putting it back into a file - it should sound the same, but it sounds wildly different. Any ideas?
-- EDIT --
I have since been working on this project a bit, but haven't yet gotten desired results. The outputted sound file is noisy (both more loud, as well as extra noise that wasn't present in the original file), and sound from one channel leaked into the other channel (which was previously silent). The input sound file is a stereo, 2-channel file with sound only coming from one channel. Here's my code:
import scipy
import wave
import struct
import numpy
import pylab
from scipy.io import wavfile
rate, data = wavfile.read('./TriLeftChannel.wav')
filtereddata = numpy.fft.rfft(data, axis=0)
print (data)
filteredwrite = numpy.fft.irfft(filtereddata, axis=0)
print (filteredwrite)
wavfile.write('TestFiltered.wav', rate, filteredwrite)
I don't quite see why this doesn't work...?
EDIT: I've zipped up the problem .py file and audio file, if that can help solve the issue here.
ifft
of the fft
(post-filtering), not of the input waveform.