6

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
4
  • Please fix error codes output. It's quite difficult to read those. Commented Dec 10, 2012 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
    Commented Feb 18, 2013 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. Commented Feb 25, 2014 at 17:57
  • Yep I've added an answer to this issue, see below for the resolution
    – Garbit
    Commented Feb 26, 2014 at 10:29

2 Answers 2

1

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
2
  • 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
    Commented Nov 20, 2012 at 11:43
  • try a better audio card then. Commented Feb 14, 2014 at 14:41
0

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
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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