diff options
| author | Author Name <[email protected]> | 2023-07-07 12:20:59 +0930 |
|---|---|---|
| committer | David Rowe <[email protected]> | 2023-07-07 12:29:06 +0930 |
| commit | ac7c48b4dee99d4c772f133d70d8d1b38262fcd2 (patch) | |
| tree | a2d0ace57a9c0e2e5b611c4987f6fed1b38b81e7 /misc/speexnoisesup.c | |
shallow zip-file copy from codec2 e9d726bf20
Diffstat (limited to 'misc/speexnoisesup.c')
| -rw-r--r-- | misc/speexnoisesup.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/misc/speexnoisesup.c b/misc/speexnoisesup.c new file mode 100644 index 0000000..7328235 --- /dev/null +++ b/misc/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 suppression. + +\*----------------------------------------------------------------------------*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <stdint.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 (fout == stdout) fflush(stdout); + } + + speex_preprocess_state_destroy(st); + + fclose(fin); + fclose(fout); + + return 0; +} |
