static void search(threeply_struct *threeply, t_symbol *s, int argc, t_atom *argv) { int not_found, not_expired = threeply -> lyap_limit; int jump, i, iterations; t_atom vars[M_var_count]; double temp_a = threeply -> a; double temp_b = threeply -> b; double temp_c = threeply -> c; if (argc > 0) { for (i = 0; i < M_var_count; i++) { SETFLOAT(&vars[i], atom_getfloatarg(i, argc, argv)); } } else { for (i = 0; i < M_var_count; i++) { SETFLOAT(&vars[i], threeply -> vars_init[i]); } } do { jump = 500; not_found = 0; iterations = 10000; bad_params: threeply -> a = (drand48() * (threeply -> a_hi - threeply -> a_lo)) + threeply -> a_lo; threeply -> b = (drand48() * (threeply -> b_hi - threeply -> b_lo)) + threeply -> b_lo; threeply -> c = (drand48() * (threeply -> c_hi - threeply -> c_lo)) + threeply -> c_lo; // put any preliminary checks specific to this fractal to eliminate bad_params reset(threeply, NULL, argc, vars); do { calc(threeply, threeply -> vars); } while(jump--); threeply -> lyap_exp = lyapunov((void *) threeply, (t_gotfn) calc, M_var_count, (double *) threeply -> vars); if (isnan(threeply -> lyap_exp)) { not_found = 1; } if (threeply -> lyap_exp < threeply -> lyap_lo || threeply -> lyap_exp > threeply -> lyap_hi) { not_found = 1; } not_expired--; } while(not_found && not_expired); reset(threeply, NULL, argc, vars); if (!not_expired) { post("Could not find a fractal after %d attempts.", (int) threeply -> lyap_limit); post("Try using wider constraints."); threeply -> a = temp_a; threeply -> b = temp_b; threeply -> c = temp_c; outlet_anything(threeply -> search_outlet, gensym("invalid"), 0, NULL); } else { threeply -> failure_ratio = (threeply -> lyap_limit - not_expired) / threeply -> lyap_limit; make_results(threeply); outlet_anything(threeply -> search_outlet, gensym("search"), M_search_count, threeply -> search_out); } }
t_iemnet_floatlist*iemnet__floatlist_init(t_iemnet_floatlist*cl) { unsigned int i; if(NULL==cl)return NULL; for(i=0; i<cl->size; i++) SETFLOAT((cl->argv+i), 0.f); return cl; }
static void rint_list(t_rint *x, t_symbol *s, int argc, t_atom *argv){ int old_bytes = x->x_bytes, i; x->x_bytes = argc*sizeof(t_atom); x->x_at = (t_atom *)t_resizebytes(x->x_at, old_bytes, x->x_bytes); for(i = 0; i < argc; i++) // get output list SETFLOAT(x->x_at+i, rint(atom_getfloatarg(i, argc, argv))); outlet_list(x->x_obj.ob_outlet, &s_list, argc, x->x_at); }
static void iem_append_kernel_float(t_iem_append_kernel *x, t_float f) { if(x->x_inlet_select) /* if 2nd inlet */ { x->x_ac2 = 1; x->x_type2 = A_FLOAT; SETFLOAT(x->x_at2, f); x->x_sym2 = &s_list; } else /* if 1st inlet */ { x->x_ac1 = 1; x->x_type1 = A_FLOAT; SETFLOAT(x->x_at12, f); iem_append_kernel_out(x); } }
static void unroute_float(t_unroute *x, t_floatarg f) { t_atom list[2]; list[0] = x->x_id; /* prepend id of that inlet */ SETFLOAT(list+1, f); outlet_list(x->x_outlet, NULL, 2, list); }
static void ctw_output_curl_error(struct _ctw *common, CURLMsg *msg) { t_atom status_data[2]; SETFLOAT(&status_data[0], msg->data.result); SETSYMBOL(&status_data[1], gensym(curl_easy_strerror(msg->data.result))); pd_error(common, "Error while performing request: %s", curl_easy_strerror(msg->data.result)); outlet_list(common->status_out, &s_list, 2, &status_data[0]); }
void maxpd_atom_set_int(t_atom *a, int i) { #ifdef MAXMSP atom_setlong(a, (long)i); #else SETFLOAT(a, (double)i); #endif }
/*-------------------------------------------------------------------- * add ELT DUR STRESS ... : append a new utterance */ void holmes_add(t_holmes *x, t_symbol *sel, int argc, t_atom *argv) { t_atom a; if (!argc) return; SETFLOAT(&a,0); atoms_to_holmes_eltq("holmes_add()", 1, &a, x->hs.eltq); atoms_to_holmes_eltq("holmes_add()", argc, argv, x->hs.eltq); }
static void writeFFTWComplexPartIntoList (int n, t_atom *l, fftw_complex *c, enum ComplexPart p) { t_float f; while (n--) { f=(t_float)c[n][p]; SETFLOAT (l+n, f); } }
void maxpd_atom_set_float(t_atom *a, float d) { #ifdef MAXMSP atom_setfloat(a, d); #else SETFLOAT(a, d); #endif }
static void binfile_float(t_binfile *x, t_float val) /* add a single byte to the file */ { t_atom a; SETFLOAT(&a, val); binfile_add(x, gensym("float"), 1, &a); }
static void mtx_col_list(t_matrix *x, t_symbol *s, int argc, t_atom *argv) { if (argc==1){ t_float f=atom_getfloat(argv); t_atom *ap=x->atombuffer+1+x->current_col; if (x->current_col>x->col){ post("mtx_col : too high a column is to be set"); return; } if (x->current_col){ int n=x->row; while(n--){ SETFLOAT(ap, f); ap+=x->row+1; } } matrix_bang(x); return; } if (argc<x->row){ post("mtx_col : column length is too small for %dx%d-matrix", x->row, x->col); return; } if (x->current_col>x->col){ post("mtx_col : too high a column is to be set"); return; } if(x->current_col) { int r=x->row; t_atom *ap=x->atombuffer+1+x->current_col; while(r--)SETFLOAT(&ap[(x->row-r-1)*x->col], atom_getfloat(argv++)); } else { int r=x->row; t_atom *ap=x->atombuffer+2; while (r--) { t_float f=atom_getfloat(argv++); int c=x->col; while(c--){ SETFLOAT(ap, f); ap++; } } } matrix_bang(x); }
// ============================================================== static void wiimote_out_status(t_wiimote *x, int state) { t_atom ap[1]; SETFLOAT(ap+0, state); outlet_anything(x->outlet_status, gensym("open"), 1, ap); }
static void wiimote_cwiid_classic(t_wiimote *x, struct cwiid_classic_mesg *mesg) { t_atom ap[3]; // t_float scale = 1.f / ((uint16_t)0xFFFF); SETSYMBOL(ap+0, gensym("left_stick")); SETFLOAT (ap+1, mesg->l_stick[CWIID_X]); SETFLOAT (ap+2, mesg->l_stick[CWIID_Y]); outlet_anything(x->outlet_data, gensym("classic"), 3, ap); SETSYMBOL(ap+0, gensym("right_stick")); SETFLOAT (ap+1, mesg->r_stick[CWIID_X]); SETFLOAT (ap+2, mesg->r_stick[CWIID_Y]); outlet_anything(x->outlet_data, gensym("classic"), 3, ap); SETSYMBOL(ap+0, gensym("left")); SETFLOAT (ap+1, mesg->l); outlet_anything(x->outlet_data, gensym("classic"), 2, ap); SETSYMBOL(ap+0, gensym("right")); SETFLOAT (ap+1, mesg->r); outlet_anything(x->outlet_data, gensym("classic"), 2, ap); SETSYMBOL(ap+0, gensym("button")); SETFLOAT(ap+1, (mesg->buttons & 0xFF00)>>8); SETFLOAT(ap+2, mesg->buttons & 0x00FF); outlet_anything(x->outlet_data, gensym("classic"), 3, ap); }
///////////////////////////////////////////////////////// // trigger // ///////////////////////////////////////////////////////// void pix_info :: render(GemState *state) { // 0 0 0 6408 5121 1 1 0 0 9.59521e+08 t_atom abuf[3]; pixBlock*img=NULL; if(state)state->get(GemState::_PIX, img); if (!state || !img){ //no pixblock (or even no image!)! outlet_float(m_pixblock, (t_float)-1); outlet_float(m_misc, (t_float)-1); outlet_float(m_format, (t_float)-1); outlet_float(m_c, (t_float)-1); outlet_float(m_y, (t_float)-1); outlet_float(m_x, (t_float)-1); return; } SETFLOAT( &abuf[0], (t_float)img->newimage); SETFLOAT( &abuf[1], (t_float)img->newfilm); if (!&img->image){ // we have a pixblock, but no image! outlet_list(m_pixblock, gensym("list"), 2, abuf); outlet_float(m_misc, (t_float)-1); outlet_float(m_format, (t_float)-1); outlet_float(m_c, (t_float)-1); outlet_float(m_y, (t_float)-1); outlet_float(m_x, (t_float)-1); return; } if(img->image.data){ t_gpointer*gp=(t_gpointer*)img->image.data; SETPOINTER(&abuf[2], gp); outlet_anything(m_data, gensym("data"), 1, abuf+2); } outlet_list(m_pixblock, gensym("list"), 2, abuf); SETFLOAT (&abuf[0], (t_float)img->image.type); SETFLOAT (&abuf[1], (t_float)img->image.upsidedown); SETFLOAT (&abuf[2], (t_float)img->image.notowned); outlet_list(m_misc, gensym("list"), 3, abuf); // send out the colorspace (as integer!) outlet_float(m_format, (t_float)img->image.format); // send out the width/height/csize information outlet_float(m_c, (t_float)img->image.csize); outlet_float(m_y, (t_float)img->image.ysize); outlet_float(m_x, (t_float)img->image.xsize); }
static void mfbb_setevehook(t_mfbb_iterator *it, t_mifi_event *evp, int *incr) { if (it->i_i < it->i_b->b_n) { t_atom *ap = it->i_a; SETFLOAT(ap, evp->e_delay), ap++; ap++; /* target is set in a separate mfbb_settarhook() call */ SETFLOAT(ap, evp->e_status), ap++; SETFLOAT(ap, evp->e_data[0]), ap++; if (MIFI_ONE_DATABYTE(evp->e_status)) { SETFLOAT(ap, evp->e_channel + 1), ap++; SETFLOAT(ap, 0), ap++; } else { SETFLOAT(ap, evp->e_data[1]), ap++; SETFLOAT(ap, evp->e_channel + 1), ap++; } SETSEMI(ap); if (incr) { it->i_a += MFBB_PARTICLE_SIZE; it->i_i += MFBB_PARTICLE_SIZE; *incr = 1; } } else if (incr) *incr = 0; }
static void make_results(rossler_struct *rossler) { SETFLOAT(&rossler -> search_out[0], rossler -> lyap_exp); SETSYMBOL(&rossler -> search_out[1], gensym(classify(rossler))); SETFLOAT(&rossler -> search_out[2], rossler -> failure_ratio); SETFLOAT(&rossler -> vars_out[M_x], rossler -> vars[M_x]); SETFLOAT(&rossler -> vars_out[M_y], rossler -> vars[M_y]); SETFLOAT(&rossler -> vars_out[M_z], rossler -> vars[M_z]); SETFLOAT(&rossler -> params_out[M_h], rossler -> h); SETFLOAT(&rossler -> params_out[M_a], rossler -> a); SETFLOAT(&rossler -> params_out[M_b], rossler -> b); SETFLOAT(&rossler -> params_out[M_c], rossler -> c); outlet_list(rossler -> params_outlet, gensym("list"), M_param_count, rossler -> params_out); outlet_list(rossler -> vars_outlet, gensym("list"), M_var_count, rossler -> vars_out); }
static void repack_float(t_repack *x, t_float f) { /* add a float-atom to the list */ SETFLOAT(&x->buffer[x->current], f); x->current++; if (x->current >= x->outputsize) { repack_bang(x); } }
void valve_set(t_valve *x, t_floatarg fmap, t_floatarg fval) { if(fmap < x->bufsize && fmap >= 0) { int imap = (int)fmap; SETFLOAT(&x->map[imap], fval); x->max = fmap > x->max ? fmap : x->max; } }
static void findReplaceNonZerosWithIndex (int n, t_atom *x, t_atom *y) { int pos = 0; zeroFloatList(n,y); while ((pos = findNextNonZero(n,x,pos)) != -1) { SETFLOAT(y+pos,(t_float)pos+1); pos++; } }
static void ceil_list(t_ceil *x, t_symbol *s, int argc, t_atom *argv) { int old_bytes = x->bytes, i = 0; x->bytes = argc*sizeof(t_atom); x->output_list = (t_atom *)t_resizebytes(x->output_list,old_bytes,x->bytes); for(i=0;i<argc;i++) SETFLOAT(x->output_list+i,convert(atom_getfloatarg(i,argc,argv))); outlet_list(x->float_outlet,0,argc,x->output_list); }
void thresh_float(t_thresh *x, double f) { if (x->t_ac < MAXSIZE - 1) { x->t_time = gettime(); SETFLOAT(x->t_av+x->t_ac,f); x->t_ac++; clock_delay(x->t_clock,x->t_interval); } }
void weightedinterpolation_bang(t_weightedinterpolation *x) { t_int i; t_atom cursorParameters[NB_PARAM]; for(i=0; i<NB_PARAM; i++) SETFLOAT(cursorParameters+i, (x->currentParameters)[i]); outlet_list(x->flist_out, &s_list, NB_PARAM, cursorParameters); }
static void mtrack_float(t_mtrack *tp, t_float f) { if (tp->tr_mode == MTR_RECMODE) { t_atom at; SETFLOAT(&at, f); mtrack_doadd(tp, 1, &at); } }
void legion_outputWinnerList(t_legion *x, t_coords c){ t_neuron w = x->t_rosom[c.row][c.col]; t_atom out[x->t_vectorLength]; int i; for(i = 0; i < x->t_vectorLength; i++){ SETFLOAT(&(out[i]), (float)w.weights[i]); } outlet_list(x->t_out, NULL, x->t_vectorLength, out); }
void pix_opencv_patreco :: adaptBlockSizeMess(t_float arg) { if ( int(arg) % 2 == 1 && int(arg) > 1 ){ m_detector->m_adapt_block_size = int(arg); t_atom data_out; SETFLOAT(&data_out, m_detector->m_adapt_block_size); outlet_anything( m_dataout, gensym("adaptBlockSize"), 1, &data_out); } else error("adaptBlockSize should be > 1 and odd"); }
static void wiimote_cwiid_battery(t_wiimote *x, int battery) { t_atom ap[1]; t_float bat=(1.f*battery) / CWIID_BATTERY_MAX; SETFLOAT(ap+0, bat); outlet_anything(x->outlet_data, gensym("battery"), 1, ap); }
void pix_opencv_patreco :: dilateMess(t_float arg){ if (int(arg)) { m_detector->m_dilate = 1; } else m_detector->m_dilate = 0; t_atom data_out; SETFLOAT(&data_out, m_detector->m_dilate); outlet_anything( m_dataout, gensym("dilate"), 1, &data_out); }
void *rdist_new(t_symbol *msg, short argc, t_atom *argv){ t_rdist *x; int i; t_atom ar[2]; x = (t_rdist *)newobject(rdist_class); // create a new instance of this object x->r_out0 = outlet_new(x, 0); x->r_numVars = 0; // set up the random number generator gsl_rng_env_setup(); // waterman14 was the fastest according to my tests x->r_rng = gsl_rng_alloc((const gsl_rng_type *)gsl_rng_waterman14); // seed it by reading from /dev/random on mac os x and // something similar on windows gsl_rng_set(x->r_rng, makeseed()); // this is really f*****g important. if there's an error and the gsl's // default handler gets called, it aborts the program! gsl_set_error_handler(rdist_errorHandler); // setup a workspace x->r_output_buffer = (t_atom *)malloc(RDIST_DEFAULT_BUF_SIZE * sizeof(t_atom)); // init the lib. just gensyms all the distribution names librdist_init(); // handle the args. this should be done with attributes. if(argc){ if(argv[0].a_type == A_SYM){ rdist_anything(x, argv[0].a_w.w_sym, argc - 1, argv + 1); } } else { SETFLOAT(&(ar[0]), 0.); SETFLOAT(&(ar[1]), 1.); rdist_anything(x, gensym("uniform"), 2, ar); } return x; }
static void mTXShMatrix (MTXSh *x, t_symbol *s, int argc, t_atom *argv) { int rows = atom_getint (argv++); int columns = atom_getint (argv++); int size = rows * columns; int in_size = argc-2; unsigned int n; /* size check */ if (!size) post("mtx_spherical_harmonics: invalid dimensions"); else if (in_size<size) post("mtx_spherical_harmonics: sparse matrix not yet supported: use \"mtx_check\""); else if ((rows!=2)||(columns<1)) post("mtx_spherical_harmonics: 2 X L matrix expected with phi and theta vector, but got more rows/no entries"); else { if (x->l!=columns) { deleteMTXShdata(x); x->l=columns; allocMTXShdata(x); } for (n=0;n<x->l;n++) { x->phi[n]=(double) atom_getfloat(argv+n); x->theta[n]=(double) atom_getfloat(argv+columns+n); } if (x->ws!=0) { int n; sharmonics(x->phi, x->theta, x->ws); in_size=x->l*(x->nmax+1)*(x->nmax+1); SETFLOAT(x->list_sh,(float)x->l); SETFLOAT(x->list_sh+1,(float)(x->nmax+1)*(x->nmax+1)); for (n=0;n<in_size; n++) SETFLOAT(x->list_sh+n+2,(float)x->ws->y[n]); mTXShBang(x); } else post("mtx_spherical_harmonics: memory error, no operation"); } }