Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > fft of a dat file?

Reply
Thread Tools

fft of a dat file?

 
 
Soumen banerjee
Guest
Posts: n/a
 
      03-25-2009
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
 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      03-25-2009
On Wed, 25 Mar 2009 11:26:00 +0530, Soumen banerjee wrote:

> 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?


--
Steven
 
Reply With Quote
 
 
 
 
Soumen banerjee
Guest
Posts: n/a
 
      03-25-2009
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


On Wed, Mar 25, 2009 at 12:15 PM, Steven D'Aprano
<(E-Mail Removed)> wrote:
> On Wed, 25 Mar 2009 11:26:00 +0530, Soumen banerjee wrote:
>
>> 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?
>
>
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list
>

 
Reply With Quote
 
R. David Murray
Guest
Posts: n/a
 
      03-25-2009
Soumen banerjee <(E-Mail Removed)> wrote:
> 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.

--
R. David Murray http://www.bitdance.com

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data DAT tape in audion DAT recorder? Barry Computer Support 17 06-02-2010 06:48 AM
FFT on Virtex-II Pro (how to download .dat file?) Vitaliy VHDL 2 12-08-2006 09:08 PM
FFT on Virtex II Pro (how to download .dat file?) Vitaliy VHDL 0 12-08-2006 07:33 PM
To all FFT guru's (2048 point FFT on Virtex 2 pro) aj VHDL 3 11-24-2005 08:53 PM
history.dat, formhistory.dat - deleting deletes history? S.Rodgers Firefox 4 05-05-2005 01:03 AM



Advertisments