Ejemplo n.º 1
0
int sporth_waveset(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT input;
    SPFLOAT out;
    SPFLOAT ilen;
    SPFLOAT rep;
    sp_waveset *waveset;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            plumber_print(pd, "waveset: Creating\n");
#endif

            sp_waveset_create(&waveset);
            plumber_add_ugen(pd, SPORTH_WAVESET, waveset);
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                plumber_print(pd,"Not enough arguments for waveset\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            ilen = sporth_stack_pop_float(stack);
            rep = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            plumber_print(pd, "waveset: Initialising\n");
#endif

            ilen = sporth_stack_pop_float(stack);
            rep = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            waveset = pd->last->ud;
            sp_waveset_init(pd->sp, waveset, ilen);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            ilen = sporth_stack_pop_float(stack);
            rep = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            waveset = pd->last->ud;
            waveset->rep = rep;
            sp_waveset_compute(pd->sp, waveset, &input, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            waveset = pd->last->ud;
            sp_waveset_destroy(&waveset);
            break;
        default:
            plumber_print(pd, "waveset: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 2
0
Archivo: ref.c Proyecto: Luckyncl/3rd
int sporth_ref(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    char *str;
    switch(pd->mode) {
        case PLUMBER_CREATE: 
            plumber_add_ugen(pd, SPORTH_REF, NULL);
            if(sporth_check_args(stack, "s") != SPORTH_OK) {
                stack->error++;
                fprintf(stderr, "ref: Invalid arguments.");
                return PLUMBER_NOTOK;
            }
            sporth_stack_pop_string(stack);
            break;
        case PLUMBER_INIT: 
            str = sporth_stack_pop_string(stack);
            plumber_ftmap_delete(pd, 0);
            /* get reference of the *next* pipe in the plumbing */
            plumber_ftmap_add_userdata(pd, str, pd->next->ud);
            plumber_ftmap_delete(pd, 1);
            break;
        case PLUMBER_COMPUTE: 
            break;
        case PLUMBER_DESTROY: 
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 3
0
int sporth_in(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;

    SPFLOAT out;
    sp_in *data;
    switch(pd->mode){
        case PLUMBER_CREATE:
            sp_in_create(&data);
            plumber_add_ugen(pd, SPORTH_IN, data);
            break;
        case PLUMBER_INIT:
            data = pd->last->ud;
            sp_in_init(pd->sp, data);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            data = pd->last->ud;
            sp_in_compute(pd->sp, data, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            data = pd->last->ud;
            sp_in_destroy(&data);
            break;
        default:
           printf("Error: Unknown mode!");
           break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 4
0
Archivo: p.c Proyecto: aure/Sporth
int sporth_palias(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    char *name;
    int id;
    SPFLOAT *foo;

    switch(pd->mode) {
        case PLUMBER_CREATE:
            plumber_add_ugen(pd, SPORTH_PALIAS, NULL);
            if(sporth_check_args(stack, "sf") != SPORTH_OK) {
                fprintf(stderr,"palias: Not enough arguments\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            id = floor(sporth_stack_pop_float(stack));
            name = sporth_stack_pop_string(stack);
            foo = &pd->p[id];
            plumber_ftmap_delete(pd, 0);
            plumber_set_var(pd, name, foo);
            plumber_ftmap_delete(pd, 1);
            break;
        case PLUMBER_INIT:
            sporth_stack_pop_float(stack);
            sporth_stack_pop_string(stack);
            break;
        case PLUMBER_COMPUTE:
            sporth_stack_pop_float(stack);
            break;
        default:
            break;
    }

    return PLUMBER_OK;
}
Ejemplo n.º 5
0
int sporth_crossfade(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT in1;
    SPFLOAT in2;
    SPFLOAT out;
    SPFLOAT pos;
    sp_crossfade *crossfade;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            plumber_print(pd, "crossfade: Creating\n");
#endif

            sp_crossfade_create(&crossfade);
            plumber_add_ugen(pd, SPORTH_CROSSFADE, crossfade);
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                plumber_print(pd,"Not enough arguments for crossfade\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            pos = sporth_stack_pop_float(stack);
            in1 = sporth_stack_pop_float(stack);
            in2 = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            plumber_print(pd, "crossfade: Initialising\n");
#endif

            pos = sporth_stack_pop_float(stack);
            in1 = sporth_stack_pop_float(stack);
            in2 = sporth_stack_pop_float(stack);
            crossfade = pd->last->ud;
            sp_crossfade_init(pd->sp, crossfade);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            pos = sporth_stack_pop_float(stack);
            in1 = sporth_stack_pop_float(stack);
            in2 = sporth_stack_pop_float(stack);
            crossfade = pd->last->ud;
            crossfade->pos = pos;
            sp_crossfade_compute(pd->sp, crossfade, &in1, &in2, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            crossfade = pd->last->ud;
            sp_crossfade_destroy(&crossfade);
            break;
        default:
            plumber_print(pd, "crossfade: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 6
0
int sporth_f(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    unsigned int fnum;
    sporth_func_d *fd;
    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "aux (f)unction: creating\n");
#endif
            fd = malloc(sizeof(sporth_func_d));
           if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for aux (f)unction\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            plumber_add_ugen(pd, SPORTH_F, fd);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "aux (f)unction: initialising\n");
#endif
            fnum = (int)sporth_stack_pop_float(stack);

            if(fnum > 16) {
                fprintf(stderr, "Invalid function number %d\n", fnum);
                stack->error++;
                return PLUMBER_NOTOK;
            }

            fd = pd->last->ud;
            fd->fun = pd->f[fnum];

            pd->mode = PLUMBER_CREATE;
            fd->fun(stack, ud);

            pd->mode = PLUMBER_INIT;
            fd->fun(stack, ud);

            break;

        case PLUMBER_COMPUTE:
            fnum = (int)sporth_stack_pop_float(stack);
            fd = pd->last->ud;
            fd->fun(stack, ud);
            break;

        case PLUMBER_DESTROY:
            fd = pd->last->ud;
            fd->fun(stack, ud);
            free(fd);
            break;
        default:
            fprintf(stderr, "aux (f)unction: unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 7
0
int sporth_delay(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT input;
    SPFLOAT out;
    SPFLOAT time;
    SPFLOAT feedback;
    sp_delay *delay;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "delay: Creating\n");
#endif

            sp_delay_create(&delay);
            plumber_add_ugen(pd, SPORTH_DELAY, delay);
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for delay\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            time = sporth_stack_pop_float(stack);
            feedback = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "delay: Initialising\n");
#endif

            time = sporth_stack_pop_float(stack);
            feedback = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            delay = pd->last->ud;
            sp_delay_init(pd->sp, delay, time);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            time = sporth_stack_pop_float(stack);
            feedback = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            delay = pd->last->ud;
            delay->feedback = feedback;
            sp_delay_compute(pd->sp, delay, &input, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            delay = pd->last->ud;
            sp_delay_destroy(&delay);
            break;
        default:
            fprintf(stderr, "delay: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 8
0
int sporth_moogladder(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT input;
    SPFLOAT out;
    SPFLOAT freq;
    SPFLOAT res;
    sp_moogladder *moogladder;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "moogladder: Creating\n");
#endif

            sp_moogladder_create(&moogladder);
            plumber_add_ugen(pd, SPORTH_MOOGLADDER, moogladder);
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for moogladder\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            res = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "moogladder: Initialising\n");
#endif
            res = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            moogladder = pd->last->ud;
            sp_moogladder_init(pd->sp, moogladder);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            res = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            moogladder = pd->last->ud;
            moogladder->freq = freq;
            moogladder->res = res;
            sp_moogladder_compute(pd->sp, moogladder, &input, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            moogladder = pd->last->ud;
            sp_moogladder_destroy(&moogladder);
            break;
        default:
            fprintf(stderr, "moogladder: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 9
0
int sporth_comb(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT input;
    SPFLOAT out;
    SPFLOAT looptime;
    SPFLOAT revtime;
    sp_comb *comb;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            plumber_print(pd, "comb: Creating\n");
#endif

            sp_comb_create(&comb);
            plumber_add_ugen(pd, SPORTH_COMB, comb);
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                plumber_print(pd,"Not enough arguments for comb\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            looptime = sporth_stack_pop_float(stack);
            revtime = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            plumber_print(pd, "comb: Initialising\n");
#endif

            looptime = sporth_stack_pop_float(stack);
            revtime = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            comb = pd->last->ud;
            sp_comb_init(pd->sp, comb, looptime);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            looptime = sporth_stack_pop_float(stack);
            revtime = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            comb = pd->last->ud;
            comb->revtime = revtime;
            sp_comb_compute(pd->sp, comb, &input, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            comb = pd->last->ud;
            sp_comb_destroy(&comb);
            break;
        default:
            plumber_print(pd, "comb: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 10
0
int sporth_bpm2dur(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    bpm2val *data;
    SPFLOAT val;
    switch(pd->mode){
        case PLUMBER_CREATE:
#ifdef DEBUG_MODE
            fprintf(stderr, "bpm2dur: Creating\n");
#endif
            data = malloc(sizeof(bpm2val));
            data->pbpm = -100;
            data->val= -100;
            if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr, "bpm2dur: not enough args\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            val = sporth_stack_pop_float(stack);
            data->pbpm= val;
            data->val= 60.0 / val;
            plumber_add_ugen(pd, SPORTH_BPM2DUR, data);
            sporth_stack_push_float(stack, data->val);
            break;
        case PLUMBER_INIT:
#ifdef DEBUG_MODE
            fprintf(stderr, "bpm2dur: Initializing\n");
#endif
            data = pd->last->ud;
            val = sporth_stack_pop_float(stack);

            if(data->pbpm != val) {
                data->pbpm= val;
                data->val= 60.0 / val;
            }

            sporth_stack_push_float(stack, data->val);
            break;
        case PLUMBER_COMPUTE:
            data = pd->last->ud;
            val = sporth_stack_pop_float(stack);
            if(data->pbpm  != val) {
                data->pbpm= val;
                data->val = 60.0 / val;
            }
            sporth_stack_push_float(stack, data->val);
            break;
        case PLUMBER_DESTROY:
            data = pd->last->ud;
            free(data);
            break;
        default:
            fprintf(stderr,"bpm2dur: unknown mode!");
            stack->error++;
            return PLUMBER_NOTOK;
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 11
0
int sporth_maygate(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT trig;
    SPFLOAT out;
    SPFLOAT prob;
    sp_maygate *maygate;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "maygate: Creating\n");
#endif

            sp_maygate_create(&maygate);
            plumber_add_ugen(pd, SPORTH_MAYGATE, maygate);
            if(sporth_check_args(stack, "ff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for maygate\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            prob = sporth_stack_pop_float(stack);
            trig = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "maygate: Initialising\n");
#endif

            prob = sporth_stack_pop_float(stack);
            trig = sporth_stack_pop_float(stack);
            maygate = pd->last->ud;
            sp_maygate_init(pd->sp, maygate);
            maygate->mode = 0;
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            prob = sporth_stack_pop_float(stack);
            trig = sporth_stack_pop_float(stack);
            maygate = pd->last->ud;
            maygate->prob = prob;
            sp_maygate_compute(pd->sp, maygate, &trig, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            maygate = pd->last->ud;
            sp_maygate_destroy(&maygate);
            break;
        default:
            fprintf(stderr, "maygate: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 12
0
int sporth_print(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    sporth_print_d *prnt;
    char *str = NULL; 
    SPFLOAT val = 0;
    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "print: Creating\n");
#endif
            prnt = malloc(sizeof(sporth_print_d));
            plumber_add_ugen(pd, SPORTH_PRINT, prnt);
            if(sporth_check_args(stack, "fs") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for print\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            str = sporth_stack_pop_string(stack);
            val = sporth_stack_pop_float(stack);
            
            strncpy(prnt->label, str, 128);
            prnt->pval = val; 
            prnt->init = 1;
            sporth_stack_push_float(stack, val);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "print: Initialising\n");
#endif
            prnt = pd->last->ud;
            str = sporth_stack_pop_string(stack);
            val = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, val);
            break;
        case PLUMBER_COMPUTE:
            prnt = pd->last->ud;
            val = sporth_stack_pop_float(stack);
            if(val != prnt->pval || prnt->init) {
                prnt->pval = val;
                prnt->init = 0;
                printf("%s: %g\n", prnt->label, val);
            }
            sporth_stack_push_float(stack, val);
            break;
        case PLUMBER_DESTROY:
            prnt = pd->last->ud;
            free(prnt);
            break;
        default:
            fprintf(stderr, "print: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 13
0
int sporth_dmetro(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT out;
    SPFLOAT time;
    sp_dmetro *dmetro;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "dmetro: Creating\n");
#endif

            sp_dmetro_create(&dmetro);
            plumber_add_ugen(pd, SPORTH_DMETRO, dmetro);
            if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for dmetro\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            time = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "dmetro: Initialising\n");
#endif

            time = sporth_stack_pop_float(stack);
            dmetro = pd->last->ud;
            sp_dmetro_init(pd->sp, dmetro);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for dmetro\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            time = sporth_stack_pop_float(stack);
            dmetro = pd->last->ud;
            dmetro->time = time;
            sp_dmetro_compute(pd->sp, dmetro, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            dmetro = pd->last->ud;
            sp_dmetro_destroy(&dmetro);
            break;
        default:
            fprintf(stderr, "dmetro: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 14
0
int sporth_pdhalf(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT sig;
    SPFLOAT out;
    SPFLOAT amount;
    sp_pdhalf *pdhalf;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "pdhalf: Creating\n");
#endif

            sp_pdhalf_create(&pdhalf);
            plumber_add_ugen(pd, SPORTH_PDHALF, pdhalf);
            if(sporth_check_args(stack, "ff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for pdhalf\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            amount = sporth_stack_pop_float(stack);
            sig = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "pdhalf: Initialising\n");
#endif

            amount = sporth_stack_pop_float(stack);
            sig = sporth_stack_pop_float(stack);
            pdhalf = pd->last->ud;
            sp_pdhalf_init(pd->sp, pdhalf);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            amount = sporth_stack_pop_float(stack);
            sig = sporth_stack_pop_float(stack);
            pdhalf = pd->last->ud;
            pdhalf->amount = amount;
            sp_pdhalf_compute(pd->sp, pdhalf, &sig, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            pdhalf = pd->last->ud;
            sp_pdhalf_destroy(&pdhalf);
            break;
        default:
            fprintf(stderr, "pdhalf: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 15
0
int sporth_blsaw(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT out;
    SPFLOAT freq;
    SPFLOAT amp;
    sp_blsaw *blsaw;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "blsaw: Creating\n");
#endif

            sp_blsaw_create(&blsaw);
            plumber_add_ugen(pd, SPORTH_SAW, blsaw);
            if(sporth_check_args(stack, "ff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for blsaw\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            amp = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "blsaw: Initialising\n");
#endif
            amp = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            blsaw = pd->last->ud;
            sp_blsaw_init(pd->sp, blsaw);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            amp = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            blsaw = pd->last->ud;
            *blsaw->freq = freq;
            *blsaw->amp = amp;
            sp_blsaw_compute(pd->sp, blsaw, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            blsaw = pd->last->ud;
            sp_blsaw_destroy(&blsaw);
            break;
        default:
            fprintf(stderr, "blsaw: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 16
0
int sporth_clip(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT in;
    SPFLOAT out;
    SPFLOAT lim;
    sp_clip *clip;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            plumber_print(pd, "clip: Creating\n");
#endif

            sp_clip_create(&clip);
            plumber_add_ugen(pd, SPORTH_CLIP, clip);
            if(sporth_check_args(stack, "ff") != SPORTH_OK) {
                plumber_print(pd,"Not enough arguments for clip\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            lim = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            plumber_print(pd, "clip: Initialising\n");
#endif
            lim = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);
            clip = pd->last->ud;
            sp_clip_init(pd->sp, clip);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            lim = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);
            clip = pd->last->ud;
            clip->lim = lim;
            sp_clip_compute(pd->sp, clip, &in, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            clip = pd->last->ud;
            sp_clip_destroy(&clip);
            break;
        default:
            plumber_print(pd, "clip: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 17
0
int sporth_atone(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT in;
    SPFLOAT out;
    SPFLOAT hp;
    sp_atone *atone;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "atone: Creating\n");
#endif

            sp_atone_create(&atone);
            plumber_add_ugen(pd, SPORTH_ATONE, atone);
            if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for atone\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            hp = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "atone: Initialising\n");
#endif
            hp = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);
            atone = pd->last->ud;
            sp_atone_init(pd->sp, atone);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            hp = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);
            atone = pd->last->ud;
            atone->hp = hp;
            sp_atone_compute(pd->sp, atone, &in, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            atone = pd->last->ud;
            sp_atone_destroy(&atone);
            break;
        default:
            fprintf(stderr, "atone: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 18
0
int sporth_phasor(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT out;
    SPFLOAT iphs;
    SPFLOAT freq;
    sp_phasor *phasor;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "phasor: Creating\n");
#endif

            sp_phasor_create(&phasor);
            plumber_add_ugen(pd, SPORTH_PHASOR, phasor);
            if(sporth_check_args(stack, "ff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for phasor\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            iphs = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "phasor: Initialising\n");
#endif
            iphs = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            phasor = pd->last->ud;
            sp_phasor_init(pd->sp, phasor, iphs);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            iphs = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            phasor = pd->last->ud;
            phasor->freq = freq;
            sp_phasor_compute(pd->sp, phasor, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            phasor = pd->last->ud;
            sp_phasor_destroy(&phasor);
            break;
        default:
            fprintf(stderr, "phasor: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 19
0
int sporth_switch(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT trig;
    SPFLOAT input_1;
    SPFLOAT input_2;
    SPFLOAT out;
    sp_switch *sw;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            plumber_print(pd, "switch: creating\n");
#endif

            sp_switch_create(&sw);
            plumber_add_ugen(pd, SPORTH_SWITCH, sw);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            plumber_print(pd, "switch: initialising\n");
#endif

            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                plumber_print(pd,"Not enough arguments for switch\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            trig = sporth_stack_pop_float(stack);
            input_1 = sporth_stack_pop_float(stack);
            input_2 = sporth_stack_pop_float(stack);
            sw = pd->last->ud;
            sp_switch_init(pd->sp, sw);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            input_2 = sporth_stack_pop_float(stack);
            input_1 = sporth_stack_pop_float(stack);
            trig = sporth_stack_pop_float(stack);
            sw = pd->last->ud;
            sp_switch_compute(pd->sp, sw, &trig, &input_1, &input_2, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            sw = pd->last->ud;
            sp_switch_destroy(&sw);
            break;
        default:
            plumber_print(pd, "switch: unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 20
0
int sporth_sdelay(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT input;
    SPFLOAT out;
    SPFLOAT size;
    sp_sdelay *sdelay;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            plumber_print(pd, "sdelay: Creating\n");
#endif

            sp_sdelay_create(&sdelay);
            plumber_add_ugen(pd, SPORTH_SDELAY, sdelay);
            if(sporth_check_args(stack, "ff") != SPORTH_OK) {
                plumber_print(pd,"Not enough arguments for sdelay\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            size = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            plumber_print(pd, "sdelay: Initialising\n");
#endif

            size = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            sdelay = pd->last->ud;
            sp_sdelay_init(pd->sp, sdelay, size);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            size = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            sdelay = pd->last->ud;
            sp_sdelay_compute(pd->sp, sdelay, &input, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            sdelay = pd->last->ud;
            sp_sdelay_destroy(&sdelay);
            break;
        default:
            plumber_print(pd, "sdelay: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 21
0
int sporth_gen_line(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;

    int size;
    sp_ftbl *ft;
    char *str;
    char *args;

    switch(pd->mode){
        case PLUMBER_CREATE:
#ifdef DEBUG_MODE
            fprintf(stderr, "gen_line: create mode\n");
#endif
            plumber_add_ugen(pd, SPORTH_GEN_LINE, NULL);
            if(sporth_check_args(stack, "sfs") != SPORTH_OK) {
                fprintf(stderr, "Init: not enough arguments for gen_line\n");
                return PLUMBER_NOTOK;
            }
            args = sporth_stack_pop_string(stack);
            size = (int)sporth_stack_pop_float(stack);
            str = sporth_stack_pop_string(stack);
#ifdef DEBUG_MODE
            fprintf(stderr, "Creating line table %s of size %d\n", str, size);
#endif
            sp_ftbl_create(pd->sp, &ft, size);
            if(sp_gen_line(pd->sp, ft, args) == SP_NOT_OK) {
                fprintf(stderr, "There was an issue creating the line ftable \"%s\".\n", str);
                stack->error++;
                return PLUMBER_NOTOK;
            }
            plumber_ftmap_add(pd, str, ft);
            break;

        case PLUMBER_INIT:

            args = sporth_stack_pop_string(stack);
            size = (int)sporth_stack_pop_float(stack);
            str = sporth_stack_pop_string(stack);
            break;

        case PLUMBER_COMPUTE:
            sporth_stack_pop_float(stack);
            break;

        case PLUMBER_DESTROY:
            break;

        default:
           printf("Error: Unknown mode!");
           break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 22
0
int sporth_fexec(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    sporth_fload_d *fexec;
    sporth_fload_d *fload;
    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "fexec: creating\n");
#endif
            fexec = malloc(sizeof(sporth_fload_d));
            plumber_add_ugen(pd, SPORTH_FEXEC, fexec);
            if(sporth_check_args(stack, "s") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for fclose\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            fexec->name = sporth_stack_pop_string(stack);
           
            if(plumber_ftmap_search_userdata(pd, fexec->name, (void *)&fload) == PLUMBER_NOTOK) {
                stack->error++;
                return PLUMBER_NOTOK;
            }
            fexec->fun = fload->fun;
            fexec->fun(pd, stack, &fexec->ud);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "fexec: initialising\n");
#endif
            fexec = pd->last->ud;
            fexec->name = sporth_stack_pop_string(stack);

            fexec->fun(pd, stack, &fexec->ud);
            break;

        case PLUMBER_COMPUTE:
            fexec = pd->last->ud;
            fexec->fun(pd, stack, &fexec->ud);
            break;

        case PLUMBER_DESTROY:
            fexec = pd->last->ud;
            fexec->fun(pd, stack, &fexec->ud);
            free(fexec);
            break;
        default:
            fprintf(stderr, "fexec: unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 23
0
int sporth_sget(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;

    char *ftname;
    uint32_t index = 0;
    slist_d *sl;
    char **str = NULL;
    switch(pd->mode){
        case PLUMBER_CREATE:
            str = malloc(sizeof(char *));
            plumber_add_ugen(pd, SPORTH_SGET, str);
            if(sporth_check_args(stack, "fs") != SPORTH_OK) {
               plumber_print(pd,"Not enough arguments for sget\n");
                return PLUMBER_NOTOK;
            }
            ftname = sporth_stack_pop_string(stack);
            index = sporth_stack_pop_float(stack);
            if(plumber_ftmap_search_userdata(pd,ftname, (void *)&sl) != 
                    PLUMBER_OK) {
                plumber_print(pd, "Could not find ftable %s\n", ftname);
                return PLUMBER_NOTOK;
            }
            if(index > sl->len - 1) {
                plumber_print(pd, "Index %d exceeds slist length %d\n",
                        index, sl->len);
                return PLUMBER_NOTOK;
            }
            *str = sl->list[index];
            sporth_stack_push_string(stack, &sl->list[index]);
            break;

        case PLUMBER_INIT:
            str = pd->last->ud;
            sporth_stack_pop_string(stack);
            sporth_stack_pop_float(stack);
            sporth_stack_push_string(stack, str);
            break;

        case PLUMBER_COMPUTE:
            sporth_stack_pop_float(stack);
            break;

        case PLUMBER_DESTROY:
            str = pd->last->ud;
            free(str);
            break;

        default:
            plumber_print(pd,"Error: Unknown mode!");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 24
0
int sporth_fclose(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    sporth_fclose_d *fclose;
    sporth_fload_d *fload;
    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "fclose: creating\n");
#endif
            fclose = malloc(sizeof(sporth_fclose_d));
            plumber_add_ugen(pd, SPORTH_FCLOSE, fclose);
            if(sporth_check_args(stack, "s") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for fclose\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            fclose->name = sporth_stack_pop_string(stack);
           
            if(plumber_ftmap_search_userdata(pd, fclose->name, (void *)&fload) == PLUMBER_NOTOK) {
                stack->error++;
                return PLUMBER_NOTOK;
            }
            fclose->handle = fload->handle;
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "fclose: initialising\n");
#endif
            fclose = pd->last->ud;
            fclose->name = sporth_stack_pop_string(stack);

            break;

        case PLUMBER_COMPUTE:
            break;

        case PLUMBER_DESTROY:
#ifdef DEBUG_MODE
            fprintf(stderr, "fclose: destroying\n");
#endif
            fclose= pd->last->ud;
            dlclose(fclose->handle);
            free(fclose);
            break;
        default:
            fprintf(stderr, "fclose: unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 25
0
int sporth_port(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;

    SPFLOAT htime;
    SPFLOAT in = 0, out = 0;
    sp_port *data;
    switch(pd->mode){
        case PLUMBER_CREATE:
            sp_port_create(&data);
            plumber_add_ugen(pd, SPORTH_PORT, data);
            if(sporth_check_args(stack, "ff") != SPORTH_OK) {
               fprintf(stderr,"Not enough arguments for port\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }

            htime = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);

            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:
            data = pd->last->ud;

            htime = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);

            sp_port_init(pd->sp, data, htime);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            data = pd->last->ud;

            htime = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);

            data->htime = htime;

            sp_port_compute(pd->sp, data, &in, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            data = pd->last->ud;
            sp_port_destroy(&data);
            break;
        default:
          fprintf(stderr,"Error: Unknown mode!");
           break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 26
0
int sporth_fload(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    sporth_fload_d *fload;
    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "fload: creating\n");
#endif
            fload = malloc(sizeof(sporth_fload_d));
            plumber_add_ugen(pd, SPORTH_FLOAD, fload);
            if(sporth_check_args(stack, "ss") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for fload\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            fload->filename= sporth_stack_pop_string(stack);
            fload->name = sporth_stack_pop_string(stack);
           
            fload->handle = dlopen(fload->filename, RTLD_NOW);
            if(fload->handle == NULL) {
                fprintf(stderr, "Error loading %s: %s\n", fload->name, dlerror());
                return PLUMBER_NOTOK;
            }

            fload->getter = dlsym(fload->handle, "sporth_return_ugen");
            fload->fun = fload->getter();
            plumber_ftmap_add_userdata(pd, fload->name, (void *)fload);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "fload: initialising\n");
#endif
            fload = pd->last->ud;
            fload->filename= sporth_stack_pop_string(stack);
            fload->name = sporth_stack_pop_string(stack);

            break;

        case PLUMBER_COMPUTE:
            break;

        case PLUMBER_DESTROY:
            break;
        default:
            fprintf(stderr, "fload: unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 27
0
int sporth_tset(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;

    sporth_tbl_d *td;
    char *ftname;

    switch(pd->mode){
        case PLUMBER_CREATE:
            td = malloc(sizeof(sporth_tbl_d));
            plumber_add_ugen(pd, SPORTH_TSET, td);
            if(sporth_check_args(stack, "ffs") != SPORTH_OK) {
               plumber_print(pd,"Init: not enough arguments for tset\n");
                return PLUMBER_NOTOK;
            }
            ftname = sporth_stack_pop_string(stack);
            td->index = floor(sporth_stack_pop_float(stack));
            td->val = sporth_stack_pop_float(stack);
            if(plumber_ftmap_search(pd, ftname, &td->ft) == PLUMBER_NOTOK) {
                plumber_print(pd, "tset: could not find table '%s'\n", ftname);
                stack->error++;
                return PLUMBER_NOTOK;
            }
            td->ft->tbl[td->index] = td->val;
            break;

        case PLUMBER_INIT:
            td = pd->last->ud;
            ftname = sporth_stack_pop_string(stack);
            td->index = floor(sporth_stack_pop_float(stack));
            td->val = sporth_stack_pop_float(stack);
            td->ft->tbl[td->index] = td->val;
            break;

        case PLUMBER_COMPUTE:
            td = pd->last->ud;
            td->index = (unsigned int) floor(sporth_stack_pop_float(stack)) % td->ft->size;
            td->val = sporth_stack_pop_float(stack);
            td->ft->tbl[td->index] = td->val;
            break;

        case PLUMBER_DESTROY:
            td = pd->last->ud;
            free(td);
            break;

        default:
            plumber_print(pd,"Error: Unknown mode!");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 28
0
int sporth_gen_file(sporth_stack *stack, void *ud)
{
#ifndef NO_LIBSNDFILE
    plumber_data *pd = ud;

    sp_ftbl *ft;
    char *str;
    char *filename;
    int size;

    switch(pd->mode){
        case PLUMBER_CREATE:
            plumber_add_ugen(pd, SPORTH_GEN_FILE, NULL);
            if(sporth_check_args(stack, "sfs") != SPORTH_OK) {
                fprintf(stderr, "Init: not enough arguments for gen_file\n");
                return PLUMBER_NOTOK;
            }

            filename = sporth_stack_pop_string(stack);
            size = (int)sporth_stack_pop_float(stack);
            str = sporth_stack_pop_string(stack);
            sp_ftbl_create(pd->sp, &ft, size);
            if(sp_gen_file(pd->sp, ft, filename) == SP_NOT_OK) {
                fprintf(stderr, "There was an issue creating the ftable \"%s\".\n", str);
                stack->error++;
                return PLUMBER_NOTOK;
            }
            plumber_ftmap_add(pd, str, ft);
            break;

        case PLUMBER_INIT:
            filename = sporth_stack_pop_string(stack);
            size = (int)sporth_stack_pop_float(stack);
            str = sporth_stack_pop_string(stack);
            break;

        case PLUMBER_COMPUTE:
            sporth_stack_pop_float(stack);
            break;

        case PLUMBER_DESTROY:
            break;

        default:
           printf("Error: Unknown mode!");
           break;
    }
    return PLUMBER_OK;
#else
    return PLUMBER_NOTOK;
#endif
}
Ejemplo n.º 29
0
int sporth_slist(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;

    char *ftname;
    char *filename;
    uint32_t size;
    slist_d *sl;

    switch(pd->mode){
        case PLUMBER_CREATE:
            sl = malloc(sizeof(slist_d));
            sl->list = NULL;
            plumber_add_ugen(pd, SPORTH_SLIST, sl);
            if(sporth_check_args(stack, "sfs") != SPORTH_OK) {
               plumber_print(pd,"Not enough arguments for slist\n");
                return PLUMBER_NOTOK;
            }
            filename = sporth_stack_pop_string(stack);
            size = sporth_stack_pop_float(stack);
            ftname = sporth_stack_pop_string(stack);
            if(slist_parse(sl, filename, size) != PLUMBER_OK) {
                plumber_print(pd, 
                        "slist: could not load file %s\n",
                        filename);
                return PLUMBER_NOTOK;
            }
            plumber_ftmap_add_userdata(pd, ftname, sl);

            break;

        case PLUMBER_INIT:
            sporth_stack_pop_string(stack);
            sporth_stack_pop_float(stack);
            sporth_stack_pop_string(stack);
            break;

        case PLUMBER_COMPUTE:
            sporth_stack_pop_float(stack);
            break;

        case PLUMBER_DESTROY:
            sl = pd->last->ud;
            slist_destroy(sl);
            break;

        default:
            plumber_print(pd,"Error: Unknown mode!");
            break;
    }
    return PLUMBER_OK;
}
Ejemplo n.º 30
0
int sporth_pinknoise(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT out;
    SPFLOAT amp;
    sp_pinknoise *pinknoise;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "pinknoise: Creating\n");
#endif

            sp_pinknoise_create(&pinknoise);
            plumber_add_ugen(pd, SPORTH_PINKNOISE, pinknoise);
            if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for pinknoise\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            amp = sporth_stack_pop_float(stack);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "pinknoise: Initialising\n");
#endif

            amp = sporth_stack_pop_float(stack);
            pinknoise = pd->last->ud;
            sp_pinknoise_init(pd->sp, pinknoise);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            amp = sporth_stack_pop_float(stack);
            pinknoise = pd->last->ud;
            pinknoise->amp = amp;
            sp_pinknoise_compute(pd->sp, pinknoise, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            pinknoise = pd->last->ud;
            sp_pinknoise_destroy(&pinknoise);
            break;
        default:
            fprintf(stderr, "pinknoise: Unknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}