wav文件提取出pcm数据
2014-10-21 14:25
274 查看
/*******************************************************************************************************
文件功能:wav文件中提取pcm数据
作者:HFL
日期:2014-1-12
说明:wav文件就是在pcm数据的基础上加了一文件头。文件头的大小为44个字节(没有附件字段的情况,如果有附加字段问46个字节)
,剔除文件头,就是纯pcm采样过来的数据。
pcm构成要素:采样率 ,声道个数,数据符号特性(一般8位都是无符号的)
********************************************************************************************************/
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *infile, *outfile;
char *buf = NULL;
long length;
if((infile = fopen ("e:\\1.wav", "rb+"))==NULL)
{
printf("Open the 1.wav failed\n");
return ;
}
else
{
printf("Open the 1.wav success\n");
}
if((outfile = fopen ("e:\\2.pcm", "wb"))==NULL)
{
printf("Open the 2.pcm failed\n");
return ;
}
else
{
printf("Open the 2.pcm success\n");
}
/*获取文件的长度*/
fseek(infile,0,SEEK_END);
length=ftell(infile);
buf = (char*)malloc(length-43);/*文件数据段长度等于文件总长度-文件头长度位置*/
fwrite(buf,1,length-44,outfile);/*文件数据段长度为a-44,但指针是指向前一个指针*/
free( buf );
fclose(infile);
fclose(outfile);
}
文件功能:wav文件中提取pcm数据
作者:HFL
日期:2014-1-12
说明:wav文件就是在pcm数据的基础上加了一文件头。文件头的大小为44个字节(没有附件字段的情况,如果有附加字段问46个字节)
,剔除文件头,就是纯pcm采样过来的数据。
pcm构成要素:采样率 ,声道个数,数据符号特性(一般8位都是无符号的)
********************************************************************************************************/
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *infile, *outfile;
char *buf = NULL;
long length;
if((infile = fopen ("e:\\1.wav", "rb+"))==NULL)
{
printf("Open the 1.wav failed\n");
return ;
}
else
{
printf("Open the 1.wav success\n");
}
if((outfile = fopen ("e:\\2.pcm", "wb"))==NULL)
{
printf("Open the 2.pcm failed\n");
return ;
}
else
{
printf("Open the 2.pcm success\n");
}
/*获取文件的长度*/
fseek(infile,0,SEEK_END);
length=ftell(infile);
buf = (char*)malloc(length-43);/*文件数据段长度等于文件总长度-文件头长度位置*/
fwrite(buf,1,length-44,outfile);/*文件数据段长度为a-44,但指针是指向前一个指针*/
free( buf );
fclose(infile);
fclose(outfile);
}
相关文章推荐
- wav文件提取出pcm数据
- 嵌入式 wave文件(*.wav)格式、PCM数据格式收藏
- PCM数据合成WAV文件
- wave文件(*.wav)格式、PCM数据格式
- wave文件(*.wav)格式、PCM数据格式
- wave文件(*.wav)格式、PCM数据格式
- PCM数据转WAV文件
- wave文件(*.wav)格式、PCM数据格式
- wave文件(*.wav)格式、PCM数据格式, goldwave 可以播放pcm raw audio
- wave文件(*.wav)格式、PCM数据格式
- 音频数据文件格式(PCM,WAV,MIDI)简记
- C读取DAT,提取AD数据,转成WAV文件
- wave文件(*.wav)格式、PCM数据格式
- wave文件(*.wav)格式、PCM数据格式
- 怎样从wav文件中提取记录频率的数据
- pcm数据生成wav文件
- [FFMPEG-2]最想实现的第一点一个功能-从mp3中提取pcm数据,重采样和加wav头
- wave文件(*.wav)格式、PCM数据格式
- C#WAV音频文件转化PCM数据文件PCM转化WAV音频
- PCM数据合成WAV文件