void *max_jit_peek_new(t_symbol *s, long argc, t_atom *argv) { t_max_jit_peek *x; long attrstart,i; t_atom a; if (x = (t_max_jit_peek *)max_jit_obex_new(max_jit_peek_class,NULL)) { //only max object, no jit object for (i=0; i<=JIT_MATRIX_MAX_DIMCOUNT+1; i++) x->vectors[i] = NULL; x->matrix_name = _jit_sym_nothing; x->dimcount = 2; x->plane = 0; x->interp = 0; x->normalize = 0; x->inperform = 0; x->mvalid = 0; x->mdata = 0; attrstart = max_jit_attr_args_offset(argc,argv); if (attrstart&&argv) { t_atom_long al; jit_atom_arg_getsym(&x->matrix_name, 0, attrstart, argv); if (!jit_atom_arg_getlong(&al, 1, attrstart, argv)) { C74_ASSERT_FITS_LONG(al); x->dimcount = (long) al; } if (!jit_atom_arg_getlong(&al, 2, attrstart, argv)) { C74_ASSERT_FITS_LONG(al); x->plane = (long) al; } jit_atom_setsym(&a,x->matrix_name); max_jit_peek_matrix_name(x,NULL,1,&a); } CLIP_ASSIGN(x->dimcount,0,JIT_MATRIX_MAX_DIMCOUNT); CLIP_ASSIGN(x->dimcount,0,32); //maximum signal inputs max_jit_attr_args(x,argc,argv); //handle attribute args dsp_setup((t_pxobject *)x,x->dimcount); max_jit_obex_dumpout_set(x, outlet_new(x,0L)); //general purpose outlet(rightmost) outlet_new((t_object *)x, "signal"); //signal output } return (x); }
t_jit_err jit_gl_hap_loadram(t_jit_gl_hap *x, t_symbol *s, long ac, t_atom *av) { t_atom_long al; t_atom_long from = 0, to = 0; short unload = (s == gensym("unloadram")); t_atom a; jit_atom_setlong(&a, 0); // 1 args end // 2 args = start, end if (x->movieloaded) { switch(ac) { case 1: if (!jit_atom_arg_getlong(&al, 0, ac, av)) { to = (t_atom_long) al; } case 2: if (!jit_atom_arg_getlong(&al, 0, ac, av)) { from = (t_atom_long) al; } if (!jit_atom_arg_getlong(&al, 1, ac, av)) { to = (t_atom_long) al; } break; default: break; } if(!jit_gl_hap_do_loadram(x, from, to, unload)) { jit_atom_setlong(&a, 1); } } jit_gl_hap_notify_atomarray_prep(x,s,1,&a); return JIT_ERR_NONE; }
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); }
////////////////////////////// Setters /////////////////////////////////////// t_jit_err jit_tml_fakeDepth_set(t_jit_tml_fakeDepth *x, void *attr, long argc, t_atom *argv) { long ss; if (argc != 1) { error("tml.ode.core: Quick Step is a scalar!"); return JIT_ERR_GENERIC; } //Make sure that the quickStep is either 0 or 1. jit_atom_arg_getlong(&ss, 0, 1, argv); if (ss != 0 && ss != 1) { error("jit.tml.fakeDepth: background is either 0 or 1. 0 no learning, 1 learn next frame."); return JIT_ERR_GENERIC; } return JIT_ERR_NONE; }
t_jit_err jit_tml_constellations_setThreshold(t_jit_tml_constellations *x, void *attr, long argc, t_atom *argv) { long ss; if (argc != 1) { error("jit.tml.constellations: threshold requires a scalar!"); return JIT_ERR_GENERIC; } jit_atom_arg_getlong(&ss, 0, 1, argv); if (ss < 0 || ss > 255) { error("jit.tml.constellations: Exceeded limit of threshold (0-255)!"); return JIT_ERR_GENERIC; } x->threshold = ss; return JIT_ERR_NONE; }
t_jit_err jit_tml_constellations_setMinBlobSize(t_jit_tml_constellations *x, void *attr, long argc, t_atom *argv) { long ss; if (argc != 1) { error("jit.tml.constellations: blob size requires a scalar!"); return JIT_ERR_GENERIC; } jit_atom_arg_getlong(&ss, 0, 1, argv); if (ss < 0 || ss > 1024*1024*1024) { error("jit.tml.constellations: Exceeded limit of blob size (0-1024*1024*1024)!"); return JIT_ERR_GENERIC; } x->minBlobSize = ss; return JIT_ERR_NONE; }
//Setters: t_jit_err jit_tml_constellations_setInvert(t_jit_tml_constellations *x, void *attr, long argc, t_atom *argv) { long ss; if (argc != 1) { error("jit.tml.constellations: invert requires a scalar!"); return JIT_ERR_GENERIC; } jit_atom_arg_getlong(&ss, 0, 1, argv); if (ss != 0 && ss != 1) { error("jit.tml.constellations: invert is 0=no, 1=yes"); return JIT_ERR_GENERIC; } x->invert = ss; return JIT_ERR_NONE; }
t_jit_err jit_tml_constellations_setRadius(t_jit_tml_constellations *x, void *attr, long argc, t_atom *argv) { long ss; if (argc != 1) { error("jit.tml.constellations: radius requires a scalar!"); return JIT_ERR_GENERIC; } jit_atom_arg_getlong(&ss, 0, 1, argv); if (ss < 0 || ss > 1024) { error("jit.tml.constellations: Radius too big (0, 1024)!"); return JIT_ERR_GENERIC; } x->radius = ss; return JIT_ERR_NONE; }
t_jit_err jit_tml_constellations_setPtCount(t_jit_tml_constellations *x, void *attr, long argc, t_atom *argv) { long ss; if (argc != 1) { error("jit.tml.constellations: ptCount requires a scalar!"); return JIT_ERR_GENERIC; } jit_atom_arg_getlong(&ss, 0, 1, argv); if (ss < 0) { error("jit.tml.constellations: Exceeded limit of ptCount ( < 0)!"); return JIT_ERR_GENERIC; } x->ptCount = ss; return JIT_ERR_NONE; }
t_jit_err jit_tml_constellations_setLearnRate(t_jit_tml_constellations *x, void *attr, long argc, t_atom *argv) { long ss; if (argc != 1) { error("jit.tml.constellations: threshold requires a scalar!"); return JIT_ERR_GENERIC; } jit_atom_arg_getlong(&ss, 0, 1, argv); if (ss < 0 || ss > 1024*1024*1024) { error("jit.tml.constellations: Exceeded limit of learning rate (0-1024*1024*1024)!"); return JIT_ERR_GENERIC; } x->learnRate = ss; return JIT_ERR_NONE; }
t_jit_err jit_tml_vp8_encode_setBitrate(t_jit_tml_vp8_encode *x, void *attr, long argc, t_atom *argv) { long ss; if (argc != 1) { error("jit.tml.vp8.encode: bitrate is a scalar!"); return JIT_ERR_GENERIC; } jit_atom_arg_getlong(&ss, 0, 1, argv); if (ss < 100) { error("jit.tml.rockeby: Very low (<100 kilobit) bitrates not recommended."); return JIT_ERR_GENERIC; } x->bitRate = ss; return JIT_ERR_NONE; }