Ejemplo n.º 1
0
int t_buthp(sp_test *tst, sp_data *sp, const char *hash) 
{
    uint32_t n;
    int fail = 0;
    SPFLOAT in = 0;
    SPFLOAT out = 0;
    
    udata ud;
    sp_noise_create(&ud.ns);
    sp_buthp_create(&ud.buthp);
    sp_noise_init(sp, ud.ns);
    sp_buthp_init(sp, ud.buthp);
    ud.buthp->freq = 5000;

    for(n = 0; n < tst->size; n++) {
        in = 0;
        out = 0;
        sp_noise_compute(sp, ud.ns, NULL, &in);
        sp_buthp_compute(sp, ud.buthp, &in, &out); 
        sp_test_add_sample(tst, out);
    }

    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_noise_destroy(&ud.ns);
    sp_buthp_destroy(&ud.buthp);
     
    if(fail) return SP_NOT_OK;
    else return SP_OK;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
int t_decimator(sp_test *tst, sp_data *sp, const char *hash) 
{
    uint32_t n;
    int fail = 0;
    SPFLOAT noise = 0, decimator = 0;
    UserData ud;

    sp_decimator_create(&ud.decimator);
    sp_noise_create(&ud.nz);

    sp_noise_init(sp, ud.nz);
    sp_decimator_init(sp, ud.decimator);
    ud.decimator->bitdepth = 8;
    ud.decimator->srate = 10000;

    for(n = 0; n < tst->size; n++) {
        noise = 0, decimator = 0;
        sp_noise_compute(sp, ud.nz, NULL, &noise);
        sp_decimator_compute(sp, ud.decimator, &noise, &decimator);
        sp_test_add_sample(tst, decimator);
    }

    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_decimator_destroy(&ud.decimator);
    sp_noise_destroy(&ud.nz);
     
    if(fail) return SP_NOT_OK;
    else return SP_OK;
}
Ejemplo n.º 4
0
int sp_test_verify(sp_test *t, const char *refhash)
{
    int fail = 0;
    if(sp_test_compare(t, refhash) == SP_NOT_OK) {
        printf("Generated hash %s does not match reference hash %s\n", 
                t->md5string, refhash);
        fail = 1;
    }
    return fail;
}
Ejemplo n.º 5
0
int t_delay(sp_test *tst, sp_data *sp, const char *hash)
{
    uint32_t n;
    int fail = 0;
    SPFLOAT osc = 0, delay = 0, met = 0, tenv = 0;
    UserData ud;

    sp_delay_create(&ud.delay);
    sp_osc_create(&ud.osc);
    sp_ftbl_create(sp, &ud.ft, 2048);
    sp_metro_create(&ud.met);
    sp_tenv_create(&ud.tenv);

    sp_delay_init(sp, ud.delay, 0.75 * 0.5);
    ud.delay->feedback = 0.5;
    sp_gen_sine(sp, ud.ft);
    sp_osc_init(sp, ud.osc, ud.ft, 0);
    ud.osc->amp = 0.5;
    sp_metro_init(sp, ud.met);
    ud.met->freq = 1;
    sp_tenv_init(sp, ud.tenv);
    ud.tenv->atk = 0.005;
    ud.tenv->hold = 0.1;
    ud.tenv->rel =  0.1;



    for(n = 0; n < tst->size; n++) {
        osc = 0, delay = 0, met = 0, tenv = 0;
        sp_metro_compute(sp, ud.met, NULL, &met);
        sp_tenv_compute(sp, ud.tenv, &met, &tenv);
        if(met) {
            ud.osc->freq = 100 + sp_rand(sp) % 500;
        }
        sp_osc_compute(sp, ud.osc, NULL, &osc);
        osc *= tenv;
        sp_delay_compute(sp, ud.delay, &osc, &delay);

        sp_test_add_sample(tst, osc + delay);
    }

    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;
    }

    if(fail) return SP_NOT_OK;
    else return SP_OK;
}
Ejemplo n.º 6
0
int t_allpass(sp_test *tst, sp_data *sp, const char *hash) 
{
    uint32_t n;
    int fail = 0;
    sp_allpass *ap_d;
    sp_tenv *env_d;
    sp_noise *nz_d;

    SPFLOAT tick = 0, env = 0, noise = 0, allpass = 0;

    sp_allpass_create(&ap_d);
    sp_tenv_create(&env_d);
    sp_noise_create(&nz_d);

    sp_allpass_init(sp, ap_d, 0.1);
    sp_tenv_init(sp, env_d);
    env_d->atk = 0.001;
    env_d->hold = 0.00;
    env_d->rel =  0.1;

    sp_noise_init(sp, nz_d);

    for(n = 0; n < tst->size; n++) {

        tick = 0, env = 0, noise = 0, allpass = 0;
        tick = (n == 0) ? 1 : 0;
        sp_tenv_compute(sp, env_d, &tick, &env);
        sp_noise_compute(sp, nz_d, NULL, &noise);
        noise *= env * 0.5;
        sp_allpass_compute(sp, ap_d, &noise, &allpass);

        sp_test_add_sample(tst, allpass);
    }

    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_noise_destroy(&nz_d);
    sp_tenv_destroy(&env_d);
    sp_allpass_destroy(&ap_d);
     
    if(fail) return SP_NOT_OK;
    else return SP_OK;
}