Topic: Low Latency Linux audio setup discussion

Here is the first draft of my low latency audio setup research and approach: https://pop-planet.info/forums/threads/.../post-2299

Open to discussion! Hoping to influence developers of System76 and Pop!_OS to incorporate optimizations either directly or make them more accessible for average users. System76 claims to be targeted toward "makers" and I would consider musicians a part of the "maker" community!

cheers and new years

Re: Low Latency Linux audio setup discussion

Hello ethanay,

do I understand it correctly?

There is an existing Linux distribution named Pop!_OS.

Is this distribution already realtime and low latency optimized?

Or do you hope this distro will be optimized by a community in the future?

Re: Low Latency Linux audio setup discussion

Recommended reading:  https://wiki.linuxaudio.org/wiki/system_configuration
Also I believe DAW refers not to a professional audio systems per se, but a specific type of program to mix/master audio such as ProTools, Logic, Ardour, Mixbus, ....

Re: Low Latency Linux audio setup discussion

groovy wrote:

Hello ethanay,

do I understand it correctly?

There is an existing Linux distribution named Pop!_OS.

Is this distribution already realtime and low latency optimized?

Or do you hope this distro will be optimized by a community in the future?

Great questions. Pop OS is an Ubuntu based distribution created and maintained by System76. While it will run on any Linux compatible Hardware, it was created to provide an optimized experience for the hardware that system76 provides, making them much closer to Apple in the Computing Market in terms of providing vertically integrated software and Hardware Solutions. However, with more of an open-source and security/privacy oriented philosophy. In addition, they are moving much of the manufacturing process back to the mainland United States.

I have several intentions for providing the information that I researched, first is yes to influence system76 to make Pro Audio setup more accessible for end users. But also to fill much-needed gaps in foundational information and philosophy regarding low latency performance tuning for pro audio or multimedia work.

In short, I wrote and compiled this stuff because as I was researching for my own purposes I did not find anyone who had already written and compiled such information into a coherent synthesis.

Re: Low Latency Linux audio setup discussion

varpa wrote:

Recommended reading:  https://wiki.linuxaudio.org/wiki/system_configuration
Also I believe DAW refers not to a professional audio systems per se, but a specific type of program to mix/master audio such as ProTools, Logic, Ardour, Mixbus, ....

It is used interchangeably for both. For example at the top of the page that you reference, which is a good starting point for some people and their configuration journey, it talks about Linux audio workstations, a subset of the daw paradigm (LAW vs WAW windows audio workstation vs MAW mac audio workstation, or generally DAW digital audio workstation). As you mentioned, it also refers to the specific software suites as well as hardware that confers audio workstation capacities to a given set of hardware. I have seen it used for any/all the above.

Setups specifics change from circumstance to circumstance, and change rapidly over time, but the underlying logic and philosophy remain consistent. I believe that if more people understand that underlying information, we will achieve more consistent and better quality results not only for the end users in their own configuration processes, but also in terms of more optimized hardware and software design. I believe that system76 is in a very unique position to compete favorably with Apple in this market segment, should it choose to do so.

Last edited by ethanay (13-01-2020 17:08)

Re: Low Latency Linux audio setup discussion

This is a very interesting project and resource. I personally have a desktop Linux computer on which I usually run Linux Mint (XFCE edition) and a laptop from System76 running Pop_OS! I use Pianoteq with both.

On the desktop computer, with an Intel CPU on an Asus motherboard, I am able to disable both CPU frequency-scaling ("Intel Speedstep") and hyperthreading (simultaneous multithreading, or SMT) in the BIOS, but the linux kernel seems to reenable frequency-scaling, so I disable it by adding "intel_pstate=disable" to the kernel boot commandline.

On the System76 laptop, I altered the systemd boot commandline to include both "intel_pstate=disable" (to disable frequency-scaling) and "nosmt" (to disable hyperthreading).

On both computers I installed and use the linux-lowlatency kernel (currently at version 5.3.0-xx), which is available in many linux-distribution repositories.

In a terminal on my System76 laptop, the command cat /proc/cmdline currently produces:

initrd=\initrd.img-5.3.0-26-lowlatency root=UUID=(uuid-number) ro loglevel=0 systemd.show_status=false intel_pstate=disable nosmt

Thank you very much for helping to document low-latency audio setup on linux in general, and on System76 computers specifically.

Last edited by Stephen_Doonan (14-01-2020 03:21)
--
Linux, Pianoteq Pro, Organteq

Re: Low Latency Linux audio setup discussion

Stephen_Doonan wrote:

[...]in the BIOS, but the linux kernel seems to reenable frequency-scaling, so I disable it by adding "intel_pstate=disable" to the kernel boot commandline.

Be aware that you fall back with "intel_pstate=disable" to the old scaling_driver acpi-cpufreq:

https://forum.modartt.com/viewtopic.php...99#p933199

There is nothing wrong with it, acpi-cpufreq is just another paradigma and has another userland. But the default in nowadays Linux distributions with Intel CPUs is intel_pstate enabled.

Re: Low Latency Linux audio setup discussion

groovy wrote:

There is nothing wrong with it, acpi-cpufreq is just another paradigma and has another userland. But the default in nowadays Linux distributions with Intel CPUs is intel_pstate enabled.

Thank you for the information.
On my computers, frequency scaling seems to invoke a penalty for digital audio processing, and even the intel_pstate governor "performance" seems to use frequency-scaling. Is it possible with intel_pstate to set the CPU cores at a fixed frequency?

In addition to using the intel_pstate=disable argument in the linux kernel command-line at bootup, I have installed the terminal command-line cpupower utility and use it to set both the governor (to userspace) and the CPU cores' frequency to the maximum factory specifications without overclocking, although using a System76 laptop with its "InSyde" BIOS, after trying to set a fixed frequency for all CPU cores, both cpupower -c all frequency-info, and the Pianoteq perf(ormance) panel of Options, report a narrow range of cpu frequencies (changing over time) rather than a fixed frequency.

It would be nice in Linux in general, and Pop_OS! in particular if some of this low-level CPU and kernel tweaking could be more easily and quickly accomplished within a graphical user interface utility using its underlying scripts or code.

Last edited by Stephen_Doonan (14-01-2020 16:38)
--
Linux, Pianoteq Pro, Organteq

Re: Low Latency Linux audio setup discussion

Stephen_Doonan wrote:

On my computers, frequency scaling seems to invoke a penalty for digital audio processing, and even the intel_pstate governor "performance" seems to use frequency-scaling. Is it possible with intel_pstate to set the CPU cores at a fixed frequency?

Not to my knowledge. All you can do is setting each CPU-core to "performance" and hope for the best. Fortunately just starting qjackctl  maxes the frequency out on my Intel N4200 in performance mode. In this case you could say it is quasifixed. - But how reliable is it with other systems and environments?

It seems to be a common tendency that manufactures try to incapacitate their customers today. When I buy a CPU I would like to be able to set its frequency to my liking. As it has been possible for decades :-/

Re: Low Latency Linux audio setup discussion

Throttling (the downgrading of CPU frequency; the flip side of scaling) seems fundamentally integrated with thermal design in modern CPUs. I think on one hand, manufacturers assume sub-par thermal design of total systems, and throttling has moved beyond a failsafe consideration to an everyday thermal control strategy. On the other hand, I feel like manufacturers are starting to give performance quotes based on unsustainable "overclocked" speeds which makes the CPU seem faster than it really is for sustained workloads. The max sustained speed of my Intel i5-8265U CPU as implemented with my Darter Pro at reasonable ambient temps (~20*C) seems to be in the 2000-2400mhz range, above the rated TDP base frequency of 1.6ghz and yet far below the top advertised burst speed of 3.9ghz. This assumes usage scenarios of transient workloads which is reasonable for non-workstation uses requiring only momentary bursts of throughput. But if we take Intel at their word, I shouldn't expect sustained performance much greater than 1.6ghz in a nominally-designed system. Energy use also factors into the equation and has become an increasing priority (eg modern digital guitar amps all must have auto-off timers built into them according to EU law). So I think there is some clever interaction between engineering and design on one side, and marketing shenanigans on the other.

To what extent is that last bit of performance a matter of practical importance? I (and Intel seems to) agree there is an inherent performance hit to scaling, but I have yet to see any real-world performance comparisons exploring the practical implications. It may in fact be minimal in practice compared to the immense advances in computing power we have access to, since it involves a very minor theoretical performance boost.

Re: Low Latency Linux audio setup discussion

bios settings. no throttling. no turbo. and no intel "speed up" (ie slow-down)
cpufreq-utils may help in Linux but other tools are available that I am not all that familiar with..
I achieve and imperceptible latency of 3 ms on Dell 6230, 6339, Thinkpad T420, T430, X230 at 128 note polyphony.
No tricks just Standard Pulseaudio in-out, no jack.audio bs... pretty much plug and play after setting bios to fixed frequency (no speed-up, no slow-down)...

@OP don't over-complicate it. just run the CPU cores at constant frequency and you'll be fine. If you allow speed-ups and downs with turbo and throttling settings then you will get glitches.

Last edited by SteveLy (15-01-2020 04:26)
3/2 = 5

Re: Low Latency Linux audio setup discussion

SteveLy wrote:

bios settings. no throttling. no turbo. and no intel "speed up" (ie slow-down)
cpufreq-utils may help in Linux but other tools are available that I am not all that familiar with..
I achieve and imperceptible latency of 3 ms on Dell 6230, 6339, Thinkpad T420, T430, X230 at 128 note polyphony.
No tricks just Standard Pulseaudio in-out, no jack.audio bs... pretty much plug and play after setting bios to fixed frequency (no speed-up, no slow-down)...

@OP don't over-complicate it. just run the CPU cores at constant frequency and you'll be fine. If you allow speed-ups and downs with turbo and throttling settings then you will get glitches.

Those are great latency results! Many people don't have those BIOS settings and they aren't necessary. Modifying CPU frequency scaling doesn't need BIOS tweaking to do and can easily be done in userspace by changing the energy performance policy. Turbo is only an issue if you have sufficient cooling, which most laptops don't.

So you are saying that is ALL you've done to tweak your system from its default install settings? No RTIRQ, no RT/lowlatency kernel, no pre-emption, no limits.conf? What OS(es) are you running? What other tweaks have you done? It would be great for you to share your process in full for others...

Unfortunately, it is more complex for many people, who use a computer for a variety of purposes and can't always run it full-out for thermal or other practical reasons (battery life, fan noise, etc) and there are other important factors at play for latency. Most important is for PTQ to see a STABLE CPU frequency. My laptop is able to sustain ~2.2ghz @ ~19*C ambient, which provides great performance but doesn't necessarily prevent buffer xruns. The more subtle OS tweaking is important to prevent those, in my experience.

How are you monitoring for I/O buffer xruns? I have never been able to acheive a stable latency of 3ms. What buffer, bit depth and sample rate settings are you using?

While "more power" is good, also "less overhead" and "more finesse" provide similar virtual performance boosts (e.g., shutting down wifi/networking is a big one).

Re: Low Latency Linux audio setup discussion

https://forum.elk.audio/t/harrison-mixb...dio-os/398

Has anyone done any experimenting with Elk Audio OS? It looks very promising, but may be beyond my technical capacities. We'll see...

Re: Low Latency Linux audio setup discussion

Could you advise me on latency and performance, please?

My system:
Laptop: Thinkpad X1 Carbon (2016)
CPU: i7-6600U (2 cores)
Sound Card: Built in (could use Focusrite Solo, but not sure it will help in any way)
OS: Void Linux

What I did:
1. Install the realtime packages (rtkit, rtaudio, rtmidi)
2. Install and configure ALSA + Jack
3. Install TLP to force "performance" scheduler and no energy-savings

Jack settings are as follows:
Buffer size: 512 samples
Sample Rate: 96000 Hz
Periods/Buffer: 2
Realtime: Yes
Realtime Priority: 10

Results in Pianoteq:
Latency: 5.3ms
Performance index: 73..97
Maximum polyphony: 48

Since I have never used the Pianoteq before and only recently got my first piano controller, I would like to know if this is a good/acceptable result or do I need to reconfigure something?
Is my laptop not powerful enough and I need to connect to my PC instead?
Additionally, is the realtime kernel absolutely necessary? It would take a bit of time to compile one correctly.

I would like to have everything set up properly before purchasing a "Pianoteq 6 Stage" license key.

Last edited by Eichhorn (30-05-2020 09:58)

Re: Low Latency Linux audio setup discussion

I just want to comment that, although I would be interested in "low latency Linux", or "realtime Linux", if latency seemed to be a problem, I'm not finding latency to be a problem at all on my generic Raspbian install on RPi 4.  The latency I get in PTeq (with 128 sample buffer at 44.1kHz) is low enough to be, to my ears, indistinguishable from the latency I hear on my keyboard's built in sounds.  I.e., I don't notice any latency at all.  And setting max cpu frequency with cpufrequtils seems to make everything quite consistent, no pops, crackles, just nice sound.

The PTeq performance index on RPi 4 isn't great, I think I get 18 or 19.  While my five year old mid-range laptop gets around 80.  So, no, if I were to ramp the polyphony up, turn sustain on, and unleash a bunch of glissandos on the PTeq on RPi, I don't think it would keep up.  But not because of latency in the kernel, more just because it doesn't have the power to process all that stuff.  For my ordinary playing, though, it seems fine.

Last edited by hesitz (31-05-2020 21:21)