DOOM 2016 sound is horribly broken (379720)
Throughout all Proton versions, sound in Doom is crackling and distorted a lot. It sometimes works when starting it with higher priority but only during the loading screen while the logos shows. When the menu screen starts, sound stutters, is distorted, or crackling horribly with many buffer drop outs.
I know this is a problem of Wine 3.7 which Proton is based on. Since then, Wine vanilla had some pulseaudio patches which finally fixed the problems here. A few other games are affected, too:
- Kingdoms of Amalur has this problem, too.
- Witcher 3 has this problem sometimes: It's either working from the start or shows sound issues from the start.
I think pulseaudio stability in wine heavily depends on system load during wine startup. This seems to have been fixed later.
The game itself has no performance issues: Playing with Vulkan, it constantly works at the vsync limit of 60 fps with GPU/CPU load way below 50% most of the time.
Sys info: https://gist.github.com/kakra/cb95087ed58cb40ca7f9c0e5109aabce
This seems to be fixed now for Doom (with 3.7-5)... But now gameplay freezes after some time (music continues to play). I need to SIGKILL the process.
Same sound issue and workaround here: https://github.com/ValveSoftware/Proton/issues/396
As for the GPU freezes: https://github.com/ValveSoftware/Proton/issues/1070#issuecomment-417657503 Workaround for me was to switch to XFCE, disabling Steam overlay might also help. Interesting to see this also exists on Nvidia!
Edit: Proton 3.7.5 beta did not resolve the sound issue for me.
For Rise of the Tomb Raider (native Vulkan) the freezes can mostly be resolved by disabling the overlay. So its counter-intuitive to enable it here... But well, my overlay is enabled. Seems stable for Rise since some nvidia update.
I'll try without overlay and report back.
The sound issue is back. I think it was pure luck that it worked correctly in one of maybe 100 launches of the game.
The most common reason for crackling on Wine is usually due to too high/low buffering.
https://wiki.winehq.org/Sound#PulseAudio
Preferably you should just make sure that the PULSE_LATENCY_MSEC variable is not overriden by your system, but if you just want a quick fix you can test to manually set it (maybe test to set it to 5, 30 or 90 and see if it works).
It sometimes works when starting it with higher priority but only during the loading screen while the logos shows.
This is quite a strong indicator that some kind over buffer overrun is occuring.
I do not set this variable because it caused more problems than it solved in the past (including freezing games). Of course I tried settings this nevertheless without success. I'm currently rebasing proton to newer wine versions. With the pulseaudio patches of proton removed and rebased to wine 3.9 it looks very promising currently. But the problem seems to be caused (or solved) by something outside of pulseaudio in wine. Once I finished rebasing, I will reapply the pulseaudio patches (including fixes that @aeikum provided) to cross-check that.
Also, there's comments in the changelogs that this variable no longer has an effect with the updated winepulse drivers and should not be set.
I've rebased to wine 3.12, sound seems to be OK always every time now: https://github.com/kakra/wine/releases/tag/wine-proton_3.7-3.12-unofficial
I cannot currently rebase to any later wine version because this breaks Vulkan (or even any game) for me. I think I messed up somewhere during rebase or some of the more complicated patches (i.e. esync) are incompatible. I see that there're esync patches based on 3.10 available from the author, I'll have to investigate this. Proton 3.7 patches completely fail to rebase (at least conflicts won't easily resolve) onto wine 3.15. This is mostly related to esync.
At least sound is okay now so I'll stick with that version for a while.
I'm pretty sure it has to do with something like 44.1 kHz vs 48 kHz vs 96 kHz. Configuring anything else than 44.1 kHz in pulseaudio has the potential to break the sound im Doom. Strange is, tho, that Wine itself seems to initialize/probe the audio device with 48 kHz (according to the code).
This also does not explain why it occurs only sometimes. But it explains pretty much every issue I'm seeing: If input vs output rate only slightly differ (48 vs 44.1 kHz), then I get the effect that I hear most of the times: A constant distortion which sounds like too short buffers. If input vs output rate differ much (96 vs 48 or 44.1 kHz), I hear what sounds like double pitch, double speed. This affects only some sound effects in the game (usually ambient speech). This kind of effect was rare. But even more rare was getting correct sound all the way through the game. Configuring pulseaudio for 44.1 kHz (or leaving defaults) seemed to have fixed this. Configuring it to 96 kHz has total potential of breaking the sound but just in this game. So maybe it's a bug in the game not in Wine?
I can only conclude that something really weird is happening when one of the involved components has to convert between different audio rates. Is it the game having a bug? Is it Wine that sometimes gets confused while probing the pulseaudio device? I don't think it's a bug in pulseaudio itself because outside of Wine it works perfectly well with these settings.
We've seen different bugs here. The one above is still present. The others were fixed for me (out-of-sync buffers with buffers playing backwards in time sometimes) thanks to the work of @aeikum and the current patches in wine-staging.
It took a while to figure this out because this 48/96 kHz config is deployed since months or even years here without causing trouble.
I've updated my wine-proton build with the latest patches if someone wants to check: https://github.com/kakra/wine/releases/tag/wine-proton_3.7-3.12-unofficial-1
I've tried your build but the sound issue appears to persist for Doom and PoE, any way to verify I'm using your build? I've got the Proton beta selected and I've copied the dist folder over the existing folder.
@zaggynl Navigate to the Proton folder in SteamApps/common for the version you're using. Then run tar df /path/to/build/dist...tar.xz. It should show no output, otherwise it would list any file that differs. It looks like Steam sometimes likes to reset the files. If you want to restore my build, just run the same command with xf instead of df.
Please also verify that you're not setting sample frequencies in /etc/pulse/daemon.conf or .config/pulse/... if you're using a config in your $HOME (see man pulse-daemon.conf for possible locations of the config file).
If you do not set sample rates, try to set different combinations of 44100 and 48000 for both default-sample-rate and alternate-sample-rate. I currently suspect that this has something to do with it and is a bug somewhere lurking around in the game or wine. Report back about your findings.
But first check if you use my latest build which includes the latest patches from Andrew (see link in previous comment, the proton_3.7-3.12-1 version).
I didn't have audio problems in PoE. Would you mind sending me a recording of the broken sound (PM [email protected], or here if you prefer) so I can hear if we are experiencing the same issue? I can only compare Doom, but recorded samples from both games are fine.
PS: If you're using multiple steam libraries, chances are that Proton got installed into multiple libraries - it seems undefined which one is used then. So if in doubt, replace them all.
BTW: Sound in Doom is currently working fine here (reproducible) even when compiling wine in the background. So it's no longer a CPU/IO load problem for me. This particular load problem seems to have been fixed by Andrew (included in my updated build).
Thanks! Doom started in windowed mode on my left monitor instead of the right primary one. Sound issue persists but the the distortion is not recorded when using kazam, I've done a recording by mic on my headphones in the past for Doom: https://www.youtube.com/watch?v=_PdEG8wh0WM Sounds similar when starting PoE: https://youtu.be/6aJatBuRZ1g
Recorded with Audacity, combined still image with audio with ffmpeg: ffmpeg -loop 1 -r 1 -i poelogo.png -i poe_distortion.wav -c:a copy -shortest poegarbled.avi
No changes made to daemon.conf, using default in ubuntu 18.04: http://paste.ubuntu.com/p/Rz7TH7jC7j/
Edit: Tried 44100/44100 and 48000/48000 for default- and alternate-sample-rate
Edit2: Killed pulseaudio with killall pulseaudio and started it with: pulseaudio --log-level=4 --log-target=file:/home/az/Downloads/pulselog20180910.txt Doom: http://paste.ubuntu.com/p/K9bk4hhj6s/ PoE:http://paste.ubuntu.com/p/FW763JThnZ/
With tsched=0 change as per: https://github.com/ValveSoftware/Proton/issues/396 sound is clear Doom: http://paste.ubuntu.com/p/DJWBPtD9Br/ PoE: http://paste.ubuntu.com/p/6GqBBbX33M/
D: [alsa-sink-ctxfi] sink.c: alsa_output.pci-0000_09_02.0.analog-stereo: Found underrun 216 bytes ago (17364 bytes ahead in playback buffer) Appears to be the issue, not sure what the proper fix is.
pulseaudio 11.1
Edit3: Installed lowlatency kernel from http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.18.7/, did not make a difference. PoE pulseaudio output: http://paste.ubuntu.com/p/bxMVz5KhkK/
Sounds a lot like my issue when I use 96 kHz... It's not the timing related issue that was fixed as far as I can tell. If possible, do a sound recording of Doom. Shortly after a first starting point in level 1 (or 2? can't remember), there should be a female ambient voice. I'm interested if it plays back in normal speed or in some high pitched faster speed with audio dropouts. It's usually only with the ambient voices in the game.
Also, here's a debug build. Edit user_settings.py to say "WINEDEBUG": "trace+pulse" (it's in the Proton directory, remember to remove it later, logging can be a performance killer). Start Doom with my updated build, then quit from the title screen. In $HOME it should have created steam-379720.log. Specifically, I am interested in the following output (no need to send the whole file):
# egrep '(sampling format|period)' ~/steam-379720.log
# my output when it works:
0034:trace:pulse:pulse_probe_settings pulse_{def,min}_period [0]: 208.
0034:trace:pulse:pulse_probe_settings Selected sampling format: { .rate=48000, .format=5, .channels=6 }.
0034:trace:pulse:pulse_probe_settings pulse_{def,min}_period [1]: 1250.
0034:trace:pulse:pulse_probe_settings Selected sampling format: { .rate=16000, .format=5, .channels=1 }.
Here the debug build: https://drive.google.com/open?id=1Q41xwwZdB1cCW-LG20HP1ZOUFOxoBt-P (sha1sum 4160aa27c4e658c1b1587731e0bd18cc091b78cc)
Since I only see it with 96 kHz and my system doesn't seem overloaded or CPU-bound, I wonder if this is an integer overflow somewhere which is causing this. Will be hard to find without deep knowledge of the code.
That took a while (I need sleep):
0030:trace:pulse:pulse_probe_settings pulse_{def,min}_period [0]: 226
0030:trace:pulse:pulse_probe_settings selected sampling format: { .rate=44100, .format=5, .channels=2 }
0030:trace:pulse:pulse_probe_settings pulse_{def,min}_period [1]: 226
0030:trace:pulse:pulse_probe_settings selected sampling format: { .rate=44100, .format=5, .channels=2 }
@zaggynl I did two recordings with OBS studio... Apparently, NVENC doesn't work here so loading takes quite a time and movement is a bit jerky (usually it runs 60 fps with pretty fast loading): https://youtu.be/yN6mnBYR4e0
For the second one, I raised OBS priority to SCHED_ISO and IO prio = 0 to see if it helps recording but it hurts game performance a lot, I even have sound drop-outs: https://youtu.be/o--kXOc_718
Black screen at the beginning is starting the game from Steam. I'm not sure why it always shows the first loading screen right before the title when recording. Usually it's a one-time occurrence. But these videos showed me that Doom is quite heavy on the loading screens, it took awfully long to load while recording. It's definitely CPU bound there.
First time playing this level... Argh, now it saved my messy progress... :-)
@zaggynl Does the debug log change when you switch pulseaudio to 48k mode?
tsched=0 makes no difference here (it used to in older wine versions for The Witcher 3 back when I played it a lot). I also had the wrong-screen issue after I cherry-picked some updates from Proton 3.7... There were some fullscreen hack fixes, one explicitly mentioning Doom. I had to Alt+Enter the game into window mode because I could only see one quarter of it, then switch it back to the correct monitor in the settings, since then: everything fine.
Odd how it's so different across PCs! Tried with 48k:
002f:trace:pulse:pulse_probe_settings pulse_{def,min}_period [0]: 208
002f:trace:pulse:pulse_probe_settings selected sampling format: { .rate=48000, .format=5, .channels=2 }
002f:trace:pulse:pulse_probe_settings pulse_{def,min}_period [1]: 208
002f:trace:pulse:pulse_probe_settings selected sampling format: { .rate=48000, .format=5, .channels=2 }
So your card supports both correctly... But the game still runs distorted?
Indeed, and the odd thing is any other audio playing app say firefox with youtube or deadbeef will also sound distorted until the game playing through wine is exited.
This sounds a lot like things become broken within pulseaudio. This is an interesting hint...
Meanwhile, you could try the following changes in pulse/daemon.conf:
; may reduce CPU usage by not doing unnecessary resampling
avoid-resampling = true
; may reduce CPU usage by using the HW mixer instead of software
flat-volumes = yes
; try different methods here, see man pulse-daemon.conf
resample-method = speex-float-1
This is the setup I am using. It may also help to fiddle around with default-fragments and default-fragment-size-msec so usually that only made the problem worse for me. But you may be lucky. :-)