static void pong_list(t_pong *x, t_symbol *s, int argc, t_atom *argv){ float minv, maxv; int mode, i; t_atom *outatom; mode = x->mode; minv = x->minval; maxv = x->maxval; ATOMS_ALLOCA(outatom, argc); //allocate memory for outatom if(minv > maxv){//checking ranges float temp; temp = maxv; maxv = minv; minv = temp; }; for(i=0; i<argc; i++){//use helper function to set outatom one by one float returnval, curterm; curterm = atom_getfloatarg(i, argc, argv); returnval = pong_ponger(curterm, minv, maxv, mode); SETFLOAT((outatom+i), (t_float)returnval); }; outlet_list(x->x_obj.ob_outlet, &s_list, argc, outatom); ATOMS_FREEA(outatom, argc); //free allocated memory for outatom }
static void list_fromsymbol_symbol(t_list_fromsymbol *x, t_symbol *s) { t_atom *outv; int n, outc = strlen(s->s_name); ATOMS_ALLOCA(outv, outc); for (n = 0; n < outc; n++) SETFLOAT(outv + n, (unsigned char)s->s_name[n]); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); ATOMS_FREEA(outv, outc); }
static void list_split_anything(t_list_split *x, t_symbol *s, int argc, t_atom *argv) { t_atom *outv; ATOMS_ALLOCA(outv, argc+1); SETSYMBOL(outv, s); atoms_copy(argc, argv, outv + 1); list_split_list(x, &s_list, argc+1, outv); ATOMS_FREEA(outv, argc+1); }
static void prepender_float(t_prepender *x, t_floatarg f) { if(x->x_id.a_type == A_FLOAT) { t_atom *outv; ATOMS_ALLOCA(outv, 2); SETFLOAT(outv + 1, f); *outv = x->x_id; outlet_list(x->x_obj.ob_outlet, &s_list, 2, outv); ATOMS_FREEA(outv, 2); } else { t_atom fman; SETFLOAT(&fman, f); outlet_anything(x->x_obj.ob_outlet, x->x_id.a_w.w_symbol, 1, &fman); } }
static void prepender_list(t_prepender *x, t_symbol *s, int argc, t_atom *argv) { t_atom *outv; if(x->x_id.a_type == A_FLOAT) { ATOMS_ALLOCA(outv, argc + 1); atoms_copy(argc, argv, outv + 1); *outv = x->x_id; argc++; outlet_list(x->x_obj.ob_outlet, &s_list, argc, outv); } else { ATOMS_ALLOCA(outv, argc); atoms_copy(argc, argv, outv); outlet_anything(x->x_obj.ob_outlet, x->x_id.a_w.w_symbol, argc, outv); } ATOMS_FREEA(outv, argc); }
static void proxy_any(t_proxy *x, t_symbol *s, int argc, t_atom *argv) { t_atom *outv; if(x->id.a_type == A_FLOAT) { ATOMS_ALLOCA(outv, argc + 2); atoms_copy(argc, argv, outv + 2); argc += 2; SETSYMBOL(outv+1, s); *outv = x->id; outlet_list(x->x->x_obj.ob_outlet, &s_list, argc, outv); } else { ATOMS_ALLOCA(outv, argc + 1); atoms_copy(argc, argv, outv + 1); argc++; SETSYMBOL(outv, s); outlet_anything(x->x->x_obj.ob_outlet, x->id.a_w.w_symbol, argc, outv); } ATOMS_FREEA(outv, argc); }
static void list_prepend_list(t_list_prepend *x, t_symbol *s, int argc, t_atom *argv) { t_atom *outv; int n, outc = x->x_alist.l_n + argc; ATOMS_ALLOCA(outv, outc); atoms_copy(argc, argv, outv + x->x_alist.l_n); if (x->x_alist.l_npointer) { t_alist y; alist_clone(&x->x_alist, &y); alist_toatoms(&y, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); alist_clear(&y); } else { alist_toatoms(&x->x_alist, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); } ATOMS_FREEA(outv, outc); }
static void pong_float(t_pong *x, t_float f){ float returnval, minv, maxv, ipt; int mode; t_atom *outatom; //since outlet is of type list, need to use list of len 1 instead of float for output mode = x->mode; minv = x->minval; maxv = x->maxval; ipt = f; ATOMS_ALLOCA(outatom, 1); //allocate memory for outatom of len 1 if(minv > maxv){//checking ranges float temp; temp = maxv; maxv = minv; minv = temp; }; returnval = pong_ponger(ipt, minv, maxv, mode); SETFLOAT(outatom, (t_float)returnval); outlet_list(x->x_obj.ob_outlet, &s_list, 1, outatom); ATOMS_FREEA(outatom, 1); //free allocated memory for outatom }
static void dkeuclid_bang(t_dkeuclid *x){ int i, r, n, k, m, ksize, msize; int * eucstr, *temp; m = (int)x->m; n = (int)x->n; k = (int)x->k; r = EUCMIN(m,k); eucstr = malloc(n*sizeof(int)); temp = malloc(n*sizeof(int)); for(i=0; i<n;i++){ if(i<k){ eucstr[i] = 1; } else{ eucstr[i] = 0; }; }; ksize = 1; msize = 1; while(r > 1){ int kidx = 0; int midx = k*ksize; int tidx = 0; int j=0; while(tidx<n){ if(kidx<(k*ksize)){ for(j=0;j<ksize;j++){ temp[tidx] = eucstr[kidx]; tidx++; kidx++; }; }; if(midx<n){ for(j=0;j<msize;j++){ temp[tidx] = eucstr[midx]; tidx++; midx++; }; } }; ksize+= msize; if(m>=k){ m = m-k; } else{ int tint; tint = k; k = m; m = tint-m; msize++; }; r = EUCMIN(m,k); for(i=0;i<n; i++){ eucstr[i] = temp[i]; }; }; t_atom * estr; ATOMS_ALLOCA(estr, n); for(i=0; i<n; i++){ SETFLOAT((estr+i), (t_float)eucstr[i]); }; free(eucstr); free(temp); outlet_float(x->x_flout, (t_float)n); outlet_list(x->x_obj.ob_outlet, &s_list, n, estr); ATOMS_FREEA(estr, n); }