User:Actioninja
Hello.
I like to program and produce music. I also like sharing things I figure out with others. I'm currently working on trying to get the pages on professional audio and JACK on the wiki to a more modern standard. A lot of them are really outdated and have caused me a lot of headache in the past, and I would hope that future users wouldn't have to go through the same crap.
PRIVATE SANDBOX
Modern Linux systems are highly capable audio production systems when setup properly. Extremely low recording latencies such as 5ms to 1ms can be achieved, as well as complex audio and midi routing of multiple programs via a virtual patchbay without the necessity of any proprietary APIs such as ReWire.
Getting Started
Professional audio work on Linux is largely centered around JACK. JACK is roughly equivalent to the role that ASIO performs on Windows and Mac. Before getting anything else started, it's best to get a well functioning JACK setup installed and configured. Detailed instructions can be found on the JACK page. The rest of this page will assume you used the KXStudio suite.
System Configuration
Some configuration tweaks that are highly recommended are:
- Add your user account to the audio user group to allow proper JACK scheduling.
- Install the linux-rtAUR kernel which features some patches that can affect latency
- Set the cpufreq governor to performance
Realtime configuration has mostly been automated. There is no longer any need to edit files like /etc/security/limits.conf
for realtime access. However, if you must change the settings, see /etc/security/limits.d/99-audio.conf
and /usr/lib/udev/rules.d/40-hpet-permissions.rules
(these files are provided by jack or jack2). Additionaly, you may want to increase the highest requested RTC interrupt frequency (default is 64 Hz) by running the following at boot:
echo 2048 > /sys/class/rtc/rtc0/max_user_freq echo 2048 > /proc/sys/dev/hpet/max-user-freq
By default, swap frequency defined by "swappiness" is set to 60. By reducing this number to 10, the system will wait much longer before trying to write to disk.
Then, there is inotify which watches for changes to files and reports them to applications requesting this information. When working with lots of audio data, a lot of watches will need to be kept track of, so they will need to be increased.
These two settings can be adjusted in /etc/sysctl.d/99-sysctl.conf
.
vm.swappiness = 10 fs.inotify.max_user_watches = 524288
You may also want to maximize the PCI latency timer of the PCI sound card and raise the latency timer of all other PCI peripherals (default is 64).
$ setpci -v -d *:* latency_timer=b0 $ setpci -v -s $SOUND_CARD_PCI_ID latency_timer=ff # eg. SOUND_CARD_PCI_ID=03:00.0 (see below)
The SOUND_CARD_PCI_ID can be obtained like so:
$ lspci ¦ grep -i audio
03:00.0 Multimedia audio controller: Creative Labs SB Audigy (rev 03) 03:01.0 Multimedia audio controller: VIA Technologies Inc. VT1720/24 [Envy24PT/HT] PCI Multi-Channel Audio Controller (rev 01)
System Configuration
You may want to consider the following often seen system optimizations:
- Add yourself to the audio user group.
- Add the
threadirqs
kernel parameter. - Install linux-rtAUR kernel.
- Set the cpufreq governor to performance.
- Add noatime to fstab (see Improving performance#Mount options).
Realtime configuration has mostly been automated. There is no longer any need to edit files like /etc/security/limits.conf
for realtime access. However, if you must change the settings, see /etc/security/limits.d/99-audio.conf
and /usr/lib/udev/rules.d/40-hpet-permissions.rules
(these files are provided by jack or jack2). Additionaly, you may want to increase the highest requested RTC interrupt frequency (default is 64 Hz) by running the following at boot:
echo 2048 > /sys/class/rtc/rtc0/max_user_freq echo 2048 > /proc/sys/dev/hpet/max-user-freq
By default, swap frequency defined by "swappiness" is set to 60. By reducing this number to 10, the system will wait much longer before trying to write to disk.
Then, there is inotify which watches for changes to files and reports them to applications requesting this information. When working with lots of audio data, a lot of watches will need to be kept track of, so they will need to be increased.
These two settings can be adjusted in /etc/sysctl.d/99-sysctl.conf
.
vm.swappiness = 10 fs.inotify.max_user_watches = 524288
You may also want to maximize the PCI latency timer of the PCI sound card and raise the latency timer of all other PCI peripherals (default is 64).
$ setpci -v -d *:* latency_timer=b0 $ setpci -v -s $SOUND_CARD_PCI_ID latency_timer=ff # eg. SOUND_CARD_PCI_ID=03:00.0 (see below)
The SOUND_CARD_PCI_ID can be obtained like so:
$ lspci ¦ grep -i audio
03:00.0 Multimedia audio controller: Creative Labs SB Audigy (rev 03) 03:01.0 Multimedia audio controller: VIA Technologies Inc. VT1720/24 [Envy24PT/HT] PCI Multi-Channel Audio Controller (rev 01)
Checklist
The steps below are mostly to double-check that you have a working multimedia system:
$ speaker-test
$ groups | grep audio
- Is PulseAudio, OSS or something else grabbing my device?
$ lsof +c 0 /dev/snd/pcm* /dev/dsp*
-OR-
$ fuser -fv /dev/snd/pcm* /dev/dsp*
- Is PAM-security and realtime working OK?
See: Realtime for Users#PAM-enabled login (Pay special attention especially if you do not run KDM, GDM or Slim.)
- Have I rebooted after having done all that?
Realtime Kernel
Since a while ago, the stock Linux kernel has proven to be adequate for realtime uses. The stock kernel (with CONFIG_PREEMPT=y
, default in Arch) can operate with a worst case latency of upto 10ms (time between the moment an interrupt occurs in hardware, and the moment the corresponding interrupt-thread gets running), although some device drivers can introduce latency much worse than that. So depending on your hardware and driver (and requirement), you might want a kernel with hard realtime capabilities.
The RT_PREEPMT patch by Ingo Molnar and Thomas Gleixner is an interesting option for hard and firm realtime applications, reaching from professional audio to industrial control. Most audio-specific distro Linux ships with this patch applied. A realtime-preemptible kernel will also make it possible to tweak priorities of IRQ handling threads and help ensure smooth audio almost regardless of the load.
If you are going to compile your own kernel, remember that removing modules/options does not equate to a "leaner and meaner" kernel. It is true that the size of the kernel image is reduced, but in today's systems it is not as much of an issue as it was back in 1995.
In any way, you should also ensure that:
- Timer Frequency is set to 1000Hz (CONFIG_HZ_1000=y; if you do not do MIDI you can ignore this)
- APM is DISABLED (CONFIG_APM=n; Troublesome with some hardware - default in x86_64)
If you truly want a slim system, we suggest you go your own way and deploy one with static /devs. You should, however, set your CPU architecture. Selecting "Core 2 Duo" for appropriate hardware will allow for a good deal of optimisation, but not so much as you go down the scale.
General issue(s) with (realtime) kernels:
- Hyperthreading (if you suspect, disable in BIOS)
There are ready-to-run/compile patched kernels available in the AUR.
AUR
From the AUR itself, you have the following options:
- linux-rtAUR
- linux-rt-ltsAUR (Long Term Support, stable release)
The first two are standard kernels with the CONFIG_PREEMPT_RT patch, while -ice includes patches some may consider to be nasty, while to others are a blessing.
- See: Real-Time Linux Wiki
MIDI
To decrease MIDI jitter when using external MIDI equipment jack2's -Xalsarawmidi option should be used. When doing this you need to use a2jmidid, too.
With alsa-midi-latency-test you could test how much jitter you get. PCI and PCIe cards are usually much better than USB MIDI devices.
To work with MIDI, it is highly recommended that you install a2j (a2jmidid), a bridge between alsa midi and jack midi. It allows you to connect applications that only communicate with alsa midi to applications that only use jack midi. Laditray can also start/stop a2j.
- See: JACK#MIDI
Environment Variables
If you install things to non-standard directories, it is often necessary to set environment path variables so that applications know where to look (for plug-ins and other libraries). This usually affects only VST since users might have a Wine or external Windows location.
We would usually not have Linux plug-ins (LADSPA, LV2, DSSI, LXVST) beyond standard paths, so it is not necessary to export them. But if you do, be sure to include those standard paths as well since Arch does not do anything for dssi or ladspa, and some applications like dssi-vst will not look anywhere else if it finds predefined paths.
~/.bashrc
... export VST_PATH=/usr/lib/vst:/usr/local/lib/vst:~/.vst:/someother/custom/dir export LXVST_PATH=/usr/lib/lxvst:/usr/local/lib/lxvst:~/.lxvst:/someother/custom/dir export LADSPA_PATH=/usr/lib/ladspa:/usr/local/lib/ladspa:~/.ladspa:/someother/custom/dir export LV2_PATH=/usr/lib/lv2:/usr/local/lib/lv2:~/.lv2:/someother/custom/dir export DSSI_PATH=/usr/lib/dssi:/usr/local/lib/dssi:~/.dssi:/someother/custom/dir
Software
A decent amount of audio production software exists with Linux support.
DAWs
A good DAW is perhaps the most important piece of software in any digital music production environment.
FOSS
Ardour
Ardour is the most fully featured FOSS DAW for Linux. It is targeted mostly at people looking to record, but also has full midi support along with a piano roll and can be used for electronic music production.
LMMS
LMMS is a less fully featured DAW more intended for recreational music sequencing. It does not support direct recording, but does have a piano roll and tracking features.
Audacity
Audacity is not a true DAW as it only features recording and audio editing, but can be used for fairly simple of recording tasks.
Commercial
Bitwig Studio
Bitwig Studio is one of the only commercial DAW with officially released native Linux support. It is very fully featured and is most similar to Ableton Live. It can be downloaded via the bitwig-studioAUR package from the AUR, but it will need a purchased license in order to fully function.
Tracktion
Tracktion is an old DAW that has recently returned to production. It is primarily focused on ease of use and affordability compared to other DAWs. Tracktion is proprietary software, but Tracktion T6 is free to use. tracktion-6AUR tracktion-7AUR
Reaper
Reaper somewhat recently started releasing some unsupported builds of it for Linux. They are fully native builds, but as mentioned, no support is provided.
reaperAUR
Non-Native
You may have success getting other non-native DAWs to run via WINE. wineasioAUR is needed to properly wrap ASIO input and output of WINE programs to JACK.
Trackers/Sequencers
Trackers and Sequencers are typically less feature-rich than a DAW, but are more focused on midi sequencing and tracking. JACK features a global transport head that can be used to play, pause, and reposition on multiple connected clients at the same time, which allows trackers and sequencers to be more easily connected to DAWs and external synth programs.
Qtractor
Qtractor is a multitrack sequencer. It features robust sample manipulation and powerful midi editing tools.
Synthesizers, Effects, and Other Tools
Along with actual production tools, synthesizers, effects, and other tools like drum machines form an essential part of a music production setup. Jack's audio routing and global transport head allow multiple independent programs to more easily route sound and midi information into each other, making it less necessary for software like this to exist as plugins.
Hydrogen
Hydrogen is a software drum machine. It acts as its own sequencer and output that can then be routed to other programs.
Guitarix
Guitarix is a guitar amp and effect simulator. It can be used on DIed guitars and basses to simulate using an amp, or it can be used as an effect in electronic production.
Yoshimi
a fork of the ZynAddSubFX software synthesizer yoshimiAUR}
Calf
Calf is a suite of various plugins. It supports LV2, DSSI, LADSPA, and also has a standalone JACK host.
Utilities
Many utilities for various usages exist as well
DSSI
DSSI is an audio plugin standard. It's not a program within its own right, as much as a set of libraries for plugins to build off of. It is loosely equivalent to the VSTi library.
WineAsio
WineAsio is an implementation of the ASIO driver standard for wine. This allows Windows DAWs and other programs that use ASIO to run in wine.
wineasioAUR
vst-bridge
vst-bridge is a program that bridges Windows VSTs to a Linux VST host. It generates individual WINE wrappers for each windows VST that are then routed to native linux VST plugins.
{{AUR|vst-bridge
Composition
Composition software is designed entirely to aid in music composition.
MuseScore
MuseScore is a sheet music composition tool that focuses entirely on composing solely sheet music. Along with its composition suite, there is a fully featured web component that allows for the sharing of composed works.
Rosegarden
Rosegarden is a sheet music composition aid that is based around a midi sequencer. The sequencer is used like many others, and then corresponding sheet music is generated.
TuxGuitar
TuxGuitar is a FOSS alternative to GuitarPro. It is primarily designed for creating guitar tabulature, and also features a sheet music display.
More
See also List of applications#Audio systems, List of applications#Sound editing, and awesome-linuxaudio.
Tips and Tricks
- Disable WiFi and close any programs that don't need to be open when recording such as browsers. Many have reported disabling WiFi has led to more reliable JACK performance.
- Some USB audio hardware is known not to work properly when plugged into USB 3 ports so try USB 2/1 ports instead.
- IRQ issues can occur and cause problems. An example is video hardware reserving the bus, causing needless interrupts in the system I/O path. See discussion at FFADO IRQ Priorities How-To. If you have a realtime or a recent kernel, you can use rtirqAUR to adjust priorities of IRQ handling threads.
- Do not use the irqbalance daemon, or do so carefully [2].
- If you need to use multiple audio devices with JACK2, the alsa_in and alsa_out utilities. can be used to have extra devices wrapped and show up as outputs in the JACK patchbay.
- Some daemons/processes can unexpectedly cause xruns. If you do not need it - kill it. No questions asked.
$ ls /var/run/daemons $ top # or htop, ps aux, whatever you are comfortable with $ killall -9 $processname # systemctl stop $daemonname
- If you are facing a lot of xruns especially with nvidia, disable your GPU throttling. This can be done via the card's control applet and for nvidia it is "prefer maximum performance" (thanks to a mail in LAU by Frank Kober).
- You may like to read more on ALSA: http://www.volkerschatz.com/noise/alsa.html
Hardware
The majority of sound cards and audio devices will work with no extra configuration or packages, simply set the sound card jack is using to them and restart.
This is not true for all devices, and so special cases are also listed.
M-Audio Delta 1010
The M-Audio Delta series cards are based on the VIA Ice1712 audio chipset. Cards using this chip require that you install the alsa-tools package, because it contains the envy24control program. Envy24control is a hardware level mixer/controller. You can use alsa-mixer but you will save yourself some hassle not to try it. Note that this section has no information on MIDI setup or usage.
Open the mixer application:
$ envy24control
This application can be more than a bit confusing; see envy24control for guidance on its use. That said, here is a very simple working setup for multitracking with Ardour.
- On the "Monitor Inputs" and "Monitor PCMs" tabs, set all monitor inputs and monitor PCM's to around 20.
- On the "Patchbay / Router" tab, set all to PCM out.
- On the "Hardware Settings" tab, verify that the Master Clock setting matches what is set in Qjackctl. If these do not match you will have xruns out of control!
M-Audio Fast Track Pro
The M-Audio Fast Track Pro is an USB 4x4 audio interface, working at 24bit/96kHz. Due to limitation of USB 1, this device requires additional setup to get access to all its features. Device works in one of two configuration:
- Configuration 1, or "Class compliant mode" - with reduced functionality, only 16bit, 48kHz, analogue input (2 channels) and digital/analogue output (4 channels).
- Configuration 2 - with access to all features of interface.
Currently with stock kernel it runs in configuration 2, but if you want to make sure in what mode you are, you can check kernel log for entries:
usb-audio: Fast Track Pro switching to config #2 usb-audio: Fast Track Pro config OK
The interface also needs extra step of cofiguration to switch modes. It is done using option device_setup
during module loading. The recommended way to setup the interface is using file in modprobe.d
:
/etc/modprobe.d/ftp.conf
options snd_usb_audio vid=0x763 pid=0x2012 device_setup=XXX index=YYY enable=1
where vid
and pid
are vendor and product id for M-Audio Fast Track Pro, index
is desired device number and device_setup
is desired device setup. Possible values for device_setup
are:
device_setup value | bit depth | frequency | analog output | digital output | analog input | digital input | IO mode |
---|---|---|---|---|---|---|---|
0x0 | 16 bit | 48kHz | + | + | + | + | 4x4 |
0x9 | 24 bit | 48kHz | + | + | + | - | 2x4 |
0x13 | 24 bit | 48kHz | + | + | - | + | 2x4 |
0x5 | 24 bit | 96kHz | * | * | * | * | 2x0 or 0x2 |
The 24 bit/96kHz mode is special: it provides all input/output, but you can open only one of 4 interfaces at a time. If you for example open output interface and then try to open second output or input interface, you will see error in kernel log:
cannot submit datapipe for urb 0, error -28: not enough bandwidth
which is perfectly normal, because this is USB 1 device and cannot provide enough bandwidth to support more than single (2 channel) destination/source of that quality at a time.
Depending on the value of index
it will setup two devices: hwYYY:0
and hwYYY:1
, which will contain available inputs and outputs. First device is most likely to contain analog output and digital input, while second one will contain analog input and digital output. To find out which devices are linked where and if they are setup correctly, you can check /proc/asound/cardYYY/stream{0,1}
. Below is list of important endpoints that will help in correctly identifying card connections (it easy to mistake analog and digital input or output connections before you get used to the device):
EP 3 (analgoue output = TRS on back, mirrored on RCA outputs 1 and 2 on back) EP 4 (digital output = S/PDIF output on back, mirrored on RCA outputs 3 and 4 on back) EP 5 (analogue input = balanced TRS or XLR microphone, unbalanced TS line on front) EP 6 (digital input = S/PDIF input on back)
This .asoundrc file enables 24-bit IO on the fast-track pro (and I'm sure it could be modified to work with other 3-byte usb devices) within the context of jack's 32-bit interface while routing default alsa traffic to jack outputs on the audio interface. Alsa will be in S24_3BE mode but jack can plug S32_LE data in and out of the interface and other alsa programs will be able to plug almost anything into jack.
### ~/.asoundrc ### default alsa config file, for a fast-track pro configured in 24-bit mode as so: ### options snd_usb_audio device_setup=0x9 ### invoke jack with: (if you use -r48000, change the rate in the plugs as well) ### $jackd -dalsa -P"hw:Pro" -C"hw:Pro,1" -r44100 ## setup input and output plugs so jack can write S24_3BE data to the audio interface pcm.maud0 { type hw card Pro } #jack_out plug makes sure that S32_LE data can be written to hw:Pro pcm.jack_out{ type plug format S32_LE channels 2 rate 44100 slave pcm.maud0 } pcm.maud1 { type hw card Pro device 1 } ## jack_in plug makes sure that hw:Pro,1 can read S32_LE data pcm.jack_in { type plug format S32_LE channels 2 rate 44100 slave pcm.maud1 } ##### # route default alsa traffic through jack system io pcm.jack { type jack playback_ports { 0 system:playback_1 1 system:playback_2 } capture_ports { 0 system:capture_1 1 system:capture_2 } } pcm.amix { type asym playback.pcm "jack" capture.pcm "jack" } pcm.!default { type plug slave.pcm amix }
PreSonus Firepod
- Startup: Either from command line or QjackCtl, the driver is called firewire.
- Specs: The card contains 8/8 preamp'ed XLR plus a stereo pair, in total 10 channels.
- Linking: Cards can be linked together without any problems.
- Hardware Settings: Nothing particular, tweak the settings in QjackCtl to your likings.
Volume levels are hardware and routing can be done through QjackCtl, even with more cards linked together, this is not a problem. The ffadomixer does not work with this card yet, hopefully in the future we can control more aspects of the card through a software interface like that.
PreSonus AudioBox USB
- Startup: It is called "USB" by ALSA.
- Specs: Two mono TRS+XLR in, two mono TRS out, MIDI in and out, plus separate stereo headphone jack. Knob controls for both inputs, for main out, and for headphone, four in all.
- Hardware: Works very well, audio and MIDI too. No software mixer controls at all.
Tascam US-122
This does not apply to the US-122L
- Required packages: alsa-tools alsa-firmware fxloadAUR
- udev rules: create the following rules file, then reload udev rules, Udev#Loading new rules
/etc/udev/rules.d/51-tascam-us-122.rules
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="8006", ATTRS{idVendor}=="1604", RUN+="/bin/sh -c '/sbin/fxload -D %N -s /usr/share/alsa/firmware/usx2yloader/tascam_loader.ihx -I /usr/share/alsa/firmware/usx2yloader/us122fw.ihx'" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="8007", ATTRS{idVendor}=="1604", RUN+="/bin/sh -c '/usr/bin/usx2yloader'"
Plug in the unit The device should now be working, there are no software mixer controls
RME Babyface
It works very well at low latencies (~5ms) with alsa-utils, jack2 and linux-rtAUR. Running on ALSA only with the standard kernel may cause crackling at lower latencies.
To be recognized and work, the firmware version of the Babyface needs to be >= 200, which introduces the Class Compliant Mode. To enter Class Compliant Mode hold the "Select" and "Recall" buttons while connecting the Babyface to the computer via USB. It should now be recognized.
To check if it is recognized:
grep -i baby /proc/asound/cards
For more info about the Class Compliant Mode visit RME's website, they have PDF which covers all the functionality.
The Babyface does not need any special Jack Settings. But if you want to use the built in MIDI In/Out then you need to set the "MIDI Driver" to "seq" and optionally disable "Enable Alsa Sequencer Support" to use it in combination with other MIDI Devices (a USB Midi Keyboard for example).
Restricted Software
Steinberg's SDKs
It is very clear - we can distribute neither the VST nor the ASIO headers in binary package form. However, whenever you are building a program which would host Windows .dll VST plug-ins, check for the following hints (that do not require use of any SDK):
- dssi-vst
- fst
- vestige
With that said, if you are building a program which would host native .so VST plug-ins, then there is no escape. For such cases, Arch yet again allows us to maintain a uniform local software database. We can "install" the SDK system-wide - you simply have to download it yourself and place it in the packaging directory.
Note: Steinberg does not forbid redistribution of resulting products, nor dictate what license they can be under. There are many GPL-licensed VST plug-ins. As such, distributing binary packages of software built with these restricted headers is not a problem, because the headers are simply buildtime dependencies.
Mailing list
- Linux-audio-user -- A list for linux audio users The Linux pro-audio related mailing list with much traffic and a huge subscriber community of users and developers.