Jack, PulseAudio and Reaper DAW

In this article I want to show up how you can make Reaper going on Linux with audio, MIDI and cooperating with PulseAudio. This means, no other applications like Firefox or VLC stuck while using Reaper or your preferred digital audio workstation (DAW).

Assumptions

  • We use any flavor of Linux, in this case Manjaro.
  • We are using Jack2, not Jack (this is default on Manjaro)
  • As long Jack2 is running, we want to route all normal linux audio through Jack, so that we do not get stuck with other applications.
  • If we stop Jack2 we want the get the old configuration back
  • We want to be in control and don’t trust our daemons to communicate to each other via D-BUS what device is available or suspended — never trust daemons! :-)

Linux System Preparation

For our audio workstation needs we first have to tune our Linux system a bit.

Let’s create an “audio” group and put our current user in it:

sudo groupadd audio
sudo usermod -a -G audio $USER

Now that this group exists we can configure some process and memory settings so that our music processes are privileged:

As root in /etc/security/limits.d we add a file 10-audio.conf, like this:

# domain type item value
@audio - rtprio 95
@audio - memlock unlimited
@audio  - nice   -19

Now restart your system!

If we now log in with our user from above then ulimit -l should give unlimited. So now we get the system resources we need.

Install QJackctl, Jack2 and a2jmidid

We want to get full control over Jack2. QJackCtl is a graphical interface where we also can use scripts to start and stop other programs around Jack2 itself.

On Manjaro and Arch Linux this would be:

sudo pacman -S jack2 pulseaudio-alsa a2jmidid qjackctl

For Ubuntu and Debian it may be something like:

sudo apt install jackd2 pulseaudio-module-jack  a2jmidid qjackctl 

Btw, the jack2 process will be seen as jackdbus in the process list.

Helper Scripts

Create a directory and put the following four files into it — I’d suggest creating a bin directory in your home folder:

mkdir -p ~/bin
cd ~/bin

Now put the following four scripts into it. These manages the other midi and audio daemons around Jack2:

The script jack-start-pre.sh is defining which devices we use with Jack2 and tells our pulseaudio system not to use these up to now.

Attention! This script needs to be adapted.

First you need to run

pactl list short sinks

and

pactl list short sources

to find out, which sinks and sources you have and how their names are. Then you need to decide which of these you want to use exclusively with Jack2.

Below you see my configuration, a cheap usb audio interface.

#!/bin/bash

# Configured sink and source to be used with Jack
SINK='alsa_output.usb-GeneralPlus_USB_Audio_Device-00.analog-stereo'
SOURCE='alsa_input.usb-GeneralPlus_USB_Audio_Device-00.mono-fallback'

# Suspend just the devices we want to use with Jack
pacmd suspend-sink $SINK true
pacmd suspend-sink $SOURCE true

The script jack-start-post.sh loads the modules pulseaudio needs to use Jack2 as input and output and tells pulseaudio which devices to use therefor.

Additionally we start another midi bridge daemon which makes alsa midi devices available to Jack2. This is, because Jack2 has no own midi support. So we need this bridge.

#!/bin/bash
pactl load-module module-jack-sink channels=2
pactl load-module module-jack-source channels=2
pacmd set-default-sink jack_out
pacmd set-default-source jack_in

# Since Jack2 has no own MIDI support, so we need this bridge
a2jmidid -e &

The script jack-stop-pre.sh is run before we may stop jack2. It tells pulseaudio not to use jack any longer.

#!/bin/bash
pactl unload-module module-jack-sink
pactl unload-module module-jack-source
sleep 3

The script jack-stop-post.sh tells pulseaudio to unsuspend all devices, which had been used by jack.

#!/bin/bash
pacmd suspend false

Jack2 Configuration

Now start QJackCtl and do the following settings, For the interface choose the one used in the script above:

Setup🠺Settings🠺Parameters🠺Driver: alsa
Setup🠺Settings🠺Parameters🠺Interface: hw:Device 
Setup🠺Settings🠺Parameters🠺Midi Driver: none
Setup🠺Settings🠺Parameters🠺Realtime: checked

The following settings are dependent on the power of your hardware, my settings are:

Setup🠺Settings🠺Parameters🠺Sample Rate: 48000
Setup🠺Settings🠺Parameters🠺Frames/Period: 256
Setup🠺Settings🠺Parameters🠺Periods/Buffer: 2

This gives a latency of about 10 msec for me. If you have a not that powerful system you could decrease the sample rate, if a bigger buffer or higher count of frames result in a too high latency.

Anyways, latency may be no problem for you if you do no audio recording. But if you play on your midi keyboard it may disturb you if you press a key and you feel the sound is not in sync.

Setup🠺Settings🠺Advanced🠺Audio: Duplex 
Setup🠺Settings🠺Advanced🠺Output Device: (default) 
Setup🠺Settings🠺Advanced🠺Input Device: (default)

I assume that you use the same audio interface for input and output. If this is not the case you can set

Setup🠺Settings🠺Parameters🠺Interface: (default)

and choose input and output devices like you want.

Now we set up QJackCtl to use our scripts for starting and stopping. Replace martin with your own user name.

Setup🠺Options🠺Execute script on Startup:  /home/martin/bin/jack-start-pre.sh
Setup🠺Options🠺Execute script after Startup: /home/martin/bin/jack-start-post.sh
Setup🠺Options🠺Execute script on Shutdown: /home/martin/bin/jack-stop-pre.sh
Setup🠺Options🠺Execute script after Shutdown: /home/martin/bin/jack-stop-post.sh

Now we switch off D-Bus support since we want to handle the things ourselves. We also don’t need ALSA sequencer support.

Setup🠺Misc🠺Enable D-Bus interface: no
Setup🠺Misc🠺Enable Jack D-Bus interface: no
Setup🠺Misc🠺Enable ALSA Sequencer support: no

Installing Reaper

I like Reaper pretty much. But if you want to make use of another DAW the settings above will also work for you.

On Manjaro you can install Reaper from AUR. For other Linux distributions it may be different. You can download a generic version here.

Connect your Midi keyboard, if available.

In Reaper now set

Menu🠺Options🠺Preferences🠺Audio🠺Device🠺Audio System: Jack

Then click on

Menu🠺Options🠺Preferences🠺Audio🠺Midi Devices🠺Reset all Midi Devices

If you have a midi controller connected it should now show up in the MIDI inputs list. Voila!

You can now right-click it and enable it for input and control messages, if you like.

Further configuration tips for Reaper and more can be seen in the great videos by Kenny Gioia.

More Plugins for your DAW

This is the great thing about open source software: There are so many free synthesizers and other plugins you can now use with your DAW of choice. Here is a selection used by unfa, many thanks to him and all the people promoting and helping us with open source music production.

From the normal Manjaro you can install these:

sudo pacman -S calf caps carla dpf-plugins dragonfly-reverb \
  drumgizmo ebumeter eq10q geonkick guitarix helm-synth ir.lv2 liquidsfz \
  lsp-plugins mda.lv2 ninjas2 noise-repellent samplv1 setbfree sherlock.lv2 \
  sonic-visualiser swh-plugins tap-plugins wolf-shaper wolf-spectrum \
  x42-plugins zam-plugins zita-ajbridge zita-rev1

Additionally you can add some from the AUR:

  • surge-synthesizer-bin
  • zyn-fusion
  • bitrot-git
  • invada-studio-plugins-lv2
  • tal-plugins

Thanks to unfa and Blakely North for these suggestions.

Conclusion

I sat there now for more than 4 days, trying to get this stuff running. I have to say, that Jack, Jack2, PulseAudio, the audio and midi bridges and all the stuff seems to be a mess for me like it is now. All the parts for themselves are great, but they do not work together, you more or less have to force them to do so.

If we want a normal human being to produce music on linux, the normal system needs to be preconfigured so that each part of software works flawlessly together with the rest.

To be honest: If you use Windows, you also have to install some ASIO stuff and you can get in resource conflicts. But on Linux especially the cooperation between PulseAudio, Jack2 and the stuff around you need, like the different audio or video bridges — this could be a lot easier. As unfa says: There is always progress in the land of open source. So let’s see, what the future will bring us.

I failed with

  • Taking my Linux, install the software and have just fun
  • Trying to use Cadence and let Jack2 and PulseAudio just communicate via D-BUS
  • Settings with dedicated input and output devices in QJackCtl. Although, it worked when not setting devices explicitely and just set the audio interface.
  • Changing from Jack2 to Jack. Half of my system incl. Firefox had been deinstalled because of dependencies. Hell, if Jack is used so seldom, why does so many software depend on it?!?

Many thanks at last to the people writing the Arch Wiki, unfa for his great helpful videos on Youtube and all the other brave people from all over the web.

Some links I found helpful on my journey:

Digital Audio Workstations running on Linux natively

  • LMMS — arranging samples, synthesizing sounds, playing on a MIDI keyboard, and combining the features of trackers and sequencers
  • Ardour — record, edit, and mix on Linux, macOS and Windows
  • Qtractor — an Audio/MIDI multi-track sequencer
  • seq24 — live looping with Linux
  • SuperBoucle — also live looping on Linux and Windows

Commercial, pay what you want or non open source

  • Reaper — a complete digital audio production application for computers, offering a full multitrack audio and MIDI recording, editing, processing, mixing and mastering toolset
  • Zrythm — a highly automated and intuitive digital audio workstation
  • Sunvox — a small, fast and powerful modular synthesizer with pattern-based sequencer (tracker)