Re: [buildcheapeeg] Re: need help with DSP

From: Jim Peters (jim_at_uazu.net)
Date: 2002-06-17 19:38:14


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