speex noise supressor test program
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 22 Jun 2014 03:30:44 +0000 (03:30 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 22 Jun 2014 03:30:44 +0000 (03:30 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1703 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/unittest/CMakeLists.txt
codec2-dev/unittest/speexnoisesup.c [new file with mode: 0644]

index fac25f93a2fd75084f3fe0ef53388d18ec2be0de..00b17f8040713a479bef7829e5e048d482bcbea5 100644 (file)
@@ -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 (file)
index 0000000..9ee7095
--- /dev/null
@@ -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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <speex/speex_preprocess.h>
+
+#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;
+}