Esempio n. 1
0
void max_jit_str_op_mproc(t_max_jit_str_op *x, void *mop)
{
	long err;
	void *o;
	long ac = 1;
	t_atom a[2];
	t_symbol *s;
	
	o = max_jit_obex_jitob_get(x);
	
	jit_attr_setlong(o, gensym("adaptflag"), jit_attr_getlong(mop, _jit_sym_adapt));
	
	if (err=(t_jit_err) jit_object_method(
		max_jit_obex_jitob_get(x),
		_jit_sym_matrix_calc,
		jit_object_method(mop,_jit_sym_getinputlist),
		jit_object_method(mop,_jit_sym_getoutputlist))) 
	{
		jit_error_code(x,err); 
	} else {
		s = jit_attr_getsym(o, gensym("op"));
		switch(jit_attr_getlong(o, gensym("outmode"))) {
		case 0:
			max_jit_mop_outputmatrix(x);
			break;
		case 2:
			ac = 2;
			jit_atom_setlong(&a[1], jit_attr_getlong(o, gensym("outlong2")));
		case 1:
			jit_atom_setlong(&a[0], jit_attr_getlong(o, gensym("outlong")));
			max_jit_obex_dumpout(x, s, ac, a);
			break;
		}	
	}
}
Esempio n. 2
0
//NOTIFY EXAMPLE: HERE'S WHERE WE GET INFO FROM SERVERS WE ARE ATTACHED TO 
//s is the servername, msg is the message, ob is the server object pointer, 
//and data is extra data the server might provide for a given message
void max_jit_notify_notify(t_max_jit_notify *x, t_symbol *s, t_symbol *msg, void *ob, void *data)
{
	if (msg==gensym("splat")) {
		post("notify: server=%s message=%s",s->s_name,msg->s_name);
		if (!data) {
			error("splat message NULL pointer");
			return;
		}
		//here's where we output using the rightmost outlet
		//we just happen to know that "data" points to a t_atom[3]
		//alternately you could use max_jit_obex_dumpout_get just to get 
		//the outlet pointer
		max_jit_obex_dumpout(x,msg,3,(t_atom *)data); 
	} else {
		//since we are a MOP, we are also attached to all the matrices for each input/output
		//so we need to deal with this by calling the default mop notify method 
		//(this is how mops handle their matrices getting new names/freed/modified)
		//mop notify ignores the data element and you should also ignore the error that
		//max_jit_mop_notify has msg prototyped as a long *, it is really a symbol *(oops)
		max_jit_mop_notify(x,s,msg);
	}
}
Esempio n. 3
0
void max_jit_openni_XMLConfig_read(t_max_jit_openni *x, t_symbol *s, short argc, t_atom *argv)
{
	long i;
	t_atom OutAtoms[2];	
	short filePathID;
	long fileType = 'TEXT', outType;
	char filename[MAX_FILENAME_CHARS];
	char fullyQualifiedPathname[MAX_PATH_CHARS];
	XnStatus nRetVal = XN_STATUS_OK;
	
#ifdef _DEBUG
	t_object *mypatcher;
	t_symbol *mypatcherpath;

	if (object_obex_lookup(x, gensym("#P"), &mypatcher) != MAX_ERR_NONE)
		LOG_ERROR("error getting patcher for jit.openni");
	mypatcherpath = object_attr_getsym(mypatcher, gensym("filepath"));
	
	if ((mypatcherpath) && (mypatcherpath != gensym(""))) 	// if I use _sym_nothing rather than gensym("") then I get linker error LNK2001: unresolved external symbol __common_symbols
	{
		LOG_COMMENT2("The patcher path is %s", mypatcherpath->s_name);
	}
	else
	{
		LOG_COMMENT("error getting filepath symbol for max.jit.openni");
		return;
	}
#endif

	if (argc == 0) // if no argument supplied, ask for file
	{
		if (open_dialog(filename, &filePathID, &outType, &fileType, 1))
		{
			// non-zero: user cancelled or error
			LOG_DEBUG("error getting XML config file from dialog box for max.jit.openni");
			atom_setsym(OutAtoms, gensym("<none>"));
			atom_setlong(OutAtoms + 1, 0);
			max_jit_obex_dumpout(x, gensym("read"), 2, OutAtoms);
			return;
		}
	}
	else if ((argc != 1) || (atom_gettype(argv) != A_SYM))
	{
		LOG_DEBUG("read must have only one symbol argument");
		atom_setsym(OutAtoms, gensym("<none>"));
		atom_setlong(OutAtoms + 1, 0);
		max_jit_obex_dumpout(x, gensym("read"), 2, OutAtoms);
		return;
	}
	else // we have exactly one symbol argument
	{
		strncpy_zero(filename, atom_getsym(argv)->s_name, MAX_FILENAME_CHARS);
		if (locatefile_extended(filename, &filePathID, &outType, &fileType, 1))
		{
			LOG_DEBUG2("Could not find file", atom_getsym(argv)->s_name);
			atom_setsym(OutAtoms, atom_getsym(argv));
			atom_setlong(OutAtoms + 1, 0);
			max_jit_obex_dumpout(x, gensym("read"), 2, OutAtoms);
			return;
		}
	}

	//Load file
	atom_setsym(OutAtoms, gensym(filename));
	if (path_topathname(filePathID, filename, fullyQualifiedPathname) == 0)
	{
		LOG_DEBUG2("asking Jitter object to load file %s", fullyQualifiedPathname);
		jit_object_method(max_jit_obex_jitob_get(x), gensym("init_from_xml"), gensym(fullyQualifiedPathname), &nRetVal);
		if (nRetVal)
		{
			atom_setlong(OutAtoms + 1, 0);
		}
		else
		{
			atom_setlong(OutAtoms + 1, 1);
		}
		max_jit_obex_dumpout(x, gensym("read"), 2, OutAtoms);
	}
	else
	{
		atom_setlong(OutAtoms + 1, 0);
		max_jit_obex_dumpout(x, gensym("read"), 2, OutAtoms);
	}

}