Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

aplay only works as root on Raspberry Pi

Writer Matthew Barrera

This is a Raspberry Pi 3 B+, running pretty vanilla Raspbian 10. aplay /usr/share/sounds/alsa/Front_Center.wav doesn't work as user pi, member of group audio, but does work with sudo as root. I'd like playback to happen through the 3.5mm headphone jack.

Two important clues which make me think the solution is obvious but I'm not clued in on Linux audio to figure it out:

  1. This works fine if I boot the Pi connected to a display and try playing from the GUI. It fails when I run it headless and try to play over ssh.
  2. The different outputs of amixer vs sudo amixer, quoted below.
$ amixer
Simple mixer control 'Master',0 Capabilities: pvolume pswitch pswitch-joined Playback channels: Front Left - Front Right Limits: Playback 0 - 65536 Mono: Front Left: Playback 65536 [100%] [on] Front Right: Playback 65536 [100%] [on]
Simple mixer control 'Capture',0 Capabilities: cvolume cvolume-joined cswitch cswitch-joined Capture channels: Mono Limits: Capture 0 - 65536 Mono: Capture 3 [0%] [on]
$ sudo amixer
Simple mixer control 'Headphone',0 Capabilities: pvolume pvolume-joined pswitch pswitch-joined Playback channels: Mono Limits: Playback -10239 - 400 Mono: Playback 400 [100%] [4.00dB] [on]
$ 

What am I missing? I'm looking for a fix that will change the default behaviour for all programs, not just amixer. Thanks!

1

1 Answer

I just came across some Forums that removing the "~/.asoundrc" helped solving the issue you can do the same by

sudo rm ~/.asoundrc

and also check if the user is added to audio group if not you can do that by

sudo adduser "username" audio

Or the simple solution could be using omxplayer or mpv player

omxplayer test.wav

Note: You need to install omxplayer manually if you are on a lite version of raspbian OS you can install it with the following command

sudo apt-get install omxplayer
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy