//根据要求填充,ACM波形.wav格式的文件头
#pragma pack(push,1)
typedef struct tagPcmWaveHeader
{
unsigned char riff[4];
unsigned long file_length;
unsigned char wave[4];
unsigned char fmt[4];
unsigned long format_length;
short wFormatTag;
short nChannels;
unsigned long nSamplesPerSec;
unsigned long nAvgBytesPerSec;
short nBlockAlign;
short wBitsPerSample;
unsigned char data[4];
unsigned long data_length;
}PCM_WAVE_HEADER,*PPCM_WAVE_HEADER;
#pragma pack(pop)
void FillAcmWavHeader(PPCM_WAVE_HEADER header,unsigned long length,
unsigned short _nChannelsRes,unsigned long _nSamplesPerSecRes,short _wBitsPerSampleRes)
{
strncpy((char*)header->riff, "RIFF", 4);
header->file_length = sizeof(PCM_WAVE_HEADER) + length - 8;
strncpy((char*)header->wave, "WAVE", 4);
strncpy((char*)header->fmt, "fmt ", 4);
header->format_length = 16;
header->wFormatTag = 1;
header->nChannels = _nChannelsRes;
header->nSamplesPerSec = _nSamplesPerSecRes;
header->wBitsPerSample = _wBitsPerSampleRes;
header->nBlockAlign = header->nChannels * header->wBitsPerSample / 8;
header->nAvgBytesPerSec = header->nSamplesPerSec * header->nBlockAlign;
strncpy((char*)header->data, "data", 4);
header->data_length = length;
}