Louis-Paul,
WASAPI shared mode will hardly be bit transparent as the Windows audio service will process the samples. Only if your process is the only one using the audio device AND the configured default format (in Windows audio control panel applet) is exactly the same format your application is requesting.
Just another 0.02$
Axel
From: portaudio-***@lists.columbia.edu [mailto:portaudio-***@lists.columbia.edu] On Behalf Of Louis-Paul CORDIER
Sent: Tuesday, July 10, 2018 10:23 AM
To: 'portaudio list' <***@lists.columbia.edu>
Subject: Re: [Portaudio] "Real" 24 bits with portaudio
Hi everybody,
Thank you all for your quick replies. Ross no worries, my first-name is being crushed since my childhood ;)
1. Opening the stream as PaInt32 is not acceptable for my use case, as I need to know at opening if it's 24bits or not.
2. I will give a try to Wasapi exclusive mode, but still portaudio can silently do a conversion to my understanding of the code.
3. I digged into the source code this morning and to my understanding of the Windows SDK doc, it would be possible to determine if the audio format is supported or not by the device. (from https://docs.microsoft.com/en-us/windows/desktop/api/audioclient/nf-audioclient-iaudioclient-isformatsupported)
"For shared mode, if the audio engine supports the caller-specified format, IsFormatSupported sets *ppClosestMatch to NULL and returns S_OK. If the audio engine does not support the caller-specified format but does support a similar format, the method retrieves the similar format through the ppClosestMatch parameter and returns S_FALSE. If the audio engine does not support the caller-specified format or any similar format, the method sets *ppClosestMatch to NULL and returns AUDCLNT_E_UNSUPPORTED_FORMAT."
After reading into the PA wasapi code, it seems that you developed an heuristic for selecting the right audio format. So even in shared mode, we could add a flag that will make Pa_IsFormatSupported to fail if the underlying device can't provide the exact format requested by the user instead of executing the heuristic.
4. Side note 1: I've found some function in pa_utils very useful, even for the end user. it would be great to export functions into this header while installing portaudio with CMake?
5. Side note 2: I jumped into Portaudio CMakeLists.txt. It does not look like a "modern cmake". Would it be accepted by the community if I update the CMakeLists? Maybe these 2 last questions deserve another thread in the mailing list though...
BR,
Louis-Paul
Le 10/07/2018 à 08:47, Axel Holzinger a écrit :
I can confirm that via WASAPI in exclusive mode on Windows (tested only with
Windows 10) bit transparent operation with 24 bits per sample with PortAudio
is working well.
Anyhow a function to really get the device capabilities would be very
useful. This was also missing in the native (Windows) APIs, which in the
past made me write Windows code that really tries to open the device in all
thinkable formats to really find out, if it's supporting some format. So it
might be hard to add such a function in PortAudio.
Just my 0.02$
Axel
-----Original Message-----
From: portaudio-***@lists.columbia.edu <mailto:portaudio-***@lists.columbia.edu> [mailto:portaudio-
***@lists.columbia.edu <mailto:***@lists.columbia.edu> ] On Behalf Of Chris
Sent: Tuesday, July 10, 2018 3:30 AM
To: ***@lists.columbia.edu <mailto:***@lists.columbia.edu> ; ***@dynamixyz.com <mailto:***@dynamixyz.com>
Subject: Re: [Portaudio] "Real" 24 bits with portaudio
-----Original Message-----
From: Ross Bencina <mailto:rossb-***@audiomulch.com> <rossb-***@audiomulch.com>
To: portaudio list <mailto:***@lists.columbia.edu> <***@lists.columbia.edu>; Louis-Paul CORDIER
<mailto:***@dynamixyz.com> <***@dynamixyz.com>
Sent: Mon, Jul 9, 2018 5:49 pm
Subject: Re: [Portaudio] "Real" 24 bits with portaudio
"Your only option is to use paInt32 and check whether the low bits are
zero."
If he fetches 32-bit samples from a 24-bit device, I would think his
samples will
be padded with 8 zeroes.
Why not simply use 24-bit WASAPI as I explained in a previous post? Dmitry
and I
put a lot of hours into making WASAPI work on PortAudio so why not use it?
I
assume the O.P. is not running Windows XP or prior.