pcm写入wav文件

typedef struct {
    FOURCC  ckid;
    DWORD   cksize;
    FOURCC  fccType;
    FOURCC  fmt;
    DWORD   nFmtSize;
    WORD    wFormatTag;
    WORD    nChannels;
    DWORD   nSamplesPerSec;
    DWORD   nAvgBytesPerSec;
    WORD    nBlockAlign;
    WORD    wBitsPerSample;
    FOURCC  data;
    DWORD   nDataSize;

} wave_header;


void create_wave_file()

{

       ...

        wave_header hdr;

  hdr.ckid = mmioFOURCC('R', 'I', 'F', 'F');
        hdr.cksize = datasize + 36;
        hdr.fccType = mmioFOURCC('W', 'A', 'V', 'E');
        hdr.fmt = mmioFOURCC('f', 'm', 't', ' ');
        hdr.nFmtSize = 16;
        hdr.wFormatTag = WAVE_FORMAT_PCM;
        hdr.nChannels = 1;
        hdr.nSamplesPerSec = 8000;
        hdr.nAvgBytesPerSec = 16000;
        hdr.nBlockAlign = 2;
        hdr.wBitsPerSample = 16;
        hdr.data = mmioFOURCC('d', 'a', 't', 'a');
        hdr.nDataSize = datasize;

       fwrite(&hdr, 1, sizeof(wave_header), file);

}


你可能感兴趣的:(流媒体)