t_ww *ww_new(t_symbol *s, short argc, t_atom *argv) { t_ww *x = NULL; t_object *box = NULL; x = (t_ww *)object_alloc(s_ww_class); if (x) { x->w_outlet = outlet_new(x, 0L); attr_args_process(x, argc, argv); object_obex_lookup(x, gensym("#P"), &x->w_patcher); object_obex_lookup(x, gensym("#B"), &box); // If/when instance methods are supported, we can use object_addmethod() to add the method // (as opposed to a class method) to our box. // Then we can be called when our box is moved. object_addmethod(box, (method)ww_boxscreenrectchanged, "boxscreenrectchanged", A_CANT, 0); // The patcherview is not available when the object is created as a patcher is being read from disk, // so we have to defer to wait for it before getting it and attaching for notifications. // if we were in a ui object then we would instead add a 'patcherview_vis' method // (and possibly a 'patcherview_invis' method) and attach to our patcherview at that time. defer_low(x, (method)ww_attach, NULL, 0, NULL); } return x; }
void HoaDecode_send_configuration(t_HoaDecode *x) { t_object *patcher; t_object *decoder; t_object *object; t_object *line; t_max_err err; err = object_obex_lookup(x, gensym("#P"), (t_object **)&patcher); if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&decoder); if (err != MAX_ERR_NONE) return; for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line)) { if (jpatchline_get_box1(line) == decoder) { object = jpatchline_get_box2(line); t_symbol* classname = object_classname(jbox_get_object(object)); if(classname == gensym("hoa.meter~") || classname == gensym("hoa.gain~") || classname == gensym("hoa.vector~")) { long argc = 1; t_atom *argv = new t_atom[1]; atom_setlong(argv, x->f_AmbisonicsDecoder->getNumberOfOutputs()); object_method_typed(jbox_get_object(object), gensym("channels"), argc, argv, NULL); free(argv); } } } }
void sheep_free(t_sheep *x) { t_object *jp; object_obex_lookup(x, gensym("#P"), &jp); // get the object's patcher if (jp) { t_hashtab *ht; // find the sheephash object_obex_lookup(jp, gensym("sheephash"), (t_object **)&ht); if (ht) { hashtab_chuckkey(ht, x->myobjname); // remove self from hashtab } } }
void iterator_bang(t_iterator *x) { t_object *jp; t_object *jb; t_object *mybox; t_object *o; t_rect jr; t_symbol *scriptingname; t_max_err err; // get the object's parent patcher err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp); if (err != MAX_ERR_NONE) return; // get the object's wrapping box err = object_obex_lookup(x, gensym("#B"), (t_object **)&mybox); if (err != MAX_ERR_NONE) return; jb = jpatcher_get_firstobject(jp); // get the first BOX in the object list while(jb) { jbox_get_patching_rect(jb, &jr); // x, y, width, height (double) object_post((t_object *)x, "found an object at %ld %ld, w %ld, h %ld", (long)jr.x, (long)jr.y, (long)jr.width, (long)jr.height); scriptingname = jbox_get_varname(jb); // scripting name if (scriptingname && scriptingname != gensym("")) object_post((t_object *)x, " it is named %s...", scriptingname->s_name); o = jbox_get_object(jb); // get the box's object (b_firstin in Max4) post(" it's a(n) %s object...", object_classname(o)->s_name); if (jpatcher_is_patcher(o)) { post(" which is some kind of a patcher. we could recurse here..."); } if (jb == mybox) post(" ...and it's me!"); jb = jbox_get_nextobject(jb); // iterate } // jbox_get_patcher(abox); // get a box's patcher // maybe upwards? jpatcher_get_parentpatcher(<#t_object * p#>) }
void posit_getinfo(t_posit *x) { t_object *jp; t_object *jb; t_object *pbox; t_rect jr; t_symbol *scriptingname = ps_none; t_symbol *patchername = ps_none; t_symbol *patcherscriptingname = ps_none; t_max_err err; t_symbol *classname; t_atom *outlist; outlist = x->p_outlist; err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp); // get the object's parent patcher if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&jb); // get the object's wrapping box if (err != MAX_ERR_NONE) return; patchername = jpatcher_get_name(jp); classname = jbox_get_maxclass(jb); // class name scriptingname = jbox_get_varname(jb); // scripting name if (scriptingname == NULL || scriptingname == ps_nothing) { scriptingname = ps_none; } pbox = jpatcher_get_box(jp); if(pbox) patcherscriptingname = jbox_get_varname(pbox); // scripting name if (patcherscriptingname == NULL || patcherscriptingname == ps_nothing) { patcherscriptingname = ps_none; } jbox_get_patching_rect(jb, &jr); // x, y, width, height (double) atom_setsym(outlist+0, classname); // class name atom_setsym(outlist+1, scriptingname); // scripting name atom_setlong(outlist+2, (long)((long)jr.x)); atom_setlong(outlist+3, (long)((long)jr.y)); atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height)); atom_setsym(outlist+6, patchername); // patcher name atom_setsym(outlist+7, patcherscriptingname); outlet_list(x->p_outlet,0L,8,outlist); outlet_bang(x->p_outlet2); //bang to notify of end of dump }
t_object* jamoma_object_getpatcher(t_object *obj) { t_object *patcher = NULL; object_obex_lookup(obj, gensym("#P"), &patcher); return patcher; }
/**@public @memberof t_OMax_learn * @brief Object instantiation */ void *OMax_learn_new(t_symbol *s, long argc, t_atom *argv) { t_OMax_learn *x = NULL; if (x = (t_OMax_learn *)object_alloc(OMax_learn_class)) { // inlets & outlets x->stateout = intout(x); ///@details Check first argument of the Max5 object for a FO name. x->obound = FALSE; if (argc == 0) object_error((t_object *)x,"Missing name of the Oracle to build"); else { if (argv->a_type != A_SYM) object_error((t_object *)x,"First argument must be a symbol (name of an existing Oracle)"); else x->oname = atom_getsym(argv); x->dataname = OMax_learn_dataname(x->oname); } // color t_object *box; t_jrgba colorvals; jrgba_set(&colorvals, 0.30, 1.0, 0.15, 1.0); object_obex_lookup((t_object *)x, gensym("#B"), &box); jbox_set_color(box, &colorvals); } return (x); }
t_max_err set_order(t_hoa_3d_scope *x, t_object *attr, long ac, t_atom *av) { long order; t_object *b = NULL; if (ac && av && atom_gettype(av) == A_LONG) { order = atom_getlong(av); if(order != x->f_scope->getDecompositionOrder() && order > 0) { object_method(hoa_sym_dsp->s_thing, hoa_sym_stop); delete x->f_scope; delete [] x->f_signals; x->f_scope = new Scope<Hoa3d, t_sample>(order, (ulong)(HOA_DISPLAY_NPOINTS * 0.25), (ulong)(HOA_DISPLAY_NPOINTS * 0.5)); x->f_order = x->f_scope->getDecompositionOrder(); x->f_signals = new double[x->f_scope->getNumberOfHarmonics() * SYS_MAXBLKSIZE]; object_obex_lookup(x, hoa_sym_pound_B, (t_object **)&b); object_method(b, hoa_sym_dynlet_begin); dsp_resize((t_pxobject*)x, x->f_scope->getNumberOfHarmonics()); object_method(b, hoa_sym_dynlet_end); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_background_layer); jbox_redraw((t_jbox *)x); } } return MAX_ERR_NONE; }
void HoaDecode_resize_outlet(t_HoaDecode *x, long lastNumberOfOutlet) { int dspState = sys_getdspobjdspstate((t_object*)x); if(dspState) object_method(gensym("dsp")->s_thing, gensym("stop")); t_object *b = NULL; object_obex_lookup(x, gensym("#B"), (t_object **)&b); object_method(b, gensym("dynlet_begin")); if(lastNumberOfOutlet > x->f_AmbisonicsDecoder->getNumberOfOutputs()) { for(int i = lastNumberOfOutlet; i > x->f_AmbisonicsDecoder->getNumberOfOutputs(); i--) { outlet_delete(outlet_nth((t_object*)x, i-1)); } } else if(lastNumberOfOutlet < x->f_AmbisonicsDecoder->getNumberOfOutputs()) { for(int i = lastNumberOfOutlet; i < x->f_AmbisonicsDecoder->getNumberOfOutputs(); i++) { outlet_append((t_object*)x, NULL, gensym("signal")); } } object_method(b, gensym("dynlet_end")); if(x->f_send_config) { HoaDecode_send_configuration(x); HoaDecode_send_angles(x); HoaDecode_reconnect_outlet(x); } }
// Start keeping track of edits and connections in the patcher void PackStartTracking(PackPtr self) { ObjectPtr patcher = NULL; ObjectPtr parent = NULL; ObjectPtr patcherview = NULL; MaxErr err; Atom result; // first find the top-level patcher err = object_obex_lookup(self, gensym("#P"), &patcher); parent = patcher; while (parent) { patcher = parent; parent = object_attr_getobj(patcher, _sym_parentpatcher); } // now iterate recursively from the top-level patcher down through all of the subpatchers object_method(patcher, gensym("iterate"), (method)PackIterateResetCallback, self, PI_DEEP, &result); object_method(patcher, gensym("iterate"), (method)PackIterateSetupCallback, self, PI_DEEP, &result); // now let's attach to the patcherview to get notifications about any further changes to the patch cords // the patcher 'dirty' attribute is not modified for each change, but the patcherview 'dirty' attribute is if (!self->patcherview) { patcherview = jpatcher_get_firstview(patcher); self->patcherview = patcherview; self->patcher = patcher; object_attach_byptr_register(self, patcherview, _sym_nobox); } // now we want to go a step further and attach to all of the patch cords // this is how we will know if one is deleted PackAttachToPatchlinesForPatcher(self, self->patcher); }
t_max_err set_order(t_hoa_scope *x, t_object *attr, long ac, t_atom *av) { long order; t_object *b = NULL; if (ac && av && atom_gettype(av) == A_LONG) { order = atom_getlong(av); if(order != x->f_scope->getOrder() && order > 0) { int dspState = sys_getdspobjdspstate((t_object*)x); if(dspState) object_method(gensym("dsp")->s_thing, hoa_sym_start); delete x->f_scope; delete [] x->f_signals; x->f_scope = new Hoa2D::Scope(order, NUMBEROFCIRCLEPOINTS_UI); x->f_order = x->f_scope->getOrder(); x->f_signals = new double[x->f_scope->getNumberOfHarmonics() * SYS_MAXBLKSIZE]; object_obex_lookup(x, gensym("#B"), (t_object **)&b); object_method(b, hoa_sym_dynlet_begin); dsp_resize((t_pxobject*)x, x->f_scope->getNumberOfHarmonics()); object_method(b, hoa_sym_dynlet_end); if(dspState) object_method(gensym("dsp")->s_thing, hoa_sym_stop); } } return MAX_ERR_NONE; }
void *sheep_new(t_symbol *s, long argc, t_atom *argv) { t_sheep *x = NULL; t_object *jp = NULL; if (x = (t_sheep *)object_alloc(sheep_class)) { jp = (t_object *)gensym("#P")->s_thing; if (jp) { t_hashtab *ht; // look in the jpatcher's obex for an object called "sheephash" object_obex_lookup(jp, gensym("sheephash"), (t_object **)&ht); if (!ht) { // it's not there? create it. ht = hashtab_new(0); // objects stored in the obex will be freed when the obex's owner is freed // in this case, when the patcher object is freed. so we don't need to // manage the memory associated with the "sheephash". object_obex_store(jp, gensym("sheephash"), (t_object *)ht); } // cache the registered name so we can remove self from hashtab x = object_register(CLASS_BOX, x->myobjname = symbol_unique(), x); // store self in the hashtab. IMPORTANT: set the OBJ_FLAG_REF flag so that the // hashtab knows not to free us when it is freed. hashtab_storeflags(ht, x->myobjname, (t_object *)x, OBJ_FLAG_REF); } } return (x); }
t_max_err hoa_meter_attr_set_loudspeakers(t_hoa_meter *x, t_object *attr, long ac, t_atom *av) { long d; t_object *b = NULL; if (ac && av) { if(atom_gettype(av) == A_LONG) { d = Hoa3D::clip_min(long(atom_getlong(av)), long(1)); if (d != x->f_number_of_loudspeakers) { int dspState = sys_getdspobjdspstate((t_object*)x); if(dspState) object_method(gensym("dsp")->s_thing, gensym("stop")); delete x->f_meter; delete [] x->f_signals; x->f_meter = new Hoa3D::Meter(x->f_number_of_loudspeakers, 100, 199); x->f_number_of_loudspeakers = x->f_meter->getNumberOfLoudspeakers(); x->f_signals = new double[x->f_meter->getNumberOfLoudspeakers() * SYS_MAXBLKSIZE]; object_obex_lookup(x, gensym("#B"), (t_object **)&b); object_method(b, gensym("dynlet_begin")); dsp_resize((t_pxobject*)x, x->f_meter->getNumberOfLoudspeakers()); object_method(b, gensym("dynlet_end")); if(dspState) object_method(gensym("dsp")->s_thing, gensym("start")); } } } return MAX_ERR_NONE; }
t_max_err channels_set(t_hoa_vector *x, t_object *attr, long argc, t_atom *argv) { t_object *b = NULL; if(argc && argv && atom_gettype(argv) == A_LONG) { int number_of_loudspeakers = atom_getlong(argv); if(number_of_loudspeakers != x->f_vector->getNumberOfChannels() && number_of_loudspeakers > 0 && number_of_loudspeakers <= MAX_CHANNELS) { object_method(gensym("dsp")->s_thing, hoa_sym_stop); delete x->f_vector; x->f_vector = new Hoa2D::Vector(number_of_loudspeakers); object_obex_lookup(x, gensym("#B"), (t_object **)&b); object_method(b, hoa_sym_dynlet_begin); dsp_resize((t_pxobject*)x, x->f_vector->getNumberOfChannels()); object_method(b, hoa_sym_dynlet_end); object_attr_setvalueof(x, hoa_sym_angles, 0, NULL); } } return MAX_ERR_NONE; }
void hoa_3d_decoder_resize_outlets(t_hoa_3d_decoder *x) { t_object *b = NULL; object_obex_lookup(x, hoa_sym_pound_B, (t_object **)&b); if (b) { object_method(hoa_sym_dsp->s_thing, hoa_sym_stop); object_method(b, hoa_sym_dynlet_begin); if(outlet_count((t_object *)x) > x->f_decoder->getNumberOfPlanewaves()) { for(int i = outlet_count((t_object *)x); i > x->f_decoder->getNumberOfPlanewaves(); i--) { outlet_delete(outlet_nth((t_object*)x, i-1)); } } else if(outlet_count((t_object *)x) < x->f_decoder->getNumberOfPlanewaves()) { for(int i = outlet_count((t_object *)x); i < x->f_decoder->getNumberOfPlanewaves(); i++) { outlet_append((t_object*)x, NULL, hoa_sym_signal); } } object_method(b, hoa_sym_dynlet_end); } }
PlugOutPtr PlugOutNew(SymbolPtr msg, AtomCount argc, AtomPtr argv) { PlugOutPtr self = PlugOutPtr(object_alloc(sPlugOutClass)); TTValue v; TTErr err; if (self) { v.setSize(2); v.set(0, TT("plugtastic.output")); v.set(1, 2); err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v); v = TTPtr(self->audioGraphObject); object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL)); self->audioGraphOutlet = outlet_new(self, "audio.connect"); self->qelem = qelem_new(self, (method)PlugOutQFn); object_obex_lookup(self, GENSYM("#P"), &self->patcher); self->pluginName = object_attr_getsym(self->patcher, _sym_name); self->pluginVersion = GENSYM("1.0"); self->pluginVersionHex = GENSYM("0x00010000"); self->pluginManufacturer = GENSYM("Plugtastic"); self->pluginManufacturerCode = GENSYM("74Ob"); self->pluginID = GENSYM("ftmp"); attr_args_process(self, argc, argv); } return self; }
void autocolorbox(t_object *x) { double color[4] = {0.7, 0.4, 0.3, 1.0}; t_object *box = NULL; object_obex_lookup(x, _sym_pound_B, &box); object_attr_setdouble_array(box, _sym_color, 4, color); }
void send_configuration(t_hoa_decoder *x) { t_object *patcher; t_object *decoder; t_object *object; t_object *line; t_max_err err; if(!x->f_send_config) return; err = object_obex_lookup(x, gensym("#P"), (t_object **)&patcher); if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&decoder); if (err != MAX_ERR_NONE) return; t_atom nchannels; t_atom offset; t_atom *argv = new t_atom[x->f_decoder->getNumberOfChannels()]; atom_setlong(&nchannels, x->f_decoder->getNumberOfChannels()); atom_setfloat(&offset, x->f_decoder->getChannelsOffset() / HOA_2PI * 360.); for(int i = 0; i < x->f_decoder->getNumberOfChannels(); i++) atom_setfloat(argv+i, x->f_decoder->getChannelAzimuth(i) / HOA_2PI * 360.); for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line)) { if (jpatchline_get_box1(line) == decoder) { object = jpatchline_get_box2(line); t_symbol* classname = object_classname(jbox_get_object(object)); if(classname == gensym("hoa.2d.meter~") || classname == gensym("hoa.meter~") || classname == gensym("hoa.2d.vector~")) { object_method_typed(jbox_get_object(object), gensym("channels"), 1, &nchannels, NULL); object_method_typed(jbox_get_object(object), gensym("angles"), x->f_decoder->getNumberOfChannels(), argv, NULL); object_method_typed(jbox_get_object(object), gensym("offset"), 1, &offset, NULL); } else if(classname == gensym("hoa.gain~")) object_method_typed(jbox_get_object(object), gensym("channels"), 1, &nchannels, NULL); } } free(argv); }
void posit_boxes(t_posit *x) // ok: done { t_object *jp; t_object *jb; t_object *mybox; t_rect jr; t_symbol *scriptingname; t_symbol *patchername; t_max_err err; t_symbol *classname; t_atom *outlist; outlist = x->p_outlist; err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp); // get the object's parent patcher if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&mybox); // get the object's wrapping box if (err != MAX_ERR_NONE) return; jb = jpatcher_get_firstobject(jp); // get the first BOX in the object list patchername = jpatcher_get_name(jp); while(jb) { // iterate through patcher classname = jbox_get_maxclass(jb); // class name scriptingname = jbox_get_varname(jb); // scripting name if (scriptingname == NULL || scriptingname == ps_nothing) { scriptingname = ps_none; } jbox_get_patching_rect(jb, &jr); // x, y, width, height (double) atom_setsym(outlist+0, classname); // class name atom_setsym(outlist+1, scriptingname); // scripting name atom_setlong(outlist+2, (long)((long)jr.x)); atom_setlong(outlist+3, (long)((long)jr.y)); atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height)); atom_setsym(outlist+6, patchername); // patcher name outlet_list(x->p_outlet,0L,7,outlist); jb = jbox_get_nextobject(jb); // iterate } outlet_bang(x->p_outlet2); //bang to notify of end of dump }
void scope_resize_inputs(t_scope *x, long newNumberOfInput) { newNumberOfInput = Tools::clip_min(newNumberOfInput, long(1)); t_object *b = NULL; object_obex_lookup(x, _sym_pound_B, (t_object **)&b); object_method(b, gensym("dynlet_begin")); dsp_resize((t_pxobject*)x, newNumberOfInput); object_method(b, gensym("dynlet_end")); }
void cmmjl_osc_makeDefaultAddress(void *x, long instance, char *buf){ char buf2[256], tmp[64]; t_patcher *p, *pp; t_box *b; t_symbol *name; char *ptr; int index; object_obex_lookup(x, gensym("#P"), (t_object **)&p); if(!p){ return; } name = jpatcher_get_name(p); if(name){ if(strcmp(name->s_name, "")){ // if this is a filename, get rid of the extension if(ptr = strrchr(name->s_name, '.')){ memset(tmp, '\0', 64); index = name->s_name - ptr; if(index < 0) index = -index; memcpy(tmp, name->s_name, index); sprintf(buf2, "/%s", tmp); }else{ sprintf(buf2, "/%s", name->s_name); } } }else{ // maybe we didn't wait long enough... } b = jpatcher_get_box(p); if(b){ while(p){ pp = jpatcher_get_parentpatcher(p); if(pp){ name = jpatcher_get_name(pp); if(name){ if(strcmp(name->s_name, "")){ if(ptr = strrchr(name->s_name, '.')){ memset(tmp, '\0', 64); index = name->s_name - ptr; if(index < 0) index = -index; memcpy(tmp, name->s_name, index); sprintf(buf, "/%s%s", tmp, buf2); }else{ sprintf(buf, "/%s%s", name->s_name, buf2); } } } } p = pp; strcpy(buf2, buf); } } }
void odisplay_doselect(t_odisplay *x){ t_object *p = NULL; object_obex_lookup(x,gensym("#P"), &p); if (p) { t_atom rv; long ac = 1; t_atom av[1]; atom_setobj(av, x); object_method_typed(p, gensym("selectbox"), ac, av, &rv); } }
void iterator_free(t_iterator *x) { t_object *jp = NULL; t_object *pv; // detach from any objects that you have attached to. object_obex_lookup(x, gensym("#P"), &jp); if (jp) { pv = jpatcher_get_firstview(jp); object_detach_byptr(x, pv); } }
void iterator_notify(t_iterator *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { // post("got %s message from %X (%s)", msg->s_name, sender, s->s_name); if (msg == gensym("attr_modified") && sender == x->a_patcherview) { // sent when an attribute of the sender changes t_symbol *attrname; // 'data' arg is the modified attribute object // get its name: attrname = (t_symbol *)object_method(data, gensym("getname")); post("'%s' attribute was modified", attrname->s_name); if (attrname == gensym("rect")) { t_atom *av = NULL; long ac = 0; object_attr_getvalueof(sender, attrname, &ac, &av); if (ac && av) { t_object *jb; post("new rect: %ld %ld %ld %ld", atom_getlong(av), atom_getlong(av+1), atom_getlong(av+2), atom_getlong(av+3)); object_obex_lookup(x, gensym("#B"), &jb); if (jb) { t_atom *rv = NULL; long rc = 0; object_attr_getvalueof(jb, gensym("patching_rect"), &rc, &rv); if (rc && rv) { // we have box rect // compare cached view size to current view long dx = atom_getlong(av+2) - x->a_cached.x; long dy = atom_getlong(av+3) - x->a_cached.y; long boxw = atom_getlong(rv+2); long boxh = atom_getlong(rv+3); // recache new size x->a_cached.x = atom_getlong(av+2); x->a_cached.y = atom_getlong(av+3); // modify my box width atom_setlong(rv+2, boxw + dx); // (height is ignored by jnewobj) atom_setlong(rv+3, boxh + dy); object_attr_setvalueof(jb, gensym("patching_rect"), rc, rv); freebytes(rv, sizeof(t_atom) * rc); } } freebytes(av, sizeof(t_atom) * ac); } } } }
void* testterminate_new(t_symbol *s, long argc, t_atom *argv) { t_testterminate *x = (t_testterminate*)object_alloc(s_testterminate_class); if (x) { object_obex_lookup(x, _sym_pound_P, &x->x_patcher); x->x_test = (t_test*)gensym("#T")->s_thing; attr_args_process(x, (short)argc, argv); } autocolorbox((t_object*)x); return x; }
TTErr PlugOutBuildGraph(PlugOutPtr self) { MaxErr err; ObjectPtr patcher = NULL; ObjectPtr parent = NULL; long result = 0; err = object_obex_lookup(self, GENSYM("#P"), &patcher); // first find the top-level patcher err = object_obex_lookup(self, GENSYM("#P"), &patcher); parent = patcher; while (parent) { patcher = parent; parent = object_attr_getobj(patcher, _sym_parentpatcher); } //object_method(patcher, gensym("iterate"), (method)PlugOutIterateResetCallback, self, PI_DEEP, &result); object_method(patcher, GENSYM("iterate"), (method)PlugOutIterateSetupCallback, self, PI_DEEP, &result); return kTTErrNone; }
void HoaDecode_reconnect_outlet(t_HoaDecode *x) { t_object *patcher; t_object *decoder; t_object *object; t_object *line; t_max_err err; err = object_obex_lookup(x, gensym("#P"), (t_object **)&patcher); if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&decoder); if (err != MAX_ERR_NONE) return; for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line)) { if (jpatchline_get_box1(line) == decoder) { object = jpatchline_get_box2(line); for(int i = 0; jbox_getinlet((t_jbox *)object, i) != NULL && i < x->f_AmbisonicsDecoder->getNumberOfOutputs(); i++) { t_atom msg[4]; t_atom rv; atom_setobj(msg, decoder); atom_setlong(msg + 1, i); atom_setobj(msg + 2, object); atom_setlong(msg + 3, i); object_method_typed(patcher , gensym("connect"), 4, msg, &rv); } } } }
void *iterator_new(t_symbol *s, long argc, t_atom *argv) { t_iterator *x = NULL; if ((x = (t_iterator *)object_alloc(iterator_class))) { // Get a pointer to our patcher object_obex_lookup(x, gensym("#P"), &x->a_patcher); // The patcherview is not available when the object is created as a patcher is being read from disk, // so we have to defer to wait for it before getting it and attaching for notifications. defer_low(x, (method)iterator_attach, NULL, 0, NULL); } return (x); }
void HoaDecode_disconnect_outlet(t_HoaDecode *x) { t_object *patcher; t_object *decoder; t_object *object; t_object *line; t_max_err err; err = object_obex_lookup(x, gensym("#P"), (t_object **)&patcher); if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&decoder); if (err != MAX_ERR_NONE) return; for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line)) { if (jpatchline_get_box1(line) == decoder) { object = jpatchline_get_box2(line); if(jpatchline_get_inletnum(line) != 0 && jpatchline_get_outletnum(line) != 0) { t_atom msg[4]; t_atom rv; atom_setobj(msg, decoder); atom_setlong(msg + 1, jpatchline_get_outletnum(line)); atom_setobj(msg + 2, object); atom_setlong(msg + 3, jpatchline_get_inletnum(line)); object_method_typed(patcher , gensym("disconnect"), 4, msg, &rv); } } } }
void HoaDecode_send_angles(t_HoaDecode *x) { t_object *patcher; t_object *decoder; t_object *object; t_object *line; t_max_err err; err = object_obex_lookup(x, gensym("#P"), (t_object **)&patcher); if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&decoder); if (err != MAX_ERR_NONE) return; for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line)) { if (jpatchline_get_box1(line) == decoder) { object = jpatchline_get_box2(line); t_symbol* classname = object_classname(jbox_get_object(object)); if(classname == gensym("hoa.meter~") || classname == gensym("hoa.gain~") || classname == gensym("hoa.vector~")) { long argc = x->f_AmbisonicsDecoder->getNumberOfOutputs(); t_atom *argv = new t_atom[argc]; for(int i = 0; i < argc; i++) atom_setfloat(argv+i, x->f_AmbisonicsDecoder->getLoudspeakerAngle(i)); object_method_typed(jbox_get_object(object), gensym("angles"), argc, argv, NULL); free(argv); } } } }