Sound examples not working on Raspberry Pi

I have been trying to run any example in openFrameworks that will get me audio out of the headphone jack. I’m running Arch Linux on Raspberry Pi 3, according to these instructions.

When I try to make the audioOutputExample I get this compile error. Basically a long list of undefined references, like:

RtAudio.cpp:(.text+0x5a0): undefined reference to `snd_card_next'
RtAudio.cpp:(.text+0x5ec): undefined reference to `snd_ctl_open'
RtAudio.cpp:(.text+0x610): undefined reference to `snd_ctl_pcm_next_device'

And many more. I have followed the instructions here to install rtAudio.

Separately, I am able to make the soundPlayerExample successfully, however I can hear no sound. Here is the console output during runtime.

There are warnings, and errors like these:

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4850:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2450:(snd_pcm_open_noupdate) Unknown PCM default
[ error ] ofOpenALSoundPlayer: loadSound(): couldn't generate source for "data/sounds/synth.wav": 40964 AL_INVALID_OPERATION
[warning] ofSoundPlayer: ofSoundUpdate() not implemented on this platform
[ error ] ofOpenALSoundPlayer: play(): couldn't create multiplay stereo sources: 40964 AL_INVALID_OPERATION

And more.

I don’t know if the two issues are related but thought I should raise them together here in case they are linked.

I have been working on this since posting… Here are notes in case it helps someone. Looking at the soundPlayerExample log, it seemed to be missing something related to ALSA. So I did some reading in the guide about ALSA.

Supposedly ALSA should be installed on Arch Linux by default, but the commands from the guide (amixer and alsamixer) weren’t recognized from my console. So I installed the packages mentioned in the guide:

sudo pacman -S alsa-utils
sudo pacman -S alsa-lib
sudo pacman -S alsa-firmware

And now those commands are found. However they both give errors:

$ alsamixer
cannot open mixer: No such File or directory


$ amixer sset Master unmute
amixer: Mixer attach default error: No such file or directory

Also I found that one of the easiest ways to test if things are working is to use the command speaker-test, which came with the ALSA packages. When I run speaker-test, I get the same error as my runtime soundPlayerExample, the one about cannot find card '0', so this is a quicker way to test.

From here I found aplay -l, which appears to be an ALSA util to list available sound cards. The output for me:

aplay: device_list:268: no soundcards found...

Then I found this Sound section of an RPi troubleshooting guide, which explains that for some reason the GPU may have disabled audio. To fix this, add this line to /boot/config.txt and reboot:


Once I did this the soundPlayerExample works! I hear sound, albeit low quality, through my headphones. I’m still working on the audioOutputExample problem.

1 Like