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
Garbit
  • 225
  • 1
  • 3
  • 7
  • 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. – RPiAwesomeness Feb 25 '14 at 17:57
  • Yep I've added an answer to this issue, see below for the resolution – Garbit Feb 26 '14 at 10:29

2 Answers2

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
Jivings
  • 22,538
  • 11
  • 90
  • 139
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
Garbit
  • 225
  • 1
  • 3
  • 7