You are not logged in.

#1 2020-05-20 23:11:47

mjd119
Member
Registered: 2020-05-07
Posts: 20

[SOLVED] Pulseaudio Crackling/Popping When Playing Audio

I've noticed crackling/popping with my audio, especially when my CPU is under load. I can recreate the noise consistenly when I'm playing youtube on chromium and when streaming from mpd when I hold down the left and right arrow keys while viewing a pdf using qpdfview. I do not have a default.pa in my home directory for my user. I have the line "load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1" to run mpd as its own user (see Arch Wiki). I added "tsched=0" to "load-module module-udev-detect" to try to solve the issue since the Arch Wiki recommended it. The only instance of the line is within an if statement, so I'm not sure if I should have the line outside of it. I want audio to have a very high priority to prevent skipping. My etc/pulse/default.pa is:

#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)

.fail

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties

### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available

### Load audio drivers statically
### (it's probably better to not load these drivers manually, but instead
### use module-udev-detect -- see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

### Automatically load driver modules depending on the hardware available
## tsched=0 added by mjd119 to disable timer-based scheduling
.ifexists module-udev-detect.so
load-module module-udev-detect tsched=0
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif

### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif

### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif

### Load several protocols
load-module module-dbus-protocol
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#Added by mjd119 (commenting out was source of problem when attempting to run mpd as own user)
#load-module module-native-protocol-tcp 
#load-module module-zeroconf-publish
# Added by mjd119 (Arch Wiki)
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 

### Load the RTP receiver module (also configured via paprefs, see above)
#load-module module-rtp-recv

### Load the RTP sender module (also configured via paprefs, see above)
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'"
#load-module module-rtp-send source=rtp.monitor

### Load additional modules from GSettings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gsettings.so
.nofail
load-module module-gsettings
.fail
.endif


### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Honour intended role device property
load-module module-intended-roles

### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle

### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif

### Enable positioned event sounds
load-module module-position-event-sounds

### Cork music/video streams when a phone stream is active
load-module module-role-cork

### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply

### Make some devices default
#set-default-sink output
#set-default-source input

EDIT:
I forgot to mention that I did open alsamixer and made sure loopback is disabled (recommended by wiki).

Last edited by mjd119 (2020-05-22 19:16:06)

Offline

#2 2020-05-21 13:27:35

coolion
Member
Registered: 2019-11-02
Posts: 7

Re: [SOLVED] Pulseaudio Crackling/Popping When Playing Audio

I had similar issues with crackling on a rpi. You can try to raise the buffer that is used by the pulseaudio instance that is doing the actual playback to ALSA:

pacmd update-sink-proplist "alsa_output.platform-soc_audio.analog-stereo" device.buffering.buffer_size=1048576

... just change the device name to your playback device and the buffer-size. The default buffer size was 128k, changing to 1M made it work. I am telling this because I also played with the "tsched" parameter but it had no effect, it actually made it worse.
The proposed command is just raising the buffer temporarily, a reboot and all is back to what it was before, so it is safe to play with.

Offline

#3 2020-05-21 17:51:13

mjd119
Member
Registered: 2020-05-07
Posts: 20

Re: [SOLVED] Pulseaudio Crackling/Popping When Playing Audio

I wasn't sure whether the problem was the same, worse, or better after I changed the tsched parameter. Is there a file to edit that will make the change permanent? Or do you just recommend changing the buffer every time you reboot?
EDIT: Also, how do I found out what my device is?

Last edited by mjd119 (2020-05-21 18:04:07)

Offline

#4 2020-05-21 19:08:39

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 9,710

Re: [SOLVED] Pulseaudio Crackling/Popping When Playing Audio

If it works you can add the working update-sink-proplist command without the pacmd to the end of your /etc/pulse/default.pa to have it applied automatically each time. To identify the device to apply (and to check the buffer sizes) to look  at

pacmd list-sinks

Last edited by V1del (2020-05-21 19:09:41)

Online

#5 2020-05-22 19:15:34

mjd119
Member
Registered: 2020-05-07
Posts: 20

Re: [SOLVED] Pulseaudio Crackling/Popping When Playing Audio

Running "pacmd list-sinks" and then running the pacmd update-sink-proplist appeared to fix the problem but I'll have to do more tests. I see more memory and cpu usage from pulseaudio and mpd, but that's too be expected since I increased the buffer. I play lossless music almost exclusively so the extra buffer probably helps prevent skips more so than with mp3. I'll try to set the change permanently as suggested by V1del. Thank you to V1del and coolion!

Last edited by mjd119 (2020-05-22 19:15:48)

Offline

#6 2020-05-22 23:43:24

mjd119
Member
Registered: 2020-05-07
Posts: 20

Re: [SOLVED] Pulseaudio Crackling/Popping When Playing Audio

After some tests, I still have crackling/popping after adding the command to my default.pa file. I can reproduce it consistently if I page through a large pdf file (3682 pages). It is not as bad as it was before but it still bothers me and I get the noise if I am doing something where there is a bump in cpu usage. I have tried it with and without the tsched=0 argument. My /etc/pulse/default.pa file is now:

#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)

.fail

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties

### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available

### Load audio drivers statically
### (it's probably better to not load these drivers manually, but instead
### use module-udev-detect -- see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

### Automatically load driver modules depending on the hardware available
## tsched=0 added by mjd119 to disable timer-based scheduling
.ifexists module-udev-detect.so
load-module module-udev-detect tsched=0
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif

### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif

### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif

### Load several protocols
load-module module-dbus-protocol
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#Added by mjd119 (commenting out was source of problem when attempting to run mpd as own user)
#load-module module-native-protocol-tcp 
#load-module module-zeroconf-publish
# Added by mjd119 (Arch Wiki)
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 

### Load the RTP receiver module (also configured via paprefs, see above)
#load-module module-rtp-recv

### Load the RTP sender module (also configured via paprefs, see above)
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'"
#load-module module-rtp-send source=rtp.monitor

### Load additional modules from GSettings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gsettings.so
.nofail
load-module module-gsettings
.fail
.endif


### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Honour intended role device property
load-module module-intended-roles

### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle

### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif

### Enable positioned event sounds
load-module module-position-event-sounds

### Cork music/video streams when a phone stream is active
load-module module-role-cork

### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply

### Make some devices default
#set-default-sink output
#set-default-source input
# Added by mjd119 to increase buffer for pulseaudio
update-sink-proplist alsa_output.pci-0000_0b_00.4.analog-stereo device.buffering.buffer_size=1048576

and pacmd list-sinks returns:

2 sink(s) available.
    index: 0
	name: <alsa_output.pci-0000_09_00.1.hdmi-stereo-extra4>
	driver: <module-alsa-card.c>
	flags: HARDWARE DECIBEL_VOLUME LATENCY 
	state: SUSPENDED
	suspend cause: IDLE
	priority: 9030
	volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: yes
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 0
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	fixed latency: 100.14 ms
	card: 0 <alsa_card.pci-0000_09_00.1>
	module: 6
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "HDMI 4"
		alsa.id = "HDMI 4"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "10"
		alsa.card = "0"
		alsa.card_name = "HD-Audio Generic"
		alsa.long_card_name = "HD-Audio Generic at 0xfcca0000 irq 103"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:09:00.1"
		sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:07:00.0/0000:08:00.0/0000:09:00.1/sound/card0"
		device.bus = "pci"
		device.vendor.id = "1002"
		device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
		device.product.id = "ab38"
		device.product.name = "Navi 10 HDMI Audio"
		device.string = "hdmi:0,4"
		device.buffering.buffer_size = "17664"
		device.buffering.fragment_size = "2944"
		device.access_mode = "mmap"
		device.profile.name = "hdmi-stereo-extra4"
		device.profile.description = "Digital Stereo (HDMI 5)"
		device.description = "Navi 10 HDMI Audio Digital Stereo (HDMI 5)"
		alsa.mixer_name = "ATI R6xx HDMI"
		alsa.components = "HDA:1002aa01,00aa0100,00100700"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		hdmi-output-4: HDMI / DisplayPort 5 (priority 5500, latency offset 0 usec, available: yes)
			properties:
				device.icon_name = "video-display"
				device.product.name = "U2879G6"
	active port: <hdmi-output-4>
  * index: 1
	name: <alsa_output.pci-0000_0b_00.4.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
	state: SUSPENDED
	suspend cause: IDLE
	priority: 9039
	volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 1
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	fixed latency: 100.14 ms
	card: 1 <alsa_card.pci-0000_0b_00.4>
	module: 7
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "ALC887-VD Analog"
		alsa.id = "ALC887-VD Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "1"
		alsa.card_name = "HD-Audio Generic"
		alsa.long_card_name = "HD-Audio Generic at 0xfcb00000 irq 104"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:0b:00.4"
		sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:0b:00.4/sound/card1"
		device.bus = "pci"
		device.vendor.id = "1022"
		device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
		device.product.id = "1487"
		device.product.name = "Starship/Matisse HD Audio Controller"
		device.string = "front:1"
		device.buffering.buffer_size = "1048576"
		device.buffering.fragment_size = "2944"
		device.access_mode = "mmap"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "Starship/Matisse HD Audio Controller Analog Stereo"
		alsa.mixer_name = "Realtek ALC887-VD"
		alsa.components = "HDA:10ec0887,1458a184,00100302"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		analog-output-lineout: Line Out (priority 9000, latency offset 0 usec, available: no)
			properties:
				
		analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: yes)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-headphones>

I do not believe the AMD Navi sink works (I plug a aux cord into my desktop which connects to my motherboard, not GPU. Turning on audio for NAVI when I'm using KDE Plasma, for example, gives no audio output.
It looks like the line added to default.pa resulted in a change to the buffer size, but I still get the noise. Is completely eliminating it possible? Should I increase the fragment size as well? I'm not sure what the difference is between the buffer size and the fragment size. My CPU is a Ryzen 3600 so I should be able to manage the extra load from keeping a larger cache for audio. I want audio to be prioritized over everything else (skips in the audio takes me out of the immersion).

EDIT:
I'm doing this in i3 which should be the best situation for trying this due to how lightweight i3 is, unless there's a quirk with audio I'm missing (issue happened in KDE Plasma too).
ADDITIONAL INFO:
Running pacmd list-sinks|egrep -i 'index:|name:' (according to Arch Wiki) gives me:

    index: 0
	name: <alsa_output.pci-0000_09_00.1.hdmi-stereo-extra4>
  * index: 1
	name: <alsa_output.pci-0000_0b_00.4.analog-stereo>

so I know I adjusted the correct sink.

Last edited by mjd119 (2020-05-22 23:58:13)

Offline

#7 2020-05-23 09:37:14

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 9,710

Re: [SOLVED] Pulseaudio Crackling/Popping When Playing Audio

Hmm Ryzens seem to be notorious for sound issues linked to CPU activity, there have been quite a few threads were disabling/unloading the CPU temp module (k8temp I believe) helped with audio dropouts. Maybe also check for vendor UEFI/BIOS updates.

Online

#8 2020-05-23 16:22:00

mjd119
Member
Registered: 2020-05-07
Posts: 20

Re: [SOLVED] Pulseaudio Crackling/Popping When Playing Audio

I updated my bios about a month ago so I don't think that's the issue. Could you link to threads about audio dropouts with Ryzen?

Offline

Board footer

Powered by FluxBB