Page 1 of 1

Audio in terminal - Debian

Posted: Tue May 15, 2012 8:07 pm
by Chrunchstick
Hello all,
I have been trying to get audio to work in my Pi. In the GUI everything works now by using:

1. Boot
2. Login
3. run "sudo modprobe snd_bcm2835"
4. startx

I can play music files and sound just works great.
Now my problem. I want to play a music file from the terminal without starting X. I've tried multiple terminal music players (xmms2, mplayer, etc.) and it does not work even when I executed "sudo modprobe snd_bcm2835" right on boot.
On Mplayer i get the following error:

Code: Select all

christiaan@raspberrypi:~$ mplayer Desktop/Hit\ the\ Floor.mp3 
MPlayer 1.0rc3-4.4.4 (C) 2000-2009 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing Desktop/Hit the Floor.mp3.
Audio only file format detected.
Clip info:
 Title: Hit the Floor                 
 Artist: Linkin Park                   
 Album: Meteora                       
 Year: 2003
 Comment:                             
 Track: 5
 Genre: Other
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 320.0 kbit/22.68% (ratio: 40000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
socket(): Address family not supported by protocol
waitpid(): No child processes
AO: [pulse] Init failed: Internal error
Failed to initialize audio driver 'pulse'
[AO_ALSA] alsa-lib: confmisc.c:768:(parse_card) cannot find card '0'
[AO_ALSA] alsa-lib: conf.c:4170:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
[AO_ALSA] alsa-lib: confmisc.c:392:(snd_func_concat) error evaluating strings
[AO_ALSA] alsa-lib: conf.c:4170:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
[AO_ALSA] alsa-lib: confmisc.c:1251:(snd_func_refer) error evaluating name
[AO_ALSA] alsa-lib: conf.c:4170:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[AO_ALSA] alsa-lib: conf.c:4649:(snd_config_expand) Evaluate error: No such file or directory
[AO_ALSA] alsa-lib: pcm.c:2190:(snd_pcm_open_noupdate) Unknown PCM default
[AO_ALSA] Playback open error: No such file or directory
Failed to initialize audio driver 'alsa'
[AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le
[AO SDL] using aalib audio driver.
[AO SDL] Unable to open audio: No available audio device
Failed to initialize audio driver 'sdl:aalib'
Could not open/initialize audio device -> no sound.
Audio: no sound
Video: no video


Exiting... (End of file)
It does not matter if I try to play a other music format.
Is there any way I CAN play music files directly form terminal?

Thank you in advance.

Chrunchstick

Re: Audio in terminal - Debian

Posted: Sun May 20, 2012 5:31 pm
by marcelh18
Hi :)
For playing music in console you should install a console audio player. I am currently using MOP.
Also keep in mind that sound driver should be loaded before you start the player.
For that, just type "sudo modprobe snd_bcm2835".

Best Regards,
Marcel

Re: Audio in terminal - Debian

Posted: Sun May 20, 2012 6:53 pm
by Chrunchstick
marcelh18 wrote:Hi :)
For playing music in console you should install a console audio player.


Mplayer is also a console player. I have tried about 6 console players. They all do not work.

Re: Audio in terminal - Debian

Posted: Sun May 20, 2012 7:10 pm
by bredman
Have you tried the tests in the troubleshooting wiki?
http://elinux.org/R-Pi_Troubleshooting#Sound

Re: Audio in terminal - Debian

Posted: Sun May 20, 2012 7:49 pm
by marcelh18
Chrunchstick wrote:
marcelh18 wrote:Hi :)
For playing music in console you should install a console audio player.


Mplayer is also a console player. I have tried about 6 console players. They all do not work.
From your error log, it seems that the sound driver is not loaded. Try "lsmod" and reply the result here.
P.S. The player i use is MOC, not MOP. I misstyped in the previous post.

Re: Audio in terminal - Debian

Posted: Mon May 21, 2012 8:59 am
by peteshew
I have added snd_bcm2835 to the file /etc/modules so that the module gets loaded automatically. I rarely use anything other than SSH at the moment.

I have found mplayer plays for a short while (from a second to up to half a minute) and then stops playing although mplayer is still going.

I installed MPD and MPC which seems to work more reliably e.g. for streaming internet radio.

I installed shairport to act as a remote 'speaker' for iTunes. This runs for maybe ten minutes before sound stops coming out with no error or failure messages.

Re: Audio in terminal - Debian

Posted: Mon May 21, 2012 4:32 pm
by Chrunchstick

Code: Select all

christiaan@raspberrypi:~$ lsmod
Module                  Size  Used by
bnep                    7912  2 
rfcomm                 25240  0 
bluetooth             118996  10 bnep,rfcomm
fuse                   49036  1 
snd_bcm2835            15388  0 
snd_pcm                49240  1 snd_bcm2835
snd_seq                35080  0 
snd_timer              13560  2 snd_pcm,snd_seq
snd_seq_device          3684  1 snd_seq
snd                    31624  5 snd_bcm2835,snd_pcm,snd_seq,snd_timer,snd_seq_device
snd_page_alloc          2660  1 snd_pcm
snd_bcm2835 seems to be loaded.

Re: Audio in terminal - Debian

Posted: Tue May 22, 2012 6:23 am
by paaland
omxplayer will play both music and videos accelerated via OpenMax and use the GPU. Prefered player to use both in console and X.

mpd and mpc also works for audio. I use it for webradio myself. There is an excellent iPhone app for controlling it as well.

Re: Audio in terminal - Debian

Posted: Tue May 22, 2012 9:23 am
by Chrunchstick
paaland wrote:omxplayer will play both music and videos accelerated via OpenMax and use the GPU. Prefered player to use both in console and X.

mpd and mpc also works for audio. I use it for webradio myself. There is an excellent iPhone app for controlling it as well.
As I said, the problem is not mplayer because non of the players works.
So omxplayer also would not work.

Re: Audio in terminal - Debian

Posted: Tue May 22, 2012 5:50 pm
by Steady_Bear
What are you using to play music under X?
Does mplayer work under X and not the terminal?

What happens when you run alsamixer (assuming it's installed - not sure what mixer kids use these days ;) )? Both under X and a pre-X terminal.

What is the last block of output from dmesg after modprobeing the sound driver?
Run dmesg (have a quick read to spot anything looking wrong), note the number of the last entry, modprobe your driver, run dmesg again and note all the new comments.

Re: Audio in terminal - Debian

Posted: Thu May 24, 2012 2:25 am
by Dendennis
omxplayer plays mp3's perfectly well for me, mplayer only plays a few seconds no matter what.

Re: Audio in terminal - Debian

Posted: Thu Jun 07, 2012 1:45 pm
by maggocnx
I also had the problem with

Code: Select all

 cannot find card '0' 
for audio playback. After some time i figured out that sound wasn't working cause i was connected with SSH.

Solved the problem with

Code: Select all

sudo chmod 777 /dev/snd/*
Now mpd and shairport are working quite ok.

Re: Audio in terminal - Debian

Posted: Thu Aug 09, 2012 1:11 pm
by boogiefer
@Chrunchstick

Did you fixed this problem?

Re: Audio in terminal - Debian

Posted: Thu Aug 09, 2012 1:45 pm
by boogiefer
hi Chrunchstick,

I have the proble same to you,

I found this http://linuxindetails.wordpress.com/201 ... processes/

it's realy useful.

Re: Audio in terminal - Debian

Posted: Thu Sep 19, 2013 11:09 am
by Denex
Instead of calling

Code: Select all

sudo chmod 777 /dev/snd/*
on every boot you can write following udev rule

Code: Select all

KERNEL=="controlC0", SUBSYSTEM=="sound", MODE="0666"
KERNEL=="pcmC0D0p", SUBSYSTEM=="sound", MODE="0666"
And place it in file /etc/udev/rules.d/99-my_sound.rules
Now udev would apply 0666 permissions

Re: Audio in terminal - Debian

Posted: Tue Sep 09, 2014 8:36 am
by lordvlad
I had the same issue of
cannot find card '0'
issue because i tried to play something from a who wasn't on the 'audio' group.

Code: Select all

usermod -a -G audio <usr>
and an logout - login solved it for me without messing with the system.