Cannot play music files or get alsamixer to work on my RPi2

Raspberry Pi 2

Cannot play music files or get alsamixer to work on my RPi2

Postby mags » Sat Jan 16, 2016 1:13 pm

I am getting a number of errors when I try to play a sound file using sox (/usr/bin/play) on my RPi2. I have alsa-utils installed but what am I missing?
$this->bbcode_second_pass_code('', '% alsamixer
cannot open mixer: No such file or directory
')

And
$this->bbcode_second_pass_code('', '% aplay -l
aplay: device_list:268: no soundcards found...
')

So playing fails
$this->bbcode_second_pass_code('', '% play 01-Loading_the_Weapon.mp3
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4292:(_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:4292:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4771:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default
[1] 492 floating point exception (core dumped) play 01-Loading_the_Weapon.mp3')
mags
 
Posts: 6
Joined: Sat Nov 07, 2015 10:10 pm

Re: Cannot play music files or get alsamixer to work on my R

Postby graysky » Sat Jan 16, 2016 1:50 pm

Did you add your user to the audio group?
graysky
Developer
 
Posts: 1728
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: Cannot play music files or get alsamixer to work on my R

Postby mags » Sat Jan 16, 2016 2:10 pm

Thank you! That was my problem. Now can I play but the audio always comes out of the HDMI. How can I make it come out the analog output?
$this->bbcode_second_pass_code('', '% aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0')
mags
 
Posts: 6
Joined: Sat Nov 07, 2015 10:10 pm

Re: Cannot play music files or get alsamixer to work on my R

Postby graysky » Sat Jan 16, 2016 2:31 pm

$this->bbcode_second_pass_code('', 'AUDIODEV=hw:0,0 play 01-Loading_the_Weapon.mp3')

Does that still output through the HDMI or speakers? If it's still HDMI then I am out of ideas. Perhaps someone else will know.
graysky
Developer
 
Posts: 1728
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: Cannot play music files or get alsamixer to work on my R

Postby graysky » Sat Jan 16, 2016 2:58 pm

I can't get this to work my my RPi2 either.

1) I know the speakers work because I can have kodi output to them or to the internal speakers (HDMI).
2) I can do the following from the CLI and get white noise to play through the TV (again HDMI) but not through the speakers connected to the 3.5mm jack.

$this->bbcode_second_pass_code('', 'play -n -c 2 synth 10:00 whitenoise')

Setting AUDIODEV=hw:0,0 or hw0,1 has no effect. Anyone?
$this->bbcode_second_pass_code('', 'AUDIODEV=hw0,0 play -n -c 2 synth 10:00 whitenoise')
graysky
Developer
 
Posts: 1728
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: Cannot play music files or get alsamixer to work on my R

Postby graysky » Sat Jan 16, 2016 4:09 pm

One solution is to use amixer to setup the output: https://www.raspberrypi.org/documentati ... -config.md

This works on my RPi2 for a white noise generator and separate output over HDMI works. Just be the user running amixer and play or whatever is in the audio group:
$this->bbcode_second_pass_code('', '% amixer cset numid=3 2
numid=3,iface=MIXER,name='PCM Playback Route'
; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
: values=2

% play -n -c 2 synth 10:05 whitenoise
play WARN alsa: can't encode 0-bit Unknown or not applicable

File Size: 0
Encoding: n/a
Channels: 1 @ 32-bit
Samplerate: 48000Hz
Replaygain: off
Duration: unknown

In:0.00% 00:01:01.44 [00:00:00.00] Out:2.95M [!=====|=====!] Hd:0.0 Clip:0')
graysky
Developer
 
Posts: 1728
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000


Return to Broadcom

Who is online

Users browsing this forum: No registered users and 7 guests