From ac7c48b4dee99d4c772f133d70d8d1b38262fcd2 Mon Sep 17 00:00:00 2001 From: Author Name Date: Fri, 7 Jul 2023 12:20:59 +0930 Subject: shallow zip-file copy from codec2 e9d726bf20 --- misc/pre.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 misc/pre.c (limited to 'misc/pre.c') diff --git a/misc/pre.c b/misc/pre.c new file mode 100644 index 0000000..8016c3f --- /dev/null +++ b/misc/pre.c @@ -0,0 +1,59 @@ +/* + pre.c + David Rowe + Sep 26 2012 + + Takes audio from a file, pre-emphasises, and sends to output file. +*/ + +#include +#include +#include +#include +#include +#include +#include "lpc.h" + +#define N 80 + +int main(int argc, char*argv[]) { + FILE *fin, *fout; + short buf[N]; + float Sn[N], Sn_pre[N]; + float pre_mem = 0.0; + int i; + + if (argc != 3) { + printf("usage: pre InputRawSpeechFile OutputRawSpeechFile\n"); + printf("e.g pre input.raw output.raw\n"); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input speech file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[2],"wb")) == NULL ) { + fprintf(stderr, "Error opening output speech file: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + while(fread(buf, sizeof(short), N, fin) == N) { + for(i=0; i