diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2023-12-12 23:17:35 +0100 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2023-12-12 23:17:35 +0100 |
commit | 0f08bc5487adffde5f3e0aff30ffe41b53a21bf1 (patch) | |
tree | dce92f6daa256f17d8e292e1578605af2f2218f9 /lib/tests/ut.c | |
parent | 93a9691246574b6d51ddbbdb5be3dceb89ff24e9 (diff) | |
download | libfshift-main.tar.gz |
- f must be divisors of 44100 and be positive
- 44100 hardcoded
Diffstat (limited to 'lib/tests/ut.c')
-rw-r--r-- | lib/tests/ut.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/lib/tests/ut.c b/lib/tests/ut.c new file mode 100644 index 0000000..78f05ab --- /dev/null +++ b/lib/tests/ut.c @@ -0,0 +1,75 @@ +#include "fct.h" + +#include <stdio.h> +#include <libfshift.h> + +//////////////////////////////////////////////////////////////////////////////// +/* +static float* create_chirp(int sz) +{ + int i = 0; + float* buf = malloc(sizeof(float) * sz); + static int done = 0; + for(i = 0; i < sz; i++) { + float t = i; + buf[i] = sinf((t + t * t * 0.5 / 2.0) * 2.0 * M_PI/(float)sz); + } + return buf; +} +*/ + +static void create_sin(float* p, int sz) +{ + int i; + for (i = 0; i < sz; i++) { + *(p + i) = sinf((float)i * 32 * M_PI / (float)sz); + } +} + +//////////////////////////////////////////////////////////////////////////////// + +FCT_BGN() +{ +FCT_SUITE_BGN(fshift) +{ + FCT_TEST_BGN(ctx-create-free) + { + fshift_ctx_t ctx = fshift_create_ctx(1.0, 8); + fshift_free_ctx(ctx); + } + FCT_TEST_END(); +/* + FCT_TEST_BGN(zero-one-frame) + { + fshift_ctx_t ctx = fshift_create_ctx(1.0, 8, NULL); + static float data_in[256]; + for (int i = 0; i < 256; i++) + data_in[i] = 1; + float data_out[512]; + fshift_run(ctx, data_in, data_out); + fshift_run(ctx, data_in, data_out + 256); + fshift_free_ctx(ctx); + } + FCT_TEST_END(); +*/ + FCT_TEST_BGN(sin) + { + fshift_ctx_t ctx = fshift_create_ctx(1.0, 11); + float data_in[4096]; + create_sin(data_in, 4096); + float data_out1[4096]; + float data_out2[4096]; + fshift_run(ctx, data_in, data_out1, data_out2); + fshift_run(ctx, data_in + 2048, data_out1, data_out2); + fshift_run(ctx, data_in, data_out1 + 2048, data_out2 + 2048); + for (int i = 0; i < 2048; i++) { + fprintf(stderr, "%d <> %f = %f %f\n", i, data_in[i], data_out1[i], data_out2[i]); + } + fshift_free_ctx(ctx); + + } + FCT_TEST_END(); +} +FCT_SUITE_END(); +} +FCT_END(); |