Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic sound emulation switching problems #279

Closed
johnnovak opened this issue Jan 10, 2024 · 2 comments
Closed

Automatic sound emulation switching problems #279

johnnovak opened this issue Jan 10, 2024 · 2 comments

Comments

@johnnovak
Copy link

johnnovak commented Jan 10, 2024

Automatic sound switching causes problems in games that don't have continuous background music but only play sound effects sporadically. What happens is the auto-switching disables the sound output after about 2 seconds, which causes a loud pop (very noticeable in good quality headphones). Then when the next sound effect plays, there is usually another loud pop when the sound is re-enabled, and frequently there is some "stuttering" at the start of the sounds. Needless to say, this is quite jarring and far from great.

I've been experiencing this for years now in games that mostly only feature sound effects (e.g., Eye of the Beholder I and II, Maniac Mansion, etc.) and always thought this was a game bug, but no -- this is introduced by the auto switching. I'm glad that I finally found the reason, but I imagine most people would run into this and most won't find out how to fix it.

With auto switching disabled (so sound always on), the problem is 100% gone in all problematic games.

I highly suggest to do the following two things:

  1. Default to sound always enabled in the Quickstart configs. Enabling cycle accurate emulation but doing this trickery with the audio makes little sense. I don't think sound always on adds significant CPU overhead in the grand scheme of things.

  2. When auto switching is enabled, I assume you disengage the sound at the sound API level (in other words, stop feeding the buffer because sound output is paused). From my own personal experience, don't do that, as that will invariably will result in clicks and pops and some stuttering when engaging/disengaging the sound generation. Never pause the sound output at the API level, so never stop feeding the buffer with data, keep the audio running all the time. Just feed it with zeroes when the sound is disabled at the emulation level. This is practically what all audio software do; they always feed the buffer with zeroes, even when the playback is stopped at the application level and there should be no sound output. Otherwise you'll end up in stutter and click & pop hell when you stop and restart the playback. That's just the way it is with audio APIs on practically all platforms (not just Windows).

If you do 2), I guess you can continue to enable auto switching in the Quickstart configs if you really want to as the problem will be gone.

@johnnovak
Copy link
Author

Extra info: the problem is because some games leave the audio output in a "constant DC offset" state when there is no sound. Then when you abruptly turn off the sound, it causes a click. One possible solution would be to fade the output over a few milliseconds to silence, as opposed to abruptly stopping it when the auto-switching kicks in.

@johnnovak
Copy link
Author

johnnovak commented Feb 7, 2024

Defaulting to no auto switching in 5.2.0 b7 fixes this, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant