Difference between revisions of "Advanced Linux Sound Architecture"

From ArchWiki
Jump to: navigation, search
m (Problems with Availability to Only One User at a Time)
(No sound in Wine)
Line 405: Line 405:
 
   pcm.default pcm.dmixer
 
   pcm.default pcm.dmixer
  
===No sound in Wine===
+
=== No sound in Wine ===
 +
 
 +
If you are on x86_64 machine be sure to have installed lib32 packages in related wine's optional dependencies.
  
 
If winecfg does not even list the Alsa driver, try the alternative bin32-wine-suse package as found in the [http://aur.archlinux.org/packages.php?ID=16531 AUR]. After the installation open winecfg again, the Alsa driver should now be listed and can be chosen; the sound test should work after winecfg is closed and opened once more.
 
If winecfg does not even list the Alsa driver, try the alternative bin32-wine-suse package as found in the [http://aur.archlinux.org/packages.php?ID=16531 AUR]. After the installation open winecfg again, the Alsa driver should now be listed and can be chosen; the sound test should work after winecfg is closed and opened once more.

Revision as of 21:33, 23 December 2010

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Advanced Linux Sound Architecture#)

The Advanced Linux Sound Architecture (ALSA) is a Linux kernel component intended to provide device drivers for sound cards.

Note: For an alternative sound environment, see the Open Sound System page.

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary end

Installation

Kernel drivers

ALSA has been included in the 2.6 kernels and is included in all Arch kernel26* packages. If you build a custom kernel, do not forget to enable the correct ALSA driver.

All necessary modules should be detected and loaded automatically by udev. No special configuration is required unless an ISA card is being used. NEVER use alsaconf if you have a PCI or ISAPNP sound card, as the entries alsaconf adds to the modprobe.conf file might break udev's autodetection.

Userspace utilities

  • Required for native ALSA programs and administration
# pacman -S alsa-utils
  • Recommended if you want to use applications with OSS sound support in combination with dmix:
# pacman -S alsa-oss

All ALSA programs will most likely have alsa-lib as a dependency, pacman will handle this automatically.

dmix

ALSA's Software Mixing System

Note: For ALSA 1.0.9rc2 and higher you don't need to setup dmix. Dmix is enabled as default for soundcards which don't support hardware mixing (from the alsa wiki). If you are still having problems: there are a lot of posts about flash + other programs that use sound. This happens because flash uses the alsa oss emulation instead of real alsa. The fix is easy, just disable oss (almost all programs are converted to alsa these days) by blacklisting the oss module in /etc/rc.conf in the MODULES section: !snd_pcm_oss

Note: dmix reduces the sound quality during mixing more or less noticeably. You should try another solution if this concerns you. (Regarding TeamSpeak; it doesn't support alsa - at least until version 3. Addendum: TeamSpeak 2 does seem to work under ALSA with OSS emulation if started using the aoss script, i.e.: $ aoss TeamSpeak. No matter what, the sound quality will not be top notch.)

Note: You may wish to read this article, Does dmix affect sound quality?

Configuration

Set the default sound card

In Kernel Space

Note: snd-pcsp is no longer in the kernel from at least 2.6.35; the only related module is then pcspkr.'

Telephony-capable modems and snd-pcsp (the internal PC speaker ALSA module) can conflict with the sound card for the default sound card slot. (pcspkr is another, non-ALSA PC speaker module. It will not conflict with ALSA sound cards.) To prevent this, discover your sound card model name with lspci(8) and your ALSA driver module names with ls(1):

$ ls -l /sys/module/snd/holders
total 0
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_ac97_codec -> ../../snd_ac97_codec
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_intel8x0 -> ../../snd_intel8x0
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_intel8x0m -> ../../snd_intel8x0m
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_pcm -> ../../snd_pcm
lrwxrwxrwx 1 root root 0 2009-06-02 23:53 snd_pcsp -> ../../snd_pcsp
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_timer -> ../../snd_timer

Or better (source[1]):

$ cat /proc/asound/modules

Then add the names of your sound card modules to:

Template:File

These entries ensure that the Intel 82801DB-ICH4 sound card will become card 0 and the PC speaker will become card 1. NB: Some modules do not support indexing options eg. snd-hda-intel. If you experience problems on reboot edit /etc/modprobe.d/modprobe.conf to just have the modules.

If you do not want snd-pcsp to load at all you can add the following to:

Template:File

If you want the PC speaker completely disabled, you can additionally add the following to:

Template:File


Note: You will need to unload all your sound modules and reload them for the changes to take effect. It might be easier to reboot. Your choice.

In User Space

This method does not require root permissions, is on a per-user basis, and takes effect as soon as any software has been restarted (like your media player, for example).

Located in Template:Filename is a list of defaults that alsa uses out of the box. These can be overridden in a Template:Filename file. Template:File The 'pcm' options affect which card and device will be used for audio playback. However it is the 'ctl' option affects which card is used by control utilities like alsamixer, amixer, and the like.

To find out which numbers correspond to what audio device, use Template:Codeline.

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: CONEXANT Analog [CONEXANT Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: Conexant Digital [Conexant Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: JamLab [JamLab], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Audio [Altec Lansing XT1 - USB Audio], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Making sure the sound modules are loaded

You can assume that udev will autodetect your sound properly, including the OSS compatibility modules. You can check this with the command

$ lsmod|grep '^snd' | column -t
snd_usb_audio          69696  0 
snd_usb_lib            13504  1 snd_usb_audio
snd_rawmidi            20064  1 snd_usb_lib
snd_hwdep               7044  1 snd_usb_audio
snd_seq_oss            29412  0 
snd_seq_midi_event      6080  1 snd_seq_oss
snd_seq                46220  4 snd_seq_oss,snd_seq_midi_event
snd_seq_device          6796  3 snd_rawmidi,snd_seq_oss,snd_seq
snd_pcm_oss            45216  0 
snd_mixer_oss          15232  1 snd_pcm_oss
snd_intel8x0           27932  0 
snd_ac97_codec         87648  1 snd_intel8x0
snd_ac97_bus            1792  1 snd_ac97_codec
snd_pcm                76296  4 snd_usb_audio,snd_pcm_oss,snd_intel8x0,snd_ac97_codec
snd_timer              19780  2 snd_seq,snd_pcm
snd                    43776  12 snd_usb_audio,snd_rawmidi,snd_hwdep,snd_seq_oss,snd_seq,snd_seq_device,
                                 snd_pcm_oss,snd_mixer_oss,snd_intel8x0,snd_ac97_codec,snd_pcm,snd_timer
snd_page_alloc          7944  2 snd_intel8x0,snd_pcm

If the output looks similar, your sound drivers have been successfully autodetected (note that in this case, snd_intel8x0 and snd_usb_audio are the drivers for the hardware devices). You might also want to check the directory /dev/snd for the right device files:

$ ls -l /dev/snd
total 0
crw-rw----  1 root audio 116,  0 Apr  8 14:17 controlC0
crw-rw----  1 root audio 116, 32 Apr  8 14:17 controlC1
crw-rw----  1 root audio 116, 24 Apr  8 14:17 pcmC0D0c
crw-rw----  1 root audio 116, 16 Apr  8 14:17 pcmC0D0p
crw-rw----  1 root audio 116, 25 Apr  8 14:17 pcmC0D1c
crw-rw----  1 root audio 116, 56 Apr  8 14:17 pcmC1D0c
crw-rw----  1 root audio 116, 48 Apr  8 14:17 pcmC1D0p
crw-rw----  1 root audio 116,  1 Apr  8 14:17 seq
crw-rw----  1 root audio 116, 33 Apr  8 14:17 timer
Note: If requesting help on IRC or the forums, please post the output of the above commands.

If you have at least the devices controlC0 and pcmC0D0p or similar, then your sound modules have been detected and loaded properly.

If this is not the case, your sound modules have not been detected properly. To solve this, you can try loading the modules manually:

  • Locate the module for your soundcard: ALSA Soundcard Matrix The module will be prefixed with 'snd-' (for example: 'snd-via82xx').
  • Load modules:
 # modprobe snd-NAME-OF-MODULE
 # modprobe snd-pcm-oss
  • Check for the device files in /dev/snd (see above) and/or try if alsamixer or amixer have reasonable output.
  • Add snd-NAME-OF-MODULE and snd-pcm-oss to the list of MODULES in Template:Filename to ensure they are loaded next time (make sure snd-NAME-OF-MODULE is before snd-pcm-oss).

Unmute the channels and test

In this section, we assume that you are logged in as root. If you want to perform these steps as an unprivileged user, you have to skip to the next section Setup Permissions first.

  • Unmute Soundcard

The current version of ALSA installs with all channels muted by default, so even if installation completes successfully and all devices are working properly you will hear no sound. You will need to unmute the channels manually. It is recommended to use Template:Codeline to accomplish this. From the alsamixer text ui, the label "MM" below a channel indicates that the channel is muted, and "00" indicates that it is open. Press the 'm' key to toggle MM/00. Use arrow-keys left and right to navigate through the channels and the arrow-keys up and down to adjust the volume. Such channels as Master and PCM and possibly Speaker will need to be unmuted for your sound to be heard.

Note: When using Template:Codeline, be sure to unmute as well as bring volumes up to a specific level in percent, i.e you must use the % sign. Template:Codeline understands the percent sign (%), not numbers. If you use a number (say, 90) then Template:Codeline will take it as 100%, which can harm your speakers.
 # amixer set Master 90% unmute
 # amixer set PCM 85% unmute
  • Now run a test
 # speaker-test -c 2
Note: Some cards need to have digital output muted/turned off in order to hear analog sound. For the Soundblaster Audigy LS mute the IEC958 channel.

If you cannot hear anything, double check your mixer settings, being sure to unmute PCM, MASTER (and some machines such as the IBM Thinkpad have an additional 'SPEAKER' channel) and try the alsaconf utility as root:

# alsaconf

Setup Permissions

To be able to use the sound card as a user, follow these steps:

  • Add your user to the audio group if it is not already available:
# gpasswd -a USERNAME audio
  • Log your user out and back in to ensure the audio group is loaded.

Restore ALSA Mixer settings at startup

# alsactl -f /var/lib/alsa/asound.state store
  • Edit Template:Filename and add Template:Codeline to the list of daemons to start on boot-up. This will store the mixer settings on every shutdown and restore them when you boot.
  • If the mixer settings are not loaded on boot-up, add the following line to Template:Filename:
# alsactl -f /var/lib/alsa/asound.state restore
  • These methods still may not work, or you may prefer to have audio settings for individual users. In this case, run Template:Codeline as a normal user. This will save and restore volume settings on a per user basis. To automate this process, add the respective commands to Template:Filename and Template:Filename, or the correct locations for the shell of your choice.

For zsh, use Template:Filename and Template:Filename.

Getting SPDIF Output

(from gralves from the Gentoo forums)

  • In GNOME Volume Control, under the Options tab, change the IEC958 to PCM. This option can be enabled in the preferences.
  • If you don't have GNOME Volume Control installed,
    • Edit /var/lib/alsa/asound.state. This file is where alsasound stores your mixer settings.
    • Find a line that says: 'IEC958 Playback Switch'. Near it you will find a line saying value:false. Change it to value:true.
    • Now find this line: 'IEC958 Playback AC97-SPSA'. Change its value to 0.
    • Restart ALSA.

Alternative way to enable SPDIF output automatically on login (tested on SoundBlaster Audigy):

 # Use COAX-digital output
 amixer set 'IEC958 Optical' 100 unmute
 amixer set 'Audigy Analog/Digital Output Jack' on

You can see the name of your card's digital output with:

 $ amixer scontrols

System-Wide Equalizer

Using AlsaEqual (provides UI)

Install alsaequal from the AUR.

Note: If you have a x86_64-system and are using a 32bit-flashplugin the sound in flash will not work. Either you have to disable alsaequal or build alsaequal for 32bit.

After installing the package, insert the following into your ALSA configuration file (Template:Filename or Template:Filename):

ctl.equal {
 type equal;
}

pcm.plugequal {
  type equal;
  # Modify the line below if you don't
  # want to use sound card 0.
  #slave.pcm "plughw:0,0";
  #by default we want to play from more sources at time:
  slave.pcm "plug:dmix";
}

#pcm.equal {
  # Or if you want the equalizer to be your
  # default soundcard uncomment the following
  # line and comment the above line.
pcm.!default {
  type plug;
  slave.pcm plugequal;
}

Then Reload your alsa settings (as root).

# /etc/rc.d/alsa restart

not sure if this is really needed - more important is to shut down all applications using ALSA...

And you are ready to change your equalizer using command

$ alsamixer -D equal

Note that configuration file is different for each user (until not specified else) it's saved in $HOME/.alsaequal.bin. so if you want to use AlsaEqual with mpd or another software running under different user, you can configure it using

# su mpd -c 'alsamixer -D equal'

or eg. you can make symlink to your .alsaequal.bin in his home...

Using mbeq

Note: This method requires the use of a ladspa plugin which might use quite a bit of CPU when sound plays. In addition, this was made with stereophonic sound (e.g. headphones) in mind.
  • You will need, in addition to the aforementioned userspace utilities, alsa-plugins.
# pacman -S alsa-plugins
  • Get the ladspa and swh-plugins packages too if you don't already have them.
# pacman -S ladspa swh-plugins
$ vim ~/.asoundrc

Template:File

  • Reload your alsa settings (as root).
# /etc/rc.d/alsa restart
  • You should be good to go (if not, ask in the forum).

Hardware Mixing

Use soundcard that supports hardware mixing: old SoundBlaster Live! series (emu10k1 chip) and new Audigy series (emu10k2 chip) cards are known to work.

The SoundBlaster Live! 5.1 is fairly easy to find and is cheap to buy.

Note: new cheap Audigy SE, Audigy 2 NX, SoundBlaster Live! 24bit and SoundBlaster Live! 7.1 do not support hardware mixing (they use other chips).

99% of motherboards with integrated sound do not support hardware mixing.

An exception is the onboard VIA8237 chip which supports 4-stream hardware mixing. However it does only 3 for some motherboards (the 4th makes no sound), or is just broken. Even if it works, the quality is not good compared to other solutions.

For Arch64 and the 00:1b.0 Audio device: Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 02), and to get sound from Enemy Territory, it works this by setting these:

echo "et.x86 0 0 direct" > /proc/asound/card0/pcm0p/oss
echo "et.x86 0 0 disable" > /proc/asound/card0/pcm0c/oss

Troubleshooting

Problems with Availability to Only One User at a Time

You might find that only one user can use the dmixer at a time. This is probably ok for most, but for those who run mpd as a separate user this poses a problem. When mpd is playing a normal user can't play sounds though the dmixer. While its quite possible to just run mpd under a user's login account, another solution has been found. Adding the line ipc_key_add_uid 0 to the pcm.dmixer block disables this locking. The following is a snippet of the asound.conf, the rest is the same as above.

...
pcm.dmixer {
 type dmix
 ipc_key 1024
 ipc_key_add_uid 0 
 ipc_perm 0666
slave {
...

Random Lack of Sound

If you randomly have no sound on startup, it may be because your system has multiple sound cards, and their order may sometimes change on startup. If this is the case, then change this section of /etc/asound.conf:

ctl.dmixer {
    type hw
    card FOO
}

Replace FOO with the desired audio device, as reported in the /proc/asound/cards file. An example of the file is shown below.

 0 [U0x46d0x9a1    ]: USB-Audio - USB Device 0x46d:0x9a1
                      USB Device 0x46d:0x9a1 at usb-0000:00:12.2-2, high speed
 1 [SB             ]: HDA-Intel - HDA ATI SB
                      HDA ATI SB at 0xf9ff4000 irq 16

Device 0 is the microphone built into a webcam, while device 1 is the integrated sound card. If you've copied the /etc/asound.conf from above as is, alsa will attempt to initialize the microphone as an audio output device, but will fail and you will have no sound. Rather than setting FOO to the number, you set it to the name next to the number, like so:

ctl.dmixer {
    type hw
    card SB
}

To make most programs use Alsa, make sure /etc/libao.conf only contains the following.

default_driver=alsa10

If you use mpd and the configuration tips above don't work for you, try reading this instead.

Specific Program Problems

For other programs who insist on their own audio setup, eg, XMMS or Mplayer, you would need to set their specific options.

For mplayer, open up ~/.mplayer/config (or /etc/mplayer/mplayer.conf for global setting) and add the following line:

ao=alsa

For XMMS/Beep Media Player, go into their options and make sure the sound driver is set to Alsa, not oss.

To do this in XMMS:

  • Open XMMS
    • Options -> preferences.
    • Choose the Alsa output plugin.

For applications which do not provide a ALSA output, you can use aoss from the alsa-oss package. To use aoss, when you run the program, prefix it with aoss, eg:

aoss realplay

pcm.!default{ ... } doesnt work for me anymore. but this does:

 pcm.default pcm.dmixer

No sound in Wine

If you are on x86_64 machine be sure to have installed lib32 packages in related wine's optional dependencies.

If winecfg does not even list the Alsa driver, try the alternative bin32-wine-suse package as found in the AUR. After the installation open winecfg again, the Alsa driver should now be listed and can be chosen; the sound test should work after winecfg is closed and opened once more.

Model Settings

Although Alsa detects your soundcard through the BIOS at times Alsa may not be able to recognize your model type. The soundcard chip can be found in alsamixer (e.g. ALC662) and the model can be set in Template:Filename or Template:Filename. For example:

options snd-hda-intel model=MODEL

There are other model settings too. For most cases Alsa defaults will do. If you want to look at more specific settings for your soundcard take a look at the Alsa Soundcard List find your model, then Details, then look at the "Setting up modprobe..." section. Enter these values in Template:Filename. For example, for an Intel AC97 audio:

# ALSA portion
alias char-major-116 snd
alias snd-card-0 snd-intel8x0
# module options should go here

# OSS/Free portion
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0

# card #1
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss

Conflicting PC Speaker

Remember, ALSA installs with all channels muted by default (see previous section, unmuting your soundcard).

However, if you're sure nothing is muted, that your drivers are installed correctly, and that your volume is right, but you still do not hear anything, then try blacklisting snd-pcsp (kernels < 2.6.35) or pcspkr from your modules array in rc.conf:

MODULES=(!snd-pcsp ... )

Note that this will disable your PC's internal speaker. If that doesn't work, then try adding the following line to /etc/modprobe.d/modprobe.conf:

options snd-NAME-OF-MODULE ac97_quirk=0

The above fix has been observed to work with via82xx

options snd-NAME-OF-MODULE ac97_quirk=1

The above fix has been reported to work with snd_intel8x0

No Microphone Input

Make sure that all the volume levels are up under recording in alsamixer, and that CAPTURE is active on the microphone (in alsamixer, select it and press space). You may also need to enable and increase the volume of Line-in in the Playback section.

To test the microphone, run these commands:

 arecord -d 5 test-mic.wav
 aplay test-mic.wav

You may want to see arecord's man page to play with it a little bit. Anyway, if you are unable to hear anything, your microphone may be broken or in the wrong hole.

Some programs use try to use OSS as the main input software. Add the following line to /etc/rc.conf to prevent OSS modules from being loaded:

 MODULES=(!snd_pcm_oss !snd_mixer_oss !snd_seq_oss ... )

Setting the default Microphone/Capture Device

Some applications (Pidgin, Adobe Flash) do not provide an option to change the capture device. It becomes an issue if your microphone is on a separate device (i.e. USB webcam or microphone) than your internal sound card. To change only the default capture device, leaving the default playback device as is, you can modify your ~/.asoundrc file to include the following:

pcm.usb
{
    type hw
    card U0x46d0x81d
}

pcm.!default
{
    type asym
    playback.pcm
    {
        type plug
        slave.pcm "dmix"
    }
    capture.pcm 
    {
        type plug
        slave.pcm "usb"
    }
}


Replace "U0x46d0x81d" with your capture device's card name in ALSA. You can use 'arecord -L' to list all the capture devices detected by ALSA.

Internal Microphone not working

First make sure all the volume levels are up under recording in alsamixer. In my case adding the following option to /etc/sound.conf and reloading the snd-* module produced a new volume setting called Capture which was capturing for the internal mic. For eg, for snd-hda-intel add

 options snd-hda-intel enable_msi=1

Then reload the module (as below), up the recording volume of Capture and then test.

 rmmod snd-hda-intel
 modprobe snd-hda-intel

No Sound with Onboard Intel Sound Card

There may be an issue with two conflicting modules loaded, namely snd_intel8x0 and snd_intel8x0m. In this case, edit rc.conf and in the MODULES array blacklist the latter one so that it reads !snd_intel8x0m afterwards.

Muting the "External Amplifier" in alsamixer or amixer may also help. See the ALSA wiki.

No Headphone Sound with Onboard Intel Sound Card

With Intel Corporation 82801 I (ICH9 Family) HD Audio Controller on laptop, you may need to add this line to modprobe or sound.conf:

options snd-hda-intel model=$model

Where $model is any one of the following (in order of possibility to work, but not merit):

  • dell-vostro
  • olpc-xo-1_5
  • laptop

Note: It may be necessary to put this "options" line below (after) any "alias" lines about your card.

You can see all the available models in the kernel documentation. For example here, but check that it's the correct version of that document for your kernel version.

Note that there is a high chance none of the input devices (all internal and external mics) will work if you choose to do this, so it's either your headphones or your mic. Please report to ALSA if you are affected by this bug.

And also, if you have problems getting beeps to work (pcspkr):

options snd-hda-intel model=$model enable=1 index=0

No sound when S/PDIF video card is installed

Discover available modules and their order:

$ cat /proc/asound/modules
0 snd_hda_intel
1 snd_ca0106

Disable the undesired video card audio codec in Template:Filename:

# /etc/modprobe.d/modprobe.conf
#
install snd_hda_intel /bin/false

Poor Sound Quality

If you experience poor sound quality, try setting the PCM volume (in alsamixer) to a level such that gain is 0.

Pops When Starting and Stopping Playback

Some modules can power off your sound card when not in use. this can make an audible noise when powering down your sound card. If you find this annoying try "modinfo snd-MY-MODULE", and look for a module option that adjusts or disables this feature.

for example: to disable the power saving mode using snd-hda-intel add "options snd-hda-intel power_save=0" in /etc/modprobe.d/modprobe.conf. or try it with "modprobe snd-hda-intel power_save=0"

Alsamixer Does Not Run

If running alsamixer does not work and you wind up with the following error

alsamixer: function snd_ctl_open failed for default: No such device or directory

You should first check /etc/group to ensure that your current user is in the 'audio' group. Don't forget to log out and log in again for the group changes.

Then you might need to re-install your kernel. Run 'pacman -S kernel26' or whichever patchset you prefer to use.

S/PDIF Output Does Not Work

If the optical/coaxial digital output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try running

iecset audio on

as root.

You can also put this command in rc.local as it sometimes it may stop working after a reboot.

HDMI Output Does Not Work

If the HDMI output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try the following.

Query for Playback Devices:

 % aplay -l
 **** List of PLAYBACK Hardware Devices ****
 card 0: NVidia [HDA NVidia], device 0: ALC1200 Analog [ALC1200 Analog]
   Subdevices: 1/1
   Subdevice #0: subdevice #0
 card 0: NVidia [HDA NVidia], device 1: ALC1200 Digital [ALC1200 Digital]
   Subdevices: 1/1
   Subdevice #0: subdevice #0
 card 0: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
   Subdevices: 0/1
   Subdevice #0: subdevice #0

Now that we have the info for the HDMI device, try a test, In the example below, 0 is the card number and 3 is the device number.

 % aplay -D plughw:0,3 /usr/share/sounds/alsa/Front_Center.wav

If aplay does not output any errors, but still no sound is heared, "reboot" the receiver, monitor or tv set. Since the HDMI interface executes a handshake on connection, it might have noticed before that there was no audio stream embedded, and disabled audio decoding.

If the test is successful, edit/create asound.conf in /etc to set HDMI as the default audio device, reboot, and audio should now work. There might be a better way to do this??

 % cat /etc/asound.conf
 pcm.!default {
      type plug
      slave.pcm {
              type hw
              card 0
              device 3
      }
 }

If the this inconclusive

No Adjustable PCM Channel

You may find that you lack adjustable PCM channel. In this case try to remove all sound-related stuff from MODULES section in /etc/rc.conf, except for snd-NAME-OF-MODULE and snd-pcm-oss.

HP TX2500

Add these 2 lines into Template:Filename:

options snd-cmipci mpu_port=0x330 fm_port=0x388
options snd-hda-intel index=0 model=toshiba position_fix=1
options snd-hda-intel model=hp (works for tx2000cto)

Skipping Sound When Playing MP3

If you have sound skipping when playing MP3 files and you have more then 2 speakers attached to your computer (i.e. > 2 speaker system), run alsamixer and disable the channels for the speakers that you DON'T have (i.e. don't enable the sound for the center speaker if you don't have a center speaker.

Using a USB Headset and External USB Sound Cards

If you are using a USB headset with ALSA you can try using asoundconf (currently only available from the AUR) to set the headset as the primary sound output. note: before running please make sure you have usb audio module enabled

#modprobe snd-usb-audio

you can add this to /etc/rc.conf if you wish

# asoundconf is-active
# asoundconf list
# asoundconf set-default-card <chosen soundcard>

KDE Settings

  • Start up KDE:
# startx
  • Set up the volumes as you want them for this user (each user has their own settings):
# alsamixer

Log out and log back in as user xyz to get sound to work (I had to kill X, logout then log back in as user xyz, then start X and open Firefox and bam audio working on YouTube)

  • KDE 3.3: Go to K Menu → Multimedia → KMix
    • Choose Settings → Configure KMix...
    • Uncheck the option "Restore volumes on logon"
    • Press OK, and you should be all set. Now your volumes will be the same from the command line or within KDE.

Error 'Unkown hardware' Appears After a Kernel Update

The following messages may be displayed during the start-up ALSA after the kernel update:

Unknown hardware "foo" "bar" ...
Hardware is initialized using a guess method
/usr/sbin/alsactl: set_control:nnnn:failed to obtain info for control #mm (No such file or directory)

Simply store ALSA mixer settings again (as root):

# alsactl -f /var/lib/alsa/asound.state store

HDA Analyzer

If the mappings to your audio pins(plugs) do not correspond but ALSA works fine, you could try HDA Analyzer -- a pyGTK2 GUI for HD-audio control can be found at the ALSA wiki. Try tweaking the Widget Control section of the PIN nodes, to make microphones IN and headphone jacks OUT. Referring to the Config Defaults heading is a good idea.

NOTE: the script is done by such way that it is incompatible with python3 (which is now shipped with ArchLinux) but tries to use it. The workaround is: open "run.py", find all occurences of "python" (2 occurences - one on the first line, and the second on the last line) and replace them all by "python2".

NOTE2: the script requires root acces, but running it via su/sudo is bogus. Run it via kdesu or gtksu.

Example configurations

The following should serve as a guide for more advanced setups. The configuration takes place in /etc/asound.conf as mentioned earlier in this article. None of the following configurations are guaranteed to be working.

Upmixing of stereo sources to 7.1 using dmix while saturated sources do not get upmixed

# 2008-11-15
#
# This .asoundrc will allow the following:
#
# - upmix stereo files to 7.1 speakers.
# - playback real 7.1 sounds, on 7.1 speakers,
# - allow the playback of both stereo (upmixed) and surround(7.1) sources at the same time.
# - use the 6th and 7th channel (side speakers) as a separate soundcard, i.e. for headphones
#   (This is called the "alternate" output throughout the file, device names prefixed with 'a')
# - play mono sources in stereo (like skype & ekiga) on the alterate output
#
# Make sure you have "8 Channels" and NOT "6 Channels" selected in alsamixer!
#
# Please try the following commands, to make sure everything is working as it should.
#
# To test stereo upmix :      speaker-test -c2 -Ddefault -twav
# To test surround(5.1):      speaker-test -c6 -Dplug:dmix6 -twav
# To test surround(7.1):      speaker-test -c6 -Dplug:dmix8 -twav
# To test alternative output: speaker-test -c2 -Daduplex -twav
# To test mono upmix:         speaker-test -c1 -Dmonoduplex -twav
#
#
# It may not work out of the box for all cards. If it doesnt work for you, read the comments throughout the file.
# The basis of this file was written by wishie of #alsa, and then modified with info from various sources by 
# squisher. Svenstaro modified it for 7.1 output support.

#Define the soundcard to use
pcm.snd_card {
    type hw
    card 0
    device 0
}

# 8 channel dmix - output whatever audio, to all 8 speakers
pcm.dmix8 {
    type dmix
    ipc_key 1024
    ipc_key_add_uid false
    ipc_perm 0660
    slave {
        pcm "snd_card"
        rate 48000
        channels 8
        period_time 0
        period_size 1024
        buffer_time 0
        buffer_size 5120
    }

# Some cards, like the "nforce" variants require the following to be uncommented. 
# It routes the audio to the correct speakers.
#    bindings {
#        0 0
#        1 1
#        2 4
#        3 5
#        4 2
#        5 3
#        6 6
#        7 7
#    }
}

# upmixing - duplicate stereo data to all 8 channels
pcm.ch71dup {
    type route
    slave.pcm dmix8
    slave.channels 8
    ttable.0.0 1
    ttable.1.1 1
    ttable.0.2 1
    ttable.1.3 1
    ttable.0.4 0.5
    ttable.1.4 0.5
    ttable.0.5 0.5
    ttable.1.5 0.5
    ttable.0.6 1
    ttable.1.7 1
}

# this creates a six channel soundcard
# and outputs to the eight channel one
# i.e. for usage in mplayer I had to define in ~/.mplayer/config:
#   ao=alsa:device=dmix6
#   channels=6
pcm.dmix6 {
    type route
    slave.pcm dmix8
    slave.channels 8
    ttable.0.0 1
    ttable.1.1 1
    ttable.2.2 1
    ttable.3.3 1
    ttable.4.4 1
    ttable.5.5 1
    ttable.6.6 1
    ttable.7.7 1
}

# share the microphone, i.e. because virtualbox grabs it by default
pcm.microphone {
    type dsnoop
    ipc_key 1027
    slave {
        pcm "snd_card"
    }
}

# rate conversion, needed i.e. for wine
pcm.2chplug {
    type plug
    slave.pcm "ch71dup"
}
pcm.a2chplug {
    type plug
    slave.pcm "dmix8"
}

# routes the channel for the alternative
# 2 channel output, which becomes the 7th and 8th channel 
# on the real soundcard
#pcm.alt2ch {
#    type route
#    slave.pcm "a2chplug"
#    slave.channels 8
#    ttable.0.6    1
#    ttable.1.7    1
#}

# skype and ekiga are only mono, so route left channel to the right channel
# note: this gets routed to the alternative 2 channels
pcm.mono_playback {
    type route
    slave.pcm "a2chplug"
    slave.channels 8
    # Send Skype channel 0 to the L and R speakers at full volume
    #ttable.0.6    1
    #ttable.0.7    1
}

# 'full-duplex' device for use with aoss
pcm.duplex {
    type asym
    playback.pcm "2chplug"
    capture.pcm "microphone"
}

#pcm.aduplex {
#    type asym
#    playback.pcm "alt2ch"
#    capture.pcm "microphone"
#}

pcm.monoduplex {
    type asym
    playback.pcm "mono_playback"
    capture.pcm "microphone"
}

# for aoss
pcm.dsp0 "duplex"
ctl.mixer0 "duplex"

# softvol manages volume in alsa
# i.e. wine likes this
pcm.mainvol {
    type softvol
    slave.pcm "duplex"
    control {
        name "2ch-Upmix Master"
        card 0
    }
}

#pcm.!default "mainvol"

# set the default device according to the environment
# variable ALSA_DEFAULT_PCM and default to mainvol
pcm.!default {
    @func refer
    name { @func concat 
           strings [ "pcm."
                     { @func getenv
                       vars [ ALSA_DEFAULT_PCM ]
                       default "mainvol"
                     }
           ]
         }
}

# uncomment the following if you want to be able to control
# the mixer device through environment variables as well
#ctl.!default {
#    @func refer
#    name { @func concat 
#           strings [ "ctl."
#                     { @func getenv
#                       vars [ ALSA_DEFAULT_CTL
#                              ALSA_DEFAULT_PCM
#                       ]
#                       default "duplex"
#                     }
#           ]
#         }
#}

Surround51 incl. upmix stereo & dmix, swap L/R, bad speaker position in room

Bad practice but works fine for almost everything without additional per-program/file customization:

pcm.!default {
    type route
## forwards to the mixer pcm defined below
    slave.pcm dmix51
    slave.channels 6

## "Native Channels" stereo, swap left/right
    ttable.0.1 1
    ttable.1.0 1
## original normal left/right commented out
#    ttable.0.0 1
#    ttable.1.1 1

## route "native surround" so it still works but weaken signal (+ RL/RF swap) 
## because my rear speakers are more like random than really behind me
    ttable.2.3 0.7
    ttable.3.2 0.7
    ttable.4.4 0.7
    ttable.5.5 0.7

## stereo => quad speaker "upmix" for "rear" speakers + swap L/R
    ttable.0.3 1
    ttable.1.2 1

## stereo L+R => join to Center & Subwoofer 50%/50%
    ttable.0.4 0.5
    ttable.1.4 0.5
    ttable.0.5 0.5
    ttable.1.5 0.5
## to test: "$ speaker-test -c6 -twav" and: "$ speaker-test -c2 -twav"
}

pcm.dmix51 {
	type dmix
	ipc_key 1024
# let multiple users share
	ipc_key_add_uid false 
# IPC permissions (octal, default 0600)
# I think changing this fixed something - but I'm not sure what.
	ipc_perm 0660 # 
	slave {
## this is specific to my hda_intel. Often hd:0 is just allready it; To find: $ aplay -L 
		pcm surround51 
# this rate makes my soundcard crackle
#		rate 44100
# this rate stops flash in firefox from playing audio, but I don't need that
       rate 48000
       channels 6
## Any other values in the 4 lines below seem to make my soundcard crackle, too
       period_time 0
       period_size 1024
       buffer_time 0
       buffer_size 4096
	}
}

External Resources