当前位置: 技术问答>linux和unix
linux 如何录音保存为.wav文件-百分求救
来源: 互联网 发布时间:2016-01-27
本文导语: 如题 ,希望能给出一个参考代码 比如说.wav的文件头需要自己去写吗???? | 文件头要自己写.刚好有源程序: char magic[]={0x52,0x49,0x46,0x46}; char middle[]={0x57,0x41,0x56,0x45,0x66,0x6D,0x74,0x20, 0x10,0x00,0x00,0...
如题 ,希望能给出一个参考代码
比如说.wav的文件头需要自己去写吗????
比如说.wav的文件头需要自己去写吗????
|
文件头要自己写.刚好有源程序:
char magic[]={0x52,0x49,0x46,0x46};
char middle[]={0x57,0x41,0x56,0x45,0x66,0x6D,0x74,0x20,
0x10,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
0x44,0xAC,0x00,0x00,0x10,0xB1,0x02,0x00,
0x04,0x00,0x10,0x00,0x64,0x61,0x74,0x61};
void write_wavheader(int fd,int data_len)
{
int tmp;
write(fd,magic,4);
tmp=data_len+36;
write(fd,(char*)&tmp,4);
write(fd,middle,32);
tmp=data_len;
write(fd,(char*)&tmp,4);
}
可作参考.
char magic[]={0x52,0x49,0x46,0x46};
char middle[]={0x57,0x41,0x56,0x45,0x66,0x6D,0x74,0x20,
0x10,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
0x44,0xAC,0x00,0x00,0x10,0xB1,0x02,0x00,
0x04,0x00,0x10,0x00,0x64,0x61,0x74,0x61};
void write_wavheader(int fd,int data_len)
{
int tmp;
write(fd,magic,4);
tmp=data_len+36;
write(fd,(char*)&tmp,4);
write(fd,middle,32);
tmp=data_len;
write(fd,(char*)&tmp,4);
}
可作参考.