Copio un mensaje relacionado con el tema que me llegó por otra lista:

--------------------------------------------------------------

We have a realtime spectrogram plot in the Audio Spectrum example for
Chaco.  (See the very last screenshot on the gallery page here:
http://code.enthought.com/projects/chaco/gallery.php)

You can see the full source code of the example here:
https://svn.enthought.com/enthought/browser/Chaco/trunk/examples/advanced/spectrum.py

The lines you would be interested in are the last few:

def get_audio_data():
    pa = PyAudio()
    stream = pa.open(format=paInt16, channels=1, rate=SAMPLING_RATE,
                     input=True,
                     frames_per_buffer=NUM_SAMPLES)
    string_audio_data = stream.read(NUM_SAMPLES)
    audio_data  = fromstring(string_audio_data, dtype=short)
    normalized_data = audio_data / 32768.0
    return (abs(fft(normalized_data))[:NUM_SAMPLES/2], normalized_data)

Here we are using the PyAudio library to directly read from the sound
card, normalize the 16-bit data, and perform an FFT on it.

In your case, since you are reading a WAV file, you might be
interested in the zoomed_plot example:
http://code.enthought.com/projects/chaco/pu-zooming-plot.html

This displays the time-space signal but can easily be modified to show
the FFT.  Here is the relevant code that uses the built-in python
'wave' module to read the data:
https://svn.enthought.com/enthought/browser/Chaco/trunk/examples/zoomed_plot/wav_to_numeric.py

You should be able to take the 'data' array in the wav_to_numeric
function and hand that in to the fft function.

-----------------------------------------------------------------------------------

_Ricardo

2008/8/15 Hernán Ordiales <[EMAIL PROTECTED]>

> 2008/8/12 Gabriel Zea <[EMAIL PROTECTED]>:
> > Hola,
> >
> > tal vez alguien en la lista me pueda ayudar a  encontrar la manera de
> > hacer un FFT al audio de entrada en vivo por en microfono en python?
>
> Aca te dejo un ejemplo de uso de la fft en python para hacer una
> convolución (solo el cálculo, no para usarlo en tiempo real):
> http://audiores.uint8.com.ar/files/code/fast_conv.py (explicaciones
> aca:
> http://audiores.uint8.com.ar/blog/2006/12/27/funciones-para-trabajar-con-wavs-vectorialmente-en-python/
> )
>
> Tengo pendiente investigar la performance en tiempo real de este tipo
> de cosas en python, incluso creo que tengo algo por ahi con el
> algoritmo de overlap-save implementado.
>
> Para la parte de obtener el sonido del microfono, para algo muy básico
> podes mirar pygame[1] (que tiene bindings a la biblioteca SDL[2]),
> sino tenes pyalsa (bindings para alsa) y pyjack (bindings para jack)
>
> [1] http://www.pygame.org/news.html
> [2] http://en.wikipedia.org/wiki/Simple_DirectMedia_Layer
> [3] http://bitglue.com/pyalsa
> [4] http://sourceforge.net/projects/py-jack/
> --
> Hernán
> http://h.ordia.com.ar
> GnuPG: 0xEE8A3FE9
> _______________________________________________
> ____ _  _ ___  _   _ ____ ___  ___
> |___  \/  |__]  \_/  |___   /  |__]
> |___ _/\_ |      |   |___  /__ |
>
> Expyezp mailing list
> [email protected]
> http://lists.slow.tk/listinfo.cgi/expyezp-slow.tk
>
_______________________________________________
____ _  _ ___  _   _ ____ ___  ___
|___  \/  |__]  \_/  |___   /  |__]
|___ _/\_ |      |   |___  /__ |

Expyezp mailing list
[email protected]
http://lists.slow.tk/listinfo.cgi/expyezp-slow.tk

Responder a