kaeru


"Stuff I'm working on ..."

USB Audio Interface Basics for Linux

by kaeru published 2021/11/28 23:17:00 GMT+8, last modified 2022-04-09T07:47:56+08:00
What it is, and how it works on Linux
MoTU M4 USB Audio Interface
MoTU M4 USB Audio Interface

Was going to do an update of my guide on MIDI and Audio Controller on Linux page article on Medium, but decided to write up some quick notes first.

One will want to get a USB Audio Interface for a couple of reasons:

  • Plug in and record quality digital audio from microphones that require phantom power
  • Lower latency for recording and playback
  • To plug in electric guitar and have digital amp and other effects
  • To have multiple line-in and out channels for instruments with line-out etc.
  • Hardware controls and audio input/output level monitoring

Since they usually have high quality DACs and parts for clean signals, they can also be good for general audio playback as well.

There is a wide range of them on the market, especially at the lower end of 1x2 (1 mic/line in, R/L line-out)  or 2x2 interfaces (2 mic/line in, R/L line-out).

When considering them for Linux specifically, you usually need to check if it's USB Audio Class 2.0 device. Since almost all the features and controls are implemented in hardware, the basic core functionality will work. What probably won't work, will be some additional DSP features, that are only used in software provided by the vendor that usually works on Windows and/or MacOS only.

So after checking that USB Audio Class 2.0 is supported, then it's the hardware features you need (I like clear technical definitions, so I learned a lot from Julian Krause's Youtube channel)  and brand preference. On bundled software, most of them will bundle a basic version of a DAW, virtual instruments and plugins (VSTs) and samples. The samples, you can use, but the DAWs and VSTs probably won't have a Linux version. The exception being Bitwig.

USB Audio Class 2.0

If you're buying one soon, I personally would prefer one that has USB-C interface, technically it doesn't matter as USB 2.0 is more than enough for audio, but in long run, I want to get rid of needing Micro-USB cables as soon as possible.

You don't need any drivers in Linux, USB Audio Class 2.0 audio interfaces should be auto-detected.

Bus 001 Device 007: ID 07fd:0008 Mark of the Unicorn M Series
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x07fd Mark of the Unicorn
idProduct 0x0008 M Series
bcdDevice 1.02
iManufacturer 1 MOTU
iProduct 3 M4
iSerial 2 M40000027757
bNumConfigurations 1
Alsa Mixer no controls
Alsa Mixer no controls


You might notice that alsamixer shows no controls, that's because everything is done in hardware, including the master volume, as you can see from the picture of the front of my audio interface. Software controls are only adjusting the digital levels of each channel, not the master one.

Pipwire and low latency kernel

These days, I  recommend installing Pipewire on Linux. It'll provide low-latency unified audio for your JACK and pulseaudio apps (and bluetooth) seamlessly.

Instructions for Ubuntu/Debian on Debian Wiki and the PPA usable for Ubuntu Users is here. I recommend installing the PPA, and then following the instructions for configuring Pulseaudio and JACK from the Debian wiki.

Also you should install a low latency kernel, which is probably one of the main reasons you want to use an audio interface.

sudo apt install low-latency 

and reboot. Another advantage of Pipewire is that it instantly detects when you plug in (or out) your USB audio interfaces, which is normally the case for when you use your audio interface on a laptop, where usually you use the built-in audio device.

Also suite of Linux audio tools including Carla VST host and patchbay, Guitarix (amp effects) etc. can be installed with Ubuntu Studio meta-package

sudo apt install ubuntustudio-audio
Carla Host Patchbay
Carla Host Patchbay

For JACK, try to get to the lowest buffer per period, without XRUNs where the audio starts to crackle because it can't keep up, you should be able to get it down to 64/48000 (1.33ms latency) or 128/48000 (2.6ms latency). There is additional latency in the complete pipeline, but these are pretty good. There is a good review with measurements of latency of the M4 I use here.

Why is audio latency important? This doesn't matter much for watching a movie, where the delay is synced to the video playback. But if you're playing an instrument, you don't want the delay from the time you press a key on your keyboard, or pluck a guitar string to hearing it on your speakers or headphones to be noticeable. Noticeable delays will throw you off, especially if you're trying to keep time.

In the relevant section of your local pipewire jack.conf (usually copying the sample to ~/.config/pipewire/jack.conf)  you can try set the defaults.

jack.properties = {
node.latency = 128/48000
#jack.merge-monitor = false
#jack.short-name = false
#jack.filter-name = false
}

The awesome thing about pipewire providing a unified audio system, is that apps that don't need low latency and sending sound through pulseaudio API will have higher buffers by default, so if you're just listening to music, then you won't be pushing your CPU or draining battery on laptop needlessly.

Active Speakers and Connections

While this might be obvious, for audio engineers and musicians, it wasn't for me and I had to do a bit of reading. Also a good Youtube explainer here. A USB Audio Interface will need to be connected to a set of powered monitor speakers. These are somewhat like your typical powered computer speakers. As an aside, if you're just looking for good audio quality computer speakers, you might want to expand your choices and take a look at active monitor speakers.

The lowest entry level audio interfaces might just have standard unbalanced RCA left (white) and right (red). These are not grounded, and you might pick up and hear noise/buzzing from your monitor speakers. If you're planning to invest in monitor speakers, you probably want to check that the audio interface has at least balanced TRS outputs. This basically using a standard TRS stereo cable, but you will need to have two of them for left and right connections. The mono TR cable for your guitar should not be used for your speaker connections, it will not be grounded.

If you need more advice on this, talk to your local musical instrument shop. They might not know if an audio interface will work with Linux, but they'll know what cables, and what speakers will work for what you need and your budget.

Speaker, Line-out and MIDI ports on MoTU M4 with TRS cable for monitors
Speaker, Line-out and MIDI ports on MoTU M4

TRS, XLR (balanced) and RCA (unbalanced) connectors for speaker
TRS, XLR (balanced) and RCA (unbalanced) connectors for speaker