1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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();
|