genres does 1st order LPC equalisation, added stdin option to c2sim
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 12 Apr 2015 02:31:09 +0000 (02:31 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 12 Apr 2015 02:31:09 +0000 (02:31 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2115 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/c2sim.c
codec2-dev/unittest/genres.c

index c80f9646a098c24c7a7b0ca58f5416d36a0a567d..b653b203b00315af34ee8bae7795e67592472282 100644 (file)
@@ -333,7 +333,8 @@ int main(int argc, char *argv[])
 
     /* Input file */
 
-     if ((fin = fopen(argv[optind],"rb")) == NULL) {
+    if (strcmp(argv[optind], "-")  == 0) fin = stdin;
+    else if ((fin = fopen(argv[optind],"rb")) == NULL) {
        fprintf(stderr, "Error opening input speech file: %s: %s.\n",
                argv[optind], strerror(errno));
        exit(1);
index bd2e73c0b676708513d93e7eee1ef29d4746a222..8777d3324c32d4218fa13dcfefebce2e017c5273 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <lpc.h>
 
 #define N 160
@@ -74,6 +75,8 @@ int main(int argc, char *argv[])
 
   while( (fread(buf,sizeof(short),N,fin)) == N) {
     frames++;
+    for(i=0; i<P; i++)
+      Sn[i] = Sn[i+N];
     for(i=0; i<N; i++)
       Sn[P+i] = (float)buf[i];
 
@@ -85,10 +88,8 @@ int main(int argc, char *argv[])
       buf[i] = (short)res[i];
     fwrite(buf,sizeof(short),N,fres);
 
-    /* update filter memory */
-
-    for(i=0; i<P; i++)
-        Sn[i] = Sn[i+N]; 
+    if (fres == stdout) fflush(stdout);
+    if (fin == stdin) fflush(stdin);
   }
 
   fclose(fin);