Pipewire was slowing down my emulators. Uninstalled and changed to Pulseaudio - now I have noise when playing my games on them

Hi EndeavourOS users!

I’m struggling with my sound system and game emulators (specifically Mednafen and MAME . When I’m using Pipewire 1:1.0.0-2 with wireplumber, the frames rates on Mednafen (in Playstation 1 and Sega Saturn Games) drops from 60 fps to 18 fps, making games unplayable . So, after some days and tests, I figured out that Pipewire was the culprit and uninstalled it, and went back to Pulseaudio. The frame rates go back to normal (60 fps), but now I face a new problem: when I use Mednafen or MAME (both configured to use the ALSA driver at bitrate 48000), all games have cracks / sound artifacts when playing it.
I found this guide:
https://wiki.archlinux.org/title/PulseAudio/Troubleshooting#Laggy_sound
And try to change my bitrate in /etc/pulse/daemon.conf to 48000 because it was 44100 (as default and 48000 as alternate) and change avoid-resampling to yes. After some tries, it worked, but by mistake I changed it, and the problem returned. Now I can’t remove the noise, and learned that Pulseaudio can’t accept some values or options (tried to change bitrate to 96000 but Pulseaudio don’t accept it, only 48000 and 44100). Also I learned to edit the daemon.conf file in ~/.config/pulse/daemon.conf because one time I lost system sounds, and I had to delete the ~/.config/pulse (it’s more secure to edit the ~/.config/pulse/, since /etc/pulse/ are the system wide configs, if you mess with them you break your sound server).
So I’m asking for help to fix this pops/noise artifacts, since when I do:
$ inxi -Aaz
I get four sounds servers ( sndiod, JACK, Pipewire and Pulseaudio - could they be in some conflict?). And I can’t uninstall completely Pipewire because the depencies will break my system, but it’s inactive (I masked the service and socket).

Ok, here are some specs:
https://0x0.st/H3bN.txt
(Yes my sound board is a Sound Blaster, I don’t use the onboard Intel Sound Device), and adding

$ sudo tee /sys/module/snd_hda_intel/parameters/power_save <<< 0

don’t solve my problem.

$ pactl info
Server String: /run/user/1000/pulse/native
Library Protocol Version: 35
Server Protocol Version: 35
Is Local: yes
Client Index: 15
Tile Size: 65472

Server Name: pulseaudio
Server Version: 16.1
Default Sample Specification: s24le 2ch 48000Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.pci-0000_05_00.0.analog-stereo
Default Source: alsa_input.pci-0000_05_00.0.analog-stereo
Cookie: c9e7:f0e3

Thanks in advance for any help!

Are you having this issue with regular videos or audio as well, or is it only the games?

Please test this using a browser - so open up a video streaming site and audio streaming site.

You can try this video from peertube: https://lostpod.space/w/24790770-6832-441f-9327-7999dd91648d
and this audio: https://freesound.org/people/jalastram/sounds/714581/

And test it with a media player - this time play an audio-only file and a video file with audio.

If you don’t have any downloaded audio or video files, you can download the same ones linked above.

Hi ddnn! Thanks for the answer!

I tested the video and audio with browser - they play fine, without noise.
Tested with my audio files .ogg in VLC and Audacious - they play fine, without noise.
Tested my video files with VLC - they play fine, without noise.

The problem is noise when I play games in MEdnafen and MAME - others emulators, like Kega Fusion, PCSX2, Muppen64Plus, Steam - runs fine without noise. Browsers and VLC and Audacious play fine too.

But there is something to say about Mednafen: according the documentation:

  • Mednafen: Select a sound device that is closest to the actual hardware; IE “hw:0”, “hw:1”, “hw:2”, etc. on ALSA.
    Avoid selecting a higher-level sound device that is routed through a sound server like PulseAudio!*

So I went to the configuration (thinking about how to set my device as hw:0) and set sound device as ALSA (it was in default) and the noise was gone in the games! But then, I went in MAME, and the noise remains. So I began to think about the volume, went to alsamixer and looked at Surround, PCM and Front volume - they were ate 100%. I reduced to 75% and type at terminal:
$ sudo alsactl store
to preserve my alsamixer settings - and the noise returned to mednafen and still continues on MAME .
(Note: I rebbot the computer and the volume settings go back to 100%)

Now I am thinking about my ALSA settings doesn’t matching with Pulseaudio.

Ah - before I forgot:
I tried to change em ~/.config/daemon.conf:

  • flat-volumes = no (didn’t work with the noise)

  • default-fragments = 5 and default-fragment-size-msec = 2 (didn’t work with the noise)

And in ~/.config/pulse/default.pa:

  • load-module module-udev-detect tsched=0
  • didn’t work with the noise, but my FPS in Mednafen went to 130-150! Whoa! So I began to think if it was the time scheduler in Pipewire that was slowing down my games (but I can’t test this now)

So, anybody has any hints about it could be my ALSA settings modifying my Pulseaudio and/or some conflict? What is strange is, if I correct the noise as above, the slightest change mess with the games.

Thanks in advance!

:tired_face:
You need to put a summary/TL;DR for this. Way too much info.

Highly likely to be a conflict caused by pulseaudio.

Hello to everyone! Sorry for the delay in posting, but I was testing a lot of config changes in ~/.config/pulse/daemon.conf, and I found a fix for removing the noise in Mednafen.
First, I tried to modify ~/.config/pulse/daemon.conf according to this article. Sometimes the changes work for a small time, and I was getting tired of the problem returning after changing another part of the system (like alsamixer, for example).
But then I find this article. So I tried a few hints from this article, and they worked.
So what did I changed in my system:

  • in ~/.config/pulse/daemon.conf:
    I’ve uncommented and changed the values of:

; avoid-resampling = no
; default-sample-format = s16le
; default-sample-rate = 44100

to:

avoid-resampling = yes
default-sample-format = float32le
default-sample-rate = 48000

(to explain a little: enabled avoid-resampling and default-sample-rate=48000 since in both articles they said that this settings can improve the audio; default-sample-format as float32le because the second article recommends this setting, and it appeared when I played a .ogg file whith audacious and used this in a terminal:

$ pacmd list-sink-inputs | grep “sample spec”

And it returned float32le.

  • And the most important thing: create the /etc/asound.conf (it didn’t exist in my system) and inser this:

# Use PulseAudio plugin hw
pcm.!default {
type plug
slave.pcm hw
}

The second article says that this setting allows a direct access of the hw plugin with the kernel’s ALSA driver - considering what was going on, I decided to try the hint…

Done a reboot and… my noise and slowdown in Mednafen has finally disappeared!

Some considerations about this solution:

  1. I doesn’t like it, because I didn’t find the error/conflict in my audio system - it was just the fact that it worked for the problem.

  2. I tried to revert default-sample-format to s16le and lost sound only in Mednafen - so the problem persists somehow.

  3. And the Pulseaudio Arch Linux wiki has a warning about ALSA settings changes when using Pulseaudio - that’s what I did when using asound.conf.

And lastly:

  • the noise at MAME has not disappeared.
    Although I’m thinking of other solutions, I’ll have to read his documentation to understand how his sound driver works - even if I think it’s connected to the volume… or not (just reflecting on what I wrote above).

Anyway, I appreciate the help and feel free to give your opinion.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.