static void dac_set(t_dac *x, t_symbol *s, int argc, t_atom *argv) { int i; for (i = 0; i < argc && i < x->x_n; i++) x->x_vec[i] = atom_getintarg(i, argc, argv); canvas_update_dsp(); }
t_outconnect *obj_connect(t_object *source, int outno, t_object *sink, int inno) { //fprintf(stderr,"obj_connect\n"); t_inlet *i; t_outlet *o; t_pd *to; t_outconnect *oc, *oc2; /* ignore attempts to connect to the same object this occurs sometimes using undo/redo */ if (source == sink) return (0); for (o = source->ob_outlet; o && outno; o = o->o_next, outno--) ; if (!o) return (0); if (sink->ob_pd->c_firstin) { if (!inno) { to = &sink->ob_pd; goto doit; } else inno--; } for (i = sink->ob_inlet; i && inno; i = i->i_next, inno--) ; if (!i) return (0); to = &i->i_pd; doit: oc = (t_outconnect *)t_getbytes(sizeof(*oc)); oc->oc_next = 0; oc->oc_to = to; /* append it to the end of the list */ /* LATER we might cache the last "oc" to make this faster. */ if ((oc2 = o->o_connections)) { while (oc2->oc_next) oc2 = oc2->oc_next; oc2->oc_next = oc; } else o->o_connections = oc; if (o->o_sym == &s_signal) canvas_update_dsp(); return (oc); }
void obj_disconnect(t_object *source, int outno, t_object *sink, int inno) { t_inlet *i; t_outlet *o; t_pd *to; t_outconnect *oc, *oc2; for (o = source->ob_outlet; o && outno; o = o->o_next, outno--) ; if (!o) return; if (sink->ob_pd->c_firstin) { if (!inno) { to = &sink->ob_pd; goto doit; } else inno--; } for (i = sink->ob_inlet; i && inno; i = i->i_next, inno--) ; if (!i) return; to = &i->i_pd; doit: if (!(oc = o->o_connections)) return; if (oc->oc_to == to) { o->o_connections = oc->oc_next; freebytes(oc, sizeof(*oc)); goto done; } while ((oc2 = oc->oc_next)) { if (oc2->oc_to == to) { oc->oc_next = oc2->oc_next; freebytes(oc2, sizeof(*oc2)); goto done; } oc = oc2; } done: if (o->o_sym == &s_signal) canvas_update_dsp(); }
t_pd_err set_order(t_hoa_scope *x, t_object *attr, long ac, t_atom *av) { long order; if (ac && av && atom_gettype(av) == A_LONG) { order = atom_getlong(av); if(order != x->f_scope->getDecompositionOrder() && order > 0) { int dspState = canvas_suspend_dsp(); delete x->f_scope; delete [] x->f_signals; x->f_scope = new Hoa2D::Scope(order, NUMBEROFCIRCLEPOINTS_UI); x->f_order = x->f_scope->getDecompositionOrder(); x->f_signals = new t_float[x->f_scope->getNumberOfHarmonics() * SYS_MAXBLKSIZE]; eobj_resize_inputs((t_ebox *)x, x->f_scope->getNumberOfHarmonics()); canvas_update_dsp(); canvas_resume_dsp(dspState); } } return 0; }
/* delete an object from a glist and free it */ void glist_delete(t_glist *x, t_gobj *y) { t_gobj *g; t_object *ob; t_gotfn chkdsp = zgetfn(&y->g_pd, gensym("dsp")); t_canvas *canvas = glist_getcanvas(x); int drawcommand = class_isdrawcommand(y->g_pd); int wasdeleting; wasdeleting = canvas_setdeleting(canvas, 1); if (x->gl_editor) { if (x->gl_editor->e_grab == y) x->gl_editor->e_grab = 0; if (glist_isselected(x, y)) glist_deselect(x, y); /* HACK -- we had phantom outlets not getting erased on the screen because the canvas_setdeleting() mechanism is too crude. LATER carefully set up rules for when the rtexts should exist, so that they stay around until all the steps of becoming invisible are done. In the meantime, just zap the inlets and outlets here... */ if (pd_class(&y->g_pd) == canvas_class) { t_glist *gl = (t_glist *)y; if (gl->gl_isgraph && glist_isvisible(x)) { char tag[80]; sprintf(tag, "graph%lx", (t_int)gl); glist_eraseiofor(x, &gl->gl_obj, tag); } else { if (glist_isvisible(x)) text_eraseborder(&gl->gl_obj, x, rtext_gettag(glist_findrtext(x, &gl->gl_obj))); } } } /* if we're a drawing command, erase all scalars now, before deleting it; we'll redraw them once it's deleted below. */ if (drawcommand) canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym( glist_getcanvas(x)->gl_name)), 2); gobj_delete(y, x); if (glist_isvisible(canvas)) { gobj_vis(y, x, 0); } if (x->gl_editor && (ob = pd_checkobject(&y->g_pd))) rtext_new(x, ob); if (x->gl_list == y) x->gl_list = y->g_next; else for (g = x->gl_list; g; g = g->g_next) if (g->g_next == y) { g->g_next = y->g_next; break; } pd_free(&y->g_pd); if (chkdsp) canvas_update_dsp(); if (drawcommand) canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym( glist_getcanvas(x)->gl_name)), 1); canvas_setdeleting(canvas, wasdeleting); x->gl_valid = ++glist_valid; }