I did some experiments about using audio output on Raspberry Pi. This is the note of what I did.
First of all
I haven’t completed my work yet. So I can’t share any sample codes. This article is just a note about how to investigate the audio output on Raspberry Pi.
Background
I wanted to make my own assistant controlled by voice interface for a long. Then I happened to get a PlayStation Eye. So I thought it was a good time to do it.
However, it wasn’t more straightforward than I thought. It didn’t work just by plugging the USB cable into Raspberry Pi. The problem is that the following test command didn't work.
speaker-test -c2 -twav -l3 -D plughw:1,0
I needed to investigate the settings of its audio.
What I did
First of all, I thought the Raspberry Pi didn’t detect the PlayStation Eye as a device. So I checked the connected device data using the command.
$ cat /proc/asound/cards
0 [Headphones ]: bcm2835_headphonbcm2835 Headphones - bcm2835 Headphones
bcm2835 Headphones
1 [vc4hdmi ]: vc4-hdmi - vc4-hdmi
vc4-hdmi
2 [CameraB404271 ]: USB-Audio - USB Camera-B4.04.27.1
OmniVision Technologies, Inc. USB Camera-B4.04.27.1 at usb-3f980000.usb-1.3, hi
The command cat /proc/asound/cards
is also used to display a list of available audio devices (sound cards) on a Linux system. This command provides detailed information on the audio devices installed in or connected to the system.
Then the CameraB404271
was my PlayStation Eye. Also, I checked the audio devices using the following command as well.
$ aplay -L
default
Playback/recording through the PulseAudio sound server
null
Discard all samples (playback) or generate zero samples (capture)
jack
JACK Audio Connection Kit
pulse
PulseAudio Sound Server
...
usbstream:CARD=CameraB404271
USB Camera-B4.04.27.1
USB Stream Output
The aplay -L
command is used to display information about ALSA (Advanced Linux Sound Architecture) sound cards and audio devices. aplay
is part of the ALSA utility and provides a variety of sound playback-related information related to sound playback.
Based on the information that I got at the moment, my PlayStation Eye was detected as an audio device by Raspberry Pi properly. Then I started to get suspicious of the driver. I checked the audio driver with the following command.
cat /proc/asound/modules
0 snd_bcm2835
1 (efault)
2 snd_usb_audio
It said there was a driver for USB audio. So it might not go well with PlayStation Eye. So I bought a USB audio adapter which is commonly used and tested the audio with it. I attached the link to what I bought below.
I checked the audio devices and drivers with the same command as before.
cat /proc/asound/cards
0 [Headphones ]: bcm2835_headphonbcm2835 Headphones - bcm2835 Headphones
bcm2835 Headphones
1 [Device ]: USB-Audio - USB PnP Sound Device
C-Media Electronics Inc. USB PnP Sound Device at usb-3f980000.usb-1.1.3, full s
2 [vc4hdmi ]: vc4-hdmi - vc4-hdmi
vc4-hdmi
aplay -L
default
Playback/recording through the PulseAudio sound server
null
Discard all samples (playback) or generate zero samples (capture)
jack
JACK Audio Connection Kit
...
usbstream:CARD=Device
USB PnP Sound Device
USB Stream Output
...
cat /proc/asound/modules
0 snd_bcm2835
1 snd_usb_audio
2 (efault)
Judging from the outputs, the same driver was used as PlayStation Eye, and the audio adapter was detected as an audio device properly. Then I tried the speaker test command. But I couldn’t hear anything. So I thought this problem came from anything other than devices and drivers because the adapter was used widely and shouldn't have been needed to configure.
At the same time, I got a huge clue to solve this problem, which is that the adapter was flashing when I ran the speaker test command. I didn’t know the specifications before I bought it but luckily the flashing feedback gave me confirmation that it was working. So I thought the volume might be too small to listen.
I increased the volume with alsamixer
command like the following link.
Then I run the speaker test command again. Finally, I could hear the sounds from the adapter and the PlayStation Eye. The cause was quite simple and easy but it took a few weeks to solve.
That’s it!