从 IAudioClient::GetMixFormat 解读 WAVEFORMATEXTENSIBLE
Interpreting WAVEFORMATEXTENSIBLE from IAudioClient::GetMixFormat
我正在学习 Windows 核心音频 API。使用这个 Rendering a Stream example, I'm finding that IAudioClient::GetMixFormat returns an ambiguous WAVEFORMATEXTENSIBLE 看起来像这样:
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
因为Format.cbSize
是22,所以这是整个结构;没有 SubFormat
GUID 来提供有关示例的更多信息。这看起来很奇怪,因为格式标记是 WAVE_FORMAT_EXTENSIBLE
,我认为这意味着您必须依赖 Subformat
GUID 来确定实际格式。
我可以看到有两个通道的 32 位样本。如何确定这些样本是整数还是浮点值?
[core-audio 标签显然适用于 Apple API。 Windows Core Audio 是否有不同的标签?]
22 是 WAVEFORMATEX
数据之后的附加数据的大小:
cbSize
Size, in bytes, of extra format information appended to the end of the WAVEFORMATEX
structure. This information can be used by non-PCM formats to store extra attributes for the wFormatTag
. If no extra information is required by the wFormatTag
, this member must be set to 0. For WAVE_FORMAT_PCM
formats (and only WAVE_FORMAT_PCM
formats), this member is ignored. When this structure is included in a WAVEFORMATEXTENSIBLE
structure, this value must be at least 22.
如果您查看 WAVEFORMATEXTENSIBLE
的定义,它以 WAVEFORMATEX
开头,然后包含额外的数据:
typedef struct {
WAVEFORMATEX Format;
union {
WORD wValidBitsPerSample;
WORD wSamplesPerBlock;
WORD wReserved;
} Samples;
DWORD dwChannelMask;
GUID SubFormat;
} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
即 WAVEFORMATEX
数据后最少 22 个字节。
SubFormat
字段包含您要查找的格式值。
我正在学习 Windows 核心音频 API。使用这个 Rendering a Stream example, I'm finding that IAudioClient::GetMixFormat returns an ambiguous WAVEFORMATEXTENSIBLE 看起来像这样:
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
因为Format.cbSize
是22,所以这是整个结构;没有 SubFormat
GUID 来提供有关示例的更多信息。这看起来很奇怪,因为格式标记是 WAVE_FORMAT_EXTENSIBLE
,我认为这意味着您必须依赖 Subformat
GUID 来确定实际格式。
我可以看到有两个通道的 32 位样本。如何确定这些样本是整数还是浮点值?
[core-audio 标签显然适用于 Apple API。 Windows Core Audio 是否有不同的标签?]
22 是 WAVEFORMATEX
数据之后的附加数据的大小:
cbSize
Size, in bytes, of extra format information appended to the end of the
WAVEFORMATEX
structure. 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_PCM
formats (and onlyWAVE_FORMAT_PCM
formats), this member is ignored. When this structure is included in aWAVEFORMATEXTENSIBLE
structure, this value must be at least 22.
如果您查看 WAVEFORMATEXTENSIBLE
的定义,它以 WAVEFORMATEX
开头,然后包含额外的数据:
typedef struct {
WAVEFORMATEX Format;
union {
WORD wValidBitsPerSample;
WORD wSamplesPerBlock;
WORD wReserved;
} Samples;
DWORD dwChannelMask;
GUID SubFormat;
} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
即 WAVEFORMATEX
数据后最少 22 个字节。
SubFormat
字段包含您要查找的格式值。