Ejemplo n.º 1
0
/* redraw all the items in a glist.  We construe this to mean
redrawing in its own window and on parent, as needed in each case.
This is too conservative -- for instance, when you draw an "open"
rectangle on the parent, you shouldn't have to redraw the window!  */
void glist_redraw(t_glist *x)
{
    if (glist_isvisible(x))
    {
        /* LATER fix the graph_vis() code to handle both cases */
        if (glist_istoplevel(x))
        {
            t_gobj *g;
            t_linetraverser t;
            t_outconnect *oc;
            for (g = x->gl_list; g; g = g->g_next)
            {
                gobj_vis(g, x, 0);
                gobj_vis(g, x, 1);
            }
            /* redraw all the lines */
            linetraverser_start(&t, x);
            while (oc = linetraverser_next(&t))
                sys_vgui(".x%lx.c coords l%lx %d %d %d %d\n",
                         glist_getcanvas(x), oc,
                         t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2);
            canvas_drawredrect(x, 0);
            if (x->gl_goprect)
            {
                canvas_drawredrect(x, 1);
            }
        }
        if (x->gl_owner && glist_isvisible(x->gl_owner))
        {
            graph_vis(&x->gl_gobj, x->gl_owner, 0);
            graph_vis(&x->gl_gobj, x->gl_owner, 1);
        }
    }
}
Ejemplo n.º 2
0
Archivo: forky.c Proyecto: fluxama/Drom
/* To be called in a 'dsp' method -- e.g. if there are no feeders, the caller
   might use an optimized version of a 'perform' routine.
   LATER think about replacing 'linetraverser' calls with something faster. */
int forky_hasfeeders(t_object *x, t_glist *glist, int inno, t_symbol *outsym)
{
    t_linetraverser t;
    linetraverser_start(&t, glist);
    while (linetraverser_next(&t))
	if (t.tr_ob2 == x && t.tr_inno == inno
#if FORKY_VERSION >= 36
	    && (!outsym || outsym == outlet_getsymbol(t.tr_outlet))
#endif
	    )
	    return (1);
    return (0);
}
Ejemplo n.º 3
0
static void canvas_deletelines_for_io(t_canvas *x, t_text *text, t_inlet *inp, t_outlet *outp)
{
    t_linetraverser t;
    t_outconnect *oc;
    linetraverser_start(&t, x);
    while((oc = linetraverser_next(&t)))
    {
        if ((t.tr_ob == text && t.tr_outlet == outp) || (t.tr_ob2 == text && t.tr_inlet == inp))
        {
            if(glist_isvisible(x))
            {
                sys_vgui(".x%lx.c delete l%lx\n", glist_getcanvas(x), oc);
            }
            obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
        }
    }
}
Ejemplo n.º 4
0
static void gobj_stowconnections(t_glist *gl, t_gobj *ob, t_binbuf *bb)
{
    t_linetraverser lt;
    t_outconnect *oc;
    binbuf_clear(bb);
    linetraverser_start(&lt, gl);
    while (oc = linetraverser_next(&lt))
    {
        if ((t_gobj *)lt.tr_ob == ob || (t_gobj *)lt.tr_ob2 == ob)
            binbuf_addv(bb, "ssiiii;",
                        gensym("#X"), gensym("connect"),
                        gobj_getindex(gl, (t_gobj *)lt.tr_ob), lt.tr_outno,
                        gobj_getindex(gl, (t_gobj *)lt.tr_ob2), lt.tr_inno);
    }
#ifdef FRINGE_DEBUG
    fprintf(stderr, "packed connections:\n");
    binbuf_print(bb);
#endif
}
Ejemplo n.º 5
0
void eobj_dsp(void *x, t_signal **sp)
{
    int i;
    short* count;
    t_int* temp;
    t_float **tempout, *tempreal;
    t_linetraverser t;
    t_outconnect    *oc;
    t_eclass* c = eobj_getclass(x);
    t_edsp* dsp = eobj_getdsp(x);
    int nouts = obj_nsigoutlets((t_object *)x);
    int nins  = obj_nsiginlets((t_object *)x);
    int samplesize;
    if(c && c->c_widget.w_dsp && dsp && (nins || nouts) && sp && sp[0])
    {
        samplesize = sp[0]->s_n;
        dsp->d_perform_method = NULL;
        if(dsp->d_misc == E_NO_INPLACE)
        {
            if(dsp->d_sigs_out)
            {
                tempout = (t_float **)realloc(dsp->d_sigs_out, (size_t)nouts * sizeof(t_float *));
            }
            else
            {
                tempout = (t_float **)malloc((size_t)nouts * sizeof(t_float *));
            }
            if(!tempout)
            {
                if(dsp->d_sigs_out)
                {
                    free(dsp->d_sigs_out);
                    dsp->d_sigs_out = NULL;
                }
                pd_error(dsp, "can't allocate memory for ni inpace processing.");
                return;
            }
            dsp->d_sigs_out = tempout;

            if(dsp->d_sigs_real)
            {
                tempreal = (t_float *)realloc(dsp->d_sigs_real, (size_t)(nouts * samplesize) * sizeof(t_float));
            }
            else
            {
                tempreal = (t_float *)malloc((size_t)(nouts * samplesize) * sizeof(t_float));
            }
            if(!tempreal)
            {
                if(dsp->d_sigs_real)
                {
                    free(dsp->d_sigs_real);
                    dsp->d_sigs_real = NULL;
                }
                free(dsp->d_sigs_out);
                dsp->d_sigs_out = NULL;
                pd_error(dsp, "can't allocate memory for ni inpace processing.");
                return;
            }
            dsp->d_sigs_real = tempreal;
            for(i = 0; i < nouts; i++)
            {
                dsp->d_sigs_out[i] = dsp->d_sigs_real+i*samplesize;
            }
        }
        if(dsp->d_vectors)
        {
            temp = (t_int *)realloc(dsp->d_vectors, (size_t)(nins + nouts + 7) * sizeof(t_int));
        }
        else
        {
            temp = (t_int *)malloc((size_t)(nins + nouts + 7) * sizeof(t_int));
        }
        if(!temp)
        {
            if(dsp->d_vectors)
            {
                free(dsp->d_vectors);
                dsp->d_vectors = NULL;
            }
            free(dsp->d_sigs_real);
            dsp->d_sigs_real = NULL;
            free(dsp->d_sigs_out);
            dsp->d_sigs_out = NULL;
            dsp->d_size = 0;
            pd_error(x, "can't allocate memory for dsp vector.");
            return;
        }
        dsp->d_vectors = temp;
        dsp->d_size = nins + nouts + 7;
        count = (short*)malloc((size_t)(nins + nouts) * sizeof(short));
        if(count)
        {
            for(i = 0; i < (nins + nouts); i++)
            {
                count[i] = 0;
            }
            linetraverser_start(&t, eobj_getcanvas(x));
            while((oc = linetraverser_next(&t)))
            {
                if(t.tr_ob2 == x && obj_issignaloutlet(t.tr_ob, t.tr_outno))
                {
                    count[t.tr_inno] = 1;
                }
            }

            dsp->d_vectors[0] = (t_int)x;
            dsp->d_vectors[1] = (t_int)dsp;
            dsp->d_vectors[2] = (t_int)sp[0]->s_n;
            dsp->d_vectors[3] = (t_int)dsp->d_flags;
            dsp->d_vectors[4] = (t_int)dsp->d_user_param;
            dsp->d_vectors[5] = (t_int)nins;
            dsp->d_vectors[6] = (t_int)nouts;

            for(i = 7; i < dsp->d_size; i++)
            {
                if(sp[i - 7] && sp[i - 7]->s_vec)
                {
                    dsp->d_vectors[i] = (t_int)(sp[i - 7]->s_vec);
                }
                else
                {
                    free(count);
                    free(dsp->d_vectors);
                    dsp->d_vectors = NULL;
                    free(dsp->d_sigs_real);
                    dsp->d_sigs_real = NULL;
                    free(dsp->d_sigs_out);
                    dsp->d_sigs_out = NULL;
                    dsp->d_size = 0;
                    pd_error(x, "one of the signal isn't allocated.");
                    return;
                }
            }

            c->c_widget.w_dsp(x, x, count, sp[0]->s_sr, sp[0]->s_n, 0);
            if(dsp->d_perform_method != NULL && dsp->d_misc == E_INPLACE)
            {
                dsp_addv(eobj_perform_inplace, (int)dsp->d_size, dsp->d_vectors);
            }
            else if(dsp->d_perform_method != NULL && dsp->d_misc == E_NO_INPLACE)
            {
                dsp_addv(eobj_perform_noinplace, (int)dsp->d_size, dsp->d_vectors);
            }

            free(count);
            return;
        }
        else
        {
            free(dsp->d_vectors);
            dsp->d_vectors = NULL;
            free(dsp->d_sigs_real);
            dsp->d_sigs_real = NULL;
            free(dsp->d_sigs_out);
            dsp->d_sigs_out = NULL;
            dsp->d_size = 0;
            pd_error(x, "can't allocate memory for dsp chain counter.");
        }
    }
}