void odisplay_anything(t_odisplay *x, t_symbol *msg, short argc, t_atom *argv) { t_atom av[argc + 1]; int ac = argc; if (msg) { ac = argc + 1; atom_setsym(av, msg); if (argc > 0) { memcpy(av + 1, argv, argc * sizeof(t_atom)); } } else { memcpy(av, argv, argc * sizeof(t_atom)); } t_osc_msg_u *m = NULL; t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&m, msg, argc, argv); if(e){ return; } t_osc_bndl_u *b = osc_bundle_u_alloc(); osc_bundle_u_addMsg(b, m); t_osc_bndl_s *bs = osc_bundle_u_serialize(b); odisplay_newBundle(x, b, bs); #ifdef OMAX_PD_VERSION x->draw_new_data_indicator = 1; x->have_new_data = 1; jbox_redraw((t_jbox *)x); #else x->draw_new_data_indicator = 1; x->have_new_data = 1; qelem_set(x->qelem); #endif }
void otimetag_anything(t_otimetag *x, t_symbol *selector, short argc, t_atom *argv) { t_osc_msg_u *msg = NULL; t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&msg, selector, argc, argv); if(e){ object_error((t_object *)x, "%s", osc_error_string(e)); return; } t_osc_bndl_u *bndl = osc_bundle_u_alloc(); osc_bundle_u_addMsg(bndl, msg); t_osc_bndl_s *bs = osc_bundle_u_serialize(bndl); if(bs){ otimetag_doFullPacket(x, osc_bundle_s_getLen(bs), osc_bundle_s_getPtr(bs)); osc_bundle_s_deepFree(bs); } osc_bundle_u_free(bndl); /* t_osc_msg_u *msg = NULL; t_symbol *address_sym = NULL; long osc_argc = argc; t_atom *osc_argv = argv; if(selector){ if(selector->s_name[0] == '/'){ address_sym = selector; } } if(!address_sym){ if(argc != 0){ if(atom_gettype(argv) != A_SYM){ object_error((t_object *)x, "first argument must be an OSC address"); return; } address_sym = atom_getsym(argv); if(address_sym->s_name[0] != '/'){ object_error((t_object *)x, "first argument must be an OSC address"); return; } osc_argc = argc - 1; osc_argv = argv + 1; }else{ object_error((t_object *)x, "first argument must be an OSC address"); return; } } omax_util_maxAtomsToOSCMsg_u(&msg, address_sym, osc_argc, osc_argv); t_osc_bndl_u *bndl = osc_bundle_u_alloc(); osc_bundle_u_addMsg(bndl, msg); long len = 0; char *buf = NULL; osc_bundle_u_serialize(bndl, &len, &buf); otimetag_doFullPacket(x, len, buf); if(buf){ osc_mem_free(buf); } osc_bundle_u_free(bndl); */ }
t_osc_bndl_u *ocontext_processPatcher(t_object *patcher) { t_osc_bndl_u *patcher_bndl = osc_bundle_u_alloc(); if(patcher == NULL){ // return empty bundle---this is intentional return patcher_bndl; } long nattrs = 0; t_symbol **attrs = NULL; object_attr_getnames(patcher, &nattrs, &attrs); for(int i = 0; i < nattrs; i++){ t_atom *av = NULL; long ac = 0; object_attr_getvalueof(patcher, attrs[i], &ac, &av); if(av && ac){ long addresslen = strlen(attrs[i]->s_name) + 2; char address[addresslen]; snprintf(address, addresslen, "/%s", attrs[i]->s_name); t_osc_msg_u *msg = NULL; if(ac == 1 && atom_gettype(av) == A_OBJ){ //printf("%s has object: %p %p\n", address, patcher, atom_getobj(av)); continue; t_osc_bndl_u *b = ocontext_processPatcher(atom_getobj(av)); if(b){ msg = osc_message_u_allocWithAddress(address); osc_message_u_appendBndl_u(msg, b); osc_bundle_u_addMsg(patcher_bndl, msg); } }else{ omax_util_maxAtomsToOSCMsg_u(&msg, gensym(address), ac, av); if(msg){ osc_bundle_u_addMsg(patcher_bndl, msg); } } } } sysmem_freeptr(attrs); t_symbol *maxclass = object_attr_getsym(patcher, gensym("maxclass")); if(maxclass && maxclass == gensym("jpatcher")){ patcher = jpatcher_get_parentpatcher(patcher); t_osc_bndl_u *parent_bndl = ocontext_processPatcher(patcher); t_osc_msg_u *msg = osc_message_u_allocWithAddress("/parent"); osc_message_u_appendBndl_u(msg, parent_bndl); osc_bundle_u_addMsg(patcher_bndl, msg); } return patcher_bndl; }
void olistenumerate_anything(t_olistenumerate *x, t_symbol *selector, short argc, t_atom *argv) { t_osc_msg_u *msg = NULL; t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&msg, selector, argc, argv); if(e){ object_error((t_object *)x, "%s", osc_error_string(e)); return; } t_osc_bndl_u *bndl = osc_bundle_u_alloc(); osc_bundle_u_addMsg(bndl, msg); t_osc_bndl_s *bs = osc_bundle_u_serialize(bndl); if(bs){ olistenumerate_doFullPacket(x, osc_bundle_s_getLen(bs), osc_bundle_s_getPtr(bs)); osc_bundle_s_deepFree(bs); } osc_bundle_u_free(bndl); }
void ocoll_anything(t_ocoll *x, t_symbol *msg, int argc, t_atom *argv) { t_osc_bndl_u *bndl_u = osc_bundle_u_alloc(); t_osc_msg_u *msg_u = NULL; t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&msg_u, msg, argc, argv); if(e){ object_error((t_object *)x, "%s", osc_error_string(e)); if(bndl_u){ osc_bundle_u_free(bndl_u); } return; } osc_bundle_u_addMsg(bndl_u, msg_u); t_osc_bndl_s *bs = osc_bundle_u_serialize(bndl_u); if(bndl_u){ osc_bundle_u_free(bndl_u); } ocoll_fullPacket_impl(x, osc_bundle_s_getLen(bs), osc_bundle_s_getPtr(bs)); if(bs){ osc_bundle_s_deepFree(bs); } }
t_osc_bndl_u *ocontext_processCanvas(t_canvas *canvas) { t_osc_bndl_u *canvas_bndl = osc_bundle_u_alloc(); if(canvas == NULL){ // return empty bundle---this is intentional return canvas_bndl; } t_osc_msg_u *msg = NULL; msg = osc_message_u_allocWithAddress("/name"); osc_message_u_appendString(msg, canvas->gl_name->s_name); osc_bundle_u_addMsg(canvas_bndl, msg); t_canvasenvironment *c_env = canvas_getenv(canvas); msg = osc_message_u_allocWithAddress("/path"); osc_message_u_appendString(msg, c_env->ce_dir->s_name); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/$0"); osc_message_u_appendInt32(msg, c_env->ce_dollarzero); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/isabstraction"); osc_message_u_appendBool(msg, !canvas_isabstraction(canvas)); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/editmode"); osc_message_u_appendBool(msg, canvas->gl_edit); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/font"); osc_message_u_appendString(msg, sys_font); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/fontsize"); osc_message_u_appendInt32(msg, canvas->gl_font); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/dirty"); osc_message_u_appendBool(msg, canvas->gl_dirty); osc_bundle_u_addMsg(canvas_bndl, msg); if(!canvas_isabstraction(canvas)) { msg = osc_message_u_allocWithAddress("/abstraction/position/x1"); osc_message_u_appendInt32(msg, canvas->gl_obj.te_xpix); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/abstraction/position/y1"); osc_message_u_appendInt32(msg, canvas->gl_obj.te_ypix); osc_bundle_u_addMsg(canvas_bndl, msg); } msg = osc_message_u_allocWithAddress("/pixwidth"); osc_message_u_appendInt32(msg, canvas->gl_pixwidth); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/pixheight"); osc_message_u_appendInt32(msg, canvas->gl_pixheight); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/screen/x1"); osc_message_u_appendInt32(msg, canvas->gl_screenx1); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/screen/y1"); osc_message_u_appendInt32(msg, canvas->gl_screeny1); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/screen/x2"); osc_message_u_appendInt32(msg, canvas->gl_screenx2); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/screen/y2"); osc_message_u_appendInt32(msg, canvas->gl_screeny2); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/xmargin"); osc_message_u_appendInt32(msg, canvas->gl_xmargin); osc_bundle_u_addMsg(canvas_bndl, msg); msg = osc_message_u_allocWithAddress("/ymargin"); osc_message_u_appendInt32(msg, canvas->gl_ymargin); osc_bundle_u_addMsg(canvas_bndl, msg); if(canvas->gl_goprect && canvas->gl_owner) { int x1,y1,x2,y2; gobj_getrect(&canvas->gl_obj.te_g, canvas->gl_owner, &x1, &y1, &x2, &y2); msg = osc_message_u_allocWithAddress("/graphrect"); osc_message_u_appendInt32(msg, x1); osc_message_u_appendInt32(msg, y1); osc_message_u_appendInt32(msg, x2); osc_message_u_appendInt32(msg, y2); osc_bundle_u_addMsg(canvas_bndl, msg); } t_binbuf *b = NULL; b = canvas->gl_obj.te_binbuf; if(b) { int argc = binbuf_getnatom(b); t_atom *argv = binbuf_getvec(b); if(argc) { t_osc_msg_u *msg_u = NULL; int abstr = !canvas_isabstraction(canvas); t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&msg_u, gensym("/arguments"), argc-1-abstr, argv+1+abstr); if(e) { if(e){ object_error((t_object *)x, "%s", osc_error_string(e)); goto exit; } } osc_bundle_u_addMsg(canvas_bndl, msg_u); } else { msg = osc_message_u_allocWithAddress("/arguments"); osc_message_u_appendString(msg, ""); osc_bundle_u_addMsg(canvas_bndl, msg); } } else { msg = osc_message_u_allocWithAddress("/arguments"); osc_message_u_appendString(msg, ""); osc_bundle_u_addMsg(canvas_bndl, msg); } exit: if(canvas->gl_owner) { t_osc_bndl_u *parent_bndl = ocontext_processCanvas(canvas->gl_owner); t_osc_msg_u *pmsg = osc_message_u_allocWithAddress("/parent"); osc_message_u_appendBndl_u(pmsg, parent_bndl); osc_bundle_u_addMsg(canvas_bndl, pmsg); } return canvas_bndl; }
void omax_outputState(t_object *x) { t_symbol *classname = object_classname(x); if(!classname){ return; } t_hashtab *ht = omax_class_getHashtab(classname->s_name); if(!ht){ return; } long nkeys = 0; t_symbol **keys = NULL; hashtab_getkeys(ht, &nkeys, &keys); t_osc_bndl_u *bndl_u = osc_bundle_u_alloc(); int i; for(i = 0; i < nkeys; i++){ if(osc_error_validateAddress(keys[i]->s_name)){ continue; } t_omax_method *m = NULL; hashtab_lookup(ht, keys[i], (t_object **)(&m)); if(!m){ continue; } if(m->type == OMAX_PARAMETER){ t_object *attr = object_attr_get(x, m->sym); long argc = 0; t_atom *argv = NULL; //m->m.m_fun(ob, attr, &argc, &argv); char getter[128]; sprintf(getter, "get%s", m->sym->s_name); long get; method f = object_attr_method(x, gensym(getter), (void **)(&attr), &get); if(f){ f(x, attr, &argc, &argv); if(argv){ char address[128]; sprintf(address, "/%s", m->sym->s_name); t_symbol *addresssym = gensym(address); t_osc_msg_u *msg_u = NULL; t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&msg_u, addresssym, argc, argv); if(e){ object_error((t_object *)x, "%s", osc_error_string(e)); if(bndl_u){ osc_bundle_u_free(bndl_u); } return; } osc_bundle_u_addMsg(bndl_u, msg_u); if(argv){ sysmem_freeptr(argv); } } } } } //long len = 0; //char *buf = NULL; t_osc_bndl_s *bs = osc_bundle_u_serialize(bndl_u); void *outlet = omax_object_getInfoOutlet(x); if(outlet && bs){ omax_util_outletOSC(outlet, osc_bundle_s_getLen(bs), osc_bundle_s_getPtr(bs)); osc_bundle_s_deepFree(bs); } if(bndl_u){ osc_bundle_u_free(bndl_u); } }
void omax_object_createIOReport(t_object *x, t_symbol *msg, int argc, t_atom *argv, long *buflen, char **buf) { t_symbol *classname = object_classname(x); if(!classname){ return; } t_hashtab *ht = omax_class_getHashtab(classname->s_name); if(!ht){ return; } long nkeys = 0; t_symbol **keys = NULL; hashtab_getkeys(ht, &nkeys, &keys); t_osc_bndl_u *bndl_u = osc_bundle_u_alloc(); int i; for(i = 0; i < nkeys; i++){ if(!osc_error_validateAddress(keys[i]->s_name)){ int j; for(j = 0; j < argc; j++){ t_atom *a = argv + j; if(atom_gettype(a) == A_SYM){ int ret = 0; int ao, po; if(atom_getsym(a) == gensym("/*")){ ret = OSC_MATCH_ADDRESS_COMPLETE; }else{ ret = osc_match(atom_getsym(a)->s_name, keys[i]->s_name, &po, &ao); } if(ret && OSC_MATCH_ADDRESS_COMPLETE){ t_omax_method *m = NULL; hashtab_lookup(ht, keys[i], (t_object **)(&m)); if(!m){ continue; } if(m->type == OMAX_PARAMETER){ t_object *attr = object_attr_get(x, m->sym); long argc = 0; t_atom *argv = NULL; //m->m.m_fun(ob, attr, &argc, &argv); char getter[128]; sprintf(getter, "get%s", m->sym->s_name); long get; method f = object_attr_method(x, gensym(getter), (void **)(&attr), &get); if(f){ f(x, attr, &argc, &argv); if(argv){ char address[128]; sprintf(address, "/%s", m->sym->s_name); t_atom a[argc + 1]; atom_setsym(a, gensym(address)); memcpy(a + 1, argv, argc * sizeof(t_atom)); t_osc_msg_u *msg_u = NULL; t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&msg_u, ps_oscioreport, argc + 1, a); if(e){ object_error((t_object *)x, "%s", osc_error_string(e)); if(bndl_u){ osc_bundle_u_free(bndl_u); } return; } osc_bundle_u_addMsg(bndl_u, msg_u); sysmem_freeptr(argv); } } } } } } } } //*buflen = pos; t_osc_bndl_s *bs = osc_bundle_u_serialize(bndl_u); if(bs){ *buflen = osc_bundle_s_getLen(bs); *buf = osc_bundle_s_getPtr(bs); osc_bundle_s_free(bs); } if(bndl_u){ osc_bundle_u_free(bndl_u); } }