diff options
author | Dan Everton <dan@iocaine.org> | 2007-02-10 11:44:26 +0000 |
---|---|---|
committer | Dan Everton <dan@iocaine.org> | 2007-02-10 11:44:26 +0000 |
commit | 7bf62e8da66ca8ff0acc2702f92ea4fe06eb94b1 (patch) | |
tree | c9db4558a73ae3094839c4655fa0b8ebc2231c56 /apps/codecs/libspeex/testecho.c | |
parent | 51587512635a8b19e6a5f19a20074d0d4d1f17da (diff) |
* Sync Speex codec with Speex SVN revision 12449 (roughly Speex 1.2beta1).
* Redo the changes required to make Speex compile in Rockbox. Should be a bit easier to keep in sync with Speex SVN now.
* Fix name of Speex library in codecs Makefile.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12254 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libspeex/testecho.c')
-rw-r--r-- | apps/codecs/libspeex/testecho.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/apps/codecs/libspeex/testecho.c b/apps/codecs/libspeex/testecho.c new file mode 100644 index 0000000000..7c32c8f60e --- /dev/null +++ b/apps/codecs/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 <unistd.h> +#include "speex/speex_echo.h" +#include "speex/speex_preprocess.h" + + +#define NN 128 +#define TAIL 1024 + +int main(int argc, char **argv) +{ + int echo_fd, ref_fd, e_fd; + short echo_buf[NN], ref_buf[NN], e_buf[NN]; + SpeexEchoState *st; + SpeexPreprocessState *den; + + if (argc != 4) + { + fprintf (stderr, "testecho mic_signal.sw speaker_signal.sw output.sw\n"); + exit(1); + } + echo_fd = open (argv[2], O_RDONLY); + ref_fd = open (argv[1], O_RDONLY); + e_fd = open (argv[3], O_WRONLY | O_CREAT | O_TRUNC, 0644); + + st = speex_echo_state_init(NN, TAIL); + den = speex_preprocess_state_init(NN, 8000); + int tmp = 8000; + speex_echo_ctl(st, SPEEX_ECHO_SET_SAMPLING_RATE, &tmp); + speex_preprocess_ctl(den, SPEEX_PREPROCESS_SET_ECHO_STATE, st); + + while (read(ref_fd, ref_buf, NN*2)) + { + read(echo_fd, echo_buf, NN*2); + speex_echo_cancellation(st, ref_buf, echo_buf, e_buf); + speex_preprocess_run(den, e_buf); + write(e_fd, e_buf, NN*2); + } + speex_echo_state_destroy(st); + speex_preprocess_state_destroy(den); + close(e_fd); + close(echo_fd); + close(ref_fd); + return 0; +} |