Difference between revisions of "Advanced Linux Sound Architecture"

From ArchWiki
Jump to navigation Jump to search
m
m (i18n links changed)
Line 7: Line 7:
 
{{i18n_entry|Italiano|ALSA Setup (Italiano)}}
 
{{i18n_entry|Italiano|ALSA Setup (Italiano)}}
 
{{i18n_entry|Nederlands|ALSA instellen}}
 
{{i18n_entry|Nederlands|ALSA instellen}}
{{i18n_entry|Русский|ALSA Setup (Русский)}}
+
{{i18n_entry|Русский|ALSA_(Russian)}}
 
{{i18n_entry|Slovensky|Nastavenie ALSA}}
 
{{i18n_entry|Slovensky|Nastavenie ALSA}}
 
{{i18n_entry|Česky|ALSA (Česky)}}
 
{{i18n_entry|Česky|ALSA (Česky)}}

Revision as of 10:04, 22 September 2007

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

Introduction

The Advanced Linux Sound Architecture (ALSA) is a Linux kernel component intended to replace the original Open Sound System (OSS) for providing device drivers for sound cards.

This document tells how to get ALSA working with 2.6 kernels. Also see how to allow multiple programs to play sound at once.

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 has to be done unless you use ISA cards. 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 -Sy alsa-lib 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.

Configuration

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

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. If you want any help on IRC or the forums, please post the output of the above commands. To solve this, you can try loading the modules manually:

 # 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 /etc/rc.conf to ensure they are loaded next time (make sure snd-NAME-OF-MODULE is before snd-pcm-oss).

Unmuting the channels and testing the sound card

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

It is recommended to use 'alsamixer' to configure your mixer and unmute the channels.

NOTE: When using amixer, be sure to unmute as well as bring volumes up to a specific level in percent, i.e you need to use that % sign. amixer understands the percent sign (%), not numbers. If you use a number (say, 90) then amixer will take it as 100%, which can harm your speakers.

 # amixer set Master 90% unmute
 # amixer set PCM 85% unmute
  • Try to play a WAV file
 # aplay mywav.wav

NOTE: Some cards (well, at least Soundblaster Audigy LS) needs to have digital output muted/turned off in order to hear analog sound.

Setup Permissions

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

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

Restore ALSA Mixer settings at startup

  • Run 'alsactl' once to create '/etc/asound.state'
alsactl store
  • Edit '/etc/rc.conf' and add '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.

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 /etc/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):

  • add following lines to /etc/rc.local:
 # 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

KDE Settings

  • Start up KDE:
# startx
  • Set up the volumes as you want them for this user (each user has their own settings):
# alsamixer
  • 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.

Troubleshooting

Still Getting No Sound?

Even though your drivers are installed correctly, your volume is right, and nothing is muted, you might not hear anything! Adding the following line to /etc/modprobe.conf should fix this problem (with the via82xx driver, at least).

options snd-NAME-OF-MODULE ac97_quirk=0

Poor Sound Quality?

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