ALSA

From Alpine Linux
Revision as of 16:59, 21 August 2025 by Prabuanand (talk | contribs) (rewrote for consistency)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Advanced Linux Sound Architecture (ALSA) provides audio and MIDI functionality to the Linux operating system. As part of the Linux kernel, it provides an application programming interface (API) for sound card device drivers.

Installation

First you will need to install the Alsa packages, Linux sound driver and volume adjuster:

# apk add alsa-utils alsaconf

Configuration

Then you will need to add all your users (including root) to the audio group.

# addgroup $USER audio # addgroup root audio

Find the default sound card.:

# alsamixer

The default sound card will show up. Try turning up the volume of Master and the device(s) such as speakers or microphones that you need, and audio should work (F1 - help, M - toggle mute, ...)

If there are no volume controls visible, try hitting F6 on your keyboard and toggling between the sound cards (which all might have the same name in the context menu that pops up except for the numbers next to and before the names).

Once you've found the sound card name that gives you volume controls, set the unique number that showed up in the F6 context menu as your default soundcard.

Put the number (you found in the F6 context menu of the alsamixer command for the soundcard you want as your default) at the end of below lines separated by a space for each. For example, if the default sound card you want is "1".

Use your favourite editor to edit the ~/.asoundrc file as follows:

Contents of ~/.asoundrc

defaults.ctl.card 1 defaults.pcm.card 1

The ~/.asoundrc file installed in a user's home directory($HOME) is called from /usr/share/alsa/alsa.conf. It is also possible to install the above in a system-wide configuration file as /etc/asound.conf. When an ALSA application starts both configuration files are read but the settings in the ~/.asoundrc file override the settings in the /etc/asound.conf settings.

Most programs require a restart to reread ~/.asoundrc or /etc/asound.conf. This includes desktop environment audio daemons, such as PulseAudio. For most changes, you will need to restart the sound server.

Try turning up the volume of Master and the device(s) such as speakers or microphones that you need with the alsamixer command, and audio should work.

Gstreamer can now catch the device once the service is started and the audio mixer will be working.

Service management

Use standard start|stop|restart OpenRC commands to manage alsa service.

Note that alsa service is not started on install. To start, issue the command:

# rc-service alsa start

To enable the Alsa user service, issue the command:

# rc-update add alsa

Troubleshooting

To list all the detected sound cards and their assigned numbers, use the command:

$ cat /proc/asound/cards

See also