ALSA

ALSA is a major sound system for Linux. It consists of several parts, the most important of which is the driver. The drivers are available as part of the kernel, or in the package Typically the drivers in the portage tree are newer than those in the kernel, but if you use them, you will have to re-emerge them each time you rebuild your kernel.

Hardware Discovery
Use the program(part of ) to identify any sound cards on your system:

We see here, as an example, that this computer is equipped with a Creative SoundBlaster Live!: 0000:00:0a.0 Multimedia audio controller: Creative Labs SB Live! EMU10k1 (rev 06) The output states the type of device, brand, model, and potentially the necessary ALSA driver. To verify the driver name, go to the ALSA sound card matrix. This information will be to build the proper drivers in the kernel.

Kernel Configuration
Refer to the official Gentoo Kernel Configuration Guide on other matters surrounding the kernel and recompilation. Select the devices for which you wish to build drivers under the Generic devices, PCI devices and USB devices. Include them as modules:

(Recompile and (re)install your kernel.

Module Configuration
ALSA does not typically need user configuration on a system with only one sound card; all necessary modules should be loaded by udev automatically with dmix enabled. If sound does not function for some reason, or if you need to configure multiple sound cards, read on.

ALSA Userspace
You will need some userspace utilities for ALSA to function properly, these are provided with the package. Note that you probably don't want to set the on this package, as it will then only install the ALSA init scripts:

When emerged it's a good idea to add alsasound to your boot runlevel(as advised by the post-emerge message):

Last but not least, edit to your liking.

Plugins
carries a special USE variable called ALSA_PCM_PLUGINS. These plugins take a raw sound stream and process it further, adding effects or filtering.

This feature is intended for embedded systems, so that the ALSA footprint can be reduced by installing only the necessary plugins. It is recommended that you leave all plugins on unless you know which plugins are required for your sound card or are willing to experiment with which plugins are optional. See the post from the developer of this feature.

For futher reading on ALSA's plugins, see the ALSA PCM Plugins section of the ALSA wiki.

Configuration
ALSA will for most single card users work out-of-the-box. If not, the following section might help.

alsaconf
The tool (part of ) is probably the easiest way to configure your sound devices. It will try to detect your sound cards and then update v accordingly. So run as root:

Permissions
Users who want to have access to the sound card need to be in the audio group.

Replace   with the user you wish to grant access. If you are adding your user to the group, remember that you must log out and back in again before the changes will take effect.

Mixer
Most window managers have a mixer which interfaces directly with ALSA. Alternatively you can use alsamixer. If you only have one sound card:

To unmute channels use the key.

If multiple:

ALSA sound cards start with 0, so 0 is the first card, 1 is the second card, etc.

Default Sound Device
If you have several sound devices you might want to set one as the default. Start with finding the (ALSA-)name of the device you want to set using the command with the --list(list devices) argument. Note that output more than we need here, so we grep for cards:

In the following example we find a Intel card and a SoundBlaster Live! card: card 0: Live [SB Live! 5.1], device 0: emu10k1 [ADC Capture/Standard PCM Playback] card 0: Live [SB Live! 5.1], device 2: emu10k1 efx [Multichannel Capture/PT Playback] card 0: Live [SB Live! 5.1], device 3: emu10k1 [Multichannel Playback] card 2: nForce2 [NVidia nForce2], device 0: Intel ICH [NVidia nForce2] card 2: nForce2 [NVidia nForce2], device 2: Intel ICH - IEC958 [NVidia nForce2 - IEC958] Don't mind that cards appear more than once here, we are just after the names, being in this case, marked bold in the example above, Live and nForce2. Now open and add:

This sets the PCM and mixer devices of the SoundBlaster Live! card as the defaults. You'll need to restart any applications using ALSA for playback for this to take effect.

MIDI for Soundblaster Live! and Audigy
This section assumes you have audio working using the emu10k1 alsa module. First you need to grab one or more soundfonts. They are suffixed with, and may be compressed using a special lossless compression tool. Soundfonts can conveniently be found, gzipped, at here.

Install awesfx, a tool to load the soundfont(s):

To load soundfonts, use the command:

If you have more than one, add additional sound fonts with the -N option:

To see what ports you've got for midi, run with the  switch:

Port   Client name                      Port name 20:0   SB Live! 5.1                    EMU10K1 MPU-401 (UART) 21:0   Emu10k1 WaveTable                Emu10k1 Port 0 21:1   Emu10k1 WaveTable                Emu10k1 Port 1 21:2   Emu10k1 WaveTable                Emu10k1 Port 2 21:3   Emu10k1 WaveTable                Emu10k1 Port 3 In this case the ports are 21:0 - 21:3. Theres also 20:0, but that is just a pass through to an external port that you probably don't have. Export these ports:

Playing music should now work:

If it works as it should, all that's left is to automate the process. It would probably be best to make a new rc script in : Here are working examples of and :

ALSA