void process(sp_data *sp, void *udata) { UserData *ud = udata; SPFLOAT osc = 0, outL = 0, outR = 0, lfo = 0; sp_osc_compute(sp, ud->osc, NULL, &osc); sp_osc_compute(sp, ud->lfo, NULL, &lfo); ud->pan2->pan = lfo; sp_pan2_compute(sp, ud->pan2, &osc, &outL, &outR); sp_out(sp, 0, outL); sp_out(sp, 1, outR); }
int t_blsaw(sp_test *tst, sp_data *sp, const char *hash) { uint32_t n; int fail = 0; SPFLOAT blsaw; sp_blsaw *blsaw_d; sp_blsaw_create(&blsaw_d); sp_blsaw_init(sp, blsaw_d); *blsaw_d->freq = 500; sp->len = 44100 * 5; for(n = 0; n < tst->size; n++) { blsaw = 0; sp_blsaw_compute(sp, blsaw_d, NULL, &blsaw); sp_out(sp, 0, blsaw); sp_test_add_sample(tst, sp->out[0]); } fail = sp_test_verify(tst, hash); sp_blsaw_destroy(&blsaw_d); if(fail) return SP_NOT_OK; else return SP_OK; }
int t_osc(sp_test *tst, sp_data *sp, const char *hash) { uint32_t n; int fail = 0; SPFLOAT osc; sp_osc *osc_d; sp_ftbl *ft_d; sp_ftbl_create(sp, &ft_d, 2048); sp_osc_create(&osc_d); sp_gen_sine(sp, ft_d); sp_osc_init(sp, osc_d, ft_d, 0); osc_d->freq = 500; sp->len = 44100 * 5; for(n = 0; n < tst->size; n++) { osc = 0; sp_osc_compute(sp, osc_d, NULL, &osc); sp_out(sp, 0, osc); sp_test_add_sample(tst, sp->out[0]); } if(sp_test_compare(tst, hash) == SP_NOT_OK) { printf("Generated hash %s does not match reference hash %s\n", tst->md5string, hash); fail = 1; } sp_ftbl_destroy(&ft_d); sp_osc_destroy(&osc_d); if(fail) return SP_NOT_OK; else return SP_OK; }