相对于视频剪辑或游戏，该类应用通常不需要高端硬件。生产于2012 年后的大多数硬件都可以针对专业音频工作进行优化。更多信息请参考 Ardour 用户手册 The Right Computer System for Digital Audio 一节。
- 进一步排障可参考 ALSA 。
在多数情况下，默认的 Arch Linux 内核已能满足低延迟应用。进一步的系统配置只需在你遇到了音频丢失，或是你确实需要/想要极低延迟的情况下进行。
- 配置 CPU 调频 调速器至 performance。
- 配置 pam_limits（例如安装 并将用户添加至 包
threadirqs内核参数（参考 ）- realtime kernel patchset 已默认启用该参数。
- 使用 realtime kernel patchset。
noatime至 fstab（参考 性能优化#挂载选项）。
- 通过在启动阶段执行下列命令来提高最大 requested RTC interrupt frequency（默认为 64 Hz）：
# echo 2048 > /sys/class/rtc/rtc0/max_user_freq # echo 2048 > /proc/sys/dev/hpet/max-user-freq
- Reducing swappiness (aka swap frequency, set to
60by default) to e.g.
10will make the system wait much longer before trying to swap to disk (see wikipedia:Paging#Swappiness). This can be done on the fly with
sysctl vm.swappiness=10(see ) or setup permanently, using a configuration file (see ) such as:
vm.swappiness = 10
- Increasing the maximum watches on files (defaults to
524288) to e.g.
600000, that inotify keeps track of for your user, can help with applications, that require many file handles (such as DAWs). This again can be done on the fly with
sysctl fs.inotify.max_user_watches=600000or in a dedicated configuration file:
fs.inotify.max_user_watches = 600000
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
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)
音频硬件无法同时播放来自多个应用的声音。虽然理论上 ALSA 可以被配置为混合来自多个应用的声音，但这方面的工作通常会交由音频服务器来处理。单独使用 ALSA 时难以实现低延迟，无法协调多个音频应用的实时播放、同时播放以及维持同一速率等，并且无法简单通过连接客户端的方式在多个应用间传输音频流，因此在这一场景下，你需要一个专业音频级的音频服务器。
- PulseAudio 在音频回放和多媒体领域是事实标准，例如视频、浏览器、音乐及游戏。它并没有针对专业音频进行构思，并缺乏低延迟及应用间同步的能力。
- JACK 专门针对专业音频的需要进行开发，并已在全球范围内获得长期应用，因此其非常成熟和稳定。多数专业音频应用针对 JACK API 进行开发。
- PipeWire 正处于活跃开发中，在音频方面目标为取代 JACK 及 PulseAudio。除本文内容外，它同时可以处理视频路由。目前为 beta 开发阶段。
音频服务器的配置很大程度上由使用场景、工作流及应用交互限制所决定。JACK Audio Connection Kit 设计为在不同应用间传输音频，并在维持低延迟下通过客户端的同步执行来同时访问同一音频硬件。
#仅使用 PipeWire #仅使用 JACK ┌──────────────┐ ┌──────────────┐ │ Applications │ │ Applications │ ├──────────────┤ ├──────────────┤ │ PipeWire │ │ JACK │ ├──────────────┤ ├──────────────┤ │ ALSA │ │ ALSA │ └──────────────┘ └──────────────┘
不幸的是，一些流行的桌面应用（例如火狐）以及大多数游戏都取消了或是根本不支持 JACK。因此，该配置仅适合作为专业音频系统的独立设备，此时不支持 JACK 的软件影响可以忽略不计。如果你仍需使用到不支持 JACK 的软件，可以在完成下列设置后参考 Professional audio/Examples#Advanced sound server setups。在安装和运行 JACK 前，请确保它可以访问到你的音频设备。
$ lsof +c 0 /dev/snd/pcm* /dev/dsp*
$ fuser -fv /dev/snd/pcm* /dev/dsp*}}
如果你的音频设备没有显示出来，它可能是在被 PulseAudio 占用（可能是由其它软件作为需求包安装）。如果你不打算使用 Professional audio/Examples#PulseAudio+JACK，可以将 PulseAudio 连带其它软件一起移除，以使其释放音频设备。
JACK 版本 1 已处于 “逐渐淘汰” 阶段中，其不支持 对称多处理（SMP），缺乏 D-Bus 及 Systemd 整合，因此建议使用官方软件源中的版本 2 。If you're going to use a 包JACK control GUI or a Systemd user service for Starting the audio graph, also install . 包
- More details in JACK Audio Connection Kit#Comparison of JACK implementations
The article on JACK describes a GUI-based and a shell-based example setup as a point of reference for your own scenario. Parameter values of JACK are discussed in detail in the #JACK parameters section and may depend on other system factors covered by the #System configuration section above.
The aim here is to find the best possible combination of buffer size and periods, given the hardware you have. Frames/Period = 256 is a sane starter. For onboard and USB devices, try Periods/Buffer = 3 before lowering both values. Commonly used values are: 256/3, 256/2, 128/3, 128/2.
Also, the sample rate must match the hardware sample rate. To check what sample and bit rates your device supports:
$ cat /proc/asound/card0/codec#0
Replace card0 and codec#0 depending on what you have. You will be looking for rates or VRA in Extended ID. A common sample rate across many of today's devices is 48000 Hz. Others common rates include 44100 Hz, 96000 Hz and 192000 Hz.
Almost always, when recording or sequencing with external gear is concerned, realtime is a must. Also, you may like to set maximum priority (at least 10 lower than system limits defined in
/etc/security/limits.d/99-realtime-privileges.conf; the highest is for the device itself).
Start jack with the options you just found out:
$ /usr/bin/jackd -R -P89 -dalsa -dhw:0 -r48000 -p128 -n2
, 包, 包 and 包 can all be used to as GUIs to monitor JACK's status and simplify its configuration. AUR
- Further reading: Linux Magazine article (2006) for basic understanding on JACK parameter finding
JACK parameters are most significant for controlling the round-trip delay (RTD). In the context of this article that is the overall time it takes for an audio signal to be recorded, processed and played back. The next subsection deals with theoretical background on the sources of latency adding up to the RTD. If you are already familiar with that, you can go to #Measuring latency to verify your RTD or skip this section completely.
Consider a typical recording situation of a singer performance. The voice is being captured with a microphone as it propagates trough the air with the speed of sound. An analog-to-digital-conversion enables the electrical signal to be recorded by a computer for digital signal processing. Finally, a digital-to-analog conversion returns the signal to be played back at the singer's headphones for monitoring similar to stage monitor system usage.
In that voice recording situation there are five significant latency sources constructing the RTD and occuring in the following order:
- Sound propagation through the air from the mouth of the singer
- Analog-to-digital conversion
- Digital signal processing
- Digital-to-analog conversion
- Sound propagation through the air to the ear of the singer
The first and last latency source is hard to change as a particular distance is technically necessary to create an intended sound during recording or playback, respectively. Additionally, when using closer miking for capturing and headphones for monitoring both sound propagation latencies are typically within the range of a few microseconds which is not noticeable by humans. Thus, an objective for RTD minimization is to reduce the other sources of latency.
In theory JACK maintains a constant low latency by using fixed values (frames, periods, sample rate) for sampling and buffering of audio to be converted analog-to-digital and vice versa. The latency occurring in the capturing process is described by the following equation:
- Lc = n / f
Lc: Capture latency in milliseconds (ms), n: Frames or buffer (multiples of 2, starting at 16), f: Sample rate in Hertz (Hz).
The playback latency is also employing the periods value:
- Lp = n * p / f
Lp: Playback latency in milliseconds (ms), n: Frames or buffer (multiples of 2, starting at 16), p: Periods, f: Sample rate in Hertz (Hz).
As already stated before the capabilities of the audio interface define working combinations. You have to trial and error to find a setup. Sure, it's a trade-off between xrun prevention and achieving low latency, but recent audio interfaces can be used at high sample rates (up to 192 kHz) to deal with that requirement. The audio flux of JACK clients in the digital domain is about zero and thus, negligible for latency measurements .
- See FramesPeriods in the ALSA wiki for more information.
Once you have set up #JACK parameters you might want to verify the RTD described above. For example, using a frames or buffer size of n = 128, a periods value of p = 2, and a sample rate of f = 48000 results in a capture latency of about Lc = 2,666... ms and a playback latency of about Lp = 5,333... ms summing up to a total round-trip delay of RTD = 8 ms.
The utility by Fons Adriaensen measures RTD by emitting test tones out a playback channel and capturing them again at a capture channel for measuring the phase differences to estimate the round-trip time the signal has taken through the whole chain. Use an appropriate cable to connect an input and output channel of your audio device or put a speaker close to a microphone as described by 包JACK Latency tests.
For example, running
jack_delay for a JACK-only setup using a cable connection between the ports playback_1 and capture_1 (the description may differ depending on your hardware) to close the loop, as well as the values discussed before yields the following insights:
$ jack_delay -O system:playback_1 -I system:capture_1
capture latency = 128 playback_latency = 256 Signal below threshold... Signal below threshold... Signal below threshold... 422.507 frames 8.802 ms total roundtrip latency extra loopback latency: 38 frames use 19 for the backend arguments -I and -O 422.507 frames 8.802 ms total roundtrip latency extra loopback latency: 38 frames use 19 for the backend arguments -I and -O 422.506 frames 8.802 ms total roundtrip latency extra loopback latency: 38 frames use 19 for the backend arguments -I and -O 422.507 frames 8.802 ms total roundtrip latency extra loopback latency: 38 frames use 19 for the backend arguments -I and -O <output omitted>
As the output indicates further optimization of JACK can be done by using the parameters
-I 19 and
-O 19 to compensate for the reported extra loopback latency in the chain:
$ /usr/bin/jackd -R -P89 -dalsa -dhw:0 -r48000 -p128 -n2 -I19 -O19
- More details can be found in the Ardour Manual page about latency and latency compensation.
Ingo Molnar 和 Thomas Gleixner 创造的 RT_PREEMPT 补丁集是对于软/硬实时应用而言非常有意思的选项，涵盖了从专业音频到工业控制等范围。大多数专注于音频的 Linux 发行版都启用了该补丁集。一个可实时抢占的内核也将使调整 IRQ 处理线程的优先级成为可能，并有助于确保几乎不受负载影响的流畅音频。
安装 或是 包 包。 包
- 更多信息可参考 如何正确配置带 PREEMPT_RT 的 Linux 。
- Timer Frequency 设为 1000Hz（
CONFIG_HZ_1000=y；不使用 MIDI 可以无视该项）
- 禁用 APM（
CONFIG_APM=n；在某些硬件上会产生问题 - 在 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.
- 超线程（如果怀疑是它导致的问题，可以在 UEFI 设置中将其禁用）
- Disable WiFi and close any programs that do not 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 to adjust priorities of IRQ handling threads. 包
- Do not use the irqbalance daemon, or do so carefully .
- 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 , 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 post in LAU by Frank Kober 包).
- You may like to read more on ALSA: https://www.volkerschatz.com/noise/alsa.html
Arch Linux provides the package group holding all relevant (semi-) professional applications. All applications in the pro-audio package group are JACK clients. Also 包组, 包组, 包组 and 包组 are subgroups of the pro-audio group. 包组
An overview and brief information on some applications is found in List of applications/Multimedia#Audio. Especially the categories Digital audio workstations, Audio effects and Music trackers, as well as Audio synthesis environments and Sound generators, provide examples of pro audio software for e.g. recording, mixing, mastering, and sound design. Other categories include Scorewriters, Audio editors, Audio converters, and DJ software.
The majority of sound cards and audio devices will work with no extra configuration or packages, simply set JACK to use the desired one.
- Arch Linux Pro-audio Discussion about real-time multimedia, including (semi-)pro audio and video.
- Linux Audio User The Linux pro-audio related mailing list with much traffic and a huge subscriber community of users and developers.
- #archlinux-proaudio - Arch Linux pro-audio channel
- #lau - General Linux Audio channel for users
- #jack - Development and support related to JACK audio system
- #lv2 - Development and support related to the LV2 plugin format
- #ardour - Discussion and support relating to the Ardour DAW
- #opensourcemusicians - Large general OSS musician discussion channel
- Audio setup Comprehensive guide for a pro-audio setup based on Arch Linux
- User repositories: proaudio, realtime
- AUR meta packages: , AUR, AURAUR
- awesome-linuxaudio A list of software and resources for professional audio/video/live events production on the Linux platform
- Multimedia and Games / Arch Linux Forums
- Realtime The Linux Foundation wiki on the PREEMPT_RT patches