fft of a dat file?

S

Soumen banerjee

Hello,
I'm kind of new to python and i wanted to do a little project, make a
frequency plot of some wav audio. I have been following this webpage
http://www.acronymchile.com/sigproc.html and have got to the making of
a dat file containing the samples and time of sampling. The question
here is how do i use FFT.fft to actually take an fft of this dat file
since the first two lines are useless and also we have a \r\n after
every sample. Also i would like some explanation on what FFT.fft
expects as input. Does it expect the sampling times also or only the
sampling values?
Regards
Soumen
 
S

Steven D'Aprano

Hello,
I'm kind of new to python and i wanted to do a little project, make a
frequency plot of some wav audio. I have been following this webpage
http://www.acronymchile.com/sigproc.html and have got to the making of a
dat file containing the samples and time of sampling. The question here
is how do i use FFT.fft to actually take an fft of this dat file since
the first two lines are useless and also we have a \r\n after every
sample. Also i would like some explanation on what FFT.fft expects as
input. Does it expect the sampling times also or only the sampling
values?


Did you follow the instructions in the webpage? I quote:

"Analysing the Signal
This is really quite easy, assuming you have Numerical Python and the FFT
modules installed. Continuing from our last code snippet, where "out"
contains a list of the samples from our sound file, the following gives
us an FFT:

import Numeric
import FFT
out_array=Numeric.array(out)
out_fft=FFT.fft(out)

It is as easy as that!"


Have you done this? Did it work? If not, what error did you get? If it
did work, then what's the problem?
 
S

Soumen banerjee

Hello
I have not tried the code because in no part of the code is the array
"out" being created. As such, it is bound to return an error that out
isnt created. The point here is how i can get sampled values from the
dat file which has lines like this:-

<sampling Time> <sampled Value> \r\n

i need to isolate the sampled values and put them into an array.
Regards
Soumen
 
R

R. David Murray

Soumen banerjee said:
Hello
I have not tried the code because in no part of the code is the array
"out" being created. As such, it is bound to return an error that out
isnt created. The point here is how i can get sampled values from the
dat file which has lines like this:-

<sampling Time> <sampled Value> \r\n

i need to isolate the sampled values and put them into an array.

Maybe something like:

samples = []
with open('myfile') as f:
for line in f:
time, value = line.strip().split()
samples.append([float(time), float(value)])

Modify as appropriate to your actual needs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top