Example #1
0
void HoaDecode_send_configuration(t_HoaDecode *x)
{
	t_object *patcher;
	t_object *decoder;
    t_object *object;
    t_object *line;
	t_max_err err;
    
	err = object_obex_lookup(x, gensym("#P"), (t_object **)&patcher);
	if (err != MAX_ERR_NONE)
		return;
	
	err = object_obex_lookup(x, gensym("#B"), (t_object **)&decoder);
	if (err != MAX_ERR_NONE)
		return;
	
    for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line))
    {
        if (jpatchline_get_box1(line) == decoder)
        {
            object = jpatchline_get_box2(line);
            t_symbol* classname = object_classname(jbox_get_object(object));
            if(classname == gensym("hoa.meter~") || classname == gensym("hoa.gain~") || classname == gensym("hoa.vector~"))
            {
                long    argc = 1;
                t_atom *argv = new t_atom[1];
                atom_setlong(argv, x->f_AmbisonicsDecoder->getNumberOfOutputs());
                
                object_method_typed(jbox_get_object(object), gensym("channels"), argc, argv, NULL);
                
                free(argv);
            }
        }
    }
}
Example #2
0
MaxErr PlugOutNotify(PlugOutPtr self, SymbolPtr s, SymbolPtr msg, ObjectPtr sender, TTPtr data)
{
	if (sender == self->patcherview) {
		if (msg == _sym_attr_modified) {
			SymbolPtr name = (SymbolPtr)object_method((ObjectPtr)data, _sym_getname);
			if (name == _sym_dirty) {
				qelem_set(self->qelem);
			}
		}
		else if (msg == _sym_free)
			self->patcherview = NULL;
	}
	else {
		if (msg == _sym_free) {
			ObjectPtr	sourceBox;	
			ObjectPtr	sourceObject;
			long		sourceOutlet;
			ObjectPtr	destBox;		
			ObjectPtr	destObject;	
			long		destInlet;

			if (self->patcherview)
				goto out; // if there is no patcherview, then we are freeing the whole thing and can skip this

			#ifdef DEBUG_NOTIFICATIONS
			object_post(SELF, "patch line deleted");
			#endif // DEBUG_NOTIFICATIONS

			// get boxes and inlets
			sourceBox = jpatchline_get_box1(sender);
			if (!sourceBox)
				goto out;
			sourceObject = jbox_get_object(sourceBox);
			sourceOutlet = jpatchline_get_outletnum(sender);
			destBox = jpatchline_get_box2(sender);
			if (!destBox)
				goto out;
			destObject = jbox_get_object(destBox);
			destInlet = jpatchline_get_inletnum(sender);

			// if both boxes are audio graph objects 
			if ( zgetfn(sourceObject, GENSYM("audio.object")) && zgetfn(destObject, GENSYM("audio.object")) ) {
				#ifdef DEBUG_NOTIFICATIONS
				object_post(SELF, "deleting audio graph patchline!");
				#endif // DEBUG_NOTIFICATIONS

				object_method(destObject, GENSYM("audio.drop"), destInlet, sourceObject, sourceOutlet);
			}
		out:		
			;
		}
	}
	return MAX_ERR_NONE;
}
Example #3
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);
}
Example #4
0
MaxErr UnpackNotify(UnpackPtr self, SymbolPtr s, SymbolPtr msg, ObjectPtr sender, TTPtr data)
{
	if (sender == self->patcherview) {
		if (msg == _sym_attr_modified) {
			SymbolPtr name = (SymbolPtr)object_method((ObjectPtr)data, _sym_getname);
			if (name == _sym_dirty) {
				qelem_set(self->qelem);
			}
		}
		else if (msg == _sym_free)
			self->patcherview = NULL;
	}
	else {
		if (msg == _sym_free) {
			ObjectPtr	sourceBox;	
			ObjectPtr	sourceObject;
			long		sourceOutlet;
			ObjectPtr	destBox;		
			ObjectPtr	destObject;	
			long		destInlet;			
			
			#ifdef DEBUG_NOTIFICATIONS
			object_post(SELF, "patch line deleted");
			#endif // DEBUG_NOTIFICATIONS

			// get boxes and inlets
			sourceBox = jpatchline_get_box1(sender);
			if (!sourceBox)
				goto out;
			sourceObject = jbox_get_object(sourceBox);
			sourceOutlet = jpatchline_get_outletnum(sender);
			destBox = jpatchline_get_box2(sender);
			if (!destBox)
				goto out;
			destObject = jbox_get_object(destBox);
			destInlet = jpatchline_get_inletnum(sender);
			
			// if both boxes are audio graph objects 
			if ( zgetfn(sourceObject, gensym("audio.object")) && zgetfn(destObject, gensym("audio.object")) ) {
				#ifdef DEBUG_NOTIFICATIONS
				object_post(SELF, "deleting audio graph patchline!");
				#endif // DEBUG_NOTIFICATIONS
				
				object_method(destObject, gensym("audio.drop"), destInlet, sourceObject, sourceOutlet);
                UnpackReset(self,  self->vectorSize);      // attempt for http://redmine.jamoma.org/issues/1248
			}
		out:		
			;
		}
	}
	return MAX_ERR_NONE;
}
Example #5
0
t_max_err PackNotify(PackPtr self, t_symbol* s, t_symbol* msg, t_object* sender, TTPtr data)
{
	if (sender == self->patcherview) {
		if (msg == _sym_attr_modified) {
			t_symbol* name = (t_symbol*)object_method((t_object*)data, _sym_getname);
			if (name == _sym_dirty) {
				qelem_set(self->qelem);
			}
		}
		else if (msg == _sym_free)
			self->patcherview = NULL;
	}
	else {
		if (msg == _sym_free) {
			t_object*	sourceBox;
			t_object*	sourceObject;
			long		sourceOutlet;
			t_object*	destBox;
			t_object*	destObject;
			long		destInlet;

			#ifdef DEBUG_NOTIFICATIONS
			object_post(SELF, "patch line deleted");
			#endif // DEBUG_NOTIFICATIONS

			// get boxes and inlets
			sourceBox = jpatchline_get_box1(sender);
			if (!sourceBox)
				goto out;

			sourceObject = jbox_get_object(sourceBox);
			sourceOutlet = jpatchline_get_outletnum(sender);
			destBox = jpatchline_get_box2(sender);
			if (!destBox)
				goto out;
			destObject = jbox_get_object(destBox);
			destInlet = jpatchline_get_inletnum(sender);

			// if both boxes are graph objects
			if ( zgetfn(sourceObject, gensym("graph.object")) && zgetfn(destObject, gensym("graph.object")) ) {
				#ifdef DEBUG_NOTIFICATIONS
				object_post(SELF, "deleting graph patchline!");
				#endif // DEBUG_NOTIFICATIONS

				object_method(destObject, gensym("graph.drop"), destInlet, sourceObject, sourceOutlet);
			}
		out:
			;
		}
	}
	return MAX_ERR_NONE;
}
Example #6
0
int validName(t_object *box)
{
	int i;
	t_object *jb, *o, *obj;
	char objName[] = "nop.";
	
	obj = jbox_get_object(box);
	
	if(object_classname(obj) == gensym("jpatcher"))
	{
		if(strlen(jpatcher_get_name(obj)->s_name) >= 4)
		{
			for(i = 0; i < 4; i++)
			{
				objName[i] = jpatcher_get_name(obj)->s_name[i];
			}
		}
		else 
		{
			jb = jpatcher_get_firstobject(obj);
			while(jb) 
			{
				o = jbox_get_object(jb);
				if(object_classname(o) == gensym("hoa.plug_script"))
				{
					strcpy(objName, "hoa.");
				}
				jb = jbox_get_nextobject(jb);
			}
		}			
	}
	else if (object_classname(obj) == gensym("dac~") || object_classname(obj) == gensym("sfrecord~") || object_classname(obj) == gensym("sfplay~"))
	{
		strcpy(objName, "hoa.");
	}
	else if (strlen(object_classname(obj)->s_name) >= 4) 
	{
		for(i = 0; i < 4; i++)
		{
			objName[i] = object_classname(obj)->s_name[i];
		}
	}
	
	if(strcmp(objName, "hoa.") == 0)
		return 1;
	else
		return 0;
}
Example #7
0
void inquisitor_attributes(t_inquisitor* x)
{
	t_symbol**	names = NULL;
	long		count = 0;
	t_atom*		av = NULL;
	
	if(!x->subject){
		t_object* b = jpatcher_get_firstobject(x->patcher);
		
		while(b){			
			if(x->name == jbox_get_varname(b)){
				x->subject = jbox_get_object(b);
				break;
			}
			b = jbox_get_nextobject(b);
		}
	}

	if(x->subject){
		object_attr_getnames(x->subject, &count, (t_symbol***)&names);
		if(count && names){
			av = (t_atom*)sysmem_newptr(sizeof(t_atom) * count);
			for(long i=0; i<count; i++)
				atom_setsym(av+i, names[i]);
			outlet_anything(x->outlet_names, atom_getsym(av), count-1, av+1);
			
			sysmem_freeptr(av);
			sysmem_freeptr(names);
		}
	}
}
Example #8
0
void send_configuration(t_hoa_decoder *x)
{
	t_object *patcher;
	t_object *decoder;
    t_object *object;
    t_object *line;
	t_max_err err;
    
    if(!x->f_send_config)
        return;
    
	err = object_obex_lookup(x, gensym("#P"), (t_object **)&patcher);
	if (err != MAX_ERR_NONE)
		return;
	
	err = object_obex_lookup(x, gensym("#B"), (t_object **)&decoder);
	if (err != MAX_ERR_NONE)
		return;
	
    t_atom nchannels;
    t_atom offset;
    t_atom *argv = new t_atom[x->f_decoder->getNumberOfChannels()];
    atom_setlong(&nchannels, x->f_decoder->getNumberOfChannels());
    atom_setfloat(&offset, x->f_decoder->getChannelsOffset() / HOA_2PI * 360.);
    for(int i = 0; i < x->f_decoder->getNumberOfChannels(); i++)
        atom_setfloat(argv+i, x->f_decoder->getChannelAzimuth(i) / HOA_2PI * 360.);
    
    for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line))
    {
        if (jpatchline_get_box1(line) == decoder)
        {
            object = jpatchline_get_box2(line);
            t_symbol* classname = object_classname(jbox_get_object(object));
            if(classname == gensym("hoa.2d.meter~") || classname == gensym("hoa.meter~") ||  classname == gensym("hoa.2d.vector~"))
            {
                object_method_typed(jbox_get_object(object), gensym("channels"), 1, &nchannels, NULL);
                object_method_typed(jbox_get_object(object), gensym("angles"), x->f_decoder->getNumberOfChannels(), argv, NULL);
                object_method_typed(jbox_get_object(object), gensym("offset"), 1, &offset, NULL);
            }
            else if(classname == gensym("hoa.gain~"))
                object_method_typed(jbox_get_object(object), gensym("channels"), 1, &nchannels, NULL);
        }
    }
    
    free(argv);
}
Example #9
0
void HoaDecode_send_angles(t_HoaDecode *x)
{
	t_object *patcher;
	t_object *decoder;
    t_object *object;
    t_object *line;
	t_max_err err;
    
	err = object_obex_lookup(x, gensym("#P"), (t_object **)&patcher);
	if (err != MAX_ERR_NONE)
		return;
	
	err = object_obex_lookup(x, gensym("#B"), (t_object **)&decoder);
	if (err != MAX_ERR_NONE)
		return;
	
    for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line))
    {
        if (jpatchline_get_box1(line) == decoder)
        {
            object = jpatchline_get_box2(line);
            t_symbol* classname = object_classname(jbox_get_object(object));
            if(classname == gensym("hoa.meter~") || classname == gensym("hoa.gain~") || classname == gensym("hoa.vector~"))
            {                
                long    argc = x->f_AmbisonicsDecoder->getNumberOfOutputs();
                t_atom *argv = new t_atom[argc];
                
                for(int i = 0; i < argc; i++)
                    atom_setfloat(argv+i, x->f_AmbisonicsDecoder->getLoudspeakerAngle(i));
                
                object_method_typed(jbox_get_object(object), gensym("angles"), argc, argv, NULL);
                free(argv);
            }
        }
    }
}
Example #10
0
void iterator_bang(t_iterator *x)
{
	t_object *jp;
	t_object *jb;
	t_object *mybox;
	t_object *o;
	t_rect jr;
	t_symbol *scriptingname;
	t_max_err err;

	// get the object's parent patcher
	err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp);
	if (err != MAX_ERR_NONE)
		return;

	// get the object's wrapping box
	err = object_obex_lookup(x, gensym("#B"), (t_object **)&mybox);
	if (err != MAX_ERR_NONE)
		return;

	jb = jpatcher_get_firstobject(jp); // get the first BOX in the object list

	while(jb) {
		jbox_get_patching_rect(jb, &jr); // x, y, width, height (double)

		object_post((t_object *)x, "found an object at %ld %ld, w %ld, h %ld", (long)jr.x, (long)jr.y, (long)jr.width, (long)jr.height);

		scriptingname = jbox_get_varname(jb); // scripting name
		if (scriptingname && scriptingname != gensym(""))
			object_post((t_object *)x, " it is named %s...", scriptingname->s_name);

		o = jbox_get_object(jb); // get the box's object (b_firstin in Max4)
		post(" it's a(n) %s object...", object_classname(o)->s_name);

		if (jpatcher_is_patcher(o)) {
			post(" which is some kind of a patcher. we could recurse here...");
		}

		if (jb == mybox)
			post(" ...and it's me!");

		jb = jbox_get_nextobject(jb); // iterate
	}

	// jbox_get_patcher(abox); // get a box's patcher

	// maybe upwards? jpatcher_get_parentpatcher(<#t_object * p#>)
}
Example #11
0
short posit_enumbuffers(t_patcher *p, t_posit *x)
{
	t_buffer *bufob;
	t_object *jb;
	t_object *o;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *buffername;
	t_symbol *patchername;
	t_symbol *classname;
	t_atom *outlist;
	
	outlist = x->p_outlist;
	
	jb = jpatcher_get_firstobject(p); // get the first BOX in the object list
	patchername = jpatcher_get_name(p);
	
	while(jb) { // iterate through patcher
		x->p_flag = 0;
		
		classname = jbox_get_maxclass(jb); // class name
		if(classname == ps_buff){
			
			o = jbox_get_object(jb);
			bufob = (t_buffer *)o;
			buffername = (t_symbol *)bufob->b_name;
			scriptingname = jbox_get_varname(jb); // scripting name
			if (!scriptingname || scriptingname == ps_nothing) {
				scriptingname = ps_none;
			}
			jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
			atom_setsym(outlist+0,  classname);			// class name
			atom_setsym(outlist+1,  buffername);		// scripting name
			atom_setsym(outlist+2,  patchername);		// patcher name
			atom_setsym(outlist+3,  scriptingname);
			atom_setlong(outlist+4, (long)((long)jr.x));
			atom_setlong(outlist+5, (long)((long)jr.y));
			atom_setlong(outlist+6, (long)((long)jr.x + (long)jr.width)); 
			atom_setlong(outlist+7, (long)((long)jr.y + (long)jr.height));
			outlet_list(x->p_outlet,0L,8,outlist); 
			x->p_flag = 1;
		}
		jb = jbox_get_nextobject(jb); // iterate
	}
	return 0;
}
Example #12
0
short is_obj_hoa_exotic(t_object *obj)
{
	int i;
	t_object *jb, *o;
	char objName[] = "nop.";
		
	if(object_classname(obj) == hoa_sym_jpatcher)
	{
		if(strlen(jpatcher_get_name(obj)->s_name) >= 4)
		{
			for(i = 0; i < 4; i++)
			{
				objName[i] = jpatcher_get_name(obj)->s_name[i];
			}
		}
		else
		{
			jb = jpatcher_get_firstobject(obj);
			while(jb)
			{
				o = jbox_get_object(jb);
				if(object_classname(o) == gensym("hoa.plug_script"))
				{
					strcpy(objName, "hoa.");
				}
				jb = jbox_get_nextobject(jb);
			}
		}
	}
	else if (object_classname(obj) == gensym("dac~") || object_classname(obj) == gensym("sfrecord~") || object_classname(obj) == gensym("sfplay~"))
	{
		strcpy(objName, "hoa.");
	}
	else if (strlen(object_classname(obj)->s_name) >= 4)
	{
		for(i = 0; i < 4; i++)
		{
			objName[i] = object_classname(obj)->s_name[i];
		}
	}
	
	if(strcmp(objName, "hoa.") == 0)
		return 1;
	
	return 0;
}
Example #13
0
void OutAttachToPatchlinesForPatcher(OutPtr self, t_object* patcher)
{
	t_object*	patchline = object_attr_getobj(patcher, _sym_firstline);
	t_object*	box = jpatcher_get_firstobject(patcher);

	while (patchline) {
		object_attach_byptr_register(self, patchline, _sym_nobox);
		patchline = object_attr_getobj(patchline, _sym_nextline);
	}

	while (box) {
		t_symbol *classname = jbox_get_maxclass(box);

		if (classname == _sym_jpatcher) {
			t_object*	subpatcher = jbox_get_object(box);

			OutAttachToPatchlinesForPatcher(self, subpatcher);
		}
		box = jbox_get_nextobject(box);
	}
}
Example #14
0
void color_patchline(t_connect *x)
{
	t_object *line, *obj, *patcher;
	object_obex_lookup(x, gensym("#P"), &patcher);
	for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line)) 
	{
		obj = jbox_get_object(jpatchline_get_box1(line));
						   
		if (validConditionColor(obj) == 1)
		{ 
			if (jpatchline_get_inletnum(line) % 2 == 1) 
				jpatchline_set_color(line, &x->f_colorPositiv);
			else
				jpatchline_set_color(line, &x->f_colorNegativ);			
		}
		else if (validConditionColor(obj) == 2)
		{ 
			jpatchline_set_color(line, &x->f_colorPlane);		
		}
	}
}
Example #15
0
void UnpackAttachToPatchlinesForPatcher(UnpackPtr self, ObjectPtr patcher)
{
	ObjectPtr	patchline = object_attr_getobj(patcher, _sym_firstline);
	ObjectPtr	box = jpatcher_get_firstobject(patcher);
	
	while (patchline) {
		object_attach_byptr_register(self, patchline, _sym_nobox);
		patchline = object_attr_getobj(patchline, _sym_nextline);
	}
		
	while (box) {
		SymbolPtr	classname = jbox_get_maxclass(box);
		
		if (classname == _sym_jpatcher) {
			ObjectPtr	subpatcher = jbox_get_object(box);
			
			UnpackAttachToPatchlinesForPatcher(self, subpatcher);
		}
		box = jbox_get_nextobject(box);
	}
}
Example #16
0
long howbigisyourp_callback(t_howbigisyourp *x, t_object *obj)
{
	long numberofinstances = 1;
	t_symbol *name = object_classname(obj);

	// if it's a newobj, get the "real" name (e.g. borax)
	if (name == gensym("newobj"))
		name = object_classname(jbox_get_object(obj));

	if (name) {
		t_object *obj;

		// if the object was already in the hashtable, increment the number of instances
		if (hashtab_lookup(x->hash, name, &obj) == MAX_ERR_NONE)
			numberofinstances = (long)obj + 1;

		// write the number of instances in the hashtable
		hashtab_store(x->hash, name, (t_object *)numberofinstances);
	}

	return 0;
}
Example #17
0
void inquisitor_get(t_inquisitor *x, t_symbol *name)
{
	if(!x->subject){
		t_object* b = jpatcher_get_firstobject(x->patcher);

		while(b){			
			if(x->name == jbox_get_varname(b)){
				x->subject = jbox_get_object(b);
				break;
			}
			b = jbox_get_nextobject(b);
		}
	}
	
	if(x->subject && !NOGOOD(x->subject)){
		t_atom*		av = NULL;
		long		ac = 0;
		t_max_err	err;
		
		err = object_attr_getvalueof(x->subject, name, &ac, &av);
		if(!err && ac && av){
			for(long i=0; i<ac; i++){
				if(atom_gettype(av+i) != A_LONG && atom_gettype(av+i) != A_FLOAT && atom_gettype(av+i) != A_SYM){
					object_error((t_object*)x, "The type of data returned for this attribute value is not usable by tap.inquisitor: %s", name->s_name);
					err = MAX_ERR_GENERIC;
					break;
				}
			}
			if(!err)
				outlet_anything(x->outlet, name, ac, av);
		}
		else{
			object_error((t_object*)x, "problem getting attribute value for %s", name->s_name);
		}
		
		if(ac && av)
			sysmem_freeptr(av);
	}
}
Example #18
0
int validConditionColor(t_object *obj)
{
	t_object *jb, *o;
	t_symbol *obclass = object_classname(obj);
	
	if(obclass == gensym("hoa.encoder~") ||
	   obclass == gensym("hoa.rotate~") ||
	   obclass == gensym("hoa.recomposer~") ||
	   obclass == gensym("sfplay~") ||
	   obclass == gensym("hoa.optim~") ||
	   obclass == gensym("hoa.convolve~") ||
	   obclass == gensym("hoa.wider~") ||
	   obclass == gensym("hoa.map~") ||
	   obclass == gensym("hoa.freeverb~") ||
	   obclass == gensym("hoa.gigaverb~")
	   )
		return 1;
	else if(obclass == gensym("hoa.projector~") ||
			obclass == gensym("hoa.space~"))
		return 2;
	else if (obclass == gensym("jpatcher"))
	{
		jb = jpatcher_get_firstobject(obj);
		while(jb) 
		{
			o = jbox_get_object(jb);
			if(object_classname(o) == gensym("hoa.plug_script"))
			{
				return 1;
			}
			jb = jbox_get_nextobject(jb);
		}
		
	}		
	
	return 0;
}
Example #19
0
short posit_enumcolls(t_patcher *p, t_posit *x)
{
	t_coll 		*collob;
	t_object *jb;
	t_object *o;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *collname;
	t_symbol *patchername;
	t_symbol *classname;
	t_atom *outlist;
	
	
	outlist = x->p_outlist;
	
	jb = jpatcher_get_firstobject(p); // get the first BOX in the object list
	patchername = jpatcher_get_name(p);
	
	while(jb) { // iterate through patcher
		x->p_flag = 0;
		
		classname = jbox_get_maxclass(jb); // class name
		if(classname == ps_coll){
			
			o = jbox_get_object(jb);
			collob = (t_coll *)o;
			collname = (t_symbol *)collob->c_x->c_sym;
			scriptingname = jbox_get_varname(jb); // scripting name
			if (!scriptingname || scriptingname == ps_nothing) {
				scriptingname = ps_none;
			}
			jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
			atom_setsym(outlist+0,  classname);			// class name
			atom_setsym(outlist+1,  collname);		// scripting name
			atom_setsym(outlist+2,  patchername);		// patcher name
			atom_setsym(outlist+3,  scriptingname);
			atom_setlong(outlist+4, (long)((long)jr.x));
			atom_setlong(outlist+5, (long)((long)jr.y));
			atom_setlong(outlist+6, (long)((long)jr.x + (long)jr.width)); 
			atom_setlong(outlist+7, (long)((long)jr.y + (long)jr.height));
			outlet_list(x->p_outlet,0L,8,outlist); 
			x->p_flag = 1;
		}
		jb = jbox_get_nextobject(jb); // iterate
	}	

	
	
	
	/*
	for (b = p->p_box; b; b = b->b_next) {
		if(b->b_firstin && (ob_sym(b->b_firstin) == ps_coll)) {
			x->p_patcher2 = b->b_patcher;
			strcpy(name, x->p_patcher2->p_wind->w_name);
			ptr = name;			
			collob = (t_coll *)b->b_firstin;
			outlist[1].a_type = A_SYM;
			outlist[1].a_w.w_sym =  collob->c_x->c_sym;
			SETSYM(outlist+2, gensym(ptr));
			SETSYM(outlist+0, ps_coll);
			if(outlist[1].a_w.w_sym != ps_nothing){
				outlet_list(x->p_outlet, 0L, 3, outlist);
			}
		}
	}*/
	return 0;
}
Example #20
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;
}
void hoa_gain_tometer(t_hoa_gain *x, t_symbol *s, long ac, t_atom *av)
{
    if(ac && av)
    {
        t_object *patcher;
        t_object *gain;
        t_object *line;
        t_max_err err;
        t_atom rv;
        t_atom msg[4];
        
        err = object_obex_lookup(x, hoa_sym_pound_P, (t_object **)&patcher);
        if (err != MAX_ERR_NONE)
            return;
        
        err = object_obex_lookup(x, hoa_sym_pound_B, (t_object **)&gain);
        if (err != MAX_ERR_NONE)
            return;
        
        vector<t_jbox *> boxes;
        
        for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line))
        {
            if (jpatchline_get_box1(line) == gain)
            {
                t_jbox *box = (t_jbox*)jpatchline_get_box2(line);
                t_object *obj = jbox_get_object((t_object*)box);
                t_symbol* classname = object_classname(obj);
                
                if (find(boxes.begin(), boxes.end(), box) == boxes.end())
                {
                    if(classname == hoa_sym_hoa_2d_meter ||
                       classname == hoa_sym_hoa_2d_vector ||
                       classname == hoa_sym_hoa_gain)
                    {
                        object_method_typed(obj, s, ac, av, NULL);
                        boxes.push_back(box);
                    }
                    else if(classname == hoa_sym_dac || (object_is_hoa(obj) && classname != hoa_sym_hoa_pi && classname != hoa_sym_hoa_pi_tilde))
                    {
                        boxes.push_back(box);
                    }
                }
            }
        }
        
        for(auto box : boxes)
        {
            // re-connect patchlines
            for(int i = 0; jbox_getinlet(box, i) != NULL && i < x->f_number_of_channels; i++)
            {
                atom_setobj(msg, gain);
                atom_setlong(msg + 1, i);
                atom_setobj(msg + 2, box);
                atom_setlong(msg + 3, i);
                object_method_typed(patcher , hoa_sym_connect, 4, msg, &rv);
            }
        }
        boxes.clear();
    }
}
Example #22
0
void color_patchline(t_connect *x)
{
	t_object *line, *startobj;
	t_object *jb, *o;
	t_hoa_err err;
	t_jrgba* linecolor = NULL;
	int inletnum, sign;
	short startobj_type;
	t_hoa_boxinfos* startobj_infos = (t_hoa_boxinfos*) malloc( sizeof(t_hoa_boxinfos));
	line = jpatcher_get_firstline(x->f_patcher);
	
	while (line)
	{
		startobj = jbox_get_object(jpatchline_get_box1(line));
		
		if(object_is_hoa(startobj) || is_obj_hoa_exotic(startobj))
		{
			startobj_type = object_is_hoa(startobj);
			
			hoa_boxinfos_init(startobj_infos);
			err = (t_hoa_err) object_method(startobj, hoa_sym_hoa_getinfos, startobj_infos, NULL);
			
			if (err == HOA_ERR_NONE)
			{
				// ambisonics colors (zero | neg | pos) (ex: hoa.encoder~ => hoa.optim~)
				if (startobj_infos->autoconnect_outputs_type == HOA_CONNECT_TYPE_AMBISONICS)
				{
					inletnum = jpatchline_get_inletnum(line);
					
					if (startobj_infos->object_type == HOA_OBJECT_2D)
						sign = x->f_ambi2D->getHarmonicArgument(inletnum);
					if (startobj_infos->object_type == HOA_OBJECT_3D)
						sign = x->f_ambi3D->getHarmonicArgument(inletnum);
					
					if (sign > 0)
						linecolor = &x->f_color_positiv;
					else if (sign < 0)
						linecolor = &x->f_color_negativ;
					else
						linecolor = &x->f_color_zero;
					
					jpatchline_set_color(line, linecolor);
				}
				// planewave color (ex: hoa.projector~ => hoa.recomposer~)
				else if (startobj_infos->autoconnect_outputs_type == HOA_CONNECT_TYPE_PLANEWAVES)
				{
					jpatchline_set_color(line, &x->f_color_plane);
				}
			}
			
			// hoa.plug~ retro compatibility
			else if (object_classname(startobj) == hoa_sym_jpatcher)
			{
				jb = jpatcher_get_firstobject(startobj);
				while(jb)
				{
					o = jbox_get_object(jb);
					if(object_classname(o) == gensym("hoa.plug_script"))
					{
						inletnum = jpatchline_get_inletnum(line);
						
						if (inletnum == 0)
							jpatchline_set_color(line, &x->f_color_zero);
						else if (inletnum % 2 == 1)
							jpatchline_set_color(line, &x->f_color_negativ);
						else
							jpatchline_set_color(line, &x->f_color_positiv);
						break;
					}
					jb = jbox_get_nextobject(jb);
				}
				
			}
		}
		
		line = jpatchline_get_nextline(line);
	}
	
	free(startobj_infos);
}