void *granulesf_new(t_symbol *msg, short argc, t_atom *argv) { t_granulesf *x = (t_granulesf *)pd_new(granulesf_class); outlet_new(&x->x_obj, gensym("signal")); outlet_new(&x->x_obj, gensym("signal")); x->wavebuf = (t_pdbuffer*)malloc(sizeof(t_pdbuffer)); x->windowbuf = (t_pdbuffer*)malloc(sizeof(t_pdbuffer)); srand(time(0)); //need "seed" message x->pitchscale = (float *) t_getbytes(MAXSCALE * sizeof(float)); x->grains = (t_grain *) t_getbytes(MAXGRAINS * sizeof(t_grain)); // default names x->wavename = gensym("waveform"); x->windowname = gensym("window"); // apparently Pd lacks this Max/MSP bug x->wavename = atom_getsymbolarg(0,argc,argv); x->windowname = atom_getsymbolarg(1,argc,argv); x->sr = sys_getsr(); if(! x->sr ) x->sr = 44100; granulesf_init(x,0); return (x); }
static void *tab_lt_new(t_symbol *s, int argc, t_atom *argv) { t_tab_lt *x = (t_tab_lt *)pd_new(tab_lt_class); t_symbol *src1, *src2, *dst; if((argc >= 3) && IS_A_SYMBOL(argv,0) && IS_A_SYMBOL(argv,1) && IS_A_SYMBOL(argv,2)) { src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv); src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv); dst = (t_symbol *)atom_getsymbolarg(2, argc, argv); } else if((argc >= 2) && IS_A_SYMBOL(argv,0) && IS_A_SYMBOL(argv,1)) { src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv); dst = src1; src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv); } else { post("tab_lt-ERROR: need 3 symbols arguments:"); post(" source1_array_name + source2_array_name + destination_array_name"); return(0); } x->x_sym_scr1 = src1; x->x_sym_scr2 = src2; x->x_sym_dst = dst; outlet_new(&x->x_obj, &s_bang); return(x); }
static void oggamp_connect(t_oggamp *x, t_symbol *s, int argc, t_atom *argv) { t_symbol *hostsym = atom_getsymbolarg(0, argc, argv); t_symbol *mountsym = atom_getsymbolarg(1, argc, argv); t_float portno = atom_getfloatarg(2, argc, argv); if (!*hostsym->s_name) /* check for hostname */ return; if (!portno) /* check wether the portnumber is specified */ portno = 8000; /* ...assume port 8000 as standard */ pthread_mutex_lock(&x->x_mutex); if(x->x_fd == -1) { x->x_hostname = hostsym->s_name; x->x_mountpoint = mountsym->s_name; x->x_port = portno; x->x_requestcode = REQUEST_CONNECT; /* empty buffer */ x->x_fifotail = 0; x->x_fifohead = 0; x->x_fifobytes = 0; x->x_streamchannels = 2; x->x_eof = 0; x->x_connecterror = 0; x->x_state = STATE_STARTUP; x->x_disconnect = 0; oggamp_cond_signal(&x->x_requestcondition); } else post("oggamp~: already connected"); pthread_mutex_unlock(&x->x_mutex); }
/*-------------------------------------------------------------------- * new() */ static void *pd_gfsm_paths_new(t_symbol *sel, int argc, t_atom *argv) { t_symbol *name = &s_; t_symbol *rname = &s_; t_pd_gfsm_paths *x = (t_pd_gfsm_paths*)pd_new(pd_gfsm_paths_class); //-- defaults x->x_automaton_pd = NULL; x->x_result_pd = NULL; x->x_labels = g_ptr_array_sized_new(PD_GFSM_PATHS_DEFAULT_LABELS_LENGTH); x->x_labels->len = 0; //-- args if (argc > 0) name = atom_getsymbolarg(0,argc,argv); if (argc > 1) rname = atom_getsymbolarg(1,argc,argv); //-- bindings x->x_automaton_pd = pd_gfsm_automaton_pd_get(name); x->x_automaton_pd->x_refcnt++; x->x_result_pd = pd_gfsm_automaton_pd_get(rname); x->x_result_pd->x_refcnt++; //-- outlets x->x_valout = outlet_new(&x->x_obj, &s_anything); //-- value outlet return (void *)x; }
void readsfx_open(t_readsfx *x, t_symbol *s, int argc, t_atom *argv) { t_symbol *filesym = atom_getsymbolarg(0, argc, argv); t_float onsetframes = atom_getfloatarg(1, argc, argv); t_symbol *endian = atom_getsymbolarg(5, argc, argv); if (!*filesym->s_name) return; pthread_mutex_lock(&x->x_mutex); x->x_requestcode = REQUEST_OPEN; x->x_filename = filesym->s_name; x->x_fifotail = 0; x->x_fifohead = 0; if (*endian->s_name == 'b') x->x_bigendian = 1; else if (*endian->s_name == 'l') x->x_bigendian = 0; else if (*endian->s_name) pd_error(x, "endianness neither 'b' nor 'l'"); else x->x_bigendian = garray_ambigendian(); x->x_onsetframes = (onsetframes > 0 ? onsetframes : 0); //These should be set when opening the file x->x_sfchannels = 1; x->x_bytespersample = 2; sfxdata_reset(&x->x_data); x->x_eof = 0; x->x_fileerror = 0; x->x_state = STATE_STARTUP; sfread_cond_signal(&x->x_requestcondition); pthread_mutex_unlock(&x->x_mutex); }
static void *nrcombf_new(t_symbol *s, int argc, t_atom *argv) { t_float time = 1000; t_float fb = 0; t_symbol *sarg; int norm = 0, i = 0; t_nrcombf *x = (t_nrcombf *)pd_new(nrcombf_class); for(; i < argc; i++) if (argv[i].a_type == A_FLOAT) { time = atom_getfloatarg(i++, argc, argv); break; } else { sarg = atom_getsymbolarg(i, argc, argv); if (!strcmp(sarg->s_name, "-n")) norm = 1; else if(!strcmp(sarg->s_name, "-l")) { i++; x->x_ttime = atom_getfloatarg(i, argc, argv); } } for(; i < argc; i++) if (argv[i].a_type == A_FLOAT) { fb = atom_getfloatarg(i++, argc, argv); break; } else { sarg = atom_getsymbolarg(i, argc, argv); if (!strcmp(sarg->s_name, "-n")) norm = 1; else if(!strcmp(sarg->s_name, "-l")) { i++; x->x_ttime = atom_getfloatarg(i, argc, argv); } } for(; i < argc; i++) if (argv[i].a_type == A_FLOAT) { x->x_ttime = atom_getfloatarg(i, argc, argv); } else { sarg = atom_getsymbolarg(i, argc, argv); if (!strcmp(sarg->s_name, "-n")) norm = 1; } signalinlet_new(&x->x_obj, time); signalinlet_new(&x->x_obj, fb); if(!norm) signalinlet_new(&x->x_obj, 1.0); outlet_new(&x->x_obj, &s_signal); x->x_f = 0; x->c_n = 0; x->c_vec = getbytes(XTRASAMPS * sizeof(t_sample)); memset((char *)(x->c_vec), 0, sizeof(t_sample)*(XTRASAMPS)); x->norm = norm; return(x); }
/* new values from dialog window */ void glob_startup_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv) { int i; namelist_free(sys_externlist); sys_externlist = 0; sys_defeatrt = atom_getintarg(0, argc, argv); sys_flags = sys_decodedialog(atom_getsymbolarg(1, argc, argv)); for (i = 0; i < argc-2; i++) { t_symbol *s = sys_decodedialog(atom_getsymbolarg(i+2, argc, argv)); if (*s->s_name) sys_externlist = namelist_append_files(sys_externlist, s->s_name); } }
static void *k_jackd_new(t_symbol *s, t_int argc, t_atom* argv){ long i; t_k_jackd *x = (t_k_jackd *)pd_new(k_jackd_class); x->mixer=aipc_audiopluginmixer_new(); for(i=0;i<argc;i++){ struct aipc_audioplugincaller *caller; switch(argv[i].a_type){ case 2: caller=k_jackd_getCaller(atom_getsymbolarg(i,argc,argv)->s_name); if(caller!=NULL){ printf("1\n"); aipc_audiopluginmixer_add_caller(x->mixer,caller); printf("2\n"); }else{ fprintf(stderr,"\"%s\" client not found.\n",atom_getsymbolarg(i,argc,argv)->s_name); } break; default: break; } } if(x->mixer->num_callers==0){ post("no clients found.\n"); return NULL; } for(i=0;i<x->mixer->num_inputs;i++){ x->inlets[i]=inlet_new( &x->x_obj, &x->x_obj.ob_pd, gensym ("signal"), gensym ("signal") ); } x->control_outlet = outlet_new (&x->x_obj, gensym ("control")); for(i=0;i<x->mixer->num_outputs;i++){ x->outlets[i] = outlet_new (&x->x_obj, gensym ("signal")); } x->dsp_vec_length = x->mixer->num_inputs + x->mixer->num_outputs + 2; x->dsp_vec = (t_int*)calloc (x->dsp_vec_length, sizeof (t_int)); return x; }
static void *ritmo1_new(t_symbol *s, int argc, t_atom *argv) { t_ritmo1 *x = (t_ritmo1 *)pd_new(ritmo1_class); ritmo1_allocate_buffers(x); if (argc>0) { x->x_arrayname_src = atom_getsymbolarg(0, argc, argv); } if (argc>1) { x->x_arrayname_dest = atom_getsymbolarg(1, argc, argv); } return (x); }
static void *route_new(t_symbol *s, int argc, t_atom *argv) { #ifdef ROCKBOX (void) s; #endif int n; t_routeelement *e; t_route *x = (t_route *)pd_new(route_class); t_atom a; if (argc == 0) { argc = 1; SETFLOAT(&a, 0); argv = &a; } x->x_type = argv[0].a_type; x->x_nelement = argc; x->x_vec = (t_routeelement *)getbytes(argc * sizeof(*x->x_vec)); for (n = 0, e = x->x_vec; n < argc; n++, e++) { e->e_outlet = outlet_new(&x->x_obj, &s_list); if (x->x_type == A_FLOAT) e->e_w.w_float = atom_getfloatarg(n, argc, argv); else e->e_w.w_symbol = atom_getsymbolarg(n, argc, argv); } x->x_rejectout = outlet_new(&x->x_obj, &s_list); return (x); }
static void list2send_list(t_list2send *x, t_symbol *s, int ac, t_atom *av) { if((ac >= 2) && (IS_A_FLOAT(av,0))) { int identifier_index = (int)atom_getintarg(0, ac, av); if(identifier_index < x->x_max) { if(x->x_snd_able[identifier_index]) { t_symbol *sender = x->x_send_entries[identifier_index]; if(sender->s_thing) { if(ac == 2) { if(IS_A_FLOAT(av, 1)) pd_float(sender->s_thing, atom_getfloatarg(1, ac, av)); else if(IS_A_SYMBOL(av, 1)) pd_symbol(sender->s_thing, atom_getsymbolarg(1, ac, av)); } else pd_list(sender->s_thing, &s_list, ac-1, av+1); } } } } }
static void list2send_from(t_list2send *x, t_symbol *s, int ac, t_atom *av) { int n=x->x_max; if(ac >= 1) { int i, j, beg=(int)atom_getintarg(0, ac, av); if((beg + ac - 1) <= n) { for(i=ac-1,j=beg+ac-2; i>=1; i--,j--)/*change*/ { if(x->x_snd_able[j]) { t_symbol *sender = x->x_send_entries[j]; if(sender->s_thing) { if(IS_A_FLOAT(av, i)) pd_float(sender->s_thing, atom_getfloatarg(i, ac, av)); else if(IS_A_SYMBOL(av, i)) pd_symbol(sender->s_thing, atom_getsymbolarg(i, ac, av)); } } } } } }
static void *relay_new(t_symbol* UNUSED(s), int argc, t_atom *argv) { int n; t_relayelement *e; t_relay *x = (t_relay *)pd_new(relay_class); t_atom a; if (argc == 0) { argc = 1; SETFLOAT(&a, 0); argv = &a; } x->x_type = argv[0].a_type; x->x_nelement = argc; x->x_vec = (t_relayelement *)getbytes(argc * sizeof(*x->x_vec)); for (n = 0, e = x->x_vec; n < argc; n++, e++) { e->e_outlet = outlet_new(&x->x_obj, gensym("list")); if (x->x_type == A_FLOAT) e->e_w.w_float = atom_getfloatarg(n, argc, argv); else e->e_w.w_symbol = atom_getsymbolarg(n, argc, argv); } x->x_rejectout = outlet_new(&x->x_obj, gensym("list")); return (x); }
static void dist_disconnect(t_dist *x, t_symbol *s, int argc, t_atom *argv) { /* need to rearrange list in order to get rid of empty entries */ int i, j, k; int done; t_symbol *name; for(i = 0; i < argc; i++) { name = atom_getsymbolarg(i, argc, argv); /* the one we're going to remove */ done = 0; /* not yet removed */ for(j = 0; j <= x->x_rec; j++) /* search for it... */ { if(x->x_sym[j] == name) { x->x_rec--; if(x->x_verbose)post("dist: \"%s\" removed from list of receivers", x->x_sym[j]->s_name); x->x_sym[j] = NULL; /* delete entry */ /* rearrange list now: move entries to close the gap */ for(k = j; k <= x->x_rec; k++) { x->x_sym[k] = x->x_sym[k + 1]; } done = 1; /* removed successfully */ } } if(!done)post("dist: \"%s\" not in list of receivers, ignored", name->s_name); } }
static void colorpanel_list(t_colorpanel *x, t_symbol *s, int argc, t_atom *argv) { t_symbol *tmp_symbol = s; /* <-- this gets rid of the unused variable warning */ int i; unsigned int tmp_int; char color_buffer[3]; char color_string[MAXPDSTRING]; strncpy(color_string,"#",MAXPDSTRING); if(argc > 3) logpost(x, 2, "[colorpanel] warning more than three elements in list"); for(i=0; i<3; i++) { tmp_symbol = atom_getsymbolarg(i, argc, argv); if(tmp_symbol == &s_) { tmp_int = (unsigned int)(atom_getfloatarg(i, argc , argv) * 255); snprintf(color_buffer, 3, "%02x", (tmp_int > 255 ? 255 : tmp_int)); strncat(color_string, color_buffer, 3); } else { pd_error(x,"[colorpanel] symbols are not allowed in the color list"); return; } } memcpy(x->current_color, color_string, 7); colorpanel_bang(x); }
/*-------------------------------------------------------------------- * list : match features */ static void holmes_mask_list(t_holmes_mask *x, t_symbol *sel, int argc, t_atom *argv) { int i; alhash_entry_t *he; t_outlet *heout; for (i = 0; i < argc; i += 3) { //-- element SETSYMBOL(x->x_buf, atom_getsymbolarg(i, argc, argv)); //-- get duration, stress SETFLOAT(x->x_buf+1, atom_getfloatarg(i+1, argc, argv)); SETFLOAT(x->x_buf+2, atom_getfloatarg(i+2, argc, argv)); //-- lookup he = alhash_lookup_extended(symbol_to_holmes_eid, x->x_buf->a_w.w_symbol); if (he) { if (x->x_mask & Elements[(unsigned int)(he->val)].feat) heout = x->x_goodout; else heout = x->x_badout; } else { heout = x->x_badout; error("holmes_mask: unknown holmes element '%s'", x->x_buf->a_w.w_symbol->s_name); } outlet_anything(heout, &s_list, 3, x->x_buf); } }
void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv) { char *cwd = atom_getsymbolarg(0, argc, argv)->s_name; t_namelist *nl; unsigned int i; int did_fontwarning = 0; int j; sys_oldtclversion = atom_getfloatarg(1, argc, argv); if (argc != 2 + 3 * NZOOM * NFONT) bug("glob_initfromgui"); for (j = 0; j < NZOOM; j++) for (i = 0; i < NFONT; i++) { int size = atom_getfloatarg(3 * (i + j * NFONT) + 2, argc, argv); int width = atom_getfloatarg(3 * (i + j * NFONT) + 3, argc, argv); int height = atom_getfloatarg(3 * (i + j * NFONT) + 4, argc, argv); if (!(size && width && height)) { size = (j+1)*sys_fontspec[i].fi_pointsize; width = (j+1)*sys_fontspec[i].fi_width; height = (j+1)*sys_fontspec[i].fi_height; if (!did_fontwarning) { verbose(1, "ignoring invalid font-metrics from GUI"); did_fontwarning = 1; } } sys_gotfonts[j][i].fi_pointsize = size; sys_gotfonts[j][i].fi_width = width; sys_gotfonts[j][i].fi_height = height; #if 0 fprintf(stderr, "font (%d %d %d)\n", sys_gotfonts[j][i].fi_pointsize, sys_gotfonts[j][i].fi_width, sys_gotfonts[j][i].fi_height); #endif } /* load dynamic libraries specified with "-lib" args */ if (sys_oktoloadfiles(0)) { for (nl = STUFF->st_externlist; nl; nl = nl->nl_next) if (!sys_load_lib(0, nl->nl_string)) post("%s: can't load library", nl->nl_string); sys_oktoloadfiles(1); } /* open patches specifies with "-open" args */ for (nl = sys_openlist; nl; nl = nl->nl_next) openit(cwd, nl->nl_string); namelist_free(sys_openlist); sys_openlist = 0; /* send messages specified with "-send" args */ for (nl = sys_messagelist; nl; nl = nl->nl_next) { t_binbuf *b = binbuf_new(); binbuf_text(b, nl->nl_string, strlen(nl->nl_string)); binbuf_eval(b, 0, 0, 0); binbuf_free(b); } namelist_free(sys_messagelist); sys_messagelist = 0; }
static void dist_connect(t_dist *x, t_symbol *s, int argc, t_atom *argv) { int i, j; int exist; t_symbol *name; /* just append every new receive-name to end of list */ for(i = 0; i < argc; i++) { exist = 0; if(x->x_rec == MAX_REC - 1) { post("dist: too many connections in use!"); return; } name = atom_getsymbolarg(i, argc, argv); for(j = 0; j <= x->x_rec; j++) { /* check if the name already exists */ if(x->x_sym[j] == name) { post("dist: \"%s\" already exists in list of receivers", name->s_name); exist = 1; /* indicate that it _does_ exist */ } } /* add it in case it's a new one */ if(!exist) { x->x_rec++; x->x_sym[x->x_rec] = name; if(x->x_verbose)post("dist: \"%s\" added to list of receivers", x->x_sym[x->x_rec]->s_name); } } }
static void *detect_new(t_symbol *s, int ac, t_atom *av){ t_detect *x = (t_detect *)pd_new(detect_class); x->x_outlet = outlet_new(&x->x_obj, &s_signal); x->x_count = x->x_total = x->x_lastin = x->x_mode = 0; x->x_sr = sys_getsr(); if(ac == 1){ if(av->a_type == A_SYMBOL){ t_symbol *curarg = s; // get rid of warning curarg = atom_getsymbolarg(0, ac, av); if(!strcmp(curarg->s_name, "samps")) x->x_mode = 0; else if(!strcmp(curarg->s_name, "ms")) x->x_mode = 1; else if(!strcmp(curarg->s_name, "hz")) x->x_mode = 2; else if(!strcmp(curarg->s_name, "bpm")) x->x_mode = 3; else goto errstate; } else goto errstate; } else if(ac > 1) goto errstate; return(x); errstate: pd_error(x, "[detect~]: improper args"); return NULL; }
void *pvwarpb_new(t_symbol *s, int argc, t_atom *argv) { t_fftease *fft; t_pvwarpb *x = (t_pvwarpb *)pd_new(pvwarpb_class); int i; for(i=0;i<3;i++){ inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal")); } outlet_new(&x->x_obj, gensym("signal")); x->fft = (t_fftease *) calloc(1,sizeof(t_fftease)); fft = x->fft; fft->initialized = 0; // for FFTease package x->initialized = 0; // for object x->lofreq = 0.0; x->hifreq = 10000.0; fft->N = FFTEASE_DEFAULT_FFTSIZE; fft->overlap = FFTEASE_DEFAULT_OVERLAP; fft->winfac = FFTEASE_DEFAULT_WINFAC; x->warpfunc = (t_float *) calloc(8192, sizeof(t_float)); if(argc > 0){ x->buffername = atom_getsymbolarg(0, argc, argv); } else { post("%s: Must specify array name", OBJECT_NAME); return NULL; } if(argc > 1){ fft->N = (int) atom_getfloatarg(1, argc, argv); } if(argc > 2){ fft->overlap = (int) atom_getfloatarg(2, argc, argv); } return x; }
void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv) { char *cwd = atom_getsymbolarg(0, argc, argv)->s_name; t_namelist *nl; unsigned int i; int j; int nhostfont = (argc-2)/3; sys_oldtclversion = atom_getfloatarg(1, argc, argv); if (argc != 2 + 3 * nhostfont) bug("glob_initfromgui"); for (i = 0; i < NFONT; i++) { int best = 0; int wantheight = sys_fontlist[i].fi_maxheight; int wantwidth = sys_fontlist[i].fi_maxwidth; for (j = 1; j < nhostfont; j++) { if (atom_getintarg(3 * j + 4, argc, argv) <= wantheight && atom_getintarg(3 * j + 3, argc, argv) <= wantwidth) best = j; } /* best is now the host font index for the desired font index i. */ sys_fontlist[i].fi_hostfontsize = atom_getintarg(3 * best + 2, argc, argv); sys_fontlist[i].fi_width = atom_getintarg(3 * best + 3, argc, argv); sys_fontlist[i].fi_height = atom_getintarg(3 * best + 4, argc, argv); } #if 0 for (i = 0; i < 6; i++) fprintf(stderr, "font (%d %d %d) -> (%d %d %d)\n", sys_fontlist[i].fi_fontsize, sys_fontlist[i].fi_maxwidth, sys_fontlist[i].fi_maxheight, sys_fontlist[i].fi_hostfontsize, sys_fontlist[i].fi_width, sys_fontlist[i].fi_height); #endif /* auto-load anything in that is in startupdir */ if(!sys_nostartup) sys_loadstartup(); /* load dynamic libraries specified with "-lib" args */ for (nl = sys_externlist; nl; nl = nl->nl_next) if (!sys_load_lib(0, nl->nl_string)) post("%s: can't load library", nl->nl_string); /* open patches specifies with "-open" args */ for (nl = sys_openlist; nl; nl = nl->nl_next) openit(cwd, nl->nl_string); namelist_free(sys_openlist); sys_openlist = 0; /* send messages specified with "-send" args */ for (nl = sys_messagelist; nl; nl = nl->nl_next) { t_binbuf *b = binbuf_new(); binbuf_text(b, nl->nl_string, strlen(nl->nl_string)); binbuf_eval(b, 0, 0, 0); binbuf_free(b); } namelist_free(sys_messagelist); sys_messagelist = 0; }
static void *NLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) { t_NLMS_tilde *x = (t_NLMS_tilde *)pd_new(NLMS_tilde_class); t_int i, n_order=39; t_symbol *w_name; t_float beta=0.1f; t_float gammax=0.00001f; if((argc >= 4) && IS_A_FLOAT(argv,0) && //IS_A_FLOAT/SYMBOL from iemlib.h IS_A_FLOAT(argv,1) && IS_A_FLOAT(argv,2) && IS_A_SYMBOL(argv,3)) { n_order = (t_int)atom_getintarg(0, argc, argv); beta = (t_float)atom_getfloatarg(1, argc, argv); gammax = (t_float)atom_getfloatarg(2, argc, argv); w_name = (t_symbol *)atom_getsymbolarg(3, argc, argv); if(beta < 0.0f) beta = 0.0f; if(beta > 2.0f) beta = 2.0f; if(gammax < 0.0f) gammax = 0.0f; if(gammax > 1.0f) gammax = 1.0f; if(n_order < 2) n_order = 2; if(n_order > 11111) n_order = 11111; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); outlet_new(&x->x_obj, &s_signal); outlet_new(&x->x_obj, &s_signal); x->x_msi = 0; x->x_n_order = n_order; x->x_update = 0; x->x_beta = beta; x->x_gamma = gammax; // 2 times in and one time desired_in memory allocation (history) x->x_in_hist = (t_float *)getbytes(2*x->x_n_order*sizeof(t_float)); // table-symbols will be linked to their memory in future (dsp_routine) x->x_w_array_sym_name = gensym(w_name->s_name); x->x_w_array_mem_beg = (t_float *)0; return(x); } else { post("NLMS~-ERROR: need 3 float- + 1 symbol-arguments:"); post(" order_of_filter + learnrate_beta + security_value + array_name_taps"); return(0); } }
void trento_load(t_trento *x, t_symbol *msg, int argc, t_atom *argv) { t_symbol *name1; t_symbol *name2; x->loadcomplete = 1; if(argc!=2) { pd_error(x,"load takes 2 arguments, not %d",argc); return; } name1 = atom_getsymbolarg(0,argc,argv); name2 = atom_getsymbolarg(1,argc,argv); if(!load_two(x,name1,name2)) return; x->loadcomplete = 0; x->name1 = name1; x->name2 = name2; }
static int k_cext_gen_cfunc_funcname(t_k_cext *x,int argc, t_atom* argv,int i, struct k_cext_init *k){ char string[500]; int lokke; k->doinitpos1=ftell(k->file); fprintf(k->file," \n"); sprintf(string,"%s",atom_getsymbolarg(i,argc,argv)->s_name); if(!strncmp(string,"INT_",4)){ k->cfuncrettype=0; sprintf(k->cfuncname,"%s",string+4); }else{ if(!strncmp(string,"FLOAT_",6)){ k->cfuncrettype=1; sprintf(k->cfuncname,"%s",string+6); }else{ post("k_cfunc: Error. Function name must begin with either INT_ or FLOAT_."); return 1; } } i++; for(;i<argc;i+=2){ sprintf(string,"%s",atom_getsymbolarg(i,argc,argv)->s_name); if(!strcmp(string,";")) goto end; if(!strcmp(string,"float") || !strcmp(string,"t_float")){ sprintf(string,"double"); } sprintf(&k->cfuncargtypes[k->numargs*50],"%s",string); sprintf(&k->cfuncargnames[k->numargs*50],"%s",atom_getsymbolarg(i+1,argc,argv)->s_name); k->numargs++; } end: fprintf(k->file,"static %s %s(t_k_cext *x%s",k->cfuncrettype==0?"int":"float",k->cfuncname,k->numargs>0?",":"){\n"); for(lokke=0;lokke<k->numargs;lokke++){ fprintf(k->file,"%s %s%s",&k->cfuncargtypes[lokke*50],&k->cfuncargnames[lokke*50],lokke==k->numargs-1?"){\n":","); } k->doinitpos2=ftell(k->file); fprintf(k->file," \n"); return i; }
static void *iem_image_new(t_symbol *s, int argc, t_atom *argv) { t_iem_image *x = (t_iem_image *)pd_new(iem_image_class); t_symbol *gifsym=(t_symbol *)0; x->x_gui.x_snd = gensym("empty"); x->x_gui.x_rcv = gensym("empty"); x->x_gui.x_lab = gensym("empty"); x->x_gui.x_fsf.x_font_style = 0; if(argc >= 1) { if(IS_A_SYMBOL(argv,0)) gifsym = atom_getsymbolarg(0, argc, argv); else if(IS_A_FLOAT(argv,0)) gifsym = (t_symbol *)0; } else if(argc >= 5) { if(IS_A_SYMBOL(argv,0)) gifsym = atom_getsymbolarg(0, argc, argv); else if(IS_A_FLOAT(argv,0)) gifsym = (t_symbol *)0; iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(1, argc, argv)); iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(2, argc, argv)); iemgui_new_getnames(&x->x_gui, 3, argv); } x->x_gui.x_draw = (t_iemfunptr)iem_image_draw; x->x_gui.x_fsf.x_snd_able = 1; x->x_gui.x_fsf.x_rcv_able = 1; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); if(!strcmp(x->x_gui.x_snd->s_name, "empty")) x->x_gui.x_fsf.x_snd_able = 0; if(!strcmp(x->x_gui.x_rcv->s_name, "empty")) x->x_gui.x_fsf.x_rcv_able = 0; if(x->x_gui.x_fsf.x_rcv_able) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_w = 100; x->x_gui.x_h = 60; x->x_gifsym = gifsym; x->x_have_image=0; x->x_gui.x_fsf.x_selected = 0; iemgui_verify_snd_ne_rcv(&x->x_gui); outlet_new(&x->x_gui.x_obj, &s_list); return(x); }
/*------------------------------------------------------------- * values() */ static void holmes_mask_values(t_holmes_mask *x, t_symbol *sel, int argc, t_atom *argv) { int i; for (i=0; i < argc; i += 2) { holmes_mask_set_byname(x, atom_getsymbolarg(i, argc, argv), atom_getintarg(i+1, argc, argv)); } }
void *chopper_new(t_symbol *msg, short argc, t_atom *argv) { t_chopper *x = (t_chopper *)pd_new(chopper_class); outlet_new(&x->x_obj, gensym("signal")); x->R = sys_getsr(); x->l_sym = atom_getsymbolarg(0,argc,argv); chopper_init(x,0); return (x); }
static void *s2f_new(t_symbol *s, int argc, t_atom * argv){ t_symbol *dummy = s; dummy = NULL; t_s2f *x = (t_s2f *)pd_new(s2f_class); x->x_stopped = 0; x->x_on = 0; x->x_value = 0; x->x_nblock = 64; // ???? x->x_ksr = 44.1; // ???? t_float interval, offset, active; interval = 0.; offset = 0.; active = 1; int argnum = 0; while(argc > 0){ if(argv -> a_type == A_FLOAT){ t_float argval = atom_getfloatarg(0, argc, argv); switch(argnum){ case 0: interval = argval; break; case 1: offset = argval; break; default: break; }; argnum++; argc--; argv++; } else if(argv -> a_type == A_SYMBOL){ t_symbol *curarg = atom_getsymbolarg(0, argc, argv); if(!strcmp(curarg->s_name, "-off")){ active = 0; argc--; argv++; } else goto errstate; } else goto errstate; }; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("\f")); // hack outlet_new(&x->x_obj, &s_float); x->x_clock = clock_new(x, (t_method)s2f_tick); s2f_offset(x, offset); s2f_ms(x, interval); s2f_float(x, active); return(x); errstate: pd_error(x, "s2f~: improper args"); return NULL; }
void *function_new(t_symbol *msg, int argc, t_atom *argv) { t_function *x = (t_function *)pd_new(function_class); outlet_new(&x->x_obj, gensym("signal")); x->wavename = atom_getsymbolarg(0,argc,argv); x->normalize = 1; // post("float size: %d, t_float size: %d, t_word size %d", sizeof(float), sizeof(t_float), sizeof(t_word)); // post("latest version"); return x; }
static void *netreceive_new(t_symbol *s, int argc, t_atom *argv) { t_netreceive *x = (t_netreceive *)pd_new(netreceive_class); int portno = 0; x->x_ns.x_protocol = SOCK_STREAM; x->x_old = 0; x->x_ns.x_bin = 0; x->x_nconnections = 0; x->x_connections = (int *)t_getbytes(0); x->x_ns.x_sockfd = -1; if (argc && argv->a_type == A_FLOAT) { portno = atom_getfloatarg(0, argc, argv); x->x_ns.x_protocol = (atom_getfloatarg(1, argc, argv) != 0 ? SOCK_DGRAM : SOCK_STREAM); x->x_old = (!strcmp(atom_getsymbolarg(2, argc, argv)->s_name, "old")); argc = 0; } else { while (argc && argv->a_type == A_SYMBOL && *argv->a_w.w_symbol->s_name == '-') { if (!strcmp(argv->a_w.w_symbol->s_name, "-b")) x->x_ns.x_bin = 1; else if (!strcmp(argv->a_w.w_symbol->s_name, "-u")) x->x_ns.x_protocol = SOCK_DGRAM; else { pd_error(x, "netreceive: unknown flag ..."); postatom(argc, argv); endpost(); } argc--; argv++; } } if (argc && argv->a_type == A_FLOAT) portno = argv->a_w.w_float, argc--, argv++; if (argc) { pd_error(x, "netreceive: extra arguments ignored:"); postatom(argc, argv); endpost(); } if (x->x_old) { /* old style, nonsecure version */ x->x_ns.x_msgout = 0; } else x->x_ns.x_msgout = outlet_new(&x->x_ns.x_obj, &s_anything); /* create a socket */ if (portno > 0) netreceive_listen(x, portno); return (x); }