Sound comes out distorted when running certain games or other CPU intensive stuff

Recently my sound has come out completely distorted when my CPU usage gets high, but not consistenly. I first noticed this two weeks ago when I was playing Bloons TD6. After a while my sound comes out like this , regardless of it being on laptop speakers or on headphones. This happened again yesterday on a different game, and also while chatting on discord.

I have never had any issue like this before, be it in the same games and programs or when compiling packages which brought CPU usage up to 100%. I also have no idea how to troubleshoot this. I have not touched the pipewire packages, and the only change I’ve done that is sound related is changing Audacity’s default input to be on JACK. I cannot imagine this being relevant for this issue, as it (1) shouldn’t be and (2) it’s a very long time since I did so.

Usually I’d reinstall at this point, but after a forum post yesterday where someone mentioned it might make it so that this issue isn’t patched I decided to create another post about this. If this doesn’t get solved, I might be left with no ofter choice than reinstalled as I’m a composer.

I’m running EndeavourOS’s i3 flavour.

Software information

Kernel: 6.4.3-arch1-1

Card: PipeWire
Chip PipeWire

[runarcn@endeavour ~]$ pacman -Q | grep pipewire
gst-plugin-pipewire 1:0.3.74-1
kpipewire 5.27.6-1
libpipewire 1:0.3.74-1
pipewire 1:0.3.74-1
pipewire-alsa 1:0.3.74-1
pipewire-audio 1:0.3.74-1
pipewire-jack 1:0.3.74-1
pipewire-pulse 1:0.3.74-1

[runarcn@endeavour ~]$ lspci -v | grep -i audio
00:1f.3 Multimedia audio controller: Intel Corporation Tiger Lake-LP Smart Sound Technology Audio Controller (rev 20)
	Subsystem: Lenovo Tiger Lake-LP Smart Sound Technology Audio Controller
	Kernel driver in use: sof-audio-pci-intel-tgl

[runarcn@endeavour ~]$  cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version k6.4.3-arch1-1.

Hardware information

CPU: 11th Gen Intel i3-1115G4 (4) $ 4.100GHz
GPU: Intel Tiger Lake-LP GT2 [UHD Graphics G4]

[runarcn@endeavour ~]$ cat /proc/asound/cards
 0 [sofhdadsp      ]: sof-hda-dsp - sof-hda-dsp

Does the problem appear on liveusb as well? If not, you could compare package versions & configs from it and see if you find any possible causes.

I’m a lot more experiences in PulseAudio than Pipewire, so sadly cannot give any solid pointers on this.
I know I’ve heard exactly the same audio problem as in your audio clip, but I just cant remember what the fix was for it and was it in pipewire or pulseaudio.

Found issue reported year ago, possible fixes downgrading pipewire and/or changing sampling rate in settings.
Arch wiki on pipewire also had same suggestion about sample rates in #5.1.15 Audio is distorted.

For professional audio Arch forums had thread with issue being missing PAM limits

Did you put your system into suspend before you launch the game? This might have something to do with a bug in rtkit where rtkit lowers the priority of realtime threads after supension.

Try using a different kernel. In my experience, zen and tkg-pds are better. tkg-bmq is by far the best if you have ridiculous load, but (so I was told) it’s primarily made for older games. In any way, I was able to play Overwatch without problems while compiling the Linux kernel. And I really mean that I couldn’t notice that my CPU was at 100%. Frame rate, input lag, etc., everything was normal (200FPS locked, without any drops). I thought that was really impressive.