Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I've got a USB sound card which I'm trying to record from using the standard pyaudio tutorial for recording however I get the following (below). Frustratingly this script actually works on my mac and I can't understand what I have to do in order to get this working on the pi.

> ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition
> 'cards.BRCM bcm2835 AL.pcm.front.0:CARD=0' ALSA lib
> conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned
> error: No such file or directory ALSA lib
> conf.c:4720:(snd_config_expand) Evaluate error: No such file or
> directory ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> front ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> cards.pcm.rear ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> cards.pcm.center_lfe ALSA lib pcm.c:2217:(snd_pcm_open_noupdate)
> Unknown PCM cards.pcm.side ALSA lib confmisc.c:1286:(snd_func_refer)
> Unable to find definition 'cards.BRCM bcm2835
> AL.pcm.surround40.0:CARD=0' ALSA lib
> conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned
> error: No such file or directory ALSA lib
> conf.c:4720:(snd_config_expand) Evaluate error: No such file or
> directory ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> surround40 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find
> definition 'cards.BRCM bcm2835 AL.pcm.surround51.0:CARD=0' ALSA lib
> conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned
> error: No such file or directory ALSA lib
> conf.c:4720:(snd_config_expand) Evaluate error: No such file or
> directory ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> surround41 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find
> definition 'cards.BRCM bcm2835 AL.pcm.surround51.0:CARD=0' ALSA lib
> conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned
> error: No such file or directory ALSA lib
> conf.c:4720:(snd_config_expand) Evaluate error: No such file or
> directory ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> surround50 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find
> definition 'cards.BRCM bcm2835 AL.pcm.surround51.0:CARD=0' ALSA lib
> conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned
> error: No such file or directory ALSA lib
> conf.c:4720:(snd_config_expand) Evaluate error: No such file or
> directory ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> surround51 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find
> definition 'cards.BRCM bcm2835 AL.pcm.surround71.0:CARD=0' ALSA lib
> conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned
> error: No such file or directory ALSA lib
> conf.c:4720:(snd_config_expand) Evaluate error: No such file or
> directory ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> surround71 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find
> definition 'cards.BRCM bcm2835
> AL.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib
> conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned
> error: No such file or directory ALSA lib
> conf.c:4720:(snd_config_expand) Evaluate error: No such file or
> directory ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> iec958 ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find
> definition 'cards.BRCM bcm2835
> AL.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib
> conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned
> error: No such file or directory ALSA lib
> conf.c:4720:(snd_config_expand) Evaluate error: No such file or
> directory ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> spdif ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find
> definition 'cards.BRCM bcm2835
> AL.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib
> conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned
> error: No such file or directory ALSA lib
> conf.c:4720:(snd_config_expand) Evaluate error: No such file or
> directory ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> spdif ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> cards.pcm.hdmi ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> cards.pcm.hdmi ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM
> cards.pcm.modem ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown
> PCM cards.pcm.modem ALSA lib pcm.c:2217:(snd_pcm_open_noupdate)
> Unknown PCM cards.pcm.phoneline ALSA lib
> pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
> ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports
> only playback stream ALSA lib
> pcm_direct.c:877:(snd1_pcm_direct_initialize_slave) slave plugin does
> not support mmap interleaved or mmap noninterleaved access ALSA lib
> pcm_dmix.c:1030:(snd_pcm_dmix_open) unable to initialize slave Cannot
> connect to server socket err = No such file or directory Cannot
> connect to server request channel jack server is not running or cannot
> be started Expression 'r' failed in
> 'src/hostapi/alsa/pa_linux_alsa.c', line: 2018 Expression
> 'PaAlsaStreamComponent_FinishConfigure( &self->capture,
> hwParamsCapture, inParams, self->primeBuffers, realSr, inputLatency )'
> failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2655 Expression
> 'PaAlsaStream_Configure( stream, inputParameters, outputParameters,
> sampleRate, framesPerBuffer, &inputLatency, &outputLatency,
> &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
> line: 2767 Traceback (most recent call last):   File "hello-world.py",
> line 17, in <module>
>     frames_per_buffer = chunk)   File "/usr/lib/pymodules/python2.7/pyaudio.py", line 714, in open
>     stream = Stream(self, *args, **kwargs)   File "/usr/lib/pymodules/python2.7/pyaudio.py", line 396, in __init__
>     self._stream = pa.open(**arguments) IOError: [Errno Unanticipated host error] -9999

edit **

Although I'm still receiving those errors I am able to record from the mic and also play back through the audio out. I found that lowering the number of chunks to 256 and also removed a channel in my pyaudio script worked. I also found that my usb sound card plugged into my usb hub plugged into my pi actually caused the pi to throw I/O exceptions every now probably because of the round about way of connecting the sound card. Therefore I've added a try catch block around my read code and just skip over lost samples.

CHUNK = 256
FORMAT = pyaudio.paInt16
SHORT_NORMALIZE = (1.0/(2**15)) #(1.0/32768.0)
CHANNELS = 1
RATE = 44100
RECORD_SECONDS = 5
share|improve this question
    
Please fix error codes output. It's quite difficult to read those. –  codewarrior Dec 10 '12 at 14:12
    
how can we tell you without seeing the code you are trying to execute? before you play with pyaudio, I suggest you make your 'aplay' and 'arecord' work by figuring the right hardware addresses for recording and playing. –  abolotnov Feb 18 '13 at 20:06
    
Have you resolved this issue? If so, could you mark an answer as such or create a self-answer and mark it. We are trying to get the site Q:A up and this question looks to be resolved in the comments in the one answer. –  RPi_Awesomeness Feb 25 at 17:57
    
Yep I've added an answer to this issue, see below for the resolution –  Garbit Feb 26 at 10:29

2 Answers 2

It doesn't look as if alsa can find the device. Try manually inserting the module and running your script again.

sudo modprobe snd_bcm2835
share|improve this answer
    
I've ran that however I found that my sampling was too large for the pi to process. So I still get all that stuff in console but it does record and playback the correct audio. –  Garbit Nov 20 '12 at 11:43
    
try a better audio card then. –  Sufiyan Ghori Feb 14 at 14:41
up vote 0 down vote accepted

I found that lowering the number of chunks to 256 and also removed a channel in my pyaudio script worked. I also found that my usb sound card plugged into my usb hub plugged into my pi actually caused the pi to throw I/O exceptions every now and then, probably because of the unreliable connection between the pi and the sound card. Therefore I've added a try catch block around my read code and just skip over lost samples.

CHUNK = 256
FORMAT = pyaudio.paInt16
SHORT_NORMALIZE = (1.0/(2**15)) #(1.0/32768.0)
CHANNELS = 1
RATE = 44100
RECORD_SECONDS = 5
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.