This applies to many, many distributions and should work regardless of the tools you prefer. I am not going into a great deal of detail to keep it short and easy to read for average users, don’t expect alsa vs oss vs jack vs pipe discussions.

Output options:

There are several options for audio output in Linux. Where windows has kmixer (mixing, lossy) and wasapi (direct control, lossless) linux uses pulseaudio (mixing, lossy) and alsa (direct control, lossless).

The general rule is to have pulseaudio only on when you are not listening to music, this means you can still watch youtube videos and hear notifications from skype at the same time.

But when you are listening to music the aim is to have only one source, your player, having priority control over your sound card.

Running the below in a terminal will list your devices detected by alsa as valid output devices:

Quote:

aplay -l

The output on my machine is:

Quote:

**** List of PLAYBACK Hardware Devices ****

card 0: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]

Subdevices: 1/1

Subdevice #0: subdevice #0

card 0: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]

Subdevices: 1/1

Subdevice #0: subdevice #0

card 1: DAC [UAC1 DAC], device 0: USB Audio [USB Audio]

Subdevices: 0/1

Subdevice #0: subdevice #0

Here you can easily see that card 1, device 0 is my usb sound card. If i was to use HDMI output i would set it to card 0 device 3 or card 0 device 7.

Quote:

Note: Sometimes if you get two HDMI outputs one is actually your DVI output, its a cheap trick hardware OEMs use to add ports. You will have to try both to find out which one is actually your HDMI device.

Testing a device is as simple as using:

aplay -D hw:0,0 test.wav

Where hw:0,0 refers to your hardware detected above with aplay -l.

For Alsa playback applications we provide hardware addresses in the form:

Quote:

hw:card#,device#

So in my case it is:

Quote:

hw:1,0

Setting defaults is the final step. Run the following in a terminal:

Quote:

sudo nano /etc/asound.conf

I suggest cleaning out this entire file so it is blank then putting the below contents in.

Quote:

pcm.!default {
type hw
card 0

device 0
}

ctl.!default {
type hw
card 0

device 0
}

Simply replace the card and device numbers with the ones you found above.

For instance my config reads:

Quote:

pcm.!default {
type hw
card 1

device 0
}

ctl.!default {
type hw
card 1

device 0
}

You are done with alsa!

Turning off pulseaudio:

As of 14.04 the version of pulseaudio used is much easier to disable with only a single line needing to be edited.

Using the command:

sudo nano /etc/pulse/client.conf

Change the autospawn line to read:

autospawn = no

That's it. No joke, you are done. Just restart your machine.

Playback!

Setting up your music player to use alsa.

There are many options out there for playing back bitperfect audio in linux as far as music players go.

Why should someone use PulseAudio at all instead of ALSA's dmix plugin? Does ALSA's mixing also degrade audio quality? if the concern is avoiding any software mixing why is switching between PulseAudio and ALSA better than always using ALSA directly and toggling the dmix plugin? http://www.alsa-project.org/main/index.php/Asoundrc#Software_mixing

I think just a little bit more information and the guide will be even more helpful to beginners.

All of that was left out for the purpose of it not being 30 pages long. I will update it tomorrow with spoiler sections to explain perhaps.

Edit: and about lossy. Anything that is not bit perfect, is by definition lossy as it has lost information. By that reasoning all software mixing is Lossy, the thing we wish to avoid.

Also, as requested. Here is the reasoning behind pulseaudio instead of dmix for instance. Pulseaudio has to be installed anyway. Its not optional, dmix is. Many apps won't even output audio if pulseaudio is not detected as it is their only output method these days. Several video players are guilty of that sadly. I miss the days of plugins and dmix sometimes, but I also see the value of a universal mixer.

There are ways to increase audio quality as well as still use pulseaudio as its entire mixing interface is configured by a single file. The downside of course is still not bit exact audio, but also massive kernel io and CPU limitations. Much like jack.Edited by yay101 - 1/15/14 at 10:07am

Edit: and about lossy. Anything that is not bit perfect, is by definition lossy as it has lost information. By that reasoning all software mixing is Lossy, the thing we wish to avoid.

Ok, I get you, thanks.

Quote:

Also, as requested. Here is the reasoning behind pulseaudio instead of dmix for instance. Pulseaudio has to be installed anyway. Its not optional, dmix is

As a Slackware user I've never had to install it. I'm guessing PulseAudio-by-default distros have all of the media/audio players in their repositories compiled to support it, but again I don't want beginners to have the wrong impression. Even in those PulseAudio-by-default distros I imagine it's possible to get along without it. If you want to assume that the reader's life will be easier the PulseAudio route then it may be prudent to include a list of popular distros that you know rely on PulseAudio more than others rather than this blanket statement.

That's a good point, I may add more information soon. The main problem is Pulseaudio is installed by default on a great majority of prepackaged distros. Even a lot of Arch's packages assume pulseaudio is present, and adding a flag for that on arch would be like 5 lines in a pkgbuild. Laziness I guess.

That a really cool script ronalde, I am going to rewrite this guide very soon with a long and short version with the short version being "mostly" automated. Recent changes to the gnome stack and the release of the next ubuntu and mint builds coming up mean some things will change, and possibly more people will shortly be looking for just this.