The below guide has been superceded by https://uzebox.org/wiki/Linux_audio_and_JACK_cheatsheet since I gained wiki access.
JACK can be thought of as a highly configurable audio mixer for Linux and other platforms. JACK is a program and API that enables you to route audio in realtime between different JACK-aware apps such as DAWs, softsynths, sequencers etc.
Most of the trouble with JACK is simply getting the JACK audio server to run. Once the JACK server is running, using JACK is as simple as using a patchbay to connect audio inputs and outputs.
Pipewire is the latest tech in Linux audio and offers JACK support. Pipewire solves the issue of using pulseaudio and ALSA only apps alongside JACK apps but it made my system very unstable when I was testing the Debian testing version of pipewire a few months ago so I recommend using traditional JACK until Pipewire matures.
There are at least three ways to start and control JACK.
* Using the cli tools
* Using qjackctl
* Using Cadence and Catarina
As a dev, there are definitely times where you'd want to use the cli tools to start the JACK server or make connections between apps. Cadence and Catarina offer a couple of things that qjackctl does not but I personally prefer to use qjackctl if only because its in the Debian repos.
Install qjackctl
apt install qjackctl
Installing qjackctl will also install JACK2 if you've not already installed a version of JACK. You may be required to reboot after installing JACK so that the new system settings are applied re realtime settings.
Start qjackctl in your preferred manner.
The single most important setting in qjackctl / JACK is setting the correct audio device for JACK to use. Click on the Setup button in qjackctl then check which device is selected under Settings -> Parameters -> Interface
For the other main settings in that tab choose:
Driver: alsa
Realtime: checked/enabled
SampleRate: 48000
Frames/Period: 256, if 256 produces xruns, use 512 or 1024. The lower value you can use the better.
Periods/buffer: 3
MIDI driver: seq - this enables ALSA midi support. You don't need to set this if you're not using any (USB) MIDI hardware.
You should be ready to try starting JACK now. In the main qjackctl window, click the 'Start' button. If you have configured qjackctl correctly, you should see 'Started' printed in yellow text and a big row of green zeros representing the JACK transport time. Just to the left of the row of big green zeros is a smaller 0 or it should be zero. This is the xrun counter and you need to adjust your JACK settings if you get any xruns. You should get no xruns when not running any JACK apps. xruns cause momentary skips and breakups in the JACK audio output.
If JACK doesn't start, go back to the qjackctl settings and try using a different interface or try a larger Frames/Period setting.
Once JACK is running you can connect JACK apps to one another using the Graph or Patchbay windows of qjackctl. That should be self explanatory.
Note that Firefox, Chrome/chromium and most browsers under most distros don't have any JACK support. This is a problem solved by Pipewire and you may also be able to get the ALSA2JACK bridge to work if you use Cadence instead of qjackctl to start JACK.
My fave open source sequencers are qtractor and muse. For using MIDI soundfonts under qtractor there is the fluida LV2 plugin. muse has its own integrated soundfont plugin. Cadence, catarina and several other great softsynth plugins and Linux music apps can be easy installing by adding the KX studio repos, which work with both recent versions of Debian and Ubuntu for x86-64 and arm64.
https://kx.studio/Repositories
Also included in the kxstudio repos and of special note to us is Carla, a plugin host which we should be able to use to use UPS as a plugin when we've added JACK support to it.
https://kx.studio/Applications:Carla
If you want a simple LV2 sampler check out rncbc's samplv1
https://www.rncbc.org/drupal/#samplv1
You can use the linuxsampler lv2 plugin for a better sampler plugin.
There are several good softsynths for Linux but some notable ones are Surge, vcvrack / cardinal, helm, yoshimi and TAL noizemaker.
If you want more than what qtractor, muse and Ardour offer then I'd recommend REAPER which has free to use builds for both x64 and arm64 Linux and offers every option you could wish for including full JACK and LV2 plugin support.
https://www.reaper.fm/
If you have no objection to paying for your music production software you may also wish to check out Bitwig, which is quite similar to Ableton Live and offers a native Linux version.
If REAPER or even qtractor seem like overkill for your needs, maybe all you need to do is simple single file audio editing or you'd prefer to use a lightweight, simpler app then you should try mhwaveedit. If you prefer to use a tracker interface for composing music then you should look at Milkytracker, sunvox and renoise.
If you're not happy with any open source plugins or instruments, most Windows VST plugins can run fine under Linux via yabridge or Carla provided they don't rely on exotic protection mechanisms. You can just also run the Windows version of REAPER or your fave Windows-based DAW or music app under wine, the free MS Windows 'emulator' that lets you run most Windows software under Linux.
There are several Linux distros optimized for using JACK that include many of the above mentioned apps (and many more) that could provide better performance and/or an easier user experience than trying to configure the OS from scratch yourself. One of the more popular and well established AV content creation Linux distros being AV Linux, a derivative of Debian Linux.
https://www.bandshed.net/avlinux/
Linux audio and JACK cheatsheet
Linux audio and JACK cheatsheet
Last edited by danboid on Mon Jan 16, 2023 10:33 pm, edited 9 times in total.
Re: JACK and Linux audio cheatsheet
Great info thank you. This should be on the Wiki.
Re: JACK and Linux audio cheatsheet
Thanks for taking the time to write all that down!
I just tried it on a Debian 11 LiveUSB (not enabling realtime, because you can't reboot a LiveUSB) and I got qjackctl installed, and configured so the JACK server would start, and when I started Rosegarden, it connected itself, but I don't have any audio.
Pulseaudio was still running, so I uninstalled that, and killed it. Used alsamixer to make sure the volume on the interface I selected was turned up, and nothing was muted, but I still can't get any audio to play.
I just tried it on a Debian 11 LiveUSB (not enabling realtime, because you can't reboot a LiveUSB) and I got qjackctl installed, and configured so the JACK server would start, and when I started Rosegarden, it connected itself, but I don't have any audio.
Pulseaudio was still running, so I uninstalled that, and killed it. Used alsamixer to make sure the volume on the interface I selected was turned up, and nothing was muted, but I still can't get any audio to play.
Re: JACK and Linux audio cheatsheet
It's been a loooong time since I used rosegarden. As I said in my guide, I prefer qtractor and muse (or REAPER) for doing MIDI under Linux.
If I wanted to use a MIDI soundfont under any of the other Linux music apps, I'd use the fluidplug LV2 plugin but I don't think rosegarden has LV2 plugin support so you need to use fluidsynth (or qsynth) if you're not using hardware MIDI. That's the joy of plugins, they spare you having to launch external apps.
Looking at the man page for fluidsynth, I see it has a -a option to set the audio driver so you can try launching it with -a jack.
There was no need for you to remove pulseaudio. PA usually just becomes inactive whilst you're running JACK. I use PA except for when I running JACK apps.
The other option you have is using an ALSA2JACK bridge app like zita-ajbridge / zita-a2j which will allow fluidsynth to work if it doesn't support JACK natively but I'd encourage you to try one of the other sequencers that has better plugin support. Cadence has integrated support for setting up an ALSA/JACK bridge if you want to use that instead of qjackctl.
If I wanted to use a MIDI soundfont under any of the other Linux music apps, I'd use the fluidplug LV2 plugin but I don't think rosegarden has LV2 plugin support so you need to use fluidsynth (or qsynth) if you're not using hardware MIDI. That's the joy of plugins, they spare you having to launch external apps.
Looking at the man page for fluidsynth, I see it has a -a option to set the audio driver so you can try launching it with -a jack.
There was no need for you to remove pulseaudio. PA usually just becomes inactive whilst you're running JACK. I use PA except for when I running JACK apps.
The other option you have is using an ALSA2JACK bridge app like zita-ajbridge / zita-a2j which will allow fluidsynth to work if it doesn't support JACK natively but I'd encourage you to try one of the other sequencers that has better plugin support. Cadence has integrated support for setting up an ALSA/JACK bridge if you want to use that instead of qjackctl.
Re: JACK and Linux audio cheatsheet
It looks like timidity has JACK support if you run it with some different command line arguments. I tried that, and could see the qjackctl looking like it is working, and I could see in the connection graph that it had made all the right connections, I've just never gotten anything JACK related to actually play a sound. It works in ALSA mode though, so I don't know what's going on with JACK on my system.
Re: JACK and Linux audio cheatsheet
Did you notice this line in my guide:
Then, after starting, RG and timidity, check your midi tracks are routed to timidity and timidity's audio outputs are connected to the jack master output or else you'll hear nothing.
I'd recommend you try qtractor instead if only because it supports LV2 plugins. Plugins reduce the amount of issues you'll encounter routing audio and most plugins will "just work" without having to touch the jack patch bay.
timidity probably uses ALSA midi to communicate with Rosegarden so it probably won't work unless you have jack's midi driver configured correctly - set it to seq mode.MIDI driver: seq - this enables ALSA midi support. You don't need to set this if you're not using any (USB) MIDI hardware.
Then, after starting, RG and timidity, check your midi tracks are routed to timidity and timidity's audio outputs are connected to the jack master output or else you'll hear nothing.
I'd recommend you try qtractor instead if only because it supports LV2 plugins. Plugins reduce the amount of issues you'll encounter routing audio and most plugins will "just work" without having to touch the jack patch bay.
Re: JACK and Linux audio cheatsheet
I did notice that line, I don't have any MIDI hardware, so I didn't think to try it with timidity this time. Next time I give it a shot, I'll try that to see if it makes a difference. I see that JACK was receiving data, so I think it was routed properly. It might be that timidity required real time support, I'm not sure. It still works using ALSA for me though. Next time I'm on my desktop, I'll give qtractor a try. I have a bunch of Rosegarden projects though, and I'm familiar with it, but no harm in trying something new!
Re: JACK and Linux audio cheatsheet
There is another option for RG but I've not tried it. RG doesn't support LV2 plugins but it does support DSSI plugins and there is a fluidsynth-dssi plugin in the Debian repos. That may be easier to work with than using timidity as an external app.
calf-plugins contains a fluidsynth LV2 plugin but it seems to be broke under Debian testing/qtractor, the GUI is drawn much too big and it crashes when you open it so forget about that.
I've updated the guide to mention that muse has its own integrated soundfont "plugin" so you only need a soundfont to get going in muse. I just tried muse 4.x for the first time just now and its cluttered GUI is much more intimidating than qtractors minimalism. muse offers a few more options as a MIDI sequencer but qtractor has better support for recording audio.
My recommendation, having just tested it, would be to use qtractor and the fluida LV2 plugin for using soundfounts such as fluid-soundfont-gm in the Debian repos. fluida has a pre-built binary on its homepage:
https://github.com/brummer10/Fluida.lv2
So all you need to do is download and extract that to ~/.lv2 (in its own fluida.lv2 sub dir) for qtractor to find it.
I can do a short video on how to use fluida with qtractor if it helps but I think you should be able to work it out easy enough. You should be able to export your MIDI tracks from RG and import them into qtractor.
calf-plugins contains a fluidsynth LV2 plugin but it seems to be broke under Debian testing/qtractor, the GUI is drawn much too big and it crashes when you open it so forget about that.
I've updated the guide to mention that muse has its own integrated soundfont "plugin" so you only need a soundfont to get going in muse. I just tried muse 4.x for the first time just now and its cluttered GUI is much more intimidating than qtractors minimalism. muse offers a few more options as a MIDI sequencer but qtractor has better support for recording audio.
My recommendation, having just tested it, would be to use qtractor and the fluida LV2 plugin for using soundfounts such as fluid-soundfont-gm in the Debian repos. fluida has a pre-built binary on its homepage:
https://github.com/brummer10/Fluida.lv2
So all you need to do is download and extract that to ~/.lv2 (in its own fluida.lv2 sub dir) for qtractor to find it.
I can do a short video on how to use fluida with qtractor if it helps but I think you should be able to work it out easy enough. You should be able to export your MIDI tracks from RG and import them into qtractor.
Re: JACK and Linux audio cheatsheet
I've made a couple of small additions to the guide by adding a mention of mhwaveedit as a simple yet JACK-friendly audio editor. Not everyone needs all of the features that REAPER and Ardour etc offer. On the other end of the spectrum I added a brief mention of Bitwig for those who are prepared to pay for its license and fancy features.
Re: JACK and Linux audio cheatsheet
Added a note on recommended trackers.