Audio: Difference between revisions
imported>Mic92 m Mic92 moved page Audio HOWTO to Audio |
imported>Mic92 No edit summary |
||
| Line 16: | Line 16: | ||
Sometimes 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 add | Sometimes 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 add | ||
< | <syntaxHighlight lang="nix"> | ||
boot.extraModprobeConfig = '' | |||
options snd slots=snd-hda-intel | |||
''; | |||
</ | </syntaxHighlight> | ||
to your <code>/etc/nixos/configuration.nix</code>. | to your <code>/etc/nixos/configuration.nix</code>. | ||
Sometimes, we may want to disable one of intel cards. Here is how to disable first card, but enable the second one. | Sometimes, we may want to disable one of intel cards. Here is how to disable first card, but enable the second one. | ||
< | <syntaxHighlight lang="nix"> | ||
boot.extraModprobeConfig = '' | |||
options snd_hda_intel enable=0,1 | |||
''; | |||
</ | </syntaxHighlight> | ||
Alternatively you can ... | Alternatively you can ... | ||
| Line 36: | Line 36: | ||
edit <code>/etc/nixos/configuration.nix</code> and add "snd_pcsp" to <code>boot.blacklistedKernelModules</code> option: | edit <code>/etc/nixos/configuration.nix</code> and add "snd_pcsp" to <code>boot.blacklistedKernelModules</code> option: | ||
<syntaxHighlight lang="nix"> | |||
boot.blacklistedKernelModules = [ "snd_pcsp" ]; | |||
</syntaxHighlight> | |||
Now reboot and retry from the beginning (i.e. check that your real card is shown by alsamixer without using the 'S' key). | Now reboot and retry from the beginning (i.e. check that your real card is shown by alsamixer without using the 'S' key). | ||
| Line 72: | Line 74: | ||
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: | ||
< | <syntaxHighlight lang="nix"> | ||
boot.extraModprobeConfig = '' | |||
options snd-hda-intel model=YOUR_MODEL | |||
''; | |||
</ | </syntaxHighlight> | ||
Much of this is taken from https://help.ubuntu.com/community/HdaIntelSoundHowto which also has additional tips. | Much of this is taken from https://help.ubuntu.com/community/HdaIntelSoundHowto which also has additional tips. | ||
| Line 83: | Line 85: | ||
In your config file: | In your config file: | ||
< | <syntaxHighlight lang="nix">hardware.pulseaudio.enable = true</syntaxHighlight> | ||
You can check if everything works by using pavucontrol to see the audio streams and to make sure that PulseAudio detects your audio hardware. | You can check if everything works by using pavucontrol to see the audio streams and to make sure that PulseAudio detects your audio hardware. | ||
| Line 90: | Line 92: | ||
You may need to add your users to the audio group: | You may need to add your users to the audio group: | ||
< | <syntaxHighlight lang="bash"> | ||
usermod -a -G audio myusername | |||
</ | </syntaxHighlight> | ||
If a user is not a member the audio group only a dummy device will appear in pavucontrol. | If a user is not a member the audio group only a dummy device will appear in pavucontrol. | ||
The following command should only show that pulseaudio (and nothing else) is using the sound devices, if you see something like "plugin-container" in the COMMAND column then something is definitely not right, perhaps you have a local ~/.asoundrc which overrides the global alsa settings?. | The following command should only show that pulseaudio (and nothing else) is using the sound devices, if you see something like "plugin-container" in the COMMAND column then something is definitely not right, perhaps you have a local ~/.asoundrc which overrides the global alsa settings?. | ||
< | <syntaxHighlight lang="bash"> | ||
$ 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 | |||
pulseaudi 14080 goibhniu 37u CHR 116,7 0t0 5169 /dev/snd/controlC0 | |||
</ | </syntaxHighlight> | ||
=== Using JACK with PulseAudio === | === Using JACK with PulseAudio === | ||
| Line 151: | Line 153: | ||
https://github.com/musnix/musnix | https://github.com/musnix/musnix | ||
< | <syntaxHighlight lang="nix"> | ||
boot = { | |||
kernelModules = [ "snd-seq" "snd-rawmidi" ]; | |||
kernel.sysctl = { "vm.swappiness" = 10; "fs.inotify.max_user_watches" = 524288; }; | |||
kernelParams = [ "threadirq" ]; | |||
kernelPackages = let | |||
rtKernel = pkgs.linuxPackagesFor (pkgs.linux.override { | rtKernel = pkgs.linuxPackagesFor (pkgs.linux.override { | ||
extraConfig = '' | extraConfig = '' | ||
| Line 169: | Line 171: | ||
''; | ''; | ||
}) pkgs.linuxPackages; | }) pkgs.linuxPackages; | ||
in rtKernel; | |||
postBootCommands = '' | |||
echo 2048 > /sys/class/rtc/rtc0/max_user_freq | |||
echo 2048 > /proc/sys/dev/hpet/max-user-freq | |||
setpci -v -d *:* latency_timer=b0 | |||
setpci -v -s $00:1b.0 latency_timer=ff | |||
''; | |||
# The SOUND_CARD_PCI_ID can be obtained like so: | |||
# $ lspci ¦ grep -i audio | |||
}; | |||
powerManagement.cpuFreqGovernor = "performance"; | |||
fileSystems."/" = { options = "noatime errors=remount-ro"; }; | |||
security.pam.loginLimits = [ | |||
{ domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; } | |||
{ domain = "@audio"; item = "rtprio"; type = "-"; value = "99"; } | |||
{ domain = "@audio"; item = "nofile"; type = "soft"; value = "99999"; } | |||
{ domain = "@audio"; item = "nofile"; type = "hard"; value = "99999"; } | |||
]; | |||
services = { | |||
udev = { | |||
packages = [ pkgs.ffado ]; # If you have a FireWire audio interface | |||
extraRules = '' | |||
KERNEL=="rtc0", GROUP="audio" | |||
KERNEL=="hpet", GROUP="audio" | |||
''; | |||
}; | }; | ||
cron.enable =false; | |||
}; | |||
shellInit = '' | |||
export VST_PATH=/nix/var/nix/profiles/default/lib/vst:/var/run/current-system/sw/lib/vst:~/.vst | |||
export LXVST_PATH=/nix/var/nix/profiles/default/lib/lxvst:/var/run/current-system/sw/lib/lxvst:~/.lxvst | |||
export LADSPA_PATH=/nix/var/nix/profiles/default/lib/ladspa:/var/run/current-system/sw/lib/ladspa:~/.ladspa | |||
export LV2_PATH=/nix/var/nix/profiles/default/lib/lv2:/var/run/current-system/sw/lib/lv2:~/.lv2 | |||
export DSSI_PATH=/nix/var/nix/profiles/default/lib/dssi:/var/run/current-system/sw/lib/dssi:~/.dssi | |||
''; | |||
users = { | |||
extraUsers.yourname= { | |||
extraGroups = [ "wheel" "audio" ]; | |||
}; | }; | ||
}; | |||
</ | </syntaxHighlight> | ||