How can I ensure my audio recordings don't lag?

Hey all, just thought I'd ask for some advice and/or thoughts on this issue.

I'm looking to record gameplays and have a script to setup screen recording, webcam recording, and mic recording. After some testing, my webcam and desktop recording seem fine, but under heavy load, my mic audio is... having issues. Here's a snippet of it.

I'm using pipewire and pw-record to record my mic. Increasing the "Resampling quality" (-q) to 15 with the command seems to help mitigate the issue, but it still "jumps" here and there, so I'm not 100% confident in it. What's stranger, Audacity seems to record without any issues at all during the same tests.

So how come Audacity records fine, but pw-record has issues? Ideally, I'd like to be able to use pw-record even with more GPU-/CPU-intensive games.

Any thoughts/ideas? Thanks in advance :)

Edit: using arecord seems to work better!

Posted Mar 29, 2022, 9:11 PM UTC ยท edited

16
dundirโ€ข

Use a realtime pre-emptible or low latency kernel.

2
whizzythorneOPโ€ข

I'll try that out, thanks ๐Ÿ˜ edit: I tried, no luck

1
whizzythorneOPโ€ข

It made no difference, unfortunately :(

1
dundirโ€ข

You might try setting the NI setting for the recording process to a higher priority (lower number). You can set this using renice.

1
whizzythorneOPโ€ข

That was my first idea, but I never tried it because it would require sudo. I think there's a way to set niceness negative without sudo though, right?

1
dundirโ€ข

It generally requires sudo to be used, but its only active for the lifetime of the process (meaning if you reboot its non-persistent).

1