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

Skipped or cut off pickup sounds #4472

Closed
Chance4us opened this issue Apr 17, 2022 · 21 comments
Closed

Skipped or cut off pickup sounds #4472

Chance4us opened this issue Apr 17, 2022 · 21 comments
Milestone

Comments

@Chance4us
Copy link
Contributor

Chance4us commented Apr 17, 2022

Since commit 4cdbd35 I have encountered issues with sounds being cut off or skipped entirely.

How to reproduce:

  1. Start game
  2. Enter the settings menu
  3. Scroll up and down with the mouse wheel
  4. Notice the shortened sounds

Or:

  1. Use the following ini file
    diablo.ini.zip
  2. Load attached game
    single_0.hsv.zip
  3. Kill some enemies
  4. Notice the shortened or skipped gold pickup sounds
@AJenbo AJenbo added this to the 1.5.0 milestone Apr 17, 2022
@Chance4us
Copy link
Contributor Author

After a little more detailed testing, I got the impression that changing the sample rate to 22050 Hz seems to be a workaround. With this setting, the samples no longer seem to be skipped. Can anyone confirm this?

@qndel
Copy link
Member

qndel commented May 21, 2022

After a little more detailed testing, I got the impression that changing the sample rate to 22050 Hz seems to be a workaround. With this setting, the samples no longer seem to be skipped. Can anyone confirm this?

Could it be this?
b28c659

I have poopy sound on everything other than 22050 hz so could it be that you deleted config like me and got default 44khz which caused the problem?

@AJenbo
Copy link
Member

AJenbo commented May 21, 2022

It should be fixed in #4544, but it contains multiple changes so takes a bit to review it.

@Chance4us
Copy link
Contributor Author

I have poopy sound on everything other than 22050 hz so could it be that you deleted config like me and got default 44khz which caused the problem?

I've had the problem since 4cdbd35. Yes and I agree the sound only works decently at 22050.

@julealgon
Copy link
Contributor

I have poopy sound on everything other than 22050 hz so could it be that you deleted config like me and got default 44khz which caused the problem?

Seems like a bad idea to have a default that performs poorly on most cases. Is this the whole Windows vs Linux thing again where 44khz works best in Linux?

@AJenbo
Copy link
Member

AJenbo commented May 25, 2022

No, this is windows vs windows. Not everything can be blamed on Linux.

@julealgon
Copy link
Contributor

No, this is windows vs windows. Not everything can be blamed on Linux.

Wasn't necessarily "blaming" Linux, but I remember a discussion around our lack of env-specific default capabilities (say different configuration values for Linux vs Windows) so we had to settle on a value that would work "good enough" everywhere.

If we are seeing differences between 22 and 44khz in Windows alone then that is pretty sad...

@AJenbo
Copy link
Member

AJenbo commented May 25, 2022

Depends on the sound card driver

@StephenCWills
Copy link
Member

If we are seeing differences between 22 and 44khz in Windows alone then that is pretty sad...

Differences between the sampling rates itself is not surprising. The game's audio is 22.05 kHz (ignoring Polish dub) so if the audio library is set to anything other than 22.05 kHz, the audio library must do resampling in software which will depend on CPU resources. If instead we set the audio library to 22.05 kHz, then no software resampling is required. So the difference here has a lot to do with whether the software resampler is running.

The sad part comes in when you start to examine how unpredictable Windows in regards to the sampling rate. If the audio library's sampling rate doesn't match the output rate of the Windows audio device, then the OS/driver/sound card must resample the audio to force it to match the output rate. This depends on audio processing in the OS/driver/sound card and provides us with a rather unpredictable moving target. It could be dependent on CPU, quality of the hardware, bugs in OS, bugs in the driver, etc. Since the latest versions of Windows default to 48 kHz, our current default bypasses this OS-level resampling on a typical installation of Windows.

If someone is having audio issues that are solved by setting the audio library to 22.05 kHz, the most likely explanation is that either they don't like the audio quality of the software resampler or their CPU can't handle the resampling algorithm.

@julealgon
Copy link
Contributor

I don't doubt anything you are saying @StephenCWills but I wonder why DevilutionX is having such big challenges with audio while I've never seen this issue in any other game. At some point it feels like we are doing something fundamentally wrong here or the sound libraries we are using are just bugged/not robust enough.

Or maybe this is just a wrong perception on my side and this is a common problem that I've just never noticed anywhere else.

@StephenCWills
Copy link
Member

I think your experience is just naturally cherry-picked down to whatever you felt was relevant at the time. You can literally Google "audio issues" with just about any game you can think of, and you'll find something.

https://us.battle.net/support/en/article/34792
https://steamcommunity.com/app/228280/discussions/7/215439774870538151/
https://www.getdroidtips.com/fix-risk-of-rain-2-audio-stutter-no-audio-issue/
https://gamertweak.com/no-sound-audio-age-empires-4/

@AJenbo
Copy link
Member

AJenbo commented May 25, 2022

@malvarenga123
Copy link

@AJenbo correct me if I'm wrong, but in 1.0.0/1.1.0 there were no audio issues whatsoever and we had a lot less audio options available. Most problems started to appear from 1.2.0+. Are you able to pinpoint what was the change that started all these audio issues?

@StephenCWills
Copy link
Member

This particular issue is caused by an experiment in swapping the Speex resampler to the one built into SDL, which seems to have some problems. SDL is currently working on a solution, and we have already referenced a PR for DevilutionX that should fix this by reintroducing Speex.

The sort of "advanced" audio options such as channels, buffer size, and sampling rate were added in 1.3.0. I believe this coincides with the introduction of SDL_audiolib which brought with it an audio latency issue that nobody had noticed before. However, it was confirmed that the issue was present in SDL_mixer as well when using a different sampling rate or buffer size so the root cause in this case was the audio settings. That said, we were able to fix it in general by implementing a fix in SDL_audiolib so you shouldn't expect to experience that issue anymore regardless of how you choose to fiddle with the audio settings.

Digging further back, the audio issues you reported for the 1.2.0 release could potentially be attributed to issues with the WASAPI audio driver in SDL. Perhaps there was a change in SDL that explains the discrepancy between 1.1.0 and 1.2.0 that you observed. If so, it should have been temporarily resolved by switching from the WASAPI audio driver to the winmm audio driver for the 1.2.1 release. However, after we received a report of high audio latency in Windows, we reviewed code changes in SDL, tested the WASAPI audio driver, and concluded that it was probably time to switch back leading up to the 1.4.0 release.

@malvarenga123 There has been an awful lot of discussion around audio recently so this post really only scratches the surface of what we've done, but I think it addresses the main points in your message. The bottom line seems to be that "all these audio issues" are actually just isolated issues that weren't necessarily kicked off by any one change in particular. The best answer to your question on whether we are able to pinpoint the cause is probably just a big maybe. I would say that we have been properly investigating each audio issue we encounter to try and determine the cause of each one, but we don't necessarily know whether the conclusion we came to is exactly correct in every case.

@AJenbo
Copy link
Member

AJenbo commented May 27, 2022

Are you able to pinpoint what was the change that started all these audio issues?

An increase in users.

The audio issues have mostly been isolated to a few individual systems. The options where introduced to allow the affected users to experiment with various settings since we where largely unable to replicate the issues. Have you actually been experiencing audio issues with 1.2.0/1.2.1/1.3.0/1.4.0 or are you mostly basing you comment on anecdotes?

@malvarenga123
Copy link

Yes, since 1.2.0 I started to get crackling sound, which only recently I found out it was caused by having the audio in 22.5 kHz and "fixed" by changing it to a proper frequency.
Reading this issue, I started to notice the cut off sounds. At first, I thought I was imagining things, but it's as described by Chance4us.
The reason why I asked you is because AFAIK 1.1.0 also outputs the audio in 22.5 kHz and none of these issues (crackling/cut off sounds) happen, so I thought some significant change in the audio system happened between 1.1.0 and 1.2.0+.

@AJenbo
Copy link
Member

AJenbo commented May 28, 2022

@malvarenga123 It is not necessarily a change in DevilutionX that would cause it. Can you test with the SDL dll from 1.1.0 in more recent versions to see if that changes things for you?

@malvarenga123
Copy link

@AJenbo the cut off sounds only happen after the commit 4cdbd35 (with any sample rate, even 22500), as Chance4Us mentioned. On releases 1.1.0, 1.2.0, 1.3.0 and 1.4.0, it works fine.
I'll post about the crackling sound in issue #1390.

@StephenCWills
Copy link
Member

with any sample rate, even 22500

Have you tried 22050?

@AJenbo
Copy link
Member

AJenbo commented May 28, 2022

@AJenbo the cut off sounds only happen after the commit 4cdbd35

Yes this is known, and the fix is being reviewed as as been stated multiple times here.

@malvarenga123
Copy link

Have you tried 22050?

My bad. With 22050 the sounds don't get cut off, only with 44100, 48000 and 96000.

@AJenbo AJenbo closed this as completed May 31, 2022
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

6 participants