void *max_jit_scissors_new(t_symbol *s, long argc, t_atom *argv) { t_max_jit_scissors *x; void *o, *p, *mop; t_jit_matrix_info info; long i; if (x=(t_max_jit_scissors *)max_jit_obex_new(max_jit_scissors_class, gensym("jit_scissors"))) { if (o=jit_object_new(gensym("jit_scissors"))) { max_jit_obex_jitob_set(x, o); max_jit_obex_dumpout_set(x, outlet_new(x, NULL)); max_jit_mop_setup(x); max_jit_mop_inputs(x); max_jit_attr_args(x, argc, argv); // get attr args to know rows and cols x->maxn = jit_attr_getlong(o, ps_rows) * jit_attr_getlong(o, ps_columns); max_jit_mop_variable_addoutputs(x, x->maxn); max_jit_mop_outputs(x); // don't forget the nolink! mop = max_jit_obex_adornment_get(x, _jit_sym_jit_mop); for (i = 1; i <= x->maxn; i++) jit_mop_output_nolink(mop, i); jit_attr_setlong(o, gensym("max"), x->maxn); max_jit_mop_matrix_args(x, argc, argv); // now set matrix info } else { jit_object_error((t_object *)x,"jit.scissors: could not allocate object"); freeobject((t_object *) x); x = NULL; } } return (x); }
void *max_jit_submatrix_new(t_symbol *s, long argc, t_atom *argv) { t_max_jit_submatrix *x; void *o,*m,*mop,*p; t_jit_matrix_info info; if (x=(t_max_jit_submatrix *)max_jit_obex_new(max_jit_submatrix_class,gensym("jit_submatrix"))) { if (o=jit_object_new(gensym("jit_submatrix"))) { max_jit_obex_jitob_set(x,o); max_jit_obex_dumpout_set(x,outlet_new(x,NULL)); max_jit_mop_setup(x); max_jit_mop_inputs(x); max_jit_mop_outputs(x); mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop); jit_attr_setlong(mop,gensym("adapt"),0); jit_attr_setlong(mop,gensym("caninplace"),0); jit_attr_setlong(mop,gensym("outputmode"),1); //make the output matrix a data reference w/NULL data pointer m = max_jit_mop_getoutput(x,1); jit_object_method(m,_jit_sym_getinfo,&info); jit_object_method(m,gensym("freedata")); info.flags = JIT_MATRIX_DATA_REFERENCE; info.size = 0; p = NULL; jit_object_method(m,_jit_sym_setinfo_ex,&info); jit_object_method(m,_jit_sym_data,p); max_jit_attr_args(x,argc,argv); } else { jit_object_error((t_object *)x,"jit.submatrix: could not allocate object"); freeobject((t_object *) x); x = NULL; } } return (x); }
void *max_jit_unpack_new(t_symbol *s, long argc, t_atom *argv) { t_max_jit_unpack *x; void *o,*m,*p,*mop; t_jit_matrix_info info; long i; if (x=(t_max_jit_unpack *)max_jit_obex_new(max_jit_unpack_class,gensym("jit_unpack"))) { if (o=jit_object_new(gensym("jit_unpack"))) { max_jit_obex_jitob_set(x,o); max_jit_obex_dumpout_set(x,outlet_new(x,NULL)); max_jit_mop_setup(x); max_jit_mop_inputs(x); if (argc&&(i=jit_atom_getlong(argv))) { CLIP(i,1,JIT_MATRIX_MAX_PLANECOUNT); } else { i=4; } x->outlets = i; max_jit_mop_variable_addoutputs(x,i); while (i) { p=max_jit_mop_getoutput(x,i); jit_attr_setlong(p,gensym("minplanecount"),1); jit_attr_setlong(p,gensym("maxplanecount"),1); i--; } max_jit_mop_outputs(x); max_jit_mop_matrix_args(x,argc,argv); //set adapt true if only plane argument(should come after matrix_args call) if ((max_jit_attr_args_offset(argc,argv)<=1) && (mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) { jit_attr_setlong(mop,_jit_sym_adapt,1); } max_jit_attr_args(x,argc,argv); } else { jit_object_error((t_object *)x,"jit.unpack: could not allocate object"); freeobject(x); x = NULL; } } return (x); }
void *max_jit_dmxmap_new(t_symbol *s, long argc, t_atom *argv) { t_max_jit_dmxmap *x; void *o,*m; t_jit_matrix_info info; long n; if (x = (t_max_jit_dmxmap *)max_jit_obex_new(class_max_jit_dmxmap,gensym("jit_dmxmap"))) { if (o=jit_object_new(gensym("jit_dmxmap"))) { attr_args_process(x, argc, argv); argc = attr_args_offset(argc, argv); max_jit_obex_jitob_set(x, o); max_jit_obex_dumpout_set(x, outlet_new(x,NULL)); max_jit_mop_setup(x); max_jit_mop_inputs(x); max_jit_mop_outputs(x); if(argc == 1) n = jit_atom_getlong(&argv[0]); else n = 512; m = max_jit_mop_getoutput(x, 1); jit_object_method(m, _jit_sym_getinfo, &info); info.type = _jit_sym_char; info.planecount = 1; info.dimcount = 1; info.dim[0] = n; info.dimstride[0] = 1; info.dimstride[1] = n; jit_object_method(m, _jit_sym_setinfo, &info); //max_jit_obex_jitob_set(x,o); //max_jit_attr_args(x,argc,argv); } else { jit_object_error((t_object *)x,"jit.dmxmap: out of memory"); freeobject((void *)x); x = NULL; goto out; } } out: return (x); }
void *max_jit_coerce_new(t_symbol *s, long argc, t_atom *argv) { t_max_jit_coerce *x; void *o,*m,*mop,*p; t_jit_matrix_info info; long attrstart; t_atom_long planecount=4; t_symbol *type=_jit_sym_char; if (x=(t_max_jit_coerce *)max_jit_obex_new(max_jit_coerce_class,gensym("jit_coerce"))) { if (o=jit_object_new(gensym("jit_coerce"))) { max_jit_obex_jitob_set(x,o); max_jit_obex_dumpout_set(x,outlet_new(x,NULL)); max_jit_mop_setup(x); max_jit_mop_inputs(x); max_jit_mop_outputs(x); mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop); jit_attr_setlong(mop,gensym("adapt"),0); jit_attr_setlong(mop,gensym("caninplace"),0); jit_attr_setlong(mop,gensym("outputmode"),1); //make the output matrix a data reference w/NULL data pointer attrstart = max_jit_attr_args_offset(argc,argv); if (attrstart&&argv) { jit_atom_arg_getlong(&planecount, 0, attrstart, argv); jit_atom_arg_getsym(&type, 1, attrstart, argv); jit_attr_setlong(o,_jit_sym_planecount,planecount); jit_attr_setsym(o,_jit_sym_type,type); } m = max_jit_mop_getoutput(x,1); jit_object_method(m,_jit_sym_getinfo,&info); jit_object_method(m,gensym("freedata")); info.flags = JIT_MATRIX_DATA_REFERENCE; info.size = 0; p = NULL; jit_object_method(m,_jit_sym_setinfo_ex,&info); jit_object_method(m,_jit_sym_data,p); max_jit_attr_args(x,argc,argv); } else { jit_object_error((t_object *)x,"jit.coerce: could not allocate object"); freeobject((t_object *) x); x = NULL; } } return (x); }
void *max_jit_openni_new(t_symbol *s, long argc, t_atom *argv) { t_max_jit_openni *x; void *o; long i; x = (t_max_jit_openni*)max_jit_obex_new(max_jit_openni_class, gensym("jit_openni")); if (x) { o = jit_object_new(gensym("jit_openni"), x); // instantiate jit.openni jitter object if (o) { // typically, max_jit_mop_setup_simple(x, o, argc, argv) is called here to handle standard MOP max wrapper setup tasks // however, I need to create a max only outlet between the MOP outlets and dumpout, so will use the code from MAx SDK 21.6. max_jit_obex_jitob_set(x,o); max_jit_obex_dumpout_set(x,outlet_new(x,NULL)); x->osc_outlet = (t_object *)outlet_new(x, NULL); max_jit_mop_setup(x); max_jit_mop_inputs(x); max_jit_mop_outputs(x); x->chrSkeletonOutputFormat = 0; max_jit_mop_matrix_args(x,argc,argv); max_jit_attr_args(x, argc, argv); // process attribute arguments, like auto handling of @attribute's #ifdef _DEBUG for (i = 0; i < argc; i++) { switch (atom_gettype(&(argv[i]))) { case A_LONG: LOG_COMMENT3("arg %ld: long (%ld)", i, atom_getlong(&(argv[i]))); break; case A_FLOAT: LOG_COMMENT3("arg %ld: float (%f)", i, atom_getfloat(&(argv[i]))); break; case A_SYM: LOG_COMMENT3("arg %ld: symbol (%s)", i, atom_getsym(&(argv[i]))->s_name); break; default: LOG_WARNING2("arg %ld: forbidden argument", i); } } #endif if(RegisterJitOpenNIEventCallbacks((t_jit_openni *)max_jit_obex_jitob_get(x), max_jit_openni_post_events, &(x->pRegistrationForEvents))) { LOG_ERROR("jit.openni: could not register for jit.openni event callbacks"); max_jit_openni_free(x); freeobject((t_object*)x); x = NULL; } else { LOG_DEBUG2("jit.openni: successfully registered for jit.openni event callbacks w/ regID=%x", x->pRegistrationForEvents); } } else { LOG_ERROR("jit.openni: could not allocate object"); max_jit_obex_free(x); freeobject((t_object*)x); x = NULL; } } return(x); }