The Advanced Linux Sound Architecture (ALSA) is a project to improve the Linux sound subsystem by rewriting large chunks of it. It has replaced the Open Sound System (OSS) as the default sound subsystem in the 2.6 kernel, but it can be used with either 2.4 or 2.6 kernels.
ALSA provides audio and MIDI functionality for Linux.
Quoted from
There's lots more to ALSA however, like support for Full Duplex playback and recording, multiple soundcard support, hardware mixing of streams, extensive mixer capabilities (to support advanced features of new soundcards), ...
Your sound card may be supported by modules available in the 2.4 kernel (these
are also provided in the 2.6 kernel under the 'Open Sound System (DEPRECATED)'
option). Additionally, you might be able to use the commercial OSS/4Front sound
driver system. If you wish to use either of these systems, then you should read
through the
The OSS/4Front drivers have some limitations, however. Being commercial is one. ALSA is an attempt to go beyond these limitations with an open source development model. ALSA is a fully GPL and LGPL'ed sound driver system that provides a professional quality system for recording, playback, and MIDI sequencing.
ALSA tries to support as many (new) cards as possible by providing open-source drivers. However, some vendors may provide binary-only packages.
To know if your card is supported, you can find a Soundcard Matrix of supported
and not-supported cards here:
To compile programs with ALSA-support, be sure to add
When using the 2.4 kernels, you'll need to compile the alsa drivers separately
from the rest of the kernel. If you are using a 2.6 kernel, you have the
option of using the ALSA drivers included in the kernel or those provided
by the
First we'll make sure that our kernel configuration is ready for use with ALSA.
All you need in your kernel configuration is having Sound Card Support set to
be built as a module (M). This will build
If you already have a working kernel configuration, make sure you remove all sound drivers (except for Sound Card Support). If you wish to do this without having to reboot, you could do like this:
# cd /usr/src/linux # cp .config ~/ # make mrproper # cp ~/.config . # make menuconfig
Now select
# make dep clean # make modules modules_install
# make # make modules_install
If you compiled 2.6 with the ALSA modules provided by the kernel, please skip to
Before installing your new modules, this last line will delete all your previous modules, even the ones from a previous ALSA installation.
Now it's time to install the ALSA drivers for your soundcard(s). If your
soundcard is PCI, you can find out the name and type of your soundcard by
looking at the output of
# grep audio /proc/pci
We could simply do an
However, to save some time, lookup the
# env ALSA_CARDS='emu10k1' emerge alsa-driver
# env ALSA_CARDS='emu10k1' emerge \>=media-sound/alsa-driver-1.0.2c
After this, the ALSA modules should be installed on your system.
Let's start configuring now to get ALSA working properly. We'll need to edit some files, to let our system know about the freshly installed ALSA modules.
First, install
# emerge alsa-utils
Hereafter, we need to edit
## and then run `modules-update' command. ## Read alsa-driver's INSTALL file in /usr/share/doc for more info. ## ## ALSA portion alias snd-card-0 snd-emu10k1 ## alias snd-card-1 snd-intel8x0 ## alias snd-card-2 snd-ens1370 ## OSS/Free portion alias sound-slot-0 snd-card-0 ## alias sound-slot-1 snd-card-1 ## alias sound-slot-2 snd-card-2 ##
Last thing to do in this file, almost at the end, check if these lines are there and uncommented:
alias /dev/mixer snd-mixer-oss alias /dev/dsp snd-pcm-oss alias /dev/midi snd-seq-oss
After double-checking the file
# modules-update
You should also verify that
# ALSA/OSS stuff # Comment/change these if you want to change the permissions on # the audio devices LOOKUP snd MODLOAD ACTION snd LOOKUP dsp MODLOAD LOOKUP mixer MODLOAD LOOKUP midi MODLOAD REGISTER sound/.* PERMISSIONS root.audio 660 REGISTER snd/.* PERMISSIONS root.audio 660
An init script is provided for you which will install all necessary sound drivers for your card (including the OSS support drivers if you set USE=oss). The first thing to do now is to make ALSA startup at boot time:
# rc-update add alsasound boot
Since we're Linux users, we don't want to reboot. So we'll start the alsasound script manually.
# /etc/init.d/alsasound start
ALSA is running now. If everything is ok, you should be able to see the ALSA
modules loaded when running
# amixer
If you got this far, now unmute Master and PCM channels. Some hardware even requires you to unmute the center channel or even the surround channel.
# amixer set Master 100 unmute # amixer set PCM 100 unmuteOnly if the above doesn't succeed on its own: # amixer set Center 100 unmute # amixer set Surround 100 unmuteTest the sound: # aplay $KDEDIR/share/sounds/pop.wav(pop.wav is part of KDE)
We check to see if sound is working by using the aplay (alsa play) command. If
you hear a pop, then sound is indeed working. Then, adjust the volume settings
to your liking; the ncurses-based
When you reboot your system, the
Some sound cards (SBLive, Audigy, and others) come with onboard MIDI synthesizers.
To use them, you must first install the
# emerge awesfx
Now, you should place your sound fonts in
After copying over the sound font you want to use, you need to select it for use
with
# /usr/bin/sfxload /usr/share/sfbank/8MBGMSFX.SF2
If you can't find soundfonts on your driver CD you can download some online from
If your sound card does not come with a hardware synthesizer (or you don't
want to use it), you can use
# emerge timidity++
A sample configuration file will be installed for you in
# cp /usr/share/timidity/config/timidity.cfg /usr/share/timidity
Now, you need to enable the init script to run when your system boots and enable it now.
# rc-update add timidity default # /etc/init.d/timidity start
Note that there is a configuration file for the init script that you can
modify in
You can use
# emerge pmidi
The '-l' command line option to pmidi will list all detected MIDI output ports, and '-p' can be used to select the one for playback. Check to see what MIDI output ports are available on your system:
# pmidi -l Port Client name Port name 64:0 Rawmidi 0 - EMU10K1 MPU-401 (U EMU10K1 MPU-401 (UART) 65:0 Emu10k1 WaveTable Emu10k1 Port 0 65:1 Emu10k1 WaveTable Emu10k1 Port 1 65:2 Emu10k1 WaveTable Emu10k1 Port 2 65:3 Emu10k1 WaveTable Emu10k1 Port 3
# pmidi -l Port Client name Port name 64:0 Rawmidi 0 - ES1371 ES1371 128:0 TiMidity TiMidity port 0 128:1 TiMidity TiMidity port 1 128:2 TiMidity TiMidity port 2 128:3 TiMidity TiMidity port 3
Now, try playing a MIDI file to make sure everything works:
# pmidi -p 65:0 Final\ Fantasy\ 7\ -\ Aerith\'s\ Theme.mid or # pmidi -p 128:0 Final\ Fantasy\ 7\ -\ Aerith\'s\ Theme.mid
When you ever rebuild your kernel, or upgrade to another kernel, you'll have to rebuild the ALSA modules.
Although you might have installed
# emerge alsa-driver
The alsa-tools and alsa-firmware packages contain tools useful to only users of specific sound cards. Most users will not need these. If you do need alsa-tools, you can set the environment variable 'ALSA_TOOLS' to install just the needed tools for your card:
# env ALSA_TOOLS='as10k1 ac3dec' emerge alsa-tools
Often times, different versions of
You won't have to edit this file for use with ALSA. After doing
If your soundcard has a joystick plug, you might be interested in activating
joystick support for your soundcard. If so, start by verifying if your soundcard
driver has a joystick parameter. You can verify this by running
# modinfo snd-via82xx filename: /lib/modules/2.4.22-ck2/snd-via82xx.o description: "VIA VT82xx audio" author: "Jaroslav Kysela <perex@suse.cz>" license: "GPL" parm: index int array (min = 1, max = 8), description "Index value for VIA 82xx bridge." parm: id string array (min = 1, max = 8), description "ID string for VIA 82xx bridge." parm: enable int array (min = 1, max = 8), description "Enable audio part of VIA 82xx bridge." parm: mpu_port long array (min = 1, max = 8), description "MPU-401 port. (VT82C686x only)" parm: joystick int array (min = 1, max = 8), description "Enable joystick. (VT82C686x only)" parm: ac97_clock int array (min = 1, max = 8), description "AC'97 codec clock (default 48000Hz)." parm: dxs_support int array (min = 1, max = 8), description "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA)"
If it has the
alias snd-card-0 snd-via82xx options snd-via82xx joystick=1
You could check these for additional info: