How do I run a process with real time priority? (for noobs)

Hello,
I would like to use a real time kernel for better audio latency, I use Stereo Tool as a general DSP (Yes, very overkill) and the total latency of 150ms is a little annyoing at times.

So I have installed the linux 5.9 rt kernel and checked if I have the rt preempt flag which i do.

But when I check the niceness of pulseaudio it is still at -15, despite being configured in /etc/pulse/daemon.conf to use real time scheduling.

Same with executing the Stereo Tool application, which supports real time, running it with sudo or with sudo nice -n 99, the niceness will still be 0 in htop.

Now the weird thing. I can set the priority of the process in ksysguard to fifo highest priority, and it will show in htop as being “RT”, but… the audio still stutters at diversity delay below 40 ms, which means it is definitely not running real time according to their guide.

Do I need to create a new user group or something to run programs within that?

You can use sudo chrt 99 myprog to run a program with the highest real time priority.

Note, that the “niceness” value is not used for real time tasks. What you want to pay attention is the “PRI” row of htop. You should see “RT” there for real time processes.

Have you change the realtime-priority to 99?

3 Likes

I’ve marked the below answer as the solution to your question as it is by far the best answer you’ll get.

However, if you disagree with my choice, please feel free to take any other answer as the solution to your question or even remove the solution altogether: You are in control! (If you disagree with my choice, just send me a personal message and explain why I shouldn’t have done this or :heart: or :+1: if you agree)

:innocent:
P.S. In the future, please don’t forget to come back and click the 3 dots below the answer to mark a solution like this below the answer that helped you most:
Solution
so that the next person that has the exact same problem you just had will benefit from your post as well as your question will now be in the “solved” status.

1 Like

^Thank you. I had a really busy time with some work and left this unanswered.

I just got back home and it worked, with sudo chrt 99.
Pulseaudio however requires a feature request to do priority 99 (by itself -15 is all it would do), but for now a workaround: I just start it manually, disabling it’s autostart entry and including in the startup script the same sudo chrt 99.
Everything is working fine now, i managed to cut down my audio latency.

1 Like

The last time I saw this software was over 10 years ago when i was using XP.
I was looking at it for use with internet streaming radio but it was excessive even for that use case

StereoTool is an essential piece of software for radio stations with AM/FM transmitters where audio has to meet strict technical standards (limited frequency and dynamic range)
Processing is the last stage before the transmitter and the audio output is usually not monitored, so latency does not matter

Stereo Tool 8.00
For the best quality, and definitely in all cases where the delay does not matter, use the maximum setting (4096 samples, around 93 ms, depending on the sample rate). A good compromise between latency and quality is setting 1024 (23 ms), which gives a total latency of about 28 ms (this includes sound card delays and the time needed to process the audio).

You could probably get better results without latency problems using pulseffects or viper4linux
but PulseAudio is not ideal for lowlatency audio

If you want low latency and a big selection of DSP effects try JACK instead of PulseAudio
or ALSA if you can get by with simpler native Linux DSP

2 Likes

Good old XP times :slight_smile: I heard that source code for XP SP1 got leaked, what if someone makes a new XP for the current time?

It will seem funny but the reason I use StereoTool is to add dynamic range, not reduce it. :slight_smile: Basically I keep the FM stack and limiters all off, and just do Normal output.

There is an effect called Natural Dynamics which I use together with the Auto EQ, it increases the dynamic range and makes many things like poorly mastered music or movies etc, come alive and not be so squashed.

And with poorer quality audio the restoration effects like declipper, delossifier, noise gate etc work extremely well.

The sound that is coming out of ST I never managed to get with any DSP. Viper4linux does seem interesting and I loved the reverb effects when using it with a older rooted Android phone a while back, but other than that it was missing the fine control over stuff, ended up sounding exagerated.

Thanks for looking into it. I’m surprised people out there know about this extremely niche stuff hehe, cheers man!

Here’s how I use the program:

(What I managed now with the improved latencies, a 10 ms delay on the output of ST and 3ms on Pulseaudio, 2048 samples quality and got the overall latency down to 55 ms. The input is alsa loopback, I’m loading the modprobe at boot and a startup script loads the pulseudio loopback sink)

1 Like

Stereo Tool is specific to radio broadcasting and not well known. There was another called Breakaway Broadcast that was more affordable for community stations
The cost of the effects you suggest using would be €389.00 (£350.92 in UK) not including the microphone processing plugin
I do not see many Linux users would be interested because of that cost
harrisonconsoles.com have professional audio tools for Linux that are familiar to a wide range of audio users and are less expensive. Harrison have made some of the finest audio hardware for many years.

But the free Linux packages on JACK are more than enough for my needs. I have a modest 10mS total round trip latency in JACK to have zero errors all the time, but I could optimise audio to get under 5mS if I needed to

with poorer quality audio the restoration effects like declipper, delossifier, noise gate etc work extremely well

most users do restoration in pre-production, and most of them still use Audacity even if they have better processing tools. If I have any audio that is poor quality it is not allowed in the main playlist of live content until it is fixed in Audacity and scanned for audio levelling

I am not sure what exactly the ‘natural dynamics’ is doing, but it may be useful to retain it for live DSP
I think it is an expander combined with something else I can’t identify yet

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.