WAVEFORMATEX 等数据结构整理

本文详细介绍了WAVEFORMATEX结构在音频处理领域的关键作用,包括格式类型、声道数、采样频率等核心参数的解释与应用。深入探讨了音频数据的组织方式和传输效率,旨在帮助开发者更好地理解和使用WAVEFORMATEX结构进行音频文件的处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



typedef struct tWAVEFORMATEX
{
    WORD        wFormatTag;         /* format type */
    WORD        nChannels;          /* number of channels (i.e. mono, stereo...) */
    DWORD       nSamplesPerSec;     /* sample rate */
    DWORD       nAvgBytesPerSec;    /* for buffer estimation */
    WORD        nBlockAlign;        /* block size of data */
    WORD        wBitsPerSample;     /* number of bits per sample of mono data */
    WORD        cbSize;             /* the count in bytes of the size of */
    /* extra information (after cbSize) */
} WAVEFORMATEX, *PWAVEFORMATEX, NEAR *NPWAVEFORMATEX, FAR *LPWAVEFORMATEX;

typedef struct 
{
WORD wFormatTag;     /* 指定格式类型; 默认 WAVE_FORMAT_PCM = 1; */
WORD nChannels;     /* 指出波形数据的声道数; 单声道为 1, 立体声为 2 */
DWORD nSamplesPerSec;     /* 指定采样频率(每秒的样本数) */
DWORD nAvgBytesPerSec;     /* 指定数据传输的传输速率(每秒的字节数) */
WORD nBlockAlign;     /* 指定块对齐块对齐是数据的最小单位 */
WORD wBitsPerSample;     /* 采样大小 */
WORD cbSize;     /* 附加信息的字节大小 */
} WAVEFORMATEX;

wFormatTag    是格式标签,几乎都是已定义好的一些常数
如:
        pcm格式是0;
        Adpcm是1;
        杜比Ac2 是30;
        等等... ...;
        其中最常用的就是PCM 和ADPCM; 
nChannels    是声道数
nSamplesPerSec    是Samples per second ,即每秒的样本数量,也就是传说中的速率、采样率。每秒有多少个样本的确可以反应“率”的概念
nAvgBytesPerSec    平均传输速率。如果是PCM的话,则该值等于nSamplesPerSec除以nBlockAlign。
nBlockAlign    数据块调整度(块对其,字节),其值为通道数*样本的数据位值/8,播放软件需要与一次处理多个该值大小的字节数据,以将其中于缓冲区调整
wBitsPerSample    每个样本的位数。表示每个声道中各个样本的数据位数。如果有多个声道,对每个声道而言样本大小都一样
cbSize    该结构(类)的大小


typedef struct waveformat_tag {
WORD wFormatTag; /* format type */
WORD nChannels; /* number of channels (i.e. mono, stereo, etc.) */
DWORD nSamplesPerSec; /* sample rate */
DWORD nAvgBytesPerSec; /* for buffer estimation */
WORD nBlockAlign; /* block size of data */
} WAVEFORMAT, *PWAVEFORMAT, NEAR *NPWAVEFORMAT, FAR *LPWAVEFORMAT;




/* wave data block header */
typedef struct wavehdr_tag {
LPSTR lpData; /* pointer to locked data buffer */
DWORD dwBufferLength; /* length of data buffer */
DWORD dwBytesRecorded; /* used for input only */
DWORD dwUser; /* for client's use */
DWORD dwFlags; /* assorted flags (see defines) */
DWORD dwLoops; /* loop control counter */
struct wavehdr_tag FAR *lpNext; /* reserved for driver */
DWORD reserved; /* reserved for driver */
} WAVEHDR, *PWAVEHDR, NEAR *NPWAVEHDR, FAR *LPWAVEHDR;


type struct
{
LPSTR lpData; /* 指向锁定的数据缓冲区的指针 */
DWORD dwBufferLength; /* 数据缓冲区的大小 */
DWORD dwByteRecorded; /* 录音时指明缓冲区中的数据量 */
DWORD dwUser; /* 用户数据 */
DWORD dwFlag; /* 提供缓冲区信息的标志 */
DWORD dwLoops; /* 循环播放的次数 */
struct wavehdr_tag *lpNext; /* 保留 */
DWORD reserved; /* 保留 */
} WAVEHDR;



typedef struct tagWAVEOUTCAPSA {
WORD wMid; /* manufacturer ID */
WORD wPid; /* product ID */
MMVERSION vDriverVersion; /* version of the driver */
CHAR szPname[MAXPNAMELEN]; /* product name (NULL terminated string) */
DWORD dwFormats; /* formats supported */
WORD wChannels; /* number of sources supported */
WORD wReserved1; /* packing */
DWORD dwSupport; /* functionality supported by driver */
} WAVEOUTCAPSA, *PWAVEOUTCAPSA, *NPWAVEOUTCAPSA, *LPWAVEOUTCAPSA;
typedef struct tagWAVEOUTCAPSW {
WORD wMid; /* manufacturer ID */
WORD wPid; /* product ID */
MMVERSION vDriverVersion; /* version of the driver */
WCHAR szPname[MAXPNAMELEN]; /* product name (NULL terminated string) */
DWORD dwFormats; /* formats supported */
WORD wChannels; /* number of sources supported */
WORD wReserved1; /* packing */
DWORD dwSupport; /* functionality supported by driver */
} WAVEOUTCAPSW, *PWAVEOUTCAPSW, *NPWAVEOUTCAPSW, *LPWAVEOUTCAPSW;


typedef struct waveoutcaps_tag {
WORD wMid; /* manufacturer ID */
WORD wPid; /* product ID */
VERSION vDriverVersion; /* version of the driver */
char szPname[MAXPNAMELEN]; /* product name (NULL terminated string) */
DWORD dwFormats; /* formats supported */
WORD wChannels; /* number of sources supported */
DWORD dwSupport; /* functionality supported by driver */
} WAVEOUTCAPS, *PWAVEOUTCAPS, NEAR *NPWAVEOUTCAPS, FAR *LPWAVEOUTCAPS;


typedef struct tagWAVEINCAPSA {
WORD wMid; /* manufacturer ID */
WORD wPid; /* product ID */
MMVERSION vDriverVersion; /* version of the driver */
CHAR szPname[MAXPNAMELEN]; /* product name (NULL terminated string) */
DWORD dwFormats; /* formats supported */
WORD wChannels; /* number of channels supported */
WORD wReserved1; /* structure packing */
} WAVEINCAPSA, *PWAVEINCAPSA, *NPWAVEINCAPSA, *LPWAVEINCAPSA;
typedef struct tagWAVEINCAPSW {
WORD wMid; /* manufacturer ID */
WORD wPid; /* product ID */
MMVERSION vDriverVersion; /* version of the driver */
WCHAR szPname[MAXPNAMELEN]; /* product name (NULL terminated string) */
DWORD dwFormats; /* formats supported */
WORD wChannels; /* number of channels supported */
WORD wReserved1; /* structure packing */
} WAVEINCAPSW, *PWAVEINCAPSW, *NPWAVEINCAPSW, *LPWAVEINCAPSW;


typedef struct waveincaps_tag {
WORD wMid; /* manufacturer ID */
WORD wPid; /* product ID */
VERSION vDriverVersion; /* version of the driver */
char szPname[MAXPNAMELEN]; /* product name (NULL terminated string) */
DWORD dwFormats; /* formats supported */
WORD wChannels; /* number of channels supported */
} WAVEINCAPS, *PWAVEINCAPS, NEAR *NPWAVEINCAPS, FAR *LPWAVEINCAPS;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值