19

I have recently switched over to Ubuntu 24.04 and I hear crackling sounds more often why is it and how can I fix it?

Emanuele
  • 1,044

12 Answers12

24

The likely issue for crackling sounds on Ubuntu 24.04 is that the distro has been switching over to pipewire and it runs a conversion service from pulse audio, namely pipewire-pulse.

The challenge is that many apps don't directly talk to piepewire, but do it through JACK and/or especially pulse itself, hence sound data needs to be moved though additional hops.

The default time buffers for pipewire-pulse is 2.7 ms, which means that an application needs to be able to fill sound content every 2.7 ms, otherwise pipewire will send to the audio device whatever was previously filled and potentially some random data, hence the crackling.

2.7 ms is quite a stringent time, especially for applications which don't have dedicated threads for audio (likely Proton/wine/games) and/or when running on old CPUs - hence one way to limit cracking is to tell pipewire-pulse to set a larger time buffer, albeit adding a delay to when the sound is sent to the audio device.

In order to do so, one needs to open the file:

/usr/share/pipewire/pipewire-pulse.conf

And then find, uncomment and change the configuration for the item:

pulse.min.quantum      = 128/48000     # 2.7ms

from he value 128 to something larger - one should try 256 or even 512 as a starting point and if they experience no crackling they should leave as is (please note that after saving the file, one has to restart pipewire, pipewire-pulse via systemctl --user restart wireplumber pipewire pipewire-pulse).

The key is to find the smallest number so that the annoying crackling is not present (or at an acceptable minimum), because if larger numbers (such as 1024) make very little crackling happen, they add a delay (1024 / 48000 -> 21.333 ms).

Slower CPUs will need numbers as 512 or higher, or when using multiple software keeping the CPU busy, it's likely that a number such as 1024 or even 2048 may be beneficial.

Please note that crackling is by default (128/48000) noticeable on a 5950x (32 cores/16 threads) with 64 GiB of ram, hence it's likely much more noticeable on less powerful CPUs.

As a side note, not sure why/how Canonical/Ubuntu have decided to ship this stringent config, looking at how many threads complaining about crackling are pervasive on this forum and others.

Emanuele
  • 1,044
3

I searched again for kernel 6.8 and ati sound issues , i read this https://bbs.archlinux.org/viewtopic.php?id=294114 and run these commands

wpctl clear-default  
systemctl restart --user pipewire

So far it seems to have resolved the issue. Others in this forum post agree , something to do with wireplumber. 10 mins after still no issues with sound on videos , checked also the HDMI output. UPDATE: Unfortunatelly , after 1 day problem appeared again.

2

The accepted answer from @Emanuele works for me on Linux Mint 22 (Ubuntu 24.04).
It's surprising that it has 0 votes. Due to not enough 50 reputations, I cannot comment or upvote, so I am writing this here so that others know the solution is worth trying.

I created a small script to automate the solution:

# copy the default config to `/etc/pipewire` for editing
export newConf=/etc/pipewire/pipewire-pulse.conf
sudo mkdir -p $(dirname $newConf)
sudo cp /usr/share/pipewire/pipewire-pulse.conf $newConf

uncomment and change the value from 128 to 1024

sudo sed -i.bak 's/#pulse.min.quantum = 128/48000 # 2.7ms/pulse.min.quantum = 1024/48000/' $newConf

check if the sed command successfully changed the config, log should show 1024

cat $newConf | grep "pulse.min.quantum"

after changing the config, restart the audio services

systemctl --user restart wireplumber pipewire pipewire-pulse

I restart the computer too

1

I was on Ubuntu 22.10 to 23.10 with kernel up to 6.11 w/o cracking problems. The problem started after exactly after upgrading to Ubuntu 24.04. The tool helps once, but the pause a Youtube video and start again or making s screendump(camera sound) the cracking noise comes back again. PW may work for on board CODECS but external usb audio devices seems not well supported, in the past 10 years before PW, could run 5 to 8 msec with 3 buffers in Jack2. Now it needs at least 512 bytes. I am running the Pro audio profile.

Also when I switch on my USB interface while Ubuntu is running it does not see the device. No one else has PW issues like these ? Is there any issues tracking this ?

Bug
  • 97
1

Kernel 6.13 seems to solve this issue. No more noise on the USB audio interface. :-)

Bug
  • 97
0

In Ubuntu 24.04 (at least) there is now a utility "Ubuntu Studio Audio configuration" For me 48000 512 with external USB 2.0 audio interface worked. You can could also try install low latency kernel to get lower latency

Well, it works sort of... when going back or forward in videos the noise is coming back.

Bug
  • 97
0

The problem is caused by the kernel 6.8. Downgrading to previous version solves it.

lboullo0
  • 101
0

Just compiled kernel 6.12-rc1 with the new feature REALTIME kernel. It is stable and it reduces latency from 1024 to 256. 128 sample size is causing distortion. It's a bit better but it's still probably and best case 16msec latency (assume it's 3 buffers, can't tell) which is still unacceptable for audio production. (that is a direct monitoring headphone on the USB device will have a significant difference versus the audio from the USB host). and it still often come back making a screenshot or jumping forward or back while a playing video. 9using a USB 2.0 audio interface)

24.10 same result. (PREEMPT_REALTIME and PREEMPT_DYNAMIC)

Bug
  • 97
0

Issue seems to be with Ubuntu Kernel see https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2091565

echo "options snd-hda-intel snoop=0" | sudo tee /etc/modprobe.d/hdmisoundfix.conf sudo update-initramfs -u -k all

Fix I think is pending but for now above worked for me...

Amos Folarin
  • 1,214
  • 9
  • 11
0

Issue is with Linux kernel see solution here re setting kernel opt snoop=0 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2091565

Amos Folarin
  • 1,214
  • 9
  • 11
0

I had this problem on the 24.04 Ubuntu Unity flavor but on the HDMI audio only, no crackle on USB audio. ATI Tobago HDMI Audio in use.

Strangely, systemctl status --user pipewire revealed that pipewire was not running. So I decided to restart pulseaudio and this fixed the problem (the crackling was gone):

systemctl restart --user pulseaudio

On a side note, selecting the HD 5.1 HDMI profile from the Configuration tab of pavucontrol substantially reduced, but did not completely eliminate the crackling. But restarting the pulseaudio service fully fixed the problem (as of now).

mchid
  • 44,904
  • 8
  • 102
  • 162
0

Ubuntu 24.04 switched to PipeWire as the new default sound system. It's meant to be an improvement, but like any big change, sometimes it needs a little tweaking with certain hardware or existing configs, which can lead to issues like crackling.

here are a few things you can try (kinda in order of simplest first):

Basic Checks (Don't skip these!):

Make sure your system is fully updated: sudo apt update && sudo apt full-upgrade then sudo reboot. sometimes it's just a pending update...

Go into Ubuntu's "Sound" settings and try switching your "Output Device" to something else, then back to your main one. Sounds silly, but it can kick things back into place.

Update PipeWire & WirePlumber via PPA : The versions in the main Ubuntu repos might not be the absolute latest. Newer versions often have bug fixes for these kinds of issues.

sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream && sudo add-apt-repository ppa:pipewire-debian/wireplumber-upstream && sudo apt update && sudo apt full-upgrade

Then reboot.

Adjust PulseAudio Config : PipeWire has a compatibility layer for PulseAudio, so these settings can still help.

First, back up the file: sudo cp /etc/pulse/daemon.conf /etc/pulse/daemon.conf.bak

Then edit it: sudo nano /etc/pulse/daemon.conf

Find these lines (they might be commented out with a ; or #), uncomment them, and set them like this:

default-sample-format = float32le default-sample-rate = 48000

Save the file and reboot. This can sometimes smooth out quality issues.

Install pavucontrol (PulseAudio Volume Control):

sudo apt install pavucontrol

Run pavucontrol.

It gives you much finer-grained control than the default sound settings. Check the "Configuration" tab for your sound card and see if different profiles make a difference. Also, check the "Output Devices" tab to ensure the correct port is selected (e.g., "Line Out" vs "Headphones" if they are separate and one is noisy).