关闭

一个简单的写wave文件头的c函数

标签: cwave
641人阅读 评论(0) 收藏 举报
分类:
void write_wave_head(FILE* wav_file, LPCWAVEFORMATEX pcfxFormat, int s_size){
	uint32_t size;

    fwrite("RIFF", 1, 4, wav_file);
    size = s_size+44;
    fwrite(&size, 1,  4, wav_file);
    fwrite("WAVE", 1, 4, wav_file);
    /* write fmt  subchunk */
    fwrite("fmt ", 1, 4, wav_file);
	size = 16;//sizeof(WAVEFORMATEX)
    fwrite(&size, 1,  4, wav_file);
 	fwrite(pcfxFormat, 1, 16, wav_file);
    /* write data subchunk */
    fwrite("data", 1, 4, wav_file);
	size = s_size;
    fwrite(&size, 1,  4, wav_file);
}
用法:
///seek to begin, rewrite wave head
fseek(file_wave, 0, SEEK_SET);
write_wave_head(file_wave, &wfx, buffer_size);
/// seek to end, write new wave data
fseek(file_wave, 0, SEEK_END);
fwrite(wavebuffer, buffer_size, 1, file_wave);

wave文件头图解:


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:76742次
    • 积分:1044
    • 等级:
    • 排名:千里之外
    • 原创:26篇
    • 转载:1篇
    • 译文:1篇
    • 评论:23条
    文章分类
    最新评论