Beispiel #1
0
void connect_bang(t_connect *x)
{
	int i, j;
 
	x->f_inc = 0;
	
	if (x->f_nbSelected > 0) 
	{
		for (i = 0; i < x->f_nbSelected; i++) 
		{	
			if(validName(x->f_object[i]))
			{
				x->f_object[x->f_inc++] = x->f_object[i];
			}
			
		}
		
		for(i = 1; i < x->f_inc; i++)
		{
			if (object_classname(jbox_get_object(x->f_object[i -1])) == gensym("hoa.decoder~") || object_classname(jbox_get_object(x->f_object[i -1])) == gensym("hoa.projector~"))
			{
				for(j = 0; j < x->f_output; j++)
				{
					connect_connect(x->f_patcher, x->f_object[i -1], j, x->f_object[i], j);
				}
			}
			else if (object_classname(jbox_get_object(x->f_object[i -1])) == gensym("jpatcher"))
			{
				for(j = 0; j < x->f_harmonics; j++)
				{
					connect_connect(x->f_patcher, x->f_object[i -1], j, x->f_object[i], j);
				}
			}
			else
			{
				for(j = 0; j < x->f_harmonics; j++)
				{
					connect_connect(x->f_patcher, x->f_object[i -1], j, x->f_object[i], j);
				}
			}
			
		}
		
		for(i  = 0; i < CONNECT_MAX_TAB; i++)
			x->f_object[i] = NULL;
		
		jpatcher_set_dirty(x->f_patcherview, true);
	}
	
	x->f_nbSelected = 0;
	
	color_patchline(x);
}
Beispiel #2
0
void cmmjl_osc_saveAddressWithPatcher(void *x, bool b){
	long ac;
	t_atom a, *aa;
	t_patcher *p;
	object_attr_attr_getvalueof(x, ps_OSCaddress, gensym("save"), &ac, &aa);
	if(aa->a_type == A_LONG){
		if(aa->a_w.w_long != (long)b){
			atom_setlong(&a, b ? 1 : 0);
			object_attr_attr_setvalueof(x, ps_OSCaddress, gensym("save"), 1, &a);
			object_obex_lookup(x, gensym("#P"), (t_object **)&p);
			if(p){
				jpatcher_set_dirty(p, true);
			}
		}
	}
}
Beispiel #3
0
void make_patchline(t_connect *x)
{
	int connexions, valid_objects, i, j;
	valid_objects = 0;
	t_object *obj1, *obj2;
	t_hoa_err err[2];
	t_hoa_boxinfos* startobj_infos;
	t_hoa_boxinfos* endobj_infos;
	short startobj_type, endobj_type;
	long outlets, inlets;
	
	if (x->f_nbSelected > 1)
	{
		for (i = 0; i < x->f_nbSelected; i++)
		{
			obj1 = jbox_get_object(x->f_objects[i]);
			if(object_is_hoa(obj1) || is_obj_hoa_exotic(obj1))
				x->f_objects[valid_objects++] = x->f_objects[i]; // ! store BOX objects
		}
		
		if (valid_objects > 1)
		{
			startobj_infos = (t_hoa_boxinfos*) malloc( sizeof(t_hoa_boxinfos));
			endobj_infos = (t_hoa_boxinfos*) malloc( sizeof(t_hoa_boxinfos));
			
			for(i = 1; i < valid_objects; i++)
			{
				obj1 = jbox_get_object(x->f_objects[i-1]);
				obj2 = jbox_get_object(x->f_objects[ i ]);
				
				outlets = inlets = 0;
				
				// referenced object or exotic hoa one;
				startobj_type = object_is_hoa(obj1);
				endobj_type	  = object_is_hoa(obj2);
				
				hoa_boxinfos_init(startobj_infos);
				hoa_boxinfos_init(endobj_infos);
				err[0] = (t_hoa_err) object_method(obj1, hoa_sym_hoa_getinfos, startobj_infos, NULL);
				err[1] = (t_hoa_err) object_method(obj2, hoa_sym_hoa_getinfos, endobj_infos, NULL);
				
				// get number of outlets
				if (startobj_type == 1 && err[0] == HOA_ERR_NONE)
					outlets = startobj_infos->autoconnect_outputs;
				else
					outlets = outlet_count(obj1);
				
				// get number of inlets
				if (endobj_type == 1 && err[1] == HOA_ERR_NONE)
					inlets = endobj_infos->autoconnect_inputs;
				else
					inlets = inlet_count(obj2);
				
				connexions = MIN(outlets, inlets);
				for(j = 0; j < connexions; j++)
					connect_connect(x->f_patcher, x->f_objects[i-1], j, x->f_objects[i], j);
			}
			
			free(startobj_infos);
			free(endobj_infos);
		}
		
		for(i = 0; i < CONNECT_MAX_TAB; i++)
			x->f_objects[i] = NULL;
		
		jpatcher_set_dirty(x->f_patcherview, true);
	}
	x->f_nbSelected = 0;
}