ALSA: Difference between revisions
imported>Mic92 fix markup |
m Cleaned up tone somewhat, however this page likely could do with a cleanup and reformating Tags: Mobile edit Mobile web edit Advanced mobile edit Visual edit |
||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
{{ | {{Cleanup}} | ||
ALSA is the kernel-level sound API for Linux. On modern systems, it is usually used via a sound server like [[PulseAudio]]. | ALSA is the kernel-level sound API for Linux. On modern systems, it is usually used via a sound server like [[PulseAudio]]. | ||
| Line 6: | Line 7: | ||
In order to save the sound card state on shutdown sound must be enabled in <code>configuration.nix</code> | In order to save the sound card state on shutdown sound must be enabled in <code>configuration.nix</code> | ||
< | <syntaxhighlight lang="nix"> | ||
hardware.alsa.enablePersistence = true; | |||
</ | </syntaxhighlight> | ||
==Troubleshooting ALSA== | ==Troubleshooting ALSA== | ||
* on a console | * on a console launch [[wikipedia:Alsamixer|alsamixer]]. | ||
alsamixer | alsamixer | ||
* you see plenty of vertical bars | * If you see plenty of vertical bars: | ||
** | ** You should be okay | ||
* you see very few vertical bars and the sound card (top-left) is | * If you see very few vertical bars and the sound card (top-left) is "PC Speaker" or similar: | ||
** | ** Hit the 'S' key, you should be able to switch to the "real" audio card (if not your audio card is likely to not being supported yet). | ||
** | ** When the real audio card is selected you should be viewing the "plenty vertical bars" thing. | ||
*** | *** First thing to do is to disable PC speaker (kernel module "snd-pcsp", see below. | ||
=== Make your audio card the default ALSA card === | === Make your audio card the default ALSA card === | ||
Occasionally the PC-speaker is the default audio card for ALSA. You can make your real sound card default instead. For example, if your sound card is "hda-intel" then you would add the following to your configuration. | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
boot.extraModprobeConfig = '' | boot.extraModprobeConfig = '' | ||
options snd slots=snd-hda-intel | options snd slots=snd-hda-intel | ||
''; | ''; | ||
</syntaxHighlight> | </syntaxHighlight>At times, you may wish to disable one of multiple Intel cards. Here is how to disable the first card, but enable a second one. | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
boot.extraModprobeConfig = '' | boot.extraModprobeConfig = '' | ||
| Line 41: | Line 38: | ||
''; | ''; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
=== Disable PC Speaker "audio card" === | === Disable PC Speaker "audio card" === | ||
Add "snd_pcsp" to the <code>boot.blacklistedKernelModules</code> option: | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
| Line 56: | Line 51: | ||
=== Other hardware specific problems === | === Other hardware specific problems === | ||
Some hardware specific problems can be resolved by adjusting the options for the sound module. For example, the microphone may be stuck on | Some hardware specific problems can be resolved by adjusting the options for the sound module. For example, the microphone may be stuck on a very low volume. First you should be sure that you have already checked the settings in alsamixer to make sure nothing is muted, and also any physical buttons on your computer. | ||
You should be able to look up the available options for | You should be able to look up the available options for model in [https://www.kernel.org/doc/Documentation/sound/hd-audio/models.rst models.rst]. You can try them out interactively as follows: | ||
# Close any applications using the sound card | # Close any applications using the sound card | ||
## See if any applications are using the sound card | ## See if any applications are using the sound card | ||
##: $ lsof /dev/snd/* | ##: {{Code|$ lsof /dev/snd/* | ||
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME | |||
pulseaudi 14080 goibhniu 30u CHR 116,7 0t0 5169 /dev/snd/controlC0 | |||
## Kill | pulseaudi 14080 goibhniu 37u CHR 116,7 0t0 5169 /dev/snd/controlC0|lang=console|line=no}} | ||
## Kill any processes | |||
##: for any process apart from pulseaudio you could just do: | ##: for any process apart from pulseaudio you could just do: | ||
##: $ kill -9 14080 | ##: $ kill -9 14080 | ||
##: but in the case of pulseaudio you have to prevent it from respawning itself automatically | ##: but in the case of pulseaudio you have to prevent it from respawning itself automatically | ||
##: $ | ##: $ systemctl --user mask pulseaudio.socket && systemctl --user stop pulseaudio | ||
##: you can then stop pulseaudio with: | ##: you can then stop pulseaudio with: | ||
##: $ pulseaudio -k # or kill it by process id | ##: $ pulseaudio -k # or kill it by process id | ||
| Line 83: | Line 79: | ||
# Repeat until you have exhausted all the options or have fixed your problem | # Repeat until you have exhausted all the options or have fixed your problem | ||
# TIDY UP! | # TIDY UP! | ||
#: Don't forget to re-enable pulse autospawning | #: Don't forget to re-enable pulse autospawning: systemctl --user unmask pulseaudio.socket | ||
Once you have found a setting that works, you can add it to your configuration file: | Once you have found a setting that works, you can add it to your configuration file: | ||
| Line 92: | Line 88: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
[[Category:Audio]] | |||