Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This structure defines the format of waveform-audio data. Only format information common to all waveform-audio data formats is included in this structure. For formats that require additional information, this structure is included as the first member in another structure, along with the additional information.

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 many compression algorithms. A complete list of format tags can be found in the Mmreg.h header file.

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), that each channel should be played or recorded. If wFormatTagis WAVE_FORMAT_PCM, then common values for nSamplesPerSecare 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. If wFormatTagis WAVE_FORMAT_PCM, nAvgBytesPerSecshould be equal to the product of nSamplesPerSecand nBlockAlign. For non-PCM formats, this member must be computed according to the manufacturer's specification of the format tag.

Playback and record software can estimate buffer sizes by using the nAvgBytesPerSecmember.

nBlockAlign

Block alignment, in bytes. The block alignment is the minimum atomic unit of data for the wFormatTagformat type. If wFormatTagis WAVE_FORMAT_PCM, nBlockAlignshould be equal to the product of nChannelsand wBitsPerSampledivided by 8 (bits per byte). For non-PCM formats, this member must be computed according to the manufacturer's specification of the format tag.

Playback and record software must process a multiple of nBlockAlignbytes of data at a time. Data written 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 for the wFormatTagformat type. If wFormatTagis WAVE_FORMAT_PCM, then wBitsPerSampleshould 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. 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 of the WAVEFORMATEXstructure. 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 zero. For WAVE_FORMAT_PCM formats only, this member is ignored.

Remarks

An example of a format that uses extra information is the Microsoft Adaptive Delta Pulse Code Modulation (MS-ADPCM) format. The wFormatTagfor MS-ADPCM is WAVE_FORMAT_ADPCM. The cbSizemember is typically set to 32. The extra information stored for WAVE_FORMAT_ADPCM is coefficient pairs required for encoding and decoding the waveform-audio data.

Requirements

Header mmsystem.h
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also