[linux-audio-dev] mp3 fft with python

Cournapeau David (ENST) cournape at enst.fr
Wed Aug 18 09:00:20 UTC 2004


michael tewner wrote:

>For my college final project, I'm embarking on a very similar idea. My
>project advisor has me implementing a wavelet transform in python, and
>displaying a waterfall in tcl/tk. GRanted, I've never programmed in either
>language;  I'm not even sure either of those are efficient enough to
>handle it in real time!
>  
>
I don't have much experience with python, but to open a wavfile, you can 
use snack:

http://www.speech.kth.se/snack/

"The Snack Sound Toolkit is designed to be used with a scripting 
language such as Tcl/Tk <http://tcl.activestate.com/> or Python 
<http://www.python.org/>. Using Snack you can create powerful 
multi-platform audio applications with just a few lines of code. Snack 
has commands for basic sound handling, such as playback, recording, file 
and socket I/O."

One thing which annoyed me when using snack is that whenever you are 
using it, you need to open an audio device, even if you just want to 
read a wavfile. On computers with soundcard which don't support hardware 
mxing, it is very annoying.

A great thing would be to wrap libsndfile to python, but I don't know 
anything about implementing C extension in Python, so I don't really 
know how easy it is. Maybe Erik, the creator of libsndfile, have better 
advice to give ;)

Computing simple wavelet tranforms (1d, dyadic wavelet) is trivial even 
in C, it should be pretty straightforward to implement it with Python. 
There is the numarray extension, which enables to compute with arrays in 
a efficient way, a la matlab. In fact, I looked at python a few months 
ago to see if it could replace matlab as a scientific environment, 
projects like scipy are promising (http://www.scipy.org/). But right 
now, python is moving from numeric ( a former fast vector implementation 
for python) to numarray, which creates a lof of incompatibilities 
between different python libraries, and made me stay away from switching 
from matlab to Python, at least for now.

Concerning fft, it should be easy to wrap fftw, for example. See for 
example this link : http://pylab.sourceforge.net/

Right now, *I* have the feeling that the biggest problem of python for 
numeric computation is the lack of standardization, but it will 
hopefully change soon(I can't imagine how wonderful it would be to run 
IronPython with scientific extensions into mono :) ).

David



More information about the Linux-audio-dev mailing list