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_buthp(sp_test *tst, sp_data *sp, const char *hash) 
{
    sp_srand(sp, 0); 
    uint32_t n;
    int fail = 0;
    SPFLOAT in = 0;
    SPFLOAT out = 0;
    
    UserData 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);
    }
    
    fail = sp_test_verify(tst, hash);
    
    sp_noise_destroy(&ud.ns);
    sp_buthp_destroy(&ud.buthp);
     
    if(fail) return SP_NOT_OK;
    else return SP_OK;
}
Ejemplo n.º 3
0
int t_atone(sp_test *tst, sp_data *sp, const char *hash) 
{
    sp_srand(sp, 0); 
    uint32_t n;
    int fail = 0;
    SPFLOAT noise = 0, atone = 0;
    
    sp_atone *atone_d;
    sp_noise *noise_d;

    sp_atone_create(&atone_d);
    sp_noise_create(&noise_d);

    sp_atone_init(sp, atone_d);
    sp_noise_init(sp, noise_d);

    for(n = 0; n < tst->size; n++) {
        noise = 0, atone = 0;
        sp_noise_compute(sp, noise_d, NULL, &noise);
        sp_atone_compute(sp, atone_d, &noise, &atone);
        sp_test_add_sample(tst, atone);
    }

    fail = sp_test_verify(tst, hash);

    sp_atone_destroy(&atone_d);
    sp_noise_destroy(&noise_d);
     
    if(fail) return SP_NOT_OK;
    else return SP_OK;
}
Ejemplo n.º 4
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.º 5
0
int t_tbvcf(sp_test *tst, sp_data *sp, const char *hash) 
{
    uint32_t n;
    int fail = 0;

    sp_srand(sp, 0); 
    UserData ud;
    sp_noise_create(&ud.ns);
    sp_tbvcf_create(&ud.tn);
    sp_noise_init(sp, ud.ns);
    sp_tbvcf_init(sp, ud.tn);
    ud.tn->dist = 1.0;
    SPFLOAT in = 0;

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

        sp_noise_compute(sp, ud.ns, NULL, &in);
        sp_tbvcf_compute(sp, ud.tn, &in, &sp->out[0]); 
        sp_test_add_sample(tst, sp->out[0]);
    }

    fail = sp_test_verify(tst, hash);
    
    sp_noise_destroy(&ud.ns);
    sp_tbvcf_destroy(&ud.tn);

    if(fail) return SP_NOT_OK;
    else return SP_OK;
}
Ejemplo n.º 6
0
int sporth_noise(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;

    SPFLOAT gain;
    SPFLOAT out;
    sp_noise *data;
    switch(pd->mode){
        case PLUMBER_CREATE:
            sp_noise_create(&data);
            plumber_add_module(pd, SPORTH_NOISE, sizeof(sp_noise), data);
            break;
        case PLUMBER_INIT:
            if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr, "Not enough arguments for noise\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            data = pd->last->ud;
            gain = sporth_stack_pop_float(stack);
            if(sp_noise_init(pd->sp, data) == SP_NOT_OK) {
                stack->error++;
                return PLUMBER_NOTOK;
            }
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr, "Not enough arguments for noise\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            gain = sporth_stack_pop_float(stack);
            data = pd->last->ud;
            data->gain = gain;
            sp_noise_compute(pd->sp, data, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            data = pd->last->ud;
            sp_noise_destroy(&data);
            break;
        default:
           printf("Error: Unknown mode!");
           break;
    }
    return PLUMBER_NOTOK;
}
Ejemplo n.º 7
0
int main() {
    srand(time(NULL));
    udata ud;
    sp_data *sp;
    sp_create(&sp);
    sp_noise_create(&ud.ns);
    sp_tone_create(&ud.tn);
    sp_noise_init(sp, ud.ns);
    sp_tone_init(sp, ud.tn);
    sp->len = 44100 * 5;
    sp_process(sp, &ud, write_noise);
    sp_noise_destroy(&ud.ns);
    sp_tone_destroy(&ud.tn);
    sp_destroy(&sp);
    return 0;
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
0
int main() {
    srand(time(NULL));
    UserData ud;
    sp_data *sp;
    sp_create(&sp);
    sp_noise_create(&ud.ns);
    sp_tbvcf_create(&ud.tn);
    sp_noise_init(sp, ud.ns);
    sp_tbvcf_init(sp, ud.tn);
    sp->len = 44100 * 5;
    ud.tn->dist = 1.0;
    sp_process(sp, &ud, write_noise);
    sp_noise_destroy(&ud.ns);
    sp_tbvcf_destroy(&ud.tn);
    sp_destroy(&sp);
    return 0;
}
Ejemplo n.º 10
0
int main() {
    udata ud;
    sp_data *sp;
    sp_create(&sp);
    sp_srand(sp, 12345);
    sp_noise_create(&ud.ns);
    sp_reson_create(&ud.reson);
    sp_noise_init(sp, ud.ns);
    ud.ns->amp = 1.0;
    sp_reson_init(sp, ud.reson);
    sp->len = 44100 * 5;
    sp_process(sp, &ud, write_noise);
    sp_noise_destroy(&ud.ns);
    sp_reson_destroy(&ud.reson);
    sp_destroy(&sp);
    return 0;
}
Ejemplo n.º 11
0
int t_allpass(sp_test *tst, sp_data *sp, const char *hash) 
{
    sp_srand(sp, 0); 
    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);
    }

    fail = sp_test_verify(tst,hash);

    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;
}
Ejemplo n.º 12
0
int main() {
    srand(time(NULL));
    udata ud;
    ud.counter = 0;
    sp_data *sp;
    sp_create(&sp);
    sp_noise_create(&ud.ns);
    sp_revsc_create(&ud.rev);
    sp_noise_init(sp, ud.ns);
    sp_revsc_init(sp, ud.rev);

    sp->len = 44100 * 5;
    sp_process(sp, &ud, process);

    sp_noise_destroy(&ud.ns);
    sp_revsc_destroy(&ud.rev);
    sp_destroy(&sp);
    return 0;
}
Ejemplo n.º 13
0
int t_revsc(sp_test *tst, sp_data *sp, const char *hash) 
{
    uint32_t n;
    int fail = 0;
    SPFLOAT in = 0;
    SPFLOAT foo = 0;
    sp_srand(sp, 123456);
    UserData ud;
    ud.counter = 0;
    sp_noise_create(&ud.ns);
    sp_revsc_create(&ud.rev);
    sp_noise_init(sp, ud.ns);
    sp_revsc_init(sp, ud.rev);

    sp->len = 44100 * 5;

    for(n = 0; n < tst->size; n++) {
        in = 0;
        foo = 0;
        sp_noise_compute(sp, ud.ns, NULL, &in);
        
        if(ud.counter < 2000) {
            ud.counter = (ud.counter + 1) % 5000;
        }else{
            in = 0;
        }
        sp_revsc_compute(sp, ud.rev, &in, &in, &sp->out[0], &foo); 
        sp_test_add_sample(tst, sp->out[0]);
    }

    fail = sp_test_verify(tst, hash);
    
    sp_noise_destroy(&ud.ns);
    sp_revsc_destroy(&ud.rev);

    if(fail) return SP_NOT_OK;
    else return SP_OK;
}
Ejemplo n.º 14
0
 void destroy() {
     sp_noise_destroy(&noise);
     sp_destroy(&sp);
 }