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

Clicking on dsound backend #1042

Open
sergeyext opened this issue Sep 8, 2024 · 3 comments
Open

Clicking on dsound backend #1042

sergeyext opened this issue Sep 8, 2024 · 3 comments

Comments

@sergeyext
Copy link
Contributor

In my previous issue I reported problems with WASAPI backend and headphones. DSound compares equal to the reference sound when using headphones, but starts clicking after switching to speakers, while WASAPI sounds perfect on speakers.

Here is the waveform recorded with a loopback virtual device with clicks clearly visible:
kick-dsound-clicks

Here's the sandbox app for reproduction:
https://github.com/sergeyext/alsoft-backends-test

and this is app's debug output on my machine:

[ALSOFT] (II) Initializing library v1.22.1-unknown UNKNOWN
[ALSOFT] (II) Supported backends: wasapi, dsound, winmm, null, wave
[ALSOFT] (II) Loading config C:\Users\Sergey\AppData\Roaming\alsoft.ini...
[ALSOFT] (II) Got binary: C:\code\alsoft-backends-test\cmake-build-debug, alsoft_backends_test.exe
[ALSOFT] (II) Loading config C:\code\alsoft-backends-test\cmake-build-debug\alsoft.ini...
[ALSOFT] (II)  found 'drivers' = 'dsound'
[ALSOFT] (II) Key disable-cpu-exts not found
[ALSOFT] (II) Vendor ID: "AuthenticAMD"
[ALSOFT] (II) Name: "AMD Ryzen 7 4800H with Radeon Graphics"
[ALSOFT] (II) Extensions: +SSE +SSE2 +SSE3 +SSE4.1
[ALSOFT] (II) Key rt-prio not found
[ALSOFT] (II) Key rt-time-limit not found
[ALSOFT] (II) Key game_compat/reverse-x not found
[ALSOFT] (II) Key game_compat/reverse-y not found
[ALSOFT] (II) Key game_compat/reverse-z not found
[ALSOFT] (II) Key resampler not found
[ALSOFT] (II) Key trap-al-error not found
[ALSOFT] (II) Key trap-alc-error not found
[ALSOFT] (II) Key reverb/boost not found
[ALSOFT] (II) Found drivers = "dsound"
[ALSOFT] (II) Initialized backend "dsound"
[ALSOFT] (II) Added "dsound" for playback
[ALSOFT] (II) Added "dsound" for capture
[ALSOFT] (II) Key excludefx not found
[ALSOFT] (II) Key default-reverb not found
[ALSOFT] (II) Key eax/enable not found
[ALSOFT] (II) Got device "OpenAL Soft on Speaker (Realtek(R) Audio)"
[ALSOFT] (II) Got device "OpenAL Soft on ╨Ф╨╕╨╜╨░╨╝╨╕╨║╨╕ (Steam Streaming Microphone)"
[ALSOFT] (II) Got device "OpenAL Soft on ASUS VA27EHE (NVIDIA High Definition Audio)"
[ALSOFT] (II) Got device "OpenAL Soft on ╨Ф╨╕╨╜╨░╨╝╨╕╨║╨╕ (Steam Streaming Speakers)"
[ALSOFT] (II) Key frequency not found
[ALSOFT] (II) Key sources not found
[ALSOFT] (II) Key slots not found
[ALSOFT] (II) Key sends not found
[ALSOFT] (II) Created device 000002A5BB3BBEB0, "OpenAL Soft on Speaker (Realtek(R) Audio)"
[ALSOFT] (II) Key sample-type not found
[ALSOFT] (II) Key channels not found
[ALSOFT] (II) Key ambi-format not found
[ALSOFT] (II) Key period_size not found
[ALSOFT] (II) Key periods not found
[ALSOFT] (II) Key hrtf not found
[ALSOFT] (II) Pre-reset: Stereo, Float32, 44100hz, 882 / 2646 buffer
[ALSOFT] (II) Post-reset: Stereo, Int16, 44100hz, 882 / 2646 buffer
[ALSOFT] (II) Key stereo-mode not found
[ALSOFT] (II) Key stereo-encoding not found
[ALSOFT] (II) Key cf_level not found
[ALSOFT] (II) Stereo rendering
[ALSOFT] (II) Channel config, Main: 3, Real: 2
[ALSOFT] (II) Allocating 5 channels, 20480 bytes
[ALSOFT] (II) Enabling single-band first-order ambisonic decoder
[ALSOFT] (II) Max sources: 256 (255 + 1), effect slots: 64, sends: 4
[ALSOFT] (II) Key dither not found
[ALSOFT] (II) Key dither-depth not found
[ALSOFT] (II) Dithering enabled (16-bit, 32768)
[ALSOFT] (II) Key output-limiter not found
[ALSOFT] (II) Output limiter enabled, -0.0005dB limit
[ALSOFT] (II) Fixed device latency: 997732ns
[ALSOFT] (II) Post-start: Stereo, Int16, 44100hz, 882 / 2646 buffer
[ALSOFT] (II) Increasing allocated voices to 256
[ALSOFT] (II) Key volume-adjust not found
[ALSOFT] (II) Created context 000002A5BB410350
ALC_SOFT_HRTF: 1
[ALSOFT] (II) Key hrtf-paths not found
[ALSOFT] (II) Searching C:\code\alsoft-backends-test\cmake-build-debug\*.mhr
[ALSOFT] (II) Searching C:\Users\Sergey\AppData\Roaming\openal\hrtf\*.mhr
[ALSOFT] (II) Searching C:\ProgramData\openal\hrtf\*.mhr
[ALSOFT] (II) Adding built-in entry "!1_Built-In HRTF"
[ALSOFT] (II) Key default-hrtf not found
HRTFs count: 1
HRTF Name: Built-In HRTF
Use HRTF: 0
HRTF status: 0
[ALSOFT] (II) Increasing allocated voice properties to 32
Playing...
Finished.
[ALSOFT] (II) Freeing context 000002A5BB410350
[ALSOFT] (II) Freed 0 context property objects
[ALSOFT] (II) Freed 0 AuxiliaryEffectSlot property objects
[ALSOFT] (II) Freeing device 000002A5BB3BBEB0
@sergeyext
Copy link
Contributor Author

Updated to the latest release 1.23.1.
Clicking reduced, but not vanished totally, and waveform surges are still here.
kick-1 23-surge
kick-1 23-surge2

@ThreeDeeJay
Copy link
Contributor

You could try playing with the INI settings, particularly periods and period size (In my experience, DirectSound needs a higher buffer in FlexASIO to prevent crackling, so maybe that also applies here)

By the way, I don't think it's recommended to use DirectSound on Vista+ because it gets emulated in WASAPI anyway so it's probably better to use that directly (pun intended) instead. I'm guessing that's why it's the default.
https://en.wikipedia.org/wiki/DirectSound#Windows_Vista/Windows_7

@kcat
Copy link
Owner

kcat commented Sep 9, 2024

Looks like an underrun. The waveform seems to jump back and repeat a bit before getting further, then jumps back and repeats again, etc. I don't really see why that would be happening, OpenAL Soft waits for DSound to signal some notifications on the playback buffer (which are set evenly spaced given the update size and buffer size), where it then mixes into the next free space in the playing buffer.

Maybe something is happening in DSound that causes it to not trigger the notifications as they should, so OpenAL Soft doesn't wake up and mix in time. My first thought was maybe the 44100hz output; if the 44100hz DSound buffer is being resampled to 48000hz for WASAPI, maybe the timing is getting thrown off. Though you say you updated to 1.23.1, which should default to 48khz output and not need resampling, and it still happens, though less often.

But yeah, as ThreeDeeJay says, DirectSound isn't recommended to use anymore since Windows Vista, since it's emulated in software and outputs through WASAPI, so it's not "direct" anymore and is just extra layers between OpenAL Soft and the output, which can cause extra latency and overhead, leading to underruns with smaller buffers.

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

3 participants