diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2008-06-10 14:09:37 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2008-06-10 14:09:37 +0000 |
commit | beaa7b7491e6deccd6c49abc375702e23aa4324a (patch) | |
tree | 9ebf2d154e6c5d7bfc61222a60731d59deb2e89e /third_party/speex/libspeex/testecho.c | |
parent | 60ce2ec8b88876b89c408ef7b78a4641d1162148 (diff) |
Upgraded Speex version to the latest and reorganized it in local copy (since Speex is now using Git)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2002 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'third_party/speex/libspeex/testecho.c')
-rw-r--r-- | third_party/speex/libspeex/testecho.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/third_party/speex/libspeex/testecho.c b/third_party/speex/libspeex/testecho.c new file mode 100644 index 00000000..5ae855f0 --- /dev/null +++ b/third_party/speex/libspeex/testecho.c @@ -0,0 +1,53 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include "speex/speex_echo.h" +#include "speex/speex_preprocess.h" + + +#define NN 128 +#define TAIL 1024 + +int main(int argc, char **argv) +{ + FILE *echo_fd, *ref_fd, *e_fd; + short echo_buf[NN], ref_buf[NN], e_buf[NN]; + SpeexEchoState *st; + SpeexPreprocessState *den; + int sampleRate = 8000; + + if (argc != 4) + { + fprintf(stderr, "testecho mic_signal.sw speaker_signal.sw output.sw\n"); + exit(1); + } + echo_fd = fopen(argv[2], "rb"); + ref_fd = fopen(argv[1], "rb"); + e_fd = fopen(argv[3], "wb"); + + st = speex_echo_state_init(NN, TAIL); + den = speex_preprocess_state_init(NN, sampleRate); + speex_echo_ctl(st, SPEEX_ECHO_SET_SAMPLING_RATE, &sampleRate); + speex_preprocess_ctl(den, SPEEX_PREPROCESS_SET_ECHO_STATE, st); + + while (!feof(ref_fd) && !feof(echo_fd)) + { + fread(ref_buf, sizeof(short), NN, ref_fd); + fread(echo_buf, sizeof(short), NN, echo_fd); + speex_echo_cancellation(st, ref_buf, echo_buf, e_buf); + speex_preprocess_run(den, e_buf); + fwrite(e_buf, sizeof(short), NN, e_fd); + } + speex_echo_state_destroy(st); + speex_preprocess_state_destroy(den); + fclose(e_fd); + fclose(echo_fd); + fclose(ref_fd); + return 0; +} |