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); }
void *fftinfo_new(t_symbol *s, short ac, t_atom *av) { t_fftinfo *x; x = object_alloc(fftinfo_class); dsp_setup((t_pxobject *)x,1); x->x_out[3] = intout(x); // fullspect flag x->x_out[2] = intout(x); x->x_out[1] = intout(x); x->x_out[0] = intout(x); x->x_fftsize = x->x_ffthop = x->x_fullspect = x->x_n = 0; // init to 0 x->x_obj.z_misc = Z_PUT_FIRST; x->x_pfft = (t_pfftpub *)ps_spfft->s_thing; if (x->x_pfft) { // these are now correctly initialized in pfft~ when patch is laoded x->x_fftsize = x->x_pfft->x_fftsize; x->x_ffthop = x->x_pfft->x_ffthop; x->x_fullspect = (x->x_pfft->x_fullspect) ? 1 : 0; // get temp values for x_n until we turn on dsp and find the real ones if (x->x_fullspect) x->x_n = x->x_fftsize; // in "fullspect mode", frame size = fft size else x->x_n = x->x_fftsize/2; // in "regular mode", frame size = fft size / 2 } return (x); }
/* 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 */ }
void *akabookmotion_new(t_symbol *s, short argc, t_atom *argv) { t_akabookmotion *x = (t_akabookmotion *)newobject(akabookmotion_class); x->m_zout = intout(x); x->m_yout = intout(x); x->m_xout = intout(x); x->type = detect_sms(); if (x->type == unknown) error("aka.bookmotion: Can't find/identify a Motion Sensor."); return x; }
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; }
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; }
void *uisimp_new(t_symbol *s, long argc, t_atom *argv) { t_uisimp *x = NULL; t_dictionary *d = NULL; long boxflags; if (!(d = object_dictionaryarg(argc,argv))) return NULL; x = (t_uisimp *)object_alloc(s_uisimp_class); boxflags = 0 | JBOX_DRAWFIRSTIN | JBOX_NODRAWBOX | JBOX_DRAWINLAST | JBOX_TRANSPARENT // | JBOX_NOGROW | JBOX_GROWY // | JBOX_GROWBOTH // | JBOX_HILITE // | JBOX_BACKGROUND | JBOX_DRAWBACKGROUND // | JBOX_NOFLOATINSPECTOR // | JBOX_TEXTFIELD // | JBOX_MOUSEDRAGDELTA // | JBOX_TEXTFIELD ; jbox_new((t_jbox *)x, boxflags, argc, argv); x->u_box.b_firstin = (void *)x; x->u_mousedowninside = x->u_mouseover = x->u_state = 0; x->u_out = intout((t_object *)x); attr_dictionary_process(x,d); jbox_ready((t_jbox *)x); return x; }
void *myobject_new(long n) { MyObject *x; EnterCallback(); x = newobject(myobject_class); // get memory for a new object & initialize x->m_value = n; // store value (default is 0) x->m_out = intout(x); // create an int outlet x->m_out_b = bangout(x); x->m_out_s = outlet_new(x,0L) ExitCallback(); return (x); // return newly created object to caller }
void *folder_new(t_symbol *s, short ac, t_atom *av) { t_folder *x; x = object_alloc(folder_class); x->f_countout = intout((t_object *)x); outlet_new((t_object *)x,0); x->f_input = 0; x->f_numtypes = 0; x->f_path = 0; x->f_outcount = 0; if (ac) { if (atom_gettype(av) == A_SYM) { x->f_input = atom_getsym(av); } if (ac > 1) { av++; folder_types(x,s,ac-1,av); // ddz 06/27/05 ac -> ac-1 bug fix } } if (!x->f_numtypes) { short numtypes; typelist_make(x->f_types, TYPELIST_MAXFILES, &numtypes); x->f_numtypes = numtypes; } if (x->f_input) folder_lookup(x); return x; }
/**@public @memberof t_OMax_learn * @brief Object instantiation */ void *OMax_learn_new(t_symbol *s, long argc, t_atom *argv) { t_OMax_learn *x = NULL; if (x = (t_OMax_learn *)object_alloc(OMax_learn_class)) { // inlets & outlets x->stateout = intout(x); ///@details Check first argument of the Max5 object for a FO name. x->obound = FALSE; if (argc == 0) object_error((t_object *)x,"Missing name of the Oracle to build"); else { if (argv->a_type != A_SYM) object_error((t_object *)x,"First argument must be a symbol (name of an existing Oracle)"); else x->oname = atom_getsym(argv); x->dataname = OMax_learn_dataname(x->oname); } // color t_object *box; t_jrgba colorvals; jrgba_set(&colorvals, 0.30, 1.0, 0.15, 1.0); object_obex_lookup((t_object *)x, gensym("#B"), &box); jbox_set_color(box, &colorvals); } return (x); }
static void print_statement(void) { uint8_t nonl; uint8_t t; uint8_t nv = 0; do { t = current_token; nonl = 0; DEBUG_PRINTF("Print loop\n"); if (nv == 0) { if(t == TOKENIZER_STRING) { /* Handle string const specially - length rules */ tokenizer_string_func(charout, NULL); tokenizer_next(); nv = 1; continue; } else if(TOKENIZER_STRINGEXP(t)) { charoutstr(stringexpr()); nv = 1; continue; } else if(TOKENIZER_NUMEXP(t)) { intout(intexpr()); nv = 1; continue; } else if(t == TOKENIZER_TAB) { nv = 1; accept_tok(TOKENIZER_TAB); chartab(bracketed_intexpr()); continue; } else if(t == TOKENIZER_AT) { int x,y; nv = 1; accept_tok(TOKENIZER_AT); y = intexpr(); accept_tok(TOKENIZER_COMMA); x = intexpr(); if (move_cursor(x,y)) chpos = x; continue; } } nv = 0; if(t == TOKENIZER_COMMA) { charout('\t', NULL); nonl = 1; tokenizer_next(); } else if(t == TOKENIZER_SEMICOLON) { nonl = 1; tokenizer_next(); } else if (!statement_end()) { syntax_error(); break; } } while(!statement_end()); if (!nonl) charout('\n', 0); DEBUG_PRINTF("End of print\n"); }
void *fact_new(long n) { t_fact *x; x = (t_fact *)object_alloc(fact_class); if(x){ x->p_outlet = intout(x); } return x; }
void *b2n_new(t_symbol *s, double arg2) { t_b2n *x; x = (t_b2n *)object_alloc(b2n_class); if(x){ x->b_outlet = intout(x); } return x; }
/**************************************************************** * Constructor */ void *strstr_new(t_symbol *sym, long argc, t_atom *argv) { t_strstr *x = NULL; x = (t_strstr *)object_alloc(strstr_class); if (x == NULL) { error("strstr: Allocation failed."); return NULL; } // Set inlets, outlets, and proxy x->inl_proxy_ind = 0; x->inl_proxy = proxy_new((t_object *)x, 1, &x->inl_proxy_ind); x->outl_int = intout((t_object *)x); // Set the left string buffer x->i_dstr1 = dstr_new(); // First argument: right string buffer x->i_dstr2 = dstr_new(); if ((argc >= 1) && (attr_args_offset((short)argc, argv) >= 1)) { x->i_dstr2 = str_cat_atom(x, x->i_dstr2, argv); } // Test the string buffers if (DSTR_IS_NULL(x->i_dstr1) || DSTR_IS_NULL(x->i_dstr2)) { object_error((t_object *)x, "Allocation error."); strstr_free(x); return NULL; } // Second argument: mode long mode = 0; if ((argc >= 2) && (attr_args_offset((short)argc, argv) >= 2)) { if ((atom_gettype(argv + 1) == A_LONG) && (atom_getlong(argv + 1) >= 0) && (atom_getlong(argv + 1) <= 1)) { mode = (long)atom_getlong(argv + 1); } else { object_error((t_object *)x, "Arg 2: Mode: 0 or 1 expected"); } } object_attr_setlong(x, gensym("mode"), mode); // Set the float precision object_attr_setlong(x, gensym("fprecision"), 6); // Set the remaining variables x->o_pos = -1; // Process the attributes attr_args_process(x, (short)argc, argv); return x; }
void *posit_new(t_symbol *s, long argc, t_atom *argv) { t_posit *x = NULL; if ((x = (t_posit *)object_alloc(posit_class))) { x->p_outlet3 = intout(x); x->p_outlet2 = bangout(x); x->p_outlet = listout(x); } return (x); }
void *hxl_new(long n) { t_hxl *x; short i; x = (t_hxl *)object_alloc(hxl_class); if(x) { x->h_outlet = intout(x); for (i=0; i<8; i++){ x->h_thelist[i].a_w.w_long = 48; } } return x; }
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; }
void *prime_new(long value) { t_prime *x; x = (t_prime *)object_alloc(this_class); // create the new instance and return a pointer to it if (x) { object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout x->p_out = intout(x); //Create the outlet x->right_inlet = proxy_new(x, 1, 0L); x->p_value = value; //Init the prime value } return(x); // must return a pointer to the new instance }
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; }
void * CLASSMETHOD(New)() { DECLARE_T; if (APC40 == nullptr) { APC40 = T; T->curMessage = M_NONE; T->intOut = intout((t_object *)T); } else { post("You should only have one APC40 box active at any time!"); } return T; }
void *cs_new(Symbol *msg, long argc, Atom *argv) { t_cs *x; // Declare an object (based on our struct) x = (t_cs *)object_alloc(this_class); // Create object, store pointer to it (get 1 inlet free) if (x) { object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout x->out3 = intout(x); x->out2 = intout(x); x->out1 = intout(x); // Create the outlet x->inlets[0] = proxy_new(x, 2, 0L); // Create inlet 3 x->inlets[1] = proxy_new(x, 1, 0L); // Create inlet 2 // Set defaults x->attr_autopack = 1; x->attr_mode = ps_rgb2hsl; x->attr_outputtype = ps_split; x->val1 = x->val2 = x->val3 = 1; attr_args_process(x,argc,argv); //handle attribute args } return(x); // must return a pointer to the new instance }
void *slide_new(t_symbol *s, short argc, t_atom *argv) { t_slide *x; short i; x = (t_slide *)object_alloc(slide_class); if(x) { x->s_outlist = (t_atom *)malloc(MAXSIZE * sizeof(t_atom)); x->s_deltaflag = (long *)malloc(MAXSIZE * sizeof(long)); x->s_in = (double *)malloc(MAXSIZE * sizeof(double)); x->s_out = (double *)malloc(MAXSIZE * sizeof(double)); x->s_proxy = proxy_new(x,1,&x->s_inletNumber); x->s_outlet2 = intout(x); x->s_outlet = outlet_new(x, 0L); for(i=0;i<MAXSIZE;i++){ x->s_outlist[i].a_type = A_FLOAT; // x->s_deltaflag[i] = 0; } x->s_thresh = 0.00001; // defaults x->s_slide = 1.0; // defaults if(argc > 0){ if ((argv[0].a_type == A_LONG)&&(argv[0].a_w.w_long > 0)){ x->s_slide = 1/(double)argv[0].a_w.w_long; // look at first argument } else if ((argv[0].a_type == A_FLOAT)&&(argv[0].a_w.w_float > 0)){ x->s_slide = 1/(double)argv[0].a_w.w_float; } else x->s_slide = 1.0; } // default value if(argc > 1){ if((argv[1].a_type == A_LONG) && (argv[1].a_w.w_long >= 0.000001) && (argv[1].a_w.w_long <= 1.0)){ x->s_thresh = (double)argv[1].a_w.w_long; // look at first argument } else if ((argv[1].a_type == A_FLOAT)&& (argv[1].a_w.w_long >= 0.000001) && (argv[1].a_w.w_long <= 1.0)){ x->s_thresh = (double)argv[1].a_w.w_float; } else x->s_thresh = 0.00001; // default value } x->s_stopflag = 1; } return x; }
void *stats_new(t_symbol *s, long argc, t_atom *argv) { t_stats *x; x = (t_stats *)object_alloc(this_class); // create the new instance and return a pointer to it if (x) { long attrstart = attr_args_offset(argc, argv); // Create outlets object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout x->outlet5 = floatout(x); // 5th outlet: standard deviation x->outlet4 = floatout(x); // 4th outlet: mean x->outlet3 = floatout(x); // 3rd outlet: maximum x->outlet2 = floatout(x); // 2nd outlet: minimum x->outlet = intout(x); // 1st outlet: counter // Setting max window size and actual window size x->maxWindowSize = 0; x->windowSize = 0; if (attrstart && argv) x->maxWindowSize = atom_getlong(argv); if ((attrstart==2) && argv) x->windowSize = atom_getlong(argv+1); if (x->maxWindowSize <= 0) x->maxWindowSize = 500; // changing to default value if (x->windowSize <= 0) x->windowSize = x->maxWindowSize; // changing to default value if (x->windowSize > x->maxWindowSize) x->windowSize = x->maxWindowSize; // making sure we do not read outside array // allocate memory for array x->values = (double *)sysmem_newptr(sizeof(double) * x->maxWindowSize); if (x->values == NULL) { error("j.stats: memory allocation error"); // whoops, out of memory... return 0; } x->attr_windowed = 1; // set default attr_args_process(x, argc, argv); // handle attribute args stats_clear(x); // initilaize instance return (x); // return the pointer to our new instantiation } else return 0; }
/*------------------------------------ listTypeCreate ---*/ static void * listTypeCreate(void) { ListTypeData * xx = static_cast<ListTypeData *>(object_alloc(gClass)); if (xx) { xx->fResultOut = static_cast<t_outlet *>(intout(xx)); if (! xx->fResultOut) { LOG_ERROR_1(xx, OUTPUT_PREFIX "unable to create port for object") freeobject(reinterpret_cast<t_object *>(xx)); xx = NULL; } } return xx; } // listTypeCreate
/*------------------------------------ senseXCreate ---*/ static void * senseXCreate(const long onDelay, const long offDelay) { SenseXData * xx = static_cast<SenseXData *>(object_alloc(gClass)); if (xx) { long actOffDelay; long actOnDelay; if (0 > offDelay) { LOG_ERROR_1(xx, OUTPUT_PREFIX "off delay is not valid") actOffDelay = 0; } else { actOffDelay = offDelay; } if (0 > onDelay) { LOG_ERROR_1(xx, OUTPUT_PREFIX "on delay is not valid") actOnDelay = 0; } else { actOnDelay = onDelay; } xx->fOffDelay = actOffDelay; xx->fOnDelay = actOnDelay; xx->fStopping = false; xx->fPollClock = MAKE_CLOCK(xx, senseXProcessClock); xx->fPollQueue = MAKE_QELEM(xx, senseXProcessQueue); xx->fResultOut = static_cast<t_outlet *>(intout(xx)); xx->fProxy = proxy_new(xx, 1L, &xx->fInletNumber); xx->fState = kAwaitingFirstMessage; if (! (xx->fResultOut && xx->fProxy)) { LOG_ERROR_1(xx, OUTPUT_PREFIX "unable to create port for object") freeobject(reinterpret_cast<t_object *>(xx)); xx = NULL; } } return xx; } // senseXCreate
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; }
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; }
void *sieve_new(t_symbol *msg, short argc, t_atom *argv) { t_sieve *x; long attrstart; long argument = 0; attrstart = attr_args_offset(argc, argv); if (attrstart && argv) argument = atom_getlong(argv); // support a normal int argument for bwc x = (t_sieve *)object_alloc(s_sieve_class);;// create the new instance and return a pointer to it if(x){ object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout x->value = argument; x->outlet = intout(x); x->right_inlet = proxy_new(x, 1, 0L); attr_args_process(x,argc,argv); //handle attribute args } 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 *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); }