/* this routine is called when a new "object" is requested whose class Pd doesn't know. Pd tries to load it as an extern, then as an abstraction. */ void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv) { t_pd *current; int fd; char dirbuf[MAXPDSTRING], *nameptr; if (tryingalready) return; newest = 0; class_loadsym = s; if (sys_load_lib(canvas_getcurrent(), s->s_name)) { tryingalready = 1; typedmess(dummy, s, argc, argv); tryingalready = 0; return; } class_loadsym = 0; current = s__X.s_thing; if ((fd = canvas_open(canvas_getcurrent(), s->s_name, ".pd", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 || (fd = canvas_open(canvas_getcurrent(), s->s_name, ".pat", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0) { close (fd); if (!pd_setloadingabstraction(s)) { canvas_setargs(argc, argv); binbuf_evalfile(gensym(nameptr), gensym(dirbuf)); if (s__X.s_thing != current) canvas_popabstraction((t_canvas *)(s__X.s_thing)); canvas_setargs(0, 0); } else error("%s: can't load abstraction within itself\n", s->s_name); } else newest = 0; }
void *plustot_var_new(t_symbol *s, int ac, t_atom *av) { t_plustot_var *x = 0; t_glist *glist = canvas_getcurrent(); t_plustin *tin = 0; t_plusvar *var = 0; if (ac && av->a_type == A_SYMBOL && (tin = plustin_glistprovide(glist, PLUSTIN_GLIST_ANY, 0)) && (var = plusvar_new(av->a_w.w_symbol->s_name, 0, tin))) { x = (t_plustot_var *)plusobject_new(plustot_var_class, s, ac, av, 0); plusbob_preserve((t_plusbob *)var); plusbob_setowner((t_plusbob *)var, (t_pd *)x); plusvar_setlist(var, ac - 1, av + 1, 1); x->x_glist = glist; x->x_var = var; x->x_proxy = plusproxy_var_new((t_pd *)x); plusinlet_new(&x->x_plusobject, (t_pd *)x->x_proxy, 0, 0); plusoutlet_new(&x->x_plusobject, &s_symbol); } else { if (!ac || av->a_type != A_SYMBOL) loud_error(0, "+var: missing name of a variable"); else loud_error(0, "+var: cannot initialize"); if (tin) { plusbob_preserve((t_plusbob *)tin); plusbob_release((t_plusbob *)tin); } } return (x); }
/* this routine is called when a new "object" is requested whose class Pd doesn't know. Pd tries to load it as an extern, then as an abstraction. */ void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv) { int fd; char dirbuf[MAXPDSTRING], classslashclass[MAXPDSTRING], *nameptr; if (tryingalready>MAXOBJDEPTH){ error("maximum object loading depth %d reached", MAXOBJDEPTH); return; } if (s == &s_anything){ error("object name \"%s\" not allowed", s->s_name); return; } pd_this->pd_newest = 0; class_loadsym = s; pd_globallock(); if (sys_load_lib(canvas_getcurrent(), s->s_name)) { tryingalready++; typedmess(dummy, s, argc, argv); tryingalready--; return; } class_loadsym = 0; pd_globalunlock(); }
void *hoa_canvas_new(t_symbol *s, long argc, t_atom *argv) { t_atom av[3]; atom_setfloat(av, 0); t_hoa_canvas *x = (t_hoa_canvas *)pd_new(hoa_canvas_class); t_canvas* owner = canvas_getcurrent(); x->x_canvas = canvas_new(0, 0, 0, NULL); canvas_vis(x->x_canvas, 0); pd_typedmess((t_pd *)x->x_canvas, gensym("pop"), 1, av); canvas_setcurrent(owner); if(argc && atom_gettype(argv) == A_SYM) { atom_setfloat(av, 0); atom_setfloat(av+1, 20); atom_setsym(av+2, atom_getsym(argv)); pd_typedmess((t_pd *)x->x_canvas, gensym("obj"), 3, av); } canvas_loadbang(x->x_canvas); canvas_vis(x->x_canvas, 1); outlet_new((t_object *)x, &s_signal); return (x); }
static void *sfread_new(t_floatarg chan,t_floatarg skip) { #ifdef ROCKBOX (void) skip; #endif t_sfread *x = (t_sfread *)pd_new(sfread_class); t_int c = chan; x->x_glist = (t_glist*) canvas_getcurrent(); if (c<1 || c > MAX_CHANS) c = 1; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2")); x->x_fd = -1; x->x_mapaddr = NULL; x->x_size = 0; x->x_loop = 0; x->x_channels = c; x->x_mapaddr=NULL; x->x_pos = 0; x->x_skip = 0; x->x_speed = ftofix(1.0); x->x_play = 0; while (c--) { outlet_new(&x->x_obj, gensym("signal")); } x->x_bangout = outlet_new(&x->x_obj, &s_float); return (x); }
void *plustot_qlist_new(t_symbol *s, int ac, t_atom *av) { t_plustot_qlist *x = 0; t_glist *glist = canvas_getcurrent(); t_plustin *tin = 0; t_plustob *tob = 0; if ((tin = plustin_glistprovide(glist, PLUSTIN_GLIST_ANY, 0)) && (tob = plustob_new(tin, 0))) { x = (t_plustot_qlist *) plusobject_new(plustot_qlist_class, s, ac, av, 0); plusbob_preserve((t_plusbob *)tob); plusbob_setowner((t_plusbob *)tob, (t_pd *)x); plustob_setlist(tob, ac, av); x->x_glist = glist; x->x_tob = tob; x->x_proxy = plusproxy_qlist_new(x); plusinlet_new(&x->x_plusobject, (t_pd *)x->x_proxy, 0, 0); plusoutlet_new(&x->x_plusobject, &s_anything); x->x_rightout = outlet_new((t_object *)x, &s_symbol); } else { loud_error(0, "+qlist: cannot initialize"); if (tin) { plusbob_preserve((t_plusbob *)tin); plusbob_release((t_plusbob *)tin); } } return (x); }
static void *matrix_new(t_symbol *s, int argc, t_atom *argv) { t_matrix *x = (t_matrix *)pd_new(matrix_class); int row, col; inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("matrix"), gensym("")); outlet_new(&x->x_obj, 0); x->atombuffer = 0; x->x_canvas = canvas_getcurrent(); switch (argc) { case 0: row = col = 0; break; case 1: if (argv->a_type == A_SYMBOL) { matrix_read(x, argv->a_w.w_symbol); return(x); } row = col = atom_getfloat(argv); break; default: row = atom_getfloat(argv++); col = atom_getfloat(argv++); } if(row*col) { adjustsize(x, row, col); matrix_set(x, 0); } return (x); }
static void xeq_newbase(t_xeq *x, t_binbuf *bb, t_method tickmethod) { xeq_window_bind(x); x->x_tempo = 1; x->x_canvas = canvas_getcurrent(); x->x_whenclockset = 0; x->x_clockdelay = 0; x->x_clock = tickmethod ? clock_new(x, tickmethod) : 0; xeq_noteons_clear(x); x->x_ttp = 0; x->x_transpo = 0; x->x_autoit.i_owner = x; x->x_stepit.i_owner = x; x->x_walkit.i_owner = x; xeq_setbinbuf(x, bb); xeqit_sethooks(&x->x_autoit, xeqithook_autodelay, xeqithook_applypp, xeqithook_playmessage, xeqithook_playfinish, xeqithook_loopover); xeqit_sethooks(&x->x_stepit, xeqithook_stepdelay, xeqithook_applypp, xeqithook_playmessage, xeqithook_stepfinish, 0); xeqit_sethooks(&x->x_walkit, 0, 0, 0, 0, 0); xeqit_rewind(&x->x_autoit); xeqit_rewind(&x->x_stepit); xeqit_rewind(&x->x_walkit); }
bool flext_obj::GetParamSym(t_atom &dst,const t_symbol *sym,t_canvas *c) { #if FLEXT_SYS == FLEXT_SYS_PD && defined(PD_MINOR_VERSION) && PD_MINOR_VERSION >= 37 if(!c) c = canvas_getcurrent(); const char *s = GetString(sym); if((s[0] == '$' || s[0] == '#') && isdigit(s[1])) { const t_symbol *res; // patcher parameter detected... get value! if(s[0] != '$') { char tmp[MAXPDSTRING]; strcpy(tmp,s); tmp[0] = '$'; res = canvas_realizedollar(c,const_cast<t_symbol *>(MakeSymbol(tmp))); } else res = canvas_realizedollar(c,const_cast<t_symbol *>(sym)); // check for number const char *c = GetString(res); while(*c && (isdigit(*c) || *c == '.')) ++c; if(!*c) SetFloat(dst,(float)atof(GetString(res))); else SetSymbol(dst,res); return true; } else #else #pragma message("Not implemented") #endif SetSymbol(dst,sym); return true; }
static void *hfadl_scale_new(t_symbol *s, int argc, t_atom *argv) { t_hfadl_scale *x = (t_hfadl_scale *)pd_new(hfadl_scale_class); if((argc >= 1)&&IS_A_FLOAT(argv,0)) { int j, i = (int)atom_getintarg(0, argc, argv); if(i >= 0) { j = iemgui_modulo_color(i); x->x_gui.x_lcol = my_iemgui_color_hex[j]; } else { j = -1 - i; x->x_gui.x_lcol = ((j & 0x3f000) << 6)|((j & 0xfc0) << 4)|((j & 0x3f) << 2); } } else x->x_gui.x_lcol = 0; x->x_gui.x_draw = (t_iemfunptr)hfadl_scale_draw; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); x->x_gui.x_w = 126; x->x_gui.x_h = 21; strcpy(x->x_gif, my_iemgui_black_hlscale_gif); my_iemgui_change_scale_col(x->x_gif, x->x_gui.x_lcol); x->x_gui.x_fsf.x_selected = 0; return(x); }
static void *scalar_define_new(t_symbol *s, int argc, t_atom *argv) { t_atom a[9]; t_glist *gl; t_canvas *x, *z = canvas_getcurrent(); t_symbol *templatesym = &s_float, *asym = gensym("#A"); t_template *template;
static void *voutlet_newsig(t_symbol *s) { t_voutlet *x = (t_voutlet *)pd_new(voutlet_class); x->x_canvas = canvas_getcurrent(); x->x_parentoutlet = canvas_addoutlet(x->x_canvas, &x->x_obj.ob_pd, &s_signal); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); x->x_endbuf = x->x_buf = (t_sample *)getbytes(0); x->x_bufsize = 0; resample_init(&x->x_updown); /* this should be though over: * it might prove hard to provide consistency between labeled up- & downsampling methods * maybe indeces would be better... * * up till now we provide several upsampling methods and 1 single downsampling method (no filtering !) */ if (s == gensym("hold"))x->x_updown.method=1; /* up: sample and hold */ else if (s == gensym("lin"))x->x_updown.method=2; /* up: linear interpolation */ else if (s == gensym("linear"))x->x_updown.method=2; /* up: linear interpolation */ else if (s == gensym("pad"))x->x_updown.method=0; /* up: zero pad */ else x->x_updown.method=3; /* up: zero-padding; down: ignore samples inbetween */ return (x); }
static void *capture_new(t_symbol *s, t_floatarg f) { t_capture *x = 0; float *buffer; int bufsize = (int)f; /* CHECKME */ if (bufsize <= 0) /* CHECKME */ bufsize = CAPTURE_DEFSIZE; if (buffer = getbytes(bufsize * sizeof(*buffer))) { x = (t_capture *)pd_new(capture_class); x->x_canvas = canvas_getcurrent(); if (s && s != &s_) { if (s == gensym("x")) x->x_intmode = 'x'; else if (s == gensym("m")) x->x_intmode = 'm'; else x->x_intmode = 'd'; /* ignore floats */ } x->x_buffer = buffer; x->x_bufsize = bufsize; outlet_new((t_object *)x, &s_float); x->x_filehandle = hammerfile_new((t_pd *)x, 0, 0, capture_writehook, 0); capture_clear(x); } return (x); }
static void *iem_send_kernel_new(void) { t_iem_send_kernel *x = (t_iem_send_kernel *)pd_new(iem_send_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); if(ac > 0) { if(IS_A_SYMBOL(av,0)) { x->x_sym = atom_getsymbol(av); } else if(IS_A_FLOAT(av,0)) { char str[100]; sprintf(str, "%g", atom_getfloat(av)); x->x_sym = gensym(str); } else x->x_sym = 0; } else x->x_sym = 0; return (x); }
static void *h_deque_new(t_symbol *s, int argc, t_atom *argv) { t_h_deque *x = (t_h_deque *)pd_new(h_deque_class); t_proxy *inlet = (t_proxy *)pd_new(proxy_class); // for the proxy inlet inlet->x = x; // make x visible to the proxy inlets switch(argc) { default: post("h_deque warning: only one argument for namespace is possible!"); case 1: x->hdeque = new HDeque(atom_getsymbol(argv)->s_name); break; case 0: x->hdeque = new HDeque(); break; } // we are going to create a proxy inlet no. 0 // it belongs to the object x but the destination is t_proxy inlet->index = 0; inlet_new(&x->x_obj, &inlet->obj.ob_pd, 0,0); x->out0 = outlet_new(&x->x_obj, 0); x->out1 = outlet_new(&x->x_obj, &s_float); x->out2 = outlet_new(&x->x_obj, &s_bang); x->x_canvas = canvas_getcurrent(); return (void *)x; }
static void *namecanvas_new(t_symbol *s) { t_namecanvas *x = (t_namecanvas *)pd_new(namecanvas_class); x->x_owner = (t_pd *)canvas_getcurrent(); x->x_sym = s; if (*s->s_name) pd_bind(x->x_owner, s); return (x); }
static void *lsend_new(t_symbol *s) { t_lsend *x = (t_lsend *)pd_new(lsend_class); char mysym[MAXPDSTRING]; sprintf(mysym,"%s%p",s->s_name,canvas_getcurrent()); x->x_sym = gensym(mysym); return (x); }
static void *vinlet_new(t_symbol *s) { t_vinlet *x = (t_vinlet *)pd_new(vinlet_class); x->x_canvas = canvas_getcurrent(); x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, 0); x->x_bufsize = 0; x->x_buf = 0; outlet_new(&x->x_obj, 0); return (x); }
static void *soundfile_info_new(void) { t_soundfile_info *x = (t_soundfile_info *)pd_new(soundfile_info_class); x->x_size = 10000; x->x_begmem = (long *)getbytes(x->x_size * sizeof(long)); x->x_list_out = outlet_new(&x->x_obj, &s_list); x->x_canvas = canvas_getcurrent(); return (x); }
/* this routine is called when a new "object" is requested whose class Pd doesn't know. Pd tries to load it as an extern, then as an abstraction. */ void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv) { t_pd *current; int fd; char dirbuf[MAXPDSTRING], classslashclass[MAXPDSTRING], *nameptr; if (tryingalready>MAXOBJDEPTH){ error("maximum object loading depth %d reached", MAXOBJDEPTH); return; } newest = 0; class_loadsym = s; if (sys_load_lib(canvas_getcurrent(), s->s_name)) { tryingalready++; typedmess(dummy, s, argc, argv); tryingalready--; return; } class_loadsym = 0; current = s__X.s_thing; /* for class/class.pd support, to match class/class.pd_linux */ snprintf(classslashclass, MAXPDSTRING, "%s/%s", s->s_name, s->s_name); if ((fd = canvas_open(canvas_getcurrent(), s->s_name, ".pd", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 || (fd = canvas_open(canvas_getcurrent(), s->s_name, ".pat", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 || (fd = canvas_open(canvas_getcurrent(), classslashclass, ".pd", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0) { close (fd); if (!pd_setloadingabstraction(s)) { canvas_setargs(argc, argv); binbuf_evalfile(gensym(nameptr), gensym(dirbuf)); canvas_initbang((t_canvas *)(s__X.s_thing));/* JMZ*/ if (s__X.s_thing != current) canvas_popabstraction((t_canvas *)(s__X.s_thing)); canvas_setargs(0, 0); } else error("%s: can't load abstraction within itself\n", s->s_name); } else newest = 0; }
static void *bitand_new(t_floatarg f1, t_floatarg f2) { t_bitand *x = (t_bitand *)pd_new(bitand_class); x->x_glist = canvas_getcurrent(); x->x_rightinlet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); outlet_new((t_object *)x, &s_signal); x->x_signalscalar = obj_findsignalscalar(x, 1); bitand_intmask(x, f1); bitand_mode(x, f2); return (x); }
static void *freadln_new(void) { t_freadln *x = (t_freadln *)pd_new(freadln_class); x->x_message_outlet = outlet_new(&x->x_ob, &s_list); x->x_readybang_outlet = outlet_new(&x->x_ob, &s_bang); x->x_filename=0; x->x_file=0; x->x_textbuf=0; x->x_canvas = canvas_getcurrent(); return (void *)x; }
static void *savepanel_new( void) { char buf[50]; t_savepanel *x = (t_savepanel *)pd_new(savepanel_class); sprintf(buf, "d%lx", (t_int)x); x->x_s = gensym(buf); x->x_canvas = canvas_getcurrent(); pd_bind(&x->x_obj.ob_pd, x->x_s); outlet_new(&x->x_obj, &s_symbol); return (x); }
static void *active_new(void) { t_active *x = (t_active *)pd_new(active_class); char buf[32]; sprintf(buf, ".x%x.c", (int)canvas_getcurrent()); x->x_cvname = gensym(buf); x->x_on = 0; outlet_new((t_object *)x, &s_float); hammergui_bindfocus((t_pd *)x); return (x); }
static void *lreceive_new(t_symbol *s) { t_lreceive *x = (t_lreceive *)pd_new(lreceive_class); char mysym[MAXPDSTRING]; sprintf(mysym,"%s%p",s->s_name,canvas_getcurrent()); x->x_sym = gensym(mysym); pd_bind(&x->x_obj.ob_pd, x->x_sym); outlet_new(&x->x_obj, 0); return (x); }
static void *patcherinfos_new(t_symbol *s, int argc, t_atom *argv) { t_patcherinfos *x = (t_patcherinfos *)eobj_new(patcherinfos_class); if(x) { if(canvas_getcurrent()) { x->f_canvas = glist_getcanvas(canvas_getcurrent()); } else { x->f_canvas = NULL; } x->f_out_name = outlet_new((t_object *)x, &s_symbol); x->f_out_path = outlet_new((t_object *)x, &s_symbol); x->f_out_coords = outlet_new((t_object *)x, &s_list); x->f_time = clock_getsystime(); } return x; }
///////////////////////////////////////////////////////// // Constructor // ///////////////////////////////////////////////////////// flext_obj :: FLEXT_CLASSDEF(flext_obj)() : x_obj(m_holder) , clss(m_holdclass) , m_name(m_holdname) { #if FLEXT_SYS == FLEXT_SYS_PD m_canvas = canvas_getcurrent(); #elif FLEXT_SYS == FLEXT_SYS_MAX m_canvas = (t_patcher *)sym__shP->s_thing; x_obj->curinlet = 0; #endif }
static void *plusequals_new(t_floatarg f) { t_plusequals *x = (t_plusequals *)pd_new(plusequals_class); x->x_sum = f; x->x_glist = canvas_getcurrent(); x->x_triglet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); outlet_new((t_object *)x, &s_signal); // MAGIC x->x_signalscalar = obj_findsignalscalar((t_object *)x, 1); return (x); }
static void *iem_event_new(t_symbol *s, int argc, t_atom *argv) { t_iem_event *x = (t_iem_event *)pd_new(iem_event_class); t_int w=32, h=32; 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 >= 6)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1) &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3) &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4)) &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))) { w = (int)atom_getintarg(0, argc, argv); h = (int)atom_getintarg(1, argc, argv); iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv)); iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(3, argc, argv)); iemgui_new_getnames(&x->x_gui, 4, argv); } else if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)) { w = (int)atom_getintarg(0, argc, argv); h = (int)atom_getintarg(1, argc, argv); } x->x_gui.x_draw = (t_iemfunptr)iem_event_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); if(w < 4) w = 4; x->x_gui.x_w = w; if(h < 4) h = 4; x->x_gui.x_h = h; iemgui_verify_snd_ne_rcv(&x->x_gui); outlet_new(&x->x_gui.x_obj, &s_list); x->x_mouse_shft_alt = gensym("mouse_shft_alt"); x->x_dragg_x_y = gensym("dragg_x_y"); x->x_key = gensym("key"); x->x_move_x_y = gensym("move_x_y"); x->x_x = 0; x->x_y = 0; x->x_doit = 0; return (x); }
///////////////////////////////////////////////////////// // // CPPExtern // ///////////////////////////////////////////////////////// // Constructor // ///////////////////////////////////////////////////////// CPPExtern :: CPPExtern() : x_obj(m_holder), m_objectname(NULL), m_canvas(NULL), m_endpost(true) { m_canvas = canvas_getcurrent(); if(m_holdname) { m_objectname=gensym(m_holdname); } else { m_objectname=gensym("unknown Gem object"); } }