Exemplo n.º 1
0
    void init(int channelCount, double inSampleRate) {
        channels = channelCount;

        sampleRate = float(inSampleRate);

        sp_create(&sp);
        sp_drip_create(&drip);
        sp_drip_init(sp, drip, 0.9);
        drip->num_tubes = 10;
        drip->damp = 0.2;
        drip->shake_max = 0;
        drip->freq = 450;
        drip->freq1 = 600;
        drip->freq2 = 750;
        drip->amp = 0.3;
    }
Exemplo n.º 2
0
int main() {
    srand(time(NULL));
    UserData ud;
    sp_data *sp;
    sp_create(&sp);
    sp_revsc_create(&ud.rev);
    sp_drip_create(&ud.drip);
    sp_dust_create(&ud.trig);
    
    sp_dust_init(sp, ud.trig, 1, 1);
    sp_drip_init(sp, ud.drip, 0.09);
    ud.drip->amp = 0.3;
    sp_revsc_init(sp, ud.rev);
    ud.rev->feedback = 0.9;
    
    sp->len = 44100 * 30;
    sp_process(sp, &ud, write_osc);
    sp_drip_destroy(&ud.drip);
    sp_dust_destroy(&ud.trig);
    sp_revsc_destroy(&ud.rev);
    sp_destroy(&sp);
    return 0;
}
Exemplo n.º 3
0
int main()
{
    srand(time(NULL));
    int i;
    UserData ud;
    ud.pdel = 0;
    sp_data *sp;
    sp_create(&sp);
    sp->len = 44100 * 40;
    char *notes[] = {
        "62 69 78",
        "55 62 69 71",
        "43 50"
    };


    for(i = 0; i < NUMLINE; i++) {
        sp_randi_create(&ud.line[i].randi);
        chord_cloud_create(&ud.line[i].cc);
        chord_cloud_init(sp, ud.line[i].cc, notes[i], 0.1);
        sp_randi_init(sp, ud.line[i].randi, rand());
        ud.line[i].randi->cps = 0.1 + randf(1.5);
    }
    sp_revsc_create(&ud.rev);
    sp_revsc_init(sp, ud.rev);
    ud.rev->feedback = 0.95;
    sp_metro_create(&ud.clk);
    sp_metro_init(sp, ud.clk);
    ud.clk->freq = 86.0 / 60.0;
    sp_count_create(&ud.meter);
    sp_count_init(sp, ud.meter);
    ud.meter->count = 5;
    sp_drip_create(&ud.drip);
    sp_drip_init(sp, ud.drip, 0.01);
    sp_vdelay_create(&ud.del);
    /* give some headroom for the delay */
    sp_vdelay_init(sp, ud.del, 0.4);
    ud.del->del = 0.3;

    sp_tenv_create(&ud.master);
    sp_tenv_init(sp, ud.master);
    ud.master->atk = 0;
    ud.master->hold = 30;
    ud.master->rel =  10;


    sp_progress_create(&ud.prog);
    sp_progress_init(sp, ud.prog);

    modal_create(&ud.mod);
    modal_init(sp, ud.mod);
    sp_ftbl_create(sp, &ud.notes, 1);
    sp_gen_vals(sp, ud.notes, "62 64 59 57");
    sp_tseq_create(&ud.seq);
    sp_tseq_init(sp, ud.seq, ud.notes);
    sp_maygate_create(&ud.mg);
    sp_maygate_init(sp, ud.mg);
    ud.mg->prob = 0.3;
    ud.mg->mode = 1;
    sp_process(sp, &ud, process);

    for(i = 0; i < NUMLINE; i++) {
        sp_randi_destroy(&ud.line[i].randi);
        chord_cloud_destroy(&ud.line[i].cc);
    }


    sp_drip_destroy(&ud.drip);
    sp_revsc_destroy(&ud.rev);
    sp_metro_destroy(&ud.clk);
    sp_count_destroy(&ud.meter);
    sp_vdelay_destroy(&ud.del);
    sp_tenv_destroy(&ud.master);
    modal_destroy(&ud.mod);
    sp_ftbl_destroy(&ud.notes);
    sp_tseq_destroy(&ud.seq);
    sp_maygate_destroy(&ud.mg);
    sp_progress_destroy(&ud.prog);

    sp_destroy(&sp);
    return 0;
}
Exemplo n.º 4
0
int sp_drip_compute(sp_data *sp, sp_drip *p, SPFLOAT *trig, SPFLOAT *out)
{
    SPFLOAT data;
    SPFLOAT lastOutput;

    SPFLOAT tpidsr = 2.0 * M_PI / sp->sr;

    if(*trig) {
        sp_drip_init(sp, p, p->dettack);
    }
    if (p->num_tubes != 0.0 && p->num_tubes != p->num_objects) {
        p->num_objects = p->num_tubes;
        if (p->num_objects < 1.0) p->num_objects = 1.0;
    }
    if (p->freq != 0.0 && p->freq != p->res_freq0) {
        p->res_freq0 = p->freq;
        p->coeffs00 = -WUTR_RESON * 2.0 *
        cos(p->res_freq0 * tpidsr);
    }
    if (p->damp != 0.0 && p->damp != p->shake_damp) {
        p->shake_damp = p->damp;
        p->systemDecay = WUTR_SYSTEM_DECAY + (p->shake_damp * 0.002);
    }
    if (p->shake_max != 0.0 && p->shake_max != p->shake_maxSave) {
        p->shake_maxSave = p->shake_max;
        p->shakeEnergy += p->shake_maxSave * MAX_SHAKE * 0.1;
        if (p->shakeEnergy > MAX_SHAKE) p->shakeEnergy = MAX_SHAKE;
    }
    if (p->freq1 != 0.0 && p->freq1 != p->res_freq1) {
        p->res_freq1 = p->freq1;
        p->coeffs10 = -WUTR_RESON * 2.0 *
        cos(p->res_freq1 * tpidsr);
    }
    if (p->freq2 != 0.0 && p->freq2 != p->res_freq2) {
        p->res_freq2 = p->freq2;
        p->coeffs20 = -WUTR_RESON * 2.0 *
        cos(p->res_freq2 * tpidsr);
    }
    if ((--p->kloop) == 0) {
        p->shakeEnergy = 0.0;
    }

    SPFLOAT shakeEnergy = p->shakeEnergy;
    SPFLOAT systemDecay = p->systemDecay;
    SPFLOAT sndLevel = p->sndLevel;
    SPFLOAT num_objects = p->num_objects;
    SPFLOAT soundDecay = p->soundDecay;
    SPFLOAT inputs0, inputs1, inputs2;

    shakeEnergy *= systemDecay; /* Exponential system decay */

    sndLevel = shakeEnergy;
    if (my_random(sp, 32767) < num_objects) {
        int j;
        j = my_random(sp, 3);
        if (j == 0) {
            p->center_freqs0 = p->res_freq1 *
            (0.75 + (0.25 * noise_tick(sp)));
            p->gains0 = fabs(noise_tick(sp));
        } else if (j == 1) {
            p->center_freqs1 = p->res_freq1 *
            (1.0 + (0.25 * noise_tick(sp)));
            p->gains1 = fabs(noise_tick(sp));
        } else  {
            p->center_freqs2 = p->res_freq1 *
            (1.25 + (0.25 * noise_tick(sp)));
            p->gains2 = fabs(noise_tick(sp));
        }
    }

    p->gains0 *= WUTR_RESON;
    if (p->gains0 > 0.001) {
        p->center_freqs0  *= WUTR_FREQ_SWEEP;
        p->coeffs00 = -WUTR_RESON * 2.0 *
        cos(p->center_freqs0 * tpidsr);
    }
    p->gains1 *= WUTR_RESON;
    if (p->gains1 > 0.00) {
        p->center_freqs1 *= WUTR_FREQ_SWEEP;
        p->coeffs10 = -WUTR_RESON * 2.0 *
        cos(p->center_freqs1 * tpidsr);
    }
    p->gains2 *= WUTR_RESON;
    if (p->gains2 > 0.001) {
        p->center_freqs2 *= WUTR_FREQ_SWEEP;
        p->coeffs20 = -WUTR_RESON * 2.0 *
        cos(p->center_freqs2 * tpidsr);
    }

    sndLevel *= soundDecay;
    inputs0 = sndLevel;
    inputs0 *= noise_tick(sp);
    inputs1 = inputs0 * p->gains1;
    inputs2 = inputs0 * p->gains2;
    inputs0 *= p->gains0;
    inputs0 -= p->outputs00*p->coeffs00;
    inputs0 -= p->outputs01*p->coeffs01;
    p->outputs01 = p->outputs00;
    p->outputs00 = inputs0;
    data = p->gains0*p->outputs00;
    inputs1 -= p->outputs10*p->coeffs10;
    inputs1 -= p->outputs11*p->coeffs11;
    p->outputs11 = p->outputs10;
    p->outputs10 = inputs1;
    data += p->gains1*p->outputs10;
    inputs2-= p->outputs20*p->coeffs20;
    inputs2 -= p->outputs21*p->coeffs21;
    p->outputs21 = p->outputs20;
    p->outputs20 = inputs2;
    data += p->gains2*p->outputs20;

    p->finalZ2 = p->finalZ1;
    p->finalZ1 = p->finalZ0;
    p->finalZ0 = data * 4.0;

    lastOutput = p->finalZ2 - p->finalZ0;
    lastOutput *= 0.005;
    *out = lastOutput;
    p->shakeEnergy = shakeEnergy;
    p->sndLevel = sndLevel;
    return SP_OK;
}