[SciPy-User] parsing a wave file

Friedrich Romstedt friedrichromstedt@gmail....
Fri Feb 24 07:12:39 CST 2012

Am 24. Februar 2012 12:26 schrieb David Hutto <smokefloat@gmail.com>:
> On Thu, Feb 23, 2012 at 9:08 AM, Friedrich Romstedt
>> Sorry for the probably dumb question, but where does "Sndfile" originate from?
> An online example.


>> A quick search in the Python 2.6.5 docs
> I'm using 2.7.2
>> and in the online scipy docs yields nothing.
> It was a .dll to access functions from I believe.

ok, so the question wasn't that dumb it seems :-)

>> I've made positive experience with using the wave module from the standard library. I wrote a module (part of a larger sound analysis suite) to
> I'd like to see that, or any quicker ways there might be of having the
> values of the device immediately, which I'm getting around to now,
> instead of having to wait for the wav file.

Alright, I'll send the file attached.  Unchanged, as I don't know what
you specifically will need.  The inportant function is the
WavfileModel.read() method.  Adapt it to whatever you need.  It is
called a model because it is part of a model–view–controller

>> For the scipy.io.wavfile module, that should work too, although I don't know if it already separates the channels or not—I never used it so far.
> I changed it to
> import scipy.io.wavfile as wv
>        for array_val in wv.read(r'c:\Users\david\test01.wav')[1]:
>                print array_val[0],array_val[1]

FWIW, was there any important outcome of that alteration? :-)

I realise the docs on that file I'm sending attached are not quite up
to date in some detail questions.  You will see yourself.  As I said,
treat the file as public domain and don't let us bother ourselves with
licensing questions.  The file is of course by me.

For immediate recording, I can name:

pygame – a Library for game programming, which can read many file
formats, but is not easy to compile, and most notably you have access
to the frames AFAIK only for a subset of the files (e.g. ogg vorbis
IIRC).  I would expect that it can also record directly, but I'm not
sure.  Check yourself: http://www.pygame.org/

pyaudio – some "alpha" software for recording and playing back
directly from and to the sound device, I used it once to playback some
sounds.  http://people.csail.mit.edu/hubert/pyaudio/

One warning: If you're dealing with Tkinter, make sure you don't call
back into Tkinter methods from the playback or recording threaad,
assumed you're using multithreading.  At least on OS X I found the
application become really unstable by this, meaning it might hang
unexpected and unreproducibly.  It's really nasty.  Use some
messanging system to some Tkinter polling thread.  I can give more
details if you need them.  The "Tkinter" thread would be that one that
imported Tkinter.

Have fun!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wavfile.py
Type: application/octet-stream
Size: 5113 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20120224/79320694/attachment.obj 

More information about the SciPy-User mailing list