Ejemplo n.º 1
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;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 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;
}
Ejemplo n.º 4
0
void tow_setup(void)
{
    int result = LOADER_OK;
    if (zgetfn(&pd_objectmaker, gensym("widget")))
	loud_warning(0, "tow", "widget is already loaded");
    else
	result = unstable_load_lib("", "widget");
    if (result == LOADER_NOFILE)
	loud_error(0, "widget library is missing");
    else if (!zgetfn(&pd_objectmaker, gensym("widget")))
    {
	loud_error(0, "version mismatch");
	loud_errand(0, "use a more recent Pd release (or recompile toxy).");
    }
}
Ejemplo n.º 5
0
void cmmjl_osc_sendMsg(void *x, t_symbol *msg, int argc, t_atom *argv){
	t_linklist *ll = cmmjl_obj_osc_address_methods_get(x);
	t_symbol *m = gensym(basename(msg->s_name));
	char *osc_address;
	int i;
	method func;
	void *r;

	if(msg == ps_OSCTimeTag){
		return;
	}
	if(!ll){
		return;
	}
	osc_address = linklist_getindex(ll, 0);
	for(i = 0; i < linklist_getsize(ll); i++){
		if(!osc_address){
			post("no OSC address--breaking");
			break;
		}
		if(!cmmjl_osc_match(x, msg->s_name, osc_address)){
			func = zgetfn((t_object *)x, m);
			if(func){
				r = typedmess(x, m, argc, argv);
				//return;
			}
		}else{
		}
		linklist_next(ll, osc_address, (void **)&osc_address);
	}
	CMMJL_ERROR(x, CMMJL_ENOFUNC, "couldn't send message %s to object", m->s_name);
}
Ejemplo n.º 6
0
static void riddle_free(t_riddle *rd)
{
    t_gotfn freefn = zgetfn((t_pd *)rd, gensym("_free"));
    if (freefn)
        freefn(rd);

    if (rd->rd_private)
        freebytes(rd->rd_private, sizeof(*rd->rd_private));

    if (rd->rd_inslots)
    {
        int nslots = rd->rd_nsiginlets + rd->rd_nremoteslots;
        freebytes(rd->rd_inslots, nslots * sizeof(*rd->rd_inslots));
    }

    if (rd->rd_outslots)
    {
        t_rdsink *si;
        int i;
        for (i = 0, si = rd->rd_outslots; i < rd->rd_nsigoutlets; i++, si++)
            if (si->si_feedchain)
                rdfeedchain_free(si->si_feedchain);
        freebytes(rd->rd_outslots,
                  rd->rd_nsigoutlets * sizeof(*rd->rd_outslots));
    }

    rdremote_freeports(rd->rd_remoteports);

    if (rd->rd_idlepicker)
        rdpicker_detach(rd->rd_idlepicker, rd);
}
Ejemplo n.º 7
0
void PlugOutIterateSetupCallback(PlugOutPtr self, ObjectPtr obj)
{
	method audioSetupMethod = zgetfn(obj, GENSYM("audio.setup"));

	if (audioSetupMethod)
		audioSetupMethod(obj);
}
Ejemplo n.º 8
0
void PackIterateSetupCallback(PackPtr self, t_object* obj)
{
	t_max_err err = MAX_ERR_NONE;
	method graphSetupMethod = zgetfn(obj, gensym("graph.setup"));

	if (graphSetupMethod)
		err = (t_max_err)graphSetupMethod(obj);
}
Ejemplo n.º 9
0
void OutIterateResetCallback(OutPtr self, t_object* obj)
{
	t_max_err err = MAX_ERR_NONE;
	method audioResetMethod = zgetfn(obj, gensym("audio.reset"));

	if (audioResetMethod)
		err = (t_max_err)audioResetMethod(obj, self->vectorSize);
}
Ejemplo n.º 10
0
void OutIterateSetupCallback(OutPtr self, t_object* obj)
{
	t_max_err err = MAX_ERR_NONE;
	method audioSetupMethod = zgetfn(obj, gensym("audio.setup"));

	if (audioSetupMethod)
		err = (t_max_err)audioSetupMethod(obj);
}
Ejemplo n.º 11
0
void PackIterateSetupCallback(PackPtr self, ObjectPtr obj)
{
	MaxErr err = MAX_ERR_NONE;
	method graphSetupMethod = zgetfn(obj, gensym("graph.setup"));
	
	if (graphSetupMethod)
		err = (MaxErr)graphSetupMethod(obj);
}
Ejemplo n.º 12
0
void UnpackIterateResetCallback(UnpackPtr self, ObjectPtr obj)
{
	MaxErr err = MAX_ERR_NONE;
	method audioResetMethod = zgetfn(obj, gensym("audio.reset"));
	
	if (audioResetMethod)
		err = (MaxErr)audioResetMethod(obj, self->vectorSize);
}
Ejemplo n.º 13
0
void UnpackIterateSetupCallback(UnpackPtr self, ObjectPtr obj)
{
	MaxErr err = MAX_ERR_NONE;
	method audioSetupMethod = zgetfn(obj, gensym("audio.setup"));
	
	if (audioSetupMethod)
		err = (MaxErr)audioSetupMethod(obj);
}
Ejemplo n.º 14
0
void PlugOutIterateResetCallback(PlugOutPtr self, ObjectPtr obj)
{
	TTUInt32	vectorSize;
	method		audioResetMethod = zgetfn(obj, GENSYM("audio.reset"));

	if (audioResetMethod) {
		self->audioGraphObject->getUnitGenerator()->getAttributeValue(TT("vectorSize"), vectorSize);
		audioResetMethod(obj, vectorSize);
	}
}
Ejemplo n.º 15
0
long object_is_hoa(t_object* z)
{
    rmethod nrmethod = NULL;
    nrmethod = (rmethod)zgetfn((t_pd *)z, _sym_is_hoa);
    if(nrmethod)
    {
        return (long)nrmethod((t_pd *)z);
    }
    else
        return 0;
}
Ejemplo n.º 16
0
static void import_addclassname(t_port *x, char *outname, t_atom *inatom)
{
    t_atom at;
    if (outname)
	SETSYMBOL(&at, gensym(outname));
    else
    {
	t_symbol *insym = 0;
	if (inatom->a_type == A_SYMBOL)
	{
	    /* LATER bash inatom to lowercase (CHECKME first) */
	    insym = inatom->a_w.w_symbol;
	    if (import_mapping && import_mapsize)
	    {
		char **fromp = import_mapping, **top = import_mapping + 1;
		int cnt = import_mapsize;
		while (cnt--)
		{
		    if (strcmp(*fromp, insym->s_name))
		    {
			fromp += 2;
			top += 2;
		    }
		    else
		    {
			insym = gensym(*top);
			inatom = 0;
			break;
		    }
		}
	    }
	    if (insym != &s_bang && insym != &s_float &&
		insym != &s_symbol && insym != &s_list &&
		(insym == portps_inlet || insym == portps_outlet ||
		 zgetfn(&pd_objectmaker, insym) == 0))
	    {
		x->x_withbogus = 1;
		SETSYMBOL(&at, portps_bogus);
		binbuf_add(x->x_outbb, 1, &at);
	    }
	}
	if (inatom)
	    import_copyatoms(&at, inatom, 1);
	else if (insym)
	    SETSYMBOL(&at, insym);
	else
	{
	    loudbug_bug("import_addclassname");
	    SETSYMBOL(&at, gensym("???"));
	}
    }
    binbuf_add(x->x_outbb, 1, &at);
}
Ejemplo n.º 17
0
void hammer_setup(void)
{
    if (canvas_getcurrent())
    {
	/* Loading the library by object creation is banned, because of a danger
	   of having some of the classes already loaded. LATER rethink. */
	loud_error(0, "apparently an attempt to create a 'hammer' object");
	loud_errand(0, "without having hammer library preloaded");
	return;
    }
    if (zgetfn(&pd_objectmaker, gensym("hammer")))
    {
	loud_error(0, "hammer is already loaded");
	return;
    }
    if (!zgetfn(&pd_objectmaker, gensym("cyclone")))
	post("this is hammer %s, %s %s build",
	     CYCLONE_VERSION, loud_ordinal(CYCLONE_BUILD), CYCLONE_RELEASE);
    hammer_class = class_new(gensym("hammer"),
			     (t_newmethod)hammer_new,
			     (t_method)hammer_free,
			     sizeof(t_hammer), 0, 0);
    class_addbang(hammer_class, hammer_bang);
    class_addmethod(hammer_class, (t_method)hammer_cd,
		    gensym("cd"), A_DEFSYM, 0);
    class_addmethod(hammer_class, (t_method)hammer_pwd,
		    gensym("pwd"), A_SYMBOL, 0);
    class_addmethod(hammer_class, (t_method)hammer_import,
		    gensym("import"), A_DEFSYM, 0);
    class_addmethod(hammer_class, (t_method)hammer_click,
		    gensym("click"),
		    A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
    hammerfile_setup(hammer_class, 0);
    hammer_firstndx = fragile_class_count();
    allhammers_setup();
    hammer_lastndx = fragile_class_count() - 1;
}
Ejemplo n.º 18
0
static void classtest_symbol(t_classtest *x, t_symbol*s)
{
  t_float result=0.;
  if(!pd_objectmaker) {
    pd_error(x, "[classtest]: couldn't find pd_objectmaker!");
    return;
  }
  if(0!=zgetfn(&pd_objectmaker, s))
    result=1.;

  outlet_float(x->x_out, result);



}
Ejemplo n.º 19
0
long hub_iterate_callback(t_hub *x, t_object *obj)
{
	method		subscribeMethod = NULL;
	//ObjectPtr	p = jbox_get_patcher(obj);
	//SymbolPtr	s = jpatcher_get_name(p);
	//SymbolPtr	name = object_classname(obj);
	
	//object_post(ObjectPtr(x), "iterate: %s (in %s)", name->s_name, s);
	
	if(!object_classname_compare(obj, jps_jcom_hub)){
		subscribeMethod = zgetfn(obj, jps_subscribe);
		if(subscribeMethod)
			(*subscribeMethod)(obj);
	}
	return 0;
}
Ejemplo n.º 20
0
void WrappedInputClass_anything(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;

    // route any message to the model
//    if (msg != _sym_nothing && msg != _sym_jit_matrix && msg != _sym_jit_gl_texture && msg != _sym_dictionary) {
    if (msg != _sym_nothing ) {
        
        // get model or view object
        if (!EXTRA->modelOrView)
            jamoma_patcher_get_model_or_view(x->patcherPtr, &EXTRA->modelOrView);
        
        zgetfn((t_pd*)x,msg)((t_object*)EXTRA->modelOrView, argc, argv, NULL);
//        object_method_typed(EXTRA->modelOrView, msg, argc, argv, NULL);
        return;
    }
	
    jamoma_input_send(x->wrappedObject, msg, argc, argv);
}
Ejemplo n.º 21
0
/* remove every object from a glist.  Experimental. */
void glist_clear(t_glist *x)
{
    t_gobj *y, *y2;
    int dspstate = 0, suspended = 0;
    t_symbol *dspsym = gensym("dsp");
    while (y = x->gl_list)
    {
        /* to avoid unnecessary DSP resorting, we suspend DSP
        only if we hit a patchable object. */
        if (!suspended && pd_checkobject(&y->g_pd) && zgetfn(&y->g_pd, dspsym))
        {
            dspstate = canvas_suspend_dsp();
            suspended = 1;
        }
        /* here's the real deletion. */
        glist_delete(x, y);
    }
    if (suspended)
        canvas_resume_dsp(dspstate);
}
Ejemplo n.º 22
0
static void preset_float(t_presetobj *x, float f)
{
    t_canvas *cnv = eobj_getcanvas(x);
    if(cnv && !cnv->gl_loading)
    {
        x->f_binbuf_selected = pd_clip(f, 1, CREAM_MAXITEMS) - 1;
        t_binbuf* b = x->f_binbuf[x->f_binbuf_selected];
        if(b && binbuf_getnatom(b) && binbuf_getvec(b))
        {
            char id[MAXPDSTRING];
            for(t_gobj *y = eobj_getcanvas(x)->gl_list; y; y = y->g_next)
            {
                t_ebox * z = (t_ebox *)y;
                t_gotfn mpreset = zgetfn(&y->g_pd, cream_sym_preset);
                /*
                if(mpreset && z->b_preset_id && z->b_preset_id != cream_sym_nothing)
                {
                    int ac = 0;
                    t_atom* av = NULL;
                    sprintf(id, "@%s", z->b_preset_id->s_name);
                    binbuf_get_attribute(b, gensym(id), &ac, &av);
                    if(ac && av && atom_gettype(av) == A_SYMBOL && atom_gettype(av+1) == A_SYMBOL)
                    {
                        if(eobj_getclassname(z) == atom_getsymbol(av))
                        {
                            pd_typedmess((t_pd *)z, atom_getsymbol(av+1), ac-2, av+2);
                        }
                    }
                    if(ac && av)
                    {
                        free(av);
                    }
                }*/
                mpreset = NULL;
            }

            ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
            ebox_redraw((t_ebox *)x);
        }
    }
}
Ejemplo n.º 23
0
t_pd_err eobj_iscicm(void* x)
{
    return (t_pd_err)zgetfn((t_pd *)x, s_iscicm);
}
Ejemplo n.º 24
0
static int rdsink_push(t_rdsink *si, t_object *x, int outno)
{
    int result = 1;
    t_outlet *op;
    t_outconnect *oc = obj_starttraverseoutlet(x, &op, outno);
    while (oc)
    {
        t_object *dst;
        t_inlet *ip;
        int inno;
        oc = obj_nexttraverseoutlet(oc, &dst, &ip, &inno);
        if (dst)
        {
            int siginno = obj_siginletindex(dst, inno);
            if (siginno < 0)
            {
                /* should not happen, LATER rethink */
            }
            else if (zgetfn((t_pd *)dst, rdps__reblock))
            {
                si->si_outbuf->a_w.w_float = (t_float)siginno;
                typedmess((t_pd *)dst, rdps__reblock, 4, si->si_outbuf);
            }
            else if (pd_class((t_pd *)dst) == canvas_class)
            {
                t_gobj *ob;
                int i;
                for (i = 0, ob = ((t_canvas *)dst)->gl_list;
                        ob; ob = ob->g_next)
                {
                    if (pd_class((t_pd *)ob) == vinlet_class)
                    {
                        if (i == inno)
                            break;
                        else
                            i++;
                    }
                }
                if (ob)
                {
#ifdef RIDDLE_DEBUG
                    riddlebug_post(si->si_riddle, "PUSH-SUBCANVAS",
                                   "vinlet %d (\"%s\")",
                                   inno, class_getname(*(t_pd *)ob));
#endif
                    rdsink_push(si, (t_object *)ob, 0);
                }
                else loudbug_bug("rdsink_push 1");
            }
            else if (pd_class((t_pd *)dst) == voutlet_class)
            {
                t_rdvoutlet *vout = (t_rdvoutlet *)dst;
                if (vout->x_canvas)
                {
                    int n;
                    t_outlet *o;
                    for (o = ((t_object *)vout->x_canvas)->ob_outlet, n = 0;
                            o; o = (t_outlet *)(((t_rdoutlet *)o)->o_next), n++)
                        if (o == vout->x_parentoutlet)
                            break;
                    if (o)
                    {
#ifdef RIDDLE_DEBUG
                        riddlebug_post(si->si_riddle, "PUSH-OUTLET",
                                       "outno %d, graph %x",
                                       n, (int)vout->x_canvas);
#endif
                        rdsink_push(si, (t_object *)vout->x_canvas, n);
                    }
                    else loudbug_bug("rdsink_push 2");
                }
#ifdef RIDDLE_DEBUG
                else riddlebug_post(si->si_riddle, "PUSH-OUTLET",
                                        "void canvas...");
#endif
            }
            else
            {
                char *dstname = class_getname(*(t_pd *)dst);
#ifdef RIDDLE_DEBUG
                riddlebug_post(si->si_riddle, "PUSH-RIDDLESS",
                               "inlet %d (\"%s\")", inno, dstname);
#endif
                if (si->si_flags & RIDDLE_STRICTNESSMASK)
                {
                    if (strcmp(dstname, "print~"))
                    {
                        loud_error((t_pd *)x, "not a riddle: \"%s\"", dstname);
                        result = 0;
                    }
                }
                else if (!strcmp(dstname, "send~") ||
                         !strcmp(dstname, "throw~"))
                {
                    loud_error((t_pd *)x, "bad destination: \"%s\"", dstname);
                    result = 0;
                }
            }
        }
    }
    return (result);
}
Ejemplo n.º 25
0
static void *riddle_new(t_symbol *s, int ac, t_atom *av)
{
    /* IFBUILTIN remove: this is a bad hack */
    t_pd *en = riddle_getenvironment();
    t_newgimme newfn = (t_newgimme)zgetfn(en, s);
    if (!newfn)
    {
        loudbug_bug("riddle_new 1");
        return (0);
    }
    else
    {
        t_riddle *rd = (t_riddle *)newfn(s, ac, av);
        int i, nslots;
        t_rdsource *inslot;
        t_rdsink *outslot;
        t_rdremote *re;
        if (!rd)
            return (0);

        rd->rd_private = getbytes(sizeof(*rd->rd_private));

        rd->rd_disabled = 0;
        rd->rd_wasdisabled = 0;
        rd->rd_blockfn = (t_rdblockfn)zgetfn((t_pd *)rd, gensym("dspblock"));
        rd->rd_dspfn = (t_rddspfn)zgetfn((t_pd *)rd, gensym("_dsp"));
        if (!rd->rd_dspfn)
            loudbug_bug("riddle_new 2");

        rd->rd_graphsr = (int)sys_getsr();
        rd->rd_graphblock = sys_getblksize();
        rd->rd_nsiginlets = obj_nsiginlets((t_object *)rd);
        rd->rd_nsigoutlets = obj_nsigoutlets((t_object *)rd);

        /* currently, rd_nremoteslots is incremented in rdbuffer_newreader(),
           which relies on calloc in pd_new(), LATER rethink */

        nslots = rd->rd_nsiginlets + rd->rd_nremoteslots;
        rd->rd_inslots = getbytes(nslots * sizeof(*rd->rd_inslots));
        for (i = 0, inslot = rd->rd_inslots; i < nslots; i++, inslot++)
        {
            inslot->so_riddle = rd;
            inslot->so_remote = 0;
            inslot->so_sourcecount = 0;
            inslot->so_pattern = 0;
            inslot->so_newpattern = 0;
            inslot->so_block = 0;
            inslot->so_newblock = 0;
            inslot->so_flags = 0;
        }
        rd->rd_remoteslots = rd->rd_inslots + rd->rd_nsiginlets;

        for (i = 0, inslot = rd->rd_remoteslots, re = rd->rd_remoteports;
                i < rd->rd_nremoteslots; i++, inslot++)
        {
            if (re = rdremote_nextreader(re))
                inslot->so_remote = re;
            else
            {
                loudbug_bug("riddle_new 3");
                break;  /* FIXME this is fatal */
            }
        }

        rd->rd_outslots =
            getbytes(rd->rd_nsigoutlets * sizeof(*rd->rd_outslots));
        for (i = 0, outslot = rd->rd_outslots;
                i < rd->rd_nsigoutlets; i++, outslot++)
        {
            outslot->si_riddle = rd;
            outslot->si_outno = -1;
            outslot->si_pattern = 0;
            outslot->si_block = 0;
            outslot->si_flags = 0;
            outslot->si_outbuf[0].a_type = A_FLOAT;
            outslot->si_outbuf[1].a_type = A_SYMBOL;
            outslot->si_outbuf[1].a_w.w_symbol = rdps__;
            outslot->si_outbuf[2].a_type = A_FLOAT;
            outslot->si_outbuf[3].a_type = A_FLOAT;
            outslot->si_outbuf[3].a_w.w_float = 0.;
            outslot->si_feedchain = 0;
            outslot->si_isready = 0;
        }

        riddle_validatesinks(rd);

        for (i = 0, outslot = rd->rd_outslots;
                i < rd->rd_nsigoutlets; i++, outslot++)
            if (outslot->si_outno >= 0)
                outslot->si_feedchain = rdfeedchain_new(outslot->si_outno);

        rd->rd_idlepicker = rdpicker_attach(rd, gensym("_idle"));

        return (rd);
    }
}
Ejemplo n.º 26
0
/* delete an object from a glist and free it */
void glist_delete(t_glist *x, t_gobj *y)
{
    t_gobj *g;
    t_object *ob;
    t_gotfn chkdsp = zgetfn(&y->g_pd, gensym("dsp"));
    t_canvas *canvas = glist_getcanvas(x);
    int drawcommand = class_isdrawcommand(y->g_pd);
    int wasdeleting;

    wasdeleting = canvas_setdeleting(canvas, 1);
    if (x->gl_editor)
    {
        if (x->gl_editor->e_grab == y) x->gl_editor->e_grab = 0;
        if (glist_isselected(x, y)) glist_deselect(x, y);

        /* HACK -- we had phantom outlets not getting erased on the
        screen because the canvas_setdeleting() mechanism is too
        crude.  LATER carefully set up rules for when the rtexts
        should exist, so that they stay around until all the
        steps of becoming invisible are done.  In the meantime, just
        zap the inlets and outlets here... */
        if (pd_class(&y->g_pd) == canvas_class)
        {
            t_glist *gl = (t_glist *)y;
            if (gl->gl_isgraph && glist_isvisible(x))
            {
                char tag[80];
                sprintf(tag, "graph%lx", (t_int)gl);
                glist_eraseiofor(x, &gl->gl_obj, tag);
            }
            else
            {
                if (glist_isvisible(x))
                    text_eraseborder(&gl->gl_obj, x,
                                     rtext_gettag(glist_findrtext(x, &gl->gl_obj)));
            }
        }
    }
    /* if we're a drawing command, erase all scalars now, before deleting
    it; we'll redraw them once it's deleted below. */
    if (drawcommand)
        canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(
                                        glist_getcanvas(x)->gl_name)), 2);
    gobj_delete(y, x);
    if (glist_isvisible(canvas))
    {
        gobj_vis(y, x, 0);
    }
    if (x->gl_editor && (ob = pd_checkobject(&y->g_pd)))
        rtext_new(x, ob);
    if (x->gl_list == y) x->gl_list = y->g_next;
    else for (g = x->gl_list; g; g = g->g_next)
            if (g->g_next == y)
            {
                g->g_next = y->g_next;
                break;
            }
    pd_free(&y->g_pd);
    if (chkdsp) canvas_update_dsp();
    if (drawcommand)
        canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(
                                        glist_getcanvas(x)->gl_name)), 1);
    canvas_setdeleting(canvas, wasdeleting);
    x->gl_valid = ++glist_valid;
}
Ejemplo n.º 27
0
void maxmode_setup(void)
{
    int dresult = LOADER_OK;
    if (zgetfn(&pd_objectmaker, gensym("maxmode")))
    {
	loud_error(0, "maxmode is already loaded");
	return;
    }
    maxmode_class = class_new(gensym("maxmode"),
			      (t_newmethod)maxmode_new,
			      (t_method)maxmode_free,
			      sizeof(t_maxmode), 0, A_GIMME, 0);
    class_addbang(maxmode_class, maxmode_bang);
    class_addmethod(maxmode_class, (t_method)maxmode_set,
		    gensym("set"), A_DEFSYM, 0);
    class_addmethod(maxmode_class, (t_method)maxmode_get,
		    gensym("get"), 0);
    class_addmethod(maxmode_class, (t_method)maxmode_cd,
		    gensym("cd"), A_DEFSYM, 0);
    class_addmethod(maxmode_class, (t_method)maxmode_pwd,
		    gensym("pwd"), A_SYMBOL, 0);
    class_addmethod(maxmode_class, (t_method)maxmode_import,
		    gensym("import"), A_DEFSYM, 0);
    class_addmethod(maxmode_class, (t_method)maxmode_click,
		    gensym("click"),
		    A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
    hammerfile_setup(maxmode_class, 0);

    if (canvas_getcurrent())
    {
	fitter_setup(0, 0);
	if (!zgetfn(&pd_objectmaker, gensym("cyclone")))
	    /* cycloneless maxmode -- banner is posted by the oldest
	       maxmode object with no creation arguments */
	    maxmode_withbanner = 1;
    }
    else
    {
	fittermax_set();
	if (zgetfn(&pd_objectmaker, gensym("cyclone")))
	    loud_warning(0, "maxmode", "cyclone is already loaded");
	else
	{
	    if (unstable_load_lib("", "cyclone") == LOADER_NOFILE)
		loud_error(0, "cyclone library is missing");
	    else if (!zgetfn(&pd_objectmaker, gensym("cyclone")))
		loud_error(0, "miXed/Pd version mismatch");
	}
    }
    maxmode_dummiesndx = fragile_class_count();
    if (zgetfn(&pd_objectmaker, gensym("dummies")))
	loud_warning(0, "maxmode", "dummies are already loaded");
    else
	dresult = unstable_load_lib("", "dummies");
    maxmode_lastndx = fragile_class_count() - 1;
    if (dresult == LOADER_NOFILE)
	loud_warning(0, "maxmode", "dummies not found");
    else
    {
	t_symbol *s = gensym("_cc.dummies");
	if (s->s_thing && !s->s_next
	    && !strcmp(class_getname(*s->s_thing), "_cc.dummies"))
	    maxmode_dproxy = s->s_thing;
	else
	    loudbug_bug("maxmode_setup");  /* FIXME */
    }
}
Ejemplo n.º 28
0
void preset_interpolate(t_presetobj *x, float f)
{
    t_gobj *y;
    t_ebox *z;
    t_gotfn mpreset = NULL;
    t_gotfn minterp = NULL;

    int acdo, acup, ac, max;
    t_atom *avdo, *avup, *av;
    char id[MAXPDSTRING];
    int i, j, indexdo, indexup, realdo, realup;
    float ratio;

    max = -1;
    for(i = CREAM_MAXITEMS-1; i >= 0; i--)
    {
        if(binbuf_getnatom(x->f_binbuf[i]))
        {
            max = i + 1;
            break;
        }
    }
    if(max < 1)
        return;

    indexdo = pd_clip(floorf(f)-1, 0, max-1);
    indexup = pd_clip(ceilf(f)-1, 0, max-1);
    if(indexdo == indexup || f <= 1 || f >= max)
    {
        preset_float(x, f);
        return;
    }

    x->f_binbuf_selected = indexdo;

    // Look for all the objects in a canvas //
    for (y = eobj_getcanvas(x)->gl_list; y; y = y->g_next)
    {
        z = (t_ebox *)y;
        mpreset = zgetfn(&y->g_pd, cream_sym_preset);
        // We find a preset method so we can send preset //
        /*
        if(mpreset && z->b_preset_id && z->b_preset_id != cream_sym_nothing)
        {
            sprintf(id, "@%s", z->b_preset_id->s_name);
            realdo = -1;
            realup = -1;
            acdo = 0;
            acup = 0;

            // Look for all the preset from the smallest index to zero //
            for(j = indexdo; j >= 0 && realdo == -1; j--)
            {
                // We find a recorded preset //
                if(binbuf_getnatom(x->f_binbuf[j]))
                {
                    // We get the preset //
                    binbuf_get_attribute(x->f_binbuf[j], gensym(id), &acdo, &avdo);
                    if(acdo >= 2 && avdo && atom_gettype(avdo) == A_SYMBOL && atom_gettype(avdo+1) == A_SYMBOL)
                    {
                        // If the object is in the preset we record the preset else we skip this preset //
                        if(eobj_getclassname(z) == atom_getsymbol(avdo))
                        {
                            realdo = j;
                            break;
                        }
                        else
                        {
                            avdo = NULL;
                            acdo = 0;
                        }
                    }
                }
            }
         
            // Look for all the preset from the biggest index to the top //
            for(j = indexup; j <= max && realup == -1; j++)
            {
                // We find a recorded preset //
                if(binbuf_getnatom(x->f_binbuf[j]))
                {
                    // We get the preset //
                    binbuf_get_attribute(x->f_binbuf[j], gensym(id), &acup, &avup);
                    if(acup >= 2 && avup && atom_gettype(avup) == A_SYMBOL && atom_gettype(avup+1) == A_SYMBOL)
                    {
                        // If the object is in the preset we record the preset else we skip this preset //
                        if(eobj_getclassname(z)== atom_getsymbol(avup))
                        {
                            realup = j;
                            break;
                        }
                        else
                        {
                            avup = NULL;
                            acup = 0;
                        }
                    }
                }
            }

            // If we have the 2 presets with the same selector for this object then we make an interpolation //
            if(acdo && acup && atom_getsymbol(avdo+1) == atom_getsymbol(avup+1))
            {
                minterp = zgetfn(&y->g_pd, cream_sym_interpolate);
                if(minterp)
                {
                    t_atom theta;
                    ratio = (float)(f - (realdo + 1)) / (float)(realup - realdo);
                    atom_setfloat(&theta, ratio);
                    minterp((t_pd *)z, (short)acdo-2, avdo+2, (short)acup-2, avup+2, theta);
                }
                else
                {
                    ratio = (float)(f - (realdo + 1)) / (float)(realup - realdo);
                    ac = acdo;
                    av = (t_atom *)calloc((size_t)ac, sizeof(t_atom));
                    atom_setsym(av+1, atom_getsymbol(avdo+1));
                    for(j = 2; j < ac; j++)
                    {
                        if(j < acup)
                        {
                            if(atom_gettype(avdo+j) == A_FLOAT && atom_gettype(avup+j) == A_FLOAT )
                            {
                                atom_setfloat(av+j, atom_getfloat(avdo+j) * (1. - ratio) + atom_getfloat(avup+j) * ratio);
                            }
                            else
                            {
                                av[j] = avdo[j];
                            }
                        }
                        else
                        {
                            av[j] = avdo[j];
                        }
                    }

                    pd_typedmess((t_pd *)z, atom_getsymbol(av+1), ac-2, av+2);
                    free(av);
                }
            }
            // If we have only the smallest preset for this object //
            else if(acdo)
            {
                pd_typedmess((t_pd *)z, atom_getsymbol(avdo+1), acdo-2, avdo+2);
            }
            // If we have only the highest preset for this object //
            else if(acup)
            {
                pd_typedmess((t_pd *)z, atom_getsymbol(avup+1), acup-2, avup+2);
            }
        }*/
        mpreset = NULL;
    }

    ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
    ebox_redraw((t_ebox *)x);
}