コード例 #1
0
ファイル: f.c プロジェクト: OpenDAWN/Sporth
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));
            plumber_add_module(pd, SPORTH_F, sizeof(sporth_func_d), fd);
            break;
        case PLUMBER_INIT:

#ifdef DEBUG_MODE
            fprintf(stderr, "aux (f)unction: initialising\n");
#endif
           if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for aux (f)unction\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            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;
}
コード例 #2
0
ファイル: tin.c プロジェクト: OpenDAWN/Sporth
int sporth_tin(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT trig;
    SPFLOAT out;
    sp_tin *tin;

    switch(pd->mode) {
        case PLUMBER_CREATE:

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

            sp_tin_create(&tin);
            plumber_add_module(pd, SPORTH_TIN, sizeof(sp_tin), tin);
            break;
        case PLUMBER_INIT:

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

            if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for tin\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            trig = sporth_stack_pop_float(stack);
            tin = pd->last->ud;
            sp_tin_init(pd->sp, tin);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for tin\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            trig = sporth_stack_pop_float(stack);
            tin = pd->last->ud;
            sp_tin_compute(pd->sp, tin, &trig, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            tin = pd->last->ud;
            sp_tin_destroy(&tin);
            break;
        default:
            fprintf(stderr, "tin: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
コード例 #3
0
ファイル: prop.c プロジェクト: OpenDAWN/Sporth
int sporth_prop(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;

    SPFLOAT bpm;
    SPFLOAT out;
    sp_prop *data;
    char *str;
    switch(pd->mode){
        case PLUMBER_CREATE:
            sp_prop_create(&data);
            plumber_add_module(pd, SPORTH_PROP, sizeof(sp_prop), data);
            break;
        case PLUMBER_INIT:
            if(sporth_check_args(stack, "fs") != SPORTH_OK) {
                fprintf(stderr, "Not enough arguments for prop\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            data = pd->last->ud;
            str = sporth_stack_pop_string(stack);
            bpm = sporth_stack_pop_float(stack);
            if(sp_prop_init(pd->sp, data, str) == SP_NOT_OK) {
                stack->error++;
                free(str);
                return PLUMBER_NOTOK;
            }
            sporth_stack_push_float(stack, 0);
            free(str);
            break;
        case PLUMBER_COMPUTE:
            if(sporth_check_args(stack, "f") != SPORTH_OK) {
                fprintf(stderr, "Not enough arguments for prop\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            bpm = sporth_stack_pop_float(stack);
            data = pd->last->ud;
            data->bpm = bpm;
            sp_prop_compute(pd->sp, data, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            data = pd->last->ud;
            sp_prop_destroy(&data);
            break;
        default:
           printf("Error: Unknown mode!");
           break;
    }
    return PLUMBER_NOTOK;
}
コード例 #4
0
int sporth_gen_sinesum(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;

    int size;
    SPFLOAT out = 0;
    sp_ftbl *ft;
    char *str;
    char *args;

    switch(pd->mode){
        case PLUMBER_CREATE:
            plumber_add_module(pd, SPORTH_GEN_SINESUM, 0, NULL);
            break;

        case PLUMBER_INIT:
            if(sporth_check_args(stack, "sfs") != SPORTH_OK) {
                fprintf(stderr, "Init: not enough arguments for gen_sinesum\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 sinesum table %s of size %d\n", str, size);
#endif
            sp_ftbl_create(pd->sp, &ft, size);
            if(sp_gen_sinesum(pd->sp, ft, args) == SP_NOT_OK) {
                fprintf(stderr, "There was an issue creating the sinesume ftable \"%s\".\n", str);
                stack->error++;
                return PLUMBER_NOTOK;
            }
            plumber_ftmap_add(pd, str, ft);
            free(str);
            free(args);
            break;

        case PLUMBER_COMPUTE:
            size = (int)sporth_stack_pop_float(stack);
            break;

        case PLUMBER_DESTROY:
            break;

        default:
           printf("Error: Unknown mode!");
           break;
    }
    return PLUMBER_OK;
}
コード例 #5
0
ファイル: line.c プロジェクト: OpenDAWN/Sporth
int sporth_line(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    
    sporth_line_d *line;

    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "line: Creating\n");
#endif
            line = malloc(sizeof(sporth_line_d));
            plumber_add_module(pd, SPORTH_LINE, sizeof(sporth_line_d), line);
            break;
        case PLUMBER_INIT:

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

            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for line\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            line = pd->last->ud;
            line->ib = sporth_stack_pop_float(stack);
            line->idur = sporth_stack_pop_float(stack);
            line->ia = sporth_stack_pop_float(stack);
            line_init(pd, line);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            line = pd->last->ud;
            sporth_stack_pop_float(stack);
            sporth_stack_pop_float(stack);
            sporth_stack_pop_float(stack);

            sporth_stack_push_float(stack, line_compute(line));
            break;
        case PLUMBER_DESTROY:
            line = pd->last->ud;
            free(line);
            break;
        default:
            fprintf(stderr, "line: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
コード例 #6
0
ファイル: noise.c プロジェクト: luiseduardohdbackup/Sporth
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;
}
コード例 #7
0
ファイル: gbuzz.c プロジェクト: OpenDAWN/Sporth
int sporth_gbuzz(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT out;
    SPFLOAT freq;
    SPFLOAT amp;
    SPFLOAT nharm;
    SPFLOAT lharm;
    SPFLOAT mul;
    sporth_gbuzz_d *gbuzz;

    switch(pd->mode) {
        case PLUMBER_CREATE:
#ifdef DEBUG_MODE
            fprintf(stderr, "gbuzz: Creating\n");
#endif
            gbuzz = malloc(sizeof(sporth_gbuzz_d));
            sp_ftbl_create(pd->sp, &gbuzz->ft, 4096);
            sp_gbuzz_create(&gbuzz->gbuzz);
            plumber_add_module(pd, SPORTH_GBUZZ, sizeof(sporth_gbuzz_d), gbuzz);
            break;
        case PLUMBER_INIT:

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

            if(sporth_check_args(stack, "fffff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for gbuzz\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            mul = sporth_stack_pop_float(stack);
            lharm = sporth_stack_pop_float(stack);
            nharm = sporth_stack_pop_float(stack);
            amp = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);

            gbuzz = pd->last->ud;
            sp_gen_sine(pd->sp, gbuzz->ft);
            sp_gbuzz_init(pd->sp, gbuzz->gbuzz, gbuzz->ft, 0);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            if(sporth_check_args(stack, "fffff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for gbuzz\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            mul = sporth_stack_pop_float(stack);
            lharm = sporth_stack_pop_float(stack);
            nharm = sporth_stack_pop_float(stack);
            amp = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);

            gbuzz = pd->last->ud;

            gbuzz->gbuzz->freq = freq;
            gbuzz->gbuzz->amp = amp;
            gbuzz->gbuzz->nharm = nharm;
            gbuzz->gbuzz->lharm = lharm;
            gbuzz->gbuzz->mul = mul;
            SPFLOAT dumb = 0;
            sp_gbuzz_compute(pd->sp, gbuzz->gbuzz, &dumb, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            gbuzz = pd->last->ud;
            sp_gbuzz_destroy(&gbuzz->gbuzz);
            sp_ftbl_destroy(&gbuzz->ft);
            free(gbuzz);
            break;
        default:
            fprintf(stderr, "gbuzz: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
コード例 #8
0
ファイル: bitcrush.c プロジェクト: OpenDAWN/Sporth
int sporth_bitcrush(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT input;
    SPFLOAT out;
    SPFLOAT bitdepth;
    SPFLOAT srate;
    sp_bitcrush *bitcrush;

    switch(pd->mode) {
        case PLUMBER_CREATE:

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

            sp_bitcrush_create(&bitcrush);
            plumber_add_module(pd, SPORTH_BITCRUSH, sizeof(sp_bitcrush), bitcrush);
            break;
        case PLUMBER_INIT:

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

            if(sporth_check_args(stack, "ff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for bitcrush\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            srate = sporth_stack_pop_float(stack);
            bitdepth = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            bitcrush = pd->last->ud;
            sp_bitcrush_init(pd->sp, bitcrush);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            if(sporth_check_args(stack, "ff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for bitcrush\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            srate = sporth_stack_pop_float(stack);
            bitdepth = sporth_stack_pop_float(stack);
            input = sporth_stack_pop_float(stack);
            bitcrush = pd->last->ud;
            bitcrush->bitdepth = bitdepth;
            bitcrush->srate = srate;
            sp_bitcrush_compute(pd->sp, bitcrush, &input, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            bitcrush = pd->last->ud;
            sp_bitcrush_destroy(&bitcrush);
            break;
        default:
            fprintf(stderr, "bitcrush: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
コード例 #9
0
ファイル: randh.c プロジェクト: OpenDAWN/Sporth
int sporth_randh(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT out;
    SPFLOAT freq;
    SPFLOAT min;
    SPFLOAT max;
    sp_randh *randh;

    switch(pd->mode) {
        case PLUMBER_CREATE:

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

            sp_randh_create(&randh);
            plumber_add_module(pd, SPORTH_RANDH, sizeof(sp_randh), randh);
            break;
        case PLUMBER_INIT:

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

            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for randh\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            max = sporth_stack_pop_float(stack);
            min = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            randh = pd->last->ud;
            sp_randh_init(pd->sp, randh);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for randh\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            max = sporth_stack_pop_float(stack);
            min = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            randh = pd->last->ud;
            randh->freq = freq;
            randh->min = min;
            randh->max = max;
            sp_randh_compute(pd->sp, randh, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            randh = pd->last->ud;
            sp_randh_destroy(&randh);
            break;
        default:
            fprintf(stderr, "randh: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
コード例 #10
0
ファイル: osc.c プロジェクト: luiseduardohdbackup/Sporth
int sporth_osc(sporth_stack *stack, void *ud)
{
    if(stack->error > 0) return PLUMBER_NOTOK;

    plumber_data *pd = ud;
    SPFLOAT out = 0, amp, freq, phs;
    char *ftname;
    sp_ftbl *ft;
    sp_osc *osc;
    switch(pd->mode){
        case PLUMBER_CREATE:
#ifdef DEBUGMODE
            fprintf(stderr, "Creating osc function... \n");
#endif
            sp_osc_create(&osc);
            plumber_add_module(pd, SPORTH_OSC, sizeof(sp_osc), osc);
            break;
        case PLUMBER_INIT:
            if(sporth_check_args(stack, "fffs") != SPORTH_OK) {
                stack->error++;
               fprintf(stderr,"Invalid arguments for osc.\n");
                return PLUMBER_NOTOK;
            }
            osc = pd->last->ud;

            ftname = sporth_stack_pop_string(stack);
            phs = sporth_stack_pop_float(stack);
            amp = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);

            if(plumber_ftmap_search(pd, ftname, &ft) == PLUMBER_NOTOK) {
                stack->error++;
                return PLUMBER_NOTOK;
            }

            sp_osc_init(pd->sp, osc, ft, phs);
            sporth_stack_push_float(stack, 0.0);
            free(ftname);
            break;

        case PLUMBER_COMPUTE:
            osc = pd->last->ud;

            phs = sporth_stack_pop_float(stack);
            amp = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);

            osc->amp = amp;
            osc->freq = freq;

            sp_osc_compute(pd->sp, osc, NULL, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            osc = pd->last->ud;
            sp_osc_destroy(&osc);
            break;
        default:
           fprintf(stderr,"Error: Unknown mode!");
            stack->error++;
            return PLUMBER_NOTOK;
            break;
    }
    return PLUMBER_OK;
}
コード例 #11
0
ファイル: count.c プロジェクト: OpenDAWN/Sporth
int sporth_count(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT trig;
    SPFLOAT out;
    SPFLOAT count;
    SPFLOAT mode;
    sp_count *cnt;

    switch(pd->mode) {
        case PLUMBER_CREATE:

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

            sp_count_create(&cnt);
            plumber_add_module(pd, SPORTH_COUNT, sizeof(sp_count), cnt);
            break;
        case PLUMBER_INIT:

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

            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for count\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            mode = sporth_stack_pop_float(stack);
            count = sporth_stack_pop_float(stack);
            trig = sporth_stack_pop_float(stack);
            cnt = pd->last->ud;
            sp_count_init(pd->sp, cnt);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for count\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            mode = sporth_stack_pop_float(stack);
            count = sporth_stack_pop_float(stack);
            trig = sporth_stack_pop_float(stack);
            cnt = pd->last->ud;
            cnt->count = count;
            cnt->mode = mode;
            sp_count_compute(pd->sp, cnt, &trig, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            cnt = pd->last->ud;
            sp_count_destroy(&cnt);
            break;
        default:
            fprintf(stderr, "count: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
コード例 #12
0
ファイル: mode.c プロジェクト: OpenDAWN/Sporth
int sporth_mode(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT in;
    SPFLOAT out;
    SPFLOAT freq;
    SPFLOAT q;
    sp_mode *mode;

    switch(pd->mode) {
        case PLUMBER_CREATE:

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

            sp_mode_create(&mode);
            plumber_add_module(pd, SPORTH_MODE, sizeof(sp_mode), mode);
            break;
        case PLUMBER_INIT:

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

            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for mode\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            q = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);
            mode = pd->last->ud;
            sp_mode_init(pd->sp, mode);
            sporth_stack_push_float(stack, 0);
            break;
        case PLUMBER_COMPUTE:
            if(sporth_check_args(stack, "fff") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for mode\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            q = sporth_stack_pop_float(stack);
            freq = sporth_stack_pop_float(stack);
            in = sporth_stack_pop_float(stack);
            mode = pd->last->ud;
            mode->freq = freq;
            mode->q = q;
            sp_mode_compute(pd->sp, mode, &in, &out);
            sporth_stack_push_float(stack, out);
            break;
        case PLUMBER_DESTROY:
            mode = pd->last->ud;
            sp_mode_destroy(&mode);
            break;
        default:
            fprintf(stderr, "mode: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}
コード例 #13
0
ファイル: ling.c プロジェクト: OpenDAWN/Sporth
int sporth_ling(sporth_stack *stack, void *ud)
{
    plumber_data *pd = ud;
    SPFLOAT tick = 0; 
    sp_ling *ling; 
    ling_func *fl = NULL; 
    char *str;
    switch(pd->mode) {
        case PLUMBER_CREATE:

#ifdef DEBUG_MODE
            fprintf(stderr, "ling: Creating\n");
#endif
            ling = malloc(sizeof(sp_ling));
            plumber_add_module(pd, SPORTH_LING, sizeof(sp_ling), ling);
            break;
        case PLUMBER_INIT:

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

            if(sporth_check_args(stack, "fffs") != SPORTH_OK) {
                fprintf(stderr,"Not enough arguments for ling\n");
                stack->error++;
                return PLUMBER_NOTOK;
            }
            ling = pd->last->ud;

            str = sporth_stack_pop_string(stack);
            ling->mode = sporth_stack_pop_float(stack);
            ling->N = (uint32_t) sporth_stack_pop_float(stack);
            tick = sporth_stack_pop_float(stack);
            ling_init(&ling->ling);
            fl = ling_create_flist(&ling->ling);
            ling_register_func(&ling->ling, fl);
            ling->val = 0;
            ling->pos = 0;
            sporth_stack_push_float(stack, 0);
#ifdef DEBUG_MODE
            printf("ling: the string is %s\n", str);
#endif
            ling_parse_line(&ling->ling, str);
            free(str);
            break;
        case PLUMBER_COMPUTE:
            ling = pd->last->ud;
            ling->mode = sporth_stack_pop_float(stack);
            ling->N = (uint32_t) sporth_stack_pop_float(stack);
            tick = sporth_stack_pop_float(stack);
            switch(ling->mode) {
                case 0:
                    if(tick != 0) {
                        ling_seq_run(&ling->ling);
                        ling->val = ling_stack_pop(&ling->ling.stack);
                        ling->ling.t++;
                    } 
                    break;
                case 1:
                    if(tick != 0 ) {
                        if(ling->N <= 0 || ling->N > 32) ling->N = 1;
                        if(ling->pos == 0) {
                            ling_seq_run(&ling->ling);
                            ling->val = ling_stack_pop(&ling->ling.stack);
                            ling->ling.t++;
                            num_to_bin(ling->val, ling->bin, ling->N);
                        }
                        ling->val = ling->bin[ling->pos];
                        ling->pos++;
                        ling->pos %= ling->N;
                    } else {
                        //fprintf(stderr, "we are here...\n");
                        ling->val = 0;
                    }
                    break;
                default: 
                    break;
            }
            sporth_stack_push_float(stack, (SPFLOAT)ling->val);
            break;
        case PLUMBER_DESTROY:
            ling = pd->last->ud;
            ling_destroy(&ling->ling);
            free(ling);
            break;
        default:
            fprintf(stderr, "ling: Uknown mode!\n");
            break;
    }
    return PLUMBER_OK;
}