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
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:
"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 ").