~ubuntu-branches/ubuntu/gutsy/speex/gutsy-security

« back to all changes in this revision

Viewing changes to libspeex/testecho.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2005-12-07 23:22:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051207232221-nme7vf9m182p7dpe
Tags: 1.1.11.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#include "config.h"
3
3
#endif
4
4
 
5
 
#include <speex/speex_echo.h>
6
5
#include <stdio.h>
7
6
#include <stdlib.h>
8
7
#include <sys/types.h>
9
8
#include <sys/stat.h>
10
9
#include <fcntl.h>
11
10
#include <unistd.h>
12
 
#include <speex/speex_preprocess.h>
 
11
#include "speex/speex_echo.h"
 
12
#include "speex/speex_preprocess.h"
 
13
 
13
14
 
14
15
#define NN 160
15
16
 
16
 
int main()
 
17
int main(int argc, char **argv)
17
18
{
18
 
   int i;
19
19
   int echo_fd, ref_fd, e_fd;
20
 
   float echo[NN], ref[NN], e[NN];
21
 
   short noise[NN];
 
20
   float noise[NN+1];
22
21
   short echo_buf[NN], ref_buf[NN], e_buf[NN];
23
22
   SpeexEchoState *st;
24
23
   SpeexPreprocessState *den;
25
24
 
26
 
   echo_fd = open ("play.sw", O_RDONLY);
27
 
   ref_fd  = open ("rec.sw",  O_RDONLY);
28
 
   e_fd    = open ("echo.sw", O_WRONLY | O_CREAT | O_TRUNC, 0644);
 
25
   if (argc != 4)
 
26
   {
 
27
      fprintf (stderr, "testecho mic_signal.sw speaker_signal.sw output.sw\n");
 
28
      exit(1);
 
29
   }
 
30
   echo_fd = open (argv[2], O_RDONLY);
 
31
   ref_fd  = open (argv[1],  O_RDONLY);
 
32
   e_fd    = open (argv[3], O_WRONLY | O_CREAT | O_TRUNC, 0644);
29
33
 
30
34
   st = speex_echo_state_init(NN, 8*NN);
31
35
   den = speex_preprocess_state_init(NN, 8000);
33
37
   while (read(ref_fd, ref_buf, NN*2))
34
38
   {
35
39
      read(echo_fd, echo_buf, NN*2);
36
 
/*
37
 
      for (i=0;i<NN;i++)
38
 
         ref[i] = ref_buf[i];
39
 
      
40
 
      for (i=0;i<NN;i++)
41
 
         echo[i] = echo_buf[i];
42
 
*/
43
 
      speex_echo_cancel(st, ref_buf, echo_buf, e_buf, NULL);
44
 
      /*speex_denoise(den, e, noise);*/
45
 
      
46
 
 /*     for (i=0;i<NN;i++)
47
 
         e_buf[i] = e[i];
48
 
*/
 
40
      speex_echo_cancel(st, ref_buf, echo_buf, e_buf, noise);
 
41
      /*speex_preprocess(den, e_buf, noise);*/
49
42
      write(e_fd, e_buf, NN*2);
50
 
#if 0
51
 
      for (i=0;i<NN;i++)
52
 
         printf ("%f\n", e[i]);
53
 
#endif
54
43
   }
55
 
#if 0
56
 
   for (i=0;i<st->window_size;i++)
57
 
      printf ("%f\n", st->W[i]);
58
 
#endif
59
44
   speex_echo_state_destroy(st);
60
45
   speex_preprocess_state_destroy(den);
61
46
   close(e_fd);