Linux audio is powerful and flexible, and annoying as heck. When you have no sound it can be as simple as Alsamixer resetting everything to mute when you shutdown (Why? Who the heck knows) to problems caused by device conflicts, and our ever-popular friends* Java and Adobe Flash. Java and Flash need drama in their lives, so they break things to get attention.
If you have sound at startup, and then sound quits sometime during your session, the lsof (“list open files”) command will tell you if a process has hijacked your audio. This example shows Java locking up my audio and not letting it go. First take a look in /dev/snd:
$ ls -l /dev/snd
total 0
drwxr-xr-x 2 root root 60 2011-03-19 05:20 by-path
crw-rw—-+ 1 root audio 116, 7 2011-03-19 05:20 controlC0
crw-rw—-+ 1 root audio 116, 6 2011-03-19 05:20 hwC0D0
crw-rw—-+ 1 root audio 116, 5 2011-03-19 05:20 pcmC0D0c
crw-rw—-+ 1 root audio 116, 4 2011-03-19 08:26 pcmC0D0p
crw-rw—-+ 1 root audio 116, 3 2011-03-19 05:20 pcmC0D1p
crw-rw—-+ 1 root audio 116, 8 2011-03-19 05:20 seq
crw-rw—-+ 1 root audio 116, 2 2011-03-19 05:20 timer
Then run lsof on each one like this:
$ lsof /dev/snd/pcmC0D0p
When you get to the audio device that is in use it looks like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 2009 carla mem CHR 116,6 3665 /dev/snd/pcmC0D0p
java 2009 carla 27u CHR 116,6 0t0 3665 /dev/snd/pcmC0D0p
java 2009 carla 28u CHR 116,6 0t0 3665 /dev/snd/pcmC0D0p
java 2009 carla 29u CHR 116,6 0t0 3665 /dev/snd/pcmC0D0p
java 2009 carla 30u CHR 116,6 0t0 3665 /dev/snd/pcmC0D0p
Aha, I says to myself, Java strikes again. So what’s using Java?
$ ps ax | grep java
2009 ? Sl 0:22 /usr/local/moneydance/jre/bin/java -client -Dinstall4j.jvmDir=/usr/local/moneydance/jre -Dexe4j.moduleName=/usr/local/moneydance/Moneydance -Xmx400m -Di4j.vmov=true -Di4j.vmov=true -Di4j.vmov=true -Di4j.vmov=true -Di4j.vmov=true -classpath /usr/local/moneydance/.install4j/i4jruntime.jar:/usr/local/moneydance/moneydance.jar:/usr/local/moneydance/appsrc.jar:/usr/local/moneydance/jfreechart-1.0.13.jar:/usr/local/moneydance/jcommon-1.0.16.jar:/usr/local/moneydance/tablelayout.jar com.install4j.runtime.Launcher launch Moneydance true false /usr/local/moneydance/error.log /usr/local/moneydance/output.log false true false s_1s3rict.gif true true 529 101 20 20 Arial 0,0,0 8 500 version 2010 20 40 Arial 0,0,0 8 500 -1
Aieee, what an indigestible glob! No wonder it makes trouble. At any rate now I know that Moneydance is gumming up my audio, so I close it and voilá! I have sound again. If you don’t have alsautils installed then by all means hie yourself to your package manager and install it. Then you can run simple and useful sound tests, like this one for testing two stereo speakers:
$ speaker-test -t wav -c 2 -l 2
You will hear a pleasant woman’s voice saying “front left, front right” and hopefully coming out of the correct speakers. -l 2 means run the test twice, then stop.
This is a great example of why I prefer command-line tools. They stay the same so you don’t have to continually re-learn them, and have complete functionality. GUI programmers keep “improving” and changing and abandoning their interfaces, and they rarely support a complete set of command options.
*Not my friends.
Carla, a minor typo above: lsof should be ls -of. Was mindlessly reading from a print-out, following your recipe and ran into an error on that command.
Oops, better to keep ones mouth shut and be thought a fool than to open it and remove all doubt.
I know the feeling….
You know why LMMS is so popular?
Because you dont have to mess with JACK or real time kernels or one of a thousand of other things to get started on Linux.
Heck, whenever someone says they just want to plug in an M-Audio style synth and just play a bit, i send them to LMMS (a bit of an overkill but you can access the great ZynAddSubFX).
I get that its powerful but if rather computer literate people have problems, I think its time to face that powerful is useless if the first step is so high that people give up on it.
Ive had people come at LUGs and tell us that they tried on more than one occassion trying to get JACK or something else to work to finally give up and try again a while later.
Then again, I remember the nightmare of doing audio on Windows about 7-8yrs ago.
OK, did all this, all my speakers front and rear work just fine, the test works perfectly. BUT BUT. What doesn’t work is the internal beeper that should sound at startup, and beep doesn’t make it work. Now, what on earth could that be? Its a new machine I put together by the way.
Computers!
Argh @internal beep speaker! That is a separate mess I have just started to research. For example, my Debian Sid system beeps that sucker for all kinds of events, and I’m trying to figure out how to control that. My beloved Antec cases do not come with beep speakers. There are tiny little coin-size beep speakers that plug directly onto some motherboards. If I ever figure it out I shall surely write it up.
Thanks Segue, I’m glad it helped you.
Dear customer,
The model GA-H55N-USB3 does not have an internal speaker.
Thank you
Oh well, at least we know. And good for gigabyte for coming back to me.
Peter
The PC speaker in Linux is activated by loading the pcspkr module. To check if it’s loaded:
lsmod | grep pcspkr
Unload it if you hate the beeps like I do: modprobe -r pcspkr. To reload it back, use modprobe pcspkr.
Nice article and timely for me, having been fighting with audio on a Deb Testing installation. I’ve bookmarked the article and saved it as a pdf.
There are so many layers involved that it is really difficult to sort out which is which and there are very few really good “explainers” like yourself.