FFT woes

eric hagemann ehagemann at comcast.net
Tue Dec 31 16:34:41 EST 2002


Bruce,

    I'd need a copy of "input3.wav" to be sure, but it appears that you have
a zero magnitude in one of the fft bins.  Adding the 1e-20 makes sure that
you do not take log10(0) -- which is undefined

Cheers
Eric


"Bruce Conlon" <vitamonkey at hotmail.com> wrote in message
news:v13t5hakpug725 at corp.supernews.com...
> Hello,
> I'm very green at signal processing and only have a passing grasp of the
> subject, and am trying to play with an example I found here (
> http://www.onlamp.com/pub/a/python/2001/01/31/numerically.html ) using a
> sampled wave. I'm trying to plot the FFT of the wave using DISLIN but am
> getting strange results (if any).  If anyone could lend a hand, I would
> greatly appreciate it.
> Thanks,
> Bruce
>
> ------CODE------
> from dislin import *
> from Numeric import *
> import FFT
> import wave
>
> filename = "input3.wav"
> input = wave.open(filename, "r")
> numsamp = input.getnframes()
>
> y = array(input.readframes(numsamp), Float32)
> x = arange(numsamp, typecode=Float32)
>
> yray = 10*log10(absolute(FFT.real_fft(y)))
> #should work? overflow exception...why?
> #I can work around it by adding (right inside log10 )
> #a small (negligible) number like 1e-20 but dont see the why
>
> yray = array(yray.tolist()[0:-1])
> #above list comes out one element greater
> # than below so have to chop one off
> xray = x[0:(len(yray.tolist()))]
>
> setvar('T1','FFT Plot of '+filename)
> setvar('X','Frequency')
> setvar('Y','Amplitude')
>
> plot(xray,yray)
> disfin()
>
>





More information about the Python-list mailing list