aboutsummaryrefslogtreecommitdiff
path: root/unittest/tquisk_filter.c
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2025-07-25 10:17:14 +0300
committerMarin Ivanov <[email protected]>2026-01-18 20:09:26 +0200
commit0168586485e6310c598713c911b1dec5618d61a1 (patch)
tree6aabc2a12ef8fef70683f5389bea00f948015f77 /unittest/tquisk_filter.c
Initial commitHEADmaster
* codec2 cut-down version 1.2.0 * Remove codebook and generation of sources * remove c2dec c2enc binaries * prepare for emscripten
Diffstat (limited to 'unittest/tquisk_filter.c')
-rw-r--r--unittest/tquisk_filter.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/unittest/tquisk_filter.c b/unittest/tquisk_filter.c
new file mode 100644
index 0000000..1879dff
--- /dev/null
+++ b/unittest/tquisk_filter.c
@@ -0,0 +1,46 @@
+/*
+ tquisk_filter.c
+
+ Unit test for complex band pass filters in src/filter.c
+
+ cd codec2/build_linux
+ ./misc/mksine - 1500 2 | unittest/tquisk_filter | aplay
+
+ By adjusting the frequency you can audibly test filter response.
+*/
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "filter.h"
+#include "filter_coef.h"
+
+#define N 159 /* processing buffer size (odd number deliberate) */
+#define CENTRE 1500.0
+#define FS 8000.0
+
+int main() {
+ short buf_short[N];
+ complex float buf[N];
+ struct quisk_cfFilter *bpf;
+ int i;
+
+ bpf = malloc(sizeof(struct quisk_cfFilter));
+ assert(bpf != NULL);
+ quisk_filt_cfInit(bpf, filtP200S400, sizeof(filtP200S400) / sizeof(float));
+ quisk_cfTune(bpf, CENTRE / FS);
+
+ while (fread(buf_short, sizeof(short), N, stdin) == N) {
+ for (i = 0; i < N; i++) buf[i] = buf_short[i];
+ quisk_ccfFilter(buf, buf, N, bpf);
+ /* we only output the real part in this test */
+ for (i = 0; i < N; i++) buf_short[i] = creal(buf[i]);
+ fwrite(buf_short, sizeof(short), N, stdout);
+ }
+
+ quisk_filt_destroy(bpf);
+ free(bpf);
+ return 0;
+}