Beispiel #1
0
void write_noise(sp_data *data, void *ud) {
    udata *udata = ud;
    SPFLOAT in = 0;
    SPFLOAT out = 0;
    sp_noise_compute(data, udata->ns, NULL, &in);
    sp_tone_compute(data, udata->tn, &in, &data->out[0]); 
}
Beispiel #2
0
void write_noise(sp_data *sp, void *udata) {
    UserData *ud = udata;
    SPFLOAT in = 0;
    SPFLOAT out = 0;
    sp_noise_compute(sp, ud->ns, NULL, &in);
    sp_tbvcf_compute(sp, ud->tn, &in, &sp->out[0]); 
}
Beispiel #3
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;
}
Beispiel #4
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;
}
Beispiel #5
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;
}
Beispiel #6
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;
}
Beispiel #7
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;
}
Beispiel #8
0
void write_noise(sp_data *data, void *ud) {
    udata *udata = ud;
    SPFLOAT in = 0;
    SPFLOAT out = 0;
    sp_noise_compute(data, udata->ns, NULL, &in);
    udata->reson->freq = 4000;
    udata->reson->bw = 1000;
    sp_reson_compute(data, udata->reson, &in, &out); 
    data->out[0] = out * 0.1;
}
Beispiel #9
0
void process(sp_data *data, void *ud) {
    udata *udata = ud;
    SPFLOAT in = 0;
    SPFLOAT out = 0;
    SPFLOAT foo = 0;
    sp_noise_compute(data, udata->ns, NULL, &in);
    
    if(udata->counter < 2000) {
        udata->counter = (udata->counter + 1) % 5000;
    }else{
        in = 0;
    }
    sp_revsc_compute(data, udata->rev, &in, &in, &data->out[0], &foo); 
}
Beispiel #10
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;
}
Beispiel #11
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;
}
Beispiel #12
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;
}
Beispiel #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;
}
    void process(AUAudioFrameCount frameCount, AUAudioFrameCount bufferOffset) override {

        for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) {

            int frameOffset = int(frameIndex + bufferOffset);

            amplitude = amplitudeRamper.getAndStep();
            noise->amp = (float)amplitude;

            float temp = 0;
            for (int channel = 0; channel < channels; ++channel) {
                float *out = (float *)outBufferListPtr->mBuffers[channel].mData + frameOffset;
                if (started) {
                    if (channel == 0) {
                        sp_noise_compute(sp, noise, nil, &temp);
                    }
                    *out = temp;
                } else {
                    *out = 0.0;
                }
            }
        }
    }