-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
WASAPI built-in resampler: Add AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM flag #819
Comments
Wow, didn't know that was in there, and would be great to get in there (especially if this works for playback too) In terms of fitting with NAudio design - a couple of thoughts
|
Thanks for sharing the thoughts:
|
Sorry it took me so long to get round to this, but finally have implemented it and it will be in the next NAudio release. Many thanks for making me aware of this capability - it makes WASAPI so much easier to work with. |
I discovered that there is a built-in resampler in WASAPI that allows to use any wave format with WASAPI.
It is turned on by AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM flag , see
https://docs.microsoft.com/en-us/windows/win32/coreaudio/audclnt-streamflags-xxx-constants
The flag is succesfully used in miniaudio and portaudio C++ open source libraries.
Adding this option to NAudio WASAPI implementation would greatly simplify the life of Windows-based developers as manual resampling is cumbersome and sometimes results in pretty much unpredictable results. Use of something built-in instead looks like a more reliable and simple option.
I was wondering if it works in NAudio. I was able to change the NAudio code inserting the flag into NAudio lib+disabling IsFormatSupported() call for NAudio.Wasapi/WasapiCapture.cs.
This allowed me to specify any format for WasapiCapture even if it is not supported by the endpoint device.
For this, I changed AudioClientStreamFlags() code:
and deleted IsFormatSupported() check from
NAudio/NAudio.Wasapi/WasapiCapture.cs
Line 127 in fb35ce8
Let me know how to proceed: propose a patch or let you incorporate this flag in a way you prefer (e.g. having a separate class, or whatever that suits NAudio code design)
The text was updated successfully, but these errors were encountered: