1 #include "soundpipe.h"
2 #include "md5.h"
3 #include "tap.h"
4 #include "test.h"
5 
6 typedef struct {
7     sp_panst *panst;
8     sp_osc *osc;
9     sp_osc *lfo;
10     sp_ftbl *ft;
11 } UserData;
12 
t_panst(sp_test * tst,sp_data * sp,const char * hash)13 int t_panst(sp_test *tst, sp_data *sp, const char *hash)
14 {
15     uint32_t n;
16     int fail = 0;
17 
18     UserData ud;
19     SPFLOAT osc = 0, outL = 0, outR = 0, lfo = 0;
20 
21     sp_panst_create(&ud.panst);
22     sp_osc_create(&ud.osc);
23     sp_osc_create(&ud.lfo);
24     sp_ftbl_create(sp, &ud.ft, 2048);
25 
26     sp_panst_init(sp, ud.panst);
27     ud.panst->type = 0;
28     sp_gen_sine(sp, ud.ft);
29     sp_osc_init(sp, ud.osc, ud.ft, 0);
30     sp_osc_init(sp, ud.lfo, ud.ft, 0);
31     ud.lfo->amp = 1;
32     ud.lfo->freq = 0.5;
33 
34     sp->len = 44100 * 5;
35 
36     for(n = 0; n < tst->size; n += 2) {
37         osc = 0; outL = 0; outR = 0; lfo = 0;
38 
39         sp_osc_compute(sp, ud.osc, NULL, &osc);
40         sp_osc_compute(sp, ud.lfo, NULL, &lfo);
41         ud.panst->pan = lfo;
42 
43         sp_panst_compute(sp, ud.panst, &osc, &osc, &outL, &outR);
44         sp_test_add_sample(tst, outL);
45         sp_test_add_sample(tst, outR);
46     }
47 
48     fail = sp_test_verify(tst, hash);
49 
50     sp_panst_destroy(&ud.panst);
51     sp_ftbl_destroy(&ud.ft);
52     sp_osc_destroy(&ud.osc);
53     sp_osc_destroy(&ud.lfo);
54 
55 
56     if(fail) return SP_NOT_OK;
57     else return SP_OK;
58 }
59