TerryCavanagh / VVVVVV

The source code to VVVVVV! http://thelettervsixtim.es/
Other
6.94k stars 555 forks source link

Harsh noise when playing on speakers (Linux) #970

Open Fussmatte opened 1 year ago

Fussmatte commented 1 year ago

This has affected me for a good while now. If I have the game open at all, then harsh noises play out over any audio that's currently playing. These noises don't occur during silence, but if I have the game on mute then if anything else plays audio the noises will happen. This only happens with VVVVVV specifically, and on Linux. These noises do not get picked up by screen recorders, so here's a phone recording I took a while back:

https://user-images.githubusercontent.com/44736084/233127653-a8a25d91-0753-484f-bcef-bd5a065977cb.mp4

An extra note: sometimes, the noises will stop altogether during a playthrough, though not before finishing off with an especially harsh noise (as if it was 'flushing out' the problem causing them).

The issue does not occur at all if I'm using headphones. It only happens if I'm playing audio through my (laptop) speakers.

flibitijibibo commented 1 year ago

One quick test is to run the game with SDL_AUDIODRIVER=disk, which will generate raw float32 PCM that something like Audacity (or whatever's left of Audacity...) can import as raw data. If that comes out clean, it's likely something related to Pulse, and at that point SDL_AUDIODRIVER=pipewire may produce a different result.

TerryCavanagh commented 1 year ago

Wow!

(Does this happen with v2.3, I wonder? I haven't seen any reports of this before, so it makes sense that it's due to a change since the last public release)

flibitijibibo commented 1 year ago

It's possible that the change from SDL_mixer to FAudio changed the app-side mixing, but since it's device-specific that would have to be within SDL, since this would mean that the final mix is being mangled between FAudio and the final output. SDL2's resampler is "eh", but not that eh, so I'm wondering if Pulse doesn't like that FAudio's update size is smaller than SDL_mixer's (FAudio's is about 1/10th SDL_mixer's, for precision/accuracy reasons) and the laptop isn't happy about it. Usually this gets worked around by increasing the OS' latency a bit, but I wouldn't be surprised if using PipeWire was enough to fix the issue properly.

Fussmatte commented 1 year ago

It doesn't happen in 2.3, no. I'll test with the SDL_AUDIODRIVER option.

Fussmatte commented 1 year ago

The raw audio that SDL_AUDIODRIVER=disk gives doesn't have the noises in it. Lines up with what happens when I try to record it with OBS or whatever else. When I have the option off the noises still happen though. SDL_AUDIODRIVER=pipewire just complains that it can't open an audio device ("target pipewire not available")

flibitijibibo commented 1 year ago

The raw audio that SDL_AUDIODRIVER=disk gives doesn't have the noises in it. Lines up with what happens when I try to record it with OBS or whatever else. When I have the option off the noises still happen though. SDL_AUDIODRIVER=pipewire just complains that it can't open an audio device

That pretty much settles it - Pulse is giving us sass! A couple options:

Fussmatte commented 1 year ago

First one is not even an option for me, I'm not uprooting my entire OS setup just for a game. Second one seems to work fine, the noises don't occur anymore until I run it without the option

(note: my current OS is Pop!_OS 22.04. I also seem to be able to lower the latency value to about 30 without issues, but 20 starts making weird noises again)