Exemple #1
0
void *bartime_new(long arg1, long arg2, long arg3, long arg4)
{
	t_bartime *x;
	x = (t_bartime *)object_alloc(bartime_class);
	if(x){
		intin(x,4);
		intin(x,3);
		intin(x,2);
		intin(x,1);
		
		x->s_outlet1 = intout(x);
		x->s_outlet2 = intout(x);
		x->s_outlet3 = intout(x);
		x->s_outlet4 = intout(x);
		x->s_outlet5 = intout(x);
		
		x->s_numerator = 4;
		x->s_nominator = 4;
		x->s_ticksperbeat = 1000;
		x->s_beatdivision = 8;
		
		if(arg1) x->s_numerator = arg1;
		if(arg2) x->s_nominator = arg2;
		if(arg3) x->s_ticksperbeat= arg3;
		if(arg4) x->s_beatdivision = arg4;
		
		bartime_precalc(x);
	}
	return (x);
}
Exemple #2
0
void *GCD_new() {
	t_GCD *x = (t_GCD *)object_alloc(t_gcd_class);
	x->storedVal = 1;
	intin(x, 1);
	x->m_outlet1 = intout((t_object *)x);
	return x;
}
Exemple #3
0
void *ccext_new(long arg1)
{
	t_ccext *x; 
	x = (t_ccext *)object_alloc(ccext_class);
	if(x){
	intin(x,1);
	x->c_outlet = intout(x);
	x->c_memory = 0;	
	if (arg1 == 0){
		x->c_mode = 0;
		}
	else if(arg1 == 1){
		x->c_mode = 1;
		}
	else if(arg1 == 2){
		x->c_mode = 2;
		}
	else if(arg1 == 3){
		x->c_mode = 3;
		}
	else 
		object_error((t_object *)x, "error in argument: mode %ld", arg1);
	}
	return x;
}
Exemple #4
0
void*
SssNew(
	long	iNN,
	long	iSeed)
	
	{
	tPink*			me			= NIL;
	tTaus88DataPtr	myTausStuff	= NIL;	
	
	
	// Run through initialization parameters from right to left, handling defaults
	if (iSeed != 0) myTausStuff = Taus88New(iSeed);
	
	// Default NN value doesn't need massaging
	// Finished checking intialization parameters

	// Let Max allocate us, our inlets, and outlets.
	me = (tPink*) newobject(gObjectClass);
	
	intin(me, 1);								// NN inlet
	
	floatout(me);								// Access through me->coreObject.o_outlet
	
	// Set up object components
	me->tausData = myTausStuff;
	SssNN(me, iNN);
	me->counter = 0;							// This will cause the dice array to be
												// initialized at the first bang.

	return me;
	}
Exemple #5
0
/*------------------------------------ VjetCreate ---*/
static void *
VjetCreate(const long howMany)
{
    VObjectData * xx = static_cast<VObjectData *>(object_alloc(gClass));
    
    if (xx)
    {
        xx->fPreviousList = NULL;
        xx->fPreviousLength = 0;
        if (0 < howMany)
        {
            xx->fHowMany = howMany;
            intin(xx, 1);
            xx->fResultOut = static_cast<t_outlet *>(outlet_new(xx, NULL));
            if (! xx->fResultOut)
            {
                LOG_ERROR_1(xx, OUTPUT_PREFIX "unable to create port for object")
                freeobject(reinterpret_cast<t_object *>(xx));
                xx = NULL;
            }
        }
        else
        {
            LOG_ERROR_2(xx, OUTPUT_PREFIX "invalid segment size (%ld)", howMany)
            freeobject(reinterpret_cast<t_object *>(xx));
            xx = NULL;
        }
    }
    return xx;
} // VjetCreate
//----------------------------------------------------------------------------------------------------------------
// object creation
void *udmx_new(t_symbol *s, long argc, t_atom *argv)	{
    

    t_atom *ap;
    t_int16 n;
    n = 0;
    
 
    // n = int argument typed into object box (A_DEFLONG) -- defaults to 0 if no args are typed
    
    t_udmx *x = (t_udmx *)object_alloc(udmx_class);
    intin(x,1);					// create a second int inlet (leftmost inlet is automatic - all objects have one inlet by default)
    x->m_clock = clock_new(x,(method)udmx_tick); 	// make new clock for polling and attach tick function to it
    x->m_qelem = qelem_new((t_object *)x, (method)find_device);
    
    x->msgOutlet = outlet_new(x,0L);	//create right outlet
    x->statusOutlet = outlet_new(x,0L);	//create an outlet for connected flag
    
    x->correct_adressing = 1;
    
    if (argc) {
        ap = argv;
        switch (atom_gettype(ap)) {
            case A_LONG:
                n = atom_getlong(ap);
                break;
            default:
                break;
        }
        ap = &argv[argc-1];
        
        switch (atom_gettype(ap)) {
            case A_LONG:
                if (atom_getlong(ap) == 0 ) {
                    x->correct_adressing = 0;
                }
                break;
            default:
                break;
        }
     }
    if(x->correct_adressing) {n = n - 1;}
    if (n < 0) n = 0;
    if (n > 511) n = 511;

    x->channel = n;
    x->debug_flag = 0;
    x->channel_changed_min = 512;
    x->channel_changed_max = -1;
    x->clock_running = 0;
    x->dev_handle = NULL;
    x->speedlim = SPEED_LIMIT;
    x->usb_devices_seen = -1;

    
    clock_fdelay(x->m_clock,100);
    usb_init();
    
    return(x);					// return a reference to the object instance
}
Exemple #7
0
static void*
LiliNew(
	unsigned long	iMul,					// Note that Max is thinking signed; we think
	unsigned long	iAdd,					// unsigned. Hope no one gets too confused.
	unsigned long	iMod,
	unsigned long	iSeed)
	
	{
	const long	kDefMul		= 65539,
				kDefSeed	= 1;
	
	objLili*	me	= NIL;
	
	// Run through initialization parameters from right to left, handling defaults
	if (iSeed == 0)  
		iSeed = kDefSeed;
	else goto noMoreDefaults;
	
		// 0 is default of iMod and iAdd
	if (iMod != 0) goto noMoreDefaults;
	if (iAdd != 0) goto noMoreDefaults;
			
	if (iMul == 0)
		iMul = kDefMul;
noMoreDefaults:
	// Finished checking intialization parameters
	
	// Let Max allocate us, our inlets, and outlets
	me = (objLili*) LitterAllocateObject();

	intin(me, 3);										// Mod inliet
	intin(me, 2);										// Adder inlet
	intin(me, 1);										// Multiplier inlet
	
	intout(me);					// Access main outlet through me->coreObject.o_outlet;
	
	// Initialize and store object components
	me->mul		= iMul;
	me->add		= iAdd;
	me->mod		= iMod;
	me->seed	= iSeed;
	
	return me;
	}
Exemple #8
0
void *index_new(t_symbol *s, long chan)
{
	t_index *x = (t_index *)newobject(index_class);
	dsp_setup((t_pxobject *)x, 1);
	intin((t_object *)x,1);
	outlet_new((t_object *)x, "signal");
	x->l_sym = s;
	index_in1(x,chan);
	return (x);
}
Exemple #9
0
void *index_new(t_symbol *s, long chan)
{
	t_index *x = object_alloc(index_class);
	dsp_setup((t_pxobject *)x, 1);
	intin((t_object *)x,1);
	outlet_new((t_object *)x, "signal");
	index_set(x, s);
	index_in1(x,chan);
	return (x);
}
Exemple #10
0
static void*
DiceyNew(
	long	iNDice,
	long	iNFaces,
	long	iSeed)
	
	{
	objDicey*			me				= NIL;
	tTaus88DataPtr	myTaus88Stuff	= NIL;
	
	// Run through initialization parameters from right to left, handling defaults
	if (iSeed != 0) {
		myTaus88Stuff = Taus88New(iSeed);
		goto noMoreDefaults;
		}
	
	if (iNFaces == 0)
		iNFaces = kDefNFaces;
	else goto noMoreDefaults;
	
	if (iNDice == 0)
		iNDice = kDefNDice;
noMoreDefaults:
	// Finished checking intialization parameters

	// Let Max allocate us, our inlets, and outlets
	me = (objDicey*) LitterAllocateObject();

	
	intin(me, 2);										// Number of faces
	intin(me, 1);										// Number of dice
	
	intout(me);					// Access main outlet through me->coreObject.o_outlet;
	
	// Initialize object components
	me->tausData	= myTaus88Stuff;
	DiceyNDice(me, iNDice);
	DiceyNFaces(me, iNFaces);
	
	return me;
	}
Exemple #11
0
void *pokef_new(t_symbol *s, long chan)
{
	t_pokef *x = (t_pokef *)object_alloc(pokef_class);
	//dsp_setup((t_pxobject *)x, 1);
    intin((t_object *)x, 3);
	dsp_setup((t_pxobject *)x, 3);
	outlet_new((t_object *)x, "signal");
	pokef_set(x, s);
	pokef_in3(x,chan);
	//x->l_obj.z_misc = Z_NO_INPLACE;
	return (x);
}
Exemple #12
0
/* function run to create a new instance of the t_slice class */
void *slice_new(long s)
{
	t_slice *x;							/* object we'll be creating */
	
	x = (t_slice *)object_alloc(s_slice_class);	/* allocates memory and sticks in an inlet */
	intin(x, 1);                        	/* added jun 96 rdd - was missing from code */
	x->s_out2 = intout(x);
	x->s_out1 = intout(x);
	x->s_len = 0;
	x->s_split = s < 1 ? 1 : s;
	return (x);						/* always return a copy of the created object */
}
Exemple #13
0
void *
valid_date_new()
{
        t_valid_date *x = (t_valid_date *)object_alloc(s_valid_date_class);
        intin(x, 4);
        intin(x, 3);
        intin(x, 2);
        intin(x, 1);
    
        x->m_outlet4 = intout((t_object *)x);
        x->m_outlet3 = intout((t_object *)x);
        x->m_outlet2 = intout((t_object *)x);
        x->m_outlet1 = intout((t_object *)x);
        x->m_outlet0 = outlet_new((t_object *)x, NULL);
    
        x->month = 0;
        x->day = 0;
        x->hour = 0;
        x->minute = 0;
    
        return (void *)x;
}
Exemple #14
0
void *minimum_new(t_symbol *s, long ac, t_atom *av)
{
	t_minimum *x;

	x = object_alloc(minimum_class);
	systhread_mutex_new(&x->m_mutex, 0);
	x->m_count = 0;
	x->m_args = NULL;
	minimum_resize(x,2);
	x->m_out2 = intout(x);
	if (ac) {
		x->m_args[1] = *av;
		if (atom_gettype(av)==A_LONG) {
			x->m_args[0].a_type = x->m_outtype = A_LONG;
			x->m_out = intout(x);
			x->m_args[0].a_w.w_long = 0;
			intin(x,1);
		} else if (atom_gettype(av)==A_FLOAT) {
			x->m_args[0].a_type = x->m_outtype = A_FLOAT;
			x->m_out = floatout(x);
			x->m_args[0].a_w.w_float = 0;
			floatin(x,1);
		} else {
			x->m_outtype = A_LONG;
			intin(x,1);
			x->m_out = intout(x);
			atom_setlong(x->m_args+1,0L);
			atom_setlong(x->m_args,0L);
		}
	} else {
		x->m_outtype = A_LONG;
		intin(x,1);
		x->m_out = intout(x);
		atom_setlong(x->m_args+1,0L);
		atom_setlong(x->m_args,0L);
	}
	return x;
}
Exemple #15
0
void *filein_new(t_symbol *fn, t_symbol *spoolFlag)
{
	t_filein *x;
	
	x = object_alloc(filein_class);
	x->f_readdone = bangout(x);
	x->f_eof = bangout(x);
	x->f_out = intout(x);
	intin(x,2);
	intin(x,1);
	x->f_open = FALSE;
	x->f_fh = 0;
	x->f_spool = 0;
	x->f_data = 0;
	if (fn != ps_nothing) {
		if (spoolFlag==ps_spool)
			x->f_spool = TRUE;
		else
			x->f_spool = FALSE;
		filein_doread(x,fn);
	}
	return (x);
}			
Exemple #16
0
void *randist_new(long num)
{
	t_randist *x;


	x = (t_randist *)object_alloc(randist_class);
	if (num < 2)
		num = 2;
	x->b_num = num;
	x->b_id = 0;
	x->distType = 0;
	x->possNum = 2;
	x->varFlt1 = 0.07; // default standard deviation for gaussian
	x->varFlt2 = 0.5; //default mean for gaussian
	x->rand_out = floatout((t_object *)x);
	x->inVar2 = floatin(x, 2);
	x->inVar1 = floatin(x, 1);
	x->inDist = intin(x, 3);
	x->inPoss = intin(x, 4);



	return x;
}
Exemple #17
0
void *thresh_new(long interval)
{
	t_thresh *x;
	short i;
	
	x = (t_thresh *)newobject(thresh_class);
	intin(x,1);
	x->t_out = outlet_new((t_object *)x,0); // cause it sends out lists and ints
	x->t_clock = clock_new(x,(method)thresh_tick);
	x->t_time = gettime();
	x->t_interval = interval < 5 ? 5 : interval;
	x->t_av = (t_atom *) sysmem_newptr(MAXSIZE*sizeof(t_atom));
	x->t_ac = 0;
	for (i=0; i < MAXSIZE; i++)
		SETLONG(x->t_av+i,0);
	
	return (x);
}			
void *channel_new(t_symbol *s, int argc, t_atom *argv)
{
#if MSP
	t_channel *x = (t_channel *)newobject(channel_class);
	intin(x,1);
	dsp_setup((t_pxobject *)x,1);
	outlet_new((t_object *)x, "signal");

#endif
#if PD
	t_channel *x = (t_channel *)pd_new(channel_class);
	outlet_new(&x->x_obj, gensym("signal"));	
#endif

	x->channel = (int)atom_getfloatarg(0,argc,argv);
	// x->channel = 0;
	return (x);
}
void *afiddle_new (long lenght)
{
	short i;
	afiddle *x;
	x = (afiddle *)newobject(afiddle_class);
	intin(x,1); 

	if(lenght < 1) x->x_tsillen = 100;//register outlistsize
	else x->x_tsillen = lenght;

	//zero doubles on the atom.double struct
	for (i=0;i<MAXSIZE;i++) {
		x->x_inlist[i].a_w.w_float=0.000f;
		}

	x->x_outlet = listout(x);	
	x->x_fire = 1;
	x->x_clear = 1;
	x->x_offset = 0.00f;
	return (x);
} 
void*
BernieNew(
	long	iNTrials,
	double	iProb,
	long	iSeed)
	
	{
	const long		kDefNTrials		= 1;
	const double	kDefProb		= 0.5;
	
	objBernie*	me = (objBernie*) newobject(gObjectClass);	// Default instantiation
	
	// Allocate inlets and outlets	
	floatin(me, 2);											// p(1)
	intin(me, 1);											// Number of Trials
	
	intout(me);					// Access main outlet through me->coreObject.o_outlet;
	
	// Set up our own members to defaults
	me->tausData	= NIL;
	me->prob		= kDefProb;
	me->nTrials		= kDefNTrials;
	me->gen			= genUndef;
		// Don't need to worry about genParams as long as the generator is undefined
	
	// Run through initialization parameters from right to left, checking for defaults
	if (iSeed == 0) Taus88Init();
	else me->tausData = Taus88New(iSeed);
	
	if (iProb == 0.0)	iProb = kDefProb;
	if (iNTrials == 0)	iNTrials = kDefNTrials;

	// Any changes from defaults?
	if (iNTrials != kDefNTrials)
		BernieNTrials(me, iNTrials);
	if (iProb != kDefProb)
		BernieProb(me, iProb);
	
	return me;
	}
void *ringdiff_new(t_symbol *s, long argc, t_atom *argv)
{
	t_ringdiff *x = NULL;
    long i;

    
	// object instantiation, NEW STYLE
	if (x = (t_ringdiff *)object_alloc(ringdiff_class)) {
        //object_post((t_object *)x, "a new %s object was instantiated: 0x%X", s->s_name, x);
        //object_post((t_object *)x, "it has %ld argu", argc);
        intin(x, 1);//inlet 1
        //x->m_outlet2 = bangout((t_object *)x);
        
        x->m_outlet1 = floatout((t_object *)x);
        x->counter = 0;
        x->mod = 1;
        x->previousVal = 0.0;
        
        for (i = 0; i < argc; i++) {
            if ((argv + i)->a_type == A_LONG) {
                long tempArg = atom_getlong(argv+i);
                object_post((t_object *)x, "arg %ld: long (%ld)", i, tempArg);
                if(i==0 && tempArg > 0 && tempArg <= 1000){
                    post("initial buffer size set to %ld", tempArg);
                    x->mod = atom_getlong(argv+i);
                }
                
            } else if ((argv + i)->a_type == A_FLOAT) {
                object_post((t_object *)x, "arg %ld: float (%f)", i, atom_getfloat(argv+i));
            } else if ((argv + i)->a_type == A_SYM) {
                object_post((t_object *)x, "arg %ld: symbol (%s)", i, atom_getsym(argv+i)->s_name);
            } else {
                object_error((t_object *)x, "forbidden argument");
            }
        }
	}    
	return (x);
}
Exemple #22
0
static void *rvbap_new(t_symbol *s, int ac, t_atom *av)  
/* create new instance of object... MUST send it an int even if you do nothing with this int!! */
{
    t_rvbap *x;
#ifdef MAXMSP
    x = (t_rvbap *)newobject(rvbap_class);
    
    t_floatin(x,4);       /* takes the distance */
    intin(x,3); 
    intin(x,2);                 /* create a second (int) inlet... remember right-to-left ordering in Max */
    intin(x,1);                 /* create a second (int) inlet... remember right-to-left ordering in Max */
    x->x_outlet4 = floatout(x); /* distance */
    x->x_outlet3 = intout(x);
    x->x_outlet2 = intout(x);   /* create an (int) outlet  - rightmost outlet first... */
    x->x_outlet1 = intout(x);   /* create an (int) outlet */
    x->x_outlet0 = listout(x);  /* create a (list) outlet */
#endif
#ifdef PD
    x = (t_rvbap *)pd_new(rvbap_class);
    floatinlet_new(&x->x_ob, &x->x_azi);
    floatinlet_new(&x->x_ob, &x->x_ele);
    floatinlet_new(&x->x_ob, &x->x_spread);
    floatinlet_new(&x->x_ob, &x->x_dist);

    x->x_outlet0 = outlet_new(&x->x_ob, gensym("list"));
    x->x_outlet1 = outlet_new(&x->x_ob, gensym("float"));   
    x->x_outlet2 = outlet_new(&x->x_ob, gensym("float"));   
    x->x_outlet3 = outlet_new(&x->x_ob, gensym("float"));   
    x->x_outlet4 = outlet_new(&x->x_ob, gensym("float"));   
#endif

    x->x_azi = 0;
    x->x_ele = 0;
    x->x_dist = 1.0;
    x->x_spread_base[0] = 0.0;
    x->x_spread_base[1] = 1.0;
    x->x_spread_base[2] = 0.0;
    x->x_spread = 0;
    x->x_lsset_available =0;
    if (ac>0) {
#ifdef MAXMSP
        if (av[0].a_type == A_LONG)
            x->x_azi = av[0].a_w.w_long;
        else 
#endif
        if (av[0].a_type == A_FLOAT)
            x->x_azi = av[0].a_w.w_float;       
    }
    if (ac>1) {
#ifdef MAXMSP
        if (av[1].a_type == A_LONG)
            x->x_ele = av[1].a_w.w_long;
        else
#endif
        if (av[1].a_type == A_FLOAT)
            x->x_ele = av[1].a_w.w_float;   
    }
    if (ac>2) {
#ifdef MAXMSP
        if (av[2].a_type == A_LONG)
            x->x_dist = (float)av[2].a_w.w_long;
        else
#endif
        if (av[2].a_type == A_FLOAT)
            x->x_dist = av[2].a_w.w_float;  
    }
    return(x);                  /* return a reference to the object instance */
}
Exemple #23
0
/*------------------------------------ x10Create ---*/
static void *
x10Create(t_symbol * kind,
          const long pollRate)
{
    X10ControlData * xx = static_cast<X10ControlData *>(object_alloc(gClass));
    
    if (xx)
    {
        xx->fHouseCodeChar = 0;
        xx->fFunctionChar = x10CM11FunctionUnitsOff;
        xx->fDimLevel = 0;
        xx->fDeviceMap = 0;
        xx->fCompletedWhenStatus = xx->fIgnoreChecksum = xx->fStopping = false;
        xx->fOutCmd = xx->fOutArea = NULL;
        if ((kind == gCM11Symbol) || (kind == gEmptySymbol))
        {
            xx->fKind = X10KindCM11;
        }
        else if (kind == gCP290Symbol)
        {
            xx->fKind = X10KindCP290;
        }
        else
        {
            LOG_ERROR_2(xx, OUTPUT_PREFIX "invalid kind '%s' for device", kind->s_name)
            xx->fKind = X10KindCM11;
        }
        if ((0 > pollRate) || (MAX_POLL_RATE < pollRate))
        {
            LOG_ERROR_2(xx, OUTPUT_PREFIX "invalid polling rate (%ld) for device", pollRate)
            xx->fPollRate = SER_SAMPLE_RATE;
        }
        else
        {
            xx->fPollRate = (pollRate ? pollRate : SER_SAMPLE_RATE);
        }
        /* Set up our connections and private data */
        intin(xx, 1);
        xx->fErrorBangOut = static_cast<t_outlet *>(bangout(xx));
        xx->fMinuteOut = static_cast<t_outlet *>(intout(xx));
        xx->fHourOut = static_cast<t_outlet *>(intout(xx));
        xx->fDayOut = static_cast<t_outlet *>(intout(xx));
        xx->fDeviceStatus = static_cast<t_outlet *>(intout(xx));
        xx->fCommandComplete = static_cast<t_outlet *>(bangout(xx));
        xx->fHouseCode = static_cast<t_outlet *>(intout(xx));
        xx->fPollerOut = static_cast<t_outlet *>(bangout(xx));
        xx->fCommandsOut = static_cast<t_outlet *>(intout(xx));
        xx->fPollClock = MAKE_CLOCK(xx, x10ProcessClock);
        xx->fPollQueue = MAKE_QELEM(xx, x10ProcessQueue);
        xx->fOutBuffer = GET_BYTES(OUTBUFF_SIZE, unsigned char);
        switch (xx->fKind)
        {
            case X10KindCM11:
                xx->fMinorState = x10CM11MinorIdle;
                xx->fMajorState = x10CM11MajorIdle;
                break;
                
            case X10KindCP290:
                xx->fMinorState = x10CP290MinorIdle;
                xx->fMajorState = x10CP290MajorIdle;
                break;
                
            default:
                break;
                
        }
        xx->fAllOnCount = xx->fEntryCount = xx->fEventByteCount = 0;
        if (xx->fErrorBangOut && xx->fMinuteOut && xx->fHourOut && xx->fDayOut &&
            xx->fDeviceStatus && xx->fCommandComplete && xx->fHouseCode &&
            xx->fPollerOut && xx->fCommandsOut && xx->fPollClock && xx->fPollQueue &&
            xx->fOutBuffer)
        {
            for (short ii = 0; ii < COMMAND_PREFIX_SIZE; ++ii)
            {
                *(xx->fOutBuffer + ii) = ALL_ON;
            }
            xx->fOutCmd = xx->fOutBuffer + COMMAND_PREFIX_SIZE;
            xx->fOutArea = xx->fOutBuffer + COMMAND_PREFIX_SIZE + 1;
            clock_delay(xx->fPollClock, xx->fPollRate);
        }
        else
        {
            LOG_ERROR_1(xx, OUTPUT_PREFIX "unable to create port or clock for device")
            freeobject(reinterpret_cast<t_object *>(xx));
            xx = NULL;
        }
    }
    return xx;
} // x10Create
Exemple #24
0
void *f0ext_new(t_symbol *s, long argc, t_atom *argv) {
	t_f0ext *x= (t_f0ext *)object_alloc(f0ext_class);
	if(x) {
        x->step= 1.0;
        x->loop= 0;
        x->min= LONG_MIN;
        x->max = LONG_MAX;
        x->val= 0.0;
        t_atom *ap;
        ap= argv;
        if(argc>4) {post("warning: f0.ultimate_counter %d extra argument(s)", argc-4);}
        switch(MIN(argc, 4)) {
            case 4:
                ap++;
                ap++;
                ap++;
                if(atom_gettype(ap)==A_FLOAT) {
                    x->max= (double)atom_getfloat(ap);
                } else if(atom_gettype(ap)==A_LONG) {
                    x->max= (double)atom_getlong(ap);
                }
                ap--;
                ap--;
                ap--;
            case 3:
                ap++;
                ap++;
                if(atom_gettype(ap)==A_FLOAT) {
                    x->min= (double)atom_getfloat(ap);
                } else if(atom_gettype(ap)==A_LONG) {
                    x->min= (double)atom_getlong(ap);
                }
                ap--;
                ap--;
                x->val= x->min;
            case 2:
                ap++;
                if(atom_gettype(ap)==A_FLOAT) {
                    x->loop= (short)atom_getfloat(ap);
                } else if(atom_gettype(ap)==A_LONG) {
                    x->loop= (short)atom_getlong(ap);
                }
                ap--;
            case 1:
                if(atom_gettype(ap)==A_FLOAT) {
                    x->step= (double)atom_getfloat(ap);
                } else if(atom_gettype(ap)==A_LONG) {
                    x->step= (double)atom_getlong(ap);
                }
        }
        floatin(x, 6);
        floatin(x, 5);
        floatin(x, 4);
        floatin(x, 3);
        intin(x, 2);
        floatin(x, 1);
        x->out3= bangout(x);
		x->out2= bangout(x);
        x->out= floatout(x);
	}
    return (x);
}
Exemple #25
0
bool flext_base::InitInlets()
{
    bool ok = true;

    // incnt has number of inlets (any type)
    // insigs should be 0

    FLEXT_ASSERT(!insigs && !inlets);

    // ----------------------------------
    // create inlets
    // ----------------------------------

#if FLEXT_SYS == FLEXT_SYS_MAX      
    // copy inlet descriptions
    indesc = new char *[incnt];
    for(int i = 0; i < incnt; ++i) {
        xlet &x = inlist[i];
        indesc[i] = x.desc;
        x.desc = NULL;
    }
#endif

#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX
    inlets = incnt > 1?new px_object *[incnt-1]:NULL;
#endif
    
    // type info is now in list array
#if FLEXT_SYS == FLEXT_SYS_PD
    {
        int cnt = 0;
        if(incnt >= 1) {
            xlet &xi = inlist[0]; // points to first inlet
            if(xi.tp == xlet_sig) ++insigs;
            // else leftmost inlet is already there...
            ++cnt;

#if PD_MINOR_VERSION >= 37 && defined(PD_DEVEL_VERSION)
            // set tooltip
// this is on a per-class basis... we cannot really use it here
//            if(xi.desc && *xi.desc) class_settip(thisClass(),gensym(xi.desc));
#endif
        }       

        for(int ix = 1; ix < incnt; ++ix,++cnt) {
            xlet &xi = inlist[ix]; // points to first inlet
            t_inlet *in = NULL;
            switch(xi.tp) {
                case xlet_float:
                case xlet_int: {
                    if(ix > 9) { 
                        // proxy inlet needed
                        (inlets[ix-1] = (px_object *)pd_new(px_class))->init(this,ix);  // proxy for 2nd inlet messages 
                        in = inlet_new(&x_obj->obj,&inlets[ix-1]->obj.ob_pd, (t_symbol *)sym_float, (t_symbol *)sym_float);  
                    }
                    else { 
                        inlets[ix-1] = NULL;
                        static char sym[] = " ft ?";
                        sym[4] = '0'+ix;  
                        in = inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_float, gensym(sym)); 
                    }
                    break;
                }
                case xlet_sym: 
                    (inlets[ix-1] = (px_object *)pd_new(px_class))->init(this,ix);  // proxy for 2nd inlet messages 
                    in = inlet_new(&x_obj->obj,&inlets[ix-1]->obj.ob_pd, (t_symbol *)sym_symbol, (t_symbol *)sym_symbol);  
                    break;
                case xlet_list:
                    (inlets[ix-1] = (px_object *)pd_new(px_class))->init(this,ix);  // proxy for 2nd inlet messages 
                    in = inlet_new(&x_obj->obj,&inlets[ix-1]->obj.ob_pd, (t_symbol *)sym_list, (t_symbol *)sym_list);  
                    break;
                case xlet_any:
                    (inlets[ix-1] = (px_object *)pd_new(px_class))->init(this,ix);  // proxy for 2nd inlet messages 
                    in = inlet_new(&x_obj->obj,&inlets[ix-1]->obj.ob_pd, 0, 0);  
                    break;
                case xlet_sig:
                    inlets[ix-1] = NULL;
#ifdef FLEXT_COMPATIBLE
                    if(inlist[ix-1].tp != xlet_sig) {
                        post("%s: All signal inlets must be left-aligned in compatibility mode",thisName());
                        ok = false;
                    }
                    else 
#endif
                    {
                        // pd is not able to handle signals and messages into the same inlet...
                        in = inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_signal, (t_symbol *)sym_signal);  
                        ++insigs;
                    }
                    break;
                default:
                    inlets[ix-1] = NULL;
                    error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)inlist[ix].tp);
                    ok = false;
            } 

#if PD_MINOR_VERSION >= 37 && defined(PD_DEVEL_VERSION)
            // set tooltip
            if(in && xi.desc && *xi.desc) inlet_settip(in,gensym(xi.desc));
#endif
        }

        incnt = cnt;
    }
#elif FLEXT_SYS == FLEXT_SYS_MAX
    {
        int ix,cnt;
        // count leftmost signal inlets
        while(insigs < incnt && inlist[insigs].tp == xlet_sig) ++insigs;
        
        for(cnt = 0,ix = incnt-1; ix >= insigs; --ix,++cnt) {
            xlet &xi = inlist[ix];
            if(!ix) {
                if(xi.tp != xlet_any) {
                    error("%s: Leftmost inlet must be of type signal or anything",thisName());
                    ok = false;
                }
            }
            else {
                FLEXT_ASSERT(inlets);
                switch(xi.tp) {
                    case xlet_sig:
                        inlets[ix-1] = NULL;
                        error("%s: All signal inlets must be left-aligned",thisName());
                        ok = false;
                        break;
                    case xlet_float: {
						if(ix < 10) {
							inlets[ix-1] = NULL;
                            floatin(x_obj,ix);
							break;
						}
						else
							goto makeproxy;
					}
                    case xlet_int: {
						if(ix < 10) {
							inlets[ix-1] = NULL;
                            intin(x_obj,ix);
							break;
						}
						else
							goto makeproxy;
					}
					makeproxy:
                    case xlet_any: // non-leftmost
                    case xlet_sym:
                    case xlet_list:
                        inlets[ix-1] = (px_object *)proxy_new(x_obj,ix,&((flext_hdr *)x_obj)->curinlet);  
                        break;
                    default:
                        inlets[ix-1] = NULL;
                        error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)xi.tp);
                        ok = false;
                } 
            }
        }
        
        if(inlets)
            while(ix >= 0) inlets[ix--] = NULL;
	}
#else
#error
#endif

    return ok;  
}