From: Michal Wallace (sabren_at_manifestation.com)
Date: 2002-06-17 23:53:10
On Mon, 17 Jun 2002, larryjanow wrote:
> --- In buildcheapeeg_at_yahoogroups.com, Jim Peters <jim_at_uazu.net> wrote:
>
> > 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.
>
> 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!
Larry: I was wondering how I'd figure out amplitude. Thanks! :)
Here's the deal. The FFT module has several functions avaliable:
http://pfdubois.com/numpy/doc/FFT/FFT.py.html
I used real_fft because the sound processing in python
article said the real and imaginary parts would be mirror
images. I didn't check that assertion or try to see if it
worked in my case. I just chopped it off and saw that the
right thing seemed to be happening. But there's a plain
fft() function that returns a list of the same length as the
input.
I should say that complex numbers are a primitive type in
python, so the fft() function returns an array of complex
numbers, and you can take the .imaginary attribute or the
.real attribute to get an array with only the axis you want.
I've got some work-related stuff I need to get done today,
but I should have some time to play around with this
tomorrow.
If anyone wants to tak a look in the meantime, be my guest.
Cheers,
- Michal http://www.sabren.net/ sabren_at_manifestation.com
------------------------------------------------------------
Switch to Cornerhost! http://www.cornerhost.com/
High Powered Hosting - With a Human Touch. :)
------------------------------------------------------------
This archive was generated by hypermail 2.1.4 : 2002-07-27 12:28:44 BST