示例#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);
            }
        }
    }
}
示例#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;
}
示例#3
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;
}
示例#4
0
文件: j.pack.cpp 项目: EQ4/JamomaMax
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;
}
示例#5
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);
}
示例#6
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);		
		}
	}
}
示例#7
0
void HoaDecode_reconnect_outlet(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);
            
            for(int i = 0; jbox_getinlet((t_jbox *)object, i) != NULL && i < x->f_AmbisonicsDecoder->getNumberOfOutputs(); i++)
            {
                t_atom msg[4];
                t_atom rv;
                    
                atom_setobj(msg, decoder);
                atom_setlong(msg + 1, i);
                atom_setobj(msg + 2, object);
                atom_setlong(msg + 3, i);
                    
                object_method_typed(patcher , gensym("connect"), 4, msg, &rv);
            }
        }
    }
}
示例#8
0
void HoaDecode_disconnect_outlet(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);
            if(jpatchline_get_inletnum(line) != 0 && jpatchline_get_outletnum(line) != 0)
            {
                t_atom msg[4];
                t_atom rv;
                    
                atom_setobj(msg, decoder);
                atom_setlong(msg + 1, jpatchline_get_outletnum(line));
                atom_setobj(msg + 2, object);
                atom_setlong(msg + 3, jpatchline_get_inletnum(line));
                    
                object_method_typed(patcher , gensym("disconnect"), 4, msg, &rv);
            }
        }
    }
}
示例#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);
            }
        }
    }
}
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();
    }
}
示例#11
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);
}