dsoal icon indicating copy to clipboard operation
dsoal copied to clipboard

Extreme lag when using DSOAL

Open ethindp opened this issue 1 year ago • 13 comments

I play some not well-known audio games specifically for the blind that were made back in the XP era and that support DirectSound. However, when using DSOAL, I've noticed that one of them in particular lags, a lot, and I'm on a pretty beefy machine. As in, I'll be running down a corridor, and the game will lag bad enough that step sounds won't play consistantly and other sounds lag behind where they're supposed to play. Without dsound usage the game only starts doing this on the higher levels around the final level, where there are a ton of enemies, but with this dsound implementation it gets really bad even on the first level.

I'd post a recording of it, but I currently don't have something like Virtual Audio Cable installed. You can try it yourself though. The game is called Shades of Doom. You can download the version I play here. after you install it, set up DSOAL like you would any other game (by copying the DLLs and .ini file to the games directory), then run the game. Then do the following:

  1. Click "OK" to tell the game that you want to continue.
  2. Click "No" on the following two dialogs.
  3. You should here "User code..." followed by four numbers. You can ignore this.
  4. The intro will start playing. You can press any key to interrupt it.
  5. You will now be in the main menu. The arrow keys navigate menus. Select "Play Game" and press enter or the right arrow. Select any experience level, and then press enter or right arrow. Experience levels are listed in ascending order of difficulty. If you've chosen the first level ("It's my Turn"), you'll be prompted if you want to enable training mode. Selecting "Yes" prevents monsters from attacking you.
  6. Once the game starts, press "S" to disable the night scope, then press "F1" to open the game menu.
  7. You can familiarize yourself with the various keys and their associated actions in this menu and its sub-menus if you like. Once done, navigate to "Options".
  8. In the options menu, navigate to "Sound". Press Space until you here "Virtual 3D, Full".
  9. Navigate to "Save" and press enter.
  10. Press control + R to reinitialize direct sound. Then, if you want to read the games documentation, press control+F1.
  11. Now, to experience this lag, press and hold up arrow and run for a while. Release it to stop moving. When you reach the end of the passage, you'll hear footsteps off to the left, indicating that you can turn here. If you move back and forth here, you'll notice that the steps don't play as they should.

I wish I could provide more info. Playing an audio game can be a rather interesting task for individuals who can see, so I'd understand if it's a bit off-putting. I hope that I've provided enough instructions that you'll be able to reproduce the bug though!

ethindp avatar Mar 16 '23 23:03 ethindp

I gave it a try, following all your steps and noticed relatively high CPU usage (~15% even during the intro/idle) Screenshot showing sod.exe taking up 13.1% CPU usage in Windows 11

At first, I thought it was caused by logging being enabled (which quickly grows to gigabytes in size), so I disabled logging but that didn't fix it. Then I removed DSOAL, and still that didn't bring down the CPU usage to reasonable levels. also tried changing all the settings in sounds.ini, disabling fullscreen optimizations, running as administrator, Windows XP compatibility without luck. I even installed the game in a virtual machine running on Windows XP with an X-Fi sound card and it even maxed out the CPU at 100%. So I think the game may just not be well optimized or just performs more calculations than a single thread/core limit can handle consistently. Screenshot showing sod.exe taking up 100% CPU usage in Windows XP

High CPU usage aside, I think I noticed some sound skipping but overall it sounds okay and I can move around hearing all sounds mostly fine. By the way, is everything supposed to be at ear height? I'd get it if it was for the sake of gameplay simplicity but if we heard our own footsteps below us, it'd make the walking indicator stand out more. But anyway, maybe someone else can test on their end to see if they also get poor CPU performance without DSOAL or if the log provides some useful info.

Log files: https://github.com/kcat/dsoal/files/11001677/Shades.of.Doom.1.2.zip

ThreeDeeJay avatar Mar 17 '23 14:03 ThreeDeeJay

Not sure why the website has two pages for this game, discovered by google search when looking this up. There's a page on a www subdomain and one without, but the non-www version seems to be newer and supports more recent versions of windows. https://gmagames.com/sod.shtml I don't have time to check for differences at the moment, so I'm not sure this other version helps or even uses DirectSound anymore.

Truth-Unknown avatar Mar 17 '23 16:03 Truth-Unknown

I prefer version 1.2; version 2.0 has some changes that I'm not a fan of. And yeah, I don't think it does use direct sound in that version, though I'm unsure.

ethindp avatar Mar 18 '23 03:03 ethindp

@ThreeDeeJay The strange thing is that when using Creative ALchemy's version of dsound, there's no skipping at all.

As for the ear height thing, I'm not honestly sure. I don't know if the 3D code in the game was ever fully written to consider just what 3D is capable of, so it was never adjusted. I do wish the game employed more 3D elements though (though it's incredibly hard as it is on the hardest difficulty, but having to aim up or down as well, or having monsters be able to attack you from above or below would be wild). The problem with ALchemy's dsound implementation is that it makes the frequencies of sounds very obvious. For example, when turning and aiming at an enemy you can hear the night scope aliasing, whereas with DSOAL it doesn't do that. Another problem is that sometimes the directions of sounds are reversed temporarily with ALchemy but then it gets reset -- it's kinda weird. Not a big deal, of course, but just an observation. The high CPU usage is probably due to calculations -- I don't know about how well the game was optimized.

A good way of seeing what I was referring to in my original comment is to go close to a door in a corridor and let the object detector repeatedly start beeping at you to let you know it's there. When it loops properly, it's a steady bleeping sound, but with Dsoal it didn't loop properly. You can here this if you start the game and then go into a level and run a bit. You should hear the game tell you there's a door down the corridor. If you run past it, go back a few steps until it starts beeping at you and just listen to it loop.

ethindp avatar Mar 18 '23 04:03 ethindp

Unfortunately the game doesn't seem to work under Wine or Proton, so I'm not able to test it. When I try to run it, I get several dialog boxes saying it failed to initialize DSound[1], then the game window opens and displays the expected 3 dialog boxes with the title text in the background, then says it failed to initialize MS SAPI. Clicking Ok to that then leaves me with a black screen that I have to force kill. 1.2 and 2.0 behave virtually the same.

[1] The dsoal log shows dsound.dll does get loaded before that error pops up, but doesn't initialize any device. A device does get initialized after the error dialogs are cleared away, but it's never used.

Generally speaking, poor performance is often a result of having the device set to a really high sample rate in the system, particularly when using headphones/HRTF. Make sure it's not set over 48khz. Another possibility is having a mobile or otherwise weaker CPU. Since the game seems to max out the CPU while running, if you have an older CPU with only 1 or 2 cores, it may not leave that much for OpenAL to process audio, causing it to lag out. You say you have a beefy machine, so it's probably not that, but it may be worth checking to make sure the CPU isn't doing any crazy power saving thing.

kcat avatar Mar 18 '23 20:03 kcat

Yeah, I think the game's just not well optimized and seems limited to a single core. Version 2.0 is a noticeable improvement over 1.2 since it doesn't max out a core even during intro/menus, but it still maxes it out when holding buttons like A, W and D, which seem to trigger as many calculations/actions the CPU core allows while they're being held, not to mention the obscene amount of DirectSound3D calls the game makes per second, even when just standing still: Shades of Doom 2.0 DSOALSOFT log.zip

That said, I wish there were more games like this, which put most if not all emphasis on audio instead of graphics for a change, especially when using 3D audio.

ThreeDeeJay avatar Mar 20 '23 14:03 ThreeDeeJay

I think you can use process explorer/hacker to see individual threads load.. You never know what you can find.

[1] The dsoal log shows dsound.dll does get loaded before that error pops up, but doesn't initialize any device. A device does get initialized after the error dialogs are cleared away, but it's never used.

That may be the game internally using COM "for stuff", and wine being stupid about it unless you replace the dll in the windows folder

mirh avatar Mar 20 '23 16:03 mirh

@kcat @mirh Yeah, the game doesn't work un Linux; other blind gamers along with myself have been strugglign to figure out why for some time, with not much success. For me, when I last tried it, it would work until I opened a door, whereupon it would instantly freeze and I'd have to kill the process.

@ThreeDeeJay Oh, there are many more games like this. They just aren't well-known. Most of the more modern ones don't use direct sound, either; they use more modern audio libraries, and I also think that most of them don't employ 3D or HRTF as well as they could've. There's a huge collection of games like these here: https://agarchive.net. Shades of Doom was probably the first computer game I played though, and even now, over 15 years after it's 1.2 release, it's still incredibly fun and addicting, even if it uses a lot of cliches and 90-degree angles.

ethindp avatar Mar 22 '23 17:03 ethindp

If you read the first post from the bug I linked, you see a remotely potential workaround... Try to replace dsound.dll in syswow64 with the dsoal one (a bit unsure about the dsoal-aldrv.dll position, but just drop it everywhere for good measure).

mirh avatar Mar 22 '23 22:03 mirh

If you read the first post from the bug I linked, you see a remotely potential workaround... Try to replace dsound.dll in syswow64 with the dsoal one (a bit unsure about the dsoal-aldrv.dll position, but just drop it everywhere for good measure).

This is not good advice, DO NOT replace Windows dsound.dll, you risk breaking your OS. As for dsoal-aldrv.dll (OpenAL Soft), you can put it in SysWOW64 without problems and it will work for all 32 bit games that use DSOAL (dsound.dll on the game folder).

Kappa971 avatar Mar 23 '23 23:03 Kappa971

Except we are talking about Wine, where supposedly CLSID adjustments aren't picked up?

mirh avatar Mar 24 '23 00:03 mirh

this is very crowded so sorry if this had been said, but do you have logging enabled on a high verbose level? because it will really lag that way

mr-sihc avatar Jul 12 '23 00:07 mr-sihc

At first, I thought it was caused by logging being enabled (which quickly grows to gigabytes in size), so I disabled logging but that didn't fix it. @mr-sihc https://github.com/kcat/dsoal/issues/80#issuecomment-1473911423

ThreeDeeJay avatar Jul 12 '23 03:07 ThreeDeeJay