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

[xaudio2] poor quality when playing 11025hz sound compared to winmm/directsound #1491

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Labels
wontfix This will not be worked on

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.1
Reported for operating system, platform: Windows 8, x86_64

Comments on the original bug report:

On 2014-05-18 21:50:34 +0000, Eric Wasylishen wrote:

Created attachment 1650
sample audio file and recordings

Tested with SDL-2.0.3-8746.zip on Windows 8.

Steps to reproduce:

  • use the loopwave SDL2 sample app to play "440.wav" from the attached zipfile. This is an 8-bit 11025hz wav of a 440hz sinewave.

  • Check that sdl is using the xaudio2 driver (look for INFO: Using audio driver: xaudio2 in stdout)

  • Expected: should sound the same as playing 440.wav in a media player (e.g. vlc)

  • Observed: There's a sort of ticking sound over the sine wave. I made a recording with audacity and attached it as 440-xaudio2-recording.wav.

I also tested the loopwave sample with the "winmm" and "directsound" drivers, by adding a line SDL_AudioInit("winmm"), and both of these drivers produce correct sounding output. For reference, I attached recordings made with these drivers as 440-directsound-recording.wav and 440-winmm-recording.wav.

On 2014-05-19 07:32:18 +0000, Eric Wasylishen wrote:

Created attachment 1652
partial fix

I investigated a bit more and came up with a partial fix; instead of resampling between the 'mastering voice' and device, I moved resampling to between the 'source voice' and 'mastering voice'.
Don't know why that works, but it gets rid of the worst distortion. It appears that this is an xaudio2 bug..

Unfortunately, the results still sound pretty bad. I recorded the output of playing my 440.wav file in loopwave, with this patch applied, and checking the frequency spectrum in audacity, there's still a lot of audio > 5kHz. There should be basically nothing over 5.5kHz since the input file is sampled 11025hz. The output with 'winmm' and 'directsound' are both correctly brickwalled at ~5.5kHz. Basically, xaudio2's resampler seems to suck, at least when given low sample rate input :-(

There's a mention in some DirectX release notes of what may be the same problem I'm seeing:

http://www.microsoft.com/en-us/download/details.aspx?id=5770

"In the March 2008 and later SDKs, the resampler in XAudio2 may introduce more aliasing for mono 16-bit source data compared to other formats. This is noticeable mostly on frequency changes larger than a factor of two. To workaround this issue, use a submix voice to implement the bulk of the frequency change."

I experimented with using a submix voice between the source voice and mastering voice, but it didn't seem to have any effect.

On 2015-03-12 20:00:20 +0000, Eric Wasylishen wrote:

Christian Knudsen also reported hitting the same issue on Windows 7, with 22050Hz sounds. "high frequencies getting a sharp/hissy tinge " was reported that went away when using 44100Hz, or avoiding Xaudio2 with SDL_AudioInit("winmm") or SDL_AudioInit("directsound ").

https://forums.libsdl.org/viewtopic.php?t=11092

I'm thinking the best solution would be for SDL to avoid using Xaudio2 if it's going to perform any resampling.

On 2015-03-26 21:53:00 +0000, Eric Wasylishen wrote:

Created attachment 2090
recording of sample.wav played back distorted by Xaudio2

Still reproducing on the latest HG. Here is a simpler way to repro:

  • run the loopwave SDL2 sample app (no need to download the sound files I posted)

  • Check that sdl is using the xaudio2 driver (look for INFO: Using audio driver: xaudio2 in stdout)

  • Expected: jazz music plays (SDL/test/sample.wav), it sounds the same as playing the file in a media player (e.g. vlc)

  • Observed: Bad distortion is heard over the music. Attached a recording of this, distorted.mp3

On 2017-08-14 05:07:06 +0000, Sam Lantinga wrote:

We're removing XAudio2 in favor of WASAPI after the 2.0.6 release.

@SDLBugzilla SDLBugzilla added bug wontfix This will not be worked on labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant