From: drowe67 Date: Sun, 22 Jun 2014 03:30:44 +0000 (+0000) Subject: speex noise supressor test program X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=a9e5ebda9902d78c29714aed9459dfbc632bb6b5;p=freetel-svn-tracking.git speex noise supressor test program git-svn-id: https://svn.code.sf.net/p/freetel/code@1703 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/unittest/CMakeLists.txt b/codec2-dev/unittest/CMakeLists.txt index fac25f93..00b17f80 100644 --- a/codec2-dev/unittest/CMakeLists.txt +++ b/codec2-dev/unittest/CMakeLists.txt @@ -75,8 +75,8 @@ target_link_libraries(de codec2) add_executable(tfifo tfifo.c ../src/fifo.c) target_link_libraries(tfifo codec2 ${CMAKE_THREAD_LIBS_INIT}) -add_executable(raw2h raw2h.c) -target_link_libraries(raw2h codec2) +add_executable(speexnoisesup speexnoisesup.c) +target_link_libraries(speexnoisesup speexdsp) add_definitions(-D__UNITTEST__) add_executable(c2validate c2validate.c) diff --git a/codec2-dev/unittest/speexnoisesup.c b/codec2-dev/unittest/speexnoisesup.c new file mode 100644 index 00000000..9ee7095d --- /dev/null +++ b/codec2-dev/unittest/speexnoisesup.c @@ -0,0 +1,58 @@ +/*----------------------------------------------------------------------------*\ + + FILE....: speexnoisesup.c + AUTHOR..: David Rowe + CREATED.: Sun 22 June 2014 + + File I/O based test program for Speex pre-processor, used for + initial testing of Speech noise supression. + +\*----------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +#define N 80 +#define FS 8000 + +int main(int argc, char *argv[]) { + FILE *fin, *fout; + short buf[N]; + SpeexPreprocessState *st; + + if (argc < 2) { + printf("usage: %s InFile OutFile\n", argv[0]); + exit(0); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening %s\n", argv[1]); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fout = stdout; + else if ((fout = fopen(argv[2],"wb")) == NULL) { + fprintf(stderr, "Error opening %s\n", argv[2]); + exit(1); + } + + st = speex_preprocess_state_init(N, FS); + + while(fread(buf, sizeof(short), N, fin) == N) { + speex_preprocess_run(st, buf); + fwrite(buf, sizeof(short), N, fout); + if (fin == stdin) fflush(stdin); + if (fout == stdout) fflush(stdout); + } + + speex_preprocess_state_destroy(st); + + fclose(fin); + fclose(fout); + + return 0; +}