2

I'd like to set up audio on my Arch Linux system so that multiple programs can access my sound card and emit audio at a time.

Unfortunately, the asoundrc file confuses me in its syntax, presently I have this file:

cm.!spdif {
     type hw
     card 1
     device 0
}

pcm.!default {
     type plug
     slave {
           pcm "plug:dmix" # this is a line is based on https://bbs.archlinux.org/viewtopic.php?id=95582
           # I have also tried pcm "dmix", based on the thread. It failed to get multiple sound processes running simultaneously. 
     }
}

and while one program at a time can emit sound, whenever I try to run audio in another program none is emitted, like running:

speaker-test -c 2

emits no sound when another program is accessing my sound card. It's irritating as I frequently pause audio-emitting programs and start others and my present situation won't let me.

Here is the output of lspci | grep -i audio:

00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06)
00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)

So my question is, "How can I set this up in a nice, simple and automated way? Is there a program I can install that will set up the audio without a problem?"

  • You have to get a soundcard which supports hardware mixing of multiple channels. Or use any software mixing daemon, like esd or pulseaudio. – Ipor Sircer Nov 30 '17 at 7:59
  • My sound card has supported multiple programs trying to use it on other distros and in the past on this Arch system so I know it can. – BH2017 Nov 30 '17 at 9:48
4

There is a nice, simple, and automated way: Just make sure all programs use plughw instead of hw when they specify the audio device they want. That will put an automatically generated dmix in front of the real hw device.

To make this the default, your .asoundrc file should look like:

pcm.!default "plughw:2,0"
ctl.!default "plughw:2,0"

with the correct numbers identifying the soundcard you want (see e.g. aplay -l).

Edit

Yes, the numers are card and device in that order. You can add a third subdevice number if there's more than one subdevice (plughw:2,0,1).

  • 1
    What do 2 and 0 correspond to in aplay -l output? Card number, device number in that order per chance? – BH2017 Nov 30 '17 at 9:57
  • Aha it seems like I was right as to the order as it's working now. Thanks! – BH2017 Nov 30 '17 at 9:58
  • One problem, is how do I just the volume now? I'm using i3 the only way I can adjust it is using alsamixer which won't work now, it gives ALSA lib control.c:1262:(snd_ctl_open_conf) Invalid type for CTL default definition cannot open mixer: Invalid argument – BH2017 Dec 3 '17 at 6:39
  • It seems like this doesn't allow multiple programs to access the sound card, it just means that after a program has been paused or closed it's easier for the next program to access the sound card. At the moment I have RS's NXT Client, SuperTuxKart, both muted and whenever I open VLC I get an audio error I got before I tried this solution -- imgur.com/nLH6ah7.png. When these games aren't running VLC runs fine, without this error. This solution lead to me asking this question on the Gentoo forum -- forums.gentoo.org/viewtopic-p-8149962.html#8149962. – BH2017 Dec 3 '17 at 9:24
  • Actually it does work, but only on Arch, on Gentoo with the same packages it doesn't. Oh well, answer still deserves the acceptance. – BH2017 Dec 4 '17 at 18:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.