Max 5 API Reference
00001 #include "jit.common.h" 00002 #include "max.jit.mop.h" 00003 00004 #define JIT_MATRIX_PROBE_INTERVAL 100 //10fps probe 00005 00006 static t_object *g_jit_matrix_probe_obj=NULL; 00007 static void *g_jit_matrix_probe_qelem=NULL; 00008 static void *g_jit_matrix_probe_clock=NULL; 00009 static long g_jit_matrix_probe_outnum=0; 00010 void *max_jit_mop_jit_matrix_startprobe(t_object *o); 00011 void *max_jit_mop_jit_matrix_probevalue(t_object *o, long innum, long outnum, long *status, long *argc, t_atom **argv); 00012 void max_jit_mop_jit_matrix_endprobe(t_object *o); 00013 void max_jit_mop_jit_matrix_probe_tick(t_object *x); 00014 void max_jit_mop_jit_matrix_probe_qfn(t_object *x); 00015 00016 /** 00017 * @defgroup maxmopmod MOP Max Wrapper Module 00018 @ingroup jitter 00019 */ 00020 00021 /** 00022 * Adds default methods and attributes to the MOP Max wrapper class. 00023 * 00024 * @ingroup maxmopmod 00025 * 00026 * @param mclass max jit classex pointer returned from max_jit_classex_setup 00027 * @param jclass t_jit_class pointer, typcially returned from jit_class_findbyname 00028 * @param flags flags to override default MOP Max wrapper behavior 00029 * 00030 * @return t_jit_err error code 00031 * 00032 */ 00033 t_jit_err max_jit_classex_mop_wrap(void *mclass, void *jclass, long flags) 00034 { 00035 void *mop,*p,*attr; 00036 long i,incount,outcount,attrflags; 00037 char tmpstr[256]; 00038 t_symbol *name; 00039 00040 //grab mop stuff from jit class and add accordingly 00041 mop = jit_class_adornment_get(jclass,_jit_sym_jit_mop); 00042 incount = jit_attr_getlong(mop,_jit_sym_inputcount); 00043 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 00044 00045 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_JIT_MATRIX)) 00046 addmess((method)max_jit_mop_jit_matrix, "jit_matrix", A_GIMME,0); 00047 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_BANG)) 00048 addbang((method)max_jit_mop_bang); 00049 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_OUTPUTMATRIX)) 00050 max_addmethod_usurp_low((method)max_jit_mop_outputmatrix, "outputmatrix"); 00051 00052 attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW; 00053 00054 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_OUTPUTMODE)) { 00055 attr = jit_object_new(_jit_sym_jit_attr_offset,"outputmode",_jit_sym_char,attrflags, 00056 (method)max_jit_mop_getoutputmode_attr,(method)max_jit_mop_outputmode,0/*custom*/); 00057 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00058 object_addattr_parse(attr,"style",_jit_sym_symbol,0,"enumindex"); 00059 object_addattr_parse(attr,"enumvals",_jit_sym_atom,0,"\"No Output\" Normal \"Pass Input\" \"Pass Output\""); 00060 max_jit_classex_addattr(mclass,attr); 00061 } 00062 00063 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_ADAPT)) { 00064 attr = jit_object_new(_jit_sym_jit_attr_offset,"adapt",_jit_sym_char,attrflags, 00065 (method)max_jit_mop_getadapt,(method)max_jit_mop_adapt,0/*custom*/); 00066 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00067 object_addattr_parse(attr,"style",_jit_sym_symbol,0,"onoff"); 00068 max_jit_classex_addattr(mclass,attr); 00069 } 00070 00071 // for each input/output 00072 // should be different if the object is not all input linked 00073 for (i=2;i<=incount;i++) { 00074 if (p=jit_object_method(mop,_jit_sym_getinput,i)) { 00075 name = jit_attr_getsym(p,_jit_sym_ioname); 00076 00077 sprintf(tmpstr,"%s_name",name->s_name); 00078 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_NAME)) { 00079 attr = jit_object_new(_jit_sym_jit_attr_offset,tmpstr,_jit_sym_symbol,attrflags, 00080 (method)max_jit_mop_getname,(method)max_jit_mop_name,0/*custom*/); 00081 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00082 max_jit_classex_addattr(mclass,attr); 00083 } 00084 00085 sprintf(tmpstr,"%s_type",name->s_name); 00086 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_TYPE)) { 00087 attr = jit_object_new(_jit_sym_jit_attr_offset,tmpstr,_jit_sym_symbol,attrflags, 00088 (method)max_jit_mop_gettype,(method)max_jit_mop_type,0/*custom*/); 00089 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00090 object_addattr_parse(attr,"style",_jit_sym_symbol,0,"enum"); 00091 object_addattr_parse(attr,"enumvals",_jit_sym_atom,0,"char long float32 float64"); 00092 max_jit_classex_addattr(mclass,attr); 00093 } 00094 00095 sprintf(tmpstr,"%s_dim",name->s_name); 00096 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_DIM)){ 00097 attr = jit_object_new(_jit_sym_jit_attr_offset_array,tmpstr,_jit_sym_long,JIT_MATRIX_MAX_DIMCOUNT,attrflags, 00098 (method)max_jit_mop_getdim,(method)max_jit_mop_dim,0/*custom*/); 00099 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00100 max_jit_classex_addattr(mclass,attr); 00101 } 00102 00103 sprintf(tmpstr,"%s_planecount",name->s_name); 00104 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_PLANECOUNT)) { 00105 attr = jit_object_new(_jit_sym_jit_attr_offset,tmpstr,_jit_sym_long,attrflags, 00106 (method)max_jit_mop_getplanecount,(method)max_jit_mop_planecount,0/*custom*/); 00107 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00108 object_addattr_parse(attr,"style",_jit_sym_symbol,0,"enum"); 00109 object_addattr_parse(attr,"enumvals",_jit_sym_atom,0,"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32"); 00110 max_jit_classex_addattr(mclass,attr); 00111 } 00112 } 00113 } 00114 00115 if (outcount!=0) { 00116 // supports negative number for variable outputs 00117 addmess((method)max_jit_mop_jit_matrix_startprobe, "jit_matrix_startprobe", A_CANT,0); 00118 addmess((method)max_jit_mop_jit_matrix_probevalue, "jit_matrix_probevalue", A_CANT,0); 00119 addmess((method)max_jit_mop_jit_matrix_endprobe, "jit_matrix_endprobe", A_CANT,0); 00120 } 00121 00122 if (outcount>0) { 00123 if (p=jit_object_method(mop,_jit_sym_getoutput,1)) { 00124 name = jit_attr_getsym(p,_jit_sym_ioname); 00125 00126 sprintf(tmpstr,"%s_name",name->s_name); 00127 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_NAME)) { 00128 attr = jit_object_new(_jit_sym_jit_attr_offset,tmpstr,_jit_sym_symbol,attrflags, 00129 (method)max_jit_mop_getname,(method)max_jit_mop_name,0/*custom*/); 00130 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00131 max_jit_classex_addattr(mclass,attr); 00132 } 00133 00134 sprintf(tmpstr,"type"); 00135 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_TYPE)) { 00136 attr = jit_object_new(_jit_sym_jit_attr_offset,tmpstr,_jit_sym_symbol,attrflags, 00137 (method)max_jit_mop_gettype,(method)max_jit_mop_type,0/*custom*/); 00138 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00139 object_addattr_parse(attr,"style",_jit_sym_symbol,0,"enum"); 00140 object_addattr_parse(attr,"enumvals",_jit_sym_atom,0,"char long float32 float64"); 00141 max_jit_classex_addattr(mclass,attr); 00142 } 00143 00144 sprintf(tmpstr,"dim"); 00145 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_DIM)){ 00146 attr = jit_object_new(_jit_sym_jit_attr_offset_array,tmpstr,_jit_sym_long,JIT_MATRIX_MAX_DIMCOUNT,attrflags, 00147 (method)max_jit_mop_getdim,(method)max_jit_mop_dim,0/*custom*/); 00148 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00149 max_jit_classex_addattr(mclass,attr); 00150 } 00151 00152 sprintf(tmpstr,"planecount"); 00153 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_PLANECOUNT)) { 00154 attr = jit_object_new(_jit_sym_jit_attr_offset,tmpstr,_jit_sym_long,attrflags, 00155 (method)max_jit_mop_getplanecount,(method)max_jit_mop_planecount,0/*custom*/); 00156 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00157 object_addattr_parse(attr,"style",_jit_sym_symbol,0,"enum"); 00158 object_addattr_parse(attr,"enumvals",_jit_sym_atom,0,"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32"); 00159 max_jit_classex_addattr(mclass,attr); 00160 } 00161 } 00162 } 00163 00164 for (i=2;i<=outcount;i++) { 00165 if (p=jit_object_method(mop,_jit_sym_getoutput,i)) { 00166 name = jit_attr_getsym(p,_jit_sym_ioname); 00167 00168 sprintf(tmpstr,"%s_name",name->s_name); 00169 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_NAME)) { 00170 attr = jit_object_new(_jit_sym_jit_attr_offset,tmpstr,_jit_sym_symbol,attrflags, 00171 (method)max_jit_mop_getname,(method)max_jit_mop_name,0/*custom*/); 00172 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00173 max_jit_classex_addattr(mclass,attr); 00174 } 00175 00176 sprintf(tmpstr,"%s_type",name->s_name); 00177 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_TYPE)) { 00178 attr = jit_object_new(_jit_sym_jit_attr_offset,tmpstr,_jit_sym_symbol,attrflags, 00179 (method)max_jit_mop_gettype,(method)max_jit_mop_type,0/*custom*/); 00180 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00181 object_addattr_parse(attr,"style",_jit_sym_symbol,0,"enum"); 00182 object_addattr_parse(attr,"enumvals",_jit_sym_atom,0,"char long float32 float64"); 00183 max_jit_classex_addattr(mclass,attr); 00184 } 00185 00186 sprintf(tmpstr,"%s_dim",name->s_name); 00187 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_DIM)){ 00188 attr = jit_object_new(_jit_sym_jit_attr_offset_array,tmpstr,_jit_sym_long,JIT_MATRIX_MAX_DIMCOUNT,attrflags, 00189 (method)max_jit_mop_getdim,(method)max_jit_mop_dim,0/*custom*/); 00190 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00191 max_jit_classex_addattr(mclass,attr); 00192 } 00193 00194 sprintf(tmpstr,"%s_planecount",name->s_name); 00195 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_PLANECOUNT)) { 00196 attr = jit_object_new(_jit_sym_jit_attr_offset,tmpstr,_jit_sym_long,attrflags, 00197 (method)max_jit_mop_getplanecount,(method)max_jit_mop_planecount,0/*custom*/); 00198 object_addattr_parse(attr,"category",_jit_sym_symbol,0,"MOP"); 00199 object_addattr_parse(attr,"style",_jit_sym_symbol,0,"enum"); 00200 object_addattr_parse(attr,"enumvals",_jit_sym_atom,0,"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32"); 00201 max_jit_classex_addattr(mclass,attr); 00202 } 00203 } 00204 } 00205 00206 //otherwise if variable inputs/outputs, homies gotta do this themselves 00207 00208 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_CLEAR)) 00209 max_addmethod_defer_low((method)max_jit_mop_clear, "clear"); 00210 if (!(flags&MAX_JIT_MOP_FLAGS_OWN_NOTIFY)) 00211 addmess((method)max_jit_mop_notify, "notify", A_CANT,0); 00212 00213 return JIT_ERR_NONE; 00214 } 00215 00216 t_jit_err max_jit_mop_variable_anything(void *x, t_symbol *s, long argc, t_atom *argv) 00217 { 00218 long i,iotype,idx,set,ac=0; 00219 t_symbol *msg=NULL,*name,*name2; 00220 t_atom *av=NULL,a; 00221 char tmpstr[256]; 00222 void *mop,*m,*n,*o,*p; 00223 t_jit_matrix_info info; 00224 00225 if (!x||!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00226 return JIT_ERR_INVALID_PTR; 00227 00228 max_jit_mop_variable_parse_sym(s,&msg,&set); 00229 if (!msg) 00230 return JIT_ERR_GENERIC; 00231 00232 if (set) { 00233 max_jit_mop_parse_name(s,&iotype,&idx); 00234 } else { 00235 max_jit_mop_parse_name(gensym(s->s_name+3),&iotype,&idx); //strip get 00236 } 00237 00238 if (idx!=0) { 00239 switch (iotype) { 00240 case JIT_MOP_INPUT: 00241 if (idx>=2) p=jit_object_method(mop,_jit_sym_getinput,idx); 00242 break; 00243 case JIT_MOP_OUTPUT: 00244 if (idx>=1) p=jit_object_method(mop,_jit_sym_getoutput,idx); 00245 break; 00246 } 00247 00248 if (p) { 00249 if (set) { 00250 if (msg==_jit_sym_name) { 00251 if (argc&&argv) { 00252 name = jit_atom_getsym(argv); 00253 } 00254 00255 if (name==_jit_sym_nothing) { 00256 name = jit_symbol_unique(); 00257 } 00258 00259 //if already something registered with this name, check class_jit_matrix, and handle accordingly 00260 if (n=jit_object_findregistered(name)) { 00261 if (!jit_object_method(n,_jit_sym_class_jit_matrix)) { 00262 jit_object_error((t_object *)x,"%s exists and is not a matrix",name); 00263 return JIT_ERR_GENERIC; 00264 } 00265 } 00266 00267 m=jit_object_method(p,_jit_sym_getmatrix); 00268 name2 = jit_attr_getsym(p,_jit_sym_matrixname); 00269 if (name==name2) { 00270 //same name...check matrix pointer just in case 00271 if (m!=n) jit_object_error((t_object *)x,"loss of matrix sync %s",name); 00272 } else { 00273 //if matrix is null, and the named instance doesn't already exist, allocate a new one 00274 if (!m&&!n) { 00275 jit_matrix_info_default(&info); 00276 max_jit_mop_restrict_info(x,p,&info); 00277 m = jit_object_new(_jit_sym_jit_matrix, &info); 00278 } 00279 //could warn user here if incompatible type/dim/planecount 00280 jit_object_detach(name, x); 00281 jit_attr_setsym(p,_jit_sym_matrixname,name); 00282 jit_object_method(p,_jit_sym_matrix,jit_object_method(m,_jit_sym_register,name)); 00283 jit_object_attach(name, x); 00284 } 00285 } else { 00286 if ((m=jit_object_method(p,_jit_sym_getmatrix))) { 00287 jit_object_method(m,_jit_sym_getinfo,&info); 00288 if (msg==_jit_sym_type) { 00289 info.type = jit_atom_getsym(argv); 00290 jit_object_method(p,_jit_sym_restrict_type,&info); 00291 } else if (msg==_jit_sym_planecount) { 00292 info.planecount = jit_atom_getlong(argv); 00293 jit_object_method(p,_jit_sym_restrict_planecount,&info); 00294 } else if (msg==_jit_sym_dim) { 00295 CLIP(argc,0,JIT_MATRIX_MAX_DIMCOUNT); 00296 info.dimcount = argc; 00297 for (i=0;i<argc;i++) 00298 info.dim[i] = jit_atom_getlong(argv+i); 00299 for (;i<JIT_MATRIX_MAX_DIMCOUNT;i++) 00300 info.dim[i] = 1; 00301 jit_object_method(p,_jit_sym_restrict_dim,&info); 00302 } 00303 jit_object_method(m,_jit_sym_setinfo,&info); 00304 } 00305 } 00306 } else { 00307 if (msg==_jit_sym_name) { 00308 jit_atom_setsym(&a,jit_attr_getsym(p,_jit_sym_matrixname)); 00309 if (o=max_jit_obex_dumpout_get(x)) 00310 outlet_anything(o,msg,1,&a); 00311 } else { 00312 if ((m=jit_object_method(p,_jit_sym_getmatrix))) { 00313 sprintf(tmpstr,"get%s",msg->s_name); 00314 if (!jit_object_method(m,gensym(tmpstr),&ac,&av)) { 00315 if (o=max_jit_obex_dumpout_get(x)) 00316 outlet_anything(o,msg,ac,av); 00317 if (ac) 00318 jit_freebytes(av,sizeof(t_atom)*ac); 00319 } 00320 } 00321 } 00322 } 00323 } 00324 return JIT_ERR_NONE; 00325 } 00326 00327 return JIT_ERR_GENERIC; 00328 } 00329 00330 /** 00331 * Sets a custom matrix procedure for the MOP Max wrapper class. 00332 * 00333 * @ingroup maxmopmod 00334 * 00335 * @param mclass max jit classex pointer returned from max_jit_classex_setup 00336 * @param jclass t_jit_class pointer, typcially returned from jit_class_findbyname 00337 * @param mproc matrix procedure 00338 * 00339 * @return t_jit_err error code 00340 * 00341 */ 00342 t_jit_err max_jit_classex_mop_mproc(void *mclass, void *jclass, void *mproc) 00343 { 00344 void *mop; 00345 00346 if (!mclass||!jclass) 00347 return JIT_ERR_INVALID_PTR; 00348 mop = jit_class_adornment_get(jclass,_jit_sym_jit_mop); 00349 return (t_jit_err) jit_object_method(mop,_jit_sym_special,mproc); 00350 } 00351 00352 00353 /** 00354 * Sets up necessary resources for MOP Max wrapper object. 00355 * 00356 * @ingroup maxmopmod 00357 * 00358 * @param x Max object pointer 00359 * 00360 * @return t_jit_err error code 00361 * 00362 */ 00363 t_jit_err max_jit_mop_setup(void *x) 00364 { 00365 void *mc,*mo,*jclass; 00366 00367 if (x&&(mc=jit_class_adornment_get(jit_object_class(max_jit_obex_jitob_get(x)),_jit_sym_jit_mop))) 00368 { 00369 if (mo=jit_object_method(mc,_jit_sym_newcopy)) 00370 max_jit_obex_addadornment(x,mo); 00371 } 00372 return JIT_ERR_NONE; 00373 } 00374 00375 /** 00376 * Sets the number of inputs for a variable input MOP Max wrapper object. 00377 * 00378 * @ingroup maxmopmod 00379 * 00380 * @param x Max object pointer 00381 * @param c inlet count 00382 * 00383 * @return t_jit_err error code 00384 * 00385 */ 00386 t_jit_err max_jit_mop_variable_addinputs(void *x, long c) 00387 { 00388 void *mop; 00389 00390 if (x&&(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00391 { 00392 return (t_jit_err) jit_object_method(mop,gensym("addinputs"),c); 00393 } 00394 return JIT_ERR_INVALID_PTR; 00395 } 00396 00397 /** 00398 * Sets the number of outputs for a variable input MOP Max wrapper object. 00399 * 00400 * @ingroup maxmopmod 00401 * 00402 * @param x Max object pointer 00403 * @param c inlet count 00404 * 00405 * @return t_jit_err error code 00406 * 00407 */ 00408 t_jit_err max_jit_mop_variable_addoutputs(void *x, long c) 00409 { 00410 void *mop; 00411 00412 if (x&&(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00413 { 00414 return (t_jit_err) jit_object_method(mop,gensym("addoutputs"),c); 00415 } 00416 return JIT_ERR_INVALID_PTR; 00417 } 00418 00419 00420 /** 00421 * Creates input resources for a MOP Max wrapper object. 00422 * 00423 * @ingroup maxmopmod 00424 * 00425 * @param x Max object pointer 00426 * 00427 * @return t_jit_err error code 00428 * 00429 */ 00430 t_jit_err max_jit_mop_inputs(void *x) 00431 { 00432 void *mop,*p,*m; 00433 long i,incount; 00434 t_jit_matrix_info info; 00435 t_symbol *name; 00436 00437 if (x&&(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00438 { 00439 incount = jit_attr_getlong(mop,_jit_sym_inputcount); 00440 for (i=2;i<=incount;i++) { 00441 max_jit_obex_proxy_new(x,(incount+1)-i); //right to left 00442 if (p=jit_object_method(mop,_jit_sym_getinput,i)) { 00443 jit_matrix_info_default(&info); 00444 max_jit_mop_restrict_info(x,p,&info); 00445 name = jit_symbol_unique(); 00446 m = jit_object_new(_jit_sym_jit_matrix,&info); 00447 m = jit_object_register(m,name); 00448 jit_attr_setsym(p,_jit_sym_matrixname,name); 00449 jit_object_method(p,_jit_sym_matrix,m); 00450 jit_object_attach(name, x); 00451 } 00452 } 00453 return JIT_ERR_NONE; 00454 } 00455 return JIT_ERR_INVALID_PTR; 00456 } 00457 00458 /** 00459 * Creates output resources for a MOP Max wrapper object. 00460 * 00461 * @ingroup maxmopmod 00462 * 00463 * @param x Max object pointer 00464 * 00465 * @return t_jit_err error code 00466 * 00467 */ 00468 t_jit_err max_jit_mop_outputs(void *x) 00469 { 00470 void *mop,*p,*m; 00471 long i,outcount; 00472 t_jit_matrix_info info; 00473 t_symbol *name; 00474 00475 if (x&&(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00476 { 00477 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 00478 for (i=1;i<=outcount;i++) { 00479 max_jit_mop_matrixout_new(x,(outcount)-i);//right to left 00480 if (p=jit_object_method(mop,_jit_sym_getoutput,i)) { 00481 jit_matrix_info_default(&info); 00482 max_jit_mop_restrict_info(x,p,&info); 00483 name = jit_symbol_unique(); 00484 m = jit_object_new(_jit_sym_jit_matrix,&info); 00485 m = jit_object_register(m,name); 00486 jit_attr_setsym(p,_jit_sym_matrixname,name); 00487 jit_object_method(p,_jit_sym_matrix,m); 00488 jit_object_attach(name, x); 00489 } 00490 } 00491 00492 return JIT_ERR_NONE; 00493 } 00494 return JIT_ERR_INVALID_PTR; 00495 } 00496 00497 /** 00498 * Creates matrix outlet for a MOP Max wrapper object. 00499 * 00500 * @ingroup maxmopmod 00501 * 00502 * @param x Max object pointer 00503 * @param c output index (zero based) 00504 * 00505 * @return t_jit_err error code 00506 * 00507 */ 00508 t_jit_err max_jit_mop_matrixout_new(void *x, long c) 00509 { 00510 void *mop,*p,*o; 00511 00512 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00513 return JIT_ERR_GENERIC; 00514 00515 if (p=jit_object_method(mop,_jit_sym_getoutput,c+1)) // 0 vs 1 based worlds. 00516 { 00517 o = outlet_new(x,"jit_matrix"); 00518 jit_object_method(p,_jit_sym_special,o); 00519 } 00520 00521 return JIT_ERR_NONE; 00522 } 00523 00524 /** 00525 * Process matrix arguments for a MOP Max wrapper object. 00526 * 00527 * @ingroup maxmopmod 00528 * 00529 * @param x Max object pointer 00530 * @param argc argument count 00531 * @param argv argument vector 00532 * 00533 * @return t_jit_err error code 00534 * 00535 */ 00536 t_jit_err max_jit_mop_matrix_args(void *x, long argc, t_atom *argv) 00537 { 00538 void *mop,*p,*m; 00539 long incount,outcount,attrstart,i,j; 00540 t_jit_matrix_info info,info2; 00541 00542 //deal with matrix args 00543 //send to matrices if link flag is on 00544 //if args present set adapt to false 00545 00546 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00547 return JIT_ERR_GENERIC; 00548 00549 incount = jit_attr_getlong(mop,_jit_sym_inputcount); 00550 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 00551 00552 jit_matrix_info_default(&info); 00553 00554 attrstart = max_jit_attr_args_offset(argc,argv); 00555 if (attrstart&&argv) { 00556 jit_atom_arg_getlong(&info.planecount, 0, attrstart, argv); 00557 jit_atom_arg_getsym(&info.type, 1, attrstart, argv); 00558 i=2; j=0; 00559 while (i<attrstart) { //dimensions 00560 jit_atom_arg_getlong(&(info.dim[j]), i, attrstart, argv); 00561 i++; j++; 00562 } 00563 if (j) info.dimcount=j; 00564 00565 jit_attr_setlong(mop,_jit_sym_adapt,0); //adapt off 00566 } 00567 00568 jit_attr_setlong(mop,_jit_sym_outputmode,1); 00569 00570 for (i=2;i<=incount;i++) { 00571 if ((p=jit_object_method(mop,_jit_sym_getinput,i)) && 00572 (m=jit_object_method(p,_jit_sym_getmatrix))) 00573 { 00574 jit_object_method(m,_jit_sym_getinfo,&info2); 00575 if (jit_attr_getlong(p,_jit_sym_typelink)) { 00576 info2.type = info.type; 00577 } 00578 if (jit_attr_getlong(p,_jit_sym_planelink)) { 00579 info2.planecount = info.planecount; 00580 } 00581 if (jit_attr_getlong(p,_jit_sym_dimlink)) { 00582 info2.dimcount = info.dimcount; 00583 for (j=0;j<info2.dimcount;j++) { 00584 info2.dim[j] = info.dim[j]; 00585 } 00586 } 00587 max_jit_mop_restrict_info(x,p,&info2); 00588 jit_object_method(m,_jit_sym_setinfo,&info2); 00589 } 00590 } 00591 00592 for (i=1;i<=outcount;i++) { 00593 if ((p=jit_object_method(mop,_jit_sym_getoutput,i)) && 00594 (m=jit_object_method(p,_jit_sym_getmatrix))) 00595 { 00596 jit_object_method(m,_jit_sym_getinfo,&info2); 00597 if (jit_attr_getlong(p,_jit_sym_typelink)) { 00598 info2.type = info.type; 00599 } 00600 if (jit_attr_getlong(p,_jit_sym_planelink)) { 00601 info2.planecount = info.planecount; 00602 } 00603 if (jit_attr_getlong(p,_jit_sym_dimlink)) { 00604 info2.dimcount = info.dimcount; 00605 for (j=0;j<info2.dimcount;j++) { 00606 info2.dim[j] = info.dim[j]; 00607 } 00608 } 00609 max_jit_mop_restrict_info(x,p,&info2); 00610 jit_object_method(m,_jit_sym_setinfo,&info2); 00611 } 00612 } 00613 00614 return JIT_ERR_NONE; 00615 } 00616 00617 /** 00618 * Default jit_matrix method for a MOP Max wrapper object. 00619 * 00620 * @ingroup maxmopmod 00621 * 00622 * @param x Max object pointer 00623 * @param s message symbol ("jit_matrix") 00624 * @param argc argument count 00625 * @param argv argument vector 00626 * 00627 * @return t_jit_err error code 00628 * 00629 */ 00630 t_jit_err max_jit_mop_jit_matrix(void *x, t_symbol *s, long argc, t_atom *argv) 00631 { 00632 void *matrix,*matrixout,*mop,*o,*p,*m; 00633 t_atom a; 00634 t_symbol *matrixname; 00635 long err=JIT_ERR_NONE,inlet,i; 00636 method ioproc,mproc; 00637 00638 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00639 return JIT_ERR_GENERIC; 00640 00641 if (argc&&argv) { 00642 //find matrix 00643 matrixname = jit_atom_getsym(argv); 00644 matrix = jit_object_findregistered(matrixname); 00645 if (matrix&&jit_object_method(matrix, _jit_sym_class_jit_matrix)) { 00646 if (inlet=max_jit_obex_inletnumber_get(x)) { 00647 //right inputs 00648 if ((p=jit_object_method(mop,_jit_sym_getinput,inlet+1)) && 00649 (m=jit_object_method(p,_jit_sym_getmatrix))) 00650 { 00651 if (ioproc=(method)jit_object_method(p,_jit_sym_getioproc)) 00652 (*ioproc)(mop,p,matrix); 00653 else 00654 jit_object_method(m,_jit_sym_frommatrix,matrix,NULL); 00655 } else { 00656 err=JIT_ERR_GENERIC; 00657 } 00658 } else { 00659 //calculate 00660 switch (jit_attr_getlong(mop,_jit_sym_outputmode)) { 00661 case 0: //nada 00662 break; 00663 case 2: //input(no calc) 00664 //pass input through leftmost output 00665 if ((p=jit_object_method(mop,_jit_sym_getoutput,1)) && 00666 (o=max_jit_mop_io_getoutlet(p))) 00667 { 00668 outlet_anything(o,_jit_sym_jit_matrix,1,argv); 00669 } 00670 break; 00671 case 3: //output(no calc) 00672 max_jit_mop_outputmatrix(x); 00673 break; 00674 default: //calc 00675 //if adapt, resize 00676 if (jit_attr_getlong(mop,_jit_sym_adapt)) 00677 max_jit_mop_adapt_matrix_all(x,matrix); 00678 if ((p=jit_object_method(mop,_jit_sym_getoutput,1))&& 00679 (ioproc=(method)jit_object_method(p,_jit_sym_getioproc))) 00680 { 00681 (*ioproc)(mop,p,matrix); 00682 } 00683 p = jit_object_method(mop,_jit_sym_getinput,1); 00684 jit_object_method(p,_jit_sym_matrix,matrix); 00685 jit_attr_setsym(p,_jit_sym_matrixname,matrixname); 00686 if (mproc=(method)max_jit_mop_getmproc(mop)) { 00687 (*mproc)(x,mop); 00688 } else { 00689 if (err=(t_jit_err) jit_object_method( 00690 max_jit_obex_jitob_get(x), 00691 _jit_sym_matrix_calc, 00692 jit_object_method(mop,_jit_sym_getinputlist), 00693 jit_object_method(mop,_jit_sym_getoutputlist))) 00694 { 00695 jit_error_code(x,err); 00696 } else { 00697 max_jit_mop_outputmatrix(x); 00698 } 00699 } 00700 jit_object_method(p,_jit_sym_matrix,NULL); 00701 jit_attr_setsym(p,_jit_sym_matrixname,_jit_sym_nothing); 00702 break; 00703 } 00704 } 00705 } else { 00706 jit_error_code(x,JIT_ERR_MATRIX_UNKNOWN); 00707 } 00708 } 00709 00710 return err; 00711 } 00712 00713 /** 00714 * Default assist method for a MOP Max wrapper object. 00715 * 00716 * @ingroup maxmopmod 00717 * 00718 * @param x Max object pointer 00719 * @param b ignored 00720 * @param m inlet or outlet type 00721 * @param a index 00722 * @param s output string 00723 * 00724 * @return t_jit_err error code 00725 * 00726 */ 00727 t_jit_err max_jit_mop_assist(void *x, void *b, long m, long a, char *s) 00728 { 00729 void *mop,*p; 00730 00731 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00732 return JIT_ERR_GENERIC; 00733 00734 if (m == 1) { //input 00735 if (p=jit_object_method(mop,_jit_sym_getinput,a+1)) 00736 sprintf(s,"(matrix) %s",jit_attr_getsym(p,_jit_sym_ioname)->s_name); 00737 else 00738 return JIT_ERR_GENERIC; 00739 } else { //output 00740 if (p=jit_object_method(mop,_jit_sym_getoutput,a+1)) 00741 sprintf(s,"(matrix) %s",jit_attr_getsym(p,_jit_sym_ioname)->s_name); 00742 else { 00743 //dump outlet(alway righmost) 00744 //if (rightmost) 00745 sprintf(s,"dumpout"); 00746 //else 00747 // return JIT_ERR_GENERIC; 00748 } 00749 } 00750 00751 return JIT_ERR_NONE; 00752 } 00753 00754 /** 00755 * Default bang method for a MOP Max wrapper object. 00756 * 00757 * Simply calls the default outputmatrix method. 00758 * 00759 * @ingroup maxmopmod 00760 * 00761 * @param x Max object pointer 00762 * 00763 * @return t_jit_err error code 00764 * 00765 */ 00766 t_jit_err max_jit_mop_bang(void *x) 00767 { 00768 typedmess(x,_jit_sym_outputmatrix,0,0L); 00769 return JIT_ERR_NONE; 00770 } 00771 00772 /** 00773 * Default outputmatrix method for a MOP Max wrapper object. 00774 * 00775 * Calculates and outputs according to the MOP outputmode attribute. 00776 * 00777 * @ingroup maxmopmod 00778 * 00779 * @param x Max object pointer 00780 * 00781 * @return t_jit_err error code 00782 * 00783 */ 00784 t_jit_err max_jit_mop_outputmatrix(void *x) 00785 { 00786 t_atom a; 00787 void *mop,*p,*o; 00788 long outcount,outputmode,i; 00789 00790 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00791 return JIT_ERR_GENERIC; 00792 00793 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 00794 outputmode = jit_attr_getlong(mop,_jit_sym_outputmode); 00795 00796 if (outputmode) { //always output unless output mode is none 00797 //right to left 00798 for (i=outcount;i>=1;i--) { 00799 if ((p=jit_object_method(mop,_jit_sym_getoutput,i)) && 00800 (o=max_jit_mop_io_getoutlet(p))) 00801 { 00802 jit_atom_setsym(&a,jit_attr_getsym(p,_jit_sym_matrixname)); 00803 outlet_anything(o,_jit_sym_jit_matrix,1,&a); 00804 } 00805 } 00806 } 00807 00808 return JIT_ERR_NONE; 00809 } 00810 00811 /** 00812 * Default clear method for a MOP Max wrapper object. 00813 * 00814 * Calls the clear method on all input and output matrices. 00815 * 00816 * @ingroup maxmopmod 00817 * 00818 * @param x Max object pointer 00819 * 00820 * @return t_jit_err error code 00821 * 00822 */ 00823 void max_jit_mop_clear(void *x) 00824 { 00825 void *mop,*p,*m; 00826 long incount,outcount,i; 00827 00828 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00829 return; 00830 00831 incount = jit_attr_getlong(mop,_jit_sym_inputcount); 00832 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 00833 00834 for (i=2;i<=incount;i++) { 00835 if ((p=jit_object_method(mop,_jit_sym_getinput,i)) && 00836 (m=jit_object_method(p,_jit_sym_getmatrix))) 00837 { 00838 jit_object_method(m,_jit_sym_clear); 00839 } 00840 } 00841 00842 for (i=1;i<=outcount;i++) { 00843 if ((p=jit_object_method(mop,_jit_sym_getoutput,i)) && 00844 (m=jit_object_method(p,_jit_sym_getmatrix))) 00845 { 00846 jit_object_method(m,_jit_sym_clear); 00847 } 00848 } 00849 } 00850 00851 /** 00852 * Default notify method for a MOP Max wrapper object. 00853 * 00854 * Handles any notification methods from any input and output matrix. 00855 * 00856 * @ingroup maxmopmod 00857 * 00858 * @param x Max object pointer 00859 * @param s notifier name 00860 * @param msg notification message 00861 * 00862 * @return t_jit_err error code 00863 * 00864 */ 00865 t_jit_err max_jit_mop_notify(void *x, t_symbol *s, t_symbol *msg) 00866 { 00867 void *mop,*p,*m; 00868 t_symbol *name; 00869 long incount,outcount,i; 00870 t_jit_matrix_info info; 00871 00872 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00873 return JIT_ERR_GENERIC; 00874 00875 incount = jit_attr_getlong(mop,_jit_sym_inputcount); 00876 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 00877 00878 if (msg==_jit_sym_free) { 00879 for (i=2;i<=incount;i++) { 00880 if (p=jit_object_method(mop,_jit_sym_getinput,i)) 00881 { 00882 name=jit_attr_getsym(p,_jit_sym_matrixname); 00883 if (s==name) { 00884 jit_object_method(jit_object_findregistered(s),_jit_sym_getinfo,&info); 00885 m = jit_object_new(_jit_sym_jit_matrix,&info); 00886 m = jit_object_register(m,name); 00887 name = m?jit_symbol_unique():NULL; 00888 jit_attr_setsym(p,_jit_sym_matrixname,name); 00889 jit_object_attach(name, x); 00890 } 00891 } 00892 } 00893 00894 for (i=1;i<=outcount;i++) { 00895 if (p=jit_object_method(mop,_jit_sym_getoutput,i)) 00896 { 00897 name=jit_attr_getsym(p,_jit_sym_matrixname); 00898 if (s==name) { 00899 jit_object_method(jit_object_findregistered(s),_jit_sym_getinfo,&info); 00900 m = jit_object_new(_jit_sym_jit_matrix,&info); 00901 m = jit_object_register(m,name); 00902 name = m?jit_symbol_unique():NULL; 00903 jit_attr_setsym(p,_jit_sym_matrixname,name); 00904 jit_object_attach(name, x); 00905 } 00906 } 00907 } 00908 } 00909 00910 return JIT_ERR_NONE; 00911 } 00912 00913 /** 00914 * Frees additional resources used by a MOP Max wrapper object. 00915 * 00916 * @ingroup maxmopmod 00917 * 00918 * @param x Max object pointer 00919 * 00920 */ 00921 void max_jit_mop_free(void *x) 00922 { 00923 void *mop,*p,*m; 00924 t_symbol *name; 00925 long incount,outcount,i; 00926 00927 if (x==g_jit_matrix_probe_obj) 00928 max_jit_mop_jit_matrix_endprobe(g_jit_matrix_probe_obj); 00929 00930 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00931 return; 00932 00933 incount = jit_attr_getlong(mop,_jit_sym_inputcount); 00934 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 00935 00936 if ((p=jit_object_method(mop,_jit_sym_getinput,1)) && 00937 (m=jit_object_method(p,_jit_sym_getmatrix))) 00938 { 00939 jit_attr_setsym(p,_jit_sym_matrixname,NULL); 00940 jit_object_method(p,_jit_sym_matrix,NULL); 00941 } 00942 00943 for (i=2;i<=incount;i++) { 00944 if ((p=jit_object_method(mop,_jit_sym_getinput,i)) && 00945 (m=jit_object_method(p,_jit_sym_getmatrix))) 00946 { 00947 name=jit_attr_getsym(p,_jit_sym_matrixname); 00948 jit_object_detach(name, x); 00949 jit_object_free(m); 00950 jit_attr_setsym(p,_jit_sym_matrixname,NULL); 00951 jit_object_method(p,_jit_sym_matrix,NULL); 00952 } 00953 } 00954 00955 for (i=1;i<=outcount;i++) { 00956 if ((p=jit_object_method(mop,_jit_sym_getoutput,i)) && 00957 (m=jit_object_method(p,_jit_sym_getmatrix))) 00958 { 00959 name=jit_attr_getsym(p,_jit_sym_matrixname); 00960 jit_object_detach(name, x); 00961 jit_object_free(m); 00962 jit_attr_setsym(p,_jit_sym_matrixname,NULL); 00963 jit_object_method(p,_jit_sym_matrix,NULL); 00964 } 00965 } 00966 } 00967 00968 //name/type/dim/planecount/adapt get/set accessors 00969 t_jit_err max_jit_mop_outputmode(void *x, void *attr, long argc, t_atom *argv) 00970 { 00971 void *mop; 00972 00973 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00974 return JIT_ERR_GENERIC; 00975 00976 return (t_jit_err) jit_object_method(mop,_jit_sym_outputmode,argc,argv); 00977 } 00978 00979 //stupid name since I goofed 00980 t_jit_err max_jit_mop_getoutputmode_attr(void *x, void *attr, long *argc, t_atom **argv) 00981 { 00982 void *mop; 00983 00984 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00985 return JIT_ERR_GENERIC; 00986 00987 return (t_jit_err) jit_object_method(mop,gensym("getoutputmode"),argc,argv); 00988 } 00989 00990 t_jit_err max_jit_mop_adapt(void *x, void *attr, long argc, t_atom *argv) 00991 { 00992 void *mop; 00993 00994 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 00995 return JIT_ERR_GENERIC; 00996 00997 return (t_jit_err) jit_object_method(mop,_jit_sym_adapt,argc,argv); 00998 } 00999 01000 t_jit_err max_jit_mop_getadapt(void *x, void *attr, long *argc, t_atom **argv) 01001 { 01002 void *mop; 01003 01004 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 01005 return JIT_ERR_GENERIC; 01006 01007 return (t_jit_err) jit_object_method(mop,gensym("getadapt"),argc,argv); 01008 } 01009 01010 t_jit_err max_jit_mop_name(void *x, void *attr, long argc, t_atom *argv) 01011 { 01012 void *mop,*p=NULL,*m,*n; 01013 t_symbol *name=_jit_sym_nothing,*name2,*s; 01014 long incount,outcount,iotype,idx; 01015 t_jit_matrix_info info; 01016 01017 s = jit_object_method(attr,_jit_sym_getname); 01018 01019 if (argc&&argv) { 01020 name = jit_atom_getsym(argv); 01021 } 01022 01023 if (name==_jit_sym_nothing) { 01024 name = jit_symbol_unique(); 01025 } 01026 01027 //if already something registered with this name, check class_jit_matrix, and handle accordingly 01028 if (n=jit_object_findregistered(name)) { 01029 if (!jit_object_method(n,_jit_sym_class_jit_matrix)) { 01030 jit_object_error((t_object *)x,"%s exists and is not a matrix",name); 01031 return JIT_ERR_GENERIC; 01032 } 01033 } 01034 01035 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 01036 return JIT_ERR_GENERIC; 01037 01038 max_jit_mop_parse_name(s, &iotype, &idx); 01039 01040 switch (iotype) { 01041 case JIT_MOP_INPUT: 01042 if (idx>=2) p=jit_object_method(mop,_jit_sym_getinput,idx); 01043 break; 01044 case JIT_MOP_OUTPUT: 01045 if (idx>=1) p=jit_object_method(mop,_jit_sym_getoutput,idx); 01046 break; 01047 } 01048 01049 if (p) { 01050 m=jit_object_method(p,_jit_sym_getmatrix); 01051 name2 = jit_attr_getsym(p,_jit_sym_matrixname); 01052 if (name==name2) { 01053 //same name...check matrix pointer just in case 01054 if (m!=n) jit_object_error((t_object *)x,"loss of matrix sync %s",name); 01055 } else { 01056 //if matrix is null, and the named instance doesn't already exist, allocate a new one 01057 if (!m&&!n) { 01058 jit_matrix_info_default(&info); 01059 max_jit_mop_restrict_info(x,p,&info); 01060 m = jit_object_new(_jit_sym_jit_matrix, &info); 01061 } 01062 //could warn user here if incompatible type/dim/planecount 01063 jit_object_detach(name2, x); 01064 jit_attr_setsym(p,_jit_sym_matrixname,name); 01065 jit_object_method(p,_jit_sym_matrix,jit_object_method(m,_jit_sym_register,name)); 01066 jit_object_attach(name, x); 01067 } 01068 } 01069 01070 return JIT_ERR_NONE; 01071 } 01072 01073 t_jit_err max_jit_mop_getname(void *x, void *attr, long *argc, t_atom **argv) 01074 { 01075 void *p; 01076 t_symbol *s; 01077 01078 s = jit_object_method(attr,_jit_sym_getname); 01079 01080 if (p=max_jit_mop_get_io_by_name(x,s)) { 01081 return (t_jit_err) jit_object_method(p,gensym("getmatrixname"),argc,argv); 01082 } 01083 01084 return JIT_ERR_GENERIC; 01085 } 01086 01087 01088 t_jit_err max_jit_mop_type(void *x, void *attr, long argc, t_atom *argv) 01089 { 01090 void *mop,*p,*m; 01091 t_symbol *type,*s; 01092 long incount,outcount,iotype,idx,i; 01093 t_jit_matrix_info info; 01094 01095 s = jit_object_method(attr,_jit_sym_getname); 01096 01097 if (!argc&&!argv) 01098 return JIT_ERR_GENERIC; 01099 01100 type = jit_atom_getsym(argv); 01101 01102 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 01103 return JIT_ERR_GENERIC; 01104 01105 max_jit_mop_parse_name(s, &iotype, &idx); 01106 01107 if (idx!=0) { 01108 switch (iotype) { 01109 case JIT_MOP_INPUT: 01110 if (idx>=2) p=jit_object_method(mop,_jit_sym_getinput,idx); 01111 break; 01112 case JIT_MOP_OUTPUT: 01113 if (idx>=1) p=jit_object_method(mop,_jit_sym_getoutput,idx); 01114 break; 01115 } 01116 01117 if (p) { 01118 m=jit_object_method(p,_jit_sym_getmatrix); 01119 if (m) { 01120 jit_object_method(m,_jit_sym_getinfo,&info); 01121 info.type = type; 01122 jit_object_method(p,_jit_sym_restrict_type,&info); 01123 jit_object_method(m,_jit_sym_setinfo,&info); 01124 } 01125 } 01126 } else { 01127 01128 incount = jit_attr_getlong(mop,_jit_sym_inputcount); 01129 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 01130 01131 for (i=2;i<=incount;i++) { 01132 if ((p=jit_object_method(mop,_jit_sym_getinput,i)) && 01133 (m=jit_object_method(p,_jit_sym_getmatrix)) && 01134 jit_attr_getlong(p,_jit_sym_typelink)) 01135 { 01136 jit_object_method(m,_jit_sym_getinfo,&info); 01137 info.type = type; 01138 jit_object_method(p,_jit_sym_restrict_type,&info); 01139 jit_object_method(m,_jit_sym_setinfo,&info); 01140 } 01141 } 01142 01143 for (i=1;i<=outcount;i++) { 01144 if ((p=jit_object_method(mop,_jit_sym_getoutput,i)) && 01145 (m=jit_object_method(p,_jit_sym_getmatrix)) && 01146 jit_attr_getlong(p,_jit_sym_typelink)) 01147 { 01148 jit_object_method(m,_jit_sym_getinfo,&info); 01149 info.type = type; 01150 jit_object_method(p,_jit_sym_restrict_type,&info); 01151 jit_object_method(m,_jit_sym_setinfo,&info); 01152 } 01153 } 01154 01155 } 01156 01157 return JIT_ERR_NONE; 01158 } 01159 01160 t_jit_err max_jit_mop_gettype(void *x, void *attr, long *argc, t_atom **argv) 01161 { 01162 void *p,*m; 01163 t_symbol *s; 01164 01165 s = jit_object_method(attr,_jit_sym_getname); 01166 01167 if ((p=max_jit_mop_get_io_by_name(x,s)) && 01168 (m=jit_object_method(p,_jit_sym_getmatrix))) 01169 { 01170 return (t_jit_err) jit_object_method(m,gensym("gettype"),argc,argv); 01171 } else if ((p=max_jit_mop_getoutput(x,1)) && 01172 (m=jit_object_method(p,_jit_sym_getmatrix))) 01173 { 01174 return (t_jit_err) jit_object_method(m,gensym("gettype"),argc,argv); 01175 } 01176 01177 return JIT_ERR_GENERIC; 01178 } 01179 01180 t_jit_err max_jit_mop_dim(void *x, void *attr, long argc, t_atom *argv) 01181 { 01182 void *mop,*p,*m; 01183 t_symbol *s; 01184 long incount,outcount,iotype,idx,dim,i,j; 01185 t_jit_matrix_info info; 01186 01187 s = jit_object_method(attr,_jit_sym_getname); 01188 01189 if (!argc&&!argv) 01190 return JIT_ERR_GENERIC; 01191 01192 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 01193 return JIT_ERR_GENERIC; 01194 01195 max_jit_mop_parse_name(s, &iotype, &idx); 01196 01197 if (idx!=0) { 01198 switch (iotype) { 01199 case JIT_MOP_INPUT: 01200 if (idx>=2) p=jit_object_method(mop,_jit_sym_getinput,idx); 01201 break; 01202 case JIT_MOP_OUTPUT: 01203 if (idx>=1) p=jit_object_method(mop,_jit_sym_getoutput,idx); 01204 break; 01205 } 01206 01207 if (p) { 01208 m=jit_object_method(p,_jit_sym_getmatrix); 01209 if (m) { 01210 jit_object_method(m,_jit_sym_getinfo,&info); 01211 CLIP(argc,0,JIT_MATRIX_MAX_DIMCOUNT); 01212 info.dimcount = argc; 01213 for (i=0;i<argc;i++) 01214 info.dim[i] = jit_atom_getlong(argv+i); 01215 for (;i<JIT_MATRIX_MAX_DIMCOUNT;i++) 01216 info.dim[i] = 1; 01217 jit_object_method(p,_jit_sym_restrict_dim,&info); 01218 jit_object_method(m,_jit_sym_setinfo,&info); 01219 } 01220 } 01221 } else { 01222 incount = jit_attr_getlong(mop,_jit_sym_inputcount); 01223 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 01224 01225 for (i=2;i<=incount;i++) { 01226 if ((p=jit_object_method(mop,_jit_sym_getinput,i)) && 01227 (m=jit_object_method(p,_jit_sym_getmatrix)) && 01228 jit_attr_getlong(p,_jit_sym_dimlink)) 01229 { 01230 jit_object_method(m,_jit_sym_getinfo,&info); 01231 CLIP(argc,0,JIT_MATRIX_MAX_DIMCOUNT); 01232 info.dimcount = argc; 01233 for (j=0;j<argc;j++) 01234 info.dim[j] = jit_atom_getlong(argv+j); 01235 for (;j<JIT_MATRIX_MAX_DIMCOUNT;j++) 01236 info.dim[j] = 1; 01237 jit_object_method(p,_jit_sym_restrict_dim,&info); 01238 jit_object_method(m,_jit_sym_setinfo,&info); 01239 } 01240 } 01241 01242 for (i=1;i<=outcount;i++) { 01243 if ((p=jit_object_method(mop,_jit_sym_getoutput,i)) && 01244 (m=jit_object_method(p,_jit_sym_getmatrix)) && 01245 jit_attr_getlong(p,_jit_sym_dimlink)) 01246 { 01247 jit_object_method(m,_jit_sym_getinfo,&info); 01248 CLIP(argc,0,JIT_MATRIX_MAX_DIMCOUNT); 01249 info.dimcount = argc; 01250 for (j=0;j<argc;j++) 01251 info.dim[j] = jit_atom_getlong(argv+j); 01252 for (;j<JIT_MATRIX_MAX_DIMCOUNT;j++) 01253 info.dim[j] = 1; 01254 jit_object_method(p,_jit_sym_restrict_dim,&info); 01255 jit_object_method(m,_jit_sym_setinfo,&info); 01256 } 01257 } 01258 01259 } 01260 01261 return JIT_ERR_NONE; 01262 } 01263 01264 t_jit_err max_jit_mop_getdim(void *x, void *attr, long *argc, t_atom **argv) 01265 { 01266 void *p,*m; 01267 t_symbol *s; 01268 01269 s = jit_object_method(attr,_jit_sym_getname); 01270 01271 if ((p=max_jit_mop_get_io_by_name(x,s)) && 01272 (m=jit_object_method(p,_jit_sym_getmatrix))) 01273 { 01274 return (t_jit_err) jit_object_method(m,gensym("getdim"),argc,argv); 01275 } else if ((p=max_jit_mop_getoutput(x,1)) && 01276 (m=jit_object_method(p,_jit_sym_getmatrix))) 01277 { 01278 return (t_jit_err) jit_object_method(m,gensym("getdim"),argc,argv); 01279 } 01280 01281 return JIT_ERR_GENERIC; 01282 } 01283 01284 /** 01285 * Adapts all input and output matrices to matrix specified. 01286 * 01287 * Typically used within the MOP Max Wrapper jit_matrix method 01288 * for left most input. 01289 * 01290 * @ingroup maxmopmod 01291 * 01292 * @param x Max object pointer 01293 * @param y matrix to adapt to 01294 * 01295 * @return t_jit_err error code 01296 * 01297 */ 01298 t_jit_err max_jit_mop_adapt_matrix_all(void *x, void *y) 01299 { 01300 void *mop,*tmp,*p,*m,*ioproc; 01301 long incount,outcount,iotype,idx,dim,i,j,change; 01302 t_jit_matrix_info info,info2; 01303 01304 if (!x||!y||!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 01305 return JIT_ERR_GENERIC; 01306 01307 incount = jit_attr_getlong(mop,_jit_sym_inputcount); 01308 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 01309 01310 jit_object_method(y,_jit_sym_getinfo,&info); 01311 01312 for (i=2;i<=incount;i++) { 01313 if ((p=jit_object_method(mop,_jit_sym_getinput,i)) && 01314 (m=jit_object_method(p,_jit_sym_getmatrix))) 01315 { 01316 change = FALSE; 01317 jit_object_method(m,_jit_sym_getinfo,&info2); 01318 if (jit_attr_getlong(p,_jit_sym_typelink)&&(info2.type!=info.type)) { 01319 change = TRUE; 01320 info2.type = info.type; 01321 } 01322 if (jit_attr_getlong(p,_jit_sym_planelink)&&(info2.planecount!=info.planecount)) { 01323 change = TRUE; 01324 info2.planecount = info.planecount; 01325 } 01326 if (jit_attr_getlong(p,_jit_sym_dimlink)) { 01327 if (info2.dimcount!=info.dimcount) { 01328 change = TRUE; 01329 info2.dimcount = info.dimcount; 01330 } 01331 for (j=0;j<info2.dimcount;j++) { 01332 if (info2.dim[j]!=info.dim[j]) { 01333 change = TRUE; 01334 info2.dim[j] = info.dim[j]; 01335 } 01336 } 01337 } 01338 if (change) { 01339 max_jit_mop_restrict_info(x,p,&info2); 01340 tmp = jit_object_new(_jit_sym_jit_matrix,&info2); 01341 jit_object_method(tmp,_jit_sym_frommatrix,m,NULL); 01342 jit_object_method(m,_jit_sym_setinfo,&info2); 01343 jit_object_method(m,_jit_sym_frommatrix,tmp,NULL); 01344 jit_object_free(tmp); 01345 } 01346 } 01347 } 01348 01349 for (i=1;i<=outcount;i++) { 01350 if ((p=jit_object_method(mop,_jit_sym_getoutput,i)) && 01351 (m=jit_object_method(p,_jit_sym_getmatrix)) && 01352 (!(ioproc=jit_object_method(p,_jit_sym_getioproc)))) 01353 { 01354 change = FALSE; 01355 jit_object_method(m,_jit_sym_getinfo,&info2); 01356 if (jit_attr_getlong(p,_jit_sym_typelink)) { 01357 info2.type = info.type; 01358 change = TRUE; 01359 } 01360 if (jit_attr_getlong(p,_jit_sym_planelink)) { 01361 info2.planecount = info.planecount; 01362 change = TRUE; 01363 } 01364 if (jit_attr_getlong(p,_jit_sym_dimlink)) { 01365 info2.dimcount = info.dimcount; 01366 for (j=0;j<info2.dimcount;j++) { 01367 info2.dim[j] = info.dim[j]; 01368 change = TRUE; 01369 } 01370 } 01371 if (change) { 01372 max_jit_mop_restrict_info(x,p,&info2); 01373 jit_object_method(m,_jit_sym_setinfo,&info2); 01374 } 01375 } 01376 } 01377 01378 return JIT_ERR_NONE; 01379 } 01380 01381 t_jit_err max_jit_mop_planecount(void *x, void *attr, long argc, t_atom *argv) 01382 { 01383 void *mop,*p,*m; 01384 t_symbol *s; 01385 long incount,outcount,iotype,planecount,idx,i; 01386 t_jit_matrix_info info; 01387 01388 s = jit_object_method(attr,_jit_sym_getname); 01389 01390 if (!argc&&!argv) 01391 return JIT_ERR_GENERIC; 01392 01393 planecount = jit_atom_getlong(argv); 01394 01395 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 01396 return JIT_ERR_GENERIC; 01397 01398 max_jit_mop_parse_name(s, &iotype, &idx); 01399 01400 if (idx!=0) { 01401 switch (iotype) { 01402 case JIT_MOP_INPUT: 01403 if (idx>=2) p=jit_object_method(mop,_jit_sym_getinput,idx); 01404 break; 01405 case JIT_MOP_OUTPUT: 01406 if (idx>=1) p=jit_object_method(mop,_jit_sym_getoutput,idx); 01407 break; 01408 } 01409 01410 if (p) { 01411 m=jit_object_method(p,_jit_sym_getmatrix); 01412 if (m) { 01413 jit_object_method(m,_jit_sym_getinfo,&info); 01414 info.planecount = planecount; 01415 jit_object_method(p,_jit_sym_restrict_planecount,&info); 01416 jit_object_method(m,_jit_sym_setinfo,&info); 01417 } 01418 } 01419 } else { 01420 01421 incount = jit_attr_getlong(mop,_jit_sym_inputcount); 01422 outcount = jit_attr_getlong(mop,_jit_sym_outputcount); 01423 01424 for (i=2;i<=incount;i++) { 01425 if ((p=jit_object_method(mop,_jit_sym_getinput,i)) && 01426 (m=jit_object_method(p,_jit_sym_getmatrix)) && 01427 jit_attr_getlong(p,_jit_sym_planelink)) 01428 { 01429 jit_object_method(m,_jit_sym_getinfo,&info); 01430 info.planecount = planecount; 01431 jit_object_method(p,_jit_sym_restrict_planecount,&info); 01432 jit_object_method(m,_jit_sym_setinfo,&info); 01433 } 01434 } 01435 01436 for (i=1;i<=outcount;i++) { 01437 if ((p=jit_object_method(mop,_jit_sym_getoutput,i)) && 01438 (m=jit_object_method(p,_jit_sym_getmatrix)) && 01439 jit_attr_getlong(p,_jit_sym_planelink)) 01440 { 01441 jit_object_method(m,_jit_sym_getinfo,&info); 01442 info.planecount = planecount; 01443 jit_object_method(p,_jit_sym_restrict_planecount,&info); 01444 jit_object_method(m,_jit_sym_setinfo,&info); 01445 } 01446 } 01447 01448 } 01449 01450 return JIT_ERR_NONE; 01451 } 01452 01453 t_jit_err max_jit_mop_getplanecount(void *x, void *attr, long *argc, t_atom **argv) 01454 { 01455 void *p,*m; 01456 t_symbol *s; 01457 01458 s = jit_object_method(attr,_jit_sym_getname); 01459 01460 if ((p=max_jit_mop_get_io_by_name(x,s)) && 01461 (m=jit_object_method(p,_jit_sym_getmatrix))) 01462 { 01463 return (t_jit_err) jit_object_method(m,gensym("getplanecount"),argc,argv); 01464 } else if ((p=max_jit_mop_getoutput(x,1)) && 01465 (m=jit_object_method(p,_jit_sym_getmatrix))) 01466 { 01467 return (t_jit_err) jit_object_method(m,gensym("getplanecount"),argc,argv); 01468 } 01469 01470 return JIT_ERR_GENERIC; 01471 } 01472 01473 t_jit_err max_jit_mop_parse_name(t_symbol *name, long *type, long *idx) 01474 { 01475 long i=1,v=0; 01476 char *p; 01477 01478 if (name&&type&&idx) { 01479 *type = 0; 01480 *idx = 0; 01481 if (name->s_name[0]=='i'&& 01482 name->s_name[1]=='n') 01483 { 01484 *type = JIT_MOP_INPUT; 01485 p = name->s_name; 01486 //move forward until end of string or '_' 01487 while (p[1]&&p[1]!='_') p++; 01488 //now move backwards + count 01489 while (*p>='0'&&*p<='9'&&p>name->s_name) { 01490 v += ((*p)-'0')*i; 01491 i *= 10; 01492 p--; 01493 } 01494 *idx = v?v:1; 01495 } else 01496 if (name->s_name[0]=='o'&& 01497 name->s_name[1]=='u'&& 01498 name->s_name[2]=='t') 01499 { 01500 *type = JIT_MOP_OUTPUT; 01501 p = name->s_name; 01502 //move forward until end of string or '_' 01503 while (p[1]&&p[1]!='_') p++; 01504 //now move backwards + count 01505 while (*p>='0'&&*p<='9'&&p>name->s_name) { 01506 v += ((*p)-'0')*i; 01507 i *= 10; 01508 p--; 01509 } 01510 *idx = v?v:1; 01511 } 01512 return JIT_ERR_NONE; 01513 } 01514 01515 return JIT_ERR_INVALID_PTR; 01516 } 01517 01518 t_jit_err max_jit_mop_variable_parse_sym(t_symbol *name, t_symbol **msg, long *set) 01519 { 01520 long i=1,v=0; 01521 char *p; 01522 01523 if (name&&msg&&set) { 01524 p = name->s_name; 01525 *set = !(p[0]=='g'&&p[1]=='e'&&p[2]=='t'); 01526 01527 //move forward until end of string or '_' 01528 while (p[1]&&p[1]!='_') p++; 01529 if (!p[1]) 01530 return JIT_ERR_GENERIC; 01531 01532 *msg = gensym(p+2); 01533 return JIT_ERR_NONE; 01534 } 01535 01536 return JIT_ERR_INVALID_PTR; 01537 } 01538 01539 t_jit_err max_jit_mop_restrict_info(void *x, void *p, t_jit_matrix_info *info) 01540 { 01541 long rv=0; 01542 rv = ((long) jit_object_method(p,_jit_sym_restrict_type,info) || rv); 01543 rv = ((long) jit_object_method(p,_jit_sym_restrict_dim,info) || rv); 01544 rv = ((long) jit_object_method(p,_jit_sym_restrict_planecount,info) || rv); 01545 return rv?JIT_ERR_GENERIC:JIT_ERR_NONE; 01546 } 01547 01548 /** 01549 * Retrieves t_jit_mop_io object pointer by name. 01550 * 01551 * @ingroup maxmopmod 01552 * 01553 * @param x Max object pointer 01554 * @param s input/output name (e.g. in, in2 , out, out2, etc.) 01555 * 01556 * @return t_jit_err error code 01557 * 01558 */ 01559 void *max_jit_mop_get_io_by_name(void *x, t_symbol *s) 01560 { 01561 void *mop,*p=NULL; 01562 long iotype,idx; 01563 01564 01565 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 01566 return NULL; 01567 01568 max_jit_mop_parse_name(s, &iotype, &idx); 01569 01570 if (idx!=0) { 01571 switch (iotype) { 01572 case JIT_MOP_INPUT: 01573 if (idx>=2) p=jit_object_method(mop,_jit_sym_getinput,idx); 01574 break; 01575 case JIT_MOP_OUTPUT: 01576 if (idx>=1) p=jit_object_method(mop,_jit_sym_getoutput,idx); 01577 break; 01578 } 01579 } 01580 return p; 01581 } 01582 01583 /** 01584 * Retrieves input t_jit_mop_io object pointer index. 01585 * 01586 * @ingroup maxmopmod 01587 * 01588 * @param x Max object pointer 01589 * @param c input index 01590 * 01591 * @return t_jit_err error code 01592 * 01593 */ 01594 void *max_jit_mop_getinput(void *x, long c) 01595 { 01596 void *mop; 01597 01598 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 01599 return NULL; 01600 01601 return jit_object_method(mop,_jit_sym_getinput,c); 01602 } 01603 01604 /** 01605 * Retrieves output t_jit_mop_io object pointer index. 01606 * 01607 * @ingroup maxmopmod 01608 * 01609 * @param x Max object pointer 01610 * @param c output index 01611 * 01612 * @return t_jit_err error code 01613 * 01614 */ 01615 void *max_jit_mop_getoutput(void *x, long c) 01616 { 01617 void *mop; 01618 01619 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 01620 return NULL; 01621 01622 return jit_object_method(mop,_jit_sym_getoutput,c); 01623 } 01624 01625 /** 01626 * Retrieves current MOP Max wrapper class output mode. 01627 * 01628 * @ingroup maxmopmod 01629 * 01630 * @param x Max object pointer 01631 * 01632 * @return t_jit_err error code 01633 * 01634 */ 01635 long max_jit_mop_getoutputmode(void *x) 01636 { 01637 void *mop; 01638 01639 if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) 01640 return 0; 01641 01642 return jit_attr_getlong(mop,_jit_sym_outputmode); 01643 } 01644 01645 void *max_jit_mop_io_getoutlet(void *mop_io) 01646 { 01647 return jit_object_method(mop_io,_jit_sym_getspecial); 01648 } 01649 01650 void *max_jit_mop_getmproc(void *mop) 01651 { 01652 return jit_object_method(mop,_jit_sym_getspecial); 01653 } 01654 01655 t_jit_err max_jit_mop_io_setoutlet(void *mop_io, void *o) 01656 { 01657 return (t_jit_err) jit_object_method(mop_io,_jit_sym_special,o); 01658 } 01659 01660 /** 01661 * Initializes default state and resources for MOP Max wrapper class. 01662 * 01663 * @ingroup maxmopmod 01664 * 01665 * @param x Max object pointer 01666 * @param o Jitter object pointer 01667 * @param argc argument count 01668 * @param argv argument vector 01669 * 01670 * @return t_jit_err error code 01671 * 01672 * @code 01673 max_jit_obex_jitob_set(x,o); 01674 max_jit_obex_dumpout_set(x,outlet_new(x,NULL)); 01675 max_jit_mop_setup(x); 01676 max_jit_mop_inputs(x); 01677 max_jit_mop_outputs(x); 01678 max_jit_mop_matrix_args(x,argc,argv); 01679 01680 return JIT_ERR_NONE; 01681 * @endcode 01682 */ 01683 t_jit_err max_jit_mop_setup_simple(void *x, void *o, long argc, t_atom *argv) 01684 { 01685 max_jit_obex_jitob_set(x,o); 01686 max_jit_obex_dumpout_set(x,outlet_new(x,NULL)); 01687 max_jit_mop_setup(x); 01688 max_jit_mop_inputs(x); 01689 max_jit_mop_outputs(x); 01690 max_jit_mop_matrix_args(x,argc,argv); 01691 01692 return JIT_ERR_NONE; 01693 } 01694 01695 01696 void *max_jit_mop_jit_matrix_startprobe(t_object *o) 01697 { 01698 void *mop; 01699 01700 //jit_object_post((t_object *)x,"start probe %x",o); 01701 if (o == g_jit_matrix_probe_obj) 01702 return NULL; 01703 if (g_jit_matrix_probe_obj) 01704 max_jit_mop_jit_matrix_endprobe(g_jit_matrix_probe_obj); 01705 01706 if (!(mop=max_jit_obex_adornment_get(o,_jit_sym_jit_mop))) 01707 return NULL; 01708 01709 //initialize o as the new probed object 01710 g_jit_matrix_probe_obj = o; 01711 01712 // confused about return value based on singal probe which returns the t_proboxy * 01713 //return NULL; 01714 return g_jit_matrix_probe_obj; 01715 } 01716 01717 void *max_jit_mop_jit_matrix_probevalue(t_object *o, long innum, long outnum, long *status, long *argc, t_atom **argv) 01718 { 01719 //jit_object_post((t_object *)x,"probe value %x outnum %d",o,outnum); 01720 01721 // o is the object you said was OK to probe in startprobe 01722 // for now ignore innum (inlet number) 01723 // do something that is a side-effect of being called, such as passing a matrix the object 01724 // is outputting for outnum (starts at 0, left to right) to a jit.pwindow 01725 01726 // we just set up the polling here 01727 // setup our qelem + clock 01728 g_jit_matrix_probe_outnum = outnum; 01729 01730 if (!g_jit_matrix_probe_qelem) 01731 g_jit_matrix_probe_qelem = qelem_new(gensym("jitter")->s_thing, (method)max_jit_mop_jit_matrix_probe_qfn); 01732 if (!g_jit_matrix_probe_clock) 01733 g_jit_matrix_probe_clock = clock_new(gensym("jitter")->s_thing, (method)max_jit_mop_jit_matrix_probe_tick); 01734 01735 // if this starts to be called more than once, I suppose we need more intelligence? 01736 //clock_unset(g_jit_matrix_probe_clock); 01737 //qelem_unset(g_jit_matrix_probe_qelem); 01738 clock_delay(g_jit_matrix_probe_clock,0); 01739 01740 // anything you return in args is ignored 01741 return NULL; 01742 } 01743 01744 void max_jit_mop_jit_matrix_endprobe(t_object *o) 01745 { 01746 //jit_object_post((t_object *)x,"end probe %x",o); 01747 // clean up 01748 if (g_jit_matrix_probe_clock) 01749 clock_unset(g_jit_matrix_probe_clock); 01750 if (g_jit_matrix_probe_qelem) 01751 qelem_unset(g_jit_matrix_probe_qelem); 01752 g_jit_matrix_probe_obj = NULL; 01753 } 01754 01755 void max_jit_mop_jit_matrix_probe_tick(t_object *x) 01756 { 01757 qelem_set(g_jit_matrix_probe_qelem); 01758 clock_delay(g_jit_matrix_probe_clock,JIT_MATRIX_PROBE_INTERVAL); 01759 } 01760 01761 void max_jit_mop_jit_matrix_probe_qfn(t_object *x) 01762 { 01763 t_atom a; 01764 void *mop,*p; 01765 static t_symbol *rname=NULL; 01766 t_object *o=g_jit_matrix_probe_obj; 01767 01768 if (!rname) 01769 rname = gensym("__jit_matrix_probe_receive"); 01770 01771 if (o) { 01772 if (!(mop = max_jit_obex_adornment_get(o,_jit_sym_jit_mop))) 01773 return; 01774 01775 if (p=jit_object_method(mop,_jit_sym_getoutput,g_jit_matrix_probe_outnum+1)) { // one-based, not zerobased 01776 jit_atom_setsym(&a,jit_attr_getsym(p,_jit_sym_matrixname)); 01777 01778 //jit_object_post((t_object *)x,"probe value sending it"); 01779 if (rname->s_thing) 01780 typedmess(rname->s_thing,_jit_sym_jit_matrix,1,&a); 01781 } 01782 } 01783 } 01784 01785 void max_jit_mop_jit_matrix_showprobe(); 01786 void max_jit_mop_jit_matrix_showprobe() 01787 { 01788 t_atom a[2]; 01789 atom_setsym(a,gensym("__jit_matrix_probe_window_ptr")); 01790 atom_setsym(a+1,gensym("jit_matrix_probe.maxpat")); 01791 typedmess(gensym("max")->s_thing,gensym("openfilefront"),2,a); 01792 } 01793
Copyright © 2008, Cycling '74