This series of articles are all copied from msdn. Remember them first, and they will be translated step by step later.
Waveformatex Structure
This is preliminary documentation and subject to change.
TheWaveformatexStructure defines the format of Waveform-audio data. only format information common to all Waveform-audio data formats is supported in this structure. for formats that require additional information, this structure is supported as the first member in another structure, along with the additional information.
This structure is part of the platform SDK and is declared in mmreg. H. It is already ented here for convenience.
Syntax
typedef struct { WORD wFormatTag; WORD nChannels; DWORD nSamplesPerSec; DWORD nAvgBytesPerSec; WORD nBlockAlign; WORD wBitsPerSample; WORD cbSize; } WAVEFORMATEX;
Members
Wformattag
Waveform-audio format type. format tags are registered with Microsoft Corporation for your compression algorithms. A complete list of format tags can be found in the mmreg. h header file. for one-or two-channel pulse code modulation (PCM) data, this value shocould be wave_format_pcm.
Nchannels
Number of channels in the waveform-audio data. Monaural data uses one channel and stereo data uses two channels.
Nsamplespersec
Sample rate, in samples per second (hertz). IfWformattagIs wave_format_pcm, then common valuesNsamplespersecAre 8.0 kHz, 11.025 kHz, 22.05 kHz, and 44.1 kHz. For non-PCM formats, this member must be computed according to the manufacturer's specification of the format tag.
Navgbytespersec
Required average data-transfer rate, in bytes per second, for the format tag. IfWformattagIs wave_format_pcm,NavgbytespersecShocould be equal to the productNsamplespersecAndNblockalign. For non-PCM formats, this member must be computed according to the manufacturer's specification of the format tag.
Nblockalign
Block alignment, in bytes. The block alignment is the minimum atomic unit of data forWformattagFormat type. IfWformattagIs wave_format_pcm or wave_format_extensible,NblockalignMust be equal to the productNchannelsAndWbitspersampleDivided by 8 (bits per byte). For non-PCM formats, this member must be computed according to the manufacturer's specification of the format tag.
Software must process a multiple of nblockalign bytes of data at a time. data written to and read from a device must always start at the beginning of a block. for example, it is illegal to start playback of PCM Data in the middle of a sample (that is, on a non-block-aligned boundary ).
Wbitspersample
Bits per sample forWformattagFormat type. IfWformattagIs wave_format_pcm, thenWbitspersampleShocould be equal to 8 or 16. For non-PCM formats, this member must be set according to the manufacturer's specification of the format tag. IfWformattagIs wave_format_extensible, this value can be any integer multiple of 8. Some compression schemes cannot define a value for wbitspersample, so this member can be zero.
Cbsize
Size, in bytes, of extra format information appended to the end ofWaveformatexStructure. This information can be used by non-PCM formats to store extra attributes forWformattag. If no extra information is required byWformattag, This member must be set to zero. For wave_format_pcm formats (and only wave_format_pcm formats), this member is ignored.
Requirements
Header:Dshow. h.