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

Sounds crack and pops using 48kHz and above frequencies with external audio cards #1696

Open
ericoporto opened this issue Jun 18, 2022 · 9 comments
Labels
backend: sdl2 related to sdl2 library context: audio type: bug unexpected/erroneous behavior in the existing functionality

Comments

@ericoporto
Copy link
Member

ericoporto commented Jun 18, 2022

Describe the bug
Explained by Dualnames here and here on the forums. Found with two different users, both with external audio cards, one specified. You can hear the issue here!

The user has the sound device on Windows configured with 48kHz, and hear the crackling and popping. Setting the OS to use 44.1kHz fixes the sound.

Windows 10, and his soundcard is "Soundblaster ZxR" and he's using "Voicemeeter Potatoe" for sound controls

Other user had a different configuration, something that accompanies a Beyerdynamics headset, my gues it's this DAC.

I sent to Dualnames a build of only MojoAL test program testposition.exe and it reproduced the crackling/popping sound in the user machine - at 48kHz setting.

Because it sounded like libsdl-org/SDL#5538, I built a version of SDL2 with libsamplerate (
samplerate_sdl2.zip), and sent to Dualnames. The user reported this indeed fixed the audio.

AGS Version
It was AGS 3.6.0.24.

Game
The game it reproduced was Old Skies Demo, but theoretically any game with sound.

To Reproduce
Unfortunately it looks like it requires having a discreet audio card for this to happen. It doesn't reproduce in my Win10 machine.

Expected behavior
The sound should not have crackling or popping sound.

Desktop:

  • OS: Windows
  • Version 10

Additional context
This is possibly not an AGS issue, but I wanted to report here just to note down and separate from any other issue involving frequency. In theory we need to either wait libsdl-org/SDL#5538 or ship along libsamplerate on the Windows build.

@Dualnames1
Copy link

The other user that reported this issue said that their music is fixed with eri0o's patch, but not the voice/sounds.

@ivan-mogilko
Copy link
Contributor

@Dualnames1

The other user that reported this issue said that their music is fixed with eri0o's patch, but not the voice/sounds.

could you summarize a difference between those, are they different in format, or anything else you may think of?

@Dualnames1
Copy link

all the files are oggs.

Their bitrate does vary.
There are audio files ranging from 32kbps to 323kbps, 90% of the audio files are at 44100 Hz, 6% at 48000 Hz
speech is at 58-170kbps,44100 Hz

I don't know why that is i can ask Dave to i guess go through all of them and match em. The difficulty here is the other user that is still experiencing this issue, is kinda difficult to get them to test anything. I don't have that issue myself, to my knowledge, i can ask how many people have downloaded the demo and finished it, but i think we're looking at a pool of like 1000 to 1.

@Dualnames1
Copy link

2022-06-21_00-39-42.zip

This is an external recording, the audio crackling starts at 0:32, i personally only hear it at 0:37-38 it's rather difficult to grasp it, but maybe im old af.

@ericoporto
Copy link
Member Author

This is an external recording, the audio crackling starts at 0:32, i personally only hear it at 0:37-38 it's rather difficult to grasp it, but maybe im old af.

I cannot hear anything wrong in the recording at all...

I don't have that issue myself

From what I could understand, one of the issues this requires having a DAC or some other type of external sound card and it has to have unfortunate filters that makes the popping sounds audible, and this is made ok by using SDL2 built to work with libsamplerate, at least until the issue is fixed upstream.

The other issue you mention about voice/sounds is then a different issue, and this may not necessarily be correlated to the other.

@ericoporto ericoporto changed the title Sounds crack and pops using 48kHz and above frequencies with discreet audio cards Sounds crack and pops using 48kHz and above frequencies with external audio cards Jun 27, 2022
@necros2k7
Copy link

Always wondered - isn`t 44,1khz enought for human ears (cd quality)?

@ivan-mogilko ivan-mogilko added type: bug unexpected/erroneous behavior in the existing functionality context: audio backend: sdl2 related to sdl2 library labels Aug 28, 2022
@ivan-mogilko ivan-mogilko added this to the 3.6.0 maintenance milestone Apr 1, 2023
@ericoporto
Copy link
Member Author

This has been reported as fixed in SDL3 but it was in a complete rewrite of the audio internals of SDL, so there is no way to backport to SDL2 - the new code rewritten from scratch just doesn't have this issue.

We may need to start thinking about SDL3 and how/when we will migrate to it... (It's not released yet)

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Oct 4, 2023

We may need to start thinking about SDL3 and how/when we will migrate to it... (It's not released yet)

Is there a serious reason to do so, rather than fixing 1 bug, that is uncommon (and has a workaround on user's side, from what i understood from the ticket's description)? We have just migrated to SDL2, it took roughly about a year to deal with various problems, and engine lost couple of functionalities in the progress that were not restored yet.
Not to mention that the new library may not be available or not working well with some systems, like the multitude of linux distros that may take years before adding it to their stable release(s).

TBH I never checked SDL3, so don't know what this hypothetical migration will entail in terms of code.

@ericoporto
Copy link
Member Author

ericoporto commented Oct 4, 2023

We can delay it and there's an adapter library to run SDL2 on top of SDL3. I believe most people will be using this for a while once SDL3 is stable.

In terms of API most things are still there but they have a different naming scheme, so the call to things is instantly incompatible. We haven't added anything that uses an API that wasn't only renamed - I do manual check from time to time. The dollar touch (we don't use) has been moved to a satellite library.

There is a new backend to the renderer called SDL_gpu that is an abstraction over 3D accelerated renderer with it's own shader language that compiles at runtime for all systems, and you can also access it and directly render stuff - this is the biggest change, and it's not merged in the main SDL3 branch yet, it's on icculus fork. Other than this internally mostly rewrites and refactors but with same functionality.

Ah there is also a script that you can use on the repo that rewrites the code for sdl2 with SDL3 API calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: sdl2 related to sdl2 library context: audio type: bug unexpected/erroneous behavior in the existing functionality
Projects
None yet
Development

No branches or pull requests

4 participants