|
|
(3 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| {{Outdated|needs cleanup}}
| | #REDIRECT [[JACK]] |
| [http://jackaudio.org The Jack Audio Connection Kit] is used by most of the serious audio applications on Linux. It provides real-time, low latency connections for both audio and MIDI data between applications that implement its API. NixOS uses the dbus version of JACK2 (jackdbus). This can be used together with pulseaudio with a little configuration. The result is that you don't have to manually hunt down applications which are using the sound device and kill them before starting JACK. You can also continue to use non-JACK aware applications (e.g. flash) at the same time as using JACK applications (e.g. Ardour).
| |
| | |
| # Load the sequencer and midi kernel modules
| |
| #: boot.kernelModules = [ "snd-seq" "snd-rawmidi" ];
| |
| #Enable JACK support
| |
| #: In your configuration file:
| |
| #: <syntaxhighlight lang="nix" >hardware.pulseaudio.package = pkgs.pulseaudio.override { jackaudioSupport = true; };</syntaxhighlight>
| |
| # Ensure that the JACK enabled pulseaudio is being used
| |
| #: ~/.config/pulse/client.conf
| |
| #: <pre>daemon-binary=/var/run/current-system/sw/bin/pulseaudio</pre>
| |
| # Configure QjackCtl
| |
| ## Enable jackdbus | |
| ##: Setup -> Settings -> Server Path: jackdbus
| |
| ##: [[File:qjackctl-settings.png]]
| |
| ##: Setup -> Misc -> Enable D-Bus interface: check
| |
| ##: [[File:qjackctl-misc.png]]
| |
| ## Load the jack modules for pulseaudio after starting jackdbus
| |
| ##: Setup -> Settings -> Options -> Execute script after Startup: check
| |
| ##: <pre>pactl load-module module-jack-sink channels=2; pactl load-module module-jack-source channels=2; pacmd set-default-sink jack_out</pre>
| |
| ##: Setup -> Settings -> Options -> Execute script on Shutdown: check
| |
| ##: <pre>pactl unload-module `pactl list|grep -A 3 jack-source|tail -1|awk '{ print $NF }'`;pactl unload-module `pactl list|grep -A 3 jack-sink|tail -1|awk '{ print $NF }'`</pre>
| |
| ##: [[File:qjackctl-options.png]]
| |
| | |
| You should now be able to start JACK with QjackCtl, you will notice a new playback and capture device in your sound mixer along with your normal devices.
| |
| | |
| [[File:kmix-pulseaudio-with-jack.png]]
| |
| | |
| ==== Troubleshooting JACK and PulseAudio ====
| |
| | |
| <pre>$ pactl load-module module-jack-sink channels=2
| |
| Failure: Module initalization failed</pre>
| |
| | |
| Check if you have previous settings in ~/.config/jack/conf.xml. Try renaming this file and running the pactl command again.
| |
| | |
| Otherwise, you may get further info by disabling PulseAudio respawning (see above) and starting it in verbose mode:
| |
| | |
| <syntaxhighlight lang="console">$ pulseaudio -vvv</syntaxhighlight>
| |
| | |
| === System optimizations for low latency audio with JACK ===
| |
| | |
| Some of the following settings, documented in http://wiki.linuxmusicians.com/doku.php?id=system_configuration and https://wiki.archlinux.org/index.php/Pro_Audio can be very helpful to reduce xruns and improve responsiveness and are required for certain programs to run at all e.g. Ardour.
| |
| The kernelPackages section was taken from https://github.com/rockfabrik/deployment/blob/master/modules/profiles/dj.nix#L32
| |
| | |
| An easy way of setting all of these, plus a true realtime kernel, is here:
| |
| 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 {
| |
| extraConfig = ''
| |
| PREEMPT_RT_FULL? y
| |
| PREEMPT y
| |
| IOSCHED_DEADLINE y
| |
| DEFAULT_DEADLINE y
| |
| DEFAULT_IOSCHED "deadline"
| |
| HPET_TIMER y
| |
| CPU_FREQ n
| |
| TREE_RCU_TRACE n
| |
| '';
| |
| }) 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>
| |