Re: mp3 fft with python

Discussion in 'Python' started by Dmitry Borisov, Aug 18, 2004.

  1. From: "Garett Shulman"
    Sent: Tuesday, August 17, 2004 6:42 PM
    Subject: mp3 fft with python


    > Hello, I would like to do a fft on an mp3 in python. I beleive I have
    > all of the fft stuff straight in my mind but am not sure of the best way
    > to get the sample data into a python array. I ran accross a web site a
    > while back which suggested using sox to convert a wav file into a raw
    > sample file and then open the raw file with python. However, I did not
    > bookmark this site when I came accross it and cannot seem to find it
    > now. If anyone has any suggestions as to a good way to get sample data
    > out of an mp3 and into a python array for an fft I would greatly
    > appreciate your suggestions. Thanks a lot. -Garett


    Not sure if it'll work for you. But here it is:

    SAMPLES= 500
    BANDS= 20
    NUM_FREQS= 256

    import pymedia.audio.acodec as acodec
    import pymedia.audio.sound as sound

    dec= acodec.Decoder( 'mp3' )
    analyzer= sound.SpectrAnalyzer( 1, SAMPLES, NUM_FREQS )
    ....
    s= f.read( 20000 )
    while len( s ):
    r= dec.decode( s )
    if len( r.data ):
    # Get fft info as bands
    bands= analyzer.asBands( BANDS, s )
    freqs= analyzer.asFrequencies( s )
    ...

    http://pymedia.sourceforge.net

    You may need to take a look at the examples/sound_viz.py in the source
    tarball.
    Dmitry/
     
    Dmitry Borisov, Aug 18, 2004
    #1
    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,308
    Jaakko Varteva
    Nov 24, 2005
  2. Daniel Dyer
    Replies:
    6
    Views:
    20,192
    Knute Johnson
    Jan 22, 2006
  3. Asle Frantzen

    Mp3-player - how to play an mp3?

    Asle Frantzen, Jul 8, 2003, in forum: C++
    Replies:
    5
    Views:
    690
    Kelsey Bjarnason
    Jul 22, 2003
  4. Garett Shulman

    mp3 fft with python

    Garett Shulman, Aug 18, 2004, in forum: Python
    Replies:
    0
    Views:
    499
    Garett Shulman
    Aug 18, 2004
  5. HY Tech
    Replies:
    0
    Views:
    639
    HY Tech
    Sep 7, 2003
Loading...

Share This Page