下载 libspeexdsp
PC上,编译。修改内置demo
输入in.pcm ,输出out.pcm, 用音频分析软件及实测效果OK.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "speex/speex_preprocess.h"
#include <stdio.h>
#define NN 160
int main()
{
short in[NN];
int i;
SpeexPreprocessState *st;
int count=0;
float f;
unsigned long flen=0;
FILE *infile = fopen("in.pcm", "rb");
FILE *outfile = fopen("out.pcm", "wb");
fseek(infile,0L,SEEK_END);
flen = ftell(infile);
printf("file size=%ld\n",flen);
fseek(infile,0L,SEEK_SET);
st = speex_preprocess_state_init(NN, 8000);
i=1;
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DENOISE, &i);
i=0;
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC, &i);
i=8000;
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC_LEVEL, &i);
i=0;
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB, &i);
f=.0;
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f);
f=.0;
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
while (1)
{
int vad;
fread(in, sizeof(short), NN, infile);
if (feof(infile))
break;
vad = speex_preprocess_run(st, in);
/*fprintf (stderr, "%d\n", vad);*/
fwrite(in, sizeof(short), NN, outfile);
count++;
}
printf("count=%d\n",count);
speex_preprocess_state_destroy(st);
fclose(infile);
fclose(outfile);
return 0;
}