/* 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);
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <lpc.h>
#define N 160
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];
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);