I'm learning about Windows Core Audio APIs. Using this Rendering a Stream example, I'm finding that IAudioClient::GetMixFormat returns an ambiguous WAVEFORMATEXTENSIBLE that looks like this:
Format
wFormatTag = WAVE_FORMAT_EXTENSIBLE (65534)
nChannels = 2
nSamplesPerSec = 48000
nAvgBytesPerSec = 384000
nBlockAlign = 8
wBitsPerSample = 32
cbSize = 22
Samples // this is a union
wValidBitsPerSample = 32
wSamplesPerBlock = 32
wReserved = 32
Since Format.cbSize is 22, this is the entire structure; there is no SubFormat GUID to provide more information about the samples. That seems weird because the format tag is WAVE_FORMAT_EXTENSIBLE, which--I thought--means that you have to rely on the Subformat GUID to determine the actual format.
I can see that there are two channels of 32-bit samples. How can I determine whether those samples are integers or floating point values?
[The core-audio tag is apparently for an Apple API. Is there a different tag for Windows Core Audio?]
22 is the size of additional data that follows the WAVEFORMATEX data:
cbSize
Size, in bytes, of extra format information appended to the end of the
WAVEFORMATEXstructure. This information can be used by non-PCM formats to store extra attributes for thewFormatTag. If no extra information is required by thewFormatTag, this member must be set to 0. ForWAVE_FORMAT_PCMformats (and onlyWAVE_FORMAT_PCMformats), this member is ignored. When this structure is included in aWAVEFORMATEXTENSIBLEstructure, this value must be at least 22.
If you look at the definition of WAVEFORMATEXTENSIBLE, it begins with a WAVEFORMATEX and then contains extra data after it:
typedef struct {
WAVEFORMATEX Format;
union {
WORD wValidBitsPerSample;
WORD wSamplesPerBlock;
WORD wReserved;
} Samples;
DWORD dwChannelMask;
GUID SubFormat;
} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
That is a minimum of 22 bytes after the WAVEFORMATEX data.
The SubFormat field contains the format value you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With