Static and crackling sound coming from speakers in 19.04

Asked and answered here.

The solution is to add this to /etc/modprobe.d/alsa-base.conf

options snd-hda-intel power_save=0 power_save_controller=N

You can create a systemd (system-daemon) service script that will run at boot.

Open a terminal and run:

sudo nano /etc/systemd/system/powersave.service

authenticate, then add the following to the file:

[Unit]
Description=powersave script

[Service]
ExecStart=/opt/powersave.sh

[Install]
WantedBy=multi-user.target

CTRL+O to save and CTRL+X to exit.

Then run...

sudo nano /opt/powersave.sh

...and add the following:

#!/bin/bash
echo 0 | sudo tee sys/module/snd_hda_intel/parameters/power_save

CTRL+O to save and CTRL+X to exit.

Finally, make the script executable:

sudo chmod+x /opt/powersave.sh

..then, enable the service by typing:

sudo systemctl enable powersave

This script will run on boot as the root user and should result in no more crackling, because it will keep your soundcard ON, instead of allowing it to go into powersaving mode.

This solution worked with my hardware. The output of lspci for my system is:

Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 02) 

I have same problem in 16.04 and 18.04. At present I am running 18.04.I have tried all suggestions from web like:

  • Kill Pulse Audio
  • Kill Pulse Audio and change /etc/pulse/default.pa
  • Try Following commands:

    hda-verb /dev/snd/hwC0D0 0x20 SET_COEF_INDEX 0x67
    hda-verb /dev/snd/hwC0D0 0x20 SET_PROC_COEF 0x3000

  • Removing Speech Dispacher
  • Set nice level of pulseaudio to -20 and allowing real-time priority of pulseaudio
  • Try changing power-save options like

    echo 0 > /sys/module/snd_hda_intel/parameters/power_save
    echo N > /sys/module/snd_hda_intel/parameters/power_save_controller

Some of the above options worked for some folks and not worked for most. I tried to some basic level debugging, so started doing strace when audio/video is on. Then the crackling sound was stopped. Here is the sample command I tried:

sudo strace -f -p $(ps -eaf|grep -E "^$USER.*/bin/pulseaudio"|grep -v grep|awk '{print $2}') 2>&1|head -1000

I found 1000 lines of strace output is sufficient to restore the sound. Please keep in mind following:

  • We have strace the pulseaudio process of the user (not the gdm process). So that is the reason we are grep'ing for $USER variable
  • When you are issuing above strace command, audio/video stream should be running
  • most of the 1000 line of strace is sufficient. You may double those lines or rerun the same command
  • Keep in mind that, if audio/video is changed, then same cracking sound will reappear. Once again run same script, the cracking sound will go.
  • Also keep in mind that this also might not solve your issue(until it is confirmed by lot others with various other configurations)