Introduction
We want to achieve the following: ALSA -> Pulse audio -> JACK
Packages
Install jack (JACK 1), pulseaudio and alsa (and alsa-utils)
Security limits
Add this to the services section of /etc/config.scm and make sure that the user is in the audio group
(pam-limits-service
(list
(pam-limits-entry "@audio" 'both 'rtprio 99)
(pam-limits-entry "@audio" 'both 'memlock 'unlimited))))
This will allow JACK to be run with real time privileges and lock down unlimited memory
ALSA
No special configuration is needed. The alsa service (included by default in the desktop services) routes to Pulse audio by default
Pulse audio
The default configuration had problems with bluetooth, so I copied it and commented the bluetooth part out. Copy ~/.guix-profile/etc/pulse/default.pa to ~/.pulse/default.pa. This will override the system version. Next, comment out these lines
### Automatically load driver modules for Bluetooth hardware
#.ifexists module-bluetooth-policy.so
#load-module module-bluetooth-policy
#.endif
#.ifexists module-bluetooth-discover.so
#load-module module-bluetooth-discover
#.endif
JACK
Make sure that JACK 1 (not 2) is installed. Also install qjackctl. Copy pajackconnect from https://github.com/brummer10/pajackconnect to ~/bin/pajackconnect (or anywhere else) and change the shebang (first line) from bash to sh.
Next, go to Setup -> Options in Qjackctl and add the following in Scripting
- Execute script after Startup: <absolute path to pajackconnect> start &
- Execute script on Shutdown: <absolute path to pajackconnect> stop &
- Execute script after Shutdown: <absolute path to pajackconnect> reset &
Now we can test this setup by starting Pulse audio (just type pulseaudio in a terminal) and then running Qjackctl.
Auto-connecting on Startup
To start pulseaudio and launch Qjackctl automatically on startup, create the following script
#!/usr/bin/env bash
pulseaudio &
sleep 6
qjackctl --start
and add an entry for it in ~/.config/autostart/run_pulse_and_jack.desktop
[Desktop Entry]
Name=Pro-Audio
GenericName=Pro Audio Bootstrap
Comment=Starts pulse and routes it to jack
Exec=/home/alex/bin/start_pulse_and_jack.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
Now every time we log in pulse audio and JACK will start automatically and we will be ready to go
Alternative option: ALSA to JACK
For direcly routing ALSA to JACK, Guix provides this .asoundrc that you can use (copy to ~/.asoundrc). This will override the system ALSA configuration and cause ALSA to give its device to JACK.
# In guix, we have to specify the absolute path for plugins.
pcm_type.jack {
lib "/home/alex/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
}
# Routing ALSA to jack:
# <http://jackaudio.org/faq/routing_alsa.html>.
pcm.rawjack {
type jack
playback_ports {
0 system:playback_1
1 system:playback_2
}
capture_ports {
0 system:capture_1
1 system:capture_2
}
}
pcm.!default {
type plug
slave {
pcm "rawjack"
}
}