WAVEFORMATEX 格式说明

来源:互联网 发布:wlan流量和数据流量 编辑:程序博客网 时间:2024/06/04 19:48

WAVEFORMATEX

The WAVEFORMATEX structure specifies the data format of a wave audio stream.

WAVEFORMATEX 为波形音频流格式的数据结构

typedef struct
{
  WORD  wFormatTag;
  WORD  nChannels;
  DWORD  nSamplesPerSec;
  DWORD  nAvgBytesPerSec;
  WORD  nBlockAlign;
  WORD  wBitsPerSample;
  WORD  cbSize;
} WAVEFORMATEX; *PWAVEFORMATEX;

Members

wFormatTag
Specifies the waveform audio format type. For more information, see the followingComments section.
设置波形声音的格式,更多的信息请参考说明部分。
nChannels
Specifies the number of channels of audio data. For monophonic audio, set this member to 1. For stereo, set this member to 2.
设置音频文件的通道数量,对于单声道的声音,此此值为1。对于立体声,此值为2.
nSamplesPerSec
Specifies the sample frequency at which each channel should be played or recorded. IfwFormatTag = WAVE_FORMAT_PCM, then common values fornSamplesPerSec are 8.0 kHz, 11.025 kHz, 22.05 kHz, and 44.1 kHz. For example, to specify a sample frequency of 11.025 kHz, setnSamplesPerSec to 11025. For non-PCM formats, this member should be computed according to the manufacturer's specification of the format tag.
设置每个声道播放和记录时的样本频率。
如果wFormatTag = WAVE_FORMAT_PCM,那么nSamplesPerSec通常为8.0 kHz, 11.025 kHz, 22.05 kHz和44.1 kHz。例如对于采样率为11.025 kHz的音频,nSamplesPerSec 将被设为11025。对于非PCM格式的,请根据厂商的设定计算。
nAvgBytesPerSec
Specifies the required average data transfer rate in bytes per second. This value is useful for estimating buffer size.
设置请求的平均数据传输率,单位byte/s。这个值对于创建缓冲大小是很有用的。
nBlockAlign
Specifies the block alignment in bytes. The block alignment is the size of the minimum atomic unit of data for thewFormatTag format type. IfwFormatTag = WAVE_FORMAT_PCM, setnBlockAlign to (nChannels*wBitsPerSample)/8, which is the size of a single audio frame. For non-PCM formats, this member should be computed according to the manufacturer's specification for the format tag.

Playback and record software should process a multiple of nBlockAlign bytes of data at a time. Data written to and read from a device should always start at the beginning of a block.

以字节为单位设置块对齐。块对齐是指最小数据的原子大小。如果wFormatTag = WAVE_FORMAT_PCM,nBlockAlign 为(nChannels*wBitsPerSample)/8。对于非PCM格式请根据厂商的说明计算。

wBitsPerSample
Specifies the number of bits per sample for the format type specified by wFormatTag. If wFormatTag = WAVE_FORMAT_PCM, then wBitsPerSample should be set to either 8 or 16. For non-PCM formats, this member should be set according to the manufacturer's specification for the format tag. Some compression schemes cannot define a value forwBitsPerSample. In this case, set wBitsPerSample to zero.
根据wFormatTag的类型设置每个样本的位深(即每次采样样本的大小,以bit为单位)。如果wFormatTag = WAVE_FORMAT_PCM,此值应该设为8或16,对于非PCM格式,根据厂商的说明设置。一些压缩的架构不能设置此值,此时wBitsPerSample应该为零。
cbSize
Specifies the 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 the wFormatTag, this member must be set to zero. For WAVE_FORMAT_PCM formats, this member is ignored.
额外信息的大小,以字节为单位,额外信息添加在WAVEFORMATEX结构的结尾。这个信息可以作为非PCM格式的wFormatTag额外属性,如果wFormatTag不需要额外的信息,此值必需为0,对于PCM格式此值被忽略。