aboutsummaryrefslogtreecommitdiff
path: root/misc/16_8_short.c
diff options
context:
space:
mode:
authorAuthor Name <[email protected]>2023-07-07 12:20:59 +0930
committerDavid Rowe <[email protected]>2023-07-07 12:29:06 +0930
commitac7c48b4dee99d4c772f133d70d8d1b38262fcd2 (patch)
treea2d0ace57a9c0e2e5b611c4987f6fed1b38b81e7 /misc/16_8_short.c
shallow zip-file copy from codec2 e9d726bf20
Diffstat (limited to 'misc/16_8_short.c')
-rw-r--r--misc/16_8_short.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/misc/16_8_short.c b/misc/16_8_short.c
new file mode 100644
index 0000000..a23722c
--- /dev/null
+++ b/misc/16_8_short.c
@@ -0,0 +1,47 @@
+/*
+ 16_8_short.c
+ David Rowe
+ October 2018
+
+ Utility for resampling raw files from 16 to 8 kHz.
+*/
+
+#include <assert.h>
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "codec2_fdmdv.h"
+
+#define N8 160 /* procssing buffer size at 8 kHz */
+#define N16 (N8*FDMDV_OS)
+
+int main(int argc, char *argv[]) {
+ short in16k_short[FDMDV_OS_TAPS_16K + N16];
+ FILE *f16;
+ short out8k_short[N16];
+ FILE *f8;
+ int i;
+
+ if (argc != 3) {
+ fprintf(stderr, "usage: %s 16kHz.raw 8kHz.raw\n", argv[0]);
+ exit(1);
+ }
+ f16 = fopen(argv[1], "rb");
+ assert(f16 != NULL);
+ f8 = fopen(argv[2], "wb");
+ assert(f8 != NULL);
+
+ /* clear filter memories */
+
+ for(i=0; i<FDMDV_OS_TAPS_16K; i++)
+ in16k_short[i] = 0;
+
+ while(fread(&in16k_short[FDMDV_OS_TAPS_16K], sizeof(short), N16, f16) == N16) {
+ fdmdv_16_to_8_short(out8k_short, &in16k_short[FDMDV_OS_TAPS_16K], N8);
+ fwrite(out8k_short, sizeof(short), N8, f8);
+ }
+
+ fclose(f16);
+ fclose(f8);
+ return 0;
+}