You are not logged in.
After two days of searching the web, reading manuals, typing and constant rebooting, I ended up with a configuration for ALSA that works fine 95% of the time. Right now I am listening to 5.1 surround sound (through upmixing) from any app I want (flash not installed, so not tested). I am writing it here 'cause I didn't find this answer to any other forum and the solution on Archwiki didn't work, so it might help a lot of people. The following .asoundrc is a slightly modified version of a .asoundrc file that could be found on alsa.opensrc.org before it went down (found it on wayback machine). Here it is:
pcm.card0 {
type hw
card 0 #change this to our device
device 0 #change this to our device
# mmap_emulation true
}
pcm.dmix0 {
type dmix
ipc_key 34521
slave {
pcm "hw:0,0" #change this to your device
channels 6
}
}
pcm.dsnoop0 {
type dsnoop
ipc_key 34523
slave {
pcm "hw:0,0" #change this to your device
}
}
pcm.asym0 {
type asym
playback.pcm "dmix0"
capture.pcm "dsnoop0"
}
pcm.pasym0 {
type plug
slave.pcm "asym0"
}
# 'dsp0' is espected by OSS emulation etc.
pcm.dsp0 {
type plug
slave.pcm "asym0"
}
ctl.dsp0 {
type hw
card 0 #change this to our device
}
pcm.!default {
type plug
slave.pcm "asym0"
}
ctl.!default {
type hw
card 0 #change this to your device
}
pcm.upmix51 {
type upmix
slave.pcm "asym0"
delay 15
channels 6
}
pcm.!default "plug:upmix51"This will allow for both input and output mixing, togther with 5.1 sound. I think it can be summarized to 5 or 6 lines but my brain is too bloated with all the linux audio crap right now to even think about it..
In some cases, in KDE, when some phonon based apps like Bangarang or Amarok are the first ones to produce sound after boot, then the sound device is locked and no other app will be able to access it and play anything. If I exit the app, play sth else, eg speakertest -c 6, then everything works fine and I can have any app produce sound (even Amarok and Bangarang). In these wicked circumstances, I noticed that KDE notifies me of some sound devices not working and falling back to some other ones (that do not necessarily have a different name). Also the login sound doesn't play and maybe it is due to this that the notification appears. In any case, after rebooting the whole thing (usually) doesn't repeat.
Another thing with ALSA that mixed things more is that, in case you have a usb webcam plugged in, sometimes its microphone becomes the default device and the above .asoundrc will stop working. To prevent this simply change the order the devices are loaded by putting the following in a file under /etc/modprobe.d:
alias snd-card-0 snd-hda-intel
alias snd-card-1 snd_usb_audio
options snd-card-0 index=0
options snd-hda-intel index=0
options snd-card-1 index=1
options snd_usb_audio index=1(found here http://ramblings.narrabilis.com/alsa-no … boot-time). The aliases are probably not needed.
I am curious to see if this works for anyone else. Also, I don't know how to use alsa-equal with this .asoundrc, so any advice is welcome. (By the way, I never got alsa-equal to work with Amarok).
Last edited by tterranigma (2012-04-12 00:18:59)
Offline
After two days of searching the web
You didn't find my ~/.asoundrc? Strewth, I've posted a link to it a million times. Alright, I'll still a link on the wiki.
the sound device is locked
So, see what state it's in.
cat /proc/asound/card0/pcm0p/sub0/hw_paramsAs shown in my config.
You have to specify the rate, period_size and buffer_size, otherwise some stupid program will do the initial open and set its own weird parameters, and then the other progs have to use those same parameters (or be silent) until the device is closed.
Offline
I did find your .asoundrc but it didn't work for me. Everytime I tried to play sth through a secod app, that app simply crashed. I kept it, however, for future reference.
The second problem, as far as I tested, doesn't have anything to do with not set parameters. I will try to set more though gradually and see if anything changes. To me it seems that the problem is purely KDE related, maybe sth to do with knotify, maybe not.. I am saying for 2 reasoons.
1st because, if I change my .asoundrc on the fly, without a reboot or anything, the normal is to just restart your app, lets say bangarang and it will immediately use the new .asoundrc, right? Yet, if I do this, there are times, especially when setting new parameters, that knotify locks the sound device, and I just receive a device busy error from other apps. I have to kill it and then everything goes back to normal.
2nd because knotify sometimes doesn't play the login sound. Any thoughts in this?
Also, I have very high cpu usage when playing sound through phonon apps. At minimum 20% (bangarang,amarok). VLC on the other hand is at only 5% and below. Any ideas?
Offline
Checked once again your .asoundrc and it does work now. I should have screwed things up back then.
Offline
that app simply crashed
Weird. What was the error message? Try experimenting with the parameters (e.g. buffer_size), because every soundcard is different.
restart your app, lets say bangarang and it will immediately use the new .asoundrc, right?
Yes, but is there another app that has audio open? That app needs to be restarted also.
Another useful debugging command:
# Show programs currently opening ALSA:
# fuser -fv /dev/snd/* /dev/dsp*
Happily for me, I use XFCE rather than KDE. I hear KDE does weird sound-related things.
At minimum 20%
I would guess that phonon is resampling using e.g. samplerate_best.
Offline
Correct about samplerate_best.
Yes, but is there another app that has audio open?
Well, yes and no.. In KDE running fuser (and lsof) shows "kde4" and "kmix", but I doubt these are actually using the device, because, even with software mixing disabled, they are still listed, yet I can still play surround sound with speakertest.
Also, in KDE, I diabled/enabled (on the fly) samplerate_best several times while trying things, without restarting KDE and the results where mixed. The same with your .asoundrc and other configurations. As a conclusion, while in KDE ALWAYS restart it to be sure that the new .asoundrc is used (fastest way ctrl+alt+bksp to kill X).
A question:
Generally, in linux, everything uses ALSA (ok, also OSS) to produce sound. So .asoundrc is always in effect no matter what app we are using, right? However, before even enabling surround sound, with alsaequal installed as the deffault device (as te wiki suggests), the equalizer was used only by apps talking directly to ALSA (eg VLC, speakertest) and was ignored by phonon apps. Any explanation? On the contrary, VLC seems to ignore .asoundrc as far as surround sound and samplrate_best are concerned. What is happening?
In any case, how could I change .asoundrc to make use of alsaequal as the default, together with 5.1 sound and dmixing?
Offline
Correct about samplerate_best.
What, did you find a setting? samplerate_best is overkill - whose ears can notice the difference? It's just wasting CPU power.
running fuser (and lsof) shows "kde4" and "kmix", but I doubt these are actually using the device
2 processes - 1 is not enough? Bizarre.
So .asoundrc is always in effect no matter what app we are using, right?
Not necessarily. Apps can use any PCM name, or make up their own configuration, or go direct to the hardware (if the soundcard device isn't already open).
To really understand what's happening, it's necessary to look at the part of the app's source code that deals with ALSA.
alsaequal as the default
Do your own googling, and experiment ![]()
speaker-test, with its many options, is your best friend when testing ALSA.
You really *don't* want KDE, or anything else, opening sound and potentially messing things up, while you are testing ALSA configurations.
Offline
OK man, fair enough! Thanks!
Offline
When you say it works 95%, does that include recording? I'm having a lot of trouble getting an internal mic to work usably. I haven't really dabbled in the other things like surround sound - sound works, but I think it is using mono.
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline