Sound crackling with Nvidia card

scf@

Developer
Every so often I here crackling during sound playback. It could happen while watching YouTube in Firefox or playing a video or audio file with mpv. "Did I hear something in the music track? Perhaps, the rip had a mistake or the CD has a scratch." I have tried to localize this issue for quite awhile. My motherboard has a Realtek ALC4080 (USB) chipset, so I have tried to find if it was a BIOS issue or a setting I made in /etc/sysctl.conf. The hardest part is that I did not know how to replicate it.

Well, finally, I have a way to do it easily. Start playing an MP3 file (or even cat a WAV file into /dev/dsp to rule out the software then run this script:

sh:
while [ ${?} -eq 0 ]
do
    nvidia-settings -q OpenGLVersion > /dev/null
done

That produce a decent amount of distortion for me. From watching with "vmstat -i 1", I see that playing music causes XHCI to use 8000 interrupts/sec. Now, with that little script, it falls to 4000-6000 interrupts/sec with all the CPU timers showing a few hundred each.

NOTE: xhci0 may be at 8000 at times without anything playing, but an app may still have a hold on /dev/dsp?
NOTE: cpu20 is an outlier for some reason.

System at rest or during playback of MP3:
Code:
cpu0:timer                            50         25
cpu1:timer                            95         47
cpu2:timer                            25         12
cpu3:timer                            13          6
cpu4:timer                            12          6
...
cpu20:timer                         2254       1126
...
irq129: xhci0                      16011       8001
...
irq174: vgapci0                      311        155
Total                              21166      10567

Code:
With polling from nvidia-settings:
cpu0:timer                          2679        535
cpu1:timer                          1959        391
cpu2:timer                          2200        440
cpu3:timer                          1920        384
cpu4:timer                          2395        479
...
cpu20:timer                         3997        799
...
irq129: xhci0                      24643       4925
...
irq174: vgapci0                     2549        509
Total                              91086      18203

Things that cause it:
  • glinfo > /dev/null
  • glxinfo > /dev/null
  • glxinfo -B > /dev/null
  • nvidia-settings -E > /dev/null
  • nvidia-settings -L > /dev/null
  • nvidia-settings -g > /dev/null
  • nvidia-settings -k > /dev/null
  • nvidia-settings -q all > /dev/null
Things that do not:
  • nvidia-smi -q > /dev/null
  • nvidia-settings -q screens -q gpus > /dev/null
  • nvidia-settings -q screens -q gpus -q framelocks -q fans -q thermalsensors -q svps -q dpys > /dev/null
  • nvidia-settings -q OpenGLImageSettings > /dev/null
  • Running multiple VMs.
  • Running poudriere builders.
  • Running a simple program I wrote to open and close repeatedly the following devices:
    • /dev/dri/card0
    • /dev/dri/renderD128
    • /dev/nvidia-modeset
    • /dev/nvidia0
    • /dev/nvidiactl
I am not sure what can be done or even how or where to report this issue since it could be:
  • My motherboard (Asus Z790-F Wi-Fi). Defect or the ALC4080.
  • Undervolting the CPU. Yes, I am one of those people. :) However, I would be surprised that polling the OpenGL version could do so much to a system.
  • GPU defect: PNY GEFORCE RTX™ 4070 XLR8 Gaming VERTO Edition
  • Nvidia driver: Currently, I am using 570.144 but any driver over the last year, I think.
  • FreeBSD 14-STABLE sound driver.
Things I have tried to fix it:
  • Tried reducing undervolting, but noticed no change.
  • Switched hw.acpi.cpu.cx_lowest back to C1. No change.
  • Removed a lot of sound settings I had in /etc/sysctl.conf to go to default. No change.
  • hw.usb.uaudio.buffer_ms=8. This is the only thing that has reduced it, by a lot. However, it still happens.
I did find this mpv issue #15775, but I do not think that is the same problem since vlc works well for them. Otherwise, it is an issue with the nvidia driver or possibly system timers? Hence, my dilemna: where do I continue for reporting this? I may consider getting an inexpensive PCI-e sound card (with an EMU10K1), but I do want it fixed to help others who may be frustated as much as I have been.
 
Have you tried with your user in realtime/idletime groups, and running lets say mpv in realtime priority ?
No change with running sudo rtprio 31 mpv file.mp3.

Interestingly, I noticed that my cursor runs slower and jumpy in an xterm when running that loop (without the music) while changing the query to OpenGLImageSettings does not have the problem. So, it is not just sound that is affected. Hmm.
 
Yes I have had interference from graphics Cards on analog sound . At some point I tested the PC's digital sound output to a DAC ( Digital-Analog-Converter) that was placed som meter or so away from the computer with analog Audi cables from the DAC to speakers , this did remove the Noise from the Audio stream.
I dont have any figures on the amountof RadioFrequencyInterference ( RFI) thats generated from a GPU , but with a soundcard next to the GPU the interference is noticable.
 
I am planning on getting the PCI-e sound card to see if that fixes my issue since I have a feeling the GPU/driver is causing issues with the USB bus since dragging an xterm also suffers.

I just created a new topic on the Nvidia forum for this and also found mention of someone else with Windows on a similar motherboard switching to a dedicated sound card:
 
Hey, i got the same problem. Using Nvidia card, crackling sound,... tried everything. Even installed pci-e soundcard and still crackles. Did you found the solution?
 
Hey, i got the same problem. Using Nvidia card, crackling sound,... tried everything. Even installed pci-e soundcard and still crackles. Did you found the solution?
Sadly, I have not found a solution. Using a sound card did reduce it some, yet the issue is still there.
 
So what i found out it's actualy NVIDIA problem. Could be drivers i don't know. I've replaced it with RX7600 radeon and so far no crackling whatsoever. So i recommend you to replace it with radeon if you want to use FreeBSD
 
In the professional audio community NVidia graphics cards are known to cause latencies large enough to disrupt sound, in some cases.

I would be curious to learn whether the onboard sound on the NVidia card itself (the HDMI/displayport one) is also affected.
 
Hello scf@ I'm glad to see a report of this because I experience the same thing but I wasn't sure whether there is something off with my hardware causing interrupt storms. I too have 'mended' it by removing all the sound sysctls I use for recording, 0ms latency etc. It made it better too.

Yes, dragging, resizing windows under Plasma generates the glitches. I can see extremely high CPU usage on intr at that time.

PCI-e interfaces, OK, but we only have RMEs working 100% and those are in another price range to usual USB stuff. But yes there are 'innate' advantages of running sound via PCI bus and not USB.

We can gather data (I'm still running the nvidia/Focusrite combo) and push nvidia with this.

I've also encountered random sound stutters while running VGA+Sound Blaster games in 86box, it is all running on the same core. The games will start OK, I will have >90% host usage and run 60 FPS graphics with fluid sound, which is perfect, but then it just begins with the speed glitching and host usage falls down to 33%. It lasts for a while, then things get back to normal.

The workaround for this is to pin the VM process to a set of cores.

So what i found out it's actualy NVIDIA problem. Could be drivers i don't know. I've replaced it with RX7600 radeon and so far no crackling whatsoever. So i recommend you to replace it with radeon if you want to use FreeBSD

Ugh. Absolutely a no solution. Nvidia is one of few hardware vendors that provides native FreeBSD drivers, they wrote and tested the driver (looks like they didn't pay attention to all systemic regressions, or they discarded that result...I'm not a fan of nvidia by any stretch, just objective)

The amdgpu driver you run on Radeon is a FreeBSD open source effort to port the open source driver AMD participated in for Linux using a emulation/translation layer of linuxKPI. I mean it probably works without major issues, but it is simply not the same type of deal like having 1st tier support from vendor...at this point FreeBSD has had 1st tier nvidia support for far longer than it was without it initially.
 
In the professional audio community NVidia graphics cards are known to cause latencies large enough to disrupt sound, in some cases.

While it does happen occasionally under Windows, the sound either works or doesn't. When it starts distorting, you can replug the interface and reset it to normal. It can happen once in a few days of heavy sound usage.

It is highly unlikely, from my statistics, to get this distortion 'phase' when running ASIO. Or games. The most times I get it, is on Youtube.

On FreeBSD, I cannot remember if it happens. What happens is if sound is configured for high performance almost any UI action produces a small period of glitching. Opening a browser window, detaching a tab, etc. Resizing a running YT video will almost always result in glitching. If sound is ran at default settings then situation is almost unrecognizable. A fraction of a second of sound glitch here and there.

Distortion (on win) and glitching on (BSD) are not the same artifact, on win the audio gets distorted and narrowbanded but retains temporal consistency, on BSD the audio frequency remains "OK" but timing is slowed down.

So yes, nvidia isn't without problems in this area but it is not a clear cut case and a showstopper for (hobby) DAW. The FreeBSD issue manifests itself differently.
 

Correct me if I'm wrong but there are two options if you want to run a new PCI express interface. ESI Juil@ with snd_envy24ht, or RME HDSPEe AIO/RayDAT with snd_hdspe. With the giant caveat that envy24 driver doesn't have recording capabilities.

So its either the cheap entry level interface without recording(!) or the expensive pro interface with full support but FreeBSD cannot run any of the professional tooling that comes special for this card. RayDAT is cheaper option but has no analog ports, at about 500 euros. AIO, the old model is not sold any more, and new "AIO Pro" costs about 800-900e new.
 
yes i agree i was a long time Nvidia user, especialy for FreeBSD because it was always well supported and easy to install.
And i'm sad i had to change it for something else.
I've tried with 2 different nvidia cards and both had the same issue.

Tbh amdgpu runs smooth, no glitches, graphic acceleration works just fine and i got no problem.
I never use it for games since i got a dedicated 9070xt windows PC just for games, so for my main workstation FreeBSD with amdgpu works great!
 
Back
Top