Categories
linux music recording

Linux for Guitarists: Part One

August 30th, 2020

Show at the Expanded House, 10/18/2003. Photo: J. Groves

I play D.I.Y. and punk music. Loud, social music. Shows are intense, cramped, and fun. There’s nothing comparable to a great show.

Now we all find ourselves in a pandemic with far fewer opportunities to congregate in tiny places. If you want to work with others during a pandemic, or even musicians that are just far away, you’ll need to adapt. One way to keep making music right now is to record it yourself. When you record your work, you can share instrument tracks with others, work together on ideas, and even produce a high quality release.

How My Guitar Stopped Hating my Laptop

I have some friends I’ve been making music with for more than twenty years. A few years ago I moved across the country and I didn’t want to let the band go. At first I’d fly back to Virginia every so often and we’d do as much as we could in a short amount of time. In 2017 I flew back for a week and we recorded a release. As with anything in life, you have to push yourself to do more. The next phase in our growth was to accomplish more before we used airplanes and hotel rooms.

The thought of self-recording on a computer struck me as painful and unnecessary. My drummer (living more than a thousand miles away) patiently encouraged me to learn how to record properly while he made due with my low-quality improvised recordings. I’d send him ideas captured on a phone or cheap mic, with lots of sloppy tempo changes. I didn’t record my ideas to a click track so my timing was terrible. My drummer encouraged me to get some equipment and start recording to a click. I resisted for quite a while but now have all the zeal of the converted.

We will take a detour for click tracks and the controversy they enjoy. A good amount of over-produced, commercial, soulless music is recorded with a click. Music produced with click tracks doesn’t have to be awful, and clicks are an important tool for writing music that’s properly synchronized. Learning to play to a click track is a skill that needs to be learned and practiced. I write a lot of tempo and time signature changes, so I had to get used to the strictness of a click while also having to learn more about how to express time in the first place.

Linux and Recording

I’m quite fond of Linux however few studios use it for audio recording. This is almost entirely because the Pro Tools software suite isn’t available. The good news is that Linux is quite capable of handling the demands of low-latency audio production, with a large selection of good software. Linux allows you to tweak minute details of your hardware to squeeze out as much performance as possible. Latency is where this matters most.

Latency is the delay from when your signal is created to when you hear it played back to you. Effects and audio processing put more demands on hardware, requiring more buffering to keep up. Buffering increases latency, which will be felt as delays. Recording busy guitar parts with high latency is frustrating, so naturally your goal is to configure your system with the least amount of latency permissable to properly record.

Hardware

Your computer probably has a sound card because it’s no longer 1996. Your onboard sound device, however, isn’t typically suitable for professional audio recording. Instead, you’ll need to acquire an audio interface. Audio interfaces are often USB-based and provide native instrument and microphone ports. Most importantly these devices offload work from your computer allowing you to achieve lower latency. I spent some time researching interfaces that worked well under Linux and chose the Focusrite Scarlett 2i2 (2nd Gen). Plug in a well-supported interface and it will be made available as a new audio output and capture device. Pretty easy.

Software

Linux users will need to run the JACK sound daemon. Modern Linux desktops default to Pulseaudio as the sound daemon. When you plug in an HDMI cable or use wireless headphones, Pulseaudio is responsible for routing the sound. While Pulseaudio and JACK have the same job, JACK is necessary because Pulseaudio wasn’t designed with low-latency professional audio in mind. As a result, most Linux recording software supports JACK.

Standard Linux distributions will need configuration to allow JACK to run optimally. Fedora’s JACK package includes the following instructions under /usr/share/doc/jack-audio-connection-kit/README.Fedora:

    Add yourself to the jackuser group.
        usermod -a -G audio,jackuser "<your username>"

Also ensure you have a config file similar to the following:

    ~]$ egrep -v '^#|^$' /etc/security/limits.d/95-jack.conf 
    @jackuser - rtprio 94
    @jackuser - memlock unlimited
    @pulse-rt - rtprio 20
    @pulse-rt - nice -20

I use both Fedora and Debian when recording. Debian packages a real time kernel which I use when recording, while I do most of my editing on Fedora. Your distribution should have similar instructions for setting up JACK. If you ignore or forget to make these changes your software will usually complain.

QjackCtl is a JACK front end that makes configuration simple. First plug in your audio interface. Open QjackCtl and press “Setup”. Choose your interface under the “Advanced” tab, under the input and output device drop down menus. Click the “Parameters” tab. Your task is now to endlessly futz with “Sample Rate”, “Frames/Period”, and “Periods/Buffer” settings until you have low enough latency for your workload. With the exception of Sample Rate, lower settings provide lower latency. Keep in mind that adding effects and other compute-heavy tasks will require settings that increase latency.

These are my typical recording settings:

  • Sample Rate: 48000
  • Frames/Period: 128
  • Periods/Buffer: 3

I record with low latency settings and mix and render with higher latency settings. Linux lets you choose your desired latency, but it’s up to your hardware to support it. You’ll know if your latency settings are too aggressive if you get terrible popping and “xruns”. An xrun is a buffer over or underrun resulting in audio data loss. An occasional xrun is often inaudible and can be ignored. Floods of xruns will result in heinous distortion and will persist until you increase your latency.

With JACK running and configured to use your audio interface, you’ll want to try out some software. For guitarists, Guitarix provides an amplifier and effect stack suitable for recording and playing live. Starting Guitarix is usually enough to play and hear sound. If you don’t hear sound, you’ll likely need to tell JACK what to route. In QjackCtl, press “Graph” and connect noodles from system capture (which will be your audio interface) to your audio application, Guitarix gfx_head_amp and gfx_head_fx in this case, and finally from Guitarix to system output.

Routing to Guitarix

I imagine JACK routing throws a lot of newcomers. To hear audio, you must make sure an application has a connection to system output. If you want an application to listen for your instrument, ensure there’s a connection from system input to the application. JACK-aware applications can be configured quite flexibly. When recording, I route my system capture twice. The first path is directly from my interface to my audio recording software allowing me to record a dry signal. The other path is from my interface to Guitarix so I can record a wet signal. Keeping a dry signal means that I have the option to change or improve my guitar tone at some point in the future. Applications like Firefox aren’t JACK-aware and will hang if you try to play audio when JACK is running, though there are ways to work around this issue. This tends to bite me when I’m trying to look at YouTube videos for some recording trick.

While routing is explained above, applications themselves can usually start JACK for you if it isn’t already running. Applications like Guitarix and Ardour will start JACK for you, but you’ll still need to configure JACK for most tasks.

Guitarix is an outstanding application that has a learning curve. You’ll need to tweak Guitarix to get a good sound. The best Guitarix resource I’ve found is Libre Music Production’s guide. Guitarix provides presets you can download from the application itself which will be stored under “~/.config/guitarix/”. I suggest starting with some online presets and tweaking from there. I’ve also had good results using impulse response files with Guitarix[0].

This essay is long enough, so an exploration of recording software will wait for another time. Get a hold of a well-supported audio interface and give Guitarix a try. It’s great software.

Resources:

Suggestions for whole-number JACK settings
Great site for Linux musicians, complete with quite exhaustive discussions about tuning, latency, and all manner of things: https://linuxmusicians.com/

[0]: Per the advice of my friend Ken Savich, I prefer the sound of impulse responses. I use the Catharsis impuse reponse files which I probably downloaded from a place like this.

$Id: linux_for_guitarists_part_one 588 2020-08-30 23:33:30Z x $