~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.1.0/third_party/speex/libspeex/testecho.c

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef HAVE_CONFIG_H
 
2
#include "config.h"
 
3
#endif
 
4
 
 
5
#include <stdio.h>
 
6
#include <stdlib.h>
 
7
#include <sys/types.h>
 
8
#include <sys/stat.h>
 
9
#include <fcntl.h>
 
10
#include "speex/speex_echo.h"
 
11
#include "speex/speex_preprocess.h"
 
12
 
 
13
 
 
14
#define NN 128
 
15
#define TAIL 1024
 
16
 
 
17
int main(int argc, char **argv)
 
18
{
 
19
   FILE *echo_fd, *ref_fd, *e_fd;
 
20
   short echo_buf[NN], ref_buf[NN], e_buf[NN];
 
21
   SpeexEchoState *st;
 
22
   SpeexPreprocessState *den;
 
23
   int sampleRate = 8000;
 
24
 
 
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 = fopen(argv[2], "rb");
 
31
   ref_fd  = fopen(argv[1],  "rb");
 
32
   e_fd    = fopen(argv[3], "wb");
 
33
 
 
34
   st = speex_echo_state_init(NN, TAIL);
 
35
   den = speex_preprocess_state_init(NN, sampleRate);
 
36
   speex_echo_ctl(st, SPEEX_ECHO_SET_SAMPLING_RATE, &sampleRate);
 
37
   speex_preprocess_ctl(den, SPEEX_PREPROCESS_SET_ECHO_STATE, st);
 
38
 
 
39
   while (!feof(ref_fd) && !feof(echo_fd))
 
40
   {
 
41
      fread(ref_buf, sizeof(short), NN, ref_fd);
 
42
      fread(echo_buf, sizeof(short), NN, echo_fd);
 
43
      speex_echo_cancellation(st, ref_buf, echo_buf, e_buf);
 
44
      speex_preprocess_run(den, e_buf);
 
45
      fwrite(e_buf, sizeof(short), NN, e_fd);
 
46
   }
 
47
   speex_echo_state_destroy(st);
 
48
   speex_preprocess_state_destroy(den);
 
49
   fclose(e_fd);
 
50
   fclose(echo_fd);
 
51
   fclose(ref_fd);
 
52
   return 0;
 
53
}