comparison intercom/testdenoise.c @ 2:13be24d74cd2

import intercom-0.4.1
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 09:57:52 +0200
parents
children
comparison
equal deleted inserted replaced
1:9cadc470e3da 2:13be24d74cd2
1 /* testdenoise.c
2 * Jean-Marc Valin, www.speex.org
3 * Changes Andre Adrian
4 *
5
6 cc -O2 -o testdenoise testdenoise.c -lm -lspeex
7
8 */
9
10
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14
15 #include <speex/speex_preprocess.h>
16 #include <stdio.h>
17
18 #define NN 160
19
20 typedef signed short MONO;
21
22 typedef struct {
23 signed short l;
24 signed short r;
25 } STEREO;
26
27 int main()
28 {
29 STEREO in[NN];
30 MONO inm[NN];
31 int i;
32 SpeexPreprocessState *st;
33 int count=0;
34 float f;
35
36 st = speex_preprocess_state_init(NN, 8000);
37 i=1;
38 speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DENOISE, &i);
39 i=0;
40 speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC, &i);
41 f=8000;
42 speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC_LEVEL, &f);
43 i=0;
44 speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB, &i);
45 f=.4;
46 speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f);
47 f=.3;
48 speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
49 while (1)
50 {
51 int vad;
52 fread(in, sizeof(STEREO), NN, stdin);
53 for (i = 0; i < NN; ++i) {
54 inm[i] = in[i].l;
55 }
56
57 if (feof(stdin))
58 break;
59 vad = speex_preprocess(st, inm, NULL);
60 /*fprintf (stderr, "%d\n", vad);*/
61 for (i = 0; i < NN; ++i) {
62 in[i].l = inm[i];
63 }
64 fwrite(in, sizeof(STEREO), NN, stdout);
65 count++;
66 }
67 speex_preprocess_state_destroy(st);
68 return 0;
69 }

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.