void GEMglRasterPos3f :: obj_setupCallback(t_class *classPtr) { class_addmethod(classPtr, reinterpret_cast<t_method>(&GEMglRasterPos3f::xMessCallback), gensym("x"), A_DEFFLOAT, A_NULL); class_addmethod(classPtr, reinterpret_cast<t_method>(&GEMglRasterPos3f::yMessCallback), gensym("y"), A_DEFFLOAT, A_NULL); class_addmethod(classPtr, reinterpret_cast<t_method>(&GEMglRasterPos3f::zMessCallback), gensym("z"), A_DEFFLOAT, A_NULL); };
void GEMglColor3sv :: obj_setupCallback(t_class *classPtr) { class_addmethod(classPtr, reinterpret_cast<t_method>(&GEMglColor3sv::vMessCallback), gensym("v"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_NULL); }
void knob_preset(t_knob *x, t_binbuf *b) { binbuf_addv(b, "sf", gensym("float"), (float)x->f_value); }
static void *iem_append_kernel_new(void) { t_iem_append_kernel *x = (t_iem_append_kernel *)pd_new(iem_append_kernel_class); t_glist *glist = (t_glist *)canvas_getcurrent(); t_canvas *canvas=glist_getcanvas(glist); int ac=0; t_atom *av; canvas_setcurrent(canvas); canvas_getargs(&ac, &av); canvas_unsetcurrent(canvas); x->x_type1 = A_NULL; x->x_sym1 = &s_list; x->x_size2 = 10; if(ac > 5) x->x_size2 = 2*ac; x->x_at2 = (t_atom *)getbytes(x->x_size2 * sizeof(t_atom)); x->x_size12 = x->x_size2 + 10; x->x_at12 = (t_atom *)getbytes(x->x_size12 * sizeof(t_atom)); x->x_ac1 = 0; x->x_inlet_select = 1; if(ac <= 0) { x->x_type2 = A_NULL; x->x_ac2 = 0; x->x_sym2 = &s_list; } else { if(IS_A_FLOAT(av, 0)) { if(ac == 1) iem_append_kernel_float(x, atom_getfloat(av)); else iem_append_kernel_list(x, &s_list, ac, av); } else if(IS_A_SYMBOL(av, 0)) { t_symbol *xsym=atom_getsymbol(av); if(xsym == gensym("symbol")) { if(ac > 1) iem_append_kernel_symbol(x, atom_getsymbol(av+1)); else iem_append_kernel_symbol(x, gensym("")); } else if(xsym == gensym("float")) { if(ac > 1) { if(IS_A_FLOAT(av, 1)) iem_append_kernel_float(x, atom_getfloat(av+1)); else iem_append_kernel_float(x, 0.0f); } else iem_append_kernel_float(x, 0.0f); } else if(xsym == gensym("list")) { iem_append_kernel_list(x, &s_list, ac-1, av+1); } else { iem_append_kernel_anything(x, xsym, ac-1, av+1); } } } outlet_new(&x->x_obj, &s_list); return (x); }
static t_symbol *iem_image_calc_size(t_iem_image *x) { char dirbuf[MAXPDSTRING], *namebufptr; char namebuf[MAXPDSTRING]; unsigned char buf[222]; unsigned int i; char *c; int fd; FILE *fh; size_t items; if(!x->x_gifsym || !x->x_gifsym->s_name) { post("iem_image-ERROR: no gifname"); x->x_gifsym = (t_symbol *)0; return((t_symbol *)0); } fd = open_via_path(canvas_getdir(glist_getcanvas(x->x_gui.x_glist))->s_name, x->x_gifsym->s_name, "", dirbuf, &namebufptr, MAXPDSTRING, 1); if (fd < 0) { post("iem_image-ERROR: cannot open %s first time", x->x_gifsym->s_name); x->x_gifsym = (t_symbol *)0; return((t_symbol *)0); } else { if(fd >= 0) close(fd); strcpy(namebuf, dirbuf); strcat(namebuf, "/"); strcat(namebuf, namebufptr); fh = fopen(namebuf, "r"); if(fh == NULL) { post("iem_image-ERROR: cannot open %s second time", namebuf); x->x_gifsym = (t_symbol *)0; return((t_symbol *)0); } else { items=fread(buf, 22, sizeof(unsigned char), fh); if((items < 1)||(strlen((char*)buf)<7)) { post("iem_image-ERROR: can not read header in %s, only %d items read: %s.", namebuf, strlen((char*)buf), (char*) buf); x->x_gifsym = (t_symbol *)0; return((t_symbol *)0); }; fclose(fh); c = (char *)buf; if((c[0] != 'G')||(c[1] != 'I')||(c[2] != 'F')) { post("iem_image-ERROR: %s is not a GIF-file", namebuf); x->x_gifsym = (t_symbol *)0; return((t_symbol *)0); } i = 256*(unsigned int)buf[7]; i += (unsigned int)buf[6]; x->x_gui.x_w = (int)i; i = 256*(unsigned int)buf[9]; i += (unsigned int)buf[8]; x->x_gui.x_h = (int)i; SETFLOAT(x->x_at_out, (t_float)x->x_gui.x_w); SETFLOAT(x->x_at_out+1, (t_float)x->x_gui.x_h); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at_out); if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at_out); return(gensym(namebuf)); } } }
void bassemu_tilde_setup(void) { bassemu_class = class_new(gensym("bassemu~"), (t_newmethod)bassemu_new, (t_method)bassemu_free, sizeof(t_bassemu), CLASS_DEFAULT, A_GIMME, 0); CLASS_MAINSIGNALIN(bassemu_class, t_bassemu, dummy); class_addmethod(bassemu_class, (t_method)bassemu_dsp, gensym("dsp"), 0); class_addfloat (bassemu_class, (t_method)bassemu_note); // start/stop using a toggle class_addmethod(bassemu_class, (t_method)bassemu_list, gensym("list"), A_GIMME, 0); class_addmethod(bassemu_class, (t_method)bassemu_vco, gensym("vco"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_hpf, gensym("hpf"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_glide, gensym("glide"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_limit, gensym("limit"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_ext, gensym("ext"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_tune, gensym("tune"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_envinc,gensym("envinc"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_reset, gensym("reset"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_cutoff,gensym("cutoff"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_reso, gensym("reso"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_envmod,gensym("envmod"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_decay, gensym("decay"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_pw, gensym("pw"), A_DEFFLOAT, 0); class_addmethod(bassemu_class, (t_method)bassemu_pitch, gensym("pitch"), A_DEFFLOAT, 0); logpost(NULL, 4, "bassemu~: transistor bass emulation"); logpost(NULL, 4, "bassemu~: version %i.%i",VER_MAJ, VER_MIN); logpost(NULL, 4, "bassemu~: (c) 2006 Ch. Klippel - [email protected]"); logpost(NULL, 4, "bassemu~: this is gpl'ed software, see README for details\n"); }
static void *NLMSerr_in_tilde_new(t_symbol *s, t_int argc, t_atom *argv) { t_NLMSerr_in_tilde *x = (t_NLMSerr_in_tilde *)pd_new(NLMSerr_in_tilde_class); t_int i, n_order=39; t_symbol *w_name; t_float beta=0.01f; 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 > 1111111) n_order = 1111111; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); outlet_new(&x->x_obj, &s_signal); x->x_flt_sig_in1 = 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 err_in memory allocation (history) x->x_ref_filt_in_hist = (t_float *)getbytes(x->x_n_order*sizeof(t_float)); x->x_ref_adapt_in_hist = (t_float *)getbytes(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; x->x_rw_index = 0; return(x); } else { post("NLMSerr_in~-ERROR: need 3 float- + 1 symbol-arguments:"); post(" order_of_filter + learnrate_beta + security_value + array_name_taps"); return(0); } }
static void show(latoocarfian_struct *latoocarfian) { make_results(latoocarfian); outlet_anything(latoocarfian -> search_outlet, gensym("show"), M_search_count, latoocarfian -> search_out); }
static void tab_ifft_bang(t_tab_ifft *x) { int i, j, k; int ok_src_re, ok_src_im, ok_dst_re, ok_dst_im; int w_index, w_inc, i_inc, v_index; int fftsize = x->x_fftsize; int fs1 = fftsize - 1; int fs2 = fftsize / 2; TAB_COMPLEX w; TAB_COMPLEX *sincos = x->x_sin_cos; iemarray_t *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im; t_float old1_re, old1_im, old2_re, old2_im, g; ok_src_re = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, fftsize); ok_src_im = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, fftsize); ok_dst_re = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, fftsize); ok_dst_im = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, fftsize); if(ok_src_re && ok_src_im && ok_dst_re && ok_dst_im) { t_garray *a; vec_src_re=x->x_beg_mem_src_re; vec_src_im=x->x_beg_mem_src_im; vec_dst_re=x->x_beg_mem_dst_re; vec_dst_im=x->x_beg_mem_dst_im; for(j=0; j<fftsize; j++) { iemarray_setfloat(vec_dst_re, j, iemarray_getfloat(vec_src_re, j)); iemarray_setfloat(vec_dst_im, j, iemarray_getfloat(vec_src_im, j)); } i_inc = fs2; w_inc = 1; for(i=1; i<fftsize; i<<=1) { v_index = 0; for(j=0; j<i; j++) { w_index = 0; for(k=0; k<i_inc; k++) { old1_re = iemarray_getfloat(vec_dst_re, v_index); old1_im = iemarray_getfloat(vec_dst_im, v_index); old2_re = iemarray_getfloat(vec_dst_re, v_index+i_inc); old2_im = iemarray_getfloat(vec_dst_im, v_index+i_inc); w = sincos[w_index]; iemarray_setfloat(vec_dst_re, v_index+i_inc, (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag); iemarray_setfloat(vec_dst_im, v_index+i_inc, (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag); iemarray_setfloat(vec_dst_re, v_index, old1_re + old2_re); iemarray_setfloat(vec_dst_im, v_index, old1_im + old2_im); w_index += w_inc; v_index++; } v_index += i_inc; } w_inc <<= 1; i_inc >>= 1; } j = 0; for(i=1;i<fs1;i++) { k = fs2; while(k <= j) { j = j - k; k >>= 1; } j = j + k; if(i < j) { old1_re = iemarray_getfloat(vec_dst_re, j); old1_im = iemarray_getfloat(vec_dst_im, j); iemarray_setfloat(vec_dst_re, j, iemarray_getfloat(vec_dst_re, i)); iemarray_setfloat(vec_dst_im, j, iemarray_getfloat(vec_dst_im, i)); iemarray_setfloat(vec_dst_re, i, old1_re); iemarray_setfloat(vec_dst_im, i, old1_im); } } // g = 2.0f / (t_float)fftsize; /* ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster g = 1.0f; for(i = 0; i < fs2; i++) { vec_dst_re[i] *= g; vec_dst_im[i] *= g; } */ g = 1.0 / (t_float)fftsize; for(i = 0; i < fftsize; i++) { iemarray_setfloat(vec_dst_re, i, iemarray_getfloat(vec_dst_re, i)*g); iemarray_setfloat(vec_dst_im, i, iemarray_getfloat(vec_dst_im, i)*g); } outlet_bang(x->x_obj.ob_outlet); a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class); garray_redraw(a); a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class); garray_redraw(a); }
void maxmode_setup(void) { int dresult = LOADER_OK; if (zgetfn(&pd_objectmaker, gensym("maxmode"))) { loud_error(0, "maxmode is already loaded"); return; } maxmode_class = class_new(gensym("maxmode"), (t_newmethod)maxmode_new, (t_method)maxmode_free, sizeof(t_maxmode), 0, A_GIMME, 0); class_addbang(maxmode_class, maxmode_bang); class_addmethod(maxmode_class, (t_method)maxmode_set, gensym("set"), A_DEFSYM, 0); class_addmethod(maxmode_class, (t_method)maxmode_get, gensym("get"), 0); class_addmethod(maxmode_class, (t_method)maxmode_cd, gensym("cd"), A_DEFSYM, 0); class_addmethod(maxmode_class, (t_method)maxmode_pwd, gensym("pwd"), A_SYMBOL, 0); class_addmethod(maxmode_class, (t_method)maxmode_import, gensym("import"), A_DEFSYM, 0); class_addmethod(maxmode_class, (t_method)maxmode_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); hammerfile_setup(maxmode_class, 0); if (canvas_getcurrent()) { fitter_setup(0, 0); if (!zgetfn(&pd_objectmaker, gensym("cyclone"))) /* cycloneless maxmode -- banner is posted by the oldest maxmode object with no creation arguments */ maxmode_withbanner = 1; } else { fittermax_set(); if (zgetfn(&pd_objectmaker, gensym("cyclone"))) loud_warning(0, "maxmode", "cyclone is already loaded"); else { if (unstable_load_lib("", "cyclone") == LOADER_NOFILE) loud_error(0, "cyclone library is missing"); else if (!zgetfn(&pd_objectmaker, gensym("cyclone"))) loud_error(0, "miXed/Pd version mismatch"); } } maxmode_dummiesndx = fragile_class_count(); if (zgetfn(&pd_objectmaker, gensym("dummies"))) loud_warning(0, "maxmode", "dummies are already loaded"); else dresult = unstable_load_lib("", "dummies"); maxmode_lastndx = fragile_class_count() - 1; if (dresult == LOADER_NOFILE) loud_warning(0, "maxmode", "dummies not found"); else { t_symbol *s = gensym("_cc.dummies"); if (s->s_thing && !s->s_next && !strcmp(class_getname(*s->s_thing), "_cc.dummies")) maxmode_dproxy = s->s_thing; else loudbug_bug("maxmode_setup"); /* FIXME */ } }
static void *matrix_new(t_symbol *s, int argc, t_atom *argv) { t_matrix *x = (t_matrix *)pd_new(matrix_class); t_float rampval = MATRIX_DEFRAMP; x->x_numinlets = (int)MATRIX_MININLETS; x->x_numoutlets = (int)MATRIX_MINOUTLETS; x->x_defgain = MATRIX_DEFGAIN; int i; int argnum = 0; while(argc > 0){ if(argv -> a_type == A_FLOAT){ t_float argval = atom_getfloatarg(0, argc, argv); switch(argnum){ case 0: if(argval < MATRIX_MININLETS){ x->x_numinlets = (int)MATRIX_MININLETS; } else if (argval > MATRIX_MAXINLETS){ x->x_numinlets = (int)MATRIX_MAXINLETS; post("matrix~: resizing to %d signal inlets", (int)MATRIX_MAXINLETS); } else{ x->x_numinlets = (int)argval; }; break; case 1: if(argval < MATRIX_MINOUTLETS){ x->x_numoutlets = (int)MATRIX_MINOUTLETS; } else if (argval > MATRIX_MAXOUTLETS){ x->x_numoutlets = (int)MATRIX_MAXOUTLETS; post("matrix~: resizing to %d signal outlets", (int)MATRIX_MAXOUTLETS); } else{ x->x_numoutlets = (int)argval; }; break; case 2: x->x_defgain = argval; break; default: break; }; argc--; argv++; argnum++; } else if(argv -> a_type == A_SYMBOL){ t_symbol *argname = atom_getsymbolarg(0, argc, argv); if(strcmp(argname->s_name, "@ramp")==0){ if(argc >= 2){ t_float argval = atom_getfloatarg(1, argc, argv); if(argval < MATRIX_MINRAMP){ rampval = MATRIX_MINRAMP; } else{ rampval = argval; }; argc -= 2; argv += 2; } else{ goto errstate; }; } else{ goto errstate; }; } else{ goto errstate; }; }; int gaingiven = argnum >= 3; //if >= 3 args given, then gain is given, binary mode is off x->x_ncells = x->x_numinlets * x->x_numoutlets; x->x_ivecs = getbytes(x->x_numinlets * sizeof(*x->x_ivecs)); x->x_ovecs = getbytes(x->x_numoutlets * sizeof(*x->x_ovecs)); x->x_nblock = x->x_maxblock = sys_getblksize(); x->x_osums = getbytes(x->x_numoutlets * sizeof(*x->x_osums)); for (i = 0; i < x->x_numoutlets; i++){ x->x_osums[i] = getbytes(x->x_maxblock * sizeof(*x->x_osums[i])); }; x->x_cells = getbytes(x->x_ncells * sizeof(*x->x_cells)); /* zerovec for filtering float inputs*/ x->x_zerovec = getbytes(x->x_maxblock * sizeof(*x->x_zerovec)); matrix_clear(x); if (gaingiven){ x->x_gains = getbytes(x->x_ncells * sizeof(*x->x_gains)); for (i = 0; i < x->x_ncells; i++){ x->x_gains[i] = x->x_defgain; }; x->x_ramps = getbytes(x->x_ncells * sizeof(*x->x_ramps)); matrix_ramp(x, rampval); x->x_coefs = getbytes(x->x_ncells * sizeof(*x->x_coefs)); for (i = 0; i < x->x_ncells; i++){ x->x_coefs[i] = 0.; }; x->x_ksr = sys_getsr() * .001; x->x_incrs = getbytes(x->x_ncells * sizeof(*x->x_incrs)); x->x_bigincrs = getbytes(x->x_ncells * sizeof(*x->x_bigincrs)); x->x_remains = getbytes(x->x_ncells * sizeof(*x->x_remains)); for (i = 0; i < x->x_ncells; i++){ x->x_remains[i] = 0; }; } else{ x->x_gains = 0; x->x_ramps = 0; x->x_coefs = 0; x->x_incrs = 0; x->x_bigincrs = 0; x->x_remains = 0; }; for (i = 1; i < x->x_numinlets; i++){ pd_float( (t_pd *)inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal), -0.); x->x_signalscalars[i] = obj_findsignalscalar((t_object *)x, i); }; for (i = 0; i < x->x_numoutlets; i++){ outlet_new(&x->x_obj, gensym("signal")); }; x->x_dumpout = outlet_new((t_object *)x, &s_list); x->x_glist = canvas_getcurrent(); return (x); errstate: pd_error(x, "matrix~: improper args"); return NULL; }
static void *n_CNLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) { t_n_CNLMS_tilde *x = (t_n_CNLMS_tilde *)pd_new(n_CNLMS_tilde_class); char buffer[400]; int i; t_int n_order=39, n_io=1; t_symbol *w_name; t_float beta=0.1f; t_float gamma=0.00001f; t_float kappa = 1.0f; if((argc >= 6) && IS_A_FLOAT(argv,0) && //IS_A_FLOAT/SYMBOL from iemlib.h IS_A_FLOAT(argv,1) && IS_A_FLOAT(argv,2) && IS_A_FLOAT(argv,3) && IS_A_FLOAT(argv,4) && IS_A_SYMBOL(argv,5)) { n_io = (t_int)atom_getintarg(0, argc, argv); n_order = (t_int)atom_getintarg(1, argc, argv); beta = (t_float)atom_getfloatarg(2, argc, argv); gamma = (t_float)atom_getfloatarg(3, argc, argv); kappa = (t_float)atom_getfloatarg(4, argc, argv); w_name = (t_symbol *)atom_getsymbolarg(5, argc, argv); if(beta < 0.0f) beta = 0.0f; if(beta > 2.0f) beta = 2.0f; if(gamma < 0.0f) gamma = 0.0f; if(gamma > 1.0f) gamma = 1.0f; if(kappa < 0.0001f) kappa = 0.0001f; if(kappa > 10000.0f) kappa = 10000.0f; if(n_order < 2) n_order = 2; if(n_order > 11111) n_order = 11111; if(n_io < 1) n_io = 1; if(n_io > 60) n_io = 60; for(i=0; i<n_io; i++) inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); for(i=0; i<=n_io; i++) outlet_new(&x->x_obj, &s_signal); x->x_out_compressing_bang = outlet_new(&x->x_obj, &s_bang); x->x_msi = 0; x->x_n_io = n_io; x->x_n_order = n_order; x->x_update = 0; x->x_beta = beta; x->x_gamma = gamma; x->x_kappa = kappa; x->x_my_kern = (t_n_CNLMS_tilde_kern *)getbytes(x->x_n_io*sizeof(t_n_CNLMS_tilde_kern)); for(i=0; i<n_io; i++) { sprintf(buffer, "%d_%s", i+1, w_name->s_name); x->x_my_kern[i].x_w_array_sym_name = gensym(buffer); x->x_my_kern[i].x_w_array_mem_beg = (t_float *)0; x->x_my_kern[i].x_in_hist = (t_float *)getbytes(2*x->x_n_order*sizeof(t_float)); } x->x_clock = clock_new(x, (t_method)n_CNLMS_tilde_tick); return(x); } else { post("n_CNLMSC~-ERROR: need 5 float- + 1 symbol-arguments:"); post(" number_of_filters + order_of_filters + learnrate_beta + security_value_gamma + threshold_kappa + array_name_taps"); return(0); } }
static void mtxIFFTMatrixHot (MtxIFFT *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; int fft_count; t_atom *list_re = x->list_re; t_atom *list_im = x->list_im; t_float *f_re = x->f_re; t_float *f_im = x->f_im; /* fftsize check */ if (!size) { pd_error(x, "[mtx_ifft]: invalid dimensions"); } else if (in_size<size) { pd_error(x, "[mtx_ifft]: sparse matrix not yet supported: use \"mtx_check\""); } else if (size != x->size) { pd_error(x, "[mtx_ifft]: left matrix has other dimensions than right matrix"); } else if (columns < 4) { pd_error(x, "[mtx_ifft]: matrix must have at least 4 columns"); } else if (columns == (1 << ilog2(columns))) { /* ok, do the FFT! */ /* main part */ readFloatFromList (size, argv, f_re); fft_count = rows; list_re += 2; list_im += 2; while (fft_count--) { mayer_ifft (columns, f_re, f_im); multiplyVector (columns, f_re, x->renorm_fac); multiplyVector (columns, f_im, x->renorm_fac); writeFloatIntoList (columns, list_re, f_re); writeFloatIntoList (columns, list_im, f_im); f_im += columns; f_re += columns; list_re += columns; list_im += columns; } list_re = x->list_re; list_im = x->list_im; SETSYMBOL(list_re, gensym("matrix")); SETSYMBOL(list_im, gensym("matrix")); SETFLOAT(list_re, rows); SETFLOAT(list_im, rows); SETFLOAT(list_re+1, columns); SETFLOAT(list_im+1, columns); outlet_anything(x->list_im_out, gensym("matrix"), x->size+2, list_im); outlet_anything(x->list_re_out, gensym("matrix"), x->size+2, list_re); } else { pd_error(x, "[mtx_ifft]: rowvector size no power of 2!"); } }
void keyboard_layout_setup(void) { keyboard_layout_class = class_new(gensym("text"), (t_method)keyboard_layout_new, NULL, sizeof(t_keyboard_layout), 0, 0); }
void sys_loadpreferences( void) { int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV]; int nmidiindev, midiindev[MAXMIDIINDEV]; int nmidioutdev, midioutdev[MAXMIDIOUTDEV]; int i, rate = 0, advance = 0, callback = 0, api, nolib, maxi; char prefbuf[MAXPDSTRING], keybuf[80]; sys_initloadpreferences(); /* load audio preferences */ if (sys_getpreference("audioapi", prefbuf, MAXPDSTRING) && sscanf(prefbuf, "%d", &api) > 0) sys_set_audio_api(api); /* JMZ/MB: brackets for initializing */ if (sys_getpreference("noaudioin", prefbuf, MAXPDSTRING) && (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))) naudioindev = 0; else { for (i = 0, naudioindev = 0; i < MAXAUDIOINDEV; i++) { sprintf(keybuf, "audioindev%d", i+1); if (!sys_getpreference(keybuf, prefbuf, MAXPDSTRING)) break; if (sscanf(prefbuf, "%d %d", &audioindev[i], &chindev[i]) < 2) break; naudioindev++; } /* if no preferences at all, set -1 for default behavior */ if (naudioindev == 0) naudioindev = -1; } /* JMZ/MB: brackets for initializing */ if (sys_getpreference("noaudioout", prefbuf, MAXPDSTRING) && (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))) naudiooutdev = 0; else { for (i = 0, naudiooutdev = 0; i < MAXAUDIOOUTDEV; i++) { sprintf(keybuf, "audiooutdev%d", i+1); if (!sys_getpreference(keybuf, prefbuf, MAXPDSTRING)) break; if (sscanf(prefbuf, "%d %d", &audiooutdev[i], &choutdev[i]) < 2) break; naudiooutdev++; } if (naudiooutdev == 0) naudiooutdev = -1; } if (sys_getpreference("rate", prefbuf, MAXPDSTRING)) sscanf(prefbuf, "%d", &rate); if (sys_getpreference("audiobuf", prefbuf, MAXPDSTRING)) sscanf(prefbuf, "%d", &advance); if (sys_getpreference("callback", prefbuf, MAXPDSTRING)) sscanf(prefbuf, "%d", &callback); sys_set_audio_settings(naudioindev, audioindev, naudioindev, chindev, naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, advance, callback); /* load MIDI preferences */ /* JMZ/MB: brackets for initializing */ if (sys_getpreference("nomidiin", prefbuf, MAXPDSTRING) && (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))) nmidiindev = 0; else for (i = 0, nmidiindev = 0; i < MAXMIDIINDEV; i++) { sprintf(keybuf, "midiindev%d", i+1); if (!sys_getpreference(keybuf, prefbuf, MAXPDSTRING)) break; if (sscanf(prefbuf, "%d", &midiindev[i]) < 1) break; nmidiindev++; } /* JMZ/MB: brackets for initializing */ if (sys_getpreference("nomidiout", prefbuf, MAXPDSTRING) && (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))) nmidioutdev = 0; else for (i = 0, nmidioutdev = 0; i < MAXMIDIOUTDEV; i++) { sprintf(keybuf, "midioutdev%d", i+1); if (!sys_getpreference(keybuf, prefbuf, MAXPDSTRING)) break; if (sscanf(prefbuf, "%d", &midioutdev[i]) < 1) break; nmidioutdev++; } sys_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev, 0); /* search path */ if (sys_getpreference("npath", prefbuf, MAXPDSTRING)) sscanf(prefbuf, "%d", &maxi); else maxi = 0x7fffffff; for (i = 0; i<maxi; i++) { sprintf(keybuf, "path%d", i+1); if (!sys_getpreference(keybuf, prefbuf, MAXPDSTRING)) break; sys_searchpath = namelist_append_files(sys_searchpath, prefbuf); } if (sys_getpreference("standardpath", prefbuf, MAXPDSTRING)) sscanf(prefbuf, "%d", &sys_usestdpath); if (sys_getpreference("verbose", prefbuf, MAXPDSTRING)) sscanf(prefbuf, "%d", &sys_verbose); /* startup settings */ if (sys_getpreference("nloadlib", prefbuf, MAXPDSTRING)) sscanf(prefbuf, "%d", &maxi); else maxi = 0x7fffffff; for (i = 0; i<maxi; i++) { sprintf(keybuf, "loadlib%d", i+1); if (!sys_getpreference(keybuf, prefbuf, MAXPDSTRING)) break; sys_externlist = namelist_append_files(sys_externlist, prefbuf); } if (sys_getpreference("defeatrt", prefbuf, MAXPDSTRING)) sscanf(prefbuf, "%d", &sys_defeatrt); if (sys_getpreference("flags", prefbuf, MAXPDSTRING)) { if (strcmp(prefbuf, ".")) sys_flags = gensym(prefbuf); } sys_doflags(); if (sys_defeatrt) sys_hipriority = 0; else #ifdef UNIX sys_hipriority = 1; //!geteuid(); #else #ifdef MSW sys_hipriority = 0; #else sys_hipriority = 1; #endif #endif }
static void show(lotkavolterra_struct *lotkavolterra) { make_results(lotkavolterra); outlet_anything(lotkavolterra -> search_outlet, gensym("show"), M_search_count, lotkavolterra -> search_out); }
t_max_err mode_set(t_hoa_decoder *x, t_object *attr, long argc, t_atom *argv) { if(argc && argv && atom_gettype(argv) == A_SYM) { if(atom_getsym(argv) == gensym("ambisonic") && x->f_decoder->getDecodingMode() != Hoa2D::DecoderMulti::Regular) { object_method(gensym("dsp")->s_thing, gensym("stop")); x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Regular); object_attr_setdisabled((t_object *)x, gensym("angles"), 1); object_attr_setdisabled((t_object *)x, gensym("channels"), 0); object_attr_setdisabled((t_object *)x, gensym("offset"), 0); object_attr_setfloat(x, gensym("offset"), (float)x->f_decoder->getChannelsOffset() / HOA_2PI * 360.f); } else if(atom_getsym(argv) == gensym("irregular") && x->f_decoder->getDecodingMode() != Hoa2D::DecoderMulti::Irregular) { object_method(gensym("dsp")->s_thing, gensym("stop")); x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Irregular); object_attr_setdisabled((t_object *)x, gensym("angles"), 0); object_attr_setdisabled((t_object *)x, gensym("channels"), 0); object_attr_setdisabled((t_object *)x, gensym("offset"), 1); } else if(atom_getsym(argv) == gensym("binaural") && x->f_decoder->getDecodingMode() != Hoa2D::DecoderMulti::Binaural) { object_method(gensym("dsp")->s_thing, gensym("stop")); x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Binaural); object_attr_setdisabled((t_object *)x, gensym("angles"), 1); object_attr_setdisabled((t_object *)x, gensym("channels"), 1); object_attr_setdisabled((t_object *)x, gensym("offset"), 1); } object_attr_setlong(x, gensym("channels"), x->f_decoder->getNumberOfChannels()); } send_configuration(x); return MAX_ERR_NONE; }
void GEMglLightf :: obj_setupCallback(t_class *classPtr) { class_addmethod(classPtr, reinterpret_cast<t_method>(&GEMglLightf::lightMessCallback), gensym("light"), A_DEFFLOAT, A_NULL); class_addmethod(classPtr, reinterpret_cast<t_method>(&GEMglLightf::pnameMessCallback), gensym("pname"), A_DEFFLOAT, A_NULL); class_addmethod(classPtr, reinterpret_cast<t_method>(&GEMglLightf::paramMessCallback), gensym("param"), A_DEFFLOAT, A_NULL); };
void HoaOptim_dsp64(t_HoaOptim *x, t_object *dsp64, short *count, double samplerate, long maxvectorsize, long flags) { x->f_AmbisonicsOptim->setVectorSize(maxvectorsize); object_method(dsp64, gensym("dsp_add64"), x, HoaOptim_perform64, 0, NULL); }
///////////////////////////////////////////////////////// // // GEMglTexCoord1dv // ///////////////////////////////////////////////////////// // Constructor // GEMglTexCoord1dv :: GEMglTexCoord1dv (t_floatarg arg0) { vMess(arg0); m_inlet = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("v")); }
static void routeOSC_doanything(t_routeOSC *x, t_symbol *s, int argc, t_atom *argv) { char *pattern, *nextSlash; int i = 0, pattern_depth = 0, matchedAnything = 0; int noPath = 0; // nonzero if we are dealing with a simple list (as from a previous [routeOSC]) pattern = s->s_name; if (x->x_verbosity) post("routeOSC_doanything(%p): pattern is %s", x, pattern); if (pattern[0] != '/') { /* output unmatched data on rightmost outlet */ if (x->x_verbosity) post("routeOSC_doanything no OSC path(%p) , %d args", x, argc); outlet_anything(x->x_outlets[x->x_num], s, argc, argv); return; } pattern_depth = routeOSC_count_slashes(pattern); if (x->x_verbosity) post("routeOSC_doanything(%p): pattern_depth is %i", x, pattern_depth); nextSlash = NextSlashOrNull(pattern+1); if (*nextSlash == '\0') { /* pattern_depth == 1 */ /* last level of the address, so we'll output the argument list */ for (i = 0; i < x->x_num; ++i) { if ( (x->x_prefix_depth[i] <= pattern_depth) && (MyPatternMatch(pattern+1, x->x_prefixes[i]+1)) ) { ++matchedAnything; if (noPath) { // just a list starting with a symbol // The special symbol is s if (x->x_verbosity) post("routeOSC_doanything _1_(%p): (%d) noPath: s is \"%s\"", x, i, s->s_name); outlet_anything(x->x_outlets[i], s, argc, argv); } else // normal OSC path { // I hate stupid Max lists with a special first element if (argc == 0) { if (x->x_verbosity) post("routeOSC_doanything _2_(%p): (%d) no args", x, i); outlet_bang(x->x_outlets[i]); } else if (argv[0].a_type == A_SYMBOL) { // Promote the symbol that was argv[0] to the special symbol if (x->x_verbosity) post("routeOSC_doanything _3_(%p): (%d) symbol: is \"%s\"", x, i, argv[0].a_w.w_symbol->s_name); outlet_anything(x->x_outlets[i], argv[0].a_w.w_symbol, argc-1, argv+1); } else if (argc > 1) { // Multiple arguments starting with a number, so naturally we have // to use a special function to output this "list", since it's what // Max originally meant by "list". if (x->x_verbosity) post("routeOSC_doanything _4_(%p): (%d) list:", x, i); outlet_list(x->x_outlets[i], 0L, argc, argv); } else { // There was only one argument, and it was a number, so we output it // not as a list if (argv[0].a_type == A_FLOAT) { if (x->x_verbosity) post("routeOSC_doanything _5_(%p): (%d) a single float", x, i); outlet_float(x->x_outlets[i], argv[0].a_w.w_float); } else { pd_error(x, "* routeOSC: unrecognized atom type!"); } } } } } } else { /* There's more address after this part, so our output list will begin with the next slash. */ t_symbol *restOfPattern = 0; /* avoid the gensym unless we have to output */ char patternBegin[1000]; /* Get the incoming pattern to match against all our prefixes */ for (i = 0; i < x->x_num; ++i) { restOfPattern = 0; if (x->x_prefix_depth[i] <= pattern_depth) { StrCopyUntilNthSlash(patternBegin, pattern+1, x->x_prefix_depth[i]); if (x->x_verbosity) post("routeOSC_doanything _6_(%p): (%d) patternBegin is %s", x, i, patternBegin); if (MyPatternMatch(patternBegin, x->x_prefixes[i]+1)) { if (x->x_verbosity) post("routeOSC_doanything _7_(%p): (%d) matched %s depth %d", x, i, x->x_prefixes[i], x->x_prefix_depth[i]); ++matchedAnything; nextSlash = NthSlashOrNull(pattern+1, x->x_prefix_depth[i]); if (x->x_verbosity) post("routeOSC_doanything _8_(%p): (%d) nextSlash %s [%d]", x, i, nextSlash, nextSlash[0]); if (*nextSlash != '\0') { if (x->x_verbosity) post("routeOSC_doanything _9_(%p): (%d) more pattern", x, i); restOfPattern = gensym(nextSlash); outlet_anything(x->x_outlets[i], restOfPattern, argc, argv); } else if (argc == 0) { if (x->x_verbosity) post("routeOSC_doanything _10_(%p): (%d) no more pattern, no args", x, i); outlet_bang(x->x_outlets[i]); } else { if (x->x_verbosity) post("routeOSC_doanything _11_(%p): (%d) no more pattern, %d args", x, i, argc); if (argv[0].a_type == A_SYMBOL) // Promote the symbol that was argv[0] to the special symbol outlet_anything(x->x_outlets[i], argv[0].a_w.w_symbol, argc-1, argv+1); else outlet_anything(x->x_outlets[i], gensym("list"), argc, argv); } } } } } if (!matchedAnything) { // output unmatched data on rightmost outlet a la normal 'route' object, jdl 20020908 if (x->x_verbosity) post("routeOSC_doanything _13_(%p) unmatched %d, %d args", x, i, argc); outlet_anything(x->x_outlets[x->x_num], s, argc, argv); } }
void hoa_3d_scope_dsp64(t_hoa_3d_scope *x, t_object *dsp64, short *count, double samplerate, long maxvectorsize, long flags) { object_method(dsp64, gensym("dsp_add64"), x, hoa_3d_scope_perform64, 0, NULL); x->f_startclock = 1; }
void pix_opencv_patreco :: loadMess (t_symbol *s, int argc, t_atom* argv) { t_symbol* filename; int id; if ( argc != 2 ) { error("wrong arguments : load <id> <filename>"); return; } else if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_SYMBOL ) { error("wrong arguments : load <id> <filename>"); return; } else { id = atom_getfloat(&argv[0]); filename = atom_getsymbol(&argv[1]); } if ( filename->s_name[0] == 0 ) { error("no filename passed to load message"); return; } if ( filename == NULL ) { error("%s is not a valid matrix", filename->s_name); return; } Mat img = imread(filename->s_name,0); if ( img.data == NULL ){ error("failed to load image '%s'", filename->s_name); puts("failed to laod images"); return; } if(img.cols!=img.rows){ error("%s is not a square pattern", filename->s_name); puts("not a square pattern"); return; } cv::Mat src(m_pattern_size, m_pattern_size, CV_8UC1); Point2f center((m_pattern_size-1)/2.0f,(m_pattern_size-1)/2.0f); Mat rot_mat(2,3,CV_32F); //~ std::map<int PatternLib>::iterator it; //~ it = m_patternLibrary.find(id); //~ if ( m_patternLibrary.find(id) != m_patternLibrary.end() ){ // TODO remove item from the map //~ } PatternLib pattern; pattern.id = id; cv::resize(img, src, Size(m_pattern_size,m_pattern_size)); if ( m_detector->m_ART_pattern ) { Mat subImg = src(cv::Range(m_pattern_size/4,3*m_pattern_size/4), cv::Range(m_pattern_size/4,3*m_pattern_size/4)); pattern.pattern[0] = subImg; pattern.mean[0] = cvMean(&((CvMat)subImg)); pattern.norm[0] = cv::norm(subImg, NORM_L1); //~ m_patternLibrary.push_back(subImg); } else { //~ m_patternLibrary.push_back(src); pattern.pattern[0] = src; pattern.mean[0] = cvMean(&((CvMat)src)); pattern.norm[0] = cv::norm(src, NORM_L1); } rot_mat = getRotationMatrix2D( center, 90, 1.0); for (int i=1; i<4; i++){ Mat dst= Mat(m_pattern_size, m_pattern_size, CV_8UC1); rot_mat = getRotationMatrix2D( center, -i*90, 1.0); cv::warpAffine( src, dst , rot_mat, Size(m_pattern_size,m_pattern_size)); if ( m_detector->m_ART_pattern ) { Mat subImg = dst(cv::Range(m_pattern_size/4,3*m_pattern_size/4), cv::Range(m_pattern_size/4,3*m_pattern_size/4)); // AV crop 25% on each side -> specific to AR tag ? pattern.pattern[i]; pattern.mean[i] = cvMean(&((CvMat)subImg)); pattern.norm[i] = cv::norm(subImg, NORM_L1); //~ m_patternLibrary.push_back(subImg); } else { pattern.pattern[i] = dst; pattern.mean[i] = cvMean(&((CvMat)dst)); pattern.norm[i] = cv::norm(dst, NORM_L1); //~ m_patternLibrary.push_back(dst); } } t_atom data_out; SETFLOAT(&data_out, m_patternLibrary.size()); outlet_anything( m_dataout, gensym("patternCount"), 1, &data_out); }
void GEMglProgramLocalParameter4fvARB :: obj_setupCallback(t_class *classPtr) { class_addmethod(classPtr, reinterpret_cast<t_method>(&GEMglProgramLocalParameter4fvARB::targetMessCallback), gensym("target"), A_DEFFLOAT, A_NULL); class_addmethod(classPtr, reinterpret_cast<t_method>(&GEMglProgramLocalParameter4fvARB::indexMessCallback), gensym("index"), A_DEFFLOAT, A_NULL); class_addmethod(classPtr, reinterpret_cast<t_method>(&GEMglProgramLocalParameter4fvARB::paramsMessCallback), gensym("params"), A_GIMME, A_NULL); };
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; t_int iinit=0, ifstyle=0; t_iem_init_symargs *init=(t_iem_init_symargs *)(&iinit); t_iem_fstyle_flags *fstyle=(t_iem_fstyle_flags *)(&ifstyle); t_symbol *srl[3]; char str[144]; x->x_gui.x_snd = gensym("empty"); x->x_gui.x_rcv = gensym("empty"); x->x_gui.x_lab = gensym("empty"); srl[0] = gensym("empty"); srl[1] = gensym("empty"); srl[2] = 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; iinit = (int)atom_getintarg(1, argc, argv); ifstyle = (int)atom_getintarg(2, argc, argv); if(IS_A_SYMBOL(argv, 3)) srl[0] = atom_getsymbolarg(3, argc, argv); else if(IS_A_FLOAT(argv,3)) { sprintf(str, "%d", (int)atom_getintarg(3, argc, argv)); srl[0] = gensym(str); } if(IS_A_SYMBOL(argv,4)) srl[1] = atom_getsymbolarg(4, argc, argv); else if(IS_A_FLOAT(argv,4)) { sprintf(str, "%d", (int)atom_getintarg(4, argc, argv)); srl[1] = gensym(str); } } iinit &= IEM_INIT_ARGS_ALL; ifstyle &= IEM_FSTYLE_FLAGS_ALL; 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(); fstyle->x_snd_able = 1; fstyle->x_rcv_able = 1; if(!strcmp(srl[0]->s_name, "empty")) fstyle->x_snd_able = 0; if(!strcmp(srl[1]->s_name, "empty")) fstyle->x_rcv_able = 0; x->x_gui.x_unique_num = 0; x->x_gui.x_fsf = *fstyle; x->x_gui.x_isa = *init; iemgui_first_dollararg2sym(&x->x_gui, sr); 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_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); }
/* get the number of slots */ static void liststorage_info(t_liststorage *x) { t_atom ap; SETFLOAT(&ap, (t_float)x->x_numslots); outlet_anything(x->x_infoout, gensym("numslots"), 1, &ap); }
void knob_mousedrag(t_knob *x, t_object *patcherview, t_pt pt, long modifiers) { float angle = pd_angle(pt.x - x->j_box.b_rect.width * 0.5, (x->j_box.b_rect.height * 0.5 - pt.y)) / EPD_2PI; if(x->f_mode) { if(x->f_endless) { if(x->f_min < x->f_max) { angle = -angle; angle -= 0.25; while (angle < 0.) angle += 1.; while (angle > 1.) angle -= 1.; x->f_value = angle * (x->f_max - x->f_min) + x->f_min; } else { angle += 0.25; while (angle < 0.) angle += 1.; while (angle > 1.) angle -= 1.; x->f_value = angle * (x->f_min - x->f_max) + x->f_max; } } else { if(x->f_min < x->f_max) { angle = -angle; angle -= 0.25; while (angle < 0.) angle += 1.; while (angle > 1.) angle -= 1.; angle = pd_clip_minmax(angle, 0.125, 0.875); angle -= 0.125; angle *= 1. / 0.75; x->f_value = angle * (x->f_max - x->f_min) + x->f_min; } else { angle += 0.25; while (angle < 0.) angle += 1.; while (angle > 1.) angle -= 1.; angle = pd_clip_minmax(angle, 0.125, 0.875); angle -= 0.125; angle *= 1. / 0.75; x->f_value = angle * (x->f_min - x->f_max) + x->f_max; } } } else { float diff = x->f_ref_y - pt.y; if(diff == 0xffffffff) return; if(x->f_min < x->f_max) { if(x->f_endless) { x->f_value = fmodf(diff / 50. * (x->f_max - x->f_min) + x->f_ref_value + x->f_max - x->f_min, x->f_max - x->f_min); } else x->f_value = pd_clip_minmax(diff / 50. * (x->f_max - x->f_min) + x->f_ref_value, x->f_min, x->f_max); } else { if(x->f_endless) { x->f_value = fmodf(diff / 50. * (x->f_min - x->f_max) + x->f_ref_value + x->f_min - x->f_max, x->f_min - x->f_max); } else x->f_value = pd_clip_minmax(diff / 50. * (x->f_min - x->f_max) + x->f_ref_value, x->f_max, x->f_min); } } ebox_invalidate_layer((t_ebox *)x, gensym("needle_layer")); ebox_redraw((t_ebox *)x); knob_output(x); }
void kbuffer_tilde_setup(void){ kbuffer_class = class_new(gensym("kbuffer~"), (t_newmethod)kbuffer_new, (t_method)kbuffer_dsp_free,sizeof(t_kbuffer), 0,A_GIMME,0); CLASS_MAINSIGNALIN(kbuffer_class, t_kbuffer, x_f); class_addmethod(kbuffer_class,(t_method)kbuffer_dsp,gensym("dsp"),0); class_addmethod(kbuffer_class,(t_method)kbuffer_record,gensym("record"),0); class_addmethod(kbuffer_class,(t_method)kbuffer_play,gensym("play"),0); class_addmethod(kbuffer_class,(t_method)kbuffer_loop,gensym("loop"),0); class_addmethod(kbuffer_class,(t_method)kbuffer_stop,gensym("stop"),0); class_addmethod(kbuffer_class,(t_method)kbuffer_dump,gensym("dump"),0); class_addmethod(kbuffer_class,(t_method)kbuffer_info,gensym("info"),0); class_addmethod(kbuffer_class,(t_method)kbuffer_speed,gensym("speed"),A_FLOAT,0); class_addmethod(kbuffer_class,(t_method)kbuffer_size,gensym("size"),A_FLOAT,0); class_addmethod(kbuffer_class,(t_method)kbuffer_ksrate,gensym("ksrate"),A_FLOAT,0); post("%s %s",OBJECT_NAME, LYONPOTPOURRI_MSG); }
///////////////////////////////////////////////////////// // // GEMglColor3sv // ///////////////////////////////////////////////////////// // Constructor // GEMglColor3sv :: GEMglColor3sv (t_floatarg arg0=0, t_floatarg arg1=0, t_floatarg arg2=0) { vMess(arg0, arg1, arg2); m_inlet = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("v")); }
SRATOM_API int sratom_write(Sratom* sratom, LV2_URID_Unmap* unmap, uint32_t flags, const SerdNode* subject, const SerdNode* predicate, uint32_t type_urid, uint32_t size, const void* body) { const char* const type = unmap->unmap(unmap->handle, type_urid); uint8_t idbuf[12] = "b0000000000"; SerdNode id = serd_node_from_string(SERD_BLANK, idbuf); uint8_t nodebuf[12] = "b0000000000"; SerdNode node = serd_node_from_string(SERD_BLANK, nodebuf); SerdNode object = SERD_NODE_NULL; SerdNode datatype = SERD_NODE_NULL; SerdNode language = SERD_NODE_NULL; bool new_node = false; if (type_urid == 0 && size == 0) { object = serd_node_from_string(SERD_URI, USTR(NS_RDF "nil")); } else if (type_urid == sratom->forge.String) { object = serd_node_from_string(SERD_LITERAL, (const uint8_t*)body); } else if (type_urid == sratom->forge.Chunk) { datatype = serd_node_from_string(SERD_URI, NS_XSD "base64Binary"); object = serd_node_new_blob(body, size, true); new_node = true; } else if (type_urid == sratom->forge.Literal) { const LV2_Atom_Literal_Body* lit = (const LV2_Atom_Literal_Body*)body; const uint8_t* str = USTR(lit + 1); object = serd_node_from_string(SERD_LITERAL, str); if (lit->datatype) { datatype = serd_node_from_string( SERD_URI, USTR(unmap->unmap(unmap->handle, lit->datatype))); } else if (lit->lang) { const char* lang = unmap->unmap(unmap->handle, lit->lang); const char* prefix = "http://lexvo.org/id/iso639-3/"; const size_t prefix_len = strlen(prefix); if (lang && !strncmp(lang, prefix, prefix_len)) { language = serd_node_from_string( SERD_LITERAL, USTR(lang + prefix_len)); } else { fprintf(stderr, "Unknown language URID %d\n", lit->lang); } } } else if (type_urid == sratom->forge.URID) { const uint32_t urid = *(const uint32_t*)body; const uint8_t* str = USTR(unmap->unmap(unmap->handle, urid)); object = serd_node_from_string(SERD_URI, str); } else if (type_urid == sratom->forge.Path) { const uint8_t* str = USTR(body); if (path_is_absolute((const char*)str)) { new_node = true; object = serd_node_new_file_uri(str, NULL, NULL, true); } else { SerdURI base_uri = SERD_URI_NULL; if (!sratom->base_uri.buf || strncmp((const char*)sratom->base_uri.buf, "file://", 7)) { fprintf(stderr, "warning: Relative path but base is not a file URI.\n"); fprintf(stderr, "warning: Writing ambiguous atom:Path literal.\n"); object = serd_node_from_string(SERD_LITERAL, str); datatype = serd_node_from_string(SERD_URI, USTR(LV2_ATOM__Path)); } else { if (sratom->base_uri.buf) { serd_uri_parse(sratom->base_uri.buf, &base_uri); } new_node = true; SerdNode rel = serd_node_new_file_uri(str, NULL, NULL, true); object = serd_node_new_uri_from_node(&rel, &base_uri, NULL); serd_node_free(&rel); } } } else if (type_urid == sratom->forge.URI) { const uint8_t* str = USTR(body); object = serd_node_from_string(SERD_URI, str); } else if (type_urid == sratom->forge.Int) { new_node = true; object = serd_node_new_integer(*(const int32_t*)body); datatype = serd_node_from_string(SERD_URI, (sratom->pretty_numbers) ? NS_XSD "integer" : NS_XSD "int"); } else if (type_urid == sratom->forge.Long) { new_node = true; object = serd_node_new_integer(*(const int64_t*)body); datatype = serd_node_from_string(SERD_URI, (sratom->pretty_numbers) ? NS_XSD "integer" : NS_XSD "long"); } else if (type_urid == sratom->forge.Float) { new_node = true; object = serd_node_new_decimal(*(const float*)body, 8); datatype = serd_node_from_string(SERD_URI, (sratom->pretty_numbers) ? NS_XSD "decimal" : NS_XSD "float"); } else if (type_urid == sratom->forge.Double) { new_node = true; object = serd_node_new_decimal(*(const double*)body, 16); datatype = serd_node_from_string(SERD_URI, (sratom->pretty_numbers) ? NS_XSD "decimal" : NS_XSD "double"); } else if (type_urid == sratom->forge.Bool) { const int32_t val = *(const int32_t*)body; datatype = serd_node_from_string(SERD_URI, NS_XSD "boolean"); object = serd_node_from_string(SERD_LITERAL, USTR(val ? "true" : "false")); } else if (type_urid == sratom->midi_MidiEvent) { new_node = true; datatype = serd_node_from_string(SERD_URI, USTR(LV2_MIDI__MidiEvent)); uint8_t* str = (uint8_t*)calloc(size * 2 + 1, 1); for (uint32_t i = 0; i < size; ++i) { snprintf((char*)str + (2 * i), size * 2 + 1, "%02X", (unsigned)(uint8_t)*((const uint8_t*)body + i)); } object = serd_node_from_string(SERD_LITERAL, USTR(str)); } else if (type_urid == sratom->atom_Event) { const LV2_Atom_Event* ev = (const LV2_Atom_Event*)body; gensym(&id, 'e', sratom->next_id++); start_object(sratom, &flags, subject, predicate, &id, NULL); // TODO: beat time SerdNode time = serd_node_new_integer(ev->time.frames); SerdNode p = serd_node_from_string(SERD_URI, USTR(LV2_ATOM__frameTime)); datatype = serd_node_from_string(SERD_URI, NS_XSD "decimal"); sratom->write_statement(sratom->handle, SERD_ANON_CONT, NULL, &id, &p, &time, &datatype, &language); serd_node_free(&time); p = serd_node_from_string(SERD_URI, NS_RDF "value"); sratom_write(sratom, unmap, SERD_ANON_CONT, &id, &p, ev->body.type, ev->body.size, LV2_ATOM_BODY(&ev->body)); if (sratom->end_anon) { sratom->end_anon(sratom->handle, &id); } } else if (type_urid == sratom->forge.Tuple) { gensym(&id, 't', sratom->next_id++); start_object(sratom, &flags, subject, predicate, &id, type); SerdNode p = serd_node_from_string(SERD_URI, NS_RDF "value"); flags |= SERD_LIST_O_BEGIN; LV2_ATOM_TUPLE_BODY_FOREACH(body, size, i) { list_append(sratom, unmap, &flags, &id, &p, &node, i->size, i->type, LV2_ATOM_BODY(i)); }