ncblakely / CataclysmEngineTweaks

Cataclysm Engine Tweaks
MIT License
24 stars 0 forks source link

Is it possible to investigate what causes the massively loud audio glitch to occur with the Siege Cannon and Nomad Moon Repulsor? #11

Closed Talthos closed 4 months ago

Talthos commented 5 months ago

Rather, this is an issue that exists in the retail game on modern operating systems newer than Windows 7 (at least as far as I know). It also affects sufficiently intense explosions from detonating crystal asteroids, or when looking at a Command Ship exploding from sufficiently close up.

I don't suppose it's possible to observe what the game's audio engine is doing, and find out what is breaking to cause this audio glitch? For reference, this issue didn't seem to occur in Windows 7, but does occur in Windows 10.

Edit: If you're unable to reproduce the issue from your end, I can try to record footage that demonstrates the exact issue.

ncblakely commented 5 months ago

I'm not noticing anything unusual with the siege cannon volume on either of the two PCs I have here, though it's possible I don't remember what it's supposed to sound like.

If you have a video that demonstrates it that would be helpful.

Talthos commented 5 months ago

I'm not noticing anything unusual with the siege cannon volume on either of the two PCs I have here, though it's possible I don't remember what it's supposed to sound like.

If you have a video that demonstrates it that would be helpful.

Okay, I've recorded a short video that very clearly demonstrates the bug I'm talking about, and have uploaded it to Youtube. Fair warning though: You'll want to turn your volume down quite a bit before listening, because this bug is very, very LOUD.

Youtube link

Edit 01: And just to reiterate, this bug occurs both in the vanilla retail game, the GOG version, and when using your Engine Tweaks. I've tried adjusting the sample rate and bit depth of my main audio device (both increasing it and decreasing it), but this didn't solve the issue. Changing my main audio device to something else didn't solve it either (I've tested with a Sound BlasterX G6 USB DAC, and I've tested with the on-board motherboard audio interface for this Gigabyte X570 Aorus Elite; both of them encounter the exact same audio glitch that is shown in the short recording).

Adjusting the value of /heap didn't solve it. Using /dsound, /dsoundCoop, or /waveout didn't solve it either. Adjusting the number of active sound channels via the in-game options menu slider didn't fix things, either.

Testing with /enableSSE, /forceSSE, and /enable3DNow, whether enabled or disabled, didn't fix it either. No improvement was observed when testing with /safeGL, /triple, /noswddraw, /noglddraw, or /noFastFE. Changing the renderer to Direct3D or Software didn't fix it, either.

Edit 02: And I've observed that this issue occurs with the Siege Cannon detonation explosion, the Nomad Moon Repulsor shockwave, crystal asteroid explosions, and Command Ship death explosions. It may occur with other sound effects as well, but I have not done a truly rigorous amount of testing to check.

ncblakely commented 5 months ago

Thanks for the video. Yeah, I for sure would have noticed that if it had happened on any of my PCs. :)

Tracking it down may be tough if I can't repro it here. Does it always occur with other effects like the siege cannon? I actually only tested with that as I don't have a save on the Nomad Moon mission.

I've already been digging around the audio code a bit to track down a different issue I'm having, so maybe something will occur to me soon that you could try to narrow down the cause.

If it is audio chipset/driver related somehow, my dev machine has a Realtek ALC1200 (MSI X670 Tomahawk) with the 6.3.9600.2369 drivers.

BTW, Cataclysm seems to have have removed all of the DirectSound code that was present in HW1. The /dsound and /dsoundCoop switches are still there but don't do anything. waveOut is always used.

Talthos commented 5 months ago

Does it always occur with other effects like the siege cannon?

If the explosion is close enough, then yes, it almost always occurs with the Siege Cannon (like, 90% of the time). Same with crystal asteroid explosions and Command Ship death explosions.

I actually only tested with that as I don't have a save on the Nomad Moon mission.

You can use the warp.script to go directly to the Nomad Moon mission from the New Game screen. Alternatively, I can share my save file for that mission (which I used to get easy footage for that glitch), where there's roughly 10 seconds before the Nomad Moon Repulsor cutscene is triggered.

Incidentally, you can still rotate and zoom the camera with the mouse during in-game cutscenes. Rapidly zooming in and out with the mouse (by moving the mouse up/down while holding left and right click simultaneously) during the Nomad Moon Repulsor cutscene might make it easier for you to induce the glitch, assuming you can trigger it on your end.

If it is audio chipset/driver related somehow, my dev machine has a Realtek ALC1200 (MSI X670 Tomahawk) with the 6.3.9600.2369 drivers.

Part of me doubts that it's chipset/driver related, since my motherboard's onboard audio is Realtek ALC1200 as well, and it still suffers the exact same audio glitch as the Sound BlasterX G6 USB DAC.

BTW, Cataclysm seems to have have removed all of the DirectSound code that was present in HW1. The /dsound and /dsoundCoop switches are still there but don't do anything. waveOut is always used.

Alright, that sounds like a decent clue to me. It makes me suspect that Microsoft changed something with how WaveOut is handled in Windows 10 (my current OS), compared to how it was handled in Windows 7 (my previous OS).

ncblakely commented 5 months ago

No luck reproducing it with any PC here, I'm afraid. I'm also on Windows 10 FWIW.

Cataclysm's audio engine is giving me problems with something else I am working on (that should in theory be entirely unrelated, but is completely killing the audio output for some reason), so I was already considering ripping out the waveOut stuff and replacing it with XAudio or WASAPI. No clue if that would improve things here, but there's a chance it could resolve it.

SuperSajuuk commented 5 months ago

Since Homeworld 1 has access to DirectSound, is there scope to try and reintroduce that with the engine fixes mod and make DSound the default over WaveOut (ie never use WaveOut unless the user sets a config to "forceWaveout"), with options to use WASAPI?

ncblakely commented 5 months ago

Possibly, but I can only guess at why Barking Dog removed it from Cataclysm. There could have been a good reason for it, or other changes in the audio engine that don't support DSound. It does seem strange to fall back to such an old API when the previous title had support for it, though. HW1 would default to DSound unless it wasn't available.

Assuming there is nothing specific to Cataclysm preventing it from working, re-introducing it would be easier than switching to an entirely new API that neither game supported (XAudio/WASAPI) but still a pretty large change that might involve pulling chunks of the audio engine out into the .dll so it can be properly recompiled.

I'd be curious to know whether this bug exists in HW1 as well when run with the /waveOut switch. If it does, that would give me some confidence that adding back in DSound alone would fix it.

SuperSajuuk commented 5 months ago

My initial thoughts are that, because Cataclysm is just the HW1 Classic engine but with a bunch of improvements and upgrades, there should be no reason why the game would have issues with DirectSound/DSound, since its using an engine which already supports it. I would probably add back support for DirectSound, force it to be required and then see what happens (to simplify some campaign stuff, play a few missions on Very Easy so there's no challenge or time wasting involved).

I have no idea if I play HW1 Classic with WaveOut, as I've long assumed its just using DirectSound. There doesn't appear to be a way to verify what audio engine the game is using (maybe the engine tweaks mod could write some technical data to a TXT file on game launch, things like audio engine, graphics adapter, gpu, cpu etc etc).

Doing a bit of searching, there's this interesting snippet of text in the HW1 Classic Readme relating to Sound Card issues, and the part about "Windows NT 4.0" is intriguing as many of us use the Hardware Acceleration Fix which forces NT4 to use OpenGL:

Running Homeworld in Windows 9x: o Homeworld will use the DirectSound mixer if your sound card driver reports as certified, otherwise Homeworld will use the Waveout mixer. If you have a newer sound card with new drivers, such as the Creative SoundBlaster Live or Diamond MX300, you may receive better performance by using the /dsound command line option because the drivers may not report as certified. If you have a slightly older card, such as the Creative SoundBlaster AWE32, and are having problems with sound try using the /waveout command line option to force use of the Waveout mixer. If you experience crashes that you believe are related to sound try the /waveout and then the /dsound command line options to see if one mixer is more stable than the other with your sound card and drivers.

Running Homeworld in Windows NT4: o Homeworld will default to using the Waveout mixer, you should not use the /dsound option unless you are having crashes that you think may be related to sound.

Is it possible that we're all going to end up being forced onto WaveOut (even if we tell the game not to use it in the engine mod) because of the Acceleration Fix that people are invariably going to end up using in the compatibility administrator, in order to run the game?

Talthos commented 5 months ago

My initial thoughts are that, because Cataclysm is just the HW1 Classic engine but with a bunch of improvements and upgrades, there should be no reason why the game would have issues with DirectSound/DSound, since its using an engine which already supports it.

I vaguely recall that Cataclysm's source code began as a fork from an earlier source revision of HW1's source code. So even if you remove all of the Cataclysm-only bits (like the code that handles the Siege Cannon and Infection Beam and whatnot), it's still not a perfect 1-to-1 match with HW1.

Talthos commented 4 months ago

You know, it occurs to me that the last system I had where this glitch was not a problem, also happened to be using an Intel Core i5-6600K CPU (4 cores, 4 threads).

My current system initially used an AMD Ryzen 7 5800X CPU (8 cores, 16 threads), and I later swapped it out for an AMD Ryzen 7 5800X3D CPU (8 cores, 16 threads, and a 96 MB L3 Cache). Both CPUs encounter the audio glitch described in this thread.

Perhaps that's not a coincidence? Hm... gonna see if dropping the CPU affinity down to a maximum of 4 does anything...

Edit: And nope. CPU affinity does not fix the problem.

SuperSajuuk commented 4 months ago

You know, it occurs to me that the last system I had where this glitch was not a problem, also happened to be using an Intel Core i5-6600K CPU (4 cores, 4 threads).

My current system initially used an AMD Ryzen 7 5800X CPU (8 cores, 16 threads), and I later swapped it out for an AMD Ryzen 7 5800X3D CPU (8 cores, 16 threads, and a 96 MB L3 Cache). Both CPUs encounter the audio glitch described in this thread.

Perhaps that's not a coincidence? Hm... gonna see if dropping the CPU affinity down to a maximum of 4 does anything...

Edit: And nope. CPU affinity does not fix the problem.

@Talthos I have noticed a LOT of different people complaining about all sorts of extremely strange behaviour with older PC games (not just Homeworld) on AMD Ryzen systems, and its starting to sound like this is not a coincidence. I am starting to wonder if some of these newer AMD Ryzen CPU's have an addressing bug that is exposed more often on older games which were likely designed to work with a specific addressing? FWIW, I don't get your audio glitch at all in Cataclysm on my Intel Core i7-12700K, and thats quite new compared to the CPU's that Cataclysm would have been tested and verified on.

My thought process is along the lines of super old versions of Windows (eg 95 and 98) which need to be patched using an open-source patcher, which allows them to be installed/run on VM's with relatively modern CPU's, due to an addressing/instructions issue in the OS code that causes them to not work on these more modern CPU's. Is something similar happening here with AMD CPU's on Cata?

NB: Your previous CPU [Core i5-6600K] was actually the CPU in my previous PC as well, and I also had no issues there at all, so its definitely not an issue that occurs on Intel systems.

Talthos commented 4 months ago

FWIW, I don't get your audio glitch at all in Cataclysm on my Intel Core i7-12700K, and thats quite new compared to the CPU's that Cataclysm would have been tested and verified on.

ncblakely mentioned not getting the issue at all on a Ryzen 7800X3D, which is an AMD CPU. Which makes the matter even more confusing.

Edit: That said, both of the AMD CPUs that I've ever used (the standard 5800X, and the 5800X3D), were AM4 socket hardware. ncblakely's 7800X3D is AM5 socket hardware, which is 1 generation newer than mine.

Not sure if there's a connection there, but it's worth putting out there, I think.

ncblakely commented 4 months ago

This seemed to be caused by the game's built-in equalizer. @Talthos helped narrow down the problem with some test builds. The next release will include a setting in the config to disable the EQ.