30 August 2016, 18:19 | #1 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,344
|
WASAPI audio on Windows 10
I was reading an MSDN article on low-latency audio, and noticed it mentions some improvements in Windows 10:
"Starting in Windows 10 , WASAPI has been enhanced to:
The above functionality is provided by a new interface, called IAudioClient3, which derives from IAudioClient2." Could those new features be any use for WinUAE? It could allow sound buffer size setting of 1 to always correspond to the smallest buffer supported by the specific audio driver. It looks like there's also IAudioClient2::GetBufferSizeLimit which seems to serve a similar purpose? That's supported from Windows 8 on. |
30 August 2016, 19:03 | #2 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
I don't think they will help because buffer size and frequency is already adjustable in UAE. It never asks for some sound driver defaults.
AFAIK It is also difficult to use Win8+ SDK and still create XP compatible executables. |
06 September 2016, 09:35 | #3 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,344
|
Knowing the smallest buffer size supported by the hardware driver could be useful, maybe a sound buffer size setting of 0 could be used to indicate that?
I can set buffer size to 1 and still get crackle-free audio, so I'm wondering how much lower could be possible. |
06 September 2016, 11:29 | #4 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
Sounds useful enough. AFAIK lowest supported number of samples is somewhere between 100 and 200 and buffer=1 equals 256 samples.
|
09 October 2016, 13:31 | #5 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
I tried AudioClient2 GetBufferSizeLimits() but it only returns AUDCLNT_E_OFFLOAD_MODE_ONLY. Bah.
|
09 October 2016, 15:40 | #6 | |
Registered User
Join Date: Jul 2008
Location: Netherlands
Posts: 485
|
Quote:
Not sure whether the following may help, but in any case a related problem is mentioned here: http://stackoverflow.com/questions/3...pi-shared-mode From reading the last comment from the OP to his own question, the solution seems to be in this part of the MS article https://msdn.microsoft.com/en-us/lib...surement_Tools Which says "In order to measure the roundtrip latency for different buffer sizes, users need to install a driver that supports small buffers. The inbox HDAudio driver has been updated to support buffer sizes between 128 samples (2.66ms@48kHz) and 480 samples (10ms@48kHz). The following steps show how to install the inbox HDAudio driver (which is part of all Windows 10 SKUs)" "After reboot, the system will be using the inbox Microsoft HDAudio driver and not the 3rd-party codec driver. Remember which driver you were using before, so that you can fallback to that driver, if you want to use the optimal settings for your audio codec." |
|
09 October 2016, 17:32 | #7 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
I added extra path if IAudioClient3 open succeeds, first log current values (GetSharedModeEnginePeriod and GetCurrentSharedModeEnginePeriod), then call InitializeSharedAudioStream (only if shared mode and new buffer size is smaller than default returned by GetSharedModeEnginePeriod). Then log GetSharedModeEnginePeriod values again.
Unfortunately I only get: default=480, min=480, max=480. Returned buffer is also always 1056 samples. (SoundBlaster Z, June 2016 drivers. I also have onboard realtek but it is disabled because last time I tested it, it also installed some useless and broken shell extension..) Quote:
Last edited by Toni Wilen; 09 October 2016 at 18:04. |
|
09 October 2016, 18:03 | #8 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,344
|
Try uninstalling the Realtek driver and let Windows install the Microsoft one, maybe that will help with the on-board audio.
|
09 October 2016, 20:06 | #9 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
I switched realtek on from bios. Realtek driver does more or less same as SB driver but forced Microsoft HD Audio driver changes Min=128, Max=448. (with Realtek driver Min=448, Max=448)
Hmm.. Now that pull mode is in use, whole WASAPI buffer selection does not make much sense anymore, especially in shared mode where the actual limit is Windows mixer/resampler buffering/latency than emulation and this new InitializeSharedAudioStream() actually adjusts internal mixer/resampler buffer size/timing (which is not visible to application). Perhaps it is much simpler to always request smallest and lowest latency possible WASAPI buffer and Sound panel buffer selection only adjusts size of WinUAE internal "reservour" buffer. |
09 October 2016, 20:27 | #10 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,344
|
A larger-than-minimum WASAPI buffer should help with power saving though, due to less-frequent CPU wakeups? Minimum-possible audio latency isn't always needed. E.g. running a demo, the video latency (double/triple-buffering + LCD monitor latency) could perhaps be larger than the minimum audio latency anyway.
|
09 October 2016, 21:52 | #11 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
Powersaving will lose if other choice is better sound stability or latency..
-- I'll try hybrid solution: keep default latency (No calls to InitializeSharedAudioStream) until configured buffer size is about same or lower than DefaultPeriodInFrames and the smaller the buffer, the smaller the PeriodInFrames value gets. -- btw, InitializeSharedAudioStream documentation is incorrect: "Periodicity requested by the client. This value must be an integral multiple of the value returned in the pDefaultPeriodInFrames parameter to IAudioClient3::GetSharedModeEnginePeriod. PeriodInFrames must also be greater than or equal to the value returned in pMinPeriodInFrames and less than or equal to the value of returned pMaxPeriodInFrames." "pDefaultPeriodInFrames" should be "pFundamentalPeriodInFrames". EDIT: Something done. Also calling IAudioClient2::SetClientProperties(). (If it does something) Last edited by Toni Wilen; 09 October 2016 at 22:01. |
10 October 2016, 16:25 | #12 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
Updated. Now if shared mode and requested buffer size is >= 10ms (Pre-Windows 10 default WASAPI buffer): use normal AudioClient->Initialize(), if < 10ms requested (currently only if buffer 1/2, possibly 3 too or new "min" option), AudioClient3->InitializeSharedAudioStream() is used.
"Min" buffer option added that selects smallest driver supported buffer size. WASAPI buffer scale adjusted: for example size 5 now is old buffer size 4 and so on. Pull mode is much more stable than push, there is now less need for very big buffers. It "sounds" like exclusive mode is not really needed anymore unless you want absolutely smallest latency possible. |
11 October 2016, 13:56 | #13 | |
Registered User
Join Date: Jul 2008
Location: Netherlands
Posts: 485
|
Quote:
|
|
11 October 2016, 15:31 | #14 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
|
11 October 2016, 23:49 | #15 | ||
Registered User
Join Date: Jul 2008
Location: Netherlands
Posts: 485
|
Quote:
Quote:
Currently it runs seemingly flawless in low latency vsync mode, i.e. no pull overflows, for the realtek chip (with MS High def driver) with Setting 2 / BUF=352 and for the esi juli@ card with BUF=528 (minimum reported "PeriodInFrames" 480, I guess the card would really need a driver update to support this new Windows 10 Wasapi small buffer feature). With BUF=352, is it possible to tell what the total latency approximately will be, is it 704/48000=~15ms? WASAPI: Shared Pull CH=2 FREQ=48000 BUF=352 (704) |
||
12 October 2016, 09:21 | #16 |
Registered User
Join Date: Mar 2012
Location: Australia
Age: 44
Posts: 1,126
|
Sound is slightly unstable in pull mode with buffer setting of 1.. I havn't done any beta testing since pull mode was first implemented as have built a new PC - but now using old hardware as dedicated winuae machine, although I have win 10 installed now instead of 7.
Anyway I'd like to try this latest "winuae.7z", where is it? beta11 link was updated? |
12 October 2016, 09:41 | #17 | |
Registered User
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
|
Quote:
|
|
12 October 2016, 11:45 | #18 |
Registered User
Join Date: Mar 2012
Location: Australia
Age: 44
Posts: 1,126
|
Thanks.
Well I have not tested for very long but wasapi with 'min' buffer seems to run very well. Although something strange. I played a few whdload games and both exhibit a behaviour where random sounds play too long.. as if stuck on a brief loop. Also I think there is occasionally random sounds being played when they shouldn't.. but need to confirm it. Perhaps this is new type of anomaly that is produce from having too low buffer set in pull mode? Anyway will continue to use this version, loving the ultra low input/sound latency |
12 October 2016, 12:20 | #19 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
If only single sample sounds wrong but other samples that play at the same time are not wrong: probably game doing something sound timing sensitive.
Also, buffer size less than 4 or so: you are on your own, don't do it, buy a better pc and so on if you have sound problems |
12 October 2016, 15:11 | #20 | ||
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
Quote:
Quote:
Value in parenthesis is wasapi buffer size. I am not sure if I want to mess with this too much, can't really improve it much more. |
||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Noise when dragging emulation window with WASAPI EX sound | mark_k | support.WinUAE | 0 | 22 August 2016 20:59 |
Best Audio Config in Winuae for a Creative X-Fi Audio Card | shaf | support.WinUAE | 2 | 14 June 2012 16:27 |
winuae 1.6.1 in Windows 7 and WASAPI audio | Gaula92 | support.WinUAE | 12 | 13 July 2009 09:14 |
Crash using Portaudio WASAPI mode | Ian | support.WinUAE | 6 | 31 May 2009 03:34 |
cd audio | SexyWayne | support.Hardware | 4 | 04 May 2005 01:47 |
|
|