Linux Ubuntu Speakers Popping every few seconds

Hello SuperUser Community,

I'm new to Linux Ubuntu, long time Windows User, and glad I'm making the switch. When setting up my desktop PC, I am subjected to an annoying and repetitive speaker 'pop' about every 2 seconds. This pop occurs regardless of volume level. It does stop if I unplug the audio jack to my speakers, and just use the speaker built into the motherboard. If I play a sound, the popping stops while the sound is playing and for about 5 seconds after, then resumes.

I am running Linux Ubuntu 18.04.3 LTS. The system information reports two Audio Adapters, HDA-Intel - HDA ATI SB & HDA-Intel - HDA NVidia

I did eventually find the solution to this problem, but I don't have enough reputation points to post Q&A together.


Solution 1:

The operation system's default behavior is to save power by turning off the Audio Adapter after 10 seconds. This power-save feature is causing the popping, and can be disabled.

In Terminal type sudo nano /sys/module/snd_hda_intel/parameters/power_save and change the value from 1 to 0.

Then type sudo nano /sys/module/snd_hda_intel/parameters/power_save_controller and change the value from Y to N.

On my system, this solved the audio popping problem immediately. However on reboot, the problem came back and I found these values had been reset. To keep these values persistent, I had to add a line of code to /etc/modprobe.d/alsa-base.conf I added this after the last line of code in the file, options snd-hda-intel power_save=0 power_save_controller=N

Save the file, and you're good to go!

Much of my information came from this video : https://www.youtube.com/watch?v=Pdmy8dMWitg

I had to piece together the "persistence after reboot" part, and my setting did reset even though I do not have TLP installed. Note that the video claims otherwise.

I was quite frustrated with Ubuntu until I figured this out. I hope this helps many people solve their audio issues!

Solution 2:

As a followup to @Glen's answer, here is a script that performs the task:

fix_ubuntu_18_04_sound_pop_issue(){
    __heredoc__="""
    Script that fixes a popping sound due to a power saving feature

    References:
        https://superuser.com/questions/1493096/linux-ubuntu-speakers-popping-every-few-seconds
        https://www.youtube.com/watch?v=Pdmy8dMWitg
    """
    sudo echo "obtaining sudo"
    # First, there are two system files that need modification
    # Changing the values here should fix the issue in your current session. 
    cat /sys/module/snd_hda_intel/parameters/power_save
    cat /sys/module/snd_hda_intel/parameters/power_save_controller
    # Flip the 1 to a 0
    sudo sh -c "echo 0 > /sys/module/snd_hda_intel/parameters/power_save"
    # Flip the Y to a N
    sudo sh -c "echo N > /sys/module/snd_hda_intel/parameters/power_save_controller"

    # To make this change persistant we must modify a config file
    if [ -f "/etc/default/tlp" ]; then
        # Some systems (usually laptops) have this controlled via TLP 
        sudo sed -i 's/SOUND_POWER_SAVE_ON_BAT=1/SOUND_POWER_SAVE_ON_BAT=0/' /etc/default/tlp
        # This line contained a typo, addressed on 2020-10-11 11:11 Bcn time
        sudo sed -i 's/SOUND_POWER_SAVE_CONTROLLER=Y/SOUND_POWER_SAVE_CONTROLLER=N/' /etc/default/tlp
    elif [ -f "/etc/modprobe.d/alsa-base.conf" ]; then
        # Append this line to the end of the file
        text="options snd-hda-intel power_save=0 power_save_controller=N"
        fpath="/etc/modprobe.d/alsa-base.conf"
        # Apppend the text only if it doesn't exist
        found="$(grep -F "$text" "$fpath")"
        if [ "$found" == "" ]; then
            sudo sh -c "echo \"$text\" >> $fpath"
        fi
        cat "$fpath"
    else
        echo "Error!, unknown system audio configuration" 1>&2
        exit 1
    fi
}