10 #include "speex/speex_echo.h"
11 #include "speex/speex_preprocess.h"
17 int main(int argc, char **argv)
19 FILE *echo_fd, *ref_fd, *e_fd;
20 short echo_buf[NN], ref_buf[NN], e_buf[NN];
22 SpeexPreprocessState *den;
23 int sampleRate = 8000;
27 fprintf(stderr, "testecho mic_signal.sw speaker_signal.sw output.sw\n");
30 echo_fd = fopen(argv[2], "rb");
31 ref_fd = fopen(argv[1], "rb");
32 e_fd = fopen(argv[3], "wb");
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);
39 while (!feof(ref_fd) && !feof(echo_fd))
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);
47 speex_echo_state_destroy(st);
48 speex_preprocess_state_destroy(den);