[python-nl] PyObjC Segfault

Dexter a.esselink at gmail.com
Mon Mar 1 23:57:43 CET 2010


Hi,

I want to record some audio on my laptop, but I can't get it to work,
What am I doing wrong here.

Thanks in advance

Dexter.

import ossaudiodev
> import wave
>
>
> SAMPLE_RATE = 8000
> SAMPLE_WIDTH = 2
> BLOCK_TIME = 5
>
>
> mic = ossaudiodev.open('r') # open a mic
> f = wave.open("sound.wav", "w") # open a wave file
>
> mic.setfmt(ossaudiodev.AFMT_S16_LE)
> mic.channels(1)
> mic.speed(SAMPLE_RATE)
>
>
> f.setparams((1, SAMPLE_WIDTH, SAMPLE_RATE, SAMPLE_RATE*BLOCK_TIME, "NONE",
> "NONE")) #(nchannels, sampwidth, framerate, nframes, comptype, compname)
>
> block = mic.read(SAMPLE_RATE*BLOCK_TIME*SAMPLE_WIDTH)
> mic.close()
>
> print set(block)
>
> f.writeframes(block)
> f.close()
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-nl/attachments/20100301/fadd61a1/attachment.html>


More information about the Python-nl mailing list