From: larryjanow (larrywj_at_attbi.com)
Date: 2002-06-17 20:10:54
I made my comments based on Michal's statement about discarding the
imaginary bins and just using the real ones. While my example might
not work for his FFT's output format, the method is still valid:
a=sqrt(r*r+i*i)/(N/2). If the compiler or library handles this (I
know nothing about Python...), that is cool!
--- In buildcheapeeg_at_yahoogroups.com, Jim Peters <jim_at_uazu.net> wrote:
> larryjanow wrote:
> > You can't discard the 'imaginary' half of the FFT output, you
need
> > it to calculate the actual output amplitude at each frequency.
>
> His python code looks like this:
>
> def makeSpectrogram(slice):
> assert len(slice)==64, "we want 32 bins, so we need 64 samples"
>
> res = abs(FFT.real_fft(slice))[:-1] # discard 33rd slot (is
this okay?)
> res = Numeric.floor(res) # round off to integers
>
> assert len(res)==32, len(res)
> return res
>
> If real_fft is returning 33 values from a 64-sample input, then it
> seems to me that it must be returning complex numbers. If so, then
> the abs() function should automatically do the square root you
> mention (i.e. sqrt(r*r+i*i)).
>
> Perhaps this needs checking. However, obviously the Python
> FFT.real_fft is not returning the imaginary parts as real numbers
in
> the places you are expecting it to, so your method won't work in
this
> particular case, and is based on some other FFT algorithm's output
> layout.
>
> Jim
>
> --
> Jim Peters (_)/=\~/_(_) jim_at_uazu.net
> (_) /=\ ~/_ (_)
> Uazú (_) /=\ ~/_ (_)
http://
> B'ham, UK (_) ____ /=\ ____ ~/_ ____ (_)
uazu.net
This archive was generated by hypermail 2.1.4 : 2002-07-27 12:28:44 BST