The [[Wikipedia:Advanced Linux Sound Architecture|Advanced Linux Sound Architecture]] ('''ALSA''') is a Linux kernel component intended to replace the original Open Sound System (OSSv3) for providing device drivers for sound cards. Besides the sound device drivers, '''ALSA''' also bundles a user space library for application developers who want to use driver features with a higher level API than direct interaction with the kernel drivers.

+

The [[Wikipedia:Advanced Linux Sound Architecture|Advanced Linux Sound Architecture]] ('''ALSA''') is a Linux kernel component which replaced the original Open Sound System (OSSv3) for providing device drivers for sound cards. Besides the sound device drivers, '''ALSA''' also bundles a user space library for application developers who want to use driver features with a higher level API than direct interaction with the kernel drivers.

Users must be in the audio [[Users and Groups|group]] to play sound with ALSA. To add a user to the audio group, use the following command:

+

Users with a local login (at a virtual terminal or a display manager) have permission to play audio and change mixer levels. To allow this for a remote login, the user has to be [[Users and Groups#Group management|added]] to the {{ic|audio}} group. Membership in the {{ic|audio}} group also allows direct access to devices, which can lead to applications grabbing exclusive output (breaking software mixing) and breaks fast-user-switching, and multiseat.

−

{{bc|# gpasswd -a ''yourusername'' audio}}

−

−

{{Note|This will not take effect until the user logs back in.}}

===User-space utilities===

===User-space utilities===

Line 77:

Line 74:

If it does not work, proceed to [[#Configuration]] and then [[#Troubleshooting]] to solve your issues.

If it does not work, proceed to [[#Configuration]] and then [[#Troubleshooting]] to solve your issues.

−

If it works, you just need to save your mixer settings.

+

The {{pkg|alsa-utils}} package includes {{ic|alsa-restore.service}} and {{ic|alsa-store.service}}, which are preconfigured to run at boot and shutdown respectively.

−

# alsactl store

+

==Configuration==

+

===No sound in virtualbox===

+

If you experience problems with virtualbox, the following command might be helpful:

−

This will create the file {{ic|/var/lib/alsa/asound.state}}, saving the alsamixer settings.

+

{{hc|$ alsactl init|2=<nowiki>

−

Then, add the {{ic|alsa}} [[daemon]] to your {{ic|DAEMONS}} array in {{ic|/etc/rc.conf}} to automatically restore the mixer settings at boot. See [[rc.conf#Daemons]] for detailed instructions.

You might need to activate the ALSA output in your audio software as well.

−

==Configuration==

===Set the default sound card===

===Set the default sound card===

+

+

If your sound card order changes on boot, you can specify their order in any file ending with {{ic|.conf}} in {{ic|/etc/modprobe.d}} ({{ic|/etc/modprobe.d/alsa-base.conf}} is suggested).

+

For example, if you want your mia sound card to be #0:

+

+

{{hc|/etc/modprobe.d/alsa-base.conf|2=<nowiki>

+

options snd slots=snd_mia,snd_hda_intel

+

options snd_mia index=0

+

options snd_hda_intel index=1

+

</nowiki>}}

+

+

snd_mia and snd_hda_intel are the modules used by the respective cards. This configuration assumes you have one mia sound card and one card using snd_hda_intel (e.g. onboard).

+

+

You can also provide an index of -2 to instruct ALSA to never use a card as the primary one. Distributions such as Linux Mint and Ubuntu use the following settings to avoid USB and other "abnormal" drivers from getting index 0:

+

+

{{hc|/etc/modprobe.d/alsa-base.conf|2=<nowiki>

+

options bt87x index=-2

+

options cx88_alsa index=-2

+

options saa7134-alsa index=-2

+

options snd-atiixp-modem index=-2

+

options snd-intel8x0m index=-2

+

options snd-via82xx-modem index=-2

+

options snd-usb-audio index=-2

+

options snd-usb-caiaq index=-2

+

options snd-usb-ua101 index=-2

+

options snd-usb-us122l index=-2

+

options snd-usb-usx2y index=-2

+

# Keep snd-pcsp from being loaded as first soundcard

+

options snd-pcsp index=-2

+

# Keep snd-usb-audio from beeing loaded as first soundcard

+

options snd-usb-audio index=-2

+

</nowiki>}}

+

+

These changes require a system reboot.

+

+

{{Out of date|{{ic|/etc/asound.conf}} does not exist on a default setup, and these instructions may not work.}}

First you will have to find out the card and device id that you want to set as the default by running {{ic|aplay -l}}:

First you will have to find out the card and device id that you want to set as the default by running {{ic|aplay -l}}:

Line 117:

Line 153:

The changes should take effect as soon as you (re-)start an application (mplayer etc.).

The changes should take effect as soon as you (re-)start an application (mplayer etc.).

−

−

−

If your sound card order changes on boot, you can specify their order in {{ic|/etc/modprobe.d/modprobe.conf}}.

−

For example, if you want your mia sound card to be #0:

−

−

{{hc|/etc/modprobe.d/modprobe.conf|2=<nowiki>

−

options snd slots=snd_mia,snd_hda_intel

−

options snd_mia index=0

−

options snd_hda_intel index=1

−

</nowiki>}}

−

−

snd_mia and snd_hda_intel are the modules used by the respective cards. This configuration assumes you have one mia sound card and one card using snd_hda_intel (e.g. onboard). These changes require a system reboot.

===Making sure the sound modules are loaded===

===Making sure the sound modules are loaded===

Line 146:

Line 170:

If the output looks similar, your sound drivers have been successfully autodetected.

If the output looks similar, your sound drivers have been successfully autodetected.

−

{{Note|Since {{ic|udev>&#61;171}}, the OSS emulation modules ({{ic|snd_seq_oss, snd_pcm_oss, snd_mixer_oss}}) are not loaded by default: If they are needed, load them with {{ic|modprobe}} and/or add them in the {{ic|MODULES}} array in [[rc.conf|{{ic|/etc/rc.conf}}]]. As they bypass software mixing, do not load them unless you have legacy software that supports nothing but OSS.}}

+

{{Note|Since {{ic|udev>&#61;171}}, the OSS emulation modules ({{ic|snd_seq_oss, snd_pcm_oss, snd_mixer_oss}}) are not loaded by default: [[kernel modules#Loading|Load them manually]] if they are needed.}}

You might also want to check the directory {{ic|/dev/snd/}} for the right device files:

You might also want to check the directory {{ic|/dev/snd/}} for the right device files:

* Check for the device files in {{ic|/dev/snd}} (see above) and/or try if {{ic|alsamixer}} or {{ic|amixer}} have reasonable output.

* Check for the device files in {{ic|/dev/snd}} (see above) and/or try if {{ic|alsamixer}} or {{ic|amixer}} have reasonable output.

−

* Add {{ic|snd-NAME-OF-MODULE}} and {{ic|snd-pcm-oss}} to the list of MODULES in {{ic|/etc/rc.conf}} to ensure they are loaded next time (make sure {{ic|snd-NAME-OF-MODULE}} is before {{ic|snd-pcm-oss}}).

+

* Configure {{ic|snd-NAME-OF-MODULE}} and {{ic|snd-pcm-oss}} to [[Kernel modules#Loading|load at boot]].

−

−

===Restore ALSA Mixer settings at startup===

−

{{Warning|If you use {{ic|kmix}}, make sure to configure it to not restore sound levels at startup. This will conflict with the configuration detailed below.}}

−

* Run {{ic|alsactl -f /var/lib/alsa/asound.state store}} once to create {{ic|/var/lib/alsa/asound.state}}.

−

−

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

−

−

* Edit {{ic|/etc/[[rc.conf]]}} and add {{ic|alsa}} 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 {{ic|/etc/rc.local}}:

−

−

# 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 {{ic|alsactl store -f ~/.asoundrc}} 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 {{ic|~/.bash_login}} and {{ic|~/.bash_logout}}, or the correct locations for the shell of your choice.

−

−

For zsh, use {{ic|~/.zlogin}} and {{ic|~/.zlogout}}.

===Getting SPDIF Output===

===Getting SPDIF Output===

Line 243:

Line 250:

Then reload your ALSA settings (as root).

Then reload your ALSA settings (as root).

−

# rc.d restart alsa

+

# systemctl restart alsa

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

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

Line 324:

Line 331:

* Reload your alsa settings (as root).

* Reload your alsa settings (as root).

−

# rc.d restart alsa

+

# systemctl restart alsa

* You should be good to go (if not, ask in the forum).

* You should be good to go (if not, ask in the forum).

Line 331:

Line 338:

When software mixing is enabled, ALSA is forced to resample everything to the same frequency (48000 by default when supported). dmix uses a poor resampling algorithm which produces noticeable sound quality loss.

When software mixing is enabled, ALSA is forced to resample everything to the same frequency (48000 by default when supported). dmix uses a poor resampling algorithm which produces noticeable sound quality loss.

−

Install alsa-plugins and libsamplerate:

+

Install {{pkg|alsa-plugins}} and {{pkg|libsamplerate}}.

−

{{bc|# pacman -S alsa-plugins libsamplerate}}

Change the default rate converter to libsamplerate:

Change the default rate converter to libsamplerate:

Line 491:

Line 497:

===Random Lack of Sound on Startup===

===Random Lack of Sound on Startup===

−

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 {{ic|/etc/asound.conf}}:

+

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, try [[#Set the default sound card|setting the default sound card]].

−

−

{{bc|<nowiki>

−

ctl.dmixer {

−

type hw

−

card FOO

−

}

−

</nowiki>}}

−

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

−

{{bc|

−

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 have copied the {{ic|/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:

−

{{bc|<nowiki>

−

ctl.dmixer {

−

type hw

−

card SB

−

}

−

</nowiki>}}

−

−

If you use dmix, you will want to have a configuration such as this one:

−

{{bc|<nowiki>

−

ctl.!default {

−

type hw

−

card Intel #adapt this to your card

−

#device 0 #not required, defaults to 0 (see the output of aplay -L)

−

}

−

−

pcm.dmixer {

−

type dmix

−

ipc_key 1024 #required and must be unique

−

slave.pcm {

−

type hw

−

card Intel #same as above

−

#device 0 #same as above

−

}

−

}

−

−

pcm.!default {

−

type plug

−

slave.pcm dmixer

−

}

−

</nowiki>}}

−

−

To make most programs use ALSA, make sure {{ic|/etc/libao.conf}} only contains the following.

−

default_driver=alsa10

If you use mpd and the configuration tips above do not work for you, try [http://mpd.wikia.com/wiki/Configuration#ALSA_MPD_software_volume_control reading this] instead.

If you use mpd and the configuration tips above do not work for you, try [http://mpd.wikia.com/wiki/Configuration#ALSA_MPD_software_volume_control reading this] instead.

Line 765:

Line 723:

===Pops When Starting and Stopping Playback===

===Pops When Starting and Stopping Playback===

−

Some modules (i.e. snd-ac97-codec and snd-hda-intel) can power off your sound card when not in use. This can make an audible noise (like a crack/pop/scratch) when turning on/off your sound card. Sometimes even when move the slider volume, or open and close windows (KDE4). If you find this annoying try "modinfo snd-MY-MODULE", and look for a module option that adjusts or disables this feature.

+

Some modules (e.g. snd_ac97_codec and snd_hda_intel) can power off your sound card when not in use. This can make an audible noise (like a crack/pop/scratch) when turning on/off your sound card. Sometimes even when move the slider volume, or open and close windows (KDE4). If you find this annoying try {{ic|modinfo snd_MY_MODULE}}, and look for a module option that adjusts or disables this feature.

Example: to disable the power saving mode and solve cracking sound trough speakers issue, using snd_hda_intel add in {{ic|/etc/modprobe.d/modprobe.conf}}

−

[options snd-hda-intel power_save=0]

+

options snd_hda_intel power_save=0

or

or

−

[options snd-hda-intel power_save=0 power_save_controller=N]

+

options snd_hda_intel power_save=0 power_save_controller=N

−

You can also try it with "modprobe snd-hda-intel power_save=0" before.

+

You can also try it with {{ic|1=modprobe snd_hda_intel power_save=0}} before.

−

You may also have to unmute the 'Line' alsa channel for this to work. Any value will do (other than '0' or something too high).

+

You may also have to unmute the 'Line' ALSA channel for this to work. Any value will do (other than '0' or something too high).

−

''Example:'' on an onboard VIA VT1708S (using the snd-hda-intel module) these cracks occured even though 'power_save' was set to 0. Unmuting the 'Line' channel and setting a value of '1' solved the issue.

+

''Example:'' on an onboard VIA VT1708S (using the snd_hda_intel module) these cracks occured even though 'power_save' was set to 0. Unmuting the 'Line' channel and setting a value of '1' solved the issue.

If you use a laptop, pm-utils will change {{ic|power_save}} back to 1 when you go onto battery power even if you disable power saving in /etc/modprobe.d. Disable this for pm-utils by disabling the script that makes the change:

+

If you use a laptop, pm-utils will change {{ic|power_save}} back to 1 when you go onto battery power even if you disable power saving in {{ic|/etc/modprobe.d}}. Disable this for pm-utils by disabling the script that makes the change:

# chmod -x /usr/lib/pm-utils/power.d/intel-audio-powersave

# chmod -x /usr/lib/pm-utils/power.d/intel-audio-powersave

Line 827:

Line 785:

You can restart alsa with the example below or you may reboot, and audio should now work.

You can restart alsa with the example below or you may reboot, and audio should now work.

You may find that you lack an adjustable PCM channel. In this case, try to remove all sound-related stuff from {{ic|MODULES}} section in {{ic|/etc/[[rc.conf]]}}, except for {{ic|snd-NAME-OF-MODULE}}.

===HP TX2500===

===HP TX2500===

Line 1,013:

Line 968:

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".

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.

+

NOTE2: the script requires root acces, but running it via su/sudo is bogus. Run it via {{ic|kdesu}} or {{ic|gksu}}.

===ALSA with SDL===

===ALSA with SDL===

Revision as of 04:53, 23 November 2012

zh-CN:Advanced Linux Sound Architecture
The Advanced Linux Sound Architecture (ALSA) is a Linux kernel component which replaced the original Open Sound System (OSSv3) for providing device drivers for sound cards. Besides the sound device drivers, ALSA also bundles a user space library for application developers who want to use driver features with a higher level API than direct interaction with the kernel drivers.

Users with a local login (at a virtual terminal or a display manager) have permission to play audio and change mixer levels. To allow this for a remote login, the user has to be added to the audio group. Membership in the audio group also allows direct access to devices, which can lead to applications grabbing exclusive output (breaking software mixing) and breaks fast-user-switching, and multiseat.

Unmuting the channels

The current version of ALSA installs with all channels muted by default. You will need to unmute the channels manually.

It is easiest to use alsamixer ncurses UI to accomplish this:

$ alsamixer

Alternatively, use amixer from the command-line:

$ amixer sset Master unmute

The label MM below a channel indicates that the channel is muted, and 00 indicates that it is open.

Scroll to the Master and PCM channels with the Template:Keypress and Template:Keypress keys and unmute them by pressing the Template:Keypress key. Use the Template:Keypress key to increase the volume and obtain a value of 0 dB gain. The gain can be found in the upper left next to the Item: field. Higher values of gain will produce distorted sound.

To get full 5.1 or 7.1 surround sound you likely need to unmute other channels such as Front, Surround, Center, LFE (subwoofer) and Side (these are the names of the channels with Intel HD Audio, they may vary with different hardware). Please take note that this will not automatically upmix stereo sources (like most music). In order to accomplish that, see #Upmixing/Downmixing.

You might need to activate the ALSA output in your audio software as well.

Set the default sound card

If your sound card order changes on boot, you can specify their order in any file ending with .conf in /etc/modprobe.d (/etc/modprobe.d/alsa-base.conf is suggested).
For example, if you want your mia sound card to be #0:

snd_mia and snd_hda_intel are the modules used by the respective cards. This configuration assumes you have one mia sound card and one card using snd_hda_intel (e.g. onboard).

You can also provide an index of -2 to instruct ALSA to never use a card as the primary one. Distributions such as Linux Mint and Ubuntu use the following settings to avoid USB and other "abnormal" drivers from getting index 0:

For example, the last entry in this list has the card ID 2 and the device ID 0. To set this card as the default, you can either use the system-wide file /etc/asound.conf or the user-specific file ~/.asoundrc. You may have to create the file if it does not exist. Then insert the following options with the corresponding card and device id.

~/.asoundrc

defaults.pcm.card 2
defaults.pcm.device 0
defaults.ctl.card 2

The 'pcm' options affect which card and device will be used for audio playback while the 'ctl' option affects which card is used by control utilities like alsamixer .

The changes should take effect as soon as you (re-)start an application (mplayer etc.).

Making sure the sound modules are loaded

You can assume that udev will autodetect your sound properly. You can check this with the command

System-Wide Equalizer

Using AlsaEqual (provides UI)

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 (~/.asoundrc or /etc/asound.conf):

ctl.equal {
type equal;
}
pcm.plugequal {
type equal;
# Modify the line below if you do not
# 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 {
# If you don't want the equalizer to be your
# default soundcard comment the following
# line and uncomment the above line. (You can
# choose it as the output device by addressing
# it with specific apps,eg mpg123 -a equal 06.Back_In_Black.mp3)
pcm.!default {
type plug;
slave.pcm plugequal;
}

Then reload your ALSA settings (as root).

# systemctl restart alsa

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 is saved in ~/.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 for example, you can make a symlink to your .alsaequal.bin in his home...

High quality resampling

When software mixing is enabled, ALSA is forced to resample everything to the same frequency (48000 by default when supported). dmix uses a poor resampling algorithm which produces noticeable sound quality loss.

samplerate_best offers the best sound quality, but you need a decent CPU to be able to use it as it requires a lot of CPU cycles for real-time resampling. There are other algorithms available (samplerate, etc.) but they may not provide much of an improvement over the default resampler.

Warning: On some systems, enabling samplerate_best may cause an issue where you get no sound from flashplayer.

Upmixing/Downmixing

Upmixing

In order for stereo sources like music to be able to saturate a 5.1 or 7.1 sound system, you need to use upmixing. In darker days this used to be tricky and error prone but nowadays plugins exist to easily take care of this task. Thus, install alsa-plugins.

Then add the following to your ALSA configuration file of choice (either /etc/asound.conf or ~/.asoundrc):

pcm.upmix71 {
type upmix
slave.pcm "surround71"
delay 15
channels 8
}

You can easily change this example for 7.1 upmixing to 5.1 or 4.0.

This adds a new pcm that you can use for upmixing. If you want all sound sources to go through this pcm, add it as a default below the previous definition like so:

pcm.!default "plug:upmix71"

The plugin automatically allows multiple sources to play through it without problems so setting is as a default is actually a safe choice.
If this is not working, you have to setup your own dmixer for the upmixing PCM like this:

Hardware mixing

Support

If you have an audio chipset that supports mixing in hardware, then no configuration is necessary. Almost every onboard audio chipset does not support hardware mixing, and requires mixing to be done in software (see above). Many sound cards do support hardware mixing, and the ones best supported on Linux are listed below:

Creative SoundBlaster Live! (5.1 model)

Creative SoundBlaster Audigy (some models)

Creative SoundBlaster Audidy 2 (ZS models)

Creative SoundBlaster Audigy 4 (Pro models)

Note: The old SoundBlaster Live! series (emu10k1 chip) and new Audigy [1, 2 ZS, 4 Pro] (emu10k2 chip) cards are known to work.

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

Note: The onboard VIA8237 chip 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.

Fixes

If you are using 64-bit Arch and the Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 02), you can get sound working for Enemy Territory with the following:

Troubleshooting

Sound Skipping While Using Dynamic Frequency Scaling

Some combinations of ALSA drivers and chipsets may cause audio from all sources to skip when used in combination with a dynamic frequency scaling governor such as ondemand or conservative. Currently, the solution is to switch back to the performance governor.

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 cannot play sounds though the dmixer. While it's 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.

Simultaneous Playback Issues

If you are having simultaneous playback issues, and if PulseAudio is installed (i.e. by GNOME), its default configuration is set to "hijack" the soundcard. Some users of ALSA may not want to use PulseAudio and are quite content with their current ALSA settings. One fix is to edit /etc/asound.conf and comment out the following lines:

Note: This /etc/asound.conf file was intended for and used successfully with a global MPD configuration. See this section on multiple users

Random Lack of Sound on Startup

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, try setting the default sound card.

If you use mpd and the configuration tips above do not 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

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 /etc/modprobe.d/modprobe.conf or /etc/modprobe.d/sound.conf. 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 /etc/modprobe.d/modprobe.conf. For example, for an Intel AC97 audio:

Conflicting PC Speaker

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 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

In alsamixer, make sure that all the volume levels are up under recording, and that CAPTURE is toggled active on the microphone (e.g. Mic, Internal Mic) and/or on Capture (in alsamixer, select these items and press space). Try making positive Mic Boost and raising Capture and Digital levels higher; this make make static or distortion, but then you can adjust them back down once you're hearing something when you record

As the pulseaudio wrapper is shown as "default" in alsamixer, your may have to press F6 to select your actual soundcard first. You may also need to enable and increase the volume of Line-in in the Playback section.

To test the microphone, run these commands (see arecord's man page for further information):

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

If all fails, you may want to eliminate hardware failure by testing the microphone with a different device.

For at least some computers, muting a microphone (MM) simply means its input doesn't go immediately to the speakers. It still receives input.

Many Dell laptops need "-dmic" to be appended to the model name in /etc/modprobe.d/modprobe.conf:

options snd-hda-intel model=dell-m6-dmic

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

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 (e.g. 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:

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, blacklist snd_intel8x0m:

/etc/modprobe.d/modprobe.conf

blacklist snd_intel8x0m

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

dell-m6

laptop-hpsense

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 is the correct version of that document for your kernel version.

A list of available models is also available here. To know your chip name type the following command (with * being corrected to match your files). Note that some chips could have been renamed and don't directly match the available ones in the file.

cat /proc/asound/card*/codec* | grep Codec

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 is either your headphones or your mic. Please report to ALSA if you are affected by this bug.

Pops When Starting and Stopping Playback

Some modules (e.g. snd_ac97_codec and snd_hda_intel) can power off your sound card when not in use. This can make an audible noise (like a crack/pop/scratch) when turning on/off your sound card. Sometimes even when move the slider volume, or open and close windows (KDE4). If you find this annoying try modinfo snd_MY_MODULE, and look for a module option that adjusts or disables this feature.

Example: to disable the power saving mode and solve cracking sound trough speakers issue, using snd_hda_intel add in /etc/modprobe.d/modprobe.conf

options snd_hda_intel power_save=0

or

options snd_hda_intel power_save=0 power_save_controller=N

You can also try it with modprobe snd_hda_intel power_save=0 before.

You may also have to unmute the 'Line' ALSA channel for this to work. Any value will do (other than '0' or something too high).

Example: on an onboard VIA VT1708S (using the snd_hda_intel module) these cracks occured even though 'power_save' was set to 0. Unmuting the 'Line' channel and setting a value of '1' solved the issue.

If you use a laptop, pm-utils will change power_save back to 1 when you go onto battery power even if you disable power saving in /etc/modprobe.d. Disable this for pm-utils by disabling the script that makes the change:

# chmod -x /usr/lib/pm-utils/power.d/intel-audio-powersave

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.

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.

Note: If you're using an ATI card and linux 3.0, check your kernel/grub settings, you most likely need to use the 'radeon.audio=1' boot parameter, or alternatively set up the option in your modprobe configuration files.

If the test is successful, create or edit your ~/.asoundrc file to set HDMI as the default audio device.

pcm.!default {
type hw
card 0
device 3
}

You can restart alsa with the example below or you may reboot, and audio should now work.

Note: Any programs running that use alsa will be closed.

# systemctl restart alsa

Using udev to automatically turn HDMI audio on or off

Note: This will only work if the driver supports udev; NVIDIA's proprietary one, for instance, does not.

The previous steps in this section are good for testing, or if you don't need to hotplug your HDMI cable often. We now consider the situation where you have a laptop and want HDMI audio only when you have the HDMI cable plugged in.

The two asound.conf versions include dmix settings and allow merging of user permissions so that, for example, the mpd user and your regular user can access it at the same time.

You may now test that the switcher script works by running,

# chmod +x /etc/alsa/hdmi-switch
# /etc/alsa/hdmi-switch

You should find that you can successfully obtain HDMI audio output when you run the script while the cable is plugged in. You should be able to restore your default audio output by unplugging the cable and manually running the script again.

Once you have that working, we automate the process by adding the udev rule:

HDMI Multi-channel PCM output does not work (Intel)

As of Linux 3.1 multi-channel PCM output through HDMI with a Intel card (Intel Eaglelake, IbexPeak/Ironlake,SandyBridge/CougarPoint and IvyBridge/PantherPoint) is not yet supported. Support for it has been recently added and expected to be available in Linux 3.2. To make it work in Linux 3.1 you need to apply the following patches:

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 DO NOT have (i.e. do not enable the sound for the center speaker if you do not 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 asoundconfAUR (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

Error 'Unknown 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)

or

Found hardware: "HDA-Intel" "VIA VT1705" "HDA:11064397,18490397,00100000" "0x1849" "0x0397"
Hardware is initialized using a generic method
/usr/sbin/alsactl: set_control:1328: failed to obtain info for control #1 (No such file or directory)
/usr/sbin/alsactl: set_control:1328: failed to obtain info for control #2 (No such file or directory)
/usr/sbin/alsactl: set_control:1328: failed to obtain info for control #25 (No such file or directory)
/usr/sbin/alsactl: set_control:1328: failed to obtain info for control #26 (No such file or directory)

Simply store ALSA mixer settings again (as root):

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

It may be necessary configure ALSA again with alsamixer

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 gksu.

ALSA with SDL

If you get no sound via SDL and ALSA cannot be chosen from the application. Try setting the environmental variable SDL_AUDIODRIVER to alsa.

# export SDL_AUDIODRIVER=alsa

Low Sound Workaround

If you are facing low sound even after maxing out your speakers/headphones, you can give the softvol plugin a try. Add the following to /etc/asound.conf.

Note: You'll probably have to restart the computer, as restarting the alsa daemon didn't load the new configuration for me. Also, if the configuration doesn't work even after restarting, try changing plug with hw in the above configuration.

After the changes are loaded successfully, you will see a Pre-Amp section in alsamixer. You can adjust the levels there.

Note: Setting a high value for Pre-Amp can cause sound distortion, so adjust it according to the level that suits you.

Popping sound after resuming from suspension

You might hear a popping sound after resuming the computer from suspension. This can be fixed by editing /etc/pm/sleep.d/90alsa and removing the line that says aplay -d 1 /dev/zero