fft of a dat file?

Discussion in 'Python' started by Soumen banerjee, Mar 25, 2009.

  1. 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
    Soumen banerjee, Mar 25, 2009
    #1
    1. Advertising

  2. 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
    Steven D'Aprano, Mar 25, 2009
    #2
    1. Advertising

  3. 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
    <> 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
    >
    Soumen banerjee, Mar 25, 2009
    #3
  4. Soumen banerjee <> 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
    R. David Murray, Mar 25, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. aj
    Replies:
    3
    Views:
    4,172
    Jaakko Varteva
    Nov 24, 2005
  2. Replies:
    0
    Views:
    511
  3. palmis

    file .dat into a window

    palmis, Jan 18, 2006, in forum: Java
    Replies:
    5
    Views:
    423
    palmis
    Jan 23, 2006
  4. Vitaliy
    Replies:
    0
    Views:
    448
    Vitaliy
    Dec 8, 2006
  5. Vitaliy
    Replies:
    2
    Views:
    1,907
    Matthew Hicks
    Dec 8, 2006
Loading...

Share This Page