ALSA: Difference between revisions

From Alpine Linux
mNo edit summary
m (rewrote for consistency)
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== Install ==
[https://en.wikipedia.org/wiki/Advanced_Linux_Sound_Architecture 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.


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


# apk add alsa-utils alsa-utils-doc alsa-lib alsaconf
First you will need to install the Alsa packages, Linux sound driver and volume adjuster: {{Cmd|# apk add {{pkg|alsa-utils}} {{pkg|alsaconf}}}}


== Setup ==
== Configuration ==


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


# addgroup $USER audio
{{Cmd|<nowiki># addgroup $USER audio
# addgroup root audio
# addgroup root audio
</nowiki>}}


Find the default sound card.
Find the default sound card.:  {{Cmd|# alsamixer}}


# 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 ({{Key|F1}} - help, {{Key|M}} - toggle mute, ...)


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 {{Key|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).


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 {{Key|F6}} context menu as your default soundcard.


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


# nano /usr/share/alsa/alsa.conf
Use your favourite editor to edit the {{Path|~/.asoundrc}} file as follows:{{Cat|~/.asoundrc|defaults.ctl.card 1
defaults.pcm.card 1
}}


Scroll down until you find the lines that start with <code>defaults.ctl.card</code> and <code>defaults.pcm.card</code> and 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 those lines separated by a space for each. For example, if the default sound card you want is "1".
The {{Path|~/.asoundrc}} file installed in a user's home directory($HOME) is called from {{Path|/usr/share/alsa/alsa.conf}}. It is also possible to install the above in a system-wide configuration file as {{Path|/etc/asound.conf}}. When an ALSA application starts both configuration files are read but the settings in the {{Path|~/.asoundrc}} file override the settings in the {{Path|/etc/asound.conf}} settings.


<code>defaults.ctl.card 1</code>
Most programs require a restart to reread {{Path|~/.asoundrc}} or {{Path|/etc/asound.conf}}. This includes desktop environment audio daemons, such as [[PulseAudio]]. For most changes, you will need to restart the sound server.  
<code>defaults.pcm.card 1</code>


Save your nano work by pressing ''Ctrl+O'' and confirm the changes by pressing ''Enter''. Then exit nano by pressing ''Ctrl+X''.
Try turning up the volume of Master and the device(s) such as speakers or microphones that you need with the <code>alsamixer</code> command, and audio should work.
 
Gstreamer can now catch the device once the [[#Service management|service is started]] and the audio mixer will be working.
 
=== Service management ===
 
Use standard start|stop|restart [[OpenRC]] commands to manage {{ic|alsa}} service.
Note that {{ic|alsa}} service is not started on install. To start, issue the command:{{Cmd|# rc-service alsa start}}
To enable the Alsa user service, issue the command:{{Cmd|# rc-update add alsa}}


Try turning up the volume of Master and the device(s) such as speakers or microphones that you need with the <code>alsamixer</code> command, and audio should work.
== Troubleshooting ==
 
To list all the detected sound cards and their assigned numbers, use the command:{{Cmd|$ cat /proc/asound/cards}}


Alsa service is not started on install, you need to start it and to add it on rc.
== See also ==
rc-service alsa start
rc-update add alsa


Gstreamer can now catch the device and the audio mixer is working.
* [https://www.alsa-project.org/wiki/Main_Page Official website]
* [https://alsa.opensrc.org/ Unofficial alsa wiki]
* [[Sound_Setup|Main page for Sound Setup]]


[[Category:Installation]]
[[Category:Desktop]]
[[Category:Multimedia]]
[[Category:Sound]]
[[Category:Sound]]
[[Category:Drivers]]

Latest revision as of 16:59, 21 August 2025

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