From c2645dc4003b1391aba9b387a79a66cff1e63d3e Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 22 Oct 2002 23:16:30 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r189, which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=190 --- externals/grill/guitest/flgui.cpp | 646 +++++++++++++++ externals/grill/guitest/flgui.h | 232 ++++++ externals/grill/guitest/flguiobj.cpp | 801 +++++++++++++++++++ externals/grill/guitest/flguiobj.h | 362 +++++++++ externals/grill/guitest/guitest.dsp | 112 +++ externals/grill/guitest/main.cpp | 152 ++++ externals/grill/pool/main.cpp | 905 ++++++++++++++++++++++ externals/grill/pool/pool.cpp | 645 +++++++++++++++ externals/grill/pool/pool.cw | Bin 0 -> 58761 bytes externals/grill/pool/pool.dsp | 103 +++ externals/grill/pool/pool.h | 124 +++ externals/grill/pool/pool.help | Bin 0 -> 5345 bytes externals/grill/pool/pool.pd | 201 +++++ externals/grill/py/build-pd-bcc.bat | 3 + externals/grill/py/build-pd-cygwin.sh | 10 + externals/grill/py/build-pd-linux.sh | 11 + externals/grill/py/build-pd-msvc.bat | 4 + externals/grill/py/config-pd-bcc.txt | 31 + externals/grill/py/config-pd-cygwin.txt | 29 + externals/grill/py/config-pd-linux.txt | 33 + externals/grill/py/config-pd-msvc.txt | 30 + externals/grill/py/gpl.txt | 346 +++++++++ externals/grill/py/license.txt | 50 ++ externals/grill/py/makefile.pd-bcc | 82 ++ externals/grill/py/makefile.pd-linux | 75 ++ externals/grill/py/pd/script-1.pd | 50 ++ externals/grill/py/pd/sendrecv-1.pd | 25 + externals/grill/py/pd/sendrecv-2.pd | 8 + externals/grill/py/pd/sendrecv-3.pd | 5 + externals/grill/py/pd/simple-1.pd | 41 + externals/grill/py/pd/simple-2.pd | 37 + externals/grill/py/pd/simple-3.pd | 27 + externals/grill/py/pd/tcltk.pd | 18 + externals/grill/py/pd/thread-1.pd | 47 ++ externals/grill/py/py.cw | Bin 0 -> 88197 bytes externals/grill/py/py.dsp | 229 ++++++ externals/grill/py/py.mpw | 91 +++ externals/grill/py/readme.txt | 106 +++ externals/grill/py/scripts/script.py | 53 ++ externals/grill/py/scripts/sendrecv.py | 173 +++++ externals/grill/py/scripts/simple.py | 206 +++++ externals/grill/py/scripts/tcltk.py | 77 ++ externals/grill/py/scripts/threads.py | 43 + externals/grill/py/source/bound.cpp | 143 ++++ externals/grill/py/source/clmeth.cpp | 278 +++++++ externals/grill/py/source/main.cpp | 212 +++++ externals/grill/py/source/main.h | 147 ++++ externals/grill/py/source/modmeth.cpp | 183 +++++ externals/grill/py/source/py.cpp | 327 ++++++++ externals/grill/py/source/pyargs.cpp | 131 ++++ externals/grill/py/source/pyext.cpp | 465 +++++++++++ externals/grill/py/source/pyext.h | 127 +++ externals/grill/py/source/register.cpp | 86 ++ externals/grill/xsample/MPW/MakeAliases | 1 + externals/grill/xsample/gpl.txt | 346 +++++++++ externals/grill/xsample/license.txt | 84 ++ externals/grill/xsample/maxmsp/xgroove~.help | Bin 0 -> 7310 bytes externals/grill/xsample/maxmsp/xplay~.help | Bin 0 -> 6069 bytes externals/grill/xsample/maxmsp/xrecord~.help | Bin 0 -> 9541 bytes externals/grill/xsample/pd/xgroove~.help.pd | 166 ++++ externals/grill/xsample/pd/xplay~.help.pd | 57 ++ externals/grill/xsample/pd/xrecord~.help.pd | 136 ++++ externals/grill/xsample/readme.txt | 142 ++++ externals/grill/xsample/source/groove.cpp | 709 +++++++++++++++++ externals/grill/xsample/source/inter.ci | 355 +++++++++ externals/grill/xsample/source/inter.cpp | 95 +++ externals/grill/xsample/source/main.cpp | 203 +++++ externals/grill/xsample/source/main.h | 277 +++++++ externals/grill/xsample/source/makefile.bcc | 74 ++ externals/grill/xsample/source/makefile.pd-cygwin | 89 +++ externals/grill/xsample/source/makefile.pd-linux | 89 +++ externals/grill/xsample/source/play.cpp | 160 ++++ externals/grill/xsample/source/record.cpp | 506 ++++++++++++ externals/grill/xsample/source/xsample.cw | Bin 0 -> 105160 bytes externals/grill/xsample/source/xsample.dsp | 127 +++ externals/grill/xsample/source/xsample.mpw | 129 +++ 76 files changed, 12067 insertions(+) create mode 100644 externals/grill/guitest/flgui.cpp create mode 100644 externals/grill/guitest/flgui.h create mode 100644 externals/grill/guitest/flguiobj.cpp create mode 100644 externals/grill/guitest/flguiobj.h create mode 100644 externals/grill/guitest/guitest.dsp create mode 100644 externals/grill/guitest/main.cpp create mode 100644 externals/grill/pool/main.cpp create mode 100644 externals/grill/pool/pool.cpp create mode 100755 externals/grill/pool/pool.cw create mode 100644 externals/grill/pool/pool.dsp create mode 100644 externals/grill/pool/pool.h create mode 100755 externals/grill/pool/pool.help create mode 100644 externals/grill/pool/pool.pd create mode 100644 externals/grill/py/build-pd-bcc.bat create mode 100644 externals/grill/py/build-pd-cygwin.sh create mode 100755 externals/grill/py/build-pd-linux.sh create mode 100644 externals/grill/py/build-pd-msvc.bat create mode 100644 externals/grill/py/config-pd-bcc.txt create mode 100644 externals/grill/py/config-pd-cygwin.txt create mode 100644 externals/grill/py/config-pd-linux.txt create mode 100644 externals/grill/py/config-pd-msvc.txt create mode 100644 externals/grill/py/gpl.txt create mode 100644 externals/grill/py/license.txt create mode 100644 externals/grill/py/makefile.pd-bcc create mode 100644 externals/grill/py/makefile.pd-linux create mode 100644 externals/grill/py/pd/script-1.pd create mode 100644 externals/grill/py/pd/sendrecv-1.pd create mode 100644 externals/grill/py/pd/sendrecv-2.pd create mode 100644 externals/grill/py/pd/sendrecv-3.pd create mode 100644 externals/grill/py/pd/simple-1.pd create mode 100644 externals/grill/py/pd/simple-2.pd create mode 100644 externals/grill/py/pd/simple-3.pd create mode 100644 externals/grill/py/pd/tcltk.pd create mode 100644 externals/grill/py/pd/thread-1.pd create mode 100644 externals/grill/py/py.cw create mode 100644 externals/grill/py/py.dsp create mode 100644 externals/grill/py/py.mpw create mode 100644 externals/grill/py/readme.txt create mode 100644 externals/grill/py/scripts/script.py create mode 100644 externals/grill/py/scripts/sendrecv.py create mode 100644 externals/grill/py/scripts/simple.py create mode 100644 externals/grill/py/scripts/tcltk.py create mode 100644 externals/grill/py/scripts/threads.py create mode 100644 externals/grill/py/source/bound.cpp create mode 100644 externals/grill/py/source/clmeth.cpp create mode 100644 externals/grill/py/source/main.cpp create mode 100644 externals/grill/py/source/main.h create mode 100644 externals/grill/py/source/modmeth.cpp create mode 100644 externals/grill/py/source/py.cpp create mode 100644 externals/grill/py/source/pyargs.cpp create mode 100644 externals/grill/py/source/pyext.cpp create mode 100644 externals/grill/py/source/pyext.h create mode 100644 externals/grill/py/source/register.cpp create mode 100755 externals/grill/xsample/MPW/MakeAliases create mode 100644 externals/grill/xsample/gpl.txt create mode 100644 externals/grill/xsample/license.txt create mode 100644 externals/grill/xsample/maxmsp/xgroove~.help create mode 100644 externals/grill/xsample/maxmsp/xplay~.help create mode 100644 externals/grill/xsample/maxmsp/xrecord~.help create mode 100644 externals/grill/xsample/pd/xgroove~.help.pd create mode 100644 externals/grill/xsample/pd/xplay~.help.pd create mode 100644 externals/grill/xsample/pd/xrecord~.help.pd create mode 100644 externals/grill/xsample/readme.txt create mode 100644 externals/grill/xsample/source/groove.cpp create mode 100644 externals/grill/xsample/source/inter.ci create mode 100644 externals/grill/xsample/source/inter.cpp create mode 100644 externals/grill/xsample/source/main.cpp create mode 100644 externals/grill/xsample/source/main.h create mode 100644 externals/grill/xsample/source/makefile.bcc create mode 100644 externals/grill/xsample/source/makefile.pd-cygwin create mode 100644 externals/grill/xsample/source/makefile.pd-linux create mode 100644 externals/grill/xsample/source/play.cpp create mode 100644 externals/grill/xsample/source/record.cpp create mode 100644 externals/grill/xsample/source/xsample.cw create mode 100644 externals/grill/xsample/source/xsample.dsp create mode 100644 externals/grill/xsample/source/xsample.mpw (limited to 'externals/grill') diff --git a/externals/grill/guitest/flgui.cpp b/externals/grill/guitest/flgui.cpp new file mode 100644 index 00000000..86d8e4ea --- /dev/null +++ b/externals/grill/guitest/flgui.cpp @@ -0,0 +1,646 @@ +#include "flgui.h" +#include "flguiobj.h" +#include "flinternal.h" + +#include +#include +#include + + +#ifdef PD +t_class *flext_gui::px_class = NULL; +t_class *flext_gui::pxkey_class = NULL; + +struct flext_gui::px_object // no virtual table! +{ + t_object obj; // MUST reside at memory offset 0 + t_canvas *canv; + + void init(t_canvas *c) { canv = c; } +}; + +struct flext_gui::pxkey_object // no virtual table! +{ + t_object obj; // MUST reside at memory offset 0 + flext_gui *th; + + void init(flext_gui *t) { th = t; } +}; +#endif + + +flext_gui::flext_gui(int xs,int ys): + objs(NULL), +#ifdef PD + xsize(xs),ysize(ys), +#endif +#ifdef MAXMSP + curx(-1),cury(-1),curmod(-1), + created(false), +#endif + bindsym(NULL) +{ + canvas = new Canvas(thisCanvas()); + objs = new GuiGroup(canvas); + +#ifdef PD + AddCanvas(); +#else + t_box *b = (t_box *)gensym("#B")->s_thing; + + int x = b->b_rect.left,y = b->b_rect.top; + t_pxbox *p = thisHdr(); + box_new(&p->z_box, thisCanvas(), F_DRAWFIRSTIN | F_GROWBOTH | F_SAVVY,x,y,x+xs,y+ys); + p->z_box.b_firstin = (void *)p; /* it's not really an inlet */ + box_ready(&p->z_box); +#endif +} + +flext_gui::~flext_gui() +{ +#ifdef PD + RmvCanvas(); +#endif + + delete objs; + delete canvas; +} + + +void flext_gui::setup(t_class *c) +{ +#ifdef PD + SetWidget(c); + + pxkey_class = class_new(gensym("flext_gui key proxy"),NULL,NULL,sizeof(pxkey_object),CLASS_PD|CLASS_NOINLET, A_NULL); + add_anything(pxkey_class,pxkey_method); + pxkey = (pxkey_object *)pd_new(pxkey_class); + + pd_bind(&pxkey_class,gensym("#keyname")); +// pd_bind(&pxkey_class,gensym("#key")); +// pd_bind(&pxkey_class,gensym("#keyup")); + + gcanv = NULL; + +#ifdef DIRECT_TK + px_class = class_new(gensym("flext_gui proxy"),NULL,NULL,sizeof(px_object),CLASS_PD|CLASS_NOINLET, A_NULL); + add_anything(px_class,px_method); + + gcm_motion = MakeSymbol("_tk_motion"); + gcm_mousekey = MakeSymbol("_tk_mousekey"); + gcm_mousewheel = MakeSymbol("_tk_mousewheel"); + gcm_key = MakeSymbol("_tk_key"); + gcm_destroy = MakeSymbol("_tk_destroy"); +#endif + + // this is wrong if a modifier key is pressed during creation of the first object..... + curmod = 0; +#else + addmess((method)sg_update, "update", A_CANT, A_NULL); + addmess((method)sg_click, "click", A_CANT, A_NULL); + addmess((method)sg_psave, "psave", A_CANT, A_NULL); + addmess((method)sg_bfont, "bfont", A_CANT, A_NULL); + addmess((method)sg_key, "key", A_CANT, A_NULL); + addmess((method)sg_bidle, "bidle", A_CANT, A_NULL); +#endif +} + +#ifdef PD + +int flext_gui::evmask = evMotion|evMouseDown|evKeyDown|evKeyUp; +int flext_gui::curmod = 0; +flext_gui::pxkey_object *flext_gui::pxkey = NULL; +flext_gui::guicanv *flext_gui::gcanv = NULL; + +#ifdef DIRECT_TK +const t_symbol *flext_gui::gcm_motion = NULL; +const t_symbol *flext_gui::gcm_mousekey = NULL; +const t_symbol *flext_gui::gcm_mousewheel = NULL; +const t_symbol *flext_gui::gcm_key = NULL; +const t_symbol *flext_gui::gcm_destroy = NULL; + +void flext_gui::px_method(px_object *obj,const t_symbol *s,int argc,t_atom *argv) +{ + guicanv *ix = gcanv; + for(; ix && ix->canv != obj->canv; ix = ix->nxt); + + if(ix) { + CBParams parms; + + if(s == gcm_motion) { + parms.kind = evMotion; + parms.pMotion.x = GetAInt(argv[0]); + parms.pMotion.y = GetAInt(argv[1]); + parms.pMotion.mod = GetAInt(argv[2]); + } + else if(s == gcm_mousekey) { + parms.kind = GetAInt(argv[0])?evMouseDown:evMouseUp; + parms.pMouseKey.x = GetAInt(argv[1]); + parms.pMouseKey.y = GetAInt(argv[2]); + parms.pMouseKey.b = GetAInt(argv[3]); + parms.pMouseKey.mod = GetAInt(argv[4]); + } + else if(s == gcm_mousewheel) { + parms.kind = evMouseWheel; + parms.pMouseWheel.x = GetAInt(argv[0]); + parms.pMouseWheel.y = GetAInt(argv[1]); + parms.pMouseWheel.mod = GetAInt(argv[2]); + parms.pMouseWheel.delta = GetAInt(argv[3]); + } + else if(s == gcm_key) { + parms.kind = GetAInt(argv[0])?evKeyDown:evKeyUp; + parms.pKey.k = GetAInt(argv[1]); + parms.pKey.a = GetAInt(argv[2]); +// parms.pKey.n = GetAInt(argv[3]); + parms.pKey.mod = GetAInt(argv[4]); + } + else if(s == gcm_destroy) { +// post("TK destroy"); + DelCanvas(ix->canv); + } + + if(parms.kind != evNone) { + for(canvobj *co = ix->head; co; co = co->nxt) + co->guiobj->m_Method(parms); + } + + } + else + error("flext_gui: canvas not found!"); +} + +#endif + +static const char *extkeys[] = { + "Escape","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12", + "Prior","Next","Home","End","Delete","Insert","" +}; + +void flext_gui::pxkey_method(pxkey_object *obj,const t_symbol *s,int argc,t_atom *argv) +{ +/* + if(s == sym_float && argc == 1) { + lastkey = GetInt(argv[0]); + } + else +*/ + if(s == sym_list && argc == 2) { + CBParams p; + + bool down = GetABool(argv[0]); + const char *str = GetString(argv[1]); + int code = str[0]; + int asc = code; + int mod = mod_None; + if(code && str[1] != 0) { + code = asc = 0; + if(GetSymbol(argv[1]) == MakeSymbol("Shift_L") || GetSymbol(argv[1]) == MakeSymbol("Shift_R")) { + code = 2001; + mod = mod_Shift; + } + else if(GetSymbol(argv[1]) == MakeSymbol("Control_L") || GetSymbol(argv[1]) == MakeSymbol("Control_R")) { + code = 2002; + mod = mod_Ctrl; + } + else if(GetSymbol(argv[1]) == MakeSymbol("Alt_L") || GetSymbol(argv[1]) == MakeSymbol("Alt_R")) { + code = 2003; + mod = mod_Alt; + } + else { + for(int i = 0;; ++i) { + const char *ci = extkeys[i]; + if(!*ci) break; + if(GetSymbol(argv[1]) == MakeSymbol(ci)) { + code = 1000+i; + break; + } + } + } +#ifdef DEBUG + else + post("unknown modifier %s",str); +#endif + } + + if(down) curmod |= mod; + else curmod &= ~mod; + +// post("Key down=%i c=%c mod=%i",down?1:0,code,curmod); + + if(code || mod) { + // button is pressed + p.kind = down?evKeyDown:evKeyUp; + p.ext = true; + p.pKey.k = code; //lastkey; + p.pKey.a = asc; + p.pKey.mod = curmod; + + for(guicanv *ix = gcanv; ix; ix = ix->nxt) + for(canvobj *ci = ix->head; ci; ci = ci->nxt) + ci->guiobj->m_Method(p); + } + } + else + post("flext_gui key proxy - unknown method"); +} + + +flext_gui::guicanv::guicanv(t_canvas *c): + canv(c),nxt(NULL),ref(0), + head(NULL),tail(NULL) +{ + char tmp[25]; + sprintf(tmp,"FLCANV%x",c); + sym = MakeSymbol(tmp); + +#ifdef DIRECT_TK + // proxy for canvas messages + (px = (px_object *)pd_new(px_class))->init(c); +#endif +} + +flext_gui::guicanv::~guicanv() +{ +#ifdef DIRECT_TK + if(px) pd_free(&px->obj.ob_pd); +#endif +} + +void flext_gui::guicanv::Push(flext_gui *o) +{ + canvobj *co = new canvobj(o); + if(tail) tail->nxt = co; + tail = co; + if(!head) head = tail; + + ++ref; +} + +void flext_gui::guicanv::Pop(flext_gui *o) +{ + canvobj *prv = NULL,*ix = head; + for(; ix && ix->guiobj != o; prv = ix,ix = ix->nxt); + + if(ix) { + --ref; + if(prv) prv->nxt = ix->nxt; + else head = ix->nxt; + if(!ix->nxt) tail = prv; + } + else + error("flext_gui: object not found in canvas!"); +} + + +void flext_gui::AddCanvas() +{ + t_canvas *c = thisCanvas(); + guicanv *prv = NULL,*ix = gcanv; + for(; ix && ix->canv != c; prv = ix,ix = ix->nxt); + + if(ix) { + ix->Push(this); + } + else { + guicanv *nc = new guicanv(c); + if(prv) prv->nxt = nc; + else gcanv = nc; + + nc->Push(this); + +#ifdef DIRECT_TK + pd_bind(&nc->px->obj.ob_pd,(t_symbol *)nc->sym); + +/* + // initialize new canvas object + sys_vgui("bind .x%x.c {pd %s %s %%x %%y %%s \\;}\n",c,GetString(nc->sym),GetString(gcm_motion)); + + sys_vgui("bind .x%x.c {pd %s %s 1 %%x %%y %%b %%s \\;}\n",c,GetString(nc->sym),GetString(gcm_mousekey)); + sys_vgui("bind .x%x.c {pd %s %s 0 %%x %%y %%b %%s \\;}\n",c,GetString(nc->sym),GetString(gcm_mousekey)); + sys_vgui("bind .x%x.c {pd %s %s %%x %%y %%s %%D \\;}\n",c,GetString(nc->sym),GetString(gcm_mousewheel)); + sys_vgui("bind .x%x.c {pd %s %s 1 %%k %%A %%N %%s \\;}\n",c,GetString(nc->sym),GetString(gcm_key)); + sys_vgui("bind .x%x.c {pd %s %s 0 %%k %%A %%N %%s \\;}\n",c,GetString(nc->sym),GetString(gcm_key)); + + // what happend to objects in subpatchers? + sys_vgui("bind .x%x.c {pd %s %s \\;}\n",c,GetString(nc->sym),GetString(gcm_destroy)); + + // sys_vgui("bind .x%x.c {pd %s %s %x %s \\;}\n",c,GetString(nc->sym),"_tk_visibility",this); +*/ +#endif + } +} + +void flext_gui::RmvCanvas() +{ + guicanv *ix = gcanv; + for(; ix && ix->canv != thisCanvas(); ix = ix->nxt); + + if(ix) { + ix->Pop(this); + if(!ix->Refs()) DelCanvas(thisCanvas()); + } + else { + error("flext_gui: Canvas not found!"); + } +} + +void flext_gui::DelCanvas(t_canvas *c) +{ + guicanv *prv = NULL,*ix = gcanv; + for(; ix && ix->canv != c; prv = ix,ix = ix->nxt); + + if(ix) { +#ifdef DIRECT_TK + pd_unbind(&ix->px->obj.ob_pd,(t_symbol *)ix->sym); +#endif + + if(prv) prv->nxt = ix->nxt; + else gcanv = ix->nxt; + } + else { + error("flext_gui: Canvas not found!"); + } +} + +static GuiObj *GetGuiObj(const t_atom &a) +{ + GuiObj *th = NULL; + sscanf(flext::GetString(a),"%x",&th); + return th; +} + +void flext_gui::g_Displace(int dx, int dy) +{ +// post("Displace"); + + XLo(XLo()+dx); + YLo(YLo()+dy); + + Group().MoveRel(dx,dy); + FixLines(); +} + +void flext_gui::g_Delete() +{ + objs->Clear(); + DelLines(); +} + + + +t_widgetbehavior flext_gui::widgetbehavior; + +void flext_gui::SetWidget(t_class *c) +{ + // widgetbehavior struct MUST be resident... (static is just ok here) + + widgetbehavior.w_getrectfn = sg_getrect; + widgetbehavior.w_displacefn = sg_displace; + widgetbehavior.w_selectfn = sg_select; + widgetbehavior.w_activatefn = NULL; //sg_activate; + widgetbehavior.w_deletefn = sg_delete; + widgetbehavior.w_visfn = sg_vis; + widgetbehavior.w_clickfn = sg_click; + widgetbehavior.w_propertiesfn = sg_properties; + widgetbehavior.w_savefn = sg_save; + class_setwidget(c, &widgetbehavior); +} + +void flext_gui::sg_getrect(t_gobj *c, t_glist *,int *xp1, int *yp1, int *xp2, int *yp2) +{ + flext_gui *th = thisObject(c); + /*th->g_GetRect(*xp1,*yp1,*xp2,*yp2);*/ + *xp1 = th->XLo(),*yp1 = th->YLo(),*xp2 = th->XHi(),*yp2 = th->YHi(); +} + +void flext_gui::sg_displace(t_gobj *c, t_glist *, int dx, int dy) +{ + thisObject(c)->g_Displace(dx,dy); +} + +void flext_gui::sg_select(t_gobj *c, t_glist *, int selected) +{ +// post("Select"); + + flext_gui *th = thisObject(c); + th->g_Edit(th->selected = (selected != 0)); +} + +void flext_gui::sg_vis(t_gobj *c, t_glist *, int vis) +{ + post("Visible %i",vis); + + if(vis) { + flext_gui *g = thisObject(c); + g->g_Create(); + g->Group().MoveRel(g->XLo(),g->YLo()); + g->FixLines(); + } +} + +int flext_gui::sg_click(t_gobj *c, t_glist *,int xpix, int ypix, int shift, int alt, int dbl, int doit) +{ + flext_gui *g = thisObject(c); + CBParams p; + int x = xpix-g->XLo(); + int y = ypix-g->YLo(); + + // PD bug: shift isn't reported for idle mousing +// int mod = (alt?mod_Alt:0)+(shift?mod_Shift:0)+(dbl?mod_Double:0); + + if(doit) { + // button is pressed + p.kind = evMouseDown; + p.pMouseKey.x = x; + p.pMouseKey.y = y; + p.pMouseKey.b = 1; + p.pMouseKey.mod = curmod; //mod; + } + else { + // only mouse position change + p.kind = evMotion; + p.pMotion.x = x; + p.pMotion.y = y; + p.pMotion.mod = curmod; //mod; + } + g->m_Method(p); + return 1; +} + +void flext_gui::sg_delete(t_gobj *c, t_glist *) +{ + thisObject(c)->g_Delete(); +} + +void flext_gui::sg_properties(t_gobj *c, t_glist *) +{ + thisObject(c)->g_Properties(); +} + +void flext_gui::sg_save(t_gobj *c, t_binbuf *b) +{ + thisObject(c)->g_Save(b); +} + +/* +bool flext_gui::sg_Key(flext_base *c,int argc,t_atom *argv) +{ + return true; +} + +bool flext_gui::sg_KeyNum(flext_base *c,int &keynum) +{ + flext_gui *g = dynamic_cast(c); + post("KeyNum %i",keynum); + return true; +} + +bool flext_gui::sg_KeyUp(flext_base *c,int &keynum) +{ + flext_gui *g = dynamic_cast(c); + post("KeyUp %i",keynum); + return true; +} +*/ + +#else // MAXMSP + +int flext_gui::evmask = evMotion|evMouseDown|evKeyDown; + +static void dragfun() +{ +} + +static void tmfun() +{ +} + +void flext_gui::sg_click(t_object *x, Point pt, short m) +{ + flext_gui *g = thisObject(x); + CBParams p(evMouseDown); + p.pMouseKey.x = pt.h-g->XLo(); + p.pMouseKey.y = pt.v-g->YLo(); + p.pMouseKey.b = 0; + p.pMouseKey.mod = (m&256?mod_Meta:0)+(m&512?mod_Shift:0)+(m&1024?mod_Caps:0)+(m&2048?mod_Alt:0)+(m&4096?mod_Ctrl:0); + g->m_Method(p); +} + +void flext_gui::sg_update(t_object *x) +{ + flext_gui *g = thisObject(x); + if(!g->created) { g->g_Create(); g->created = true; } + + // draw elements + g->Update(); +} + +void flext_gui::sg_psave (t_object *x, t_binbuf *dest) { thisObject(x)->g_Save(dest); } + +void flext_gui::sg_bfont (t_object *x, short size, short font) {} + +void flext_gui::sg_key (t_object *x, short keyvalue) +{ + flext_gui *g = thisObject(x); + + CBParams p(evKeyDown); + p.pKey.k = keyvalue; + p.pKey.a = 0; + p.pKey.mod = 0; + g->m_Method(p); +} + +void flext_gui::sg_enter (t_object *x) {} + +void flext_gui::sg_clipregion (t_object *x, RgnHandle *rgn, short *result) {} + +void flext_gui::sg_bidle (t_object *x) +{ + flext_gui *g = thisObject(x); + Point pnt; GetMouse(&pnt); + + CBParams p(evMotion); + p.pMotion.x = pnt.h-g->XLo(); + p.pMotion.y = pnt.v-g->YLo(); + p.pMotion.mod = 0; + + if(p.pMotion.x != g->curx || p.pMotion.y != g->cury || p.pMotion.mod != g->curmod) { + g->m_Method(p); + g->curx = p.pMotion.x; + g->cury = p.pMotion.y; + g->curmod = p.pMotion.mod; + } +} + +void flext_gui::g_Displace(int dx, int dy) +{ +} + +void flext_gui::g_Delete() +{ + objs->Clear(); +} + +void flext_gui::Update() +{ + box_ready(&thisHdr()->z_box); + + if(Group().Canv().Pre(XLo(),YLo())) + Group().Draw(); + Group().Canv().Post(); +} + +#endif // PD / MAXMSP + +void flext_gui::m_Method(const CBParams &p) +{ +/* + switch(p.kind) { + case evMotion: { + // if(!g->Selected() || mod) + post("Motion: x=%i y=%i m=%i",p.pMotion.x,p.pMotion.y,p.pMotion.mod); + break; + } + case evMouseDown: { + post("MouseDown: x=%i y=%i b=%i m=%i",p.pMouseKey.x,p.pMouseKey.y,p.pMouseKey.b,p.pMouseKey.mod); + break; + } + case evMouseUp: { + post("MouseUp: x=%i y=%i b=%i m=%i",p.pMouseKey.x,p.pMouseKey.y,p.pMouseKey.b,p.pMouseKey.mod); + break; + } + case evMouseWheel: { + post("Mousewheel: x=%i y=%i m=%i d=%i",p.pMouseWheel.x,p.pMouseWheel.y,p.pMouseWheel.mod,p.pMouseWheel.delta); + break; + } + case evKeyDown: { + post("KeyDown: k=%i a=%i m=%i",p.pKey.k,p.pKey.a,p.pKey.mod); + break; + } + case evKeyUp: { + post("KeyUp: k=%i a=%i m=%i",p.pKey.k,p.pKey.a,p.pKey.mod); + break; + } + } +*/ + if(!Selected() || p.kind != evMotion || p.kind != evMouseDown || p.kind != evMouseUp) + Group().Method(*this,p); + } + +bool flext_gui::BindEvent(GuiSingle &o,bool (*cb)(flext_gui &o,GuiSingle &obj,const CBParams &p),int evs) +{ + if((evs&EventMask()) == evs) { + o.AddEvent(evs,cb); + return true; + } + else + // not all requested events supported + return false; +} + +void flext_gui::UnbindEvent(GuiSingle &o,bool (*cb)(flext_gui &o,GuiSingle &obj,const CBParams &p),int evs) +{ + o.RmvEvent(evs,cb); +} + + diff --git a/externals/grill/guitest/flgui.h b/externals/grill/guitest/flgui.h new file mode 100644 index 00000000..ac42ab7b --- /dev/null +++ b/externals/grill/guitest/flgui.h @@ -0,0 +1,232 @@ +#ifndef __FLEXT_GUI +#define __FLEXT_GUI + +#define FLEXT_GUI +#include + +#ifdef PD +#pragma warning( disable : 4091 ) +#include +#endif + +class Canvas; +class GuiObj; +class GuiGroup; +class GuiSingle; + +class flext_gui: + virtual public flext_base +{ + FLEXT_HEADER_S(flext_gui,flext_base,setup) + +public: + flext_gui(int xs,int ys); + ~flext_gui(); + + enum CBEvs { + evNone = 0, + evMotion = 0x01, + evMouseDown = 0x02, + evMouseUp = 0x04, + evMouseWheel = 0x08, + evKeyDown = 0x10, + evKeyUp = 0x20 + }; + + class CBParams { + public: + CBParams(CBEvs k = evNone): kind(k),ext(false) {} + + CBEvs kind; + union { + struct { int x,y,mod; } pMotion; + struct { int x,y,b,mod; } pMouseKey; + struct { int x,y,mod,delta; } pMouseWheel; + struct { int k,a,mod; } pKey; + }; + bool ext; + }; + + static int EventMask() { return evmask; } + + bool BindEvent(GuiSingle &o,bool (*cb)(flext_gui &o,GuiSingle &obj,const CBParams &p),int evs); + void UnbindEvent(GuiSingle &o,bool (*cb)(flext_gui &o,GuiSingle &obj,const CBParams &p),int evs); + +protected: + + virtual void g_Create() {} + virtual void g_Delete(); +// virtual void g_GetRect(int &xp1,int &yp1,int &xp2,int &yp2); + virtual void g_Edit(bool selected) {} + virtual void g_Displace(int dx, int dy); +// virtual void g_Activate(bool state) {} +// virtual int g_Click(int xpix, int ypix, int shift, int alt, int dbl, int doit) { return 0; } + virtual void g_Properties() {} + virtual void g_Save(t_binbuf *b) {} +/* + virtual bool g_Motion(GuiObj &obj,int x,int y,int mod) { return false; } + virtual bool g_MouseKey(GuiObj &obj,bool down,int x,int y,int b,int mod) { return false; } + virtual bool g_MouseWheel(GuiObj &obj,int x,int y,int d,int mod) { return false; } + virtual bool g_Key(GuiObj &obj,bool down,int k,int a,int n,int mod) { return false; } + virtual bool g_Region(GuiObj &obj,bool on,int mod) { return false; } + virtual bool g_Focus(GuiObj &obj,bool on,int mod) { return false; } +*/ + +#ifdef PD + bool Selected() const { return selected; } + + void FixLines() { canvas_fixlinesfor( thisCanvas(), thisHdr() ); } + void DelLines() { canvas_deletelinesfor( glist_getcanvas(thisCanvas()), (t_text *)thisHdr()); } + + int XLo() const { return thisHdr()->te_xpix; } + int YLo() const { return thisHdr()->te_ypix; } + int XHi() const { return XLo()+XSize()-1; } + int YHi() const { return YLo()+YSize()-1; } + void XLo(int x) { thisHdr()->te_xpix = x; } + void YLo(int y) { thisHdr()->te_ypix = y; } + + int XSize() const { return xsize; } + int YSize() const { return ysize; } +#else // MAXMSP + bool Selected() const { return box_ownerlocked((t_box *)(&thisHdr()->z_box)) == 0; } + + void FixLines() {} + void DelLines() {} + + int XLo() const { return thisHdr()->z_box.b_rect.left; } + int YLo() const { return thisHdr()->z_box.b_rect.top; } + int XHi() const { return thisHdr()->z_box.b_rect.right; } + int YHi() const { return thisHdr()->z_box.b_rect.bottom; } + void XLo(int x) { thisHdr()->z_box.b_rect.left = x; } + void YLo(int y) { thisHdr()->z_box.b_rect.top = y; } + + int XSize() const { return XHi()-XLo()+1; } + int YSize() const { return YHi()-YLo()+1; } +#endif + + const t_symbol *Id() const { return bindsym; } + + GuiGroup &Group() { return *objs; } + + + static void Setup(t_class *c); + + + enum Modifier { + mod_None = 0, + mod_Ctrl = 0x0001, + mod_Shift = 0x0002, + mod_Alt = 0x0004, + mod_Meta = 0x0008, + mod_Mod1 = 0x0010, + mod_Mod2 = 0x0020, + mod_Mod3 = 0x0040, + mod_Caps = 0x0080, + mod_Double = 0x0100, +// mod_Triple = 0x0200, + mod_Button1 = 0x1000, + mod_Button2 = 0x2000, + mod_Button3 = 0x4000, + mod_Button4 = 0x8000 + }; + +private: + bool visible; + Canvas *canvas; + GuiGroup *objs; + + const t_symbol *bindsym; + + static int evmask; + + static void setup(t_class *); + + virtual void m_Method(const CBParams &p); + +#ifdef PD + bool selected; + int xsize,ysize; + + static void sg_getrect(t_gobj *c, t_glist *,int *xp1, int *yp1, int *xp2, int *yp2); + static void sg_displace(t_gobj *c, t_glist *, int dx, int dy); + static void sg_select(t_gobj *c, t_glist *, int selected); +// static void sg_activate(t_gobj *c, t_glist *, int state) { thisObject(c)->g_Activate(state != 0); } + static void sg_delete(t_gobj *c, t_glist *); + static void sg_vis(t_gobj *c, t_glist *, int vis); + static int sg_click(t_gobj *c, t_glist *,int xpix, int ypix, int shift, int alt, int dbl, int doit); + static void sg_properties(t_gobj *c, t_glist *); + static void sg_save(t_gobj *c, t_binbuf *b); +// static void sg_motion(void *c, float dx,float dy) { thisObject((t_gobj *)c)->g_Motion(dx,dy); } + + static bool sg_Key(flext_base *c,int argc,t_atom *argv); + static bool sg_KeyNum(flext_base *c,int &keynum); + static bool sg_KeyUp(flext_base *c,int &keynum); + + static t_widgetbehavior widgetbehavior; + static void SetWidget(t_class *c); + + struct px_object; + struct pxkey_object; + static int curmod; //,lastkey; + static pxkey_object *pxkey; + + class canvobj { + public: + canvobj(flext_gui *go): guiobj(go),nxt(NULL) {} + + flext_gui *guiobj; + canvobj *nxt; + }; + + class guicanv { + public: + guicanv(t_canvas *c); + ~guicanv(); + + int Refs() const { return ref; } + void Push(flext_gui *o); + void Pop(flext_gui *o); + +#ifdef DIRECT_TK + px_object *px; +#endif + const t_symbol *sym; + t_canvas *canv; + guicanv *nxt; + canvobj *head,*tail; + int ref; + }; + + static guicanv *gcanv; + static const t_symbol *gcm_motion,*gcm_mousekey,*gcm_mousewheel,*gcm_key,*gcm_destroy; + static void px_method(px_object *c,const t_symbol *s,int argc,t_atom *argv); + static void pxkey_method(pxkey_object *c,const t_symbol *s,int argc,t_atom *argv); + + void AddCanvas(); + void RmvCanvas(); + static void DelCanvas(t_canvas *c); + +public: + static t_class *px_class,*pxkey_class; + static void sg_tk(t_canvas *c,const t_symbol *s,int argc,t_atom *argv); + +#else + int curx,cury,curmod; + bool created; + static t_clock clock; + static t_qelem qelem; + + void Update(); + + static void sg_click(t_object *x, Point pt, short modifiers); + static void sg_update(t_object *x); + static void sg_psave (t_object *x, t_binbuf *dest); + static void sg_bfont (t_object *x, short size, short font); + static void sg_key (t_object *x,short keyvalue); + static void sg_enter (t_object *x); + static void sg_clipregion (t_object *x, RgnHandle *rgn, short *result); + static void sg_bidle(t_object *x); +#endif +}; + +#endif diff --git a/externals/grill/guitest/flguiobj.cpp b/externals/grill/guitest/flguiobj.cpp new file mode 100644 index 00000000..b845ae5e --- /dev/null +++ b/externals/grill/guitest/flguiobj.cpp @@ -0,0 +1,801 @@ +#include "flguiobj.h" + +#include +#include +#include +#include + + +#define USETAGS + +#define BUFSIZE 20000 +#define ZONE 1000 + + +#ifdef PD +bool Canvas::store = true; +bool Canvas::debug = false; +#endif + +Canvas::Canvas(t_canvas *c): + canvas(c) +#ifdef PD + ,buffer(new char[BUFSIZE]),bufix(0),waiting(0) +#endif +{} + +Canvas::~Canvas() +{ +#ifdef PD + if(buffer) delete[] buffer; +#endif +} + +#ifdef PD +void Canvas::Send(const char *t) +{ + if(debug) post("GUI - %s",t); + sys_gui((char *)t); +} + +void Canvas::SendBuf() +{ + if(bufix) { + Send(buffer); + bufix = 0; + } +} + +void Canvas::ToBuf(const char *t) +{ + int len = strlen(t); + if(!len) return; + + bool end = t[len-1] == '\n'; + if((store && waiting) || !end) { + int nxt = bufix+len; + if(nxt >= BUFSIZE || (end && nxt >= BUFSIZE-ZONE)) SendBuf(); + + memcpy(buffer+bufix,t,len); + buffer[bufix += len] = 0; + } + else { + SendBuf(); + Send(t); + } +} + +Canvas &Canvas::TkC() +{ + char tmp[20]; + sprintf(tmp,".x%x.c ",canvas); + ToBuf(tmp); + return *this; +} + +Canvas &Canvas::TkE() +{ + ToBuf("\n"); + return *this; +} + +Canvas &Canvas::Tk(char *fmt,...) +{ + // int result, i; + char buf[2048]; + va_list ap; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + ToBuf(buf); + va_end(ap); + return *this; +} +#endif + +bool Canvas::Pre(int x,int y) +{ + xpos = x,ypos = y; +#ifdef PD + ++waiting; + return true; +#else + svgp = patcher_setport(canvas); + if(svgp != NULL) { + GetForeColor(&svcol); + GetPenState(&svpen); + ::PenMode(patCopy); + return true; + } + else return false; +#endif +} + +void Canvas::Post() +{ +#ifdef PD + if(!--waiting) SendBuf(); +#else + if(svgp) { + RGBForeColor(&svcol); + SetPenState(&svpen); + SetPort(svgp); + } +#endif +} + + +// -------------------------------------------------------------------------- + + +Rect &Rect::Add(const Pnt &p) +{ + if(p.x < lo.x) lo.x = p.x; + if(p.y < lo.y) lo.y = p.y; + if(p.x > hi.x) hi.x = p.x; + if(p.y > hi.y) hi.y = p.y; + return *this; +} + +Rect &Rect::Add(const Rect &r) +{ + if(r.lo.x < lo.x) lo.x = r.lo.x; + if(r.lo.y < lo.y) lo.y = r.lo.y; + if(r.hi.x > hi.x) hi.x = r.hi.x; + if(r.hi.y > hi.y) hi.y = r.hi.y; + return *this; +} + +bool Rect::In(const Pnt &p) const +{ + return p.x >= lo.x && p.x <= hi.x && p.y >= lo.y && p.y <= hi.y; +} + +bool Rect::Inter(const Rect &r) const +{ + return true; +} + + +// -------------------------------------------------------------------------- + + +GuiObj::GuiObj(Canvas *c,GuiGroup *p): + canvas(c),idsym(NULL), + parent(p) +// ,ori(0,0) +{} + +GuiObj::~GuiObj() +{ +// Delete(); +} + + +// -------------------------------------------------------------------------- + +GuiSingle::Event::Event(int evmask,bool (*m)(flext_gui &g,GuiSingle &obj,const flext_gui::CBParams &p)): + methfl(evmask),method(m),ext(false),nxt(NULL) +{} + +GuiSingle::Event::~Event() { if(nxt) delete nxt; } + + +GuiSingle::GuiSingle(Canvas *c,GuiGroup *p,const t_symbol *s): + GuiObj(c,p),sym(s),active(false),event(NULL) +{ + char tmp[20]; +#ifdef __MWERKS__ + std:: +#endif + sprintf(tmp,"GUI%x",this); + idsym = MakeSymbol(tmp); +} + +GuiSingle::~GuiSingle() +{ + Delete(); + if(event) delete event; +} + +void GuiSingle::Symbol(const t_symbol *s) +{ + sym = s; +} + +GuiSingle *GuiSingle::Find(const t_symbol *s) +{ + return sym == s?this:NULL; +} + +GuiObj &GuiSingle::MoveTo(int x,int y) +{ +#ifdef PD + if(active) { + canvas->TkC().Tk("coords %s %i %i\n",GetString(Id()), x, y); + } +#endif + rect.MoveTo(x,y); + return *this; +} + +GuiObj &GuiSingle::MoveRel(int dx,int dy) +{ +#ifdef PD + if(active) { + canvas->TkC().Tk("move %s %i %i\n",GetString(Id()), dx, dy); + } +#endif + rect.Move(dx,dy); + return *this; +} + +GuiObj &GuiSingle::Delete() +{ +#ifdef PD + if(active) { + canvas->TkC().Tk("delete -tags %s\n",GetString(Id())); + active = false; + } +#endif + return *this; +} + +GuiObj &GuiSingle::FillColor(unsigned long col) +{ +#ifdef PD + if(active) { + canvas->TkC().Tk("itemconfigure %s -fill #%06x\n",GetString(Id()),col); + } +#endif + return *this; +} + +GuiObj &GuiSingle::Outline(unsigned long col) +{ +#ifdef PD + if(active) { + canvas->TkC().Tk("itemconfigure %s -outline #%06x\n",GetString(Id()),col); + } +#endif + return *this; +} + +GuiObj &GuiSingle::Focus() +{ +#ifdef PD + if(active) { + canvas->TkC().Tk("focus %s\n",GetString(Id())); + } +#endif + return *this; +} + +bool GuiSingle::Method(flext_gui &g,const flext_gui::CBParams &p) +{ + bool ret = true; + for(Event *ei = event; ei && ret; ei = ei->nxt) + ret = ret && ((ei->method && (ei->methfl&p.kind))?ei->method(g,*this,p):true); + return ret; +} + +void GuiSingle::AddEvent(int evmask,bool (*m)(flext_gui &g,GuiSingle &obj,const flext_gui::CBParams &p)) +{ + Event *prv = NULL,*ix = event; + for(; ix && ix->method != m; prv = ix,ix = ix->nxt) {} + + if(ix) + // previous handler found -> update event mask + ix->methfl |= evmask; + else { + // no previous handler was found -> make new one + + Event *nev = new Event(evmask,m); + if(prv) prv->nxt = nev; + else event = nev; + } +} + +void GuiSingle::RmvEvent(int evmask,bool (*m)(flext_gui &g,GuiSingle &obj,const flext_gui::CBParams &p)) +{ + Event *prv = NULL,*ix = event; + for(; ix && ix->method != m; prv = ix,ix = ix->nxt) {} + + if(ix) { + // handler found + + if(!(ix->methfl &= ~evmask)) { + // mask has become zero -> remove handler + + if(prv) prv->nxt = ix->nxt; + else event = ix->nxt; + ix->nxt = NULL; + delete ix; + } + } +} + + + +// -------------------------------------------------------------------------- + + +GuiGroup::GuiGroup(Canvas *c,GuiGroup *p): + GuiObj(c,p),head(NULL),tail(NULL) +{ + char tmp[20]; +#ifdef __MWERKS__ + std:: +#endif + sprintf(tmp,"GRP%x",this); + idsym = MakeSymbol(tmp); +} + +GuiGroup::~GuiGroup() { Clear(); } + +void GuiGroup::Clear() +{ + for(Part *ix = head; ix; ) { + Part *n = ix->nxt; +#ifdef PD + RemoveTag(ix->obj); +#endif + if(ix->owner) delete ix->obj; + delete ix; + ix = n; + } + head = tail = NULL; +} + +void GuiGroup::Add(GuiObj *o,bool owner) +{ + o->canvas = canvas; +#ifdef PD + AddTag(o); // valid only for GuiSingle! +#endif + Part *n = new Part(o,owner); + if(!head) head = n; + else tail->nxt = n; + tail = n; + + rect.Add(o->rect); +} + +GuiSingle *GuiGroup::Find(const t_symbol *s) +{ + GuiSingle *r = NULL; + for(Part *ix = head; ix && !r; ix = ix->nxt) { + r = ix->obj->Find(s); + } + return r; +} + +GuiSingle *GuiGroup::Detach(const t_symbol *s) +{ + if(head) { + Part *p = NULL,*ix = head; + while(ix) { + if(ix->obj->Symbol() == s) { + // found + if(p) p->nxt = ix->nxt; + GuiSingle *ret = (GuiSingle *)(ix->obj); + +#ifdef PD + RemoveTag(ret); +#endif + if(head == ix) head = ix->nxt; + if(tail == ix) tail = p; + + delete ix; + + return ret; + } + else p = ix,ix = ix->nxt; + } + } + return NULL; +} + +GuiObj &GuiGroup::MoveRel(int dx,int dy) +{ +#ifdef PD + canvas->TkC().Tk("move %s %i %i\n",GetString(Id()), dx, dy); +#endif + for(Part *ix = head; ix; ix = ix->nxt) { + ix->obj->rect.Move(dx,dy); + } + return *this; +} + +GuiObj &GuiGroup::Delete() +{ +#ifdef PD + canvas->TkC().Tk("delete -tags %s\n",GetString(Id())); + + for(Part *ix = head; ix; ix = ix->nxt) ix->obj->Inactive(); +#endif + return *this; +} + + +GuiObj &GuiGroup::Draw() +{ + for(Part *ix = head; ix; ix = ix->nxt) ix->obj->Draw(); + return *this; +} + + +#ifdef PD + +void GuiGroup::AddTag(GuiObj *o) +{ + canvas->TkC().Tk("addtag %s withtag %s\n",GetString(Id()),GetString(o->Id())); +} + +void GuiGroup::RemoveTag(GuiObj *o) +{ + canvas->TkC().Tk("dtag %s %s\n",GetString(o->Id()),GetString(Id())); +} + +#endif + +GuiGroup *GuiGroup::Add_Group() +{ + GuiGroup *obj = new GuiGroup(canvas,this); + Add(obj); + return obj; +} + + +GuiSingle *GuiGroup::Add_Point(int x,int y,long fill) +{ + GuiPoint *obj = new GuiPoint(canvas,this); + obj->Set(x,y,fill); + Add(obj); + return obj; +} + +GuiSingle *GuiGroup::Add_Cloud(int n,const Pnt *p,long fill) +{ + GuiCloud *obj = new GuiCloud(canvas,this); + obj->Set(n,p,fill); + Add(obj); + return obj; +} + +GuiSingle *GuiGroup::Add_Box(int x,int y,int xsz,int ysz,int width,long fill,long outl) +{ + GuiBox *obj = new GuiBox(canvas,this); + obj->Set(x,y,xsz,ysz,width,fill,outl); + Add(obj); + return obj; +} + +GuiSingle *GuiGroup::Add_Rect(int x,int y,int xsz,int ysz,int width,long outl) +{ + GuiRect *obj = new GuiRect(canvas,this); + obj->Set(x,y,xsz,ysz,width,outl); + Add(obj); + return obj; +} + +GuiSingle *GuiGroup::Add_Line(int x1,int y1,int x2,int y2,int width,long fill) +{ + GuiLine *obj = new GuiLine(canvas,this); + obj->Set(x1,y1,x2,y2,width,fill); + Add(obj); + return obj; +} + +GuiSingle *GuiGroup::Add_Poly(int n,const Pnt *p,int width,long fill) +{ + GuiPoly *obj = new GuiPoly(canvas,this); + obj->Set(n,p,width,fill); + Add(obj); + return obj; +} + +GuiSingle *GuiGroup::Add_Text(int x,int y,const char *txt,long fill,GuiText::just_t just) +{ + GuiText *obj = new GuiText(canvas,this); + obj->Set(x,y,txt,fill,just); + Add(obj); + return obj; +} + +GuiSingle *GuiGroup::Remove(GuiSingle *go) +{ + for(Part *prv = NULL,*ix = head; ix; prv = ix,ix = ix->nxt) + if(ix->obj == go) { + if(prv) prv->nxt = ix->nxt; + else head = ix->nxt; + if(!head) tail = NULL; + + GuiObj *ret = ix->obj; + delete ix; + + if(head) { + rect = head->obj->rect; + for(ix = head->nxt; ix; ix = ix->nxt) rect.Add(ix->obj->rect); + } + + return (GuiSingle *)ret; + } + + return NULL; +} + +bool GuiGroup::Method(flext_gui &g,const flext_gui::CBParams &p) +{ + bool go = true; + for(Part *ix = head; go && ix; ix = ix->nxt) go = go && ix->obj->Method(g,p); + return go; +} + + +// -------------------------------------------------------------------------- + + +GuiObj &GuiPoint::Set(int x,int y,long fl) +{ + Delete(); + fill = fl; + rect(x,y,x,y); + +#ifdef PD + canvas->TkC(); + canvas->Tk("create line %i %i %i %i -tags %s",x,y,x+1,y,GetString(Id())); + if(fill >= 0) canvas->Tk(" -fill #%06x",fill); + canvas->TkE(); + + active = true; +#endif + return *this; +} + +GuiObj &GuiPoint::Draw() +{ +#ifdef MAXMSP +#endif + return *this; +} + + +GuiObj &GuiCloud::Set(int n,const Pnt *p,long fl) +{ + int i; + Delete(); + + fill = fl; + pnt = new Pnt[pnts = n]; + rect(pnt[0] = p[0],p[0]); + for(i = 1; i < n; ++i) rect.Add(pnt[i] = p[i]); + +#ifdef PD + canvas->TkC().Tk("create line"); + for(i = 0; i < n; ++i) + canvas->Tk(" %i %i",p[i].X(),p[i].Y()); + canvas->Tk(" -tags %s",GetString(Id())); + if(fill >= 0) canvas->Tk(" -fill #%06x",fill); + canvas->TkE(); + + active = true; +#endif + return *this; +} + +GuiObj &GuiCloud::Draw() +{ +#ifdef MAXMSP +#endif + return *this; +} + +GuiObj &GuiCloud::Delete() +{ + if(pnt) { delete[] pnt; pnt = NULL; } + return *this; +} + + +GuiObj &GuiBox::Set(int x,int y,int xsz,int ysz,int wd,long fl,long outl) +{ + Delete(); + rect(x,y,x+xsz-1,y+ysz-1); + width = wd,fill = fl,outln = outl; + +#ifdef PD + canvas->TkC().Tk("create rectangle %i %i %i %i -tags %s",x,y,x+xsz,y+ysz,GetString(Id())); + if(wd >= 0) canvas->Tk(" -width %i",wd); + if(fl >= 0) canvas->Tk(" -fill #%06x",fl); + if(outl >= 0) canvas->Tk(" -outline #%06x",outl); + canvas->TkE(); + + active = true; +#endif + return *this; +} + +GuiObj &GuiBox::Draw() +{ +#ifdef MAXMSP + ::Rect r; + ::RGBColor col; + int w = width; + if(!w) w = 1; + + r.left = Canv().X()+rect.Lo().X(); + r.top = Canv().Y()+rect.Lo().Y(); + r.right = Canv().X()+rect.Hi().X(); + r.bottom = Canv().Y()+rect.Hi().Y(); + + if(width >= 0) { + col.red = (outln>>8)&0xff00; + col.green = outln&0xff00; + col.blue = (outln&0xff)<<8; + ::RGBForeColor(&col); + ::PenSize(w,w); + ::FrameRect(&r); + } + col.red = (fill>>8)&0xff00; + col.green = fill&0xff00; + col.blue = (fill&0xff)<<8; + ::RGBForeColor(&col); + ::PaintRect(&r); +#endif + return *this; +} + + +GuiObj &GuiRect::Set(int x,int y,int xsz,int ysz,int wd,long outl) +{ + Delete(); + rect(x,y,x+xsz-1,y+ysz-1); + width = wd,outln = outl; + +#ifdef PD + canvas->TkC().Tk("create line %i %i %i %i %i %i %i %i %i %i -tags %s",x,y,x+xsz,y,x+xsz,y+ysz,x,y+ysz,x,y,GetString(Id())); + if(width >= 0) canvas->Tk(" -width %i",width); + if(outl >= 0) canvas->Tk(" -fill #%06x",outl); + canvas->TkE(); + + active = true; +#endif + return *this; +} + +GuiObj &GuiRect::Draw() +{ +#ifdef MAXMSP +#endif + return *this; +} + + +GuiObj &GuiLine::Set(int x1,int y1,int x2,int y2,int wd,long fl) +{ + Delete(); + rect(p1(x1,y1),p2(x2,y2)); + width = wd,fill = fl; + +#ifdef PD + canvas->TkC().Tk("create line %i %i %i %i -tags %s",x1,y1,x2,y2,GetString(Id())); + if(width >= 0) canvas->Tk(" -width %i",width); + if(fill >= 0) canvas->Tk(" -fill #%06x",fill); + canvas->TkE(); + + active = true; +#endif + return *this; +} + +GuiObj &GuiLine::Draw() +{ +#ifdef MAXMSP + ::Point p; + ::RGBColor col; + int w = width; + if(!w) w = 1; + + col.red = (fill>>8)&0xff00; + col.green = fill&0xff00; + col.blue = (fill&0xff)<<8; + ::RGBForeColor(&col); + ::PenSize(w,w); + p.h = Canv().X()+p1.X(); + p.v = Canv().Y()+p1.Y(); + ::MoveTo(p.h,p.v); + p.h = Canv().X()+p2.X(); + p.v = Canv().Y()+p2.Y(); + ::LineTo(p.h,p.v); +#endif + return *this; +} + + +GuiObj &GuiPoly::Set(int n,const Pnt *p,int wd,long fl) +{ + int i; + + Delete(); + + width = wd,fill = fl; + pnt = new Pnt[pnts = n]; + rect(pnt[0] = p[0],p[0]); + for(i = 1; i < n; ++i) rect.Add(pnt[i] = p[i]); + +#ifdef PD + canvas->TkC().Tk("create line"); + for(i = 0; i < n; ++i) + canvas->Tk(" %i %i",p[i].X(),p[i].Y()); + canvas->Tk(" -tags %s",GetString(Id())); + if(width >= 0) canvas->Tk(" -width %i",width); + if(fill >= 0) canvas->Tk(" -fill #%06x",fill); + canvas->TkE(); + + active = true; +#endif + return *this; +} + +GuiObj &GuiPoly::Draw() +{ +#ifdef MAXMSP + ::Point p; + ::RGBColor col; + int ox = Canv().X(),oy = Canv().Y(); + int w = width; + if(!w) w = 1; + + col.red = (fill>>8)&0xff00; + col.green = fill&0xff00; + col.blue = (fill&0xff)<<8; + ::RGBForeColor(&col); + ::PenSize(w,w); + p.h = ox+pnt[0].X(); + p.v = oy+pnt[0].Y(); + ::MoveTo(p.h,p.v); + for(int i = 1; i < pnts; ++i) { + p.h = ox+pnt[i].X(); + p.v = oy+pnt[i].Y(); + ::LineTo(p.h,p.v); + } +#endif + return *this; +} + +GuiObj &GuiPoly::Delete() +{ + if(pnt) { delete[] pnt; pnt = NULL; } + return *this; +} + + +GuiObj &GuiText::Set(int x,int y,const char *txt,long fl,just_t jt) +{ + Delete(); + rect(x,y,x,y); + fill = fl,just = jt; + +#ifdef PD + canvas->TkC().Tk("create text %i %i -tags %s",x,y,GetString(Id())); + if(txt) canvas->Tk(" -text %s",txt); + if(fill >= 0) canvas->Tk(" -fill #%06x",fill); + if(just != none) { + static const char justtxt[][7] = {"left","right","center"}; + canvas->Tk(" -justify %s",justtxt[(int)just]); + } + canvas->TkE(); + + active = true; +#endif + return *this; +} + +GuiObj &GuiText::Draw() +{ +#ifdef MAXMSP +#endif + return *this; +} + diff --git a/externals/grill/guitest/flguiobj.h b/externals/grill/guitest/flguiobj.h new file mode 100644 index 00000000..66286cef --- /dev/null +++ b/externals/grill/guitest/flguiobj.h @@ -0,0 +1,362 @@ +#ifndef __FLGUIOBJ_H +#define __FLGUIOBJ_H + +#define FLEXT_GUI +#include +#include "flgui.h" + + +class Canvas +{ +public: + Canvas(t_canvas *c); + ~Canvas(); + +#ifdef PD + Canvas &Tk(char *fmt,...); + Canvas &TkC(); + Canvas &TkE(); + + void ToBuf(const char *t); +#endif + + bool Pre(int x,int y); + void Post(); + + int X() const { return xpos; } + int Y() const { return ypos; } + +protected: + + t_canvas *canvas; + int xpos,ypos; + +#ifdef PD + void Send(const char *t); + void SendBuf(); + + static bool debug,store; + + char *buffer; + int bufix; + int waiting; +#else + PenState svpen; + RGBColor svcol; + GrafPtr svgp; +#endif +}; + + +class Pnt +{ +public: + Pnt() {} + Pnt(const Pnt &p): x(p.x),y(p.y) {} + Pnt(int px,int py): x(px),y(py) {} + + Pnt &operator =(const Pnt &p) { x = p.x,y = p.y; return *this; } + Pnt &operator ()(int px,int py) { x = px,y = py; return *this; } + + Pnt &Move(int dx,int dy) { x += dx,y += dy; return *this; } + + int X() const { return x; } + int Y() const { return y; } + +//protected: + int x,y; +}; + +class Rect +{ +public: + Rect() {} + Rect(const Rect &r): lo(r.lo),hi(r.hi) {} + Rect(int xlo,int ylo,int xhi,int yhi): lo(xlo,ylo),hi(xhi,yhi) {} + + Rect &operator =(const Rect &r) { lo = r.lo; hi = r.hi; return *this; } + Rect &operator ()(const Pnt &l,const Pnt &h) { lo = l; hi = h; return *this; } + Rect &operator ()(int xlo,int ylo,int xhi,int yhi) { lo(xlo,ylo); hi(xhi,yhi); return *this; } + + Rect &Move(int dx,int dy) { lo.Move(dx,dy); hi.Move(dx,dy); return *this; } + Rect &MoveTo(int x,int y) { hi(x+hi.X()-lo.X(),y+hi.Y()-lo.Y()); lo(x,y); return *this; } + + Pnt &Lo() { return lo; } + Pnt &Hi() { return hi; } + int SizeX() const { return hi.X()-lo.X()+1; } + int SizeY() const { return hi.Y()-lo.Y()+1; } + + Rect &Add(const Pnt &p); + Rect &Add(const Rect &r); + bool In(const Pnt &p) const; + bool Inter(const Rect &r) const; + +protected: + Pnt lo,hi; +}; + +class GuiObj: + public flext +{ + friend class GuiGroup; +public: + GuiObj(Canvas *c = NULL,GuiGroup *p = NULL); + virtual ~GuiObj(); + + const t_symbol *Id() const { return idsym; } + virtual const t_symbol *Symbol() const { return NULL; } + + virtual void Active() {} + virtual void Inactive() {} + +/* + void Origin(int x,int y) { ori(x,y); } + void Origin(const Pnt &p) { ori = p; } + const Pnt &Origin() const { return ori; } + void OriMove(int dx,int dy) { ori.Move(dx,dy); } + int OriX() const { return ori.X(); } + int OriY() const { return ori.Y(); } +*/ + + virtual GuiSingle *Find(const t_symbol *s) { return NULL; } + inline GuiSingle *Find(const char *s) { return Find(MakeSymbol(s)); } + + virtual GuiObj &MoveRel(int dx,int dy) = 0; + virtual GuiObj &Focus() { return *this; } + + virtual GuiObj &Draw() = 0; + + Canvas &Canv() { return *canvas; } + +protected: + virtual GuiObj &Delete() = 0; + + GuiGroup *parent; + Canvas *canvas; + const t_symbol *idsym; + + virtual bool Method(flext_gui &g,const flext_gui::CBParams &p) = 0; + + Rect rect; +}; + + +class GuiSingle: + public GuiObj +{ + friend class flext_gui; +public: + GuiSingle(Canvas *c = NULL,GuiGroup *p = NULL,const t_symbol *s = NULL); + ~GuiSingle(); + + virtual const t_symbol *Symbol() const { return sym; } + virtual void Symbol(const t_symbol *s); + void Symbol(const char *s) { Symbol(MakeSymbol(s)); } + + virtual void Active() { active = true; } + virtual void Inactive() { active = false; } + + virtual bool In(const Pnt &p) const { return false; } + + virtual GuiSingle *Find(const t_symbol *s); + virtual GuiObj &MoveTo(int x,int y); + virtual GuiObj &MoveRel(int dx,int dy); + virtual GuiObj &FillColor(unsigned long col); + virtual GuiObj &Outline(unsigned long col); + + virtual GuiObj &Focus(); + + GuiGroup &Parent() { return *parent; } + +protected: + virtual GuiObj &Delete(); + + const t_symbol *sym; + bool active; + + class Event { + public: + Event(int evmask,bool (*m)(flext_gui &g,GuiSingle &obj,const flext_gui::CBParams &p)); + ~Event(); + + int methfl; + bool (*method)(flext_gui &g,GuiSingle &obj,const flext_gui::CBParams &p); + bool ext; + Event *nxt; + } *event; + + void AddEvent(int evmask,bool (*m)(flext_gui &g,GuiSingle &obj,const flext_gui::CBParams &p)); + void RmvEvent(int evmask,bool (*m)(flext_gui &g,GuiSingle &obj,const flext_gui::CBParams &p)); + + virtual bool Method(flext_gui &g,const flext_gui::CBParams &p); +}; + + +class GuiPoint: + public GuiSingle +{ + friend class GuiGroup; + + GuiPoint(Canvas *c = NULL,GuiGroup *p = NULL,const t_symbol *s = NULL): GuiSingle(c,p,s) {} + GuiObj &Set(int x,int y,long fill = -1); + virtual GuiObj &Draw(); + + long fill; +public: +}; + + +class GuiCloud: + public GuiSingle +{ + friend class GuiGroup; + + GuiCloud(Canvas *c = NULL,GuiGroup *p = NULL,const t_symbol *s = NULL): GuiSingle(c,p,s),pnt(NULL) {} + GuiObj &Set(int n,const Pnt *p,long fill = -1); + virtual GuiObj &Draw(); + virtual GuiObj &Delete(); + + long fill; + int pnts; + Pnt *pnt; +public: +}; + + +class GuiBox: + public GuiSingle +{ + friend class GuiGroup; + + GuiBox(Canvas *c = NULL,GuiGroup *p = NULL,const t_symbol *s = NULL): GuiSingle(c,p,s) {} + GuiObj &Set(int x,int y,int xsz,int ysz,int width = -1,long fill = -1,long outl = -1); + virtual GuiObj &Draw(); + + virtual bool In(const Pnt &p) const { return rect.In(p); } + + int width; + long fill,outln; +public: +}; + + +class GuiRect: + public GuiSingle +{ + friend class GuiGroup; + + GuiRect(Canvas *c = NULL,GuiGroup *p = NULL,const t_symbol *s = NULL): GuiSingle(c,p,s) {} + GuiObj &Set(int x,int y,int xsz,int ysz,int width = -1,long outl = -1); + virtual GuiObj &Draw(); + + virtual bool In(const Pnt &p) const { return rect.In(p); } + + int width; + long outln; +public: +}; + + +class GuiLine: + public GuiSingle +{ + friend class GuiGroup; + + GuiLine(Canvas *c = NULL,GuiGroup *p = NULL,const t_symbol *s = NULL): GuiSingle(c,p,s) {} + GuiObj &Set(int x1,int y1,int x2,int y2,int width = -1,long fill = -1); + virtual GuiObj &Draw(); + + int width; + long fill; + Pnt p1,p2; +public: +}; + + +class GuiPoly: + public GuiSingle +{ + friend class GuiGroup; + + GuiPoly(Canvas *c = NULL,GuiGroup *p = NULL,const t_symbol *s = NULL): GuiSingle(c,p,s),pnt(NULL) {} + GuiObj &Set(int n,const Pnt *p,int width = -1,long fill = -1); + virtual GuiObj &Draw(); + virtual GuiObj &Delete(); + + int width; + long fill; + int pnts; + Pnt *pnt; +public: +}; + + +class GuiText: + public GuiSingle +{ + friend class GuiGroup; +public: + enum just_t { none = -1,left = 0,right,center }; +protected: + GuiText(Canvas *c = NULL,GuiGroup *p = NULL,const t_symbol *s = NULL): GuiSingle(c,p,s) {} + GuiObj &Set(int x,int y,const char *txt = NULL,long fill = -1,just_t just = none); + virtual GuiObj &Draw(); + + just_t just; + long fill; +}; + + +class GuiGroup: + public GuiObj +{ + friend class flext_gui; +public: + GuiGroup(Canvas *c,GuiGroup *p = NULL); + ~GuiGroup(); + + virtual GuiSingle *Find(const t_symbol *s); + virtual GuiObj &MoveRel(int dx,int dy); + + void Clear(); + void Add(GuiObj *o,bool own = true); + GuiSingle *Detach(const t_symbol *s); + + virtual GuiObj &Draw(); + + GuiGroup *Add_Group(); + GuiSingle *Add_Point(int x,int y,long fill = -1); + inline GuiSingle *Add_Point(const Pnt &p,long fill = -1) { return Add_Point(p.X(),p.Y(),fill); } + GuiSingle *Add_Cloud(int n,const Pnt *p,long fill = -1); + GuiSingle *Add_Box(int x,int y,int xsz,int ysz,int width = -1,long fill = -1,long outl = -1); + GuiSingle *Add_Rect(int x,int y,int xsz,int ysz,int width = -1,long outl = -1); + GuiSingle *Add_Line(int x1,int y1,int x2,int y2,int width = -1,long fill = -1); + inline GuiSingle *Add_Line(const Pnt &p1,const Pnt &p2,int width = -1,long fill = -1) { return Add_Line(p1.X(),p1.Y(),p2.X(),p2.Y(),width,fill); } + GuiSingle *Add_Poly(int n,const Pnt *p,int width = -1,long fill = -1); + GuiSingle *Add_Text(int x,int y,const char *txt,long fill = -1,GuiText::just_t just = GuiText::none); + inline GuiSingle *Add_Text(const Pnt &p,const char *txt,long fill = -1,GuiText::just_t just = GuiText::none) { return Add_Text(p.X(),p.Y(),txt,fill,just); } + + GuiSingle *Remove(GuiSingle *obj); + +protected: +#ifdef PD + void AddTag(GuiObj *o); + void RemoveTag(GuiObj *o); +#endif + + virtual GuiObj &Delete(); + + class Part + { + public: + Part(GuiObj *o,bool own = true): obj(o),owner(own),nxt(NULL) {} + + GuiObj *obj; + bool owner; + Part *nxt; + } *head,*tail; + + virtual bool Method(flext_gui &g,const flext_gui::CBParams &p); +}; + +#endif diff --git a/externals/grill/guitest/guitest.dsp b/externals/grill/guitest/guitest.dsp new file mode 100644 index 00000000..e7dcf20e --- /dev/null +++ b/externals/grill/guitest/guitest.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="guitest" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=guitest - Win32 Debug +!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "guitest.mak". +!MESSAGE +!MESSAGE Sie knnen beim Ausfhren von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "guitest.mak" CFG="guitest - Win32 Debug" +!MESSAGE +!MESSAGE Fr die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "guitest - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "guitest - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "max/guitest" +# PROP Scc_LocalPath "." +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "guitest - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "msvc\r" +# PROP Intermediate_Dir "msvc\r" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GUITEST_EXPORTS" /YX /FD /c +# ADD CPP /nologo /W3 /GR /O2 /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext\source" /I "F:\prog\packs\wxwindows-2.3.2\include" /I "F:\prog\packs\wxwindows-2.3.2\lib\mswdll" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /YX /FD /c +# SUBTRACT CPP /Fr +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib /nologo /dll /machine:I386 /libpath:"c:\programme\audio\pd\bin" /libpath:"f:\prog\max\flext\pd-msvc" /libpath:"F:\prog\packs\wxwindows-2.2.9\lib" + +!ELSEIF "$(CFG)" == "guitest - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "msvc\d" +# PROP Intermediate_Dir "msvc\d" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GUITEST_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GR /ZI /Od /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext\source" /I "F:\prog\packs\wxwindows-2.3.2\include" /I "F:\prog\packs\wxwindows-2.3.2\lib\mswdlld" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "_DEBUG" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib pd.lib flext_d-pdwin.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:\programme\audio\pd\bin" /libpath:"f:\prog\max\flext\pd-msvc" /libpath:"F:\prog\packs\wxwindows-2.3.2\lib" + +!ENDIF + +# Begin Target + +# Name "guitest - Win32 Release" +# Name "guitest - Win32 Debug" +# Begin Source File + +SOURCE=.\flgui.cpp +# End Source File +# Begin Source File + +SOURCE=.\flgui.h +# End Source File +# Begin Source File + +SOURCE=.\flguiobj.cpp +# End Source File +# Begin Source File + +SOURCE=.\flguiobj.h +# End Source File +# Begin Source File + +SOURCE=.\main.cpp +# End Source File +# End Target +# End Project diff --git a/externals/grill/guitest/main.cpp b/externals/grill/guitest/main.cpp new file mode 100644 index 00000000..775a206b --- /dev/null +++ b/externals/grill/guitest/main.cpp @@ -0,0 +1,152 @@ +#include "flgui.h" +#include "flguiobj.h" + +#include +/* +#include +#include +#include +*/ + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 303) +#error You need at least flext version 0.3.3 +#endif + + +#define V void +#define I int +#define C char +#define BL bool +#define L long +#define UL unsigned long + +class guitest: +public flext_gui,virtual public flext_base +{ + FLEXT_HEADER(guitest,flext_gui) + +public: + guitest(I argc,t_atom *argv); + ~guitest(); + + virtual void m_bang() + { + post("%s - bang!",thisName()); + } + +protected: + + virtual void g_Create(); + virtual void g_Edit(bool selected); + + static bool g_Motion(flext_gui &g,GuiSingle &obj,const CBParams &p); + static bool g_MouseKey(flext_gui &g,GuiSingle &obj,const CBParams &p); + static bool g_Key(flext_gui &g,GuiSingle &obj,const CBParams &p); + + virtual void g_Properties(); + virtual void g_Save(t_binbuf *b); + +private: + FLEXT_CALLBACK(m_bang); +}; + +FLEXT_NEW_V("guitest",guitest) + + +void guitest::g_Create() +{ + GuiSingle *frame = Group().Add_Box(0,0,XSize(),YSize(),-1,0xE0E0E0); + frame->Symbol("rect1"); + GuiSingle *wave = Group().Add_Box(8,10,XSize()-16,YSize()-11,0,0x4040FF); + Group().Add_Text(1,1,"Hula",-1); + + I n = XSize()-16; + Pnt *p = new Pnt[n]; + for(int i = 0; i < n; ++i) { + p[i](8+i,10+rand()%(YSize()-11)); + } + Group().Add_Poly(n,p,-1,0xC0C0C0); + delete[] p; + + if(!BindEvent(*frame,g_Motion,evMotion)) post("Motion not supported"); + if(!BindEvent(*wave,g_MouseKey,evMouseDown)) post("MouseDown not supported"); + if(!BindEvent(*wave,g_MouseKey,evKeyDown)) post("KeyDown not supported"); + if(!BindEvent(*wave,g_MouseKey,evKeyUp)) post("KeyUp not supported"); +} + +void guitest::g_Properties() +{ + post("properties"); +} + +void guitest::g_Save(t_binbuf *b) +{ + post("save"); +#ifdef PD + binbuf_addv(b, "ssiis;", gensym("#X"),gensym("obj"), + (t_int)XLo(), (t_int)YLo(),MakeSymbol(thisName()) + // here the arguments + ); +#else +#endif +} + +void guitest::g_Edit(bool selected) +{ + post("select is=%d", selected); + + GuiSingle *obj = Group().Find(MakeSymbol("rect1")); + if(obj) + obj->Outline(selected?0xFF0000:0x000000); + else + post("obj not found"); +} + +bool guitest::g_Motion(flext_gui &g,GuiSingle &obj,const CBParams &p) +{ + if(p.kind == evMotion) { + post("Motion %s x:%i y:%i mod:%i",GetString(obj.Id()),p.pMotion.x,p.pMotion.y,p.pMotion.mod); + } + else + post("Motion"); + return true; +} + +bool guitest::g_MouseKey(flext_gui &g,GuiSingle &obj,const CBParams &p) +{ + if(p.kind == evMouseDown) { + post("MouseDown %s x:%i y:%i b:%i mod:%i",GetString(obj.Id()),p.pMouseKey.x,p.pMouseKey.y,p.pMouseKey.b,p.pMouseKey.mod); + } + else if(p.kind == evKeyDown) { + post("KeyDown %s asc:%i key:%i mod:%i",GetString(obj.Id()),p.pKey.a,p.pKey.k,p.pKey.mod); + } + else if(p.kind == evKeyUp) { + post("KeyUp %s asc:%i key:%i mod:%i",GetString(obj.Id()),p.pKey.a,p.pKey.k,p.pKey.mod); + } + return true; +} + +bool guitest::g_Key(flext_gui &g,GuiSingle &obj,const CBParams &p) +{ + post("Key"); + return true; +} + + + + + +guitest::guitest(I argc,t_atom *argv): + flext_gui(400,100) +{ + AddInAnything(); + AddOutInt(2); + + FLEXT_ADDBANG(0,m_bang); +} + +guitest::~guitest() +{ +} + + diff --git a/externals/grill/pool/main.cpp b/externals/grill/pool/main.cpp new file mode 100644 index 00000000..5d0cef10 --- /dev/null +++ b/externals/grill/pool/main.cpp @@ -0,0 +1,905 @@ +/* + +pool - hierarchical storage object for PD and Max/MSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "pool.h" + +class pool: + public flext_base +{ + FLEXT_HEADER_S(pool,flext_base,setup) + +public: + pool(I argc,const A *argv); + ~pool(); + + static V setup(t_class *); + + pooldata *Pool() { return pl; } + +protected: + + // switch to other pool + V m_pool(I argc,const A *argv); + + // clear all data in pool + V m_reset(); + + // output absolute directory paths? + V m_absdir(BL abs) { absdir = abs; } + // always output current directory + V m_echodir(BL e) { echo = e; } + + // handle directories + V m_getdir(); + + V m_mkdir(I argc,const A *argv,BL abs = true); // make and change to dir + V m_chdir(I argc,const A *argv,BL abs = true); // change to dir + V m_rmdir(I argc,const A *argv,BL abs = true); // remove dir + V m_updir(I argc,const A *argv); // one or more levels up + + V m_mksub(I argc,const A *argv) { m_mkdir(argc,argv,false); } + V m_chsub(I argc,const A *argv) { m_chdir(argc,argv,false); } + V m_rmsub(I argc,const A *argv) { m_rmdir(argc,argv,false); } + + // handle data + V m_set(I argc,const A *argv) { set(MakeSymbol("set"),argc,argv,true); } + V m_add(I argc,const A *argv) { set(MakeSymbol("add"),argc,argv,false); } + V m_clr(I argc,const A *argv); + V m_clrall(); // only values + V m_clrrec(); // also subdirectories + V m_clrsub(); // only subdirectories + V m_get(I argc,const A *argv); + V m_getall(); // only values + V m_getrec(I argc,const A *argv); // also subdirectories + V m_getsub(I argc,const A *argv); // only subdirectories + V m_cntall(); // only values + V m_cntrec(I argc,const A *argv); // also subdirectories + V m_cntsub(I argc,const A *argv); // only subdirectories + + // cut/copy/paste + V m_paste(I argc,const A *argv) { paste(MakeSymbol("paste"),argc,argv,true); } // paste contents of clipboard + V m_pasteadd(I argc,const A *argv) { paste(MakeSymbol("pasteadd"),argc,argv,false); } // paste but don't replace + V m_clrclip(); // clear clipboard + V m_cut(I argc,const A *argv) { copy(MakeSymbol("cut"),argc,argv,true); } // cut value into clipboard + V m_copy(I argc,const A *argv) { copy(MakeSymbol("copy"),argc,argv,false); } // copy value into clipboard + V m_cutall() { copyall(MakeSymbol("cutall"),true,0); } // cut all values in current directory into clipboard + V m_copyall() { copyall(MakeSymbol("copyall"),false,0); } // copy all values in current directory into clipboard + V m_cutrec(I argc,const A *argv) { copyrec(MakeSymbol("cutrec"),argc,argv,true); } // cut directory (and subdirs) into clipboard + V m_copyrec(I argc,const A *argv) { copyrec(MakeSymbol("copyrec"),argc,argv,false); } // cut directory (and subdirs) into clipboard + + // load/save from/to file + V m_load(I argc,const A *argv); + V m_save(I argc,const A *argv); + + // load directories + V m_lddir(I argc,const A *argv); // load values into current dir + V m_ldrec(I argc,const A *argv); // load values recursively + + // save directories + V m_svdir(I argc,const A *argv); // save values in current dir + V m_svrec(I argc,const A *argv); // save values recursively + +private: + static BL KeyChk(const A &a); + static BL ValChk(I argc,const A *argv); + static BL ValChk(const AtomList &l) { return ValChk(l.Count(),l.Atoms()); } + V ToOutAtom(I ix,const A &a); + + V set(const S *tag,I argc,const A *argv,BL over); + V getdir(const S *tag); + I getrec(const S *tag,I level,BL cntonly = false,const AtomList &rdir = AtomList()); + I getsub(const S *tag,I level,BL cntonly = false,const AtomList &rdir = AtomList()); + + V paste(const S *tag,I argc,const A *argv,BL repl); + V copy(const S *tag,I argc,const A *argv,BL cut); + V copyall(const S *tag,BL cut,I lvls); + V copyrec(const S *tag,I argc,const A *argv,BL cut); + + V echodir() { if(echo) getdir(MakeSymbol("echo")); } + + BL priv,absdir,echo; + pooldata *pl; + AtomList curdir; + pooldir *clip; + + static pooldata *head,*tail; + + V SetPool(const S *s); + V FreePool(); + + static pooldata *GetPool(const S *s); + static V RmvPool(pooldata *p); + + FLEXT_CALLBACK_V(m_pool) + FLEXT_CALLBACK(m_reset) + FLEXT_CALLBACK_B(m_absdir) + FLEXT_CALLBACK_B(m_echodir) + FLEXT_CALLBACK(m_getdir) + FLEXT_CALLBACK_V(m_mkdir) + FLEXT_CALLBACK_V(m_chdir) + FLEXT_CALLBACK_V(m_updir) + FLEXT_CALLBACK_V(m_rmdir) + FLEXT_CALLBACK_V(m_mksub) + FLEXT_CALLBACK_V(m_chsub) + FLEXT_CALLBACK_V(m_rmsub) + + FLEXT_CALLBACK_V(m_set) + FLEXT_CALLBACK_V(m_add) + FLEXT_CALLBACK_V(m_clr) + FLEXT_CALLBACK(m_clrall) + FLEXT_CALLBACK(m_clrrec) + FLEXT_CALLBACK(m_clrsub) + FLEXT_CALLBACK_V(m_get) + FLEXT_CALLBACK(m_getall) + FLEXT_CALLBACK_V(m_getrec) + FLEXT_CALLBACK_V(m_getsub) + FLEXT_CALLBACK(m_cntall) + FLEXT_CALLBACK_V(m_cntrec) + FLEXT_CALLBACK_V(m_cntsub) + + FLEXT_CALLBACK_V(m_paste) + FLEXT_CALLBACK_V(m_pasteadd) + FLEXT_CALLBACK(m_clrclip) + FLEXT_CALLBACK_V(m_copy) + FLEXT_CALLBACK_V(m_cut) + FLEXT_CALLBACK(m_copyall) + FLEXT_CALLBACK(m_cutall) + FLEXT_CALLBACK_V(m_copyrec) + FLEXT_CALLBACK_V(m_cutrec) + + FLEXT_CALLBACK_V(m_load) + FLEXT_CALLBACK_V(m_save) + FLEXT_CALLBACK_V(m_lddir) + FLEXT_CALLBACK_V(m_ldrec) + FLEXT_CALLBACK_V(m_svdir) + FLEXT_CALLBACK_V(m_svrec) +}; + +FLEXT_NEW_V("pool",pool); + + +pooldata *pool::head,*pool::tail; + + +V pool::setup(t_class *) +{ + post(""); + post("pool %s - hierarchical storage object, (C)2002 Thomas Grill",POOL_VERSION); + post(""); + + head = tail = NULL; +} + +pool::pool(I argc,const A *argv): + absdir(true),echo(false),pl(NULL), + clip(NULL) +{ + SetPool(argc >= 1 && IsSymbol(argv[0])?GetSymbol(argv[0]):NULL); + + AddInAnything(); + AddOutList(); + AddOutAnything(); + AddOutList(); + AddOutAnything(); + + FLEXT_ADDMETHOD_(0,"set",m_set); + FLEXT_ADDMETHOD_(0,"add",m_add); + FLEXT_ADDMETHOD_(0,"reset",m_reset); + FLEXT_ADDMETHOD_(0,"absdir",m_absdir); + FLEXT_ADDMETHOD_(0,"echodir",m_echodir); + FLEXT_ADDMETHOD_(0,"getdir",m_getdir); + FLEXT_ADDMETHOD_(0,"mkdir",m_mkdir); + FLEXT_ADDMETHOD_(0,"chdir",m_chdir); + FLEXT_ADDMETHOD_(0,"rmdir",m_rmdir); + FLEXT_ADDMETHOD_(0,"updir",m_updir); + FLEXT_ADDMETHOD_(0,"mksub",m_mksub); + FLEXT_ADDMETHOD_(0,"chsub",m_chsub); + FLEXT_ADDMETHOD_(0,"rmsub",m_rmsub); + + FLEXT_ADDMETHOD_(0,"set",m_set); + FLEXT_ADDMETHOD_(0,"clr",m_clr); + FLEXT_ADDMETHOD_(0,"clrall",m_clrall); + FLEXT_ADDMETHOD_(0,"clrrec",m_clrrec); + FLEXT_ADDMETHOD_(0,"clrsub",m_clrsub); + FLEXT_ADDMETHOD_(0,"get",m_get); + FLEXT_ADDMETHOD_(0,"getall",m_getall); + FLEXT_ADDMETHOD_(0,"getrec",m_getrec); + FLEXT_ADDMETHOD_(0,"getsub",m_getsub); + FLEXT_ADDMETHOD_(0,"cntall",m_cntall); + FLEXT_ADDMETHOD_(0,"cntrec",m_cntrec); + FLEXT_ADDMETHOD_(0,"cntsub",m_cntsub); + + FLEXT_ADDMETHOD_(0,"paste",m_paste); + FLEXT_ADDMETHOD_(0,"pasteadd",m_pasteadd); + FLEXT_ADDMETHOD_(0,"clrclip",m_clrclip); + FLEXT_ADDMETHOD_(0,"cut",m_cut); + FLEXT_ADDMETHOD_(0,"copy",m_copy); + FLEXT_ADDMETHOD_(0,"cutall",m_cutall); + FLEXT_ADDMETHOD_(0,"copyall",m_copyall); + FLEXT_ADDMETHOD_(0,"cutrec",m_cutrec); + FLEXT_ADDMETHOD_(0,"copyrec",m_copyrec); + + FLEXT_ADDMETHOD_(0,"load",m_load); + FLEXT_ADDMETHOD_(0,"save",m_save); + FLEXT_ADDMETHOD_(0,"lddir",m_lddir); + FLEXT_ADDMETHOD_(0,"ldrec",m_ldrec); + FLEXT_ADDMETHOD_(0,"svdir",m_svdir); + FLEXT_ADDMETHOD_(0,"svrec",m_svrec); +} + +pool::~pool() +{ + FreePool(); +} + +V pool::SetPool(const S *s) +{ + if(pl) FreePool(); + + if(s) { + priv = false; + pl = GetPool(s); + } + else { + priv = true; + pl = new pooldata; + } +} + +V pool::FreePool() +{ + curdir(); // reset current directory + + if(pl) { + if(!priv) + RmvPool(pl); + else + delete pl; + pl = NULL; + } + + if(clip) { delete clip; clip = NULL; } +} + +V pool::m_pool(I argc,const A *argv) +{ + const S *s = NULL; + if(argc > 0) { + if(argc > 1) post("%s - pool: superfluous arguments ignored",thisName()); + s = GetASymbol(argv[0]); + if(!s) post("%s - pool: invalid pool name, pool set to private",thisName()); + } + + SetPool(s); +} + +V pool::m_reset() +{ + pl->Reset(); +} + + +V pool::getdir(const S *tag) +{ + ToOutAnything(3,tag,0,NULL); + ToOutList(2,curdir); +} + +V pool::m_getdir() { getdir(MakeSymbol("getdir")); } + +V pool::m_mkdir(I argc,const A *argv,BL abs) +{ + if(!ValChk(argc,argv)) + post("%s - mkdir: invalid directory name",thisName()); + else { + AtomList ndir; + if(abs) ndir(argc,argv); + else (ndir = curdir).Append(argc,argv); + if(!pl->MkDir(ndir)) { + post("%s - mkdir: directory couldn't be created",thisName()); + } + } + + echodir(); +} + +V pool::m_chdir(I argc,const A *argv,BL abs) +{ + if(!ValChk(argc,argv)) + post("%s - chdir: invalid directory name",thisName()); + else { + AtomList prv(curdir); + if(abs) curdir(argc,argv); + else curdir.Append(argc,argv); + if(!pl->ChkDir(curdir)) { + post("%s - chdir: directory couldn't be changed",thisName()); + curdir = prv; + } + } + + echodir(); +} + +V pool::m_updir(I argc,const A *argv) +{ + I lvls = 1; + if(argc > 0) { + if(CanbeInt(argv[0])) { + if(argc > 1) + post("%s - updir: superfluous arguments ignored",thisName()); + lvls = GetAInt(argv[0]); + if(lvls < 0) + post("%s - updir: invalid level specification - set to 1",thisName()); + } + else + post("%s - updir: invalid level specification - set to 1",thisName()); + } + + AtomList prv(curdir); + + if(lvls > curdir.Count()) { + post("%s - updir: level exceeds directory depth - corrected",thisName()); + curdir(); + } + else + curdir.Part(0,curdir.Count()-lvls); + + if(!pl->ChkDir(curdir)) { + post("%s - updir: directory couldn't be changed",thisName()); + curdir = prv; + } + + echodir(); +} + +V pool::m_rmdir(I argc,const A *argv,BL abs) +{ + if(abs) curdir(argc,argv); + else curdir.Append(argc,argv); + + if(!pl->RmDir(curdir)) + post("%s - rmdir: directory couldn't be removed",thisName()); + curdir(); + + echodir(); +} + +V pool::set(const S *tag,I argc,const A *argv,BL over) +{ + if(!argc || !KeyChk(argv[0])) + post("%s - %s: invalid key",thisName(),GetString(tag)); + else if(!ValChk(argc-1,argv+1)) { + post("%s - %s: invalid data values",thisName(),GetString(tag)); + } + else + if(!pl->Set(curdir,argv[0],new AtomList(argc-1,argv+1),over)) + post("%s - %s: value couldn't be set",thisName(),GetString(tag)); + + echodir(); +} + +V pool::m_clr(I argc,const A *argv) +{ + if(!argc || !KeyChk(argv[0])) + post("%s - clr: invalid key",thisName()); + else { + if(argc > 1) + post("%s - clr: superfluous arguments ignored",thisName()); + + if(!pl->Clr(curdir,argv[0])) + post("%s - clr: value couldn't be cleared",thisName()); + } + + echodir(); +} + +V pool::m_clrall() +{ + if(!pl->ClrAll(curdir,false)) + post("%s - clrall: values couldn't be cleared",thisName()); + + echodir(); +} + +V pool::m_clrrec() +{ + if(!pl->ClrAll(curdir,true)) + post("%s - clrrec: values couldn't be cleared",thisName()); + + echodir(); +} + +V pool::m_clrsub() +{ + if(!pl->ClrAll(curdir,true,true)) + post("%s - clrsub: directories couldn't be cleared",thisName()); + + echodir(); +} + +V pool::m_get(I argc,const A *argv) +{ + if(!argc || !KeyChk(argv[0])) + post("%s - get: invalid key",thisName()); + else { + if(argc > 1) + post("%s - get: superfluous arguments ignored",thisName()); + + AtomList *r = pl->Get(curdir,argv[0]); + + ToOutAnything(3,MakeSymbol("get"),0,NULL); + if(absdir) + ToOutList(2,curdir); + else + ToOutList(2,0,NULL); + ToOutAtom(1,argv[0]); + if(r) { + ToOutList(0,*r); + delete r; + } + else + ToOutBang(0); + } + + echodir(); +} + +I pool::getrec(const S *tag,I level,BL cntonly,const AtomList &rdir) +{ + AtomList gldir(curdir); + gldir.Append(rdir); + + I ret = 0; + + if(cntonly) + ret = pl->CntAll(gldir); + else { + A *k; + AtomList *r; + I cnt = pl->GetAll(gldir,k,r); + if(!k) + post("%s - %s: error retrieving values",thisName(),GetString(tag)); + else { + for(I i = 0; i < cnt; ++i) { + ToOutAnything(3,tag,0,NULL); + ToOutList(2,absdir?gldir:rdir); + ToOutAtom(1,k[i]); + ToOutList(0,r[i]); + } + delete[] k; + delete[] r; + } + ret = cnt; + } + + if(level != 0) { + const A **r; + I cnt = pl->GetSub(gldir,r); + if(!r) + post("%s - %s: error retrieving directories",thisName(),GetString(tag)); + else { + I lv = level > 0?level-1:-1; + for(I i = 0; i < cnt; ++i) { + ret += getrec(tag,lv,cntonly,AtomList(rdir).Append(*r[i])); + } + delete[] r; + } + } + + return ret; +} + +V pool::m_getall() +{ + getrec(MakeSymbol("getall"),0); + ToOutBang(3); + + echodir(); +} + +V pool::m_getrec(I argc,const A *argv) +{ + I lvls = -1; + if(argc > 0) { + if(CanbeInt(argv[0])) { + if(argc > 1) + post("%s - getrec: superfluous arguments ignored",thisName()); + lvls = GetAInt(argv[0]); + } + else + post("%s - getrec: invalid level specification - set to infinite",thisName()); + } + getrec(MakeSymbol("getrec"),lvls); + ToOutBang(3); + + echodir(); +} + + +I pool::getsub(const S *tag,I level,BL cntonly,const AtomList &rdir) +{ + AtomList gldir(curdir); + gldir.Append(rdir); + + I ret = 0; + + const A **r; + I cnt = pl->GetSub(gldir,r); + if(!r) + post("%s - %s: error retrieving directories",thisName(),GetString(tag)); + else { + I lv = level > 0?level-1:-1; + for(I i = 0; i < cnt; ++i) { + AtomList ndir(absdir?gldir:rdir); + ndir.Append(*r[i]); + + if(!cntonly) { + ToOutAnything(3,tag,0,NULL); + ToOutList(2,curdir); + ToOutList(1,ndir); + } + + if(level != 0) + ret += getsub(tag,lv,cntonly,AtomList(rdir).Append(*r[i])); + } + delete[] r; + } + + return ret; +} + +V pool::m_getsub(I argc,const A *argv) +{ + I lvls = 0; + if(argc > 0) { + if(CanbeInt(argv[0])) { + if(argc > 1) + post("%s - getsub: superfluous arguments ignored",thisName()); + lvls = GetAInt(argv[0]); + } + else + post("%s - getsub: invalid level specification - set to 0",thisName()); + } + + getsub(MakeSymbol("getsub"),lvls); + ToOutBang(3); + + echodir(); +} + + +V pool::m_cntall() +{ + const S *tag = MakeSymbol("cntall"); + I cnt = getrec(tag,0,true); + ToOutSymbol(3,tag); + ToOutBang(2); + ToOutBang(1); + ToOutInt(0,cnt); + + echodir(); +} + +V pool::m_cntrec(I argc,const A *argv) +{ + const S *tag = MakeSymbol("cntrec"); + + I lvls = -1; + if(argc > 0) { + if(CanbeInt(argv[0])) { + if(argc > 1) + post("%s - %s: superfluous arguments ignored",thisName(),GetString(tag)); + lvls = GetAInt(argv[0]); + } + else + post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(tag)); + } + + I cnt = getrec(tag,lvls,true); + ToOutSymbol(3,tag); + ToOutBang(2); + ToOutBang(1); + ToOutInt(0,cnt); + + echodir(); +} + + +V pool::m_cntsub(I argc,const A *argv) +{ + const S *tag = MakeSymbol("cntsub"); + + I lvls = 0; + if(argc > 0) { + if(CanbeInt(argv[0])) { + if(argc > 1) + post("%s - %s: superfluous arguments ignored",thisName(),GetString(tag)); + lvls = GetAInt(argv[0]); + } + else + post("%s - %s: invalid level specification - set to 0",thisName(),GetString(tag)); + } + + I cnt = getsub(tag,lvls,true); + ToOutSymbol(3,tag); + ToOutBang(2); + ToOutBang(1); + ToOutInt(0,cnt); + + echodir(); +} + + +V pool::paste(const S *tag,I argc,const A *argv,BL repl) +{ + if(clip) { + BL mkdir = true; + I depth = -1; + + if(argc >= 1) { + if(CanbeInt(argv[0])) depth = GetAInt(argv[1]); + else + post("%s - %s: invalid depth argument - set to -1",thisName(),GetString(tag)); + + if(argc >= 2) { + if(CanbeBool(argv[1])) mkdir = GetABool(argv[1]); + else + post("%s - %s: invalid mkdir argument - set to true",thisName(),GetString(tag)); + + if(argc > 2) post("%s - %s: superfluous arguments ignored",thisName(),GetString(tag)); + } + } + + pl->Paste(curdir,clip,depth,repl,mkdir); + } + else + post("%s - %s: clipboard is empty",thisName(),GetString(tag)); + + echodir(); +} + + +V pool::m_clrclip() +{ + if(clip) { delete clip; clip = NULL; } +} + + +V pool::copy(const S *tag,I argc,const A *argv,BL cut) +{ + if(!argc || !KeyChk(argv[0])) + post("%s - %s: invalid key",thisName(),GetString(tag)); + else { + if(argc > 1) + post("%s - %s: superfluous arguments ignored",thisName(),GetString(tag)); + + m_clrclip(); + clip = pl->Copy(curdir,argv[0],cut); + + if(!clip) + post("%s - %s: Copying into clipboard failed",thisName(),GetString(tag)); + } + + echodir(); +} + + +V pool::copyall(const S *tag,BL cut,I depth) +{ + m_clrclip(); + clip = pl->CopyAll(curdir,depth,cut); + + if(!clip) + post("%s - %s: Copying into clipboard failed",thisName(),GetString(tag)); + + echodir(); +} + + +V pool::copyrec(const S *tag,I argc,const A *argv,BL cut) +{ + I lvls = -1; + if(argc > 0) { + if(CanbeInt(argv[0])) { + if(argc > 1) + post("%s - %s: superfluous arguments ignored",thisName(),GetString(tag)); + lvls = GetAInt(argv[0]); + } + else + post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(tag)); + } + + copyall(tag,cut,lvls); +} + +V pool::m_load(I argc,const A *argv) +{ + const C *flnm = NULL; + if(argc > 0) { + if(argc > 1) post("%s - load: superfluous arguments ignored",thisName()); + if(IsString(argv[0])) flnm = GetString(argv[0]); + } + + if(!flnm) + post("%s - load: no filename given",thisName()); + else if(!pl->Load(flnm)) + post("%s - load: error loading data",thisName()); + + echodir(); +} + +V pool::m_save(I argc,const A *argv) +{ + const C *flnm = NULL; + if(argc > 0) { + if(argc > 1) post("%s - save: superfluous arguments ignored",thisName()); + if(IsString(argv[0])) flnm = GetString(argv[0]); + } + + if(!flnm) + post("%s - save: no filename given",thisName()); + else if(!pl->Save(flnm)) + post("%s - save: error saving data",thisName()); + + echodir(); +} + +V pool::m_lddir(I argc,const A *argv) +{ + const C *flnm = NULL; + if(argc > 0) { + if(argc > 1) post("%s - lddir: superfluous arguments ignored",thisName()); + if(IsString(argv[0])) flnm = GetString(argv[0]); + } + + if(!flnm) + post("%s - lddir: invalid filename",thisName()); + else { + if(!pl->LdDir(curdir,flnm,0)) + post("%s - lddir: directory couldn't be loaded",thisName()); + } + + echodir(); +} + +V pool::m_ldrec(I argc,const A *argv) +{ + const C *flnm = NULL; + I depth = -1; + BL mkdir = true; + if(argc >= 1) { + if(IsString(argv[0])) flnm = GetString(argv[0]); + + if(argc >= 2) { + if(CanbeInt(argv[1])) depth = GetAInt(argv[1]); + else + post("%s - ldrec: invalid depth argument - set to -1",thisName()); + + if(argc >= 3) { + if(CanbeBool(argv[2])) mkdir = GetABool(argv[2]); + else + post("%s - ldrec: invalid mkdir argument - set to true",thisName()); + + if(argc > 3) post("%s - ldrec: superfluous arguments ignored",thisName()); + } + } + } + + if(!flnm) + post("%s - ldrec: invalid filename",thisName()); + else { + if(!pl->LdDir(curdir,flnm,depth,mkdir)) + post("%s - ldrec: directory couldn't be saved",thisName()); + } + + echodir(); +} + +V pool::m_svdir(I argc,const A *argv) +{ + const C *flnm = NULL; + if(argc > 0) { + if(argc > 1) post("%s - svdir: superfluous arguments ignored",thisName()); + if(IsString(argv[0])) flnm = GetString(argv[0]); + } + + if(!flnm) + post("%s - svdir: invalid filename",thisName()); + else { + if(!pl->SvDir(curdir,flnm,0,absdir)) + post("%s - svdir: directory couldn't be saved",thisName()); + } + + echodir(); +} + +V pool::m_svrec(I argc,const A *argv) +{ + const C *flnm = NULL; + if(argc > 0) { + if(argc > 1) post("%s - svrec: superfluous arguments ignored",thisName()); + if(IsString(argv[0])) flnm = GetString(argv[0]); + } + + if(!flnm) + post("%s - svrec: invalid filename",thisName()); + else { + if(!pl->SvDir(curdir,flnm,-1,absdir)) + post("%s - svrec: directory couldn't be saved",thisName()); + } + + echodir(); +} + + + +BL pool::KeyChk(const t_atom &a) +{ + return IsSymbol(a) || IsFloat(a) || IsInt(a); +} + +BL pool::ValChk(I argc,const t_atom *argv) +{ + for(I i = 0; i < argc; ++i) { + const t_atom &a = argv[i]; + if(!IsSymbol(a) && !IsFloat(a) && !IsInt(a)) return false; + } + return true; +} + +V pool::ToOutAtom(I ix,const t_atom &a) +{ + if(IsSymbol(a)) + ToOutSymbol(ix,GetSymbol(a)); + else if(IsFloat(a)) + ToOutFloat(ix,GetFloat(a)); + else if(IsInt(a)) + ToOutInt(ix,GetInt(a)); + else + post("%s - output atom: type not supported!",thisName()); +} + + + +pooldata *pool::GetPool(const S *s) +{ + pooldata *pi = head; + for(; pi && pi->sym != s; pi = pi->nxt) (V)0; + + if(pi) { + pi->Push(); + return pi; + } + else { + pooldata *p = new pooldata(s); + p->Push(); + + // now add to chain + if(head) head->nxt = p; + else head = p; + tail = p; + return p; + } +} + +V pool::RmvPool(pooldata *p) +{ + pooldata *prv = NULL,*pi = head; + for(; pi && pi != p; prv = pi,pi = pi->nxt) (V)0; + + if(pi && !pi->Pop()) { + if(prv) prv->nxt = pi->nxt; + else head = pi->nxt; + if(!pi->nxt) tail = pi; + + delete pi; + } +} + diff --git a/externals/grill/pool/pool.cpp b/externals/grill/pool/pool.cpp new file mode 100644 index 00000000..629ab7fb --- /dev/null +++ b/externals/grill/pool/pool.cpp @@ -0,0 +1,645 @@ +/* + +pool - hierarchical storage object for PD and Max/MSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "pool.h" + +#include +#include +#include +#include + + +inline I compare(I a,I b) { return a == b?0:(a < b?-1:1); } +inline I compare(F a,F b) { return a == b?0:(a < b?-1:1); } + +static I compare(const S *a,const S *b) +{ + if(a == b) + return 0; + else + return strcmp(flext::GetString(a),flext::GetString(b)); +} + +static I compare(const A &a,const A &b) +{ + if(a.a_type == b.a_type) { + switch(a.a_type) { + case A_FLOAT: + return compare(a.a_w.w_float,b.a_w.w_float); +#ifdef MAXMSP + case A_LONG: + return compare((I)a.a_w.w_long,(I)b.a_w.w_long); +#endif + case A_SYMBOL: + return compare(a.a_w.w_symbol,b.a_w.w_symbol); +#ifdef PD + case A_POINTER: + return a.a_w.w_gpointer == b.a_w.w_gpointer?0:(a.a_w.w_gpointer < b.a_w.w_gpointer?-1:1); +#endif + default: + LOG("pool - atom comparison: type not handled"); + return -1; + } + } + else + return a.a_type < b.a_type?-1:1; +} + + +poolval::poolval(const A &k,AtomList *d): + data(d),nxt(NULL) +{ + SetAtom(key,k); +} + +poolval::~poolval() +{ + if(data) delete data; + if(nxt) delete nxt; +} + +poolval &poolval::Set(AtomList *d) +{ + if(data) delete data; + data = d; + return *this; +} + +poolval *poolval::Dup() const +{ + return new poolval(key,data?new AtomList(*data):NULL); +} + + +pooldir::pooldir(const A &d): + dirs(NULL),vals(NULL),nxt(NULL) +{ + CopyAtom(&dir,&d); +} + +pooldir::~pooldir() +{ + Clear(true); + if(nxt) delete nxt; +} + +V pooldir::Clear(BL rec,BL dironly) +{ + if(rec && dirs) { delete dirs; dirs = NULL; } + if(!dironly && vals) { delete vals; vals = NULL; } +} + +pooldir *pooldir::AddDir(I argc,const A *argv) +{ + if(!argc) return this; + + I c = 1; + pooldir *prv = NULL,*ix = dirs; + for(; ix; prv = ix,ix = ix->nxt) { + c = compare(argv[0],ix->dir); + if(c <= 0) break; + } + + if(c || !ix) { + pooldir *nd = new pooldir(argv[0]); + nd->nxt = ix; + + if(prv) prv->nxt = nd; + else dirs = nd; + ix = nd; + } + + return ix->AddDir(argc-1,argv+1); +} + +pooldir *pooldir::GetDir(I argc,const A *argv,BL rmv) +{ + if(!argc) return this; + + I c = 1; + pooldir *prv = NULL,*ix = dirs; + for(; ix; prv = ix,ix = ix->nxt) { + c = compare(argv[0],ix->dir); + if(c <= 0) break; + } + + if(c || !ix) + return NULL; + else { + if(argc > 1) + return ix->GetDir(argc-1,argv+1,rmv); + else if(rmv) { + pooldir *nd = ix->nxt; + if(prv) prv->nxt = nd; + else dirs = nd; + ix->nxt = NULL; + return ix; + } + else + return ix; + } +} + +BL pooldir::DelDir(const AtomList &d) +{ + pooldir *pd = GetDir(d,true); + if(pd && pd != this) { + delete pd; + return true; + } + else + return false; +} + +V pooldir::SetVal(const A &key,AtomList *data,BL over) +{ + I c = 1; + poolval *prv = NULL,*ix = vals; + for(; ix; prv = ix,ix = ix->nxt) { + c = compare(key,ix->key); + if(c <= 0) break; + } + + if(c || !ix) { + // no existing data found + + if(data) { + poolval *nv = new poolval(key,data); + nv->nxt = ix; + + if(prv) prv->nxt = nv; + else vals = nv; + } + } + else if(over) { + // data exists... only set if overwriting enabled + + if(data) + ix->Set(data); + else { + poolval *nv = ix->nxt; + if(prv) prv->nxt = nv; + else vals = nv; + ix->nxt = NULL; + delete ix; + } + } +} + +flext::AtomList *pooldir::GetVal(const A &key,BL cut) +{ + I c = 1; + poolval *prv = NULL,*ix = vals; + for(; ix; prv = ix,ix = ix->nxt) { + c = compare(key,ix->key); + if(c <= 0) break; + } + + if(c || !ix) + return NULL; + else { + AtomList *ret; + if(cut) { + poolval *nv = ix->nxt; + if(prv) prv->nxt = nv; + else vals = nv; + ix->nxt = NULL; + ret = ix->data; ix->data = NULL; + delete ix; + } + else + ret = new AtomList(*ix->data); + return ret; + } +} + +I pooldir::CntAll() +{ + I cnt = 0; + poolval *ix = vals; + for(; ix; ix = ix->nxt,++cnt) {} + return cnt; +} + +I pooldir::GetAll(A *&keys,AtomList *&lst,BL cut) +{ + I cnt = CntAll(); + keys = new A[cnt]; + lst = new AtomList[cnt]; + + poolval *ix = vals; + for(I i = 0; ix; ++i) { + SetAtom(keys[i],ix->key); + lst[i] = *ix->data; + + if(cut) { + poolval *t = ix; + vals = ix = ix->nxt; + t->nxt = NULL; delete t; + } + else + ix = ix->nxt; + } + + return cnt; +} + +I pooldir::GetSub(const A **&lst) +{ + I cnt = 0; + pooldir *ix = dirs; + for(; ix; ix = ix->nxt,++cnt) {} + lst = new const A *[cnt]; + + ix = dirs; + for(I i = 0; ix; ix = ix->nxt,++i) { + lst[i] = &ix->dir; + } + + return cnt; +} + + +BL pooldir::Paste(const pooldir *p,I depth,BL repl,BL mkdir) +{ + BL ok = true; + + for(poolval *ix = p->vals; ix; ix = ix->nxt) { + SetVal(ix->key,new AtomList(*ix->data),repl); + } + + if(ok && depth) { + for(pooldir *dix = p->dirs; ok && dix; dix = dix->nxt) { + pooldir *ndir = mkdir?AddDir(1,&dix->dir):GetDir(1,&dix->dir); + if(ndir) { + ok = ndir->Paste(dix,depth > 0?depth-1:depth,repl,mkdir); + } + } + } + + return ok; +} + +BL pooldir::Copy(pooldir *p,I depth,BL cut) +{ + BL ok = true; + + if(cut) { + if(p->vals) + ok = false; + else + p->vals = vals, vals = NULL; + } + else { + // inefficient!! p->SetVal has to search through list unnecessarily!! + for(poolval *ix = vals; ix; ix = ix->nxt) { + p->SetVal(ix->key,new AtomList(*ix->data)); + } + } + + if(ok && depth) { + // also quite inefficient for cut + for(pooldir *dix = dirs; ok && dix; dix = dix->nxt) { + pooldir *ndir = p->AddDir(1,&dix->dir); + if(ndir) + ok = ndir->Copy(dix,depth > 0?depth-1:depth,cut); + else + ok = false; + } + } + + return ok; +} + + +static C *ReadAtom(C *c,A *a) +{ + // skip whitespace + while(*c && isspace(*c)) ++c; + if(!*c) return NULL; + + const C *m = c; // remember position + + // check for word type (s = 0,1,2 ... int,float,symbol) + I s = 0; + for(; *c && !isspace(*c); ++c) { + if(!isdigit(*c)) + s = (*c != '.' || s == 1)?2:1; + } + + if(a) { + switch(s) { + case 0: // integer +#ifdef MAXMSP + a->a_type = A_LONG; + a->a_w.w_long = atol(m); + break; +#endif + case 1: // float + a->a_type = A_FLOAT; + a->a_w.w_float = (F)atof(m); + break; + default: { // anything else is a symbol + C t = *c; *c = 0; + a->a_type = A_SYMBOL; + a->a_w.w_symbol = (S *)flext::MakeSymbol(m); + *c = t; + break; + } + } + } + + return c; +} + +static BL ReadAtoms(istream &is,flext::AtomList &l,C del) +{ + C tmp[1024]; + is.getline(tmp,sizeof tmp,del); + if(is.eof() || !is.good()) return false; + + I i,cnt; + C *t = tmp; + for(cnt = 0; ; ++cnt) { + t = ReadAtom(t,NULL); + if(!t) break; + } + + l(cnt); + if(cnt) { + for(i = 0,t = tmp; i < cnt; ++i) + t = ReadAtom(t,&l[i]); + } + return true; +} + +static V WriteAtom(ostream &os,const A &a) +{ + switch(a.a_type) { + case A_FLOAT: + os << a.a_w.w_float; + break; +#ifdef MAXMSP + case A_LONG: + os << a.a_w.w_long; + break; +#endif + case A_SYMBOL: + os << flext::GetString(a.a_w.w_symbol); + break; + } +} + +static V WriteAtoms(ostream &os,const flext::AtomList &l) +{ + for(I i = 0; i < l.Count(); ++i) { + WriteAtom(os,l[i]); + os << ' '; + } +} + +BL pooldir::LdDir(istream &is,I depth,BL mkdir) +{ + BL r; + for(I i = 1; !is.eof(); ++i) { + AtomList d,k,*v = new AtomList; + r = ReadAtoms(is,d,','); + r = r && ReadAtoms(is,k,',') && k.Count() == 1; + r = r && ReadAtoms(is,*v,'\n') && v->Count(); + + if(r) { + if(depth < 0 || d.Count() <= depth) { + pooldir *nd = mkdir?AddDir(d):GetDir(d); + if(nd) { + nd->SetVal(k[0],v); v = NULL; + } + #ifdef _DEBUG + else + post("pool - directory was not found",i); + #endif + } + } + else if(!is.eof()) + post("pool - format mismatch encountered, skipped line %i",i); + + if(v) delete v; + } + return true; +} + +BL pooldir::SvDir(ostream &os,I depth,const AtomList &dir) +{ + { + for(poolval *ix = vals; ix; ix = ix->nxt) { + WriteAtoms(os,dir); + os << ", "; + WriteAtom(os,ix->key); + os << " , "; + WriteAtoms(os,*ix->data); + os << endl; + } + } + if(depth) { + I nd = depth > 0?depth-1:-1; + for(pooldir *ix = dirs; ix; ix = ix->nxt) { + ix->SvDir(os,nd,AtomList(dir).Append(ix->dir)); + } + } + return true; +} + + + + +pooldata::pooldata(const S *s): + sym(s),nxt(NULL),refs(0), + root(nullatom) +{ + LOG1("new pool %s",sym?flext_base::GetString(sym):""); +} + +pooldata::~pooldata() +{ + LOG1("free pool %s",sym?flext_base::GetString(sym):""); +} + +t_atom pooldata::nullatom = { A_NULL }; + + +V pooldata::Reset() +{ + root.Clear(true); +} + +BL pooldata::MkDir(const AtomList &d) +{ + root.AddDir(d); + return true; +} + +BL pooldata::ChkDir(const AtomList &d) +{ + return root.GetDir(d) != NULL; +} + +BL pooldata::RmDir(const AtomList &d) +{ + return root.DelDir(d); +} + +BL pooldata::Set(const AtomList &d,const A &key,AtomList *data,BL over) +{ + pooldir *pd = root.GetDir(d); + if(!pd) return false; + pd->SetVal(key,data,over); + return true; +} + +BL pooldata::Clr(const AtomList &d,const A &key) +{ + pooldir *pd = root.GetDir(d); + if(!pd) return false; + pd->ClrVal(key); + return true; +} + +BL pooldata::ClrAll(const AtomList &d,BL rec,BL dironly) +{ + pooldir *pd = root.GetDir(d); + if(!pd) return false; + pd->Clear(rec,dironly); + return true; +} + +flext::AtomList *pooldata::Get(const AtomList &d,const A &key) +{ + pooldir *pd = root.GetDir(d); + return pd?pd->GetVal(key):NULL; +} + +I pooldata::CntAll(const AtomList &d) +{ + pooldir *pd = root.GetDir(d); + return pd?pd->CntAll():0; +} + +I pooldata::GetAll(const AtomList &d,A *&keys,AtomList *&lst) +{ + pooldir *pd = root.GetDir(d); + if(pd) + return pd->GetAll(keys,lst); + else { + keys = NULL; lst = NULL; + return 0; + } +} + +I pooldata::GetSub(const AtomList &d,const t_atom **&dirs) +{ + pooldir *pd = root.GetDir(d); + if(pd) + return pd->GetSub(dirs); + else { + dirs = NULL; + return 0; + } +} + + +BL pooldata::Paste(const AtomList &d,const pooldir *clip,I depth,BL repl,BL mkdir) +{ + pooldir *pd = root.GetDir(d); + if(pd) + return pd->Paste(clip,depth,repl,mkdir); + else + return false; +} + +pooldir *pooldata::Copy(const AtomList &d,const A &key,BL cut) +{ + pooldir *pd = root.GetDir(d); + if(pd) { + AtomList *val = pd->GetVal(key,cut); + if(val) { + pooldir *ret = new pooldir(nullatom); + ret->SetVal(key,val); + return ret; + } + else + return NULL; + } + else + return NULL; +} + +pooldir *pooldata::CopyAll(const AtomList &d,I depth,BL cut) +{ + pooldir *pd = root.GetDir(d); + if(pd) { + pooldir *ret = new pooldir(nullatom); + if(pd->Copy(ret,depth,cut)) + return ret; + else { + delete ret; + return NULL; + } + } + else + return NULL; +} + + +static const C *CnvFlnm(C *dst,const C *src,I sz) +{ +#if defined(PD) && defined(NT) + I cnt = strlen(src); + if(cnt >= sz-1) return NULL; + for(I i = 0; i < cnt; ++i) + dst[i] = src[i] != '/'?src[i]:'\\'; + dst[i] = 0; + return dst; +#else + return src; +#endif +} + +BL pooldata::LdDir(const AtomList &d,const C *flnm,I depth,BL mkdir) +{ + pooldir *pd = root.GetDir(d); + if(pd) { + C tmp[1024]; + const C *t = CnvFlnm(tmp,flnm,sizeof tmp); + if(t) { + ifstream fl(t); + return fl.good() && pd->LdDir(fl,depth,mkdir); + } + else return false; + } + else + return false; +} + +BL pooldata::SvDir(const AtomList &d,const C *flnm,I depth,BL absdir) +{ + pooldir *pd = root.GetDir(d); + if(pd) { + C tmp[1024]; + const C *t = CnvFlnm(tmp,flnm,sizeof tmp); + if(t) { + ofstream fl(t); + return fl.good() && pd->SvDir(fl,depth,absdir?d:AtomList()); + } + else return false; + } + else + return false; +} + + diff --git a/externals/grill/pool/pool.cw b/externals/grill/pool/pool.cw new file mode 100755 index 00000000..66e93306 Binary files /dev/null and b/externals/grill/pool/pool.cw differ diff --git a/externals/grill/pool/pool.dsp b/externals/grill/pool/pool.dsp new file mode 100644 index 00000000..dbe09386 --- /dev/null +++ b/externals/grill/pool/pool.dsp @@ -0,0 +1,103 @@ +# Microsoft Developer Studio Project File - Name="pool" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=pool - Win32 Debug +!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "pool.mak". +!MESSAGE +!MESSAGE Sie knnen beim Ausfhren von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "pool.mak" CFG="pool - Win32 Debug" +!MESSAGE +!MESSAGE Fr die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "pool - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "pool - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "max/pool" +# PROP Scc_LocalPath "." +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pool - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "pd-msvc/r" +# PROP Intermediate_Dir "pd-msvc/r" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "POOL_EXPORTS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext\source" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib /nologo /dll /machine:I386 /libpath:"c:\programme\audio\pd\bin" /libpath:"f:\prog\max\flext\pd-msvc" + +!ELSEIF "$(CFG)" == "pool - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "pd-msvc/d" +# PROP Intermediate_Dir "pd-msvc/d" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "POOL_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext\source" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "_DEBUG" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib pd.lib flext_d-pdwin.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:\programme\audio\pd\bin" /libpath:"f:\prog\max\flext\pd-msvc" + +!ENDIF + +# Begin Target + +# Name "pool - Win32 Release" +# Name "pool - Win32 Debug" +# Begin Source File + +SOURCE=.\main.cpp +# End Source File +# Begin Source File + +SOURCE=.\pool.cpp +# End Source File +# Begin Source File + +SOURCE=.\pool.h +# End Source File +# End Target +# End Project diff --git a/externals/grill/pool/pool.h b/externals/grill/pool/pool.h new file mode 100644 index 00000000..21fe4eb3 --- /dev/null +++ b/externals/grill/pool/pool.h @@ -0,0 +1,124 @@ +/* + +pool - hierarchical storage object for PD and Max/MSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#ifndef __POOL_H +#define __POOL_H + +#include + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400) +#error You need at least flext version 0.4.0 +#endif + +#define POOL_VERSION "0.0.5" + +#include + +typedef void V; +typedef int I; +typedef float F; +typedef char C; +typedef bool BL; +typedef t_atom A; +typedef t_symbol S; + +class poolval: + public flext +{ +public: + poolval(const A &key,AtomList *data); + ~poolval(); + + poolval &Set(AtomList *data); + poolval *Dup() const; + + A key; + AtomList *data; + poolval *nxt; +}; + + class pooldir: + public flext +{ +public: + pooldir(const A &dir); + ~pooldir(); + + V Clear(BL rec,BL dironly = false); + + pooldir *GetDir(I argc,const A *argv,BL cut = false); + pooldir *GetDir(const AtomList &d,BL cut = false) { return GetDir(d.Count(),d.Atoms(),cut); } + BL DelDir(const AtomList &d); + pooldir *AddDir(I argc,const A *argv); + pooldir *AddDir(const AtomList &d) { return AddDir(d.Count(),d.Atoms()); } + + V SetVal(const A &key,AtomList *data,BL over = true); + V ClrVal(const A &key) { SetVal(key,NULL); } + AtomList *GetVal(const A &key,BL cut = false); + I CntAll(); + I GetAll(A *&keys,AtomList *&lst,BL cut = false); + I GetSub(const t_atom **&dirs); + + BL Paste(const pooldir *p,I depth,BL repl,BL mkdir); + BL Copy(pooldir *p,I depth,BL cur); + + BL LdDir(istream &is,I depth,BL mkdir); + BL SvDir(ostream &os,I depth,const AtomList &dir = AtomList()); + + A dir; + pooldir *nxt; + + pooldir *dirs; + poolval *vals; +}; + + class pooldata: + public flext +{ +public: + pooldata(const S *s = NULL); + ~pooldata(); + + V Push() { ++refs; } + BL Pop() { return --refs > 0; } + + V Reset(); + BL MkDir(const AtomList &d); + BL ChkDir(const AtomList &d); + BL RmDir(const AtomList &d); + + BL Set(const AtomList &d,const A &key,AtomList *data,BL over = true); + BL Clr(const AtomList &d,const A &key); + BL ClrAll(const AtomList &d,BL rec,BL dironly = false); + AtomList *Get(const AtomList &d,const A &key); + I CntAll(const AtomList &d); + I GetAll(const AtomList &d,A *&keys,AtomList *&lst); + I GetSub(const AtomList &d,const t_atom **&dirs); + + BL Paste(const AtomList &d,const pooldir *clip,I depth = -1,BL repl = true,BL mkdir = true); + pooldir *Copy(const AtomList &d,const A &key,BL cut); + pooldir *CopyAll(const AtomList &d,I depth,BL cut); + + BL LdDir(const AtomList &d,const C *flnm,I depth,BL mkdir = true); + BL SvDir(const AtomList &d,const C *flnm,I depth,BL absdir); + BL Load(const C *flnm) { return LdDir(AtomList(),flnm,-1); } + BL Save(const C *flnm) { return SvDir(AtomList(),flnm,-1,true); } + + I refs; + const S *sym; + pooldata *nxt; + + pooldir root; + +private: + static t_atom nullatom; +}; + +#endif diff --git a/externals/grill/pool/pool.help b/externals/grill/pool/pool.help new file mode 100755 index 00000000..24d189b7 Binary files /dev/null and b/externals/grill/pool/pool.help differ diff --git a/externals/grill/pool/pool.pd b/externals/grill/pool/pool.pd new file mode 100644 index 00000000..ffd49615 --- /dev/null +++ b/externals/grill/pool/pool.pd @@ -0,0 +1,201 @@ +#N canvas 25 23 966 669 12; +#X obj 273 441 pool; +#X msg 236 52 set 1 2 3; +#X obj 272 563 print K; +#X msg 602 156 getall; +#X msg 236 81 set A k g; +#X obj 251 594 print V; +#X obj 290 532 print D; +#X msg 236 111 set A l m; +#X msg 239 140 set 2 34; +#X msg 238 171 set 3 17; +#X msg 423 50 clr A; +#X msg 427 126 get A; +#X msg 427 158 get 2; +#X msg 20 79 echodir \$1; +#X obj 20 58 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 20 160 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X msg 20 181 absdir \$1; +#X text 422 30 clear value; +#X text 423 104 get value; +#X obj 309 505 print C; +#X text 375 504 command; +#X text 357 531 directory (abs or rel to current); +#X text 320 594 data value; +#X text 338 562 data key; +#X msg 26 279 pool pool1; +#X msg 27 308 pool; +#X text 69 308 set to private; +#X msg 27 370 reset; +#X text 26 349 clear all pool data; +#X msg 608 56 clrall; +#X text 599 34 clear all values in dir; +#X text 602 135 get all values in dir; +#X text 314 442 pool name can be given as argument; +#X text 598 81 clear all values and dirs; +#X msg 606 103 clrrec; +#X msg 600 203 getrec; +#X text 600 181 get all values in dir and subdirs; +#X text 652 232 bang at EOL; +#X text 661 150 bang at EOL; +#X text 655 202 depth may be given; +#X text 22 258 data is shared among pool objects; +#X text 23 237 set pool name; +#X text 20 36 at each command; +#X text 20 20 echo current dir; +#X text 233 27 set values; +#X text 15 141 (default on); +#X text 7 125 report absolute dirs; +#X msg 28 417 help; +#X text 70 418 get some info; +#X text 658 219 default=-1 (= infinite); +#X msg 604 283 cntall; +#X text 663 281 count all values in dir; +#X msg 604 309 cntrec; +#X text 665 307 ... and subdirs; +#X text 661 321 (depth may be given); +#X msg 237 226 add 3 14; +#X text 235 205 set but don't replace; +#N canvas 0 0 421 528 dirs 0; +#X msg 109 27 mkdir fld1; +#X msg 111 122 chdir; +#X msg 110 217 updir; +#X msg 111 354 getsub -1; +#X text 110 7 make absolute dir; +#X text 109 51 make relative dir; +#X msg 110 72 mksub fld2; +#X text 109 104 change to absolute dir; +#X msg 110 165 chsub fld2; +#X text 108 146 change to relative dir; +#X text 106 198 change to upper dir; +#X text 107 250 remove absolute dir; +#X msg 108 269 rmdir fld1; +#X msg 110 308 rmsub fld2; +#X text 109 289 remove relative dir; +#X text 109 336 get subdirs; +#X text 239 379 -1 ... infinite; +#X text 161 213 depth may be given; +#X text 162 229 default=1; +#X text 192 348 depth may be given; +#X text 192 365 default=1; +#X text 108 377 count subdirs; +#X msg 111 398 cntsub -1; +#X obj 11 239 outlet; +#X msg 111 458 getdir; +#X text 110 438 get current dir; +#X text 172 457 always absolute; +#X connect 0 0 23 0; +#X connect 1 0 23 0; +#X connect 2 0 23 0; +#X connect 3 0 23 0; +#X connect 6 0 23 0; +#X connect 8 0 23 0; +#X connect 12 0 23 0; +#X connect 13 0 23 0; +#X connect 22 0 23 0; +#X connect 24 0 23 0; +#X restore 713 494 pd dirs; +#X text 710 468 directory operations; +#N canvas 0 0 467 434 file 0; +#X text 117 207 save dir and subdirs; +#X text 117 165 save data in current dir; +#X msg 117 184 svdir c:/temp/pool.dat; +#X msg 117 226 svrec c:/temp/pool.dat; +#X msg 116 272 lddir c:/temp/pool.dat; +#X msg 116 319 ldrec c:/temp/pool.dat; +#X text 117 253 load data into current dir; +#X text 115 300 load data into current dir and below; +#X text 132 340 depth (default -1) and; +#X text 134 356 mkdir flag (default 1) can be given; +#X obj 22 188 outlet; +#X text 117 37 save all; +#X text 117 81 load all (add to existing data); +#X msg 118 100 load c:/temp/pool.dat; +#X msg 120 54 save c:/temp/pool.dat; +#X text 22 12 file operations; +#X connect 2 0 10 0; +#X connect 3 0 10 0; +#X connect 4 0 10 0; +#X connect 5 0 10 0; +#X connect 13 0 10 0; +#X connect 14 0 10 0; +#X restore 714 549 pd file; +#X text 712 526 file operations; +#X text 712 583 clipboard operations; +#N canvas 0 0 529 577 clip 0; +#X obj 17 183 outlet; +#X text 97 56 copy value associated to key into clipboard; +#X msg 100 77 copy A; +#X msg 98 119 cut B; +#X text 96 101 cut value associated to key into clipboard; +#X msg 96 401 paste; +#X msg 98 179 copyall; +#X text 95 158 copy all values in current dir into clipboard; +#X msg 97 221 cutall; +#X text 95 201 cut all values in current dir into clipboard; +#X text 94 263 copy all values in current dir into clipboard; +#X text 94 306 cut all values in current dir into clipboard; +#X msg 97 284 copyrec; +#X text 194 285 depth may be given (default=-1); +#X text 193 326 depth may be given (default=-1); +#X msg 96 326 cutrec 1; +#X text 194 345 1..only with first level subdirs; +#X text 96 379 paste clipboard contents into current directory; +#X text 167 397 depth (default -1) and; +#X text 169 413 mkdir flag (default 1) can be given; +#X text 171 448 depth (default -1) and; +#X text 173 466 mkdir flag (default 1) can be given; +#X msg 95 453 pasteadd; +#X text 95 431 paste but don't replace; +#X msg 94 521 clrclip; +#X text 160 523 clear clipboard (free memory); +#X text 22 12 clipboard operations (this is an internal clipboard...) +; +#X connect 2 0 0 0; +#X connect 3 0 0 0; +#X connect 5 0 0 0; +#X connect 6 0 0 0; +#X connect 8 0 0 0; +#X connect 12 0 0 0; +#X connect 15 0 0 0; +#X connect 22 0 0 0; +#X connect 24 0 0 0; +#X restore 714 606 pd clip; +#X text 712 437 more commands:; +#X obj 780 494 s \$0-pool; +#X obj 778 549 s \$0-pool; +#X obj 778 606 s \$0-pool; +#X obj 349 392 r \$0-pool; +#X connect 0 0 5 0; +#X connect 0 1 2 0; +#X connect 0 2 6 0; +#X connect 0 3 19 0; +#X connect 1 0 0 0; +#X connect 3 0 0 0; +#X connect 4 0 0 0; +#X connect 7 0 0 0; +#X connect 8 0 0 0; +#X connect 9 0 0 0; +#X connect 10 0 0 0; +#X connect 11 0 0 0; +#X connect 12 0 0 0; +#X connect 13 0 0 0; +#X connect 14 0 13 0; +#X connect 15 0 16 0; +#X connect 16 0 0 0; +#X connect 24 0 0 0; +#X connect 25 0 0 0; +#X connect 27 0 0 0; +#X connect 29 0 0 0; +#X connect 34 0 0 0; +#X connect 35 0 0 0; +#X connect 47 0 0 0; +#X connect 50 0 0 0; +#X connect 52 0 0 0; +#X connect 55 0 0 0; +#X connect 57 0 64 0; +#X connect 59 0 65 0; +#X connect 62 0 66 0; +#X connect 67 0 0 0; diff --git a/externals/grill/py/build-pd-bcc.bat b/externals/grill/py/build-pd-bcc.bat new file mode 100644 index 00000000..3dd21329 --- /dev/null +++ b/externals/grill/py/build-pd-bcc.bat @@ -0,0 +1,3 @@ +@echo --- Building with BorlandC++ --- + +make -f makefile.pd-bcc diff --git a/externals/grill/py/build-pd-cygwin.sh b/externals/grill/py/build-pd-cygwin.sh new file mode 100644 index 00000000..8eb7bcab --- /dev/null +++ b/externals/grill/py/build-pd-cygwin.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +. config-pd-cygwin.txt + +make -f makefile.pd-cygwin && +{ + if [ $INSTALL = "yes" ]; then + make -f makefile.pd-cygwin install + fi +} diff --git a/externals/grill/py/build-pd-linux.sh b/externals/grill/py/build-pd-linux.sh new file mode 100755 index 00000000..90e4a04a --- /dev/null +++ b/externals/grill/py/build-pd-linux.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. config-pd-linux.txt + +make -f makefile.pd-linux && +{ + if [ $INSTALL = "yes" ]; then + echo Now install as root + su -c "make -f makefile.pd-linux install" + fi +} diff --git a/externals/grill/py/build-pd-msvc.bat b/externals/grill/py/build-pd-msvc.bat new file mode 100644 index 00000000..d6187f08 --- /dev/null +++ b/externals/grill/py/build-pd-msvc.bat @@ -0,0 +1,4 @@ +@echo --- Building with MS Visual C++ --- + +nmake -f makefile.pd-msvc clean +nmake -f makefile.pd-msvc diff --git a/externals/grill/py/config-pd-bcc.txt b/externals/grill/py/config-pd-bcc.txt new file mode 100644 index 00000000..83d23264 --- /dev/null +++ b/externals/grill/py/config-pd-bcc.txt @@ -0,0 +1,31 @@ +# py/pyext - python script objects for PD and Max/MSP +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# + +# where is PD? +PDPATH=c:\programme\audio\pd + +# where do the flext libraries reside? +FLEXTPATH=$(PDPATH)\flext + +# where is BorlandC++? +BCCPATH=c:\programme\prog\bcc55 + +# which version of Python? +PYTHONVER=python22 + +# where are the python header files? +PYTHONINCLUDE=c:\programme\prog\$(PYTHONVER)\include + +# what is the python library file? +PYTHONBIN=c:\windows\system32\$(PYTHONVER).dll + +# where should the external(s) be built? +OUTPATH=.\pd-bcc + +# should the external be installed? (yes/no) +INSTALL=yes + +# where should the external be installed? +INSTDIR=$(PDPATH)\extra + diff --git a/externals/grill/py/config-pd-cygwin.txt b/externals/grill/py/config-pd-cygwin.txt new file mode 100644 index 00000000..7c7bebd8 --- /dev/null +++ b/externals/grill/py/config-pd-cygwin.txt @@ -0,0 +1,29 @@ +# py/pyext - python script objects for PD and Max/MSP +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# + +# where is PD? +PDPATH=/cygdrive/c/programme/audio/pd + +# where do the flext libraries reside? +FLEXTPATH=${PDPATH}/flext + +# which version of Python? +PYTHONVER=python22 + +# where are the python header files? +PYTHONINCLUDE=/cygdrive/c/programme/prog/${PYTHONVER}/include + +# what is the python library file? +PYTHONLIB=/cygdrive/c/programme/prog/${PYTHONVER}/libs/${PYTHONVER}.lib + +# where should the external(s) be built? +TARGDIR=./pd-cygwin + +# should the external be installed? (yes/no) +INSTALL=yes + +# where should the external be installed? +INSTDIR=${PDPATH}/extra + + diff --git a/externals/grill/py/config-pd-linux.txt b/externals/grill/py/config-pd-linux.txt new file mode 100644 index 00000000..bc63be41 --- /dev/null +++ b/externals/grill/py/config-pd-linux.txt @@ -0,0 +1,33 @@ +# py/pyext - python script objects for PD and Max/MSP +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# + +# your c++ compiler (normally g++) +CXX=g++-3.2 + +# where are the PD header files? +# leave it blank if it is a system directory (like /usr/local/include), +# since gcc 3.2 complains about it +PDPATH= + +# where do the flext libraries reside? +FLEXTPATH=/usr/local/lib/pd/flext + +# what is the python version? +PYTHONVER=2.2 +# where are the python header files? +PYTHONINCLUDE=/usr/include/python${PYTHONVER} +# where is the python library file? +PYTHONLIB=/usr/lib/python${PYTHONVER}/config + +# where should flext libraries be built? +TARGDIR=./pd-linux + +# should the flext stuff be installed? (yes/no) +INSTALL=yes + +# where should py/pyext be installed? +INSTPATH=/usr/local/lib/pd/extra + + + diff --git a/externals/grill/py/config-pd-msvc.txt b/externals/grill/py/config-pd-msvc.txt new file mode 100644 index 00000000..e5c4d044 --- /dev/null +++ b/externals/grill/py/config-pd-msvc.txt @@ -0,0 +1,30 @@ +# py/pyext - python script objects for PD and Max/MSP +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# + +# where is PD? +PDPATH=c:\programme\audio\pd + +# where do the flext libraries reside? +FLEXTPATH=$(PDPATH)\flext + +# where is MS VC++? +MSVCPATH="c:\programme\prog\microsoft visual studio\VC98" + +# which version of Python? +PYTHONVER=python22 + +# where are the python header files? +PYTHONINCLUDE=c:\programme\prog\$(PYTHONVER)\include + +# what is the python library file? +PYTHONLIB=c:\programme\prog\$(PYTHONVER)\libs\$(PYTHONVER).lib + +# where should the external be built? +OUTPATH=pd-msvc + +# should the external be installed? (yes/no) +INSTALL=yes + +# where should the external be installed? +INSTDIR=$(PDPATH)\extra diff --git a/externals/grill/py/gpl.txt b/externals/grill/py/gpl.txt new file mode 100644 index 00000000..5ea29a7d --- /dev/null +++ b/externals/grill/py/gpl.txt @@ -0,0 +1,346 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + diff --git a/externals/grill/py/license.txt b/externals/grill/py/license.txt new file mode 100644 index 00000000..949207fd --- /dev/null +++ b/externals/grill/py/license.txt @@ -0,0 +1,50 @@ +py/pyext - python script objects for PD and MaxMSP +Copyright (C) 2002 Thomas Grill + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +In the official py/pyext distribution, the GNU General Public License is +in the file gpl.txt + +--------------------------------------------------------- + + OTHER COPYRIGHT NOTICES + +--------------------------------------------------------- +This package uses the flext C++ layer - See its license text below: + + +--- flext ---------------------------------------------- +flext - C++ layer for Max/MSP and pd (pure data) externals +Copyright (C) 2001,2002 Thomas Grill + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +In the official flext distribution, the GNU General Public License is +in the file gpl.txt + + diff --git a/externals/grill/py/makefile.pd-bcc b/externals/grill/py/makefile.pd-bcc new file mode 100644 index 00000000..e94abdf4 --- /dev/null +++ b/externals/grill/py/makefile.pd-bcc @@ -0,0 +1,82 @@ +# py/pyext - python script object for PD and MaxMSP +# Copyright (C) 2002 Thomas Grill +# +# Makefile for BorlandC++ +# +# usage: make -f makefile.pd-bcc +# +# ... no threads! +# +# --------------------------------------------- + +!include config-pd-bcc.txt + +NAME=py +SETUPFUNCTION=$(NAME)_setup + +# flext stuff +TARGET=pdwin + +# includes, libs +INCPATH=-I$(BCCPATH)\include -I$(PYTHONINCLUDE) -I$(PDPATH)\src -I$(FLEXTPATH) +LIBPATH=-L$(BCCPATH)\lib -L$(PDPATH)\lib +LIBS=cw32.lib import32.lib C0D32.OBJ + +# compiler definitions and flags +DEFS=-DPD -DNT +CFLAGS=-6 -O2 -OS -ff -tWD + + +# the rest can stay untouched +# ---------------------------------------------- + +# all the source files from the package +SRCS= main.cpp py.cpp pyext.cpp modmeth.cpp clmeth.cpp register.cpp pyargs.cpp bound.cpp +HDRS= main.h pyext.h + +# default target +all: $(OUTPATH)\$(NAME).dll + +# remove build +clean: + -del /s /q $(OUTPATH) > nul + rmdir $(OUTPATH) + + +install: + cp $(OUTPATH)\$(NAME).dll $(INSTDIR) + +# ---------------------------------------------- + +OBJS= $(SRCS:.cpp=.obj) + +#.PATH.OBJ=$(OUTPATH) + +#$(SRCS): $(HDRS) +# -touch $< + +{source}.cpp.obj: + bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(OUTPATH) $< + +$(OUTPATH): + -@if not exist $< mkdir $< + +$(OUTPATH)\pd.lib: $(PDPATH)\bin\pd.dll + implib -a $< $** + +$(OUTPATH)\python.lib: $(PYTHONBIN) + implib -a $< $** + +$(OUTPATH)\$(NAME).def: + @echo EXPORTS $(SETUPFUNCTION) = _$(SETUPFUNCTION) > $< + @echo IMPORTS _Py_Initialize = $(PYTHONVER).Py_Initialize >> $< + @echo IMPORTS _Py_Finalize = $(PYTHONVER).Py_Finalize >> $< + +$(OUTPATH)\$(NAME).dll :: $(OUTPATH) $(OUTPATH)\$(NAME).def $(OUTPATH)\pd.lib $(OUTPATH)\python.lib + +$(OUTPATH)\$(NAME).dll :: $(OBJS) + cd $(OUTPATH) + ilink32 -C -Tpd $(LIBPATH) $** ,..\$<,,$(LIBS) pd.lib python.lib $(FLEXTPATH)\flext-$(TARGET).lib ,$(NAME).def + cd .. + + \ No newline at end of file diff --git a/externals/grill/py/makefile.pd-linux b/externals/grill/py/makefile.pd-linux new file mode 100644 index 00000000..af2b58d2 --- /dev/null +++ b/externals/grill/py/makefile.pd-linux @@ -0,0 +1,75 @@ +# py/pyext - python script object for PD and Max/MSP +# Copyright (C) 2002 Thomas Grill (xovo@gmx.net) +# +# Makefile for gcc @ linux +# +# usage: +# to build run "make -f makefile.pd-linux" +# to install (as root), do "make -f makefile.pd-linux install" +# + +CONFIG=config-pd-linux.txt + +include $(CONFIG) + +FLEXTLIB=$(FLEXTPATH)/flext_t.a + +# compiler+linker stuff +INCLUDES=$(PDPATH) $(PYTHONINCLUDE) +LIBPATH=$(PYTHONLIB) +FLAGS=-DPD -DFLEXT_THREADS +CFLAGS=-O6 -mcpu=pentiumpro +#CFLAGS=-g +LIBS=m util python$(PYTHONVER) + + +# --------------------------------------------- +# the rest can stay untouched +# ---------------------------------------------- + +NAME=py + +# all the source files from the package +SRCS=main.cpp py.cpp pyext.cpp bound.cpp clmeth.cpp modmeth.cpp pyargs.cpp register.cpp +HDRS=main.h pyext.h + +TARGET=$(TARGDIR)/$(NAME).pd_linux + +# default target +all: $(TARGDIR) $(TARGET) + +$(patsubst %,source/%,$(SRCS)): $(patsubst %,source/%,$(HDRS)) $(FLEXTLIB) $(CONFIG) + touch $@ + +$(TARGDIR): + mkdir $(TARGDIR) + +$(TARGDIR)/%.o : source/%.cpp + $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@ + +$(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) $(FLEXTLIB) + $(CXX) -shared $^ $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@ + chmod 755 $@ + +$(INSTPATH): + mkdir $(INSTDIR) + +install:: $(INSTDIR) + +install:: $(TARGET) + cp $^ $(INSTPATH) + chown root.root $(patsubst %,$(INSTPATH)/%,$(notdir $^)) + chmod 755 $(patsubst %,$(INSTPATH)/%,$(notdir $^)) + +.PHONY: clean +clean: + rm -f $(TARGDIR)/*.o $(TARGET) + + + + + + + + + diff --git a/externals/grill/py/pd/script-1.pd b/externals/grill/py/pd/script-1.pd new file mode 100644 index 00000000..e143d5e8 --- /dev/null +++ b/externals/grill/py/pd/script-1.pd @@ -0,0 +1,50 @@ +#N canvas 297 17 672 523 12; +#X obj 39 278 print; +#X obj 345 251 print; +#X msg 499 149 freakhole; +#X msg 148 149 list H e l l o; +#X msg 166 175 Hello friend; +#X obj 42 460 print; +#X msg 102 367 0 1 2 3 4; +#X msg 197 367 5 67 3; +#X obj 350 456 print; +#X obj 326 365 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 +-1; +#X obj 515 455 print; +#X obj 514 386 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 +-1; +#X msg 188 204 1 3; +#X msg 345 155 help; +#X msg 360 327 set ret1; +#X msg 379 351 set ret2; +#X text 434 326 functions can be set; +#X msg 421 120 somewhere_past_mars; +#X text 152 101 reload with new arguments; +#X msg 40 104 reload 1 2 3; +#X text 23 13 py/pyext - Python script objects \, (C)2002 Thomas Grill +; +#X text 21 42 This demonstrates simple scripting. See the script.py +file.; +#X obj 39 241 py script strcat; +#X obj 43 424 py script addall; +#X obj 350 420 py script; +#X obj 516 419 py script ret3; +#X obj 346 204 py script strlen; +#X connect 2 0 26 1; +#X connect 3 0 22 1; +#X connect 4 0 22 1; +#X connect 6 0 23 1; +#X connect 7 0 23 1; +#X connect 9 0 24 0; +#X connect 11 0 25 0; +#X connect 12 0 22 1; +#X connect 13 0 26 0; +#X connect 14 0 24 0; +#X connect 15 0 24 0; +#X connect 17 0 26 1; +#X connect 19 0 22 0; +#X connect 22 0 0 0; +#X connect 23 0 5 0; +#X connect 24 0 8 0; +#X connect 25 0 10 0; +#X connect 26 0 1 0; diff --git a/externals/grill/py/pd/sendrecv-1.pd b/externals/grill/py/pd/sendrecv-1.pd new file mode 100644 index 00000000..d2d4b50a --- /dev/null +++ b/externals/grill/py/pd/sendrecv-1.pd @@ -0,0 +1,25 @@ +#N canvas 343 246 466 316 12; +#X msg 125 52 reload mi ma; +#X floatatom 48 173 5 0 0; +#X floatatom 181 174 5 0 0; +#X obj 181 198 s mi; +#X floatatom 49 265 5 0 0; +#X floatatom 181 266 5 0 0; +#X obj 181 239 r ma; +#X obj 48 197 s he; +#X obj 49 238 r hu; +#X text 233 51 reload with different args; +#X msg 20 17 help; +#X msg 19 49 doc; +#X msg 58 49 doc+; +#X obj 49 100 pyext sendrecv ex1 he hu; +#X text 28 151 scroll here; +#X text 176 152 or here; +#X connect 0 0 13 0; +#X connect 1 0 7 0; +#X connect 2 0 3 0; +#X connect 6 0 5 0; +#X connect 8 0 4 0; +#X connect 10 0 13 0; +#X connect 11 0 13 0; +#X connect 12 0 13 0; diff --git a/externals/grill/py/pd/sendrecv-2.pd b/externals/grill/py/pd/sendrecv-2.pd new file mode 100644 index 00000000..9f015b4c --- /dev/null +++ b/externals/grill/py/pd/sendrecv-2.pd @@ -0,0 +1,8 @@ +#N canvas 133 322 454 304 12; +#X obj 36 135 pyext sendrecv ex2 huha; +#X floatatom 36 165 5 0 0; +#X floatatom 35 38 5 0 0; +#X obj 34 65 s huha; +#X text 22 19 scroll here; +#X connect 0 0 1 0; +#X connect 2 0 3 0; diff --git a/externals/grill/py/pd/sendrecv-3.pd b/externals/grill/py/pd/sendrecv-3.pd new file mode 100644 index 00000000..0f42edfc --- /dev/null +++ b/externals/grill/py/pd/sendrecv-3.pd @@ -0,0 +1,5 @@ +#N canvas 294 237 484 334 12; +#X obj 283 258 pyext sendrecv ex3; +#X obj 437 255 bng 25 250 50 0 empty ugh empty 0 -6 64 8 -258699 -1 +-1; +#X connect 1 0 0 1; diff --git a/externals/grill/py/pd/simple-1.pd b/externals/grill/py/pd/simple-1.pd new file mode 100644 index 00000000..2d60db5b --- /dev/null +++ b/externals/grill/py/pd/simple-1.pd @@ -0,0 +1,41 @@ +#N canvas 156 192 650 389 12; +#X obj 53 123 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X floatatom 52 155 5 0 0; +#X text 388 337 watch the console output!; +#X msg 52 186 2 3 4; +#X msg 277 131 ho; +#X msg 233 155 lets; +#X msg 283 190 go; +#X msg 212 214 !!!; +#X msg 205 113 hey; +#X obj 183 301 pyext simple ex1; +#X msg 434 114 onearg 123; +#X msg 456 167 threeargs 9 8 7; +#X msg 463 196 varargs 8 4 2 1; +#X msg 447 140 twoargs 41 15; +#X msg 453 239 twoargs 1 2 3; +#X msg 71 299 help; +#X text 16 15 py/pyext - Python script objects \, (C)2002 Thomas Grill +; +#X text 15 57 This demonstrates message handling. See the simple.py +file.; +#X text 232 322 file class; +#X msg 70 324 doc; +#X msg 106 325 doc+; +#X connect 0 0 9 1; +#X connect 1 0 9 1; +#X connect 3 0 9 1; +#X connect 4 0 9 2; +#X connect 5 0 9 2; +#X connect 6 0 9 2; +#X connect 7 0 9 2; +#X connect 8 0 9 2; +#X connect 10 0 9 3; +#X connect 11 0 9 3; +#X connect 12 0 9 3; +#X connect 13 0 9 3; +#X connect 14 0 9 3; +#X connect 15 0 9 0; +#X connect 19 0 9 0; +#X connect 20 0 9 0; diff --git a/externals/grill/py/pd/simple-2.pd b/externals/grill/py/pd/simple-2.pd new file mode 100644 index 00000000..e20be506 --- /dev/null +++ b/externals/grill/py/pd/simple-2.pd @@ -0,0 +1,37 @@ +#N canvas 225 210 689 411 12; +#X floatatom 251 106 5 0 0; +#X text 409 291 watch the console output!; +#X msg 55 213 help; +#X text 15 57 This demonstrates message handling. See the simple.py +file.; +#X msg 54 238 doc; +#X msg 90 239 doc+; +#X floatatom 308 106 5 0 0; +#X msg 218 228 msg 2; +#X obj 172 282 pyext simple ex2; +#X floatatom 172 327 5 0 0; +#X floatatom 289 328 5 0 0; +#X text 17 22 py/pyext - Python script objects \, (C)2002 Thomas Grill +; +#X msg 149 197 msg 1 3; +#X msg 283 213 msg a b; +#X msg 169 167 hello; +#X msg 242 173 hello; +#X msg 315 172 msg; +#X msg 374 147 hello 3; +#X text 418 172 special case: 'hello' handler doesn't like args \, +so _anything_ is called!; +#X connect 0 0 8 1; +#X connect 2 0 8 0; +#X connect 4 0 8 0; +#X connect 5 0 8 0; +#X connect 6 0 8 2; +#X connect 7 0 8 2; +#X connect 8 0 9 0; +#X connect 8 1 10 0; +#X connect 12 0 8 1; +#X connect 13 0 8 3; +#X connect 14 0 8 1; +#X connect 15 0 8 3; +#X connect 16 0 8 2; +#X connect 17 0 8 3; diff --git a/externals/grill/py/pd/simple-3.pd b/externals/grill/py/pd/simple-3.pd new file mode 100644 index 00000000..70416ad0 --- /dev/null +++ b/externals/grill/py/pd/simple-3.pd @@ -0,0 +1,27 @@ +#N canvas 307 249 546 386 12; +#X msg 88 279 help; +#X text 15 50 This demonstrates message handling. See the simple.py +file.; +#X msg 87 304 doc; +#X msg 123 305 doc+; +#X floatatom 288 345 5 0 0; +#X text 17 22 py/pyext - Python script objects \, (C)2002 Thomas Grill +; +#X floatatom 316 119 5 0 0; +#X floatatom 399 119 5 0 0; +#X obj 225 279 pyext simple ex3 1; +#X msg 39 195 reload.; +#X msg 39 223 reload -10; +#X text 110 194 reload script and keep arguments; +#X text 128 224 reload script with new arguments; +#X text 281 140 triggers; +#X text 340 344 result; +#X text 410 140 sets argument; +#X connect 0 0 8 0; +#X connect 2 0 8 0; +#X connect 3 0 8 0; +#X connect 6 0 8 1; +#X connect 7 0 8 2; +#X connect 8 0 4 0; +#X connect 9 0 8 0; +#X connect 10 0 8 0; diff --git a/externals/grill/py/pd/tcltk.pd b/externals/grill/py/pd/tcltk.pd new file mode 100644 index 00000000..c1c3b246 --- /dev/null +++ b/externals/grill/py/pd/tcltk.pd @@ -0,0 +1,18 @@ +#N canvas 156 192 610 329 12; +#X obj 328 118 bng 25 250 50 0 empty empty empty 0 -6 0 8 -258699 -1 +-1; +#X msg 94 128 help; +#X text 16 15 py/pyext - Python script objects \, (C)2002 Thomas Grill +; +#X msg 139 127 doc; +#X text 14 49 This demonstrates a tcl/tk dialog. See the tcltk.py file. +; +#X text 10 263 Note: When used concurrently with audio \, you will +notice clicks. This Tk window is NOT called over a net socket \, like +PD is; +#X obj 206 169 pyext tcltk myapp; +#X obj 206 200 print tcltk; +#X connect 0 0 6 1; +#X connect 1 0 6 0; +#X connect 3 0 6 0; +#X connect 6 0 7 0; diff --git a/externals/grill/py/pd/thread-1.pd b/externals/grill/py/pd/thread-1.pd new file mode 100644 index 00000000..892c37ce --- /dev/null +++ b/externals/grill/py/pd/thread-1.pd @@ -0,0 +1,47 @@ +#N canvas 307 249 576 388 12; +#X msg 38 265 help; +#X msg 37 290 doc; +#X msg 73 291 doc+; +#X floatatom 145 323 5 0 0; +#X text 16 14 py/pyext - Python script objects \, (C)2002 Thomas Grill +; +#X text 14 44 This demonstrates threading. See the threads.py file. +; +#X obj 145 279 pyext threads ex1; +#X obj 140 216 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 +1; +#X msg 140 236 detach \$1; +#X floatatom 253 324 5 0 0; +#X obj 275 123 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1 +-1; +#X obj 146 127 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1 +-1; +#X obj 146 154 t b b b; +#X obj 275 150 t b b b; +#X obj 289 179 1; +#X obj 160 181 0; +#X text 87 87 without threads; +#X text 113 105 blocking; +#X text 251 85 with threads; +#X text 252 102 non-blocking; +#X text 178 345 watch that!; +#X msg 414 127 stop; +#X text 384 106 you can even stop it; +#X connect 0 0 6 0; +#X connect 1 0 6 0; +#X connect 2 0 6 0; +#X connect 6 0 3 0; +#X connect 6 1 9 0; +#X connect 7 0 8 0; +#X connect 8 0 6 0; +#X connect 10 0 13 0; +#X connect 11 0 12 0; +#X connect 12 0 6 1; +#X connect 12 1 6 2; +#X connect 12 2 15 0; +#X connect 13 0 6 1; +#X connect 13 1 6 2; +#X connect 13 2 14 0; +#X connect 14 0 7 0; +#X connect 15 0 7 0; +#X connect 21 0 6 0; diff --git a/externals/grill/py/py.cw b/externals/grill/py/py.cw new file mode 100644 index 00000000..f5f6fc7f Binary files /dev/null and b/externals/grill/py/py.cw differ diff --git a/externals/grill/py/py.dsp b/externals/grill/py/py.dsp new file mode 100644 index 00000000..8171624c --- /dev/null +++ b/externals/grill/py/py.dsp @@ -0,0 +1,229 @@ +# Microsoft Developer Studio Project File - Name="py" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=py - Win32 Threads Debug +!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "py.mak". +!MESSAGE +!MESSAGE Sie knnen beim Ausfhren von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "py.mak" CFG="py - Win32 Threads Debug" +!MESSAGE +!MESSAGE Fr die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "py - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "py - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "py - Win32 Threads Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "py - Win32 Threads Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "py" +# PROP Scc_LocalPath "." +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "py - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "pd-msvc\r" +# PROP Intermediate_Dir "pd-msvc\r" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PY_EXPORTS" /YX /FD /c +# ADD CPP /nologo /W3 /GR- /O2 /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext\source" /I "C:\Programme\prog\Python22\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /D "NT" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib /nologo /dll /machine:I386 /libpath:"c:/programme/audio/pd/bin" /libpath:"..\flext\pd-msvc" /libpath:"C:\Programme\prog\Python22\libs" + +!ELSEIF "$(CFG)" == "py - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "pd-msvc\d" +# PROP Intermediate_Dir "pd-msvc\d" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PY_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GR /ZI /Od /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext\source" /I "C:\Programme\prog\Python22\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /D "NT" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "_DEBUG" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib pd.lib flext_d-pdwin.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:/programme/audio/pd/bin" /libpath:"..\flext\pd-msvc" /libpath:"f:\prog\packs\Python-2.2.1\PCbuild" + +!ELSEIF "$(CFG)" == "py - Win32 Threads Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "py___Win32_Threads_Release" +# PROP BASE Intermediate_Dir "py___Win32_Threads_Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "pd-msvc\tr" +# PROP Intermediate_Dir "pd-msvc\tr" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GR /GX /O2 /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext" /I "C:\Programme\prog\Python22\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /D "NT" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GR /O2 /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext\source" /I "C:\Programme\prog\Python22\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /D "NT" /D "FLEXT_THREADS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib /nologo /dll /machine:I386 /libpath:"c:/programme/audio/pd/bin" /libpath:"..\flext\msvc" /libpath:"C:\Programme\prog\Python22\libs" +# ADD LINK32 kernel32.lib user32.lib pd.lib flext_t-pdwin.lib pthreadVC.lib /nologo /dll /machine:I386 /out:"pd-msvc\py.dll" /libpath:"c:/programme/audio/pd/bin" /libpath:"..\flext\pd-msvc" /libpath:"C:\Programme\prog\Python22\libs" + +!ELSEIF "$(CFG)" == "py - Win32 Threads Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "py___Win32_Threads_Debug" +# PROP BASE Intermediate_Dir "py___Win32_Threads_Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "pd-msvc\td" +# PROP Intermediate_Dir "pd-msvc\td" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GR /GX /ZI /Od /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext" /I "C:\Programme\prog\Python22\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /D "NT" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext\source" /I "C:\Programme\prog\Python22\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /D "NT" /D "FLEXT_THREADS" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "_DEBUG" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:/programme/audio/pd/bin" /libpath:"..\flext\msvc-debug" /libpath:"f:\prog\packs\Python-2.2.1\PCbuild" +# ADD LINK32 kernel32.lib user32.lib pd.lib flext_td-pdwin.lib pthreadVC.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:/programme/audio/pd/bin" /libpath:"..\flext\pd-msvc" /libpath:"f:\prog\packs\Python-2.2.1\PCbuild" + +!ENDIF + +# Begin Target + +# Name "py - Win32 Release" +# Name "py - Win32 Debug" +# Name "py - Win32 Threads Release" +# Name "py - Win32 Threads Debug" +# Begin Group "scripts" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\scripts\script.py +# End Source File +# Begin Source File + +SOURCE=.\scripts\sendrecv.py +# End Source File +# Begin Source File + +SOURCE=.\scripts\simple.py +# End Source File +# Begin Source File + +SOURCE=.\scripts\tcltk.py +# End Source File +# Begin Source File + +SOURCE=.\scripts\threads.py +# End Source File +# End Group +# Begin Group "doc" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\gpl.txt +# End Source File +# Begin Source File + +SOURCE=.\license.txt +# End Source File +# Begin Source File + +SOURCE=.\readme.txt +# End Source File +# End Group +# Begin Source File + +SOURCE=.\source\bound.cpp +# End Source File +# Begin Source File + +SOURCE=.\source\clmeth.cpp +# End Source File +# Begin Source File + +SOURCE=.\source\main.cpp +# End Source File +# Begin Source File + +SOURCE=.\source\main.h +# End Source File +# Begin Source File + +SOURCE=.\source\modmeth.cpp +# End Source File +# Begin Source File + +SOURCE=.\source\py.cpp +# End Source File +# Begin Source File + +SOURCE=.\source\pyargs.cpp +# End Source File +# Begin Source File + +SOURCE=.\source\pyext.cpp +# End Source File +# Begin Source File + +SOURCE=.\source\pyext.h +# End Source File +# Begin Source File + +SOURCE=.\source\register.cpp +# End Source File +# End Target +# End Project diff --git a/externals/grill/py/py.mpw b/externals/grill/py/py.mpw new file mode 100644 index 00000000..54c507a0 --- /dev/null +++ b/externals/grill/py/py.mpw @@ -0,0 +1,91 @@ +# py - python script object for PD and MaxMSP +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# +# Makefile for Apple MPW-PR +# +# usage: make -f py.mpw +# +# --------------------------------------------- + +MAKEFILE = py.mpw +MondoBuild = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified + +Name = py + +ObjDir = :MPW: +MaxSDK = HD Daten:Prog Stuff:Max/MSP SDK:SDK Examples +flext = ::flext: +Python = HD Daten:Prog Stuff:Packs:Python-2.2 +PythonIncludes = {Python}:Include +PythonMacIncludes = {Python}:Mac:Include +PythonCore = HD MacOS:Applications (Mac OS 9):dev:Python 2.2:PythonCore + + + +Includes = -i :,"{flext}","{MaxSDK}:Max Includes","{MaxSDK}:MSP Includes","{GUSI}include","{PythonIncludes}","{PythonMacIncludes}" +### MPW Shell - Command "Includes" was not found. + +Defines = -d MAXMSP -d USE_GUSI2 + +Sym-PPC = -sym off +Flags = -bool on -enum int -includes unix -opt speed,unroll,unswitch + + +PPCCPlusOptions = {Includes} {Sym-PPC} {Defines} {Flags} + + +### Source Files ### + +SrcFiles = main.cpp +Headers = + + +### Object Files ### + +Obj-PPC = + "{ObjDir}main.cpp.x" + +LibFiles-Ext = + "{flext}MPW:flext.o" + "{MaxSDK}:Max Includes:MaxLib" + "{MaxSDK}:MSP Includes:MaxAudioLib" + "{PythonCore}" + +### Libraries ### + +LibFiles-PPC = + "{SharedLibraries}StdCLib" + "{SharedLibraries}MathLib" + "{PPCLibraries}StdCRuntime.o" + "{PPCLibraries}PPCCRuntime.o" + "{PPCLibraries}MrCPlusLib.o" + + +### Default Rules ### + +{ObjDir} : + +.cpp.x .cpp {MondoBuild} {Headers} + {PPCCPlus} {depDir}{default}.cpp -o {targDir}{default}.cpp.x {PPCCPlusOptions} + + +### Build Rules ### + +all Folder {MondoBuild} {ObjDir}{Name} + +Folder + if !`Exists {ObjDir}` ; NewFolder {ObjDir} ; end + +{ObjDir}{Name} {Obj-PPC} + PPCLink + -o {Targ} + {deps} + {LibFiles-Ext} + {LibFiles-PPC} + {Sym-PPC} + -mf -d + -t 'iLaF' + -c 'max2' + -xm s + -export main + -main main diff --git a/externals/grill/py/readme.txt b/externals/grill/py/readme.txt new file mode 100644 index 00000000..fc82880b --- /dev/null +++ b/externals/grill/py/readme.txt @@ -0,0 +1,106 @@ +py/pyext - python script objects for PD (and MaxMSP... once, under MacOSX and Windows) + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +Donations for further development of the package are highly appreciated. + +---------------------------------------------------------------------------- + +You will need the flext C++ layer for PD and Max/MSP externals to compile this. + +Package files: +- readme.txt: this one +- gpl.txt,license.txt: GPL license stuff +- main.cpp, main.h, modmeth.cpp, pyargs.cpp, register.cpp: base class +- py.cpp: py object +- pyext.cpp, pyext.h, clmeth.cpp, bound.cpp: pyext object + +---------------------------------------------------------------------------- + +Goals/features of the package: + +Access the flexibility of the python language in PD/MaxMSP + + +PD - Load it as i library with e.g. "pd -lib py -path scripts" +Max/MSP - Wait for Windows or MacOSX version. MacOS9 doesn't want it. + + +Check out the sample patches and scripts + + +Description: + +With the py object you can load python modules and execute the functions therein. +With the pyext you can use python classes to represent full-featured pd/Max message objects. +Multithreading (detached methods) is supported for both objects. +You can send messages to named objects or receive (with pyext) with Python methods. + +---------------------------------------------------------------------------- + +The py/pyext package should run with Python version >= 2.1. +It has been thoroughly tested with version 2.2 + + +The package should at least compile (and is tested) with the following compilers: + +pd - Windows: +------------- +o Borland C++ 5.5 (free): edit "config-pd-bcc.txt" & run "build-pd-bcc.bat" + +o Microsoft Visual C++ 6: edit the project file "py.dsp" & build + +pd - linux: +----------- +Python doesn't provide a shared lib by default - static linking produces huge externals +Ok, debian is an exception... the precompiled binary is for debian, therefore. + +o GCC: edit "config-pd-linux.txt" & run "sh build-pd-linux.sh" + +---------------------------------------------------------------------------- + +Version history: + +0.1.1: +- FIX: crash when module couldn't be loaded +- FIX: GetBound method (modmeth.cpp, line 138) doesn't exist in flext any more +- FIX: deadlock occured when connecting to py/pyext boxes in non-detached mode +- ADD: current path and path of the canvas is added to the python path + +0.1.0: +- completely reworked all code +- added class functionality for full-featured objects and renamed the merge to pyext +- enabled threads and made everything thread-safe ... phew! +- using flext 0.3.2 +- pyext now gets full python path +- python's argv[0] is now "py" or "pyext" +- etc.etc. + +0.0.2: +- fixed bug when calling script with no function defined (thanks to Ben Saylor) +- cleaner gcc makefile + +0.0.1: +- using flext 0.2.1 + +--------------------------------------------------------------------------- + +TODO list: + +general: +- Documentation and better example patches + +features: +- enable multiple interpreters? +- make a pygui object where Tkinter draws to the PD canvas... +- stop individual threads + +tests: +- check for python threading support + +bugs: +- the python interpreter can't be unloaded due to some bug at re-initialization +- named (keyword) arguments are not supported + diff --git a/externals/grill/py/scripts/script.py b/externals/grill/py/scripts/script.py new file mode 100644 index 00000000..4796949c --- /dev/null +++ b/externals/grill/py/scripts/script.py @@ -0,0 +1,53 @@ +# py/pyext - python script objects for PD and MaxMSP +# +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# For information on usage and redistribution, and for a DISCLAIMER OF ALL +# WARRANTIES, see the file, "license.txt," in this distribution. +# + +"""Several functions to show the py script functionality""" + +import sys + +print "Script initialized" + +try: + print "Script arguments: ",sys.argv +except: + print + +def numargs(*args): # variable argument list + """Return the number of arguments""" + return len(args) + +def strlen(arg): + """Return the string length""" + return len(arg) + + +def strcat(*args): + """Concatenate several symbols""" + s = "" + for si in args: + s += str(si) + return s + + +def addall(*args): # variable argument list + s = 0 + for si in args: + s += si + return s + + +def ret1(): + return 1,2,3,4 + + +def ret2(): + return "sd","lk","ki" + + +def ret3(): + return ["sd","lk","ki"] + diff --git a/externals/grill/py/scripts/sendrecv.py b/externals/grill/py/scripts/sendrecv.py new file mode 100644 index 00000000..f31eae2d --- /dev/null +++ b/externals/grill/py/scripts/sendrecv.py @@ -0,0 +1,173 @@ +# py/pyext - python script objects for PD and MaxMSP +# +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# For information on usage and redistribution, and for a DISCLAIMER OF ALL +# WARRANTIES, see the file, "license.txt," in this distribution. +# + +"""This is an example script for the py/pyext object's send/receive functionality. + +You can: +- bind + + +There are several classes exposing py/pyext features: +- ex1: A class receiving messages and sending them out again +- ex2: A class receiving messages and putting them out to an outlet +- ex3: Do some PD scripting + +""" + +import pyext +from time import sleep + +################################################################# + +def recv_gl(arg): + """This is a global receive function, it has no access to class members.""" + print "GLOBAL",arg + +class ex1(pyext._class): + """Example of a class which receives and sends messages + + It has two creation arguments: a receiver and a sender name. + There are no inlets and outlets. + Python functions (one global function, one class method) are bound to PD's or Max/MSP's receive symbols. + The class method sends the received messages out again. + """ + + + # no inlets and outlets + _inlets=0 + _outlets=0 + + recvname="" + sendname="" + + def recv(self,arg): + """This is a class-local receive function, which has access to class members.""" + + # print some stuff + print "CLASS",self.recvname,arg + + # send data to specified send address + self._send(self.sendname,arg) + + + def __init__(self,args): + """Class constructor""" + + # store sender/receiver names + if len(args) >= 1: self.recvname = args[0] + if len(args) >= 2: self.sendname = args[1] + + # bind functions to receiver names + # both are called upon message + self._bind(self.recvname,self.recv) + self._bind(self.recvname,recv_gl) + + + def __del__(self): + """Class destructor""" + + # you can but you don't need to + # unbinding is automatically done at destruction + # you can also comment the _unbind lines + self._unbind(self.recvname,self.recv) + self._unbind(self.recvname,recv_gl) + + pass + + +################################################################# + +class ex2(pyext._class): + """Example of a class which receives a message and forwards it to an outlet + + It has one creation argument: the receiver name. + """ + + + # define inlets and outlets + _inlets=0 + _outlets=1 + + recvname="" + + def recv(self,arg): + """This is a class-local receive function""" + + # send received data to outlet + self._outlet(1,arg) + + + def __init__(self,rname): + """Class constructor""" + + # store receiver names + self.recvname = rname + + # bind function to receiver name + self._bind(self.recvname,self.recv) + + +################################################################# + +from math import sin,cos,pi +from cmath import exp +from random import random,randint + +class ex3(pyext._class): + """Example of a class which does some object manipulation by scripting""" + + + # define inlets and outlets + _inlets=1 + _outlets=0 + + def __init__(self): + """Class constructor""" + + # called scripting method should run on its own thread + self._detach(1) + + + def bang_1(self): + """Do some scripting - PD only!""" + + num = 12 # number of objects + ori = complex(150,150) # origin + rad = 100 # radius + l = range(num) # initialize list + + # make flower + self._tocanvas("obj",ori.real,ori.imag,"bng",20,250,50,0,"empty","yeah","empty",0,-6,64,8,-24198,-1,-1) + for i in range(num): + l[i] = ori+rad*exp(complex(0,i*2*pi/num)) + self._tocanvas("obj",l[i].real,l[i].imag,"bng",15,250,50,0,"empty","yeah"+str(i),"empty",0,-6,64,8,0,-1,-1) + self._tocanvas("connect",2,0,3+i,0) + + # blink + for i in range(10): + self._send("yeah","bang") + sleep(1./(i+1)) + + # move objects around + for i in range(200): + ix = randint(0,num-1) + l[ix] = ori+rad*complex(2*random()-1,2*random()-1) + self._send("yeah"+str(ix),"pos",l[ix].real,l[ix].imag) + sleep(0.02) + + # now delete + # this is not well-done... from time to time an object remains + self._tocanvas("editmode",1) + for i in range(num): + self._tocanvas("mouse",l[i].real,l[i].imag,0,0) + self._tocanvas("cut") + + self._tocanvas("mouse",ori.real+1,ori.imag+1,0,0) + self._tocanvas("cut") + + self._tocanvas("editmode",0) + diff --git a/externals/grill/py/scripts/simple.py b/externals/grill/py/scripts/simple.py new file mode 100644 index 00000000..60cebec7 --- /dev/null +++ b/externals/grill/py/scripts/simple.py @@ -0,0 +1,206 @@ +# py/pyext - python script objects for PD and MaxMSP +# +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# For information on usage and redistribution, and for a DISCLAIMER OF ALL +# WARRANTIES, see the file, "license.txt," in this distribution. +# + +"""This is an example script for the py/pyext object's basic functionality. + +pyext Usage: +- Import pyext + +- Inherit your class from pyext._class + +- Specfiy the number of inlets and outlets: + Use the class members (variables) _inlets and _outlets + If not given they default to 1 + You can also use class methods with the same names to return the respective number + +- Constructors/Destructors + You can specify an __init__ constructor and/or an __del__ destructor. + The constructor will be called with the object's arguments + + e.g. if your PD or MaxMSP object looks like + [pyext script class arg1 arg2 arg3] + + then the __init__(self,args) function will be called with a tuple argument + args = (arg1,arg2,arg3) + With this syntax, you will have to give at least one argument. + By defining the constructor as __init__(self,*args) you can also initialize + the class without arguments. + +- Methods called by pyext + The general format is 'tag_inlet(self,args)' resp. 'tag_inlet(self,*args)': + tag is the PD or MaxMSP message header.. either bang, float, list etc. + inlet is the inlet (starting from 1) from which messages are received. + args is a tuple which corresponds to the content of the message. args can be omitted. + + The inlet index can be omitted. The method name then has the format 'tag_(self,inlet,args)'. + Here, the inlet index is a additional parameter to the method + + You can also set up methods which react on any message. These have the special forms + _anything_inlet(self,args) + or + _anything_(self,inlet,args) + + Please see below for examples. + + Any return values are ignored - use _outlet (see below). + + Generally, you should avoid method_, method_xx forms for your non-pyext class methods. + Identifiers (variables and functions) with leading underscores are reserved for pyext. + +- Send messages to outlets: + Use the inherited _outlet method. + You can either use the form + self._outlet(outlet,arg1,arg2,arg3,arg4) ... where all args are atoms (no sequence types!) + or + self._outlet(outlet,arg) ... where arg is a sequence containing only atoms + +- Use pyext functions and methods: + See the __doc__ strings of the pyext module and the pyext._class base class. + +""" + +import pyext + +################################################################# + +class ex1(pyext._class): + """Example of a simple class which receives messages and prints to the console""" + + # number of inlets and outlets + _inlets=3 + _outlets=0 + + + # methods for first inlet + + def bang_1(self): + print "Bang into first inlet" + + def float_1(self,f): + print "Float ",f," into first inlet" + + def list_1(self,s): + print "List ",s," into first inlet" + + + # methods for second inlet + + def hey_2(self): + print "Tag 'hey' into second inlet" + + def ho_2(self): + print "Tag 'ho' into second inlet" + + def lets_2(self): + print "Tag 'lets' into second inlet" + + def go_2(self): + print "Tag 'go' into second inlet" + + def _anything_2(self,args): + print "Some other message into second inlet:",args + + + # methods for third inlet + + def onearg_3(self,a): + print "Tag 'onearg' into third inlet:",a + + def twoargs_3(self,a): + if len(a) == 2: + print "Tag 'twoargs' into third inlet:",a[0],a[1] + else: + print "Tag 'twoargs': wrong number of arguments" + + def threeargs_3(self,a): + if len(a) == 3: + print "Tag 'threeargs' into third inlet",a[0],a[1],a[2] + else: + print "Tag 'threeargs': wrong number of arguments" + + def varargs_3(self,*args): + # with *args there can be arguments or not + + print "Tag 'varargs' into third inlet",args + + + +################################################################# + +class ex2(pyext._class): + """Example of a simple class which receives messages and writes to outlets""" + + # number of inlets and outlets + _inlets=3 + _outlets=2 + + # methods for all inlets + + def hello_(self,n): + print "Tag 'hello' into inlet",n + + def _anything_(self,n,args): + print "Message into inlet",n,":",args + + + # methods for first inlet + + def float_1(self,f): + self._outlet(2,f) + + # methods for second inlet + + def float_2(self,f): + self._outlet(1,f) + + +################################################################# + +# helper function - determine whether argument is a numeric type +def isNumber(value): + import types + if type(value) in (types.FloatType, types.IntType, types.LongType): + return 1 + else: + return 0 + + +class ex3(pyext._class): + """Example of a simple class doing a typical number addition + + It uses a constructor and a class member as temporary storage. + """ + + # number of inlets and outlets + _inlets=2 + _outlets=1 + + # temporary storage + tmp=0 + + # constructor + def __init__(self,*args): + if len(args) == 1: + if isNumber(args[0]): + self.tmp = args[0] + else: + print "ex3: __init__ has superfluous arguments" + + # methods + + def float_1(self,f): + self._outlet(1,self.tmp+f) + + def float_2(self,f): + self.tmp = f + + # handlers for MaxMSP int type + def int_1(self,f): + self.float_1(f) + + def int_2(self,f): + self.float_2(f) diff --git a/externals/grill/py/scripts/tcltk.py b/externals/grill/py/scripts/tcltk.py new file mode 100644 index 00000000..154a51b1 --- /dev/null +++ b/externals/grill/py/scripts/tcltk.py @@ -0,0 +1,77 @@ +# py/pyext - python script objects for PD and MaxMSP +# +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# For information on usage and redistribution, and for a DISCLAIMER OF ALL +# WARRANTIES, see the file, "license.txt," in this distribution. +# + +"""This is an example script for showing a nonsense tcl/tk application.""" + +import pyext +from Tkinter import * +import random + + +class Application(Frame): + """This is the TK application class""" + + # Button pressed + def say_hi(self): + self.extcl._outlet(1,"hi there, everyone!") + + # Mouse motion over canvas + def evfunc(self, ev): + x = random.uniform(-3,3) + y = random.uniform(-3,3) + self.mcanv.move('group',x,y) + + # Create interface stuff + def createWidgets(self): + self.hi = Button(self) + self.hi["text"] = "Hi!" + self.hi["fg"] = "red" + self.hi["command"] = self.say_hi + self.hi.pack({"side": "left"}) + + self.mcanv = Canvas(self) + self.mcanv.pack({"side": "left"}) + self.mcanv.bind("", self.evfunc) + self.mcanv.create_rectangle(50,50,200,200) + r = self.mcanv.create_rectangle(50,50,200,200) + self.mcanv.addtag_withtag('group',r) + + for i in range(500): + x = random.uniform(50,200) + y = random.uniform(50,200) + l = self.mcanv.create_line(x,y,x+1,y) + self.mcanv.addtag_withtag('group',l) + + # Constructor + def __init__(self,cl): + self.extcl = cl + Frame.__init__(self) + self.pack() + self.createWidgets() + pass + + +# derive class from pyext._class + +class myapp(pyext._class): + """This class demonstrates how a TCL/TK can be openened from within a pyext external""" + + # how many inlets and outlets? + _inlets = 1 + _outlets = 1 + + # Constructor + def __init__(self): + # detach bang method + self._detach(1) + + def bang_1(self): + self._priority(-3) + # display the tcl/tk dialog + app = Application(self) + app.mainloop() + diff --git a/externals/grill/py/scripts/threads.py b/externals/grill/py/scripts/threads.py new file mode 100644 index 00000000..e8486699 --- /dev/null +++ b/externals/grill/py/scripts/threads.py @@ -0,0 +1,43 @@ +# py/pyext - python script objects for PD and MaxMSP +# +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# For information on usage and redistribution, and for a DISCLAIMER OF ALL +# WARRANTIES, see the file, "license.txt," in this distribution. +# + +"""This is an example script for the py/pyext object's threading functionality. + +For threading support pyext exposes several function and variables + +- _detach([0/1]): by enabling thread detaching, threads will run in their own threads +- _priority(prio+-): you can raise or lower the priority of the current thread +- _stop({wait time in ms}): stop all running threads (you can additionally specify a wait time in ms) +- _shouldexit: this is a flag which indicates that the running thread should terminate + +""" + +import pyext +from time import sleep + +################################################################# + +class ex1(pyext._class): + """This is a simple class with one method looping over time.""" + + # number of inlets and outlets + _inlets=2 + _outlets=2 + + sltime=0.2 # sleep time + loops=30 # loops to iterate + + # method for bang to any inlet + def bang_(self,n): + for i in range(30): + # if _shouldexit is true, the thread ought to stop + if self._shouldexit: break + + self._outlet(n,i) + sleep(self.sltime) + + diff --git a/externals/grill/py/source/bound.cpp b/externals/grill/py/source/bound.cpp new file mode 100644 index 00000000..651bb52b --- /dev/null +++ b/externals/grill/py/source/bound.cpp @@ -0,0 +1,143 @@ +/* + +py/pyext - python external object for PD and MaxMSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "pyext.h" +#include "flinternal.h" + +t_class *pyext::px_class; +pyext::py_proxy *pyext::px_head,*pyext::px_tail; + +void pyext::py_proxy::px_method(py_proxy *obj,const t_symbol *s,int argc,t_atom *argv) +{ + PY_LOCK + + PyObject *args = MakePyArgs(s,AtomList(argc,argv),-1,obj->self != NULL); + PyObject *ret = PyObject_CallObject(obj->func,args); + if(!ret) { + PyErr_Print(); + } + Py_XDECREF(ret); + + PY_UNLOCK +} + + +PyObject *pyext::pyext_bind(PyObject *,PyObject *args) +{ + PyObject *self,*meth; + C *name; + if(!PyArg_ParseTuple(args, "OsO:pyext_bind", &self,&name,&meth)) + post("py/pyext - Wrong arguments!"); + else if(!PyInstance_Check(self) || !(PyMethod_Check(meth) || PyFunction_Check(meth))) { + post("py/pyext - Wrong argument types!"); + } + else { + t_symbol *recv = gensym(name); +/* + if(GetBound(recv)) + post("py/pyext - Symbol \"%s\" is already hooked",GetString(recv)); +*/ + // make a proxy object + py_proxy *px = (py_proxy *)object_new(px_class); + if(PyMethod_Check(meth)) { + PyObject *no = PyObject_GetAttrString(meth,"__name__"); + meth = PyObject_GetAttr(self,no); + Py_DECREF(no); + } + px->init(recv,self,meth); + + // add it to the list + if(px_tail) px_tail->nxt = px; + else px_head = px; + px_tail = px; + + // Do bind + pd_bind(&px->obj.ob_pd,recv); + + Py_INCREF(self); // self is borrowed reference + } + + Py_INCREF(Py_None); + return Py_None; +} + +PyObject *pyext::pyext_unbind(PyObject *,PyObject *args) +{ + PyObject *self,*meth; + C *name; + if(!PyArg_ParseTuple(args, "OsO:pyext_bind", &self,&name,&meth)) + post("py/pyext - Wrong arguments!"); + else if(!PyInstance_Check(self) || !(PyMethod_Check(meth) || PyFunction_Check(meth))) { + post("py/pyext - Wrong argument types!"); + } + else { + t_symbol *recv = gensym(name); + if(PyMethod_Check(meth)) { + PyObject *no = PyObject_GetAttrString(meth,"__name__"); + meth = PyObject_GetAttr(self,no); // meth is given a new reference! + Py_DECREF(no); + } + + // search proxy object + py_proxy *pp = NULL,*px = px_head; + while(px) { + py_proxy *pn = px->nxt; + if(recv == px->name && self == px->self && meth == px->func) { + if(pp) + pp->nxt = pn; + else + px_head = pn; + if(!pn) px_tail = pp; + break; + } + else pp = px; + px = pn; + } + + // do unbind + if(px) { + pd_unbind(&px->obj.ob_pd,recv); + object_free(px->obj); + + Py_DECREF(self); + if(PyMethod_Check(meth)) Py_DECREF(meth); + } + } + + Py_INCREF(Py_None); + return Py_None; +} + + +V pyext::ClearBinding() +{ + // search proxy object + py_proxy *pp = NULL,*px = px_head; + while(px) { + py_proxy *pn = px->nxt; + if(px->self == pyobj) { + if(pp) + pp->nxt = pn; + else + px_head = pn; + if(!pn) px_tail = pp; + + Py_DECREF(px->self); + if(PyMethod_Check(px->func)) Py_DECREF(px->func); + + pd_unbind(&px->obj.ob_pd,px->name); + object_free(px->obj); + } + else pp = px; + px = pn; + } +} + + diff --git a/externals/grill/py/source/clmeth.cpp b/externals/grill/py/source/clmeth.cpp new file mode 100644 index 00000000..0a30d1f7 --- /dev/null +++ b/externals/grill/py/source/clmeth.cpp @@ -0,0 +1,278 @@ +/* + +py/pyext - python external object for PD and MaxMSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "pyext.h" + + +PyMethodDef pyext::meth_tbl[] = +{ + {"__init__", pyext::pyext__init__, METH_VARARGS, "Constructor"}, + {"__del__", pyext::pyext__del__, METH_VARARGS, "Destructor"}, + + {"_outlet", pyext::pyext_outlet, METH_VARARGS,"Send message to outlet"}, + {"_tocanvas", pyext::pyext_tocanvas, METH_VARARGS,"Send message to canvas" }, + + { "_bind", pyext::pyext_bind, METH_VARARGS,"Bind function to a receiving symbol" }, + { "_unbind", pyext::pyext_unbind, METH_VARARGS,"Unbind function from a receiving symbol" }, +#ifdef FLEXT_THREADS + { "_detach", pyext::pyext_detach, METH_VARARGS,"Set detach flag for called methods" }, + { "_stop", pyext::pyext_stop, METH_VARARGS,"Stop running threads" }, +#endif + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +PyMethodDef pyext::attr_tbl[] = +{ + { "__setattr__", pyext::pyext_setattr, METH_VARARGS,"Set class attribute" }, + { "__getattr__", pyext::pyext_getattr, METH_VARARGS,"Get class attribute" }, + { NULL, NULL,0,NULL }, +}; + + +const C *pyext::pyext_doc = + "py/pyext - python external object for PD and MaxMSP, (C)2002 Thomas Grill\n" + "\n" + "This is the pyext base class. Available methods:\n" + "_outlet(self,ix,args...): Send a message to an indexed outlet\n" + "_tocanvas(self,args...): Send a message to the parent canvas\n" +#ifdef FLEXT_THREADS + "_detach(self,int): Define whether a called Python method has its own thread\n" +#endif + "_bind(self,name,func): Bind a python function to a symbol\n" + "_unbind(self,name,func): Unbind a python function from a symbol\n" +; + +PyObject* pyext::pyext__init__(PyObject *,PyObject *args) +{ +// post("pyext.__init__ called"); + + Py_INCREF(Py_None); + return Py_None; +} + +PyObject* pyext::pyext__del__(PyObject *,PyObject *args) +{ +// post("pyext.__del__ called"); + + Py_INCREF(Py_None); + return Py_None; +} + +PyObject* pyext::pyext_setattr(PyObject *,PyObject *args) +{ + PyObject *self,*name,*val,*ret = NULL; + if(!PyArg_ParseTuple(args, "OOO:test_foo", &self,&name,&val)) { + // handle error + ERRINTERNAL(); + return NULL; + } + + BL handled = false; + if(PyString_Check(name)) { + char* sname = PyString_AsString(name); + if (sname) { +// post("pyext::setattr %s",sname); + } + } + + if(!handled) { + if(PyInstance_Check(self)) + PyDict_SetItem(((PyInstanceObject *)self)->in_dict, name,val); + else + ERRINTERNAL(); + } + + Py_INCREF(Py_None); + return Py_None; +} + +PyObject* pyext::pyext_getattr(PyObject *,PyObject *args) +{ + PyObject *self,*name,*ret = NULL; + if(!PyArg_ParseTuple(args, "OO:test_foo", &self,&name)) { + // handle error + ERRINTERNAL(); + } + + if(PyString_Check(name)) { + char* sname = PyString_AsString(name); + if (sname) { + if(!strcmp(sname,"_shouldexit")) { + pyext *ext = GetThis(self); + if(ext) + ret = PyLong_FromLong(ext->shouldexit?1:0); + } +// post("pyext::getattr %s",sname); + } + } + + if(!ret) { +#if PY_VERSION_HEX >= 0x02020000 + ret = PyObject_GenericGetAttr(self,name); +#else + if(PyInstance_Check(self)) + ret = PyDict_GetItem(((PyInstanceObject *)self)->in_dict,name); +#endif + } + return ret; +} + + +//! Send message to outlet +PyObject *pyext::pyext_outlet(PyObject *,PyObject *args) +{ + BL ok = false; + if(PySequence_Check(args)) { + PyObject *self = PySequence_GetItem(args,0); + PyObject *outl = PySequence_GetItem(args,1); + if( + self && PyInstance_Check(self) && + outl && PyInt_Check(outl) + ) { + pyext *ext = GetThis(self); + + I sz = PySequence_Size(args); + PyObject *val; + BL tp = sz == 3 && PySequence_Check(PySequence_GetItem(args,2)); + + if(tp) + val = PySequence_GetItem(args,2); // borrowed + else + val = PySequence_GetSlice(args,2,sz); // new ref + + AtomList *lst = GetPyArgs(val); + if(lst) { + I o = PyInt_AsLong(outl); + if(o >= 1 && o <= ext->Outlets()) { + // by using the queue there is no immediate call of the next object + // deadlock would occur if this was another py/pyext object! + if(lst->Count() && IsSymbol((*lst)[0])) + ext->ToQueueAnything(o-1,GetSymbol((*lst)[0]),lst->Count()-1,lst->Atoms()+1); + else + ext->ToQueueList(o-1,*lst); + } + else + post("pyext: outlet index out of range"); + + ok = true; + } + else + post("py/pyext - No data to send"); + if(lst) delete lst; + + if(!tp) Py_DECREF(val); + } + } + + if(!ok) post("pyext - Syntax: _outlet(self,outlet,args...)"); + + Py_INCREF(Py_None); + return Py_None; +} + + + +#ifdef FLEXT_THREADS +//! Detach threads +PyObject *pyext::pyext_detach(PyObject *,PyObject *args) +{ + PyObject *self; + int val; + if(!PyArg_ParseTuple(args, "Oi:pyext_detach",&self,&val)) { + // handle error + post("pyext - Syntax: _detach(self,[0/1])"); + } + else { + pyext *ext = GetThis(self); + ext->m_detach(val != 0); + } + + Py_INCREF(Py_None); + return Py_None; +} + +//! Stop running threads +PyObject *pyext::pyext_stop(PyObject *,PyObject *args) +{ + PyObject *self; + int val = -1; + if(!PyArg_ParseTuple(args, "O|i:pyext_stop",&self,&val)) { + // handle error + post("pyext - Syntax: _stop(self,{wait time}"); + } + else { + pyext *ext = GetThis(self); + I cnt = 0; + t_atom at; + if(val >= 0) flext::SetInt(at,val); + ext->m_stop(cnt,&at); + } + + Py_INCREF(Py_None); + return Py_None; +} + +#endif + +//! Send message to canvas +PyObject *pyext::pyext_tocanvas(PyObject *,PyObject *args) +{ + BL ok = false; + if(PySequence_Check(args)) { + PyObject *self = PySequence_GetItem(args,0); + if(self && PyInstance_Check(self)) { + pyext *ext = GetThis(self); + +#ifdef PD + I sz = PySequence_Size(args); + PyObject *val; + BL tp = sz == 2 && PySequence_Check(PyTuple_GetItem(args,1)); + + if(tp) + val = PySequence_GetItem(args,1); // borrowed + else + val = PySequence_GetSlice(args,1,sz); // new ref + + AtomList *lst = GetPyArgs(val); + if(lst) { + t_glist *gl = ext->thisCanvas(); //canvas_getcurrent(); + t_class **cl = (t_pd *)gl; + if(cl) { +#ifdef PD + pd_forwardmess(cl,lst->Count(),lst->Atoms()); +#else + #pragma message ("Send is not implemented") +#endif + } +#ifdef _DEBUG + else + post("pyext - no parent canvas?!"); +#endif + ok = true; + } + else + post("py/pyext - No data to send"); + if(lst) delete lst; + + if(!tp) Py_DECREF(val); +#else +#pragma message ("Not implemented for MaxMSP") +#endif + } + } + + if(!ok) post("pyext - Syntax: _tocanvas(self,args...)"); + + Py_INCREF(Py_None); + return Py_None; +} + + + diff --git a/externals/grill/py/source/main.cpp b/externals/grill/py/source/main.cpp new file mode 100644 index 00000000..65e1d274 --- /dev/null +++ b/externals/grill/py/source/main.cpp @@ -0,0 +1,212 @@ +/* + +py/pyext - python external object for PD and MaxMSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "main.h" + + +V py::lib_setup() +{ + post(""); + post("py/pyext %s - python script objects, (C)2002 Thomas Grill",PY__VERSION); + post(""); + + FLEXT_SETUP(pyobj); + FLEXT_SETUP(pyext); + + pyref = 0; +} + +FLEXT_LIB_SETUP(py,py::lib_setup) + +PyInterpreterState *py::pystate = NULL; + + +I py::pyref = 0; +PyObject *py::module_obj = NULL; +PyObject *py::module_dict = NULL; + + +py::py(): + module(NULL), + detach(false),shouldexit(false),thrcount(0), + clk(NULL),stoptick(0) +{ + Lock(); + // under Max/MSP: doesn't survive next line..... + + if(!(pyref++)) { + Py_Initialize(); + + #ifdef FLEXT_THREADS + PyEval_InitThreads(); + + pystate = PyThreadState_Get()->interp; + #endif + // register/initialize pyext module only once! + module_obj = Py_InitModule(PYEXT_MODULE, func_tbl); + module_dict = PyModule_GetDict(module_obj); + + PyModule_AddStringConstant(module_obj,"__doc__",(C *)py_doc); + + #ifdef FLEXT_THREADS + pythrmain = PyEval_SaveThread(); + #endif + } + else { + PY_LOCK + Py_INCREF(module_obj); + Py_INCREF(module_dict); + PY_UNLOCK + } + + Unlock(); + + clk = clock_new(this,(t_method)tick); +} + +py::~py() +{ + if(thrcount) { + shouldexit = true; + + // Wait for a certain time + for(int i = 0; i < (PY_STOP_WAIT/PY_STOP_TICK) && thrcount; ++i) Sleep((F)(PY_STOP_TICK/1000.)); + + // Wait forever + post("%s - Waiting for thread termination!",thisName()); + while(thrcount) Sleep(0.2f); + post("%s - Okay, all threads have terminated",thisName()); + } + +/* + // don't unregister + + Lock(); + + if(!(--pyref)) { + Py_DECREF(module_obj); + module_obj = NULL; + Py_DECREF(module_dict); + module_dict = NULL; + + Py_XDECREF(module); + +// delete modules; modules = NULL; + + PyEval_AcquireThread(pythrmain); + PyThreadState *new_state = PyThreadState_New(pystate); // must have lock + PyThreadState *prev_state = PyThreadState_Swap(new_state); + + Py_Finalize(); + } + + Unlock(); +*/ + if(clk) clock_free(clk); +} + + +V py::m_doc() +{ + if(dict) { + PyObject *docf = PyDict_GetItemString(dict,"__doc__"); // borrowed!!! + if(docf && PyString_Check(docf)) { + post(""); + post(PyString_AsString(docf)); + } + } +} + + + + +V py::SetArgs(I argc,t_atom *argv) +{ + // script arguments + C **sargv = new C *[argc+1]; + for(int i = 0; i <= argc; ++i) { + sargv[i] = new C[256]; + if(!i) + strcpy(sargv[i],thisName()); + else + GetAString(argv[i-1],sargv[i],255); + } + + // the arguments to the module are only recognized once! (at first use in a patcher) + PySys_SetArgv(argc+1,sargv); + + for(int j = 0; j <= argc; ++j) delete[] sargv[j]; + delete[] sargv; +} + +V py::ImportModule(const C *name) +{ + if(!name) return; + + module = PyImport_ImportModule((C *)name); + if (!module) { + PyErr_Print(); + dict = NULL; + } + else + dict = PyModule_GetDict(module); // borrowed + +} + + +V py::ReloadModule() +{ + if(module) { + PyObject *newmod = PyImport_ReloadModule(module); + if(!newmod) { + PyErr_Print(); + // old module still exists?! +// dict = NULL; + } + else { + Py_XDECREF(module); + module = newmod; + dict = PyModule_GetDict(module); // borrowed + } + } + else + post("%s - No module to reload",thisName()); +} + +V py::GetModulePath(const C *mod,C *dir,I len) +{ +#ifdef PD + // uarghh... pd doesn't show it's path for extra modules + + C *name; + I fd = open_via_path("",mod,".py",dir,&name,len,0); + if(fd > 0) close(fd); + else name = NULL; + + // if dir is current working directory... name points to dir + if(dir == name) strcpy(dir,"."); +#elif defined(MAXMSP) + *dir = 0; +#endif +} + +V py::AddToPath(const C *dir) +{ + if(dir && *dir) { + PyObject *pobj = PySys_GetObject("path"); + if(pobj && PyList_Check(pobj)) { + PyObject *ps = PyString_FromString(dir); + PyList_Append(pobj,ps); + } + PySys_SetObject("path",pobj); + } +} + + diff --git a/externals/grill/py/source/main.h b/externals/grill/py/source/main.h new file mode 100644 index 00000000..66b332cf --- /dev/null +++ b/externals/grill/py/source/main.h @@ -0,0 +1,147 @@ +/* + +py/pyext - python script object for PD and MaxMSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#ifndef __MAIN_H +#define __MAIN_H + +#include +#include +#ifndef NT +#include +#endif + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400) +#error You need at least flext version 0.4.0 +#endif + +#define PY__VERSION "0.1.1pre3" + + +#define PYEXT_MODULE "pyext" // name for module +#define PYEXT_CLASS "_class" // name for base class + +#define PY_STOP_WAIT 1000 // ms +#define PY_STOP_TICK 10 // ms + + + +#define I int +#define C char +#define V void +#define BL bool +#define F float +#define D double + + +#include "main.h" + +class py: + public flext_base +{ + FLEXT_HEADER(py,flext_base) + +public: + py(); + ~py(); + static V lib_setup(); + + static PyObject *MakePyArgs(const t_symbol *s,const AtomList &args,I inlet = -1,BL withself = false); + static AtomList *GetPyArgs(PyObject *pValue,PyObject **self = NULL); + +protected: + + V m_doc(); + + PyObject *module,*dict; // inherited user class module and associated dictionary + + static I pyref; + static const C *py_doc; + + V GetModulePath(const C *mod,C *dir,I len); + V AddToPath(const C *dir); + V SetArgs(I argc,t_atom *argv); + V ImportModule(const C *name); + V ReloadModule(); + + V Register(const C *reg); + V Unregister(const C *reg); + V Reregister(const C *reg); + virtual V Reload() = 0; + + static BL IsAnything(const t_symbol *s) { return s && s != sym_bang && s != sym_float && s != sym_int && s != sym_symbol && s != sym_list && s != sym_pointer; } + + enum retval { nothing,atom,sequ /*,tuple,list*/ }; + + // --- module stuff ----- + + static PyObject *module_obj,*module_dict; + static PyMethodDef func_tbl[]; + + static PyObject *py__doc__(PyObject *,PyObject *args); + static PyObject *py_send(PyObject *,PyObject *args); +#ifdef FLEXT_THREADS + static PyObject *py_priority(PyObject *,PyObject *args); +#endif + + static PyObject *py_samplerate(PyObject *,PyObject *args); + static PyObject *py_blocksize(PyObject *,PyObject *args); + static PyObject *py_inchannels(PyObject *,PyObject *args); + static PyObject *py_outchannels(PyObject *,PyObject *args); + + // ----thread stuff ------------ + + V m_detach(BL det) { detach = det; } + virtual V m_stop(int argc,t_atom *argv); + + BL detach,shouldexit; + I thrcount; + t_clock *clk; + I stoptick; + + static V tick(py *obj); + +public: + static PyInterpreterState *pystate; + PyThreadState *pythrmain; + +#ifdef FLEXT_THREADS + ThrMutex mutex; + V Lock() { mutex.Unlock(); } + V Unlock() { mutex.Unlock(); } +#else + V Lock() {} + V Unlock() {} +#endif + +protected: + // callbacks + + FLEXT_CALLBACK_B(m_detach) + FLEXT_CALLBACK_V(m_stop) + FLEXT_CALLBACK(m_doc) +}; + +#ifdef FLEXT_THREADS +#define PY_LOCK \ + { \ + PyThreadState *thrst = PyThreadState_New(pystate); \ + PyEval_AcquireThread(thrst); + +#define PY_UNLOCK \ + PyThreadState_Clear(thrst); /* must have lock */ \ + PyEval_ReleaseThread(thrst); \ + PyThreadState_Delete(thrst); /* needn't have lock */ \ + } +#else +#define PY_LOCK +#define PY_UNLOCK +#endif + +#endif diff --git a/externals/grill/py/source/modmeth.cpp b/externals/grill/py/source/modmeth.cpp new file mode 100644 index 00000000..51e103ed --- /dev/null +++ b/externals/grill/py/source/modmeth.cpp @@ -0,0 +1,183 @@ +/* + +py/pyext - python external object for PD and MaxMSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "main.h" + + +// function table for module +PyMethodDef py::func_tbl[] = +{ + { "_send", py::py_send, METH_VARARGS,"Send message to a named object" }, +#ifdef FLEXT_THREADS + { "_priority", py::py_priority, METH_VARARGS,"Set priority of current thread" }, +#endif + + { "_samplerate", py::py_samplerate, 0,"Get system sample rate" }, + { "_blocksize", py::py_blocksize, 0,"Get system block size" }, + { "_inchannels", py::py_inchannels, 0,"Get number of audio in channels" }, + { "_outchannels", py::py_outchannels, 0,"Get number of audio out channels" }, + + {NULL, NULL, 0, NULL} // sentinel +}; + +const C *py::py_doc = + "py/pyext - python external object for PD and MaxMSP, (C)2002 Thomas Grill\n" + "\n" + "This is the pyext module. Available function:\n" + "_send(args...): Send a message to a send symbol\n" +#ifdef FLEXT_THREADS + "_priority(int): Raise/lower thread priority\n" +#endif + "_samplerate(): Get system sample rate\n" + "_blocksize(): Get current blocksize\n" + "_inchannels(): Get number of audio in channels\n" + "_outchannels(): Get number of audio out channels\n" +; + + + +V py::tick(py *th) +{ + th->Lock(); + + if(!th->thrcount) { + // all threads have stopped + th->shouldexit = false; + th->stoptick = 0; + } + else { + // still active threads + if(!--th->stoptick) { + post("%s - Threads couldn't be stopped entirely - %i remaining",th->thisName(),th->thrcount); + th->shouldexit = false; + } + else + // continue waiting + clock_delay(th->clk,PY_STOP_TICK); + } + + th->Unlock(); +} + +V py::m_stop(int argc,t_atom *argv) +{ + if(thrcount) { + Lock(); + + I wait = PY_STOP_WAIT; + if(argc >= 1 && CanbeInt(argv[0])) wait = GetAInt(argv[0]); + + I ticks = wait/PY_STOP_TICK; + if(stoptick) { + // already stopping + if(ticks < stoptick) stoptick = ticks; + } + else + stoptick = ticks; + shouldexit = true; + clock_delay(clk,PY_STOP_TICK); + + Unlock(); + } + +} + +PyObject *py::py_samplerate(PyObject *self,PyObject *args) +{ + return PyFloat_FromDouble(sys_getsr()); +} + +PyObject *py::py_blocksize(PyObject *self,PyObject *args) +{ + return PyLong_FromLong(sys_getblksize()); +} + +PyObject *py::py_inchannels(PyObject *self,PyObject *args) +{ +#ifdef PD + I ch = sys_get_inchannels(); +#else // MAXMSP + I ch = sys_getch(); // not functioning +#endif + return PyLong_FromLong(ch); +} + +PyObject *py::py_outchannels(PyObject *self,PyObject *args) +{ +#ifdef PD + I ch = sys_get_outchannels(); +#else // MAXMSP + I ch = sys_getch(); // not functioning +#endif + return PyLong_FromLong(ch); +} + +PyObject *py::py_send(PyObject *,PyObject *args) +{ + if(PySequence_Check(args)) { + PyObject *name = PySequence_GetItem(args,0); // borrowed + if(name && PyString_Check(name)) { + const t_symbol *recv = MakeSymbol(PyString_AsString(name)); + I sz = PySequence_Size(args); + PyObject *val; + BL tp = sz == 2 && PySequence_Check(PySequence_GetItem(args,1)); + + if(tp) + val = PySequence_GetItem(args,1); // borrowed + else + val = PySequence_GetSlice(args,1,sz); // new ref + + AtomList *lst = GetPyArgs(val); + if(lst) { +// t_class **cl = (t_class **)GetBound(recv); + t_class **cl = (t_class **)recv->s_thing; + if(cl) { +#ifdef PD + pd_forwardmess(cl,lst->Count(),lst->Atoms()); +#else + #pragma message ("Send is not implemented") +#endif + } +#ifdef _DEBUG + else + post("py/pyext - Receiver doesn't exist"); +#endif + } + else + post("py/pyext - No data to send"); + if(lst) delete lst; + + if(!tp) Py_DECREF(val); + } + else + post("py/pyext - Send name is invalid"); + } + + Py_INCREF(Py_None); + return Py_None; +} + +#ifdef FLEXT_THREADS +PyObject *py::py_priority(PyObject *self,PyObject *args) +{ + int val; + if(!PyArg_ParseTuple(args, "i:py_priority", &val)) { + post("py/pyext - Syntax: _priority [int]"); + } + else + ChangePriority(val); + + Py_INCREF(Py_None); + return Py_None; +} +#endif + + + diff --git a/externals/grill/py/source/py.cpp b/externals/grill/py/source/py.cpp new file mode 100644 index 00000000..83c5d9b5 --- /dev/null +++ b/externals/grill/py/source/py.cpp @@ -0,0 +1,327 @@ +/* + +py/pyext - python script object for PD and MaxMSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "main.h" + + +class pyobj: + public py +{ + FLEXT_HEADER(pyobj,py) + +public: + pyobj(I argc,t_atom *argv); + ~pyobj(); + +protected: + BL m_method_(I n,const t_symbol *s,I argc,t_atom *argv); + + V work(const t_symbol *s,I argc,t_atom *argv); + + V m_bang() { work(sym_bang,0,NULL); } + V m_reload(); + V m_reload_(I argc,t_atom *argv); + V m_set(I argc,t_atom *argv); + V m_doc_(); + + virtual V m_help(); + + // methods for python arguments + V callwork(const t_symbol *s,I argc,t_atom *argv); + + V m_py_list(I argc,t_atom *argv) { callwork(sym_list,argc,argv); } + V m_py_float(I argc,t_atom *argv) { callwork(sym_float,argc,argv); } + V m_py_int(I argc,t_atom *argv) { callwork(sym_int,argc,argv); } + V m_py_any(const t_symbol *s,I argc,t_atom *argv) { callwork(s,argc,argv); } + + const t_symbol *funname; + PyObject *function; + + virtual V Reload(); + + V SetFunction(const C *func); + V ResetFunction(); + +private: + + FLEXT_CALLBACK(m_bang) + FLEXT_CALLBACK(m_reload) + FLEXT_CALLBACK_V(m_reload_) + FLEXT_CALLBACK_V(m_set) + FLEXT_CALLBACK(m_doc_) + + FLEXT_CALLBACK_V(m_py_float) + FLEXT_CALLBACK_V(m_py_list) + FLEXT_CALLBACK_V(m_py_int) + FLEXT_CALLBACK_A(m_py_any) + +#ifdef FLEXT_THREADS + FLEXT_THREAD_A(work) +#else + FLEXT_CALLBACK_A(work) +#endif +}; + +FLEXT_LIB_V("py",pyobj) + + +pyobj::pyobj(I argc,t_atom *argv): + function(NULL),funname(NULL) +{ + PY_LOCK + + AddInAnything(2); + AddOutAnything(); + + FLEXT_ADDBANG(0,m_bang); + FLEXT_ADDMETHOD_(0,"reload",m_reload_); + FLEXT_ADDMETHOD_(0,"reload.",m_reload); + FLEXT_ADDMETHOD_(0,"set",m_set); + FLEXT_ADDMETHOD_(0,"doc",m_doc); + FLEXT_ADDMETHOD_(0,"doc+",m_doc_); +#ifdef FLEXT_THREADS + FLEXT_ADDMETHOD_(0,"detach",m_detach); + FLEXT_ADDMETHOD_(0,"stop",m_stop); +#endif + + FLEXT_ADDMETHOD_(1,"float",m_py_float); + FLEXT_ADDMETHOD_(1,"int",m_py_int); + FLEXT_ADDMETHOD(1,m_py_list); + FLEXT_ADDMETHOD(1,m_py_any); + + if(argc > 2) + SetArgs(argc-2,argv+2); + else + SetArgs(0,NULL); + + // init script module + if(argc >= 1) { + C dir[1024]; + GetModulePath(GetString(argv[0]),dir,sizeof(dir)); + // set script path + AddToPath(dir); + + if(!IsString(argv[0])) + post("%s - script name argument is invalid",thisName()); + else + ImportModule(GetString(argv[0])); + } + + Register("_py"); + + if(argc >= 2) { + // set function name + if(!IsString(argv[1])) + post("%s - function name argument is invalid",thisName()); + else { + // Set function + SetFunction(GetString(argv[1])); + } + } + + PY_UNLOCK +} + +pyobj::~pyobj() +{ + PY_LOCK + Unregister("_py"); + PY_UNLOCK +} + + + + +BL pyobj::m_method_(I n,const t_symbol *s,I argc,t_atom *argv) +{ + if(n == 1) + post("%s - no method for type %s",thisName(),GetString(s)); + return false; +} + +V pyobj::m_reload() +{ + PY_LOCK + + Unregister("_py"); + + ReloadModule(); + Reregister("_py"); + Register("_py"); + SetFunction(funname?GetString(funname):NULL); + + PY_UNLOCK +} + +V pyobj::m_reload_(I argc,t_atom *argv) +{ + PY_LOCK + SetArgs(argc,argv); + PY_UNLOCK + + m_reload(); +} + +V pyobj::m_set(I argc,t_atom *argv) +{ + PY_LOCK + + I ix = 0; + if(argc >= 2) { + if(!IsString(argv[ix])) { + post("%s - script name is not valid",thisName()); + return; + } + const C *sn = GetString(argv[ix]); + + if(!module || !strcmp(sn,PyModule_GetName(module))) { + ImportModule(sn); + Register("_py"); + } + + ++ix; + } + + if(!IsString(argv[ix])) + post("%s - function name is not valid",thisName()); + else + SetFunction(GetString(argv[ix])); + + PY_UNLOCK +} + + +V pyobj::m_doc_() +{ + PY_LOCK + + if(function) { + PyObject *docf = PyObject_GetAttrString(function,"__doc__"); // borrowed!!! + if(docf && PyString_Check(docf)) { + post(""); + post(PyString_AsString(docf)); + } + } + + PY_UNLOCK +} + + +V pyobj::m_help() +{ + post(""); + post("py %s - python script object, (C)2002 Thomas Grill",PY__VERSION); +#ifdef _DEBUG + post("compiled on " __DATE__ " " __TIME__); +#endif + + post("Arguments: %s [script name] [function name] {args...}",thisName()); + + post("Inlet 1:messages to control the py object"); + post(" 2:call python function with message as argument(s)"); + post("Outlet: 1:return values from python function"); + post("Methods:"); + post("\thelp: shows this help"); + post("\tbang: call script without arguments"); + post("\tset [script name] [function name]: set (script and) function name"); + post("\treload {args...}: reload python script"); + post("\treload. : reload with former arguments"); + post("\tdoc: display module doc string"); + post("\tdoc+: display function doc string"); +#ifdef FLEXT_THREADS + post("\tdetach 0/1: detach threads"); + post("\tstop {wait time (ms)}: stop threads"); +#endif + post(""); +} + +V pyobj::ResetFunction() +{ + if(!module || !dict) + { + post("%s - No module loaded",thisName()); + function = NULL; + return; + } + + function = funname?PyDict_GetItemString(dict,(C *)GetString(funname)):NULL; // borrowed!!! + if(!function) { + PyErr_Clear(); + if(funname) post("%s - Function %s could not be found",thisName(),GetString(funname)); + } + else if(!PyFunction_Check(function)) { + post("%s - Object %s is not a function",thisName(),GetString(funname)); + function = NULL; + } +} + +V pyobj::SetFunction(const C *func) +{ + if(func) { + funname = MakeSymbol(func); + ResetFunction(); + } + else + function = NULL,funname = NULL; +} + + +V pyobj::Reload() +{ + ResetFunction(); +} + + +V pyobj::work(const t_symbol *s,I argc,t_atom *argv) +{ + AtomList *rargs = NULL; + + ++thrcount; + PY_LOCK + + if(function) { + PyObject *pArgs = MakePyArgs(s,AtomList(argc,argv)); + PyObject *pValue = PyObject_CallObject(function, pArgs); + + rargs = GetPyArgs(pValue); + if(!rargs) PyErr_Print(); + + Py_XDECREF(pArgs); + Py_XDECREF(pValue); + } + else { + post("%s: no function defined",thisName()); + } + + PY_UNLOCK + --thrcount; + + if(rargs) { + // call to outlet _outside_ the Mutex lock! + // otherwise (if not detached) deadlock will occur + ToOutList(0,*rargs); + delete rargs; + } +} + +V pyobj::callwork(const t_symbol *s,I argc,t_atom *argv) +{ + if(detach) { + if(shouldexit) + post("%s - New threads can't be launched now!",thisName()); + else + if(!FLEXT_CALLMETHOD_A(work,s,argc,argv)) + post("%s - Failed to launch thread!",thisName()); + } + else + work(s,argc,argv); +} + + diff --git a/externals/grill/py/source/pyargs.cpp b/externals/grill/py/source/pyargs.cpp new file mode 100644 index 00000000..be4adaa1 --- /dev/null +++ b/externals/grill/py/source/pyargs.cpp @@ -0,0 +1,131 @@ +/* + +py/pyext - python external object for PD and MaxMSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "main.h" + + +PyObject *py::MakePyArgs(const t_symbol *s,const AtomList &args,I inlet,BL withself) +{ + PyObject *pArgs; + + BL any = IsAnything(s); + pArgs = PyTuple_New(args.Count()+(any?1:0)+(inlet >= 0?1:0)); + + I pix = 0; + + if(inlet >= 0) { + PyObject *pValue = PyInt_FromLong(inlet); + + // reference stolen: + PyTuple_SetItem(pArgs, pix++, pValue); + } + + I ix; + PyObject *tmp; + if(!withself || args.Count() < (any?1:2)) tmp = pArgs,ix = pix; + else tmp = PyTuple_New(args.Count()+(any?1:0)),ix = 0; + + if(any) { + PyObject *pValue = PyString_FromString(GetString(s)); + + // reference stolen here: + PyTuple_SetItem(tmp, ix++, pValue); + } + + for(I i = 0; i < args.Count(); ++i) { + PyObject *pValue = NULL; + + if(IsFloat(args[i])) pValue = PyFloat_FromDouble((D)GetFloat(args[i])); + else if(IsInt(args[i])) pValue = PyInt_FromLong(GetInt(args[i])); + else if(IsSymbol(args[i])) pValue = PyString_FromString(GetString(args[i])); + else if(IsPointer(args[i])) pValue = NULL; // not handled + + if(!pValue) { + post("py/pyext: cannot convert argument %i",any?i+1:i); + continue; + } + + /* pValue reference stolen here: */ + PyTuple_SetItem(tmp, ix++, pValue); + } + + if(tmp != pArgs) { + PyTuple_SetItem(pArgs, pix++, tmp); +#if PY_VERSION_HEX >= 0x02020000 + _PyTuple_Resize(&pArgs,pix); +#else + _PyTuple_Resize(&pArgs,pix,0); +#endif + } + + return pArgs; +} + +flext::AtomList *py::GetPyArgs(PyObject *pValue,PyObject **self) +{ + if(pValue == NULL) return NULL; + AtomList *ret = NULL; + + // analyze return value or tuple + + I rargc = 0; + BL ok = true; + retval tp = nothing; + + if(PyString_Check(pValue)) { + rargc = 1; + tp = atom; + } + else if(PySequence_Check(pValue)) { + rargc = PySequence_Size(pValue); + tp = sequ; + } + else { + rargc = 1; + tp = atom; + } + + ret = new AtomList(rargc); + + for(I ix = 0; ix < rargc; ++ix) { + PyObject *arg; + switch(tp) { + case sequ: arg = PySequence_GetItem(pValue,ix); break; + default: arg = pValue; + } + + if(PyInt_Check(arg)) SetInt((*ret)[ix],PyInt_AsLong(arg)); + else if(PyLong_Check(arg)) SetInt((*ret)[ix],PyLong_AsLong(arg)); + else if(PyFloat_Check(arg)) SetFloat((*ret)[ix],(F)PyFloat_AsDouble(arg)); + else if(PyString_Check(arg)) SetString((*ret)[ix],PyString_AsString(arg)); + else if(ix == 0 && self && PyInstance_Check(arg)) { + // assumed to be self ... that should be checked _somehow_ !!! + *self = arg; + } + else { + PyObject *tp = PyObject_Type(arg); + PyObject *stp = tp?PyObject_Str(tp):NULL; + C *tmp = ""; + if(stp) tmp = PyString_AsString(stp); + post("py/pyext: Could not convert argument %s",tmp); + Py_XDECREF(stp); + Py_XDECREF(tp); + ok = false; + } + // No DECREF for arg -> borrowed from pValue! + } + + if(!ok) { + delete ret; + ret = NULL; + } + return ret; +} + diff --git a/externals/grill/py/source/pyext.cpp b/externals/grill/py/source/pyext.cpp new file mode 100644 index 00000000..8e971873 --- /dev/null +++ b/externals/grill/py/source/pyext.cpp @@ -0,0 +1,465 @@ +/* + +py/pyext - python script object for PD and MaxMSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "pyext.h" +#include + + +FLEXT_LIB_V("pyext",pyext) + +V pyext::setup(t_class *) +{ + px_head = px_tail = NULL; + + px_class = class_new(gensym("pyext proxy"),NULL,NULL,sizeof(py_proxy),CLASS_PD|CLASS_NOINLET, A_NULL); + ::add_anything(px_class,py_proxy::px_method); // for other inlets +} + +pyext *pyext::GetThis(PyObject *self) +{ + PyObject *th = PyObject_GetAttrString(self,"_this"); + pyext *ret = th?(pyext *)PyLong_AsVoidPtr(th):NULL; + PyErr_Clear(); + Py_XDECREF(th); + return ret; +} + + +I pyext::pyextref = 0; +PyObject *pyext::class_obj = NULL; +PyObject *pyext::class_dict = NULL; + +pyext::pyext(I argc,t_atom *argv): + pyobj(NULL),pythr(NULL), + inlets(0),outlets(0), + methname(NULL) +{ + PY_LOCK + + if(!pyextref++) { + // register/initialize pyext base class along with module + class_dict = PyDict_New(); + PyObject *className = PyString_FromString(PYEXT_CLASS); + PyMethodDef *def; + + // add setattr/getattr to class + for(def = attr_tbl; def->ml_name; def++) { + PyObject *func = PyCFunction_New(def, NULL); + PyDict_SetItemString(class_dict, def->ml_name, func); + Py_DECREF(func); + } + + class_obj = PyClass_New(NULL, class_dict, className); + PyDict_SetItemString(module_dict, PYEXT_CLASS,class_obj); + Py_DECREF(className); + + // add methods to class + for (def = meth_tbl; def->ml_name != NULL; def++) { + PyObject *func = PyCFunction_New(def, NULL); + PyObject *method = PyMethod_New(func, NULL, class_obj); + PyDict_SetItemString(class_dict, def->ml_name, method); + Py_DECREF(func); + Py_DECREF(method); + } + +#if PY_VERSION_HEX >= 0x02020000 + // not absolutely necessary, existent in python 2.2 upwards + // make pyext functions available in class scope + PyDict_Merge(class_dict,module_dict,0); +#endif + + PyDict_SetItemString(class_dict,"__doc__",PyString_FromString(pyext_doc)); + } + else { + Py_INCREF(class_obj); + Py_INCREF(class_dict); + } + + // init script module + if(argc >= 1) { + C dir[1024]; +#ifdef PD + // add dir of current patch to path + strcpy(dir,GetString(canvas_getdir(thisCanvas()))); + AddToPath(dir); + // add current dir to path + strcpy(dir,GetString(canvas_getcurrentdir())); + AddToPath(dir); +#else + #pragma message("Adding current dir to path is not implemented") +#endif + + GetModulePath(GetString(argv[0]),dir,sizeof(dir)); + // add to path + AddToPath(dir); + + if(!IsString(argv[0])) + post("%s - script name argument is invalid",thisName()); + else { + SetArgs(0,NULL); + ImportModule(GetString(argv[0])); + } + } + + Register("_pyext"); + +// t_symbol *sobj = NULL; + if(argc >= 2) { + // object name + if(!IsString(argv[1])) + post("%s - object name argument is invalid",thisName()); + else { + methname = GetSymbol(argv[1]); + } + + args(argc-2,argv+2); + } + + if(methname) { + SetClssMeth(); + + // now get number of inlets and outlets + inlets = 1,outlets = 1; + + if(pyobj) { + PyObject *res; + res = PyObject_GetAttrString(pyobj,"_inlets"); // get ref + if(res) { + if(PyCallable_Check(res)) { + PyObject *fres = PyEval_CallObject(res,NULL); + Py_DECREF(res); + res = fres; + } + if(PyInt_Check(res)) + inlets = PyInt_AsLong(res); + Py_DECREF(res); + } + else + PyErr_Clear(); + + res = PyObject_GetAttrString(pyobj,"_outlets"); // get ref + if(res) { + if(PyCallable_Check(res)) { + PyObject *fres = PyEval_CallObject(res,NULL); + Py_DECREF(res); + res = fres; + } + if(PyInt_Check(res)) + outlets = PyInt_AsLong(res); + Py_DECREF(res); + } + else + PyErr_Clear(); + } + } + + PY_UNLOCK + + AddInAnything(1+inlets); + AddOutAnything(outlets); + + FLEXT_ADDMETHOD_(0,"reload.",m_reload); + FLEXT_ADDMETHOD_(0,"reload",m_reload_); + FLEXT_ADDMETHOD_(0,"doc",m_doc); + FLEXT_ADDMETHOD_(0,"doc+",m_doc_); + +#ifdef FLEXT_THREADS + FLEXT_ADDMETHOD_(0,"detach",m_detach); + FLEXT_ADDMETHOD_(0,"stop",m_stop); +#endif + + if(!pyobj) + InitProblem(); +} + +pyext::~pyext() +{ + PY_LOCK + + ClearBinding(); + Unregister("_pyext"); + + Py_XDECREF(pyobj); + + Py_XDECREF(class_obj); + Py_XDECREF(class_dict); +/* + // Don't unregister + + if(!--pyextref) { + class_obj = NULL; + class_dict = NULL; + } +*/ + PY_UNLOCK +} + +BL pyext::SetClssMeth() //I argc,t_atom *argv) +{ + // pyobj should already have been decref'd / cleared before getting here!! + + if(module && methname) { + PyObject *pref = PyObject_GetAttrString(module,const_cast(GetString(methname))); + if(!pref) + PyErr_Print(); + else if(PyClass_Check(pref)) { + // make instance, but don't call __init__ + pyobj = PyInstance_NewRaw(pref,NULL); + + Py_DECREF(pref); + if(pyobj == NULL) + PyErr_Print(); + else { + // remember the this pointer + PyObject *th = PyLong_FromVoidPtr(this); + int ret = PyObject_SetAttrString(pyobj,"_this",th); // ref is taken + + // call init now, after _this has been set, which is + // important for eventual callbacks from __init__ to c + PyObject *pargs = MakePyArgs(NULL,args,-1,true); + if (pargs == NULL) PyErr_Print(); + + PyObject *init; + init = PyObject_GetAttrString(pyobj,"__init__"); // get ref + if(init && PyCallable_Check(init)) { + PyObject *res = PyEval_CallObject(init,pargs); + if(!res) + PyErr_Print(); + else + Py_DECREF(res); + } + + Py_XDECREF(pargs); + } + } + else + post("%s - Type of \"%s\" is unhandled!",thisName(),GetString(methname)); + return true; + } + else + return false; +} + +V pyext::Reload() +{ + ClearBinding(); + Py_XDECREF(pyobj); + // by here, the Python class destructor should have been called! + + SetArgs(0,NULL); + ReloadModule(); + + SetClssMeth(); +} + + +V pyext::m_reload() +{ + PY_LOCK + + Unregister("_pyext"); // self + + Reload(); + + Reregister("_pyext"); // the others + Register("_pyext"); // self + + PY_UNLOCK +} + +V pyext::m_reload_(I argc,t_atom *argv) +{ + args(argc,argv); + m_reload(); +} + +V pyext::m_doc_() +{ + if(pyobj) { + PY_LOCK + + PyObject *docf = PyObject_GetAttrString(pyobj,"__doc__"); // borrowed!!! + if(docf && PyString_Check(docf)) { + post(""); + post(PyString_AsString(docf)); + } + + PY_UNLOCK + } +} + + + + +BL pyext::m_method_(I n,const t_symbol *s,I argc,t_atom *argv) +{ + if(pyobj && n >= 1) { + return callwork(n,s,argc,argv); + } + else { + post("%s - no method for type '%s' into inlet %i",thisName(),GetString(s),n); + return false; + } +} + + +V pyext::m_help() +{ + post(""); + post("pyext %s - python script object, (C)2002 Thomas Grill",PY__VERSION); +#ifdef _DEBUG + post("compiled on " __DATE__ " " __TIME__); +#endif + + post("Arguments: %s [script name] [class name] {args...}",thisName()); + + post("Inlet 1: messages to control the pyext object"); + post(" 2...: python inlets"); + post("Outlets: python outlets"); + post("Methods:"); + post("\thelp: shows this help"); + post("\treload {args...}: reload python script"); + post("\treload. : reload with former arguments"); + post("\tdoc: display module doc string"); + post("\tdoc+: display class doc string"); +#ifdef FLEXT_THREADS + post("\tdetach 0/1: detach threads"); + post("\tstop {wait time (ms)}: stop threads"); +#endif + post(""); +} + +PyObject *pyext::call(const C *meth,I inlet,const t_symbol *s,I argc,t_atom *argv) +{ + PyObject *ret = NULL; + + PyObject *pmeth = PyObject_GetAttrString(pyobj,const_cast(meth)); /* fetch bound method */ + if(pmeth == NULL) { + PyErr_Clear(); // no method found + } + else { + PyObject *pargs = MakePyArgs(s,AtomList(argc,argv),inlet?inlet:-1,true); + if(!pargs) + PyErr_Print(); + else { + ret = PyEval_CallObject(pmeth, pargs); + if (ret == NULL) // function not found resp. arguments not matching +#ifdef _DEBUG + PyErr_Print(); +#else + PyErr_Clear(); +#endif + else { +// Py_DECREF(pres); + } + + Py_DECREF(pargs); + } + Py_DECREF(pmeth); + } + + return ret; +} + +V pyext::work_wrapper(V *data) +{ + ++thrcount; +#ifdef _DEBUG + if(!data) + post("%s - no data!",thisName()); + else +#endif + { + work_data *w = (work_data *)data; + work(w->n,w->Header(),w->Count(),w->Atoms()); +// delete w; + } + --thrcount; +} + +BL pyext::callwork(I n,const t_symbol *s,I argc,t_atom *argv) +{ + if(detach) { + if(shouldexit) { + post("%s - Stopping.... new threads can't be launched now!",thisName()); + return true; + } + else { + BL ret = FLEXT_CALLMETHOD_X(work_wrapper,new work_data(n,s,argc,argv)); + if(!ret) post("%s - Failed to launch thread!",thisName()); + return true; + } + } + else + return work(n,s,argc,argv); +} + +BL pyext::work(I n,const t_symbol *s,I argc,t_atom *argv) +{ + BL retv = false; + + PY_LOCK + + PyObject *ret = NULL; + char *str = new char[strlen(GetString(s))+10]; + + { + // try tag/inlet + sprintf(str,"%s_%i",GetString(s),n); + ret = call(str,0,NULL,argc,argv); + } + + if(!ret) { + // try anything/inlet + sprintf(str,"_anything_%i",n); + if(s == sym_bang && !argc) { + t_atom argv; + SetString(argv,""); + ret = call(str,0,s,1,&argv); + } + else + ret = call(str,0,s,argc,argv); + } + if(!ret) { + // try tag at any inlet + sprintf(str,"%s_",GetString(s)); + ret = call(str,n,NULL,argc,argv); + } + if(!ret) { + // try anything at any inlet + strcpy(str,"_anything_"); + if(s == sym_bang && !argc) { + t_atom argv; + SetString(argv,""); + ret = call(str,n,s,1,&argv); + } + else + ret = call(str,n,s,argc,argv); + } + + if(!ret) + // no matching python method found + post("%s - no matching method found for '%s' into inlet %i",thisName(),GetString(s),n); + + if(str) delete[] str; + + if(ret) { + if(!PyObject_Not(ret)) post("%s - returned value is ignored",thisName()); + Py_DECREF(ret); + retv = true; + } + + PY_UNLOCK + + return retv; +} + + + diff --git a/externals/grill/py/source/pyext.h b/externals/grill/py/source/pyext.h new file mode 100644 index 00000000..2aba0e8e --- /dev/null +++ b/externals/grill/py/source/pyext.h @@ -0,0 +1,127 @@ +/* + +py/pyext - python external object for PD and MaxMSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#ifndef __PYEXT_H +#define __PYEXT_H + +#include "main.h" + +class pyext: + public py +{ + FLEXT_HEADER_S(pyext,py,setup) + +public: + pyext(I argc,t_atom *argv); + ~pyext(); + + static PyObject *pyext__doc__(PyObject *,PyObject *args); + static PyObject *pyext__init__(PyObject *,PyObject *args); + static PyObject *pyext__del__(PyObject *,PyObject *args); + + static PyObject *pyext_outlet(PyObject *,PyObject *args); + static PyObject *pyext_tocanvas(PyObject *,PyObject *args); + + static PyObject *pyext_setattr(PyObject *,PyObject *args); + static PyObject *pyext_getattr(PyObject *,PyObject *args); + + static PyObject *pyext_detach(PyObject *,PyObject *args); + static PyObject *pyext_stop(PyObject *,PyObject *args); + + I Inlets() const { return inlets; } + I Outlets() const { return outlets; } + +protected: + BL m_method_(I n,const t_symbol *s,I argc,t_atom *argv); + + BL work(I n,const t_symbol *s,I argc,t_atom *argv); + + V m_reload(); + V m_reload_(I argc,t_atom *argv); + V m_doc_(); + virtual V m_help(); + + const t_symbol *methname; + PyObject *pyobj; + I inlets,outlets; + +private: + static V setup(t_class *); + + static pyext *GetThis(PyObject *self); + V ClearBinding(); + BL SetClssMeth(); //I argc,t_atom *argv); + + AtomList args; + + virtual V Reload(); + + static I pyextref; + static PyObject *class_obj,*class_dict; + static PyMethodDef attr_tbl[],meth_tbl[]; + static const C *pyext_doc; + + // -------- bound stuff ------------------ + + static t_class *px_class; + + friend class py_proxy; + + class py_proxy // no virtual table! + { + public: + t_object obj; // MUST reside at memory offset 0 + PyObject *self,*func; + t_symbol *name; + + py_proxy *nxt; + + void init(t_symbol *n,PyObject *s,PyObject *f) { name = n,self = s,func = f,nxt = NULL; } +// bool cmp(PyObject *s,PyObject *f) const { return self == s && func == f; } +// void init(PyObject *s,char *f) { self = s,func = f,nxt = NULL; } +// bool cmp(PyObject *s,char *f) const { return self == s && func == f; } + static void px_method(py_proxy *c,const t_symbol *s,int argc,t_atom *argv); + }; + static py_proxy *px_head,*px_tail; + + static PyObject *pyext_bind(PyObject *,PyObject *args); + static PyObject *pyext_unbind(PyObject *,PyObject *args); + + // --------------------------- + + PyObject *call(const C *meth,I inlet,const t_symbol *s,I argc,t_atom *argv); + + V work_wrapper(void *data); + BL callwork(I n,const t_symbol *s,I argc,t_atom *argv); + + class work_data: + public flext::AtomAnything + { + public: + work_data(I _n,const t_symbol *_s,I _argc,t_atom *_argv): n(_n),AtomAnything(_s,_argc,_argv) {} + I n; + }; + +#ifdef FLEXT_THREADS + FLEXT_THREAD_X(work_wrapper) +#else + FLEXT_CALLBACK_X(work_wrapper) +#endif + + PyThreadState *pythr; + +private: + FLEXT_CALLBACK(m_reload) + FLEXT_CALLBACK_V(m_reload_) + FLEXT_CALLBACK(m_doc_) +}; + + +#endif \ No newline at end of file diff --git a/externals/grill/py/source/register.cpp b/externals/grill/py/source/register.cpp new file mode 100644 index 00000000..63a9f952 --- /dev/null +++ b/externals/grill/py/source/register.cpp @@ -0,0 +1,86 @@ +/* + +py/pyext - python external object for PD and MaxMSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "main.h" + + +V py::Register(const C *regnm) +{ + if(module) { + // add this to module registry + + PyObject *reg = PyDict_GetItemString(dict,(C *)regnm); // borrowed!!! + PyObject *add = Py_BuildValue("[i]",(long)this); + if(!reg || !PyList_Check(reg)) { + if(PyDict_SetItemString(dict,(C *)regnm,add)) { + post("%s - Could not set registry",thisName()); + } + // Py_XDECREF(reg); + } + else { + PySequence_InPlaceConcat(reg,add); + } + } + +} + +V py::Unregister(const C *regnm) +{ + if(module) { + // remove this from module registry + + PyObject *reg = PyDict_GetItemString(dict,(C *)regnm); // borrowed!!! + PyObject *add = Py_BuildValue("i",(int)this); + if(!reg || !PySequence_Check(reg)) + post("%s - Registry not found!?",thisName()); + else { + I ix = PySequence_Index(reg,add); + if(ix < 0) { + post("%s - This object not found in registry?!",thisName()); + } + else { + PySequence_DelItem(reg,ix); + } + } + Py_DECREF(add); + } + +} + +V py::Reregister(const C *regnm) +{ + if(module) { + // remove this from module registry + + PyObject *reg = PyDict_GetItemString(dict,(C *)regnm); // borrowed!!! + + if(!reg || !PySequence_Check(reg)) + post("%s - Registry not found!?",thisName()); + else { + I cnt = PySequence_Size(reg); + for(I i = 0; i < cnt; ++i) { + PyObject *it = PySequence_GetItem(reg,i); // borrowed!! + if(!it || !PyInt_Check(it)) { + post("%s - Corrupt registry?!",thisName()); + } + else { + py *th = (py *)PyInt_AsLong(it); + th->module = module; + th->dict = dict; + th->Reload(); + } + } + } + } + +} + + + diff --git a/externals/grill/xsample/MPW/MakeAliases b/externals/grill/xsample/MPW/MakeAliases new file mode 100755 index 00000000..681b5f17 --- /dev/null +++ b/externals/grill/xsample/MPW/MakeAliases @@ -0,0 +1 @@ +(This file must be converted with BinHex 4.0) :!!""8&"-BA"XG#!!!!!MR!!!&83XSIlYqXi!!!!5!*!(!J!!!!S!!!6-!!!!"3! !!!%!!!!iAep338G&@N956`#3$"!!N"J%!!!!!3!!!34IAe4&@&3!N!`3!!!!%!# 3"a!!N!3(!!!!"3!!!!-!N!4IAh4PH(3!N!TIAe4&@&3!N!`EL!!!!bJ!!!Z)!!! !!J#3#)!!"!#3#9pIBh0dFQPZC`#3"epI9%9B9!#3$"k`!!!!R!!!$V!!!!!#!*! ,!J#3#&pIF'PMFhPYBQpXAh0dG@*IAe4&@&3!N!`I6!!!!,3!!!p-!!!!!J#3#)! !"!J!N!FN!!!!!3!!!BaIAd4"9%%!N!`J!!!!%!!!!"!!!!!3!*!%"`!!!!-!!!! &!*!%AepNBA4K!*!+Aep%394"!*!-)!#3""!!!"!!N!3#!*!8AepXB9pcH@eLEfa IF(4b!&pI4%&833#3$#!3!!!!&!!!%"!!!!!#!*!,"`!!!!8!N!4IAfjXAh0jE@* [E&p`G()!Aep%394"!*!-)#3!!!!8!!!3*!!!!!)!N!X'!!!!#J#3"&pIC(PXC!# 3#PpI4%&833#3$#!i!!!!(!!!%$J!!!!#!*!8AepMEfeYEfi!N!KIAd4"9%%!N!` JB!!!!%!!N!F%!*!,!3#3#`%!!!!iAep-58j,484*9!#3#$!!!!!$R!!!)!!!!!1 F!!!!"`!!!!%!N!F%!!!!$J!!!"`!!!!-,h9cFLpXD@)[C(PXC!#3"J`!!!"N!!! !'$UHiV!!#3!!!!%!!#p6HA0dC@d[6'PLFQ&bH5p'FQ&YCAG[FQYc,d0[FQ96CA* fD@0PFbjQFQ&YCAG[FQX[9Q9bFfP[ER-[35p$Eh*P8f9bGQPMCA-!N!B-!!!!0!! !!"JkPeF%!$)!!!!"!!![GA0b,faTBLpXD@*6HA0dC@dZ3LjNH@aTBJ#3"3)!!!! B!!!J!*!%'3!!)@J!!!)d!!!!#`!!!&!!N!m4!!!!%3!!!!J!N"SK,!!!!!m!N"- &!!!!X!!!!!%!!!!S!!!EL!#3r`#3r`#3r`#3r`#3r`#3r`#3r`#33h`k#hJi)Ir m9#%!0$J!!!#3!!%!!*3Krm#!HJ!!1*S!"$YM!!&AHa!kI+6D&%J!!!Pri!!)I!J #TVq"rr#3!!%!#*3Krl"#R`!&IqJ#TRam'hKmRL0iI,dVH%J!!HNp2`!!NiN%-$d r!!#6b33d26m!!*1T"$Jp2`!!J5N%C)%T!!!X#3!!3B)!%(dS!kCp,%Yi6S!!)6d r!!#"+34JJ5N!!#`*!!""JJ!3I5J$TRdX5hK1J!!K5!!$@8J!!6dp2`!!J5N%A)! *!!!X!!!!3B)!#%J!""%p2`!!J5N%@)!*!!!X!!!!3B)!%(q$ihKra20i5!!$k6a r!!!iB`,N1)%!1%J!!C@!B3!i,!-!!%'#!!K)!!,C26m!!)%T"&3i!!!!N!!*!!# !(J!!I!N$H#`!!!""JJ"F18!!!$PJ!!"m#J#Z,!!!!%'#!#Km#9LZ,!!!,d##!!K p59S81@X!!B%q!!"m#9LZ,!!!!%#Lrq!X#J!!3B)!%$J+!!%p2`!!5!!!$$dr!!# !(J!!N!!*"$`i!!!!N!!"!$`i`3!mIkRVH)!G!!!X!!!!3B)!%)3*!!3X!!!!3+, rq$J*!!3pB,rrB@[rrh`!@%""J3!FJ5N!"(`*!%"!J3!3I!PB3%'"!!Km"J0iIi2 MH(r%mhKrTHYi5!!!p8J!!G9m#!+QNq(rr*!!!3!)P#(rX%+I!!9rk!+Q2(m!!$K M!6`iJ3!i5!!!IB!"!$Km#!1QI!`$H%k!!#'!!3"B1#%!8(`)!kD$iIrm6S!!)$e J!!#"Db!i,)X!!%''!!K1J!!J1+!!6ML!!!"JK"lm1'!!!MJ!!!4%!!!#1'!!1cJ !!!&%!!!#Iq!!#$f!!!#!$#!iI!N$TMf!!!"KM"!!6S!%)$eJ!!#"Db!mI@N$TNk !"#"m#!+QN!!"!!L8)Ir!15!!!*!!B3!m1!!!!CNK!$Q`!3!k1'%!1*NK!$K)!!' *J!%!5$JK!%"m#!1Q6S!!)(`)!UD3!!%!#*3Krm!mB'&`2)"cBf"ME(4JK("d5!! "0AaJ'hNiB!!"3B)!%(`$!hK,rrq91'!!!)!"!%Ji)3"!I!J$TNk!!#!!N!4IAf4 jE'4IE@pNAh4PFQeICR9ZBh-!!!"IAf4jE'4IE@&VC9pNC@aKH@9NAfe[C(9XC9p TEQPdD@&XDATPFPpMB@aXF`#3"&4SC5"VCA*ZC@`JFh9`F'pbG#"QEh)JG'KP)'4 jEQ&YD@-JE'PZDf9b)'Pc)'j[G#"`FQ9cC@jd)(4[)(*eEL"dD'Pc)("bEfGbB@d Z#J!!I!J#TN+I!!9pD!+Q2@X!!(`)!kD"L`#mIBN$TMPV!,a1J!3JI!J#TN+I!!9 pD!+Q2@X!!(`)!kD"L`#FIBN$TMPV!*a1J!3JI!J#TN+I!!9pD!+Q2@X!!(`)!kD "L`"mIBN$TMPV!(a1J!3JI!J#TN+I!!9pD!+Q2@X!!(`)!kD"L`"FIBN$TMPV!&a 1J!3JI!J#TN+I!!9pD!+Q2@X!!(`)!kD"L`!mIBN$TMPV!$a1J!3J!*!1(V!!!"i %!!!H"!!!(J3!!"i%!!!H"!#3"L"J!!!JD!#3(Ki%!*$r!*$r!*$r!*$r!*$r!*$ r!*$r!*$r!*$r!*$r!*$r!*$r!*$r!*$r!*$r!*$#"!m%!"!!!#!!N!3-$`3!%!! !)!3!!!!8!`!!%!!!%!#3"#J2#!!3!!!JE!!!!$m2#!!3!!!JF!!!!&`2#!!3!!! JG!!!!))2#!!3!!!JH!!!!*82#!!3!!!JI!!!!+m2#!!3!!!JJ!!!!-S2#!!3!!! JK!!!!1F2#!!3!!!JL!!!!3%2#!!3!!!JM!!!!5)2#!!3!!!JN!!!!!&%$`J!%!! !)*3!!!&S$`J!%!!!)*J!!!'*$`3!%!!!)!J!!!'5$`J!%!!!)*`!!!'M!3!!!3# 3"J'k!3!!!3#3"J(3!3!!!3#3"J(c!3#3#3)+!3!!!3#3"J)5!3#3#3)C!3!!!3# 3"J)I!3#3#KF!!!!9!!!!%`!!!")!!!!4!!!!&`!!!"8!!!!6!!!!%J!!!"%!!!! @J!!!!)!!N!B8!!!!'!#3"&p1@%&bCf-!AdjB3A*RGJ"IAfeSAf9iC@0eG'9ID'9 KC'9b!&pMBA4MD&pPH'0PF(4TEfjIFQ&TFf8!Af0KG'0SAf9iBf9`G'P[EPpbB@P cC9pcG'&dC3"IBf&dBfKICAKMCA"dD@pZAh*KDA0PAh0dBA4PAfPNC@jdDA4j!&p ME'pMDepKE'&bE9pbCA"XH3"IC'pIE@&MD&pZEh4TCRPIC'9KC&pZB@eP!&pNEep YB@0SAfj[G'PQH9pZEepcC@jNCA*c!&pNEepYB@0SAfj[G'PQH9p`Eh*dAf4PE'9 dC@3!Af4[AfeKBfKIEQpdD@CjAh0PEQ4IEfjMC3"IC'pIFf9aEQpcAfeKBfKIEQp dD@CjAf4PB@4IEQ&YC3"IC'pIFf9aEQpcAfeKBfKIEQpdD@CjAfj[Ah0PEQ4PFR- !Af4[Ah0PF@j[FepYB@0SAfj[G'PQH9p`Eh*dAf4PE'9dC@3!Af4[Ah0PF@j[Fep YB@0SAfj[G'PQH9pcC@jNAfpZBf8!Af9ZGQPbEfi!Ah*PBf9TGQ9IFf&YF'aPF`" I3f&XE%0[EA"[EQ9ZG%4TFh"KG'0S!&p2F'9Z4'9QBA9XG%0[EA"[EQ9ZG!"IAep VCAPYCh*IC(GKFQBbAh*PCfPcG'9bAh0PBh4TEfjc!&pIBh4SFQ9KC&pTEQPdAh* [GA4TEQ8!Af&dCAKTG!"ICA*bEQm!Af9iDA3!AfeKBfKID@jTG&pbEh9dD@jP!!! !Q(!!!!%!!!!6ZJ!!%VS!!!'+!*$c'N!!N"`I6@&VC5"KE'PKFf9c)(4[)(KcB@e `E'8JE'PLFQ&bH3!!!"B!!3#3"3i!#J!3!!!!$!#3#3)!N!8B!!!!+!#3"`J!!!! J!'3r2!!"UI!!!!$#!!!!!8j@rrJ[!hB!,`-`2+'YTdBQ(be)rrJ[!c!mU*qR4LB I)#lrq,(!Cb![!b!mBh"ZG%(Zrr`L5+'Y)SJQ(dT!CJK+V[rmC`*f!4!$*Llrp%j H6R@24fpd3fpYF'pZC@jd6@Gb!!"19J!!,`a1Z[q85J"R+PQ2,caKF'ad,cacBh" dF#'S+LKI)!aR%PQ2,``[2!!!!!&`!+JUUI4B6h!$2`#Tb(!$2`#Tb#KZrra1ANj eLN&`F'aPG&0dG@)!N!B+@1!!!b!!!!-J!*!)('&`E(3!!!!"4P*&4J#3"B"*3di M!*!&PJ!!!!%!N!3(39"36!#3"3%!!!%!!!!#J!!!"%!!!(JJ!!#%%!!"!JJ!!J) %!!3%!J!)#!%!%"3!J#!L!%"!33!Jm)#!%)N!3!L'!#!%K!!J!N!!%!%J!"!#%!! 3"!J!%!J%!#!3!J"!)!%!J%!#J3#!"))"!!K%!J!)5!3!#&J)!!4N%!!$`L!!!!& !!!!!J!!!!3!!!!1!!!!(`!!!Iq!!!2r`!!(rq!!$rr`!"rrq!!rrr`!Irrq!2rr r`(rrrq$rrrr`rrrrq2rrrrcrrrrqIrrrrcrrrriIrrrm$rrrq!Irrr!$rrrJ!Ir r`!2rri!(rrm!$rrq!!rrr!!2rrJ!"qI`!!2$i!!!!F!!!!#!!!!!!J#3#!m!N!r `m!#3$3m!$`#3#`rrm!!!m!#3#[$-h`!!$`#3#3m!$-c`!!$`!*!)m!$-cI!!!!m !N!F2!!c-h`#3"2!!N!E`!-c0m!#3"!m!N!82!!c-hpm!N!A`!*!%m!$-cIhGm!# 3"!m!!!!2!!c-hph-h`#3"I!!!2rrc-hph-$0m!#3"!m!!2lFr0rGc!`-h`#3"I! !rFc2rGc!`-$0m!#3"!m!r-`2cF`-$!!-r3#3"I!2!-$-`-$!!!cI!*!%$-m!m!b 3"!!!c0m!N!6-m!!2!-$!`!!-$0m!!!!-c`!!!2!-$!!!`-cI!!!!c2!!!!!2!-! !$!c0r!!!$-m!N!A`!!$!c0r-!!$-m!#3"3m!$!c0r-`!$-m!N!Epm-$-hmc!!-c `!*!&$phm$-hmc!!-c`#3"[hFcmcIc-!!c2!!N!Epc-r0r-`!$-m!N!Imc!rIr-! !c2!!N!F2`-r`$m`-c`#3#Irr!!$mc2!!N!d2c`#3$r!!N!T!!B!13"%J)4"##18 %Q)+3!%&!)5!L%%3BL#83*L!G3!#!!B!2`"rJ2r"rq2rmrrlrrhrr2riIr"ri2r! ri"h!!)!!!!#!!!!!$r!!N!Arm!m!N!32$!m!m!!!!2$!c`!2!!!2$!c`!!$`!2r `cpm!!!m!rGrpc2!!!2$p$p`-c`!!$`m!`-$0m!$2!2!-$-h`$2!!$`$-hm$2!!! 2m-hm$2!!!2h2hm$2!!!!r-rm$2!!!!!2r`r2!*!(m!#3"Lp6Dh*TF(4`FQpRFQ& YE3d06@&VC5"KE'PKFf9c)(4[)(KcB@e`E'8JE'PLFQ&bH3!!!")!!J#3#3%!"J! '%iN!!!!8!%m!-3,*!f`!6`!a!XN$E!#3"Jd!4Q&cC&9"8b!a,M%`-5ia-!i!!!! %$rrr!!%!!J!$!Irr!!!0!!%!!@X!N!F%!J!%!!)!"3!'$3!&!!*X!!)!!!"M!!I rrJd!"`!#6`#3"@-!#!!*$3!)!!&V!!!!"!"L!!S#!!S!!J!,!!`0!!X!!Q`!!J! %!!6rrIrm!Irp!!!"rr`!!!)!$!!#!!d!$Jd!$3!#FJ!!!!3!"`!2!"!0!!m!!@d !!!!%!!8!%3`!%3!0!!GiFf&YF'aP!!)!!!d!%!!"E`#3"[rl#rrl!!``!!K[FQP RD@jKE!!!!J!1!!)!%J!6$3!5!!*b!!!!#!!2!"3!&3d!&!!"5J!!!!J!$3!@!J! @!!)!&`!B$3!A!!&Y!!!!#!!*!"N-!"N!$J!)H'GbEfpfCAi!!J!!!J!B!!)!'J! E$3!D!!&Y!!!!#3!+!"`-!"`!$!!'H("XBAPq!!)!!!)!'`!#!"hrqJd!(3!"E3! !!!S!#`!H$!!H!!i!#(KbC@0[FQ4q!!)!!!,rqJ!!$3!9!!&[!*!'rrN,rrN!$6! !#@9iG'9bEQ&XF`!!!J!6!!)!(`!J$3!I!!*X!!)!%!!3rrMrp`(rq!!!!Irh!!! #!#!!!J!K!#)0!#%!!Q`!!!!3!"$rpJ!M!Irf!!!-!#-!#`!&)'4[)5!!!J!!!J! L!!)!*!!P$3!N!!*X!!)!%!!3rrArp!(rp3!!!Ird!!!#!#8!!J!Q!#F0!#B!!R) !!!!3!"N!+!!T$3!S!!*X!!8!%!!A!#Vrm`d!+J!#EJ!!!"!!&`!V!#`0!#X!!@d !!!!9!"IrmJVrmJ!%#Q0dER)0!#`!!Q`!"3!3!"8!,Ira$3!Y!!0*!!)!%!!9rr! !,[r[#[r`!"JZC@&bFfCQC(*KE'Pc!*!')!"KCQ4b$3!Z!!"Q!!!!%!!4![r[!!! "rr%!!!(rm`!!$3!T!!&[!*!'rqi,rqi!#M!!"Q0eFQ4TFJ!!!J!R!!)!,`!`$3! [!!*b!!!!'J!J!$%!-Jd!-3!#E!!&!"S!(J!crqd0!$-!!Qi!!!!D!"i!0!!e$3! d!!)d!!!!'`!Hrq`!0JVrl!!%#QCTE'80!$B!!@m!!!!F!"hrk`[rk`!--!!)Eh* TCfPZB@`!!!d!03!"E`!!!"S!'rrU#rrU!!S`!!CMGA*NDA)!!!(rl3!!$3!b!!& [!*!'rqN,rqN!"c!!!fpbD3!!!J!`!!)!0`!i$3!h!!*X!!)!)3!KrqMrj`(rk!! !!IrR!!!#!$J!!J!j!$S0!$N!!Q`!!!!K!#(rjJ!l!IrQ!!!-!$X!)!!D)'CTFR0 d)'4PE'9dC5"KE'`JB@aTBA0PFb!!!J!!!J!k!!)!2!!p$3!m!!0*!!)!)3!arq8 !2[rN#[rP!"JZBfpbC@4PE'mUN!3!N!D3!!!UN!30!$i!!Q`!"3!K!#d!2rrM$3! r!!)f!3!!)3!Y!%!!33d!3!!#EJ!!!#%!*!"#!%-0!%)!!6)!!!!L!#6riJVriJ! %#Q&XD@%0!%-!!@m!!!!K!#,ri3[ri3!+-!!'Bh9bC'Pb!!!0!%%!!N8!!3!P!#` !4!"&$3"%!!&[!!!!*J!Srq!,rq!!$6!!#@9iG'9bEQ&XF`!!$3"&!!%a!!!!+3! Vrpm+rpm!"!T`EQ&Y!IrM!!!#rq3!!!)!23!#!%B!4`d!4J!#E!!#!$)!-[rHrpd "rpi!!!(rh3!!!J"(!!)!5!"*$3")!!*X!!!!-J!brp`!5J(rh!!!$!"+!"N!%b" ZEhFJE@&VC5"ZCAFJEfjPFb!!!J!!!J"*!!)!5rrE$3",!!0B!!!!-J"L!%crfJ" 0$3"-!!*b!!!!4J"G!%i!6`d!6J!"E`!!!%B!4rrC#rrC!!F`!!0PH(3!!!d!6`! #EJ#3"e!!83d!8!!"-3!!!&S!A2rB#[rB!!3+F'jKE3d!83!#E!!&!%F!@J"5rpF 0!&)!!dN!!J"(!&Vre[r9!&-+rpB!'#jMEh*PBh*PE#U3"!#3"T!!!'jeE'`"rp8 !!!B!8`!$rp3!9!"9#[r8!!3+DfpME!d!9!!"E3!!!%X!62r6#[r6!!3+B@aTB3B !93!$rp)!9J"A#[r5!!3+D@jcD!d!9J!"E`!!!%m!82r4#rr4!!S`!!CMGA*NDA) !!!B!9`!$rp!!@2r2#[r3!!3+G'mJ)!d!@!!"E`!!!&-!92r1#rr1!!F`!!0[FQN !!!Erc`!!!IrA!!!,rpS!"c!!!f9iG!!!$3"0!!&[!!!!03!frmd,rmd!$6!!#@9 iG'9bEQ&XF`!!![rE!!!0!!N!!@d!N!8"!&N2!&N"-!KZG@aX!*!&!Gq%rrm!!!! H"NCTEQ4PFJ!!!"62&%!!!daN&-+L@!!!S'88ca4!!I543"6#@D3!!$JbrJ)!!!! 2Zl38ca5!!!$rU!#3"Ne"3e-!!"%!B@aTF`#3"G)!!J!!#%K%)%eKBdp6!*!6Z"p ,#8*%!*!&(JC'D@jNCA)!N$X1BEFj2m"'6N4568&$8rq3"!#3%`a6HA0dC@e[FQ4 ZCA)!!3!%!!!!(J!#!"a)4#"0B@028cT6HA0dC@e[FQ4ZCA)k4QPZC'9brrm!!!( rrJ!!!J!'!!)!@[r-$3"D!!*X!!)!N!6rbrr+!Ir,!!!"rmS!!!,rc!!!$J!#!!! 2%!!$!!Vrb3"E!&`!%3"G!&i!Arr)rmIraJ(rb3!!%!"E!!MraIr%rm2r`[r"rm$ r[rqq#[r&!"JZB@9fG'pKF("ZG@aX!!#!!!!!N!!!+T!%#rr%!!``!!K[FQPRD@j KE!!!#rr$!!d`!!PPH(4PFQjKE(-!!![r`J!+-!!'Bh9bC'Pb!!!,rm%!"c!!!fp bD3!!!Ir!!!!"rlm!!!(r[J!!$J"F!!F3rld!B2qmrlX!B3"LrlS+rld!'#jKCAC dEf&`F'jeE'`!!)!!!!#3!!!UN!30!'!!!@X!N!9M!'-#!'-!!J!&rlN#rlN!!!( r[!!!![ql!!!3!'%!!Iqi#rqi!!F`!!0PH(3!!"!!BJ!A!&N!%Iqh!"N!(!!HrlE rYIqdrl2rX[qarl!!C2q[rklrVIqXrk[rU[qTrkMrT`[rY`!--!!)Eh*TCfPZB@` !!![rYJ!0-!!*CAKdCA*ZB@ac!!!+rl8!'#jPBA*cCQCNFQ&XDA-!N!BJ!'&QC() +rl3!"!TMG'jb#rqc!!S`!!CMGA*NDA)!!!VrXJ!%#QCTE'8,rl%!"c!!!fpbD3! !#[q`!!3+B@aTB3i!C!!!%`VrV`!%#R"ZB@d+rki!'#jMEh*PC'9XEbU3"!#3"T! !!#U3"!VrV3!%#QY[Bf`+rk`!"!TMEf*U#[qV!"JZBfpbC@0ZG'8UN!3!N!B3!#U 3"!VrUJ!%#QPZFfJ+rkN!"!TdEb!J!rqS!!B+rkF!'#jMEh*PBh*PE#U3"!#3"T! !!'jeE'`4rlS!C1!5!'$K4G*2iq6PEAC&eNmTDJ`!"qJX4GP2bHV#,dAE6mRX,He E@XCFlLa!-@S-!!p2&`![aPYK!""K!"&X$!!5DfJE!!#J+Q%!%1aK!"2*B3!8bf% !&3`!&ZiX4PY2@IrM93m1!&d!!J6rTJ"P!rqQ!!-1!'8!!`!!'3!F!"i1!&i!!43 !CJi!CJ!$'!"Rrk8!D!i!C`!$'!"Trk3!DJi!D3!$'!"Vrk-!E!i!D`!$'!"Yrk) !EJi!E3!$'!"Crk%!E`VrS3!%#Q0NDA--!'m!$J!)5%3J4'&dC@i!!J!!#[qL!!3 +BfC[E!`!EJ!3!!T3FQpR)(0dG@CQ!!)!!!VrS`!%#Q0QEf`-!'`!#3!$E@&i!!) !!!VrT!!%#Q0QEf`-!'S!$3!(H(0KEA"XC3!#!!!+rk8!"!TMCQpX$!"S!!N!!de 39`!#!!!1!&m!!43!F!i!F!!$'!"ark!!FJi!F3!$'!"crjm!G!i!F`!$'!"erji !GJi!G3!$'!"hrjd!H!i!G`!$'!"jrj`!HJi!H3!$'!"CrjX!H`VrQ`!%#Q0NDA- -!(X!$J!)5%3J4'&dC@i!!J!!#[qF!!3+BfC[E!`!HJ!3!!T3FQpR)(0dG@CQ!!) !!!VrR3!%#Q0QEf`-!(J!#3!$E@&i!!)!!!VrRJ!%#Q0QEf`-!(B!$3!(H(0KEA" XC3!#!!!+rjm!"!TMCQpX$!"d!!N!!de39`!#!!!+rk!!"!TQD@aP$!"b!!d!"hK cB@e`E'8!!J!!!Ir)!!!"rmF!!!(raJ!!!'&cBh)!!3!0qYlHV3!!!3!!!"1k!!! 5ZJ!!!BT66e*8!IB!J!!F!BS!%%*14%`!!!#+3dp%43!"!*C'8N9'!!!!VNP$6L- !!!#k8dPD43!!!-C849K8!!%!dPG3Eh-!!!$UBA"XG!!!!2CMBA*L!!!"!QKQC() !!!%1D@0X0!!!!4TTBh-M!!!"*QPMFc3!!!%bFf0`G!!!!6jcBh0k!!!"5R0`FfJ !!!&@Fh4jE!!!!@)!J2rr!!!"93#3"[rr)!!!B46%k3J!!Irr&!!!I46%k63!J2r r!!!"HJ#3"CErr`!!!B8!N!6rN!3!!!&$!*!%"'Mrr`!!!"i!N!36LIrr!!!&93# 3"B$rr`!!"Ci!N!Err`!!!A8!N!Err`!!!9%!N!6T`2rr!!!&L!#3"CErr`!!!SN !N!@@rrm!!!50!*!&P[rr!!!%d3#3"B$rr`!!"EB8a6PJ!!$rr`#3#[rr!!!!@`# 3"!4Srrm!!!""!*!%))i: \ No newline at end of file diff --git a/externals/grill/xsample/gpl.txt b/externals/grill/xsample/gpl.txt new file mode 100644 index 00000000..5ea29a7d --- /dev/null +++ b/externals/grill/xsample/gpl.txt @@ -0,0 +1,346 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + diff --git a/externals/grill/xsample/license.txt b/externals/grill/xsample/license.txt new file mode 100644 index 00000000..dc45deed --- /dev/null +++ b/externals/grill/xsample/license.txt @@ -0,0 +1,84 @@ +xsample - extended sample objects for Max/MSP and pd (pure data) +Copyright (C) 2001,2002 Thomas Grill + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +In the official xsample distribution, the GNU General Public License is +in the file gpl.txt + +--------------------------------------------------------- + + OTHER COPYRIGHT NOTICES + +--------------------------------------------------------- +This package uses the flext C++ layer and some code snippets +from pd (pure data). +See the license texts below: + + +--- flext ---------------------------------------------- +flext - C++ layer for Max/MSP and pd (pure data) externals +Copyright (C) 2001,2002 Thomas Grill + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +In the official flext distribution, the GNU General Public License is +in the file gpl.txt + + +--- pd (pure data) -------------------------------------- +This software is copyrighted by Miller Puckette and others. The following +terms apply to all files associated with the software unless explicitly +disclaimed in individual files. + +The authors hereby grant permission to use, copy, modify, distribute, +and license this software and its documentation for any purpose, provided +that existing copyright notices are retained in all copies and that this +notice is included verbatim in any distributions. No written agreement, +license, or royalty fee is required for any of the authorized uses. +Modifications to this software may be copyrighted by their authors +and need not follow the licensing terms described here, provided that +the new terms are clearly indicated on the first page of each file where +they apply. + +IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY +FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY +DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE +IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE +NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. + +RESTRICTED RIGHTS: Use, duplication or disclosure by the government +is subject to the restrictions as set forth in subparagraph (c) (1) (ii) +of the Rights in Technical Data and Computer Software Clause as DFARS +252.227-7013 and FAR 52.227-19. diff --git a/externals/grill/xsample/maxmsp/xgroove~.help b/externals/grill/xsample/maxmsp/xgroove~.help new file mode 100644 index 00000000..c26c6eff Binary files /dev/null and b/externals/grill/xsample/maxmsp/xgroove~.help differ diff --git a/externals/grill/xsample/maxmsp/xplay~.help b/externals/grill/xsample/maxmsp/xplay~.help new file mode 100644 index 00000000..cb4f7cad Binary files /dev/null and b/externals/grill/xsample/maxmsp/xplay~.help differ diff --git a/externals/grill/xsample/maxmsp/xrecord~.help b/externals/grill/xsample/maxmsp/xrecord~.help new file mode 100644 index 00000000..a45de207 Binary files /dev/null and b/externals/grill/xsample/maxmsp/xrecord~.help differ diff --git a/externals/grill/xsample/pd/xgroove~.help.pd b/externals/grill/xsample/pd/xgroove~.help.pd new file mode 100644 index 00000000..74b9e312 --- /dev/null +++ b/externals/grill/xsample/pd/xgroove~.help.pd @@ -0,0 +1,166 @@ +#N canvas 92 110 837 556 12; +#X obj 258 240 hsl 128 15 0.001 3 1 1 empty empty empty 20 8 0 8 -225271 +-1 -1 0 1; +#X floatatom 255 261 8 0 0; +#X floatatom 275 312 8 0 0; +#X floatatom 350 312 8 0 0; +#X floatatom 273 372 8 0 0; +#X floatatom 348 372 8 0 0; +#X obj 275 419 loadbang; +#X obj 274 445 metro 30; +#X obj 250 470 snapshot~; +#X floatatom 250 494 8 0 0; +#X msg 258 82 loop \$1; +#X obj 159 27 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1 +-1; +#X msg 158 47 stop; +#N canvas 0 0 450 300 graph7 0; +#X array buf 300 float 1; +#A 0 0.841115 0.9094 0.95923 0.989636 0.999991 0.990063 0.960094 0.910649 +0.842757 0.757796 0.65746 0.543816 0.419143 0.285978 0.147021 0.00508036 +-0.136962 -0.276228 -0.409895 -0.535265 -0.649771 -0.751121 -0.83725 +-0.906401 -0.957205 -0.988587 -0.999947 -0.991051 -0.962051 -0.913577 +-0.846573 -0.762418 -0.662823 -0.549777 -0.425604 -0.292801 -0.154064 +-0.0122066 0.129898 0.269372 0.403387 0.529223 0.644347 0.746395 0.833328 +0.903378 0.955105 0.987498 0.99986 0.991967 0.963983 0.91644 0.850346 +0.767009 0.668129 0.555721 0.432034 0.299602 0.161097 0.0193266 -0.122836 +-0.262506 -0.396859 -0.523173 -0.638875 -0.741645 -0.82937 -0.900294 +-0.952984 -0.986339 -0.999729 -0.992844 -0.965842 -0.919283 -0.854067 +-0.771564 -0.673418 -0.561622 -0.438457 -0.306392 -0.168126 -0.0264512 +0.115759 0.255627 0.390308 0.517083 0.633384 0.736837 0.825374 0.89717 +0.95079 0.985156 0.999531 0.993672 0.967666 0.922048 0.857765 0.776069 +0.678665 0.567504 0.444838 0.313167 0.175141 0.0335691 -0.108684 -0.248732 +-0.383745 -0.510974 -0.627851 -0.732014 -0.821324 -0.894008 -0.948562 +-0.983895 -0.999309 -0.994439 -0.96944 -0.924788 -0.861391 -0.780556 +-0.683878 -0.573355 -0.451214 -0.319922 -0.182154 -0.0406903 0.101596 +0.241826 0.37715 0.504839 0.62229 0.727131 0.81725 0.890784 0.946286 +0.982602 0.999003 0.99518 0.971156 0.927473 0.864993 0.784974 0.689065 +0.579174 0.457555 0.326665 0.189149 0.047805 -0.0945095 -0.234908 -0.370551 +-0.498674 -0.616703 -0.722227 -0.813114 -0.887541 -0.943952 -0.981256 +-0.998669 -0.995836 -0.972845 -0.93011 -0.868543 -0.789377 -0.694202 +-0.584975 -0.463879 -0.333389 -0.196144 -0.0549212 0.0874133 0.227976 +0.363918 0.492493 0.611072 0.717282 0.80895 0.88422 0.941593 0.979852 +0.998275 0.996467 0.974453 0.932714 0.872048 0.793723 0.699318 0.590728 +0.47018 0.340094 0.20312 0.0620311 -0.0803164 -0.221037 -0.357277 -0.486275 +-0.605431 -0.712297 -0.804743 -0.880878 -0.939154 -0.97842 -0.99783 +-0.997035 -0.976038 -0.935246 -0.875523 -0.798037 -0.704388 -0.596471 +-0.476452 -0.346789 -0.210093 -0.0691412 0.0732124 0.21408 0.350613 +0.480039 0.599733 0.707289 0.800488 0.87748 0.936691 0.976908 0.997349 +0.997554 0.977556 0.937754 0.87893 0.802314 0.709426 0.602164 0.482708 +0.353456 0.217051 0.0762439 -0.0661074 -0.207122 -0.343933 -0.473779 +-0.594024 -0.702224 -0.796211 -0.87404 -0.934169 -0.975372 -0.996792 +-0.998035 -0.979032 -0.940196 -0.882319 -0.806539 -0.714434 -0.60784 +-0.48893 -0.36012 -0.224 -0.0833475 0.0589955 0.200142 0.337238 0.467489 +0.588274 0.69714 0.791867 0.870566 0.931602 0.973768 0.996211 0.998443 +0.980464 0.9426 0.885637 0.810741 0.719392 0.613481 0.495132 0.366748 +0.230939 0.0904412 -0.0518851 -0.193161 -0.33052 -0.461188 -0.582499 +-0.692013 -0.787507 -0.867028 -0.928998 -0.972125 -0.995556 -0.998827 +-0.98183 -0.944959 -0.888927 -0.81488 -0.724336 -0.619089 -0.501311 +-0.373371; +#X coords 0 1 299 -1 300 200 1; +#X restore 521 23 graph; +#X obj 144 486 dac~; +#X msg 157 86 reset; +#X text 290 292 min/max points; +#X text 289 390 min/max points; +#X text 323 494 position; +#X text 181 24 start; +#X text 198 45 stop; +#X msg 156 113 help; +#X text 416 234 speed; +#X text 337 254 (float or signal); +#X obj 656 365 table buf2; +#X floatatom 519 380 8 0 0; +#X obj 519 353 soundfiler; +#X msg 158 172 set buf2; +#X msg 157 144 set buf; +#X msg 372 82 interp \$1; +#X msg 240 312 all; +#X obj 198 341 xgroove~ buf; +#X text 255 10 looping mode; +#X text 370 9 interpolation; +#X msg 20 170 pos 100; +#X msg 35 199 pos 200; +#X obj 152 447 *~; +#X obj 22 242 ramp 10; +#X msg 10 105 xzone \$1; +#X obj 13 62 hsl 128 15 0 300 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 0 1; +#X floatatom 10 83 5 0 0; +#X obj 258 32 vdl 15 0 0 3 empty empty empty 0 -6 0 8 -262144 -1 -1 +1; +#X text 277 29 once; +#X text 277 45 forward; +#X text 277 61 bidir; +#X obj 372 31 vdl 15 0 0 3 empty empty empty 0 -6 0 8 -262144 -1 -1 +1; +#X text 391 28 none; +#X text 391 44 linear; +#X text 391 60 4-point; +#X obj 520 299 openpanel; +#X msg 521 326 read -resize \$1 buf2; +#X obj 521 275 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 256 134 vdl 15 0 0 4 empty empty empty 0 -6 0 8 -262144 -1 -1 +2; +#X text 255 113 units; +#X msg 256 199 units \$1; +#X obj 364 134 vdl 15 0 0 4 empty empty empty 0 -6 0 8 -262144 -1 -1 +0; +#X text 363 113 scale mode; +#X msg 364 199 sclmode \$1; +#X text 275 131 frames; +#X text 275 147 buffer sz; +#X text 275 163 ms; +#X text 275 178 s; +#X text 383 147 units in loop; +#X text 383 163 buffer; +#X text 383 178 loop; +#X text 383 131 units in buffer; +#X obj 524 440 osc~ 1000; +#X obj 524 498 tabwrite~ buf; +#X obj 536 467 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 557 468 stop; +#X connect 0 0 1 0; +#X connect 1 0 31 0; +#X connect 2 0 31 1; +#X connect 3 0 31 2; +#X connect 6 0 7 0; +#X connect 7 0 8 0; +#X connect 8 0 9 0; +#X connect 10 0 31 0; +#X connect 11 0 31 0; +#X connect 12 0 31 0; +#X connect 15 0 31 0; +#X connect 21 0 31 0; +#X connect 26 0 25 0; +#X connect 27 0 31 0; +#X connect 28 0 31 0; +#X connect 29 0 31 0; +#X connect 30 0 31 0; +#X connect 31 0 36 1; +#X connect 31 1 8 0; +#X connect 31 2 4 0; +#X connect 31 3 5 0; +#X connect 34 0 37 0; +#X connect 35 0 37 0; +#X connect 36 0 14 0; +#X connect 36 0 14 1; +#X connect 37 0 36 0; +#X connect 37 1 31 0; +#X connect 38 0 31 0; +#X connect 39 0 40 0; +#X connect 40 0 38 0; +#X connect 41 0 10 0; +#X connect 45 0 29 0; +#X connect 49 0 50 0; +#X connect 50 0 26 0; +#X connect 51 0 49 0; +#X connect 52 0 54 0; +#X connect 54 0 31 0; +#X connect 55 0 57 0; +#X connect 57 0 31 0; +#X connect 66 0 67 0; +#X connect 68 0 67 0; +#X connect 69 0 67 0; diff --git a/externals/grill/xsample/pd/xplay~.help.pd b/externals/grill/xsample/pd/xplay~.help.pd new file mode 100644 index 00000000..9bca8cbb --- /dev/null +++ b/externals/grill/xsample/pd/xplay~.help.pd @@ -0,0 +1,57 @@ +#N canvas 297 114 616 300 12; +#X obj 69 252 dac~; +#X obj 19 54 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1 +-1; +#X msg 18 74 stop; +#X msg 16 141 reset; +#X text 41 51 start; +#X text 58 72 stop; +#X obj 125 155 *~ 300; +#X text 107 176 position signal; +#X msg 16 115 help; +#X graph graph7 0 -1 299 1 284 217 584 17; +#X array buf 300 float 1; +#A 0 -0.03 -0.03 -0.03 -0.0366667 -0.0433333 -0.05 -0.065 -0.08 -0.085 +-0.09 -0.096 -0.102 -0.108 -0.114 -0.12 -0.1275 -0.135 -0.1425 -0.15 +-0.156 -0.162 -0.168 -0.174 -0.18 -0.186 -0.192 -0.198 -0.204 -0.21 +-0.2175 -0.225 -0.2325 -0.24 -0.246 -0.252 -0.258 -0.264 -0.27 -0.276 +-0.282 -0.288 -0.294 -0.3 -0.305 -0.31 -0.315 -0.32 -0.325 -0.33 -0.335 +-0.34 -0.34375 -0.3475 -0.35125 -0.355 -0.35875 -0.3625 -0.36625 -0.37 +-0.373333 -0.376667 -0.38 -0.383333 -0.386667 -0.39 -0.393333 -0.396667 +-0.4 -0.402 -0.404 -0.406 -0.408 -0.41 -0.4125 -0.415 -0.4175 -0.42 +-0.42 -0.42 -0.42 -0.42 -0.42 -0.42 -0.42 -0.42 -0.42 -0.42 -0.42 -0.42 +-0.42 -0.42 -0.42 -0.42 -0.42 -0.42 -0.42 -0.4175 -0.415 -0.4125 -0.41 +-0.41 -0.4 -0.39 -0.39 -0.385 -0.38 -0.36 -0.35 -0.34 -0.33 -0.32 -0.31 +-0.3 -0.29 -0.28 -0.27 -0.26 -0.25 -0.2425 -0.235 -0.2275 -0.22 -0.21 +-0.2 -0.19 -0.18 -0.17 -0.16 -0.15 -0.14 -0.132 -0.124 -0.116 -0.108 +-0.1 -0.09 -0.08 -0.07 -0.06 -0.05 -0.0425 -0.035 -0.0275 -0.02 -0.01 +0 0.01 0.0175 0.025 0.0325 0.04 0.05 0.06 0.07 0.08 0.08875 0.0975 +0.10625 0.115 0.12375 0.1325 0.14125 0.15 0.156 0.162 0.168 0.174 0.18 +0.186 0.192 0.198 0.204 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.278 0.286 +0.294 0.302 0.31 0.318 0.326 0.334 0.342 0.35 0.355556 0.361111 0.366667 +0.372222 0.377778 0.383333 0.388889 0.394444 0.4 0.405714 0.411429 +0.417143 0.45 0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 +0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 0.46 +0.46 0.46 0.46 0.46 0.46 0.456667 0.453333 0.45 0.45 0.45 0.448333 +0.446667 0.445 0.443333 0.441667 0.44 0.44 0.43625 0.4325 0.42875 0.425 +0.42125 0.4175 0.41375 0.41 0.405 0.4 0.4 0.3925 0.385 0.3775 0.37 +0.37 0.355 0.35 0.34 0.33 0.32 0.31 0.29 0.283333 0.276667 0.27 0.26 +0.25 0.24 0.23 0.22 0.21 0.2 0.19 0.18 0.16 0.15 0.14 0.13 0.12 0.11 +0.105 0.1 0.09 0.075 0.06 0.05 0.04 0.03 0.02 0 -0.02 -0.0266667 -0.0333333 +-0.04 -0.05; +#X pop; +#X obj 117 82 hsl 128 15 1 100 1 1 empty empty empty 20 8 0 8 -225271 +-1 -1 11100 1; +#X obj 77 203 xplay~ buf; +#X msg 17 168 print; +#X obj 124 124 phasor~ 100; +#X connect 1 0 11 0; +#X connect 2 0 11 0; +#X connect 3 0 11 0; +#X connect 6 0 11 0; +#X connect 8 0 11 0; +#X connect 10 0 13 0; +#X connect 11 0 0 0; +#X connect 11 0 0 1; +#X connect 12 0 11 0; +#X connect 13 0 6 0; diff --git a/externals/grill/xsample/pd/xrecord~.help.pd b/externals/grill/xsample/pd/xrecord~.help.pd new file mode 100644 index 00000000..5226f539 --- /dev/null +++ b/externals/grill/xsample/pd/xrecord~.help.pd @@ -0,0 +1,136 @@ +#N canvas 134 12 855 608 12; +#X obj 14 15 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1 +-1; +#X msg 13 35 stop; +#X floatatom 165 248 5 0 0; +#X floatatom 219 248 5 0 0; +#X floatatom 190 170 5 0 0; +#X floatatom 239 171 5 0 0; +#N canvas 0 0 450 300 graph7 0; +#X array buf 10000 float 0; +#X coords 0 1 9999 -1 200 140 1; +#X restore 52 431 graph; +#X obj 91 212 xrecord~ buf; +#X msg 11 69 reset; +#X obj 70 287 snapshot~; +#X floatatom 72 312 7 0 0; +#X obj 18 220 loadbang; +#X msg 10 99 help; +#X obj 175 96 tgl 15 1 empty empty empty 20 8 0 8 -225271 -1 -1 1 1 +; +#X msg 193 93 loop \$1; +#X msg 173 36 0; +#X msg 209 36 200; +#X msg 172 64 draw \$1; +#X obj 411 275 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1 +-1; +#X msg 410 295 stop; +#X floatatom 565 485 5 0 0; +#X floatatom 619 485 5 0 0; +#X floatatom 568 427 5 0 0; +#X floatatom 617 428 5 0 0; +#X obj 500 458 xrecord~ buf; +#X msg 409 334 reset; +#X obj 500 518 snapshot~; +#X floatatom 500 548 7 0 0; +#X obj 411 446 loadbang; +#X obj 537 242 tgl 15 1 empty empty empty 20 8 0 8 -225271 -1 -1 0 +1; +#X msg 556 239 loop \$1; +#X msg 452 206 0; +#X msg 451 234 draw \$1; +#X obj 538 265 tgl 15 1 empty empty empty 20 8 0 8 -225271 -1 -1 1 +1; +#X msg 556 263 sigmode \$1; +#X msg 409 360 print; +#X obj 581 353 hsl 128 15 -0.001 1 0 1 empty empty empty 20 8 0 8 -225271 +-1 -1 12700 1; +#X obj 537 291 tgl 15 0 empty empty empty 20 8 0 8 -225271 -1 -1 0 +1; +#X msg 557 288 mixmode \$1; +#X floatatom 629 381 8 0 0; +#X obj 411 473 metro 30; +#X obj 18 247 metro 30; +#X obj 640 21 osc~ 10; +#X obj 91 133 r~ rec; +#X obj 482 339 r~ rec; +#X obj 678 95 s~ rec; +#X obj 623 48 *~ 1; +#X obj 622 25 tgl 15 1 empty empty empty 20 8 0 8 -225271 -1 -1 1 1 +; +#X obj 719 50 *~ 1; +#X obj 718 27 tgl 15 0 empty empty empty 20 8 0 8 -225271 -1 -1 0 1 +; +#X obj 736 23 adc~; +#X text 198 149 min/max position; +#X text 166 267 min/max position; +#X text 262 96 looping on/off; +#X text 237 65 display refresh; +#X text 52 13 start; +#X text 53 35 stop; +#X text 26 270 position signal; +#X text 619 238 looping on/off; +#X text 644 264 signal mode on/off; +#X text 700 381 trigger signal; +#X text 379 121 <----- message triggered; +#X text 173 368 signal triggered ------->; +#X text 493 185 click to activate auto update; +#X text 432 271 start; +#X text 450 295 stop; +#X text 538 307 mix-in by trigger signal on/off; +#X msg 153 170 all; +#X msg 488 206 100; +#X obj 521 426 line~; +#X msg 520 401 \$1 20; +#X connect 0 0 7 0; +#X connect 1 0 7 0; +#X connect 4 0 7 2; +#X connect 5 0 7 3; +#X connect 7 0 9 0; +#X connect 7 1 2 0; +#X connect 7 2 3 0; +#X connect 8 0 7 0; +#X connect 9 0 10 0; +#X connect 11 0 41 0; +#X connect 12 0 7 0; +#X connect 13 0 14 0; +#X connect 14 0 7 0; +#X connect 15 0 17 0; +#X connect 16 0 17 0; +#X connect 17 0 7 0; +#X connect 18 0 24 0; +#X connect 19 0 24 0; +#X connect 22 0 24 2; +#X connect 23 0 24 3; +#X connect 24 0 26 0; +#X connect 24 1 20 0; +#X connect 24 2 21 0; +#X connect 25 0 24 0; +#X connect 26 0 27 0; +#X connect 28 0 40 0; +#X connect 29 0 30 0; +#X connect 30 0 24 0; +#X connect 31 0 32 0; +#X connect 32 0 24 0; +#X connect 33 0 34 0; +#X connect 34 0 24 0; +#X connect 35 0 24 0; +#X connect 36 0 39 0; +#X connect 36 0 70 0; +#X connect 37 0 38 0; +#X connect 38 0 24 0; +#X connect 40 0 26 0; +#X connect 41 0 9 0; +#X connect 42 0 46 0; +#X connect 43 0 7 0; +#X connect 44 0 24 0; +#X connect 46 0 45 0; +#X connect 47 0 46 1; +#X connect 48 0 45 0; +#X connect 49 0 48 1; +#X connect 50 0 48 0; +#X connect 50 1 48 0; +#X connect 67 0 7 0; +#X connect 68 0 32 0; +#X connect 69 0 24 1; +#X connect 70 0 69 0; diff --git a/externals/grill/xsample/readme.txt b/externals/grill/xsample/readme.txt new file mode 100644 index 00000000..cf678085 --- /dev/null +++ b/externals/grill/xsample/readme.txt @@ -0,0 +1,142 @@ +xsample - extended sample objects for Max/MSP and pd (pure data) + +Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +Donations for further development of the package are highly appreciated. + +---------------------------------------------------------------------------- + +IMPORTANT INFORMATION for all MaxMSP users: + +It is advisable to put the xsample shared library file into the "startup" folder. Hence it will be +loaded at Max startup. + +If you want to load the xsample library on demand, please run MakeAliases inside the MPW folder. +This will create aliases to the several xsample objects contained in the library. +Move these into the "externals" folder. +(This latter procedure is only tested for OS 9.2, you may experience problems with other MacOS versions) + +---------------------------------------------------------------------------- + +You will need the flext C++ layer for PD and Max/MSP externals to compile this. + + +Package files: +- readme.txt: this one +- gpl.txt,license.txt: GPL license stuff +- main.h,main.cpp,inter.cpp,inter.ci: base class definition for all the other objects +- record.cpp: xrecord~ +- play.cpp: xplay~ +- groove.cpp: xgroove~ + +---------------------------------------------------------------------------- + +The package should at least compile (and is tested) with the following compilers: + +pd - Windows: +------------- +o Borland C++ 5.5 (free): edit & run "make -f makefile.bcc" + +o Microsoft Visual C++ 6: edit "xsample.dsp" project file +> due to a compiler bug the optimization using templates is not functional + +pd - linux: +----------- +o GCC for linux: run "make -f makefile.pd-linux" and as root "make -f makefile.pd-linux install" +> various versions of GCC die during compile with template optimization turned on + +Max/MSP - MacOS: +---------------- +o Metrowerks CodeWarrior V6: edit "xsample.cw" project file functions + +o Apple MPW-PR: edit & use the "flext.mpw" makefile + + +---------------------------------------------------------------------------- + +Goals/features of the package: + +- portable and effective sample recording/playing objects for pd and Max/MSP +- MSP-like groove~ object for PD +- message- or signal-triggered recording object with mix-in capability +- avoid the various bugs of the original MSP2 objects +- multi-channel capability +- live update of respective buffer/array content +- switchable 4-point or linear interpolation for xplay~/xgroove~ object +- cross-fading loop zone (inside or outside to loop) for xgroove~ + +---------------------------------------------------------------------------- + +Version history: + +0.2.5: +- added resources to MaxMSP build +- xgroove~, xrecord~: introduced a loop/end bang outlet +- added MaxMSP buffer resize recognition +- xgroove~: introduced a crossfading loop zone +- adapted source for flext 0.4.0 + +0.2.4: +- according to flext 0.2.3 changed sample type to t_sample (S) +- xrecord~: fixed mix mode bug +- fixed argument buffer problem + +0.2.3: +- using flext 0.2.2 - xsample is now a library under MaxMSP +- cleaner gcc makefile +- xgroove~, xrecord~: added "all" message to select entire buffer length +- xgroove~, xplay~: revisited dsp methods, restructured the code, fixed small interpolation bugs +- xgroove~, xplay~: added linear interpolation (message "interp 2") +- enabled 0 output channels -> xgroove~: position output only +- xgroove~: added bidirectional looping (message "loop 2") + +0.2.2: +- using flext 0.2.0 +- xrecord~ for PD: new flext brings better graphics update behavior +- xrecord~: recording position doesn't jump to start when recording length is reached +- fixed bug with refresh message (min/max reset) +- xgroove~: position (by pos message) isn't sample rounded anymore +- reset/refresh messages readjust dsp routines to current buffer format (e.g. channel count) +- corrected Max/MSP assist method for multi-channel +- fixed xplay~ help method +- changed syntax to x*~ [channels=1] [buffer] for future enhancements (MaxMSP only, warning for old syntax) +- fixed small bug concerning startup position in xgroove~ and xrecord~ +- fixed deadly bug in xplay~ dsp code (only active with template optimization) + +0.2.1: +- no leftmost float inlet for position setting - use pos method +- changed dsp handling for flext 0.1.1 conformance +- workarounds for buggy/incomplete compilers +- prevent buffer warning message at patcher load (wait for loadbang) +- fixed bug: current pos is reset when changing min or max points + +0.2.0: +- first version for flext + +--------------------------------------------------------------------------- + + +TODO list: + +general: +- Documentation and better example patches + +- do a smooth (line~) mixin in xrecord~ help patch + +features: +- multi-buffer handling (aka multi-channel for pd) +- vasp handling +- performance comparison to respective PD/Max objects +- anti-alias filter? (possible?) + +- delay min/max changes when cur pos in cross-fade zone + +tests: +- reconsider startup sequence of set buffer,set units,set sclmode,set pos/min/max + +bugs: +- PD: problems with timed buffer redrawing (takes a lot of cpu time) - flext bug? +- Apple MPW doesn't correctly compile template optimization +- Max help files aren't correctly opened due to xsample objects residing in a library diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp new file mode 100644 index 00000000..5c2b056f --- /dev/null +++ b/externals/grill/xsample/source/groove.cpp @@ -0,0 +1,709 @@ +/* + +xsample - extended sample objects for Max/MSP and pd (pure data) + +Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "main.h" +#include + +#ifdef _MSC_VER +#pragma warning (disable:4244) +#endif + + +#define XZONE_TABLE 512 + + +class xgroove: + public xinter +{ +// FLEXT_HEADER_S(xgroove,xinter,setup) + FLEXT_HEADER(xgroove,xinter) + +public: + xgroove(I argc,t_atom *argv); + ~xgroove(); + + virtual BL Init(); + +#ifdef MAXMSP + virtual V m_assist(L msg,L arg,C *s); +#endif + + virtual V m_help(); + virtual V m_print(); + + virtual V m_units(xs_unit mode = xsu__); + + virtual BL m_reset(); + + virtual V m_pos(F pos); + virtual V m_all(); + virtual V m_min(F mn); + virtual V m_max(F mx); + + V m_xzone(F xz); + V m_xsymm(F xz); + V m_xshape(I argc = 0,t_atom *argv = NULL); + V m_xkeep(BL k); + + enum xs_loop { + xsl__ = -1, // don't change + xsl_once = 0,xsl_loop,xsl_bidir + }; + + V m_loop(xs_loop lp = xsl__); + +protected: + + xs_loop loopmode; + D curpos; // in samples + I bidir; + + F _xzone,xzone,xsymm; + F znmin,znmax; + I xkeep; + S **znbuf; + S *znpos,*znmul,*znidx; + I pblksz; + + outlet *outmin,*outmax; // float outlets + + V outputmin() { ToOutFloat(outmin,curmin*s2u); } + V outputmax() { ToOutFloat(outmax,curmax*s2u); } + + inline V setpos(F pos) + { + if(pos < curmin) pos = curmin; + else if(pos > curmax) pos = curmax; + curpos = pos; + } + +private: +// static V setup(t_class *c); + + virtual V s_dsp(); + + DEFSIGFUN(s_pos_off); + DEFSIGFUN(s_pos_once); + DEFSIGFUN(s_pos_loop); + DEFSIGFUN(s_pos_loopzn); + DEFSIGFUN(s_pos_bidir); + + DEFSIGCALL(posfun); + + DEFSTCALL(zonefun); + + V do_xzone(); + + virtual V m_signal(I n,S *const *in,S *const *out) + { + bufchk(); + posfun(n,in,out); + } + + FLEXT_CALLBACK_F(m_pos) + FLEXT_CALLBACK(m_all) + FLEXT_CALLBACK_F(m_min) + FLEXT_CALLBACK_F(m_max) + + FLEXT_CALLBACK_F(m_xzone) + FLEXT_CALLBACK_F(m_xsymm) + FLEXT_CALLBACK_V(m_xshape) + FLEXT_CALLBACK_B(m_xkeep) + + FLEXT_CALLBACK_1(m_loop,xs_loop) +}; + + +FLEXT_LIB_DSP_V("xgroove~",xgroove) + +/* +V xgroove::setup(t_class *) +{ +#ifndef PD + post("loaded xgroove~ - part of xsample objects, version " XSAMPLE_VERSION " - (C) Thomas Grill, 2001-2002"); +#endif +} +*/ + +xgroove::xgroove(I argc,t_atom *argv): + loopmode(xsl_loop),curpos(0), + _xzone(0),xzone(0),xsymm(0.5),xkeep(0),pblksz(0), + znbuf(NULL),znmul(NULL),znidx(NULL),znpos(NULL), + bidir(1) +{ + I argi = 0; +#ifdef MAXMSP + if(argc > argi && CanbeInt(argv[argi])) { + outchns = GetAInt(argv[argi]); + argi++; + } +#endif + + if(argc > argi && IsSymbol(argv[argi])) { + buf = new buffer(GetSymbol(argv[argi]),true); + argi++; + +#ifdef MAXMSP + // oldstyle command line? + if(argi == 1 && argc == 2 && CanbeInt(argv[argi])) { + outchns = GetAInt(argv[argi]); + argi++; + post("%s: old style command line detected - please change to '%s [channels] [buffer]'",thisName(),thisName()); + } +#endif + } + else + buf = new buffer(NULL,true); + + AddInSignal(); // speed signal + AddInFloat(2); // min & max play pos + AddOutSignal(outchns); // output + AddOutSignal(); // position + AddOutFloat(2); // play min & max + AddOutBang(); // loop bang + + FLEXT_ADDMETHOD(1,m_min); + FLEXT_ADDMETHOD(2,m_max); + FLEXT_ADDMETHOD_F(0,"min",m_min); + FLEXT_ADDMETHOD_F(0,"max",m_max); + FLEXT_ADDMETHOD_F(0,"pos",m_pos); + FLEXT_ADDMETHOD_(0,"all",m_all); + FLEXT_ADDMETHOD_B(0,"loop",m_loop); + + FLEXT_ADDMETHOD_F(0,"xzone",m_xzone); + FLEXT_ADDMETHOD_F(0,"xsymm",m_xsymm); + FLEXT_ADDMETHOD_(0,"xshape",m_xshape); + FLEXT_ADDMETHOD_B(0,"xkeep",m_xkeep); + + znbuf = new S *[outchns]; + for(I i = 0; i < outchns; ++i) znbuf[i] = new S[0]; + znpos = new S[0]; + znidx = new S[0]; + m_xshape(); +} + +xgroove::~xgroove() +{ + if(znbuf) { + for(I i = 0; i < outchns; ++i) delete[] znbuf[i]; + delete[] znbuf; + } + + if(znmul) delete[] znmul; + if(znpos) delete[] znpos; + if(znidx) delete[] znidx; +} + +BL xgroove::Init() +{ + if(xinter::Init()) { + outmin = GetOut(outchns+1); + outmax = GetOut(outchns+2); + + m_reset(); + return true; + } + else + return false; +} + +V xgroove::m_units(xs_unit mode) +{ + xsample::m_units(mode); + + m_sclmode(); + outputmin(); + outputmax(); +} + +V xgroove::m_min(F mn) +{ + xsample::m_min(mn); + m_pos(curpos*s2u); + do_xzone(); + outputmin(); +} + +V xgroove::m_max(F mx) +{ + xsample::m_max(mx); + m_pos(curpos*s2u); + do_xzone(); + outputmax(); +} + +V xgroove::m_pos(F pos) +{ + setpos(pos?pos/s2u:0); +} + +V xgroove::m_all() +{ + xsample::m_all(); + do_xzone(); + outputmin(); + outputmax(); +} + +BL xgroove::m_reset() +{ + curpos = 0; + bidir = 1; + return xsample::m_reset(); +} + +V xgroove::m_xzone(F xz) +{ + bufchk(); + _xzone = xz < 0?0:xz/s2u; + do_xzone(); + s_dsp(); +} + +V xgroove::m_xsymm(F xs) +{ + if(xs < 0) + xsymm = -1; + else if(xs <= 1) + xsymm = xs; + else { + post("%s - xsymm value out of range - set to center (0.5)",thisName()); + xsymm = 0.5; + } + do_xzone(); +} + +V xgroove::m_xshape(I argc,t_atom *argv) +{ + const F pi = 3.14159265358979f; + I i,sh = 0; + F param = 1; + if(argc >= 1 && CanbeInt(argv[0])) sh = GetAInt(argv[0]); + if(argc >= 2 && CanbeFloat(argv[1])) { + param = GetAFloat(argv[1]); + // clip to 0..1 + if(param < 0) param = 0; + else if(param > 1) param = 1; + } + + if(znmul) delete[] znmul; + znmul = new S[XZONE_TABLE+1]; + + switch(sh) { + case 1: + for(i = 0; i <= XZONE_TABLE; ++i) + znmul[i] = sin(i*(pi/2./XZONE_TABLE))*param+i*(1./XZONE_TABLE)*(1-param); + break; + case 0: + default: + for(i = 0; i <= XZONE_TABLE; ++i) + znmul[i] = i*(1./XZONE_TABLE); + } +} + +V xgroove::m_xkeep(BL k) +{ + xkeep = k; + do_xzone(); +} + +V xgroove::do_xzone() +{ + xzone = _xzone; + I smin = curmin,smax = curmax,plen = smax-smin; //curlen; + if(xsymm < 0) { + // crossfade zone is inside the loop (-> loop is shorter than nominal!) + if(xzone >= plen) xzone = plen-1; + znmin = smin+xzone,znmax = smax-xzone; + } + else { + // desired crossfade points + znmin = smin+xzone*xsymm,znmax = smax+xzone*(xsymm-1); + // extra space at beginning and end + F o1 = znmin-xzone,o2 = buf->Frames()-(znmax+xzone); + + if(o1 < 0 || o2 < 0) { // or (o1*o2 < 0) + if(o1+o2 < 0) { + // must reduce crossfade/loop length + if(!xkeep) { + // prefer preservation of cross-fade length + if(xzone >= plen) // have to reduce cross-fade length + xzone = plen-1; + znmin = smin+xzone,znmax = smax-xzone; + } + else { + // prefer preservation of loop length + znmin += o1,znmax -= o2; + xzone = (buf->Frames()-znmax+znmin)/2; + } + smin = 0,plen = smax = buf->Frames(); + } + else if(o1 < 0) { + // min point is out of bounds (but enough space for mere shift) + I i1 = (I)o1; + smin -= i1,smax -= i1; + znmin = smin+xzone*xsymm,znmax = smax+xzone*(xsymm-1); + } + else /* o2 < 0 */ { + // max point is out of bounds (but enough space for mere shift) + I i2 = (I)o2; + smin += i2,smax += i2; + znmin = smin+xzone*xsymm,znmax = smax+xzone*(xsymm-1); + } + } + } +} + +V xgroove::m_loop(xs_loop lp) +{ + loopmode = lp; + bidir = 1; + s_dsp(); +} + + +V xgroove::s_pos_off(I n,S *const *invecs,S *const *outvecs) +{ + S *pos = outvecs[outchns]; + + const F oscl = scale(curpos); + for(I si = 0; si < n; ++si) pos[si] = oscl; + + playfun(n,&pos,outvecs); +} + +V xgroove::s_pos_once(I n,S *const *invecs,S *const *outvecs) +{ + const S *speed = invecs[0]; + S *pos = outvecs[outchns]; + BL lpbang = false; + + const I smin = curmin,smax = curmax,plen = smax-smin; //curlen; + + if(buf && plen > 0) { + register D o = curpos; + + for(I i = 0; i < n; ++i) { + const S spd = speed[i]; // must be first because the vector is reused for output! + + if(o >= smax) { o = smax; lpbang = true; } + else if(o < smin) { o = smin; lpbang = true; } + + pos[i] = scale(o); + o += spd; + } + // normalize and store current playing position + setpos(o); + + playfun(n,&pos,outvecs); + } + else + s_pos_off(n,invecs,outvecs); + + if(lpbang) ToOutBang(outchns+3); +} + +V xgroove::s_pos_loop(I n,S *const *invecs,S *const *outvecs) +{ + const S *speed = invecs[0]; + S *pos = outvecs[outchns]; + BL lpbang = false; + + const I smin = curmin,smax = curmax,plen = smax-smin; //curlen; + + if(buf && plen > 0) { + register D o = curpos; + + for(I i = 0; i < n; ++i) { + const S spd = speed[i]; // must be first because the vector is reused for output! + + // normalize offset + if(o >= smax) { + o = fmod(o-smin,plen)+smin; + lpbang = true; + } + else if(o < smin) { + o = fmod(o-smin,plen)+smax; + lpbang = true; + } + + pos[i] = scale(o); + o += spd; + } + // normalize and store current playing position + setpos(o); + + playfun(n,&pos,outvecs); + } + else + s_pos_off(n,invecs,outvecs); + + if(lpbang) ToOutBang(outchns+3); +} + +V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) +{ + const S *speed = invecs[0]; + S *pos = outvecs[outchns]; + BL lpbang = false; + + const I smin = curmin,smax = curmax,plen = smax-smin; //curlen; + const F xz = xzone,lmin = znmin,lmax = znmax; + const F xf = (F)XZONE_TABLE/xz; + + if(buf && plen > 0) { + BL inzn = false; + register D o = curpos; + + for(I i = 0; i < n; ++i) { + const S spd = speed[i]; // must be first because the vector is reused for output! + + // normalize offset + if(o >= smax) { + o = fmod(o-smin,plen)+smin; + lpbang = true; + } + else if(o < smin) { + o = fmod(o-smin,plen)+smax; + lpbang = true; + } + + if(o >= lmax) // in late cross-fade zone + o -= lmax-smin; + + if(o < lmin) { + // in early cross-fade zone + register F inp = o-smin; + znidx[i] = inp*xf; + znpos[i] = scale(lmax+inp); + inzn = true; + } + else + znidx[i] = XZONE_TABLE,znpos[i] = 0; + + pos[i] = scale(o); + o += spd; + } + // normalize and store current playing position + setpos(o); + + playfun(n,&pos,outvecs); + + if(inzn) { + // only if we were in cross-fade zone + playfun(n,&znpos,znbuf); + + for(I i = 0; i < n; ++i) znpos[i] = XZONE_TABLE-znidx[i]; + zonefun(znmul,0,XZONE_TABLE+1,1,n,1,1,&znidx,&znidx); + zonefun(znmul,0,XZONE_TABLE+1,1,n,1,1,&znpos,&znpos); + + for(I o = 0; o < outchns; ++o) { + F *ov = outvecs[o],*ob = znbuf[o]; + for(I i = 0; i < n; ++i,ov++,ob++) + *ov = (*ov)*znidx[i]+(*ob)*znpos[i]; + } + } + } + else + s_pos_off(n,invecs,outvecs); + + if(lpbang) ToOutBang(outchns+3); +} + +V xgroove::s_pos_bidir(I n,S *const *invecs,S *const *outvecs) +{ + const S *speed = invecs[0]; + S *pos = outvecs[outchns]; + BL lpbang = false; + + const I smin = curmin,smax = curmax,plen = smax-smin; //curlen; + + if(buf && plen > 0) { + register D o = curpos; + register F bd = bidir; + + for(I i = 0; i < n; ++i) { + const S spd = speed[i]; // must be first because the vector is reused for output! + + // normalize offset + if(o >= smax) { + o = smax-fmod(o-smin,plen); // mirror the position at smax + bd = -bd; + lpbang = true; + } + else if(o < smin) { + o = smin-fmod(o-smin,plen); // mirror the position at smin + bd = -bd; + lpbang = true; + } + + pos[i] = scale(o); + o += spd*bd; + } + // normalize and store current playing position + setpos(o); + + bidir = (I)bd; + playfun(n,&pos,outvecs); + } + else + s_pos_off(n,invecs,outvecs); + + if(lpbang) ToOutBang(outchns+3); +} + + +V xgroove::s_dsp() +{ + if(doplay) { + switch(loopmode) { + case xsl_once: SETSIGFUN(posfun,SIGFUN(s_pos_once)); break; + case xsl_loop: + if(xzone > 0) { + const I blksz = Blocksize(); + + if(pblksz != blksz) { + for(I o = 0; o < outchns; ++o) { + delete[] znbuf[o]; + znbuf[o] = new S[blksz]; + } + + delete[] znpos; znpos = new S[blksz]; + delete[] znidx; znidx = new S[blksz]; + + pblksz = blksz; + } + + SETSIGFUN(posfun,SIGFUN(s_pos_loopzn)); + + if(interp == xsi_4p) + switch(outchns) { + case 1: SETSTFUN(zonefun,TMPLSTF(st_play4,1,1)); break; + case 2: SETSTFUN(zonefun,TMPLSTF(st_play4,1,2)); break; + case 4: SETSTFUN(zonefun,TMPLSTF(st_play4,1,4)); break; + default: SETSTFUN(zonefun,TMPLSTF(st_play4,1,-1)); + } + else if(interp == xsi_lin) + switch(outchns) { + case 1: SETSTFUN(zonefun,TMPLSTF(st_play2,1,1)); break; + case 2: SETSTFUN(zonefun,TMPLSTF(st_play2,1,2)); break; + case 4: SETSTFUN(zonefun,TMPLSTF(st_play2,1,4)); break; + default: SETSTFUN(zonefun,TMPLSTF(st_play2,1,-1)); + } + else + switch(outchns) { + case 1: SETSTFUN(zonefun,TMPLSTF(st_play1,1,1)); break; + case 2: SETSTFUN(zonefun,TMPLSTF(st_play1,1,2)); break; + case 4: SETSTFUN(zonefun,TMPLSTF(st_play1,1,4)); break; + default: SETSTFUN(zonefun,TMPLSTF(st_play1,1,-1)); + } + } + else + SETSIGFUN(posfun,SIGFUN(s_pos_loop)); + break; + case xsl_bidir: SETSIGFUN(posfun,SIGFUN(s_pos_bidir)); break; + } + } + else + SETSIGFUN(posfun,SIGFUN(s_pos_off)); + xinter::s_dsp(); +} + + + +V xgroove::m_help() +{ + post("%s - part of xsample objects, version " XSAMPLE_VERSION,thisName()); +#ifdef _DEBUG + post("compiled on " __DATE__ " " __TIME__); +#endif + post("(C) Thomas Grill, 2001-2002"); +#ifdef MAXMSP + post("Arguments: %s [channels=1] [buffer]",thisName()); +#else + post("Arguments: %s [buffer]",thisName()); +#endif + post("Inlets: 1:Messages/Speed signal, 2:Min position, 3:Max position"); + post("Outlets: 1:Audio signal, 2:Position signal, 3:Min position (rounded), 4:Max position (rounded)"); + post("Methods:"); + post("\thelp: shows this help"); + post("\tset [name]: set buffer or reinit"); + post("\tenable 0/1: turn dsp calculation off/on"); + post("\treset: reset min/max playing points and playing offset"); + post("\tprint: print current settings"); + post("\tloop 0/1/2: sets looping to off/forward/bidirectional"); + post("\tinterp 0/1/2: set interpolation to off/4-point/linear"); + post("\tmin {unit}: set minimum playing point"); + post("\tmax {unit}: set maximum playing point"); + post("\tall: select entire buffer length"); + post("\tpos {unit}: set playing position (obeying the current scale mode)"); + post("\tbang/start: start playing"); + post("\tstop: stop playing"); + post("\trefresh: checks buffer and refreshes outlets"); + post("\tunits 0/1/2/3: set units to frames/buffer size/ms/s"); + post("\tsclmode 0/1/2/3: set range of position to units/units in loop/buffer/loop"); + post("\txzone {unit}: length of loop crossfade zone"); + post("\txsymm -1,0...1: symmetry of crossfade zone inside/outside point"); + post("\txshape 0/1 [param 0...1]: shape of crossfading (linear/trig)"); + post(""); +} + +V xgroove::m_print() +{ + static const C *sclmode_txt[] = {"units","units in loop","buffer","loop"}; + static const C *interp_txt[] = {"off","4-point","linear"}; + static const C *loop_txt[] = {"once","looping","bidir"}; + + // print all current settings + post("%s - current settings:",thisName()); + post("bufname = '%s', length = %.3f, channels = %i",buf->Name(),(F)(buf->Frames()*s2u),buf->Channels()); + post("out channels = %i, frames/unit = %.3f, scale mode = %s",outchns,(F)(1./s2u),sclmode_txt[sclmode]); + post("loop = %s, interpolation = %s",loop_txt[(I)loopmode],interp_txt[interp >= xsi_none && interp <= xsi_lin?interp:xsi_none]); + post("loop crossfade zone = %.3f",(F)(xzone*s2u)); + post(""); +} + +#ifdef MAXMSP +V xgroove::m_assist(long msg, long arg, char *s) +{ + switch(msg) { + case 1: //ASSIST_INLET: + switch(arg) { + case 0: + sprintf(s,"Signal of playing speed"); break; + case 1: + sprintf(s,"Starting point"); break; + case 2: + sprintf(s,"Ending point"); break; + } + break; + case 2: //ASSIST_OUTLET: + if(arg < outchns) + sprintf(s,"Audio signal channel %li",arg+1); + else + switch(arg-outchns) { + case 0: + sprintf(s,"Position currently played"); break; + case 1: + sprintf(s,"Starting point (rounded to frame)"); break; + case 2: + sprintf(s,"Ending point (rounded to frame)"); break; + case 3: + sprintf(s,"Bang on loop end/rollover"); break; + } + break; + } +} +#endif + + + + + diff --git a/externals/grill/xsample/source/inter.ci b/externals/grill/xsample/source/inter.ci new file mode 100644 index 00000000..2902c386 --- /dev/null +++ b/externals/grill/xsample/source/inter.ci @@ -0,0 +1,355 @@ +#ifndef __INTER_H +#define __INTER_H + +TMPLDEF V xinter::st_play0(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs) +{ + // stopped + SIGCHNS(BCHNS,inchns,OCHNS,outchns); + + const S *pos = invecs[0]; + S *const *sig = outvecs; + + for(I ci = 0; ci < outchns; ++ci) + for(I si = 0; si < n; ++si) sig[ci][si] = 0; +} + +TMPLDEF V xinter::st_play1(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs) +{ + SIGCHNS(BCHNS,inchns,OCHNS,outchns); + + const S *pos = invecs[0]; + S *const *sig = outvecs; + register I si = 0; + + // no interpolation + // ---------------- + + for(I i = 0; i < n; ++i,++si) { + register const I oint = (I)(*(pos++)/s2u); + register const S *fp; + if(oint < smin) { + // position < 0 ... take only 0th sample + fp = bdt+smin*BCHNS; + } + else if(oint >= smax) { + // position > last sample ... take only last sample + fp = bdt+(smax-1)*BCHNS; + } + else { + // normal + fp = bdt+oint*BCHNS; + } + + for(I ci = 0; ci < OCHNS; ++ci) + sig[ci][si] = fp[ci]; + } + + // clear rest of output channels (if buffer has less channels) + for(I ci = OCHNS; ci < outchns; ++ci) + for(si = 0; si < n; ++si) sig[ci][si] = 0; +} + +TMPLDEF V xinter::st_play2(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs) +{ + const I plen = smax-smin; //curlen; + if(plen < 2) { + st_play1 TMPLCALL (bdt,smin,smax,s2u,n,inchns,outchns,invecs,outvecs); + return; + } + + SIGCHNS(BCHNS,inchns,OCHNS,outchns); + + const S *pos = invecs[0]; + S *const *sig = outvecs; + register I si = 0; + + // linear interpolation + // -------------------- + + const I maxo = smax-1; // last sample in buffer + + for(I i = 0; i < n; ++i,++si) { + const F o = *(pos++)/s2u; + register const I oint = (I)o; + + if(oint < smin) { + // position is before first sample -> take the first sample + register const S *const fp = bdt+smin*BCHNS; + for(I ci = 0; ci < OCHNS; ++ci) + sig[ci][si] = fp[ci]; + } + else if(oint >= maxo) { + // position is past last sample -> take the last sample + register const S *const fp = bdt+maxo*BCHNS; + for(I ci = 0; ci < OCHNS; ++ci) + sig[ci][si] = fp[ci]; + } + else { + // normal interpolation + register const F frac = o-oint; + register const S *const fp0 = bdt+oint*BCHNS; + register const S *const fp1 = fp0+BCHNS; + for(I ci = 0; ci < OCHNS; ++ci) + sig[ci][si] = fp0[ci]+frac*(fp1[ci]-fp0[ci]); + } + } + + // clear rest of output channels (if buffer has less channels) + for(I ci = OCHNS; ci < outchns; ++ci) + for(si = 0; si < n; ++si) sig[ci][si] = 0; +} + +TMPLDEF V xinter::st_play4(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs) +{ + const I plen = smax-smin; //curlen; + if(plen < 4) { + if(plen < 2) st_play1 TMPLCALL (bdt,smin,smax,s2u,n,inchns,outchns,invecs,outvecs); + else st_play2 TMPLCALL (bdt,smin,smax,s2u,n,inchns,outchns,invecs,outvecs); + return; + } + + SIGCHNS(BCHNS,inchns,OCHNS,outchns); + + const S *pos = invecs[0]; + S *const *sig = outvecs; + register I si = 0; + + // 4-point interpolation + // --------------------- + const I maxo = smax-1; // last sample in play region + + for(I i = 0; i < n; ++i,++si) { + F o = *(pos++)/s2u; + register I oint = (I)o,ointm,oint1,oint2; + + if(oint <= smin) { + if(oint < smin) oint = smin,o = smin; + // position is first simple + ointm = smin; // first sample + oint1 = oint+1; + oint2 = oint1+1; + } + else if(oint >= maxo-2) { + if(oint > maxo) oint = maxo,o = smax; + ointm = oint-1; + oint1 = oint >= maxo?maxo:oint+1; + oint2 = oint1 >= maxo?maxo:oint1+1; + } + else { + ointm = oint-1; + oint1 = oint+1; + oint2 = oint1+1; + } + + register F frac = o-oint; + + register const S *fa = bdt+ointm*BCHNS; + register const S *fb = bdt+oint*BCHNS; + register const S *fc = bdt+oint1*BCHNS; + register const S *fd = bdt+oint2*BCHNS; + + for(I ci = 0; ci < OCHNS; ++ci) { + const F cmb = fc[ci]-fb[ci]; + sig[ci][si] = fb[ci] + frac*( + cmb - 0.5f*(frac-1.) * ((fa[ci]-fd[ci]+3.0f*cmb)*frac + (fb[ci]-fa[ci]-cmb)) + ); + } + } + + // clear rest of output channels (if buffer has less channels) + for(I ci = OCHNS; ci < outchns; ++ci) + for(si = 0; si < n; ++si) sig[ci][si] = 0; +} + +#if 0 + +TMPLDEF V xinter::s_play0(I n,S *const *invecs,S *const *outvecs) +{ + // stopped + SIGCHNS(BCHNS,buf->Channels(),OCHNS,outchns); + + const S *pos = invecs[0]; + S *const *sig = outvecs; + + for(I ci = 0; ci < outchns; ++ci) + for(I si = 0; si < n; ++si) sig[ci][si] = 0; +} + +TMPLDEF V xinter::s_play4(I n,S *const *invecs,S *const *outvecs) +{ + const I smin = curmin,smax = curmax,plen = smax-smin; //curlen; + if(plen < 4) { + if(plen < 2) s_play1 TMPLCALL (n,invecs,outvecs); + else s_play2 TMPLCALL (n,invecs,outvecs); + return; + } + + SIGCHNS(BCHNS,buf->Channels(),OCHNS,outchns); + + const S *pos = invecs[0]; + S *const *sig = outvecs; + register I si = 0; + const S *bdt = buf->Data(); + + // 4-point interpolation + // --------------------- + const I maxo = smax-1; // last sample in play region + + for(I i = 0; i < n; ++i,++si) { + F o = *(pos++)/s2u; + register I oint = (I)o,ointm,oint1,oint2; + + if(oint <= smin) { + if(oint < smin) oint = smin,o = smin; + // position is first simple + ointm = smin; // first sample + oint1 = oint+1; + oint2 = oint1+1; + } + else if(oint >= maxo-2) { + if(oint > maxo) oint = maxo,o = smax; + ointm = oint-1; + oint1 = oint >= maxo?maxo:oint+1; + oint2 = oint1 >= maxo?maxo:oint1+1; + } + else { + ointm = oint-1; + oint1 = oint+1; + oint2 = oint1+1; + } + + register F frac = o-oint; + + register const S *fa = bdt+ointm*BCHNS; + register const S *fb = bdt+oint*BCHNS; + register const S *fc = bdt+oint1*BCHNS; + register const S *fd = bdt+oint2*BCHNS; + + for(I ci = 0; ci < OCHNS; ++ci) { + const F cmb = fc[ci]-fb[ci]; + sig[ci][si] = fb[ci] + frac*( + cmb - 0.5f*(frac-1.) * ((fa[ci]-fd[ci]+3.0f*cmb)*frac + (fb[ci]-fa[ci]-cmb)) + ); + } + } + + // clear rest of output channels (if buffer has less channels) + for(I ci = OCHNS; ci < outchns; ++ci) + for(si = 0; si < n; ++si) sig[ci][si] = 0; +} + +TMPLDEF V xinter::s_play2(I n,S *const *invecs,S *const *outvecs) +{ + const I smin = curmin,smax = curmax,plen = smax-smin; //curlen; + if(plen < 2) { + s_play1 TMPLCALL (n,invecs,outvecs); + return; + } + + SIGCHNS(BCHNS,buf->Channels(),OCHNS,outchns); + + const S *pos = invecs[0]; + S *const *sig = outvecs; + register I si = 0; + + // linear interpolation + // -------------------- + + const I maxo = smax-1; // last sample in buffer + const S *bdt = buf->Data(); + + for(I i = 0; i < n; ++i,++si) { + const F o = *(pos++)/s2u; + register const I oint = (I)o; + + if(oint < smin) { + // position is before first sample -> take the first sample + register const S *const fp = bdt+smin*BCHNS; + for(I ci = 0; ci < OCHNS; ++ci) + sig[ci][si] = fp[ci]; + } + else if(oint >= maxo) { + // position is past last sample -> take the last sample + register const S *const fp = bdt+maxo*BCHNS; + for(I ci = 0; ci < OCHNS; ++ci) + sig[ci][si] = fp[ci]; + } + else { + // normal interpolation + register const F frac = o-oint; + register const S *const fp0 = bdt+oint*BCHNS; + register const S *const fp1 = fp0+BCHNS; + for(I ci = 0; ci < OCHNS; ++ci) + sig[ci][si] = fp0[ci]+frac*(fp1[ci]-fp0[ci]); + } + } + + // clear rest of output channels (if buffer has less channels) + for(I ci = OCHNS; ci < outchns; ++ci) + for(si = 0; si < n; ++si) sig[ci][si] = 0; +} + +TMPLDEF V xinter::s_play1(I n,S *const *invecs,S *const *outvecs) +{ + SIGCHNS(BCHNS,buf->Channels(),OCHNS,outchns); + + const S *pos = invecs[0]; + S *const *sig = outvecs; + register I si = 0; + const I smin = curmin,smax = curmax; + const S *bdt = buf->Data(); + + // no interpolation + // ---------------- + + for(I i = 0; i < n; ++i,++si) { + register const I oint = (I)(*(pos++)/s2u); + register const S *fp; + if(oint < smin) { + // position < 0 ... take only 0th sample + fp = bdt+smin*BCHNS; + } + else if(oint >= smax) { + // position > last sample ... take only last sample + fp = bdt+(smax-1)*BCHNS; + } + else { + // normal + fp = bdt+oint*BCHNS; + } + + for(I ci = 0; ci < OCHNS; ++ci) + sig[ci][si] = fp[ci]; + } + + // clear rest of output channels (if buffer has less channels) + for(I ci = OCHNS; ci < outchns; ++ci) + for(si = 0; si < n; ++si) sig[ci][si] = 0; +} + +#else + +TMPLDEF V xinter::s_play0(I n,S *const *invecs,S *const *outvecs) +{ + st_play0 TMPLCALL (buf->Data(),curmin,curmax,s2u,n,buf->Channels(),outchns,invecs,outvecs); +} + +TMPLDEF V xinter::s_play1(I n,S *const *invecs,S *const *outvecs) +{ + st_play1 TMPLCALL (buf->Data(),curmin,curmax,s2u,n,buf->Channels(),outchns,invecs,outvecs); +} + +TMPLDEF V xinter::s_play2(I n,S *const *invecs,S *const *outvecs) +{ + st_play2 TMPLCALL (buf->Data(),curmin,curmax,s2u,n,buf->Channels(),outchns,invecs,outvecs); +} + +TMPLDEF V xinter::s_play4(I n,S *const *invecs,S *const *outvecs) +{ + st_play4 TMPLCALL (buf->Data(),curmin,curmax,s2u,n,buf->Channels(),outchns,invecs,outvecs); +} + +#endif + + +#endif diff --git a/externals/grill/xsample/source/inter.cpp b/externals/grill/xsample/source/inter.cpp new file mode 100644 index 00000000..095fba6f --- /dev/null +++ b/externals/grill/xsample/source/inter.cpp @@ -0,0 +1,95 @@ +/* + +xsample - extended sample objects for Max/MSP and pd (pure data) + +Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "main.h" +#include + +#ifdef _MSC_VER +#pragma warning (disable:4244) +#endif + +#ifndef TMPLOPT +#include "inter.ci" +#endif + + +xinter::xinter(): + doplay(false),outchns(1), + interp(xsi_4p) +{ + FLEXT_ADDMETHOD_E(0,"interp",m_interp); +} + +I xinter::m_set(I argc,t_atom *argv) +{ + I r = xsample::m_set(argc,argv); + if(r < 0) m_reset(); // resets pos/min/max + if(r != 0) m_units(); + return r; +} + +V xinter::m_start() +{ + m_refresh(); + doplay = true; + s_dsp(); +} + +V xinter::m_stop() +{ + doplay = false; + s_dsp(); +} + +V xinter::s_dsp() +{ + if(doplay) { + if(interp == xsi_4p) + switch(buf->Channels()*1000+outchns) { + case 1001: SETSIGFUN(playfun,TMPLFUN(s_play4,1,1)); break; + case 1002: SETSIGFUN(playfun,TMPLFUN(s_play4,1,2)); break; + case 2001: SETSIGFUN(playfun,TMPLFUN(s_play4,2,1)); break; + case 2002: SETSIGFUN(playfun,TMPLFUN(s_play4,2,2)); break; + case 4001: + case 4002: + case 4003: SETSIGFUN(playfun,TMPLFUN(s_play4,4,-1)); break; + case 4004: SETSIGFUN(playfun,TMPLFUN(s_play4,4,4)); break; + default: SETSIGFUN(playfun,TMPLFUN(s_play4,-1,-1)); + } + else if(interp == xsi_lin) + switch(buf->Channels()*1000+outchns) { + case 1001: SETSIGFUN(playfun,TMPLFUN(s_play2,1,1)); break; + case 1002: SETSIGFUN(playfun,TMPLFUN(s_play2,1,2)); break; + case 2001: SETSIGFUN(playfun,TMPLFUN(s_play2,2,1)); break; + case 2002: SETSIGFUN(playfun,TMPLFUN(s_play2,2,2)); break; + case 4001: + case 4002: + case 4003: SETSIGFUN(playfun,TMPLFUN(s_play2,4,-1)); break; + case 4004: SETSIGFUN(playfun,TMPLFUN(s_play2,4,4)); break; + default: SETSIGFUN(playfun,TMPLFUN(s_play2,-1,-1)); + } + else + switch(buf->Channels()*1000+outchns) { + case 1001: SETSIGFUN(playfun,TMPLFUN(s_play1,1,1)); break; + case 1002: SETSIGFUN(playfun,TMPLFUN(s_play1,1,2)); break; + case 2001: SETSIGFUN(playfun,TMPLFUN(s_play1,2,1)); break; + case 2002: SETSIGFUN(playfun,TMPLFUN(s_play1,2,2)); break; + case 4001: + case 4002: + case 4003: SETSIGFUN(playfun,TMPLFUN(s_play1,4,-1)); break; + case 4004: SETSIGFUN(playfun,TMPLFUN(s_play1,4,4)); break; + default: SETSIGFUN(playfun,TMPLFUN(s_play1,-1,-1)); + } + } + else + SETSIGFUN(playfun,TMPLFUN(s_play0,-1,-1)); +} + + diff --git a/externals/grill/xsample/source/main.cpp b/externals/grill/xsample/source/main.cpp new file mode 100644 index 00000000..410746ff --- /dev/null +++ b/externals/grill/xsample/source/main.cpp @@ -0,0 +1,203 @@ +/* + +xsample - extended sample objects for Max/MSP and pd (pure data) + +Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "main.h" + + +// Initialization function for xsample library +V lib_setup() +{ + post("xsample objects, version " XSAMPLE_VERSION ", (C)2001,2002 Thomas Grill"); + post("xsample: xrecord~, xplay~, xgroove~ - send objects a 'help' message to get assistance"); + post(""); + + // call the objects' setup routines + FLEXT_DSP_SETUP(xrecord); + FLEXT_DSP_SETUP(xplay); + FLEXT_DSP_SETUP(xgroove); + +#ifdef MAXMSP + // That's not the right place..... (doesn't work) + finder_addclass((char *)"MSP Sampling",(char *)"xgroove~"); + finder_addclass((char *)"MSP Sampling",(char *)"xplay~"); + finder_addclass((char *)"MSP Sampling",(char *)"xrecord~"); +#endif + +} + +// setup the library +FLEXT_LIB_SETUP(xsample,lib_setup) + +// ------------------------------ + +xsample::xsample(): + buf(NULL), +#ifdef PD + unitmode(xsu_sample), // PD defaults to samples +#else + unitmode(xsu_ms), // Max/MSP defaults to milliseconds +#endif + sclmode(xss_unitsinbuf), + curmin(0),curmax(1<<30) +{ + FLEXT_ADDBANG(0,m_start); + FLEXT_ADDMETHOD_(0,"start",m_start); + FLEXT_ADDMETHOD_(0,"stop",m_stop); + + FLEXT_ADDMETHOD_(0,"set",m_set); + FLEXT_ADDMETHOD_(0,"print",m_print); + FLEXT_ADDMETHOD_(0,"refresh",m_refresh); + FLEXT_ADDMETHOD_(0,"reset",m_reset); + + FLEXT_ADDMETHOD_E(0,"units",m_units); + FLEXT_ADDMETHOD_E(0,"sclmode",m_sclmode); +} + +xsample::~xsample() +{ +// m_enable(false); // switch off DSP + + if(buf) delete buf; +} + + + +I xsample::m_set(I argc, t_atom *argv) +{ + return buf->Set(argc >= 1?GetASymbol(argv[0]):NULL); +} + +BL xsample::m_refresh() +{ +// bufchk(); + + BL ret; + if(buf->Set()) { s_dsp(); ret = true; } // channel count may have changed + else ret = false; + + m_min((F)curmin*s2u); // also checks pos + m_max((F)curmax*s2u); // also checks pos + + return ret; +} + +BL xsample::m_reset() +{ +// bufchk(); + + BL ret; + if(buf->Set()) { s_dsp(); ret = true; } // channel count may have changed + else ret = false; + + m_units(); + m_sclmode(); + m_min(0); + m_max(buf->Frames()*s2u); + + return ret; +} + +V xsample::m_loadbang() +{ + m_reset(); +} + +V xsample::m_units(xs_unit mode) +{ + bufchk(); + + if(mode != xsu__) unitmode = mode; + switch(unitmode) { + case xsu_sample: // samples + s2u = 1; + break; + case xsu_buffer: // buffer size + s2u = 1.f/buf->Frames(); + break; + case xsu_ms: // ms + s2u = 1000.f/Samplerate(); + break; + case xsu_s: // s + s2u = 1.f/Samplerate(); + break; + default: + post("%s: Unknown unit mode",thisName()); + } +} + +V xsample::m_sclmode(xs_sclmd mode) +{ + bufchk(); + + if(mode != xss__) sclmode = mode; + switch(sclmode) { + case 0: // samples/units + sclmin = 0; sclmul = s2u; + break; + case 1: // samples/units from recmin to recmax + sclmin = curmin; sclmul = s2u; + break; + case 2: // unity between 0 and buffer size + sclmin = 0; sclmul = buf->Frames()?1.f/buf->Frames():0; + break; + case 3: // unity between recmin and recmax +// sclmin = curmin; sclmul = curlen?1.f/curlen:0; + sclmin = curmin; sclmul = curmin != curmax?1.f/(curmax-curmin):0; + break; + default: + post("%s: Unknown scale mode",thisName()); + } +} + +V xsample::m_min(F mn) +{ + bufchk(); + + mn /= s2u; // conversion to samples + if(mn < 0) mn = 0; + else if(mn > curmax) mn = (F)curmax; + curmin = (I)(mn+.5); +// curlen = curmax-curmin; + + m_sclmode(); +} + +V xsample::m_max(F mx) +{ + bufchk(); + + mx /= s2u; // conversion to samples + if(mx > buf->Frames()) mx = (F)buf->Frames(); + else if(mx < curmin) mx = (F)curmin; + curmax = (I)(mx+.5); +// curlen = curmax-curmin; + + m_sclmode(); +} + +V xsample::m_all() +{ + bufchk(); + +// curlen = (curmax = buf->Frames())-(curmin = 0); + curmin = 0; curmax = buf->Frames(); + m_sclmode(); +} + +V xsample::m_dsp(I /*n*/,S *const * /*insigs*/,S *const * /*outsigs*/) +{ + // this is hopefully called at change of sample rate ?! + + if(!m_refresh()) s_dsp(); +} + + + + diff --git a/externals/grill/xsample/source/main.h b/externals/grill/xsample/source/main.h new file mode 100644 index 00000000..db78a630 --- /dev/null +++ b/externals/grill/xsample/source/main.h @@ -0,0 +1,277 @@ +/* + +xsample - extended sample objects for Max/MSP and pd (pure data) + +Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#ifndef __XSAMPLE_H +#define __XSAMPLE_H + +#define XSAMPLE_VERSION "0.2.5pre1" + + +#include + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400) +#error You need at least flext version 0.4.0 +#endif + + +// most compilers are somehow broken..... +// in other words: can't handle all C++ features + +#if defined(_MSC_VER) +// MS VC 6.0 can't handle templates?! -> no optimization +// #define TMPLOPT +#elif defined(__BORLANDC__) +// handles all optimizations + #define TMPLOPT +#elif defined(__GNUC__) +// GNUC 2.95.2 dies at compile with templates +#if __GNUC__ >= 3 + #define TMPLOPT // only workable with gcc >= 3.0 +#endif +#elif defined(__MWERKS__) +// CodeWarrior can't take address of a template member function + #define TMPLOPT + #define SIGSTATIC +#elif defined(__MRC__) +// Apple MPW - MrCpp +// #define TMPLOPT // template optimation for more speed +#else +// another compiler +// #define TMPLOPT // template optimation for more speed (about 10%) + //#define SIGSTATIC // another redirection to avoid addresses of class member functions +#endif + + +// lazy me +#define F float +#define D double +#define I int +#define L long +#define C char +#define V void +#define BL bool +#define S t_sample + + +class xsample: + public flext_dsp +{ + FLEXT_HEADER(xsample,flext_dsp) + +public: + xsample(); + ~xsample(); + + enum xs_unit { + xsu__ = -1, // don't change + xsu_sample = 0,xsu_buffer,xsu_ms,xsu_s + }; + + enum xs_intp { + xsi__ = -1, // don't change + xsi_none = 0,xsi_4p,xsi_lin + }; + + enum xs_sclmd { + xss__ = -1, // don't change + xss_unitsinbuf = 0,xss_unitsinloop,xss_buffer,xss_loop + }; + +protected: + buffer *buf; + + virtual V m_start() = 0; + virtual V m_stop() = 0; + virtual BL m_reset(); + + virtual I m_set(I argc,t_atom *argv); + virtual V m_print() = 0; + virtual BL m_refresh(); + virtual V m_loadbang(); + + virtual V m_units(xs_unit u = xsu__); + virtual V m_sclmode(xs_sclmd u = xss__); + + virtual V m_all(); + virtual V m_min(F mn); + virtual V m_max(F mx); + + virtual V m_dsp(I n,F *const *insigs,F *const *outsigs); + virtual V s_dsp() = 0; + + xs_unit unitmode; //iunitmode,ounitmode; + xs_sclmd sclmode; //isclmode,osclmode; + + I curmin,curmax; //,curlen; // in samples + I sclmin; // in samples + F sclmul; + F s2u; // sample to unit conversion factor + + inline F scale(F smp) const { return (smp-sclmin)*sclmul; } + + BL bufchk() { if(buf->Update()) { m_refresh(); return true; } return false; } + +private: + + FLEXT_CALLBACK(m_start) + FLEXT_CALLBACK(m_stop) + + FLEXT_CALLBACK_V(m_set) + FLEXT_CALLBACK(m_print) + FLEXT_CALLBACK(m_refresh) + FLEXT_CALLBACK(m_reset) + + FLEXT_CALLBACK_1(m_units,xs_unit) + FLEXT_CALLBACK_1(m_sclmode,xs_sclmd) +}; + + +// defines which are used in the derived classes +#ifdef SIGSTATIC + #ifdef TMPLOPT + #define TMPLFUN(FUN,BCHNS,IOCHNS) &thisType::st_##FUN + #define TMPLSTF(FUN,BCHNS,IOCHNS) &thisType::FUN + #define SIGFUN(FUN) &thisType::st_##FUN + #define TMPLDEF template + #define TMPLCALL <_BCHNS_,_IOCHNS_> + #else + #define TMPLFUN(FUN,BCHNS,IOCHNS) &thisType::st_##FUN + #define TMPLSTF(FUN,BCHNS,IOCHNS) &thisType::FUN + #define SIGFUN(FUN) &thisType::st_##FUN + #define TMPLDEF + #define TMPLCALL + #endif + + #define DEFSIGFUN(NAME) \ + static V st_##NAME(thisType *obj,I n,S *const *in,S *const *out) { obj->NAME (n,in,out); } \ + V NAME(I n,S *const *in,S *const *out) + + #define TMPLSIGFUN(NAME) \ + TMPLDEF static V st_##NAME(thisType *obj,I n,S *const *in,S *const *out) { obj->NAME TMPLCALL (n,in,out); } \ + TMPLDEF V NAME(I n,S *const *in,S *const *out) + + #define TMPLSTFUN(NAME) TMPLDEF static V NAME(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs) + + #define SETSIGFUN(VAR,FUN) v_##VAR = FUN + + #define SETSTFUN(VAR,FUN) VAR = FUN + + #define DEFSIGCALL(NAME) \ + inline V NAME(I n,S *const *in,S *const *out) { (*v_##NAME)(this,n,in,out); } \ + V (*v_##NAME)(thisType *obj,I n,S *const *in,S *const *out) + + #define DEFSTCALL(NAME) \ + V (*NAME)(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs) + +#else + #ifdef TMPLOPT + #define TMPLFUN(FUN,BCHNS,IOCHNS) &thisType::FUN + #define SIGFUN(FUN) &thisType::FUN + #define TMPLDEF template + #define TMPLCALL <_BCHNS_,_IOCHNS_> + #else + #define TMPLFUN(FUN,BCHNS,IOCHNS) &thisType::FUN + #define SIGFUN(FUN) &thisType::FUN + #define TMPLDEF + #define TMPLCALL + #endif + + #define TMPLSTF(FUN,BCHNS,IOCHNS) TMPLFUN(FUN,BCHNS,IOCHNS) + + #define DEFSIGFUN(NAME) V NAME(I n,S *const *in,S *const *out) + #define TMPLSIGFUN(NAME) TMPLDEF V NAME(I n,S *const *in,S *const *out) + #define TMPLSTFUN(NAME) TMPLDEF static V NAME(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs) + + #define SETSIGFUN(VAR,FUN) v_##VAR = FUN + + #define DEFSIGCALL(NAME) \ + inline V NAME(I n,S *const *in,S *const *out) { (this->*v_##NAME)(n,in,out); } \ + V (thisType::*v_##NAME)(I n,S *const *invecs,S *const *outvecs) + + #define SETSTFUN(VAR,FUN) VAR = FUN + + #define DEFSTCALL(NAME) \ + V (*NAME)(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs) +#endif + + + + + +#ifndef MIN +#define MIN(x,y) ((x) < (y)?(x):(y)) +#endif + +// in the signal functions +#ifdef TMPLOPT + // optimization by using constants for channel numbers + #define SIGCHNS(BCHNS,bchns,IOCHNS,iochns) \ + const I BCHNS = _BCHNS_ < 0?(bchns):_BCHNS_; \ + const I IOCHNS = _IOCHNS_ < 0?MIN(iochns,BCHNS):MIN(_IOCHNS_,BCHNS) +#else + // no template optimization + #ifdef PD // only mono buffers + #define SIGCHNS(BCHNS,bchns,IOCHNS,iochns) \ + const I BCHNS = 1; \ + const I IOCHNS = MIN(iochns,BCHNS) + #else // MAXMSP + #define SIGCHNS(BCHNS,bchns,IOCHNS,iochns) \ + const I BCHNS = bchns; \ + const I IOCHNS = MIN(iochns,BCHNS) + #endif +#endif + + +class xinter: + public xsample +{ + FLEXT_HEADER(xinter,xsample) + +public: + xinter(); + +protected: + virtual I m_set(I argc,t_atom *argv); + + virtual V m_start(); + virtual V m_stop(); + + V m_interp(xs_intp mode = xsi__) { interp = mode; s_dsp(); } + + I outchns; + BL doplay; + xs_intp interp; + + TMPLSIGFUN(s_play0); + TMPLSIGFUN(s_play1); + TMPLSIGFUN(s_play2); + TMPLSIGFUN(s_play4); + + TMPLSTFUN(st_play0); + TMPLSTFUN(st_play1); + TMPLSTFUN(st_play2); + TMPLSTFUN(st_play4); + + DEFSIGCALL(playfun); + + virtual V s_dsp(); + +private: + + FLEXT_CALLBACK_1(m_interp,xs_intp) +}; + +#ifdef TMPLOPT +#include "inter.ci" +#endif + +#endif + + diff --git a/externals/grill/xsample/source/makefile.bcc b/externals/grill/xsample/source/makefile.bcc new file mode 100644 index 00000000..e9e624b2 --- /dev/null +++ b/externals/grill/xsample/source/makefile.bcc @@ -0,0 +1,74 @@ +# xsample - extended sample objects for Max/MSP and pd (pure data) +# Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +# +# Makefile for BorlandC++ +# +# usage: make -f makefile.bcc +# +# --------------------------------------------- + +NAME=xsample +SETUPFUNCTION=$(NAME)_setup + +# where to put the build +OUTPATH=..\bcc + +# flext stuff +FLEXTPATH=..\..\flext ### EDIT! ## +TARGET=pdwin + +# paths +BCCPATH=c:\programme\prog\bcc55 ### EDIT! ## +PDPATH=c:\programme\audio\pd ### EDIT! ## + +# includes, libs +INCPATH=-I$(BCCPATH)\include -I$(PDPATH)\src -I$(FLEXTPATH)\source +LIBPATH=-L$(BCCPATH)\lib -L$(PDPATH)\lib +LIBS=cw32.lib import32.lib C0D32.OBJ + +# compiler definitions and flags +DEFS=-DPD -DNT +CFLAGS=-6 -O2 -OS -ff -tWD + + +# the rest can stay untouched +# ---------------------------------------------- + +# all the source files from the package +SRCS= main.cpp inter.cpp record.cpp play.cpp groove.cpp +HDRS= main.h inter.ci + +OBJS= $(SRCS:.cpp=.obj) + +# default target +all: $(OUTPATH)\$(NAME).dll + +# remove build +clean: + -del /s /q $(OUTPATH) > nul + rmdir $(OUTPATH) + +# ---------------------------------------------- + +$(SRCS): $(HDRS) + -touch $< + +.PATH.OBJ=$(OUTPATH) + +.cpp.obj: + bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(OUTPATH) $< + +$(OUTPATH): + -@if not exist $< mkdir $< + +$(OUTPATH)\pd.lib: $(PDPATH)\bin\pd.dll + implib -a $@ $** + +$(OUTPATH)\$(NAME).def: + @echo EXPORTS $(SETUPFUNCTION) = _$(SETUPFUNCTION) > $< + +$(OUTPATH)\$(NAME).dll :: $(OUTPATH) $(OUTPATH)\$(NAME).def $(OUTPATH)\pd.lib + +$(OUTPATH)\$(NAME).dll :: $(OBJS) + ilink32 -C -Tpd $(LIBPATH) $** ,$<,,$(LIBS) $(OUTPATH)\pd.lib $(FLEXTPATH)\pd-bcc\flext-$(TARGET).lib,$(OUTPATH)\$(NAME).def + diff --git a/externals/grill/xsample/source/makefile.pd-cygwin b/externals/grill/xsample/source/makefile.pd-cygwin new file mode 100644 index 00000000..18c53431 --- /dev/null +++ b/externals/grill/xsample/source/makefile.pd-cygwin @@ -0,0 +1,89 @@ +# xsample - extended sample objects for Max/MSP and pd (pure data) +# Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +# +# Makefile for gcc @ linux +# +# usage: +# to build run "make -f makefile.pd-cygwin" +# to install (as root), do "make -f makefile.pd-cygwin install" +# + +## EDIT ZONE ################################## + +# flext path +FLEXTPATH=../../flext + +# pd path +PDPATH=c:/programme/audio/pd + +# where to install +INSTDIR=c:/programme/audio/pd/extra + +############################################### + +FLEXTLIB=$(FLEXTPATH)/pd-cygwin/flext.lib + +# where to build (temporary) +TARGDIR=../pd-cygwin + +# compiler stuff +INCLUDES=$(PDPATH)/src +LIBPATH=$(PDPATH)/bin +FLAGS=-DPD +CFLAGS=-O6 -mcpu=pentiumpro -funroll-loops -fmove-all-movables -frerun-loop-opt -finline-functions +LIBS=m pd + +# ---------------------------------------------- +# the rest can stay untouched +# ---------------------------------------------- + +NAME=xsample + +# all the source files from the package +SRCS=main.cpp inter.cpp play.cpp record.cpp groove.cpp +HDRS=main.h + +MAKEFILE=makefile.pd-cygwin +TARGET=$(TARGDIR)/$(NAME).dll + +# default target +all: $(TARGDIR) $(TARGET) + +$(SRCS): $(HDRS) $(MAKEFILE) + touch $@ + +$(TARGDIR): + mkdir $(TARGDIR) + +$(TARGDIR)/%.o : %.cpp + $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@ + +$(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) $(FLEXTLIB) + $(CXX) $(LDFLAGS) -shared $(patsubst %,-L%,$(LIBPATH)) $^ $(patsubst %,-l%,$(LIBS)) -o $@ + strip --strip-unneeded $@ + chmod 755 $@ + +$(INSTDIR): + mkdir $(INSTDIR) + +install:: $(INSTDIR) + +install:: $(TARGET) + cp $^ $(INSTDIR) + chown root.root $(patsubst %,$(INSTDIR)/%,$(notdir $^)) + +.PHONY: clean +clean: + rm -f $(TARGDIR)/*.o $(TARGET) + + + + + + + + + + + + diff --git a/externals/grill/xsample/source/makefile.pd-linux b/externals/grill/xsample/source/makefile.pd-linux new file mode 100644 index 00000000..863a0068 --- /dev/null +++ b/externals/grill/xsample/source/makefile.pd-linux @@ -0,0 +1,89 @@ +# xsample - extended sample objects for Max/MSP and pd (pure data) +# Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +# +# Makefile for gcc @ linux +# +# usage: +# to build run "make -f makefile.pd-linux" +# to install (as root), do "make -f makefile.pd-linux install" +# + +## EDIT ZONE ################################## + +# flext path +FLEXTPATH=/usr/local/lib/pd/flext + +# pd path +#PDPATH=/usr/local/lib/pd/include + +# where to install +INSTDIR=/usr/local/lib/pd/extra + +############################################### + +FLEXTLIB=$(FLEXTPATH)/flext.a + +# where to build (temporary) +TARGDIR=../pd-linux + +# compiler stuff +CXX=g++-3.2 +INCLUDES=$(PDPATH) +FLAGS=-DPD +CFLAGS=-O6 -mcpu=pentiumpro -funroll-loops -fmove-all-movables -frerun-loop-opt -finline-functions +LIBS=m + +# ---------------------------------------------- +# the rest can stay untouched +# ---------------------------------------------- + +NAME=xsample + +# all the source files from the package +SRCS=main.cpp inter.cpp play.cpp record.cpp groove.cpp +HDRS=main.h + +MAKEFILE=makefile.pd-linux +TARGET=$(TARGDIR)/$(NAME).pd_linux + +# default target +all: $(TARGDIR) $(TARGET) + +$(SRCS): $(HDRS) $(MAKEFILE) + touch $@ + +$(TARGDIR): + mkdir $(TARGDIR) + +$(TARGDIR)/%.o : %.cpp + $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@ + +$(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) $(FLEXTLIB) + $(CXX) $(LDFLAGS) -shared $^ $(patsubst %,-l%,$(LIBS)) -o $@ + strip --strip-unneeded $@ + chmod 755 $@ + +$(INSTDIR): + mkdir $(INSTDIR) + +install:: $(INSTDIR) + +install:: $(TARGET) + cp $^ $(INSTDIR) + chown root.root $(patsubst %,$(INSTDIR)/%,$(notdir $^)) + +.PHONY: clean +clean: + rm -f $(TARGDIR)/*.o $(TARGET) + + + + + + + + + + + + diff --git a/externals/grill/xsample/source/play.cpp b/externals/grill/xsample/source/play.cpp new file mode 100644 index 00000000..827d88de --- /dev/null +++ b/externals/grill/xsample/source/play.cpp @@ -0,0 +1,160 @@ +/* + +xsample - extended sample objects for Max/MSP and pd (pure data) + +Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "main.h" + +#ifdef _MSC_VER +#pragma warning (disable:4244) +#endif + + +class xplay: + public xinter +{ +// FLEXT_HEADER_S(xplay,xinter,setup) + FLEXT_HEADER(xplay,xinter) + +public: + xplay(I argc, t_atom *argv); + + virtual BL Init(); + +#ifdef MAXMSP + virtual V m_assist(L msg,L arg,C *s); +#endif + + virtual V m_help(); + virtual V m_print(); + +private: +// static V setup(t_class *c); + + virtual V m_signal(I n,S *const *in,S *const *out) + { + bufchk(); + playfun(n,in,out); + } +}; + +FLEXT_LIB_DSP_V("xplay~",xplay) + +/* +V xplay::setup(t_class *) +{ +#ifndef PD + post("loaded xplay~ - part of xsample objects, version " XSAMPLE_VERSION " - (C) Thomas Grill, 2001-2002"); +#endif +} +*/ + +xplay::xplay(I argc, t_atom *argv) +{ + I argi = 0; +#ifdef MAXMSP + if(argc > argi && CanbeInt(argv[argi])) { + outchns = GetAInt(argv[argi]); + argi++; + } +#endif + + if(argc > argi && IsSymbol(argv[argi])) { + buf = new buffer(GetSymbol(argv[argi]),true); + argi++; + +#ifdef MAXMSP + // oldstyle command line? + if(argi == 1 && argc == 2 && CanbeInt(argv[argi])) { + outchns = GetAInt(argv[argi]); + argi++; + post("%s: old style command line detected - please change to '%s [channels] [buffer]'",thisName(),thisName()); + } +#endif + } + else + buf = new buffer(NULL,true); + + AddInSignal(); // pos signal + AddOutSignal(outchns); + + m_reset(); +} + +BL xplay::Init() +{ + if(xinter::Init()) { + m_reset(); + return true; + } + else + return false; +} + + + +V xplay::m_help() +{ + post("%s - part of xsample objects, version " XSAMPLE_VERSION,thisName()); +#ifdef _DEBUG + post("compiled on " __DATE__ " " __TIME__); +#endif + post("(C) Thomas Grill, 2001-2002"); +#ifdef MAXMSP + post("Arguments: %s [channels=1] [buffer]",thisName()); +#else + post("Arguments: %s [buffer]",thisName()); +#endif + post("Inlets: 1:Messages/Position signal"); + post("Outlets: 1:Audio signal"); + post("Methods:"); + post("\thelp: shows this help"); + post("\tset name: set buffer"); + post("\tenable 0/1: turn dsp calculation off/on"); + post("\tprint: print current settings"); + post("\tbang/start: begin playing"); + post("\tstop: stop playing"); + post("\treset: checks buffer"); + post("\trefresh: checks buffer and refreshes outlets"); + post("\tunits 0/1/2/3: set units to samples/buffer size/ms/s"); + post("\tinterp 0/1/2: set interpolation to off/4-point/linear"); + post(""); +} + +V xplay::m_print() +{ + const C *interp_txt[] = {"off","4-point","linear"}; + // print all current settings + post("%s - current settings:",thisName()); + post("bufname = '%s', length = %.3f, channels = %i",buf->Name(),(F)(buf->Frames()*s2u),buf->Channels()); + post("out channels = %i, samples/unit = %.3f, interpolation = %s",outchns,(F)(1./s2u),interp_txt[interp >= xsi_none && interp <= xsi_lin?interp:xsi_none]); + post(""); +} + + +#ifdef MAXMSP +V xplay::m_assist(L msg,L arg,C *s) +{ + switch(msg) { + case 1: //ASSIST_INLET: + switch(arg) { + case 0: + sprintf(s,"Messages and Signal of playing position"); break; + } + break; + case 2: //ASSIST_OUTLET: + if(arg < outchns) + sprintf(s,"Audio signal channel %li",arg+1); + break; + } +} +#endif + + + + diff --git a/externals/grill/xsample/source/record.cpp b/externals/grill/xsample/source/record.cpp new file mode 100644 index 00000000..cc3543a3 --- /dev/null +++ b/externals/grill/xsample/source/record.cpp @@ -0,0 +1,506 @@ +/* + +xsample - extended sample objects for Max/MSP and pd (pure data) + +Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "main.h" + +#ifdef _MSC_VER +#pragma warning (disable:4244) +#endif + + +class xrecord: + public xsample +{ +// FLEXT_HEADER_S(xrecord,xsample,setup) + FLEXT_HEADER(xrecord,xsample) + +public: + xrecord(I argc,t_atom *argv); + + virtual BL Init(); + +#ifdef MAXMSP + virtual V m_assist(L msg,L arg,C *s); +#endif + + virtual V m_help(); + virtual V m_print(); + + virtual I m_set(I argc,t_atom *argv); + + virtual V m_pos(F pos); + virtual V m_all(); + virtual V m_start(); + virtual V m_stop(); + + virtual BL m_reset(); + + virtual V m_units(xs_unit md = xsu__); + virtual V m_min(F mn); + virtual V m_max(F mx); + + virtual V m_mixmode(BL mx) { mixmode = mx; } + virtual V m_sigmode(BL mode) { /*dorec =*/ sigmode = mode; } + virtual V m_loop(BL lp) { doloop = lp; } + virtual V m_append(BL app) { if(!(appmode = app)) m_pos(0); } + + virtual V m_draw(I argc,t_atom *argv); + +protected: + I inchns; + BL sigmode,appmode; + F drintv; + + BL dorec,doloop,mixmode; + L curpos; // in samples + + outlet *outmin,*outmax; // float outlets + + V outputmin() { ToOutFloat(outmin,curmin*s2u); } + V outputmax() { ToOutFloat(outmax,curmax*s2u); } + +private: +// static V setup(t_class *c); + + virtual V s_dsp(); + + TMPLSIGFUN(s_rec); + + DEFSIGCALL(recfun); + virtual V m_signal(I n,S *const *in,S *const *out) + { + bufchk(); + recfun(n,in,out); + } + + FLEXT_CALLBACK_F(m_pos) + FLEXT_CALLBACK(m_all) + FLEXT_CALLBACK_F(m_min) + FLEXT_CALLBACK_F(m_max) + + FLEXT_CALLBACK_B(m_loop) + FLEXT_CALLBACK_B(m_mixmode) + FLEXT_CALLBACK_B(m_sigmode) + FLEXT_CALLBACK_B(m_append) + + FLEXT_CALLBACK_V(m_draw) +}; + + +FLEXT_LIB_DSP_V("xrecord~",xrecord) + +/* +V xrecord::setup(t_class *) +{ +#ifndef PD + post("loaded xrecord~ - part of xsample objects, version " XSAMPLE_VERSION " - (C) Thomas Grill, 2001-2002"); +#endif +} +*/ + +xrecord::xrecord(I argc,t_atom *argv): + dorec(false), + sigmode(false),mixmode(false), + appmode(true),doloop(false), + drintv(0), + inchns(1) +{ + I argi = 0; +#ifdef MAXMSP + if(argc > argi && CanbeInt(argv[argi])) { + inchns = GetAInt(argv[argi]); + argi++; + } +#endif + + if(argc > argi && IsSymbol(argv[argi])) { + buf = new buffer(GetSymbol(argv[argi]),true); + argi++; + +#ifdef MAXMSP + // oldstyle command line? + if(argi == 1 && argc == 2 && CanbeInt(argv[argi])) { + inchns = GetAInt(argv[argi]); + argi++; + post("%s: old style command line detected - please change to '%s [channels] [buffer]'",thisName(),thisName()); + } +#endif + } + else + buf = new buffer(NULL,true); + + AddInSignal(inchns); // audio signals + AddInSignal(); // on/off signal + AddInFloat(2); // min & max + AddOutSignal(); // pos signal + AddOutFloat(2); // min & max + AddOutBang(); // loop bang + + FLEXT_ADDMETHOD_F(0,"pos",m_pos); + FLEXT_ADDMETHOD(inchns+1,m_min); + FLEXT_ADDMETHOD(inchns+2,m_max); + FLEXT_ADDMETHOD_F(0,"min",m_min); + FLEXT_ADDMETHOD_F(0,"max",m_max); + FLEXT_ADDMETHOD_(0,"all",m_all); + + FLEXT_ADDMETHOD_B(0,"loop",m_loop); + FLEXT_ADDMETHOD_B(0,"mixmode",m_mixmode); + FLEXT_ADDMETHOD_B(0,"sigmode",m_sigmode); + FLEXT_ADDMETHOD_B(0,"append",m_append); + + FLEXT_ADDMETHOD_(0,"draw",m_draw); +} + + +BL xrecord::Init() +{ + if(xsample::Init()) { + outmin = GetOut(1); + outmax = GetOut(2); + + m_reset(); + return true; + } + else + return false; +} + +V xrecord::m_units(xs_unit mode) +{ + xsample::m_units(mode); + + m_sclmode(); + outputmin(); + outputmax(); +} + +V xrecord::m_min(F mn) +{ + xsample::m_min(mn); + m_pos(curpos*s2u); + outputmin(); +} + +V xrecord::m_max(F mx) +{ + xsample::m_max(mx); + m_pos(curpos*s2u); + outputmax(); +} + +V xrecord::m_all() +{ + xsample::m_all(); + outputmin(); + outputmax(); +} + +V xrecord::m_pos(F pos) +{ + curpos = pos?(L)(pos/s2u+.5):0; + + if(curpos < curmin) curpos = curmin; + else if(curpos > curmax) curpos = curmax; +} + + +I xrecord::m_set(I argc,t_atom *argv) +{ + I r = xsample::m_set(argc,argv); + if(r < 0) m_reset(); // resets pos/min/max + if(r != 0) m_units(); + return r; +} + +V xrecord::m_start() +{ + if(!sigmode && !appmode) m_pos(0); + m_refresh(); + dorec = true; + buf->SetRefrIntv(drintv); + s_dsp(); +} + +V xrecord::m_stop() +{ + dorec = false; + buf->Dirty(true); + buf->SetRefrIntv(0); + s_dsp(); +} + +BL xrecord::m_reset() +{ + curpos = 0; + return xsample::m_reset(); +} + +V xrecord::m_draw(I argc,t_atom *argv) +{ + if(argc >= 1) { + drintv = GetInt(argv[0]); + if(dorec) buf->SetRefrIntv(drintv); + } + else + buf->Dirty(true); +} + + +TMPLDEF V xrecord::s_rec(I n,S *const *invecs,S *const *outvecs) +{ + SIGCHNS(BCHNS,buf->Channels(),ICHNS,inchns); + + const S *const *sig = invecs; + register I si = 0; + const S *on = invecs[inchns]; + S *pos = outvecs[0]; + + BL lpbang = false; + register const F pf = sclmul; + register L o = curpos; + + if(o < curmin) o = curmin; + +// if(buf && dorec && curlen > 0) { + if(buf && dorec && curmax > curmin) { + while(n) { + L ncur = curmax-o; // at max to buffer or recording end + + if(ncur <= 0) { // end of buffer + if(doloop) { + o = curmin; +// ncur = curlen; + ncur = curmax-o; + } + else + m_stop(); // loop expired; + + lpbang = true; + } + + if(!dorec) break; + + if(ncur > n) ncur = n; + + register I i; + register S *bf = buf->Data()+o*BCHNS; + register F p = scale(o); + + if(sigmode) { + if(appmode) { + // append to current position + + if(!mixmode) { + for(i = 0; i < ncur; ++i,++si) { + if(*(on++) >= 0) { + for(int ci = 0; ci < ICHNS; ++ci) + bf[ci] = sig[ci][si]; + bf += BCHNS; + *(pos++) = p,p += pf,++o; + } + else + *(pos++) = p; + } + } + else { + for(i = 0; i < ncur; ++i,++si) { + register const S g = *(on++); + if(g >= 0) { + for(int ci = 0; ci < ICHNS; ++ci) + bf[ci] = bf[ci]*(1.-g)+sig[ci][si]*g; + bf += BCHNS; + *(pos++) = p,p += pf,++o; + } + else + *(pos++) = p; + } + } + } + else { + // don't append + if(!mixmode) { + for(i = 0; i < ncur; ++i,++si) { + if(*(on++) >= 0) + { + for(int ci = 0; ci < ICHNS; ++ci) + bf[ci] = sig[ci][si]; + bf += BCHNS; + *(pos++) = p,p += pf,++o; + } + else { + *(pos++) = p = scale(o = 0); + bf = buf->Data(); + } + } + } + else { + for(i = 0; i < ncur; ++i,++si) { + register const S g = *(on++); + if(g >= 0) { + for(int ci = 0; ci < ICHNS; ++ci) + bf[ci] = bf[ci]*(1.-g)+sig[ci][si]*g; + bf += BCHNS; + *(pos++) = p,p += pf,++o; + } + else { + *(pos++) = p = scale(o = 0); + bf = buf->Data(); + } + } + } + } + } + else { + // message mode + + // Altivec optimization for that! + if(!mixmode) { + for(int ci = 0; ci < ICHNS; ++ci) { + register S *b = bf+ci; + register const F *s = sig[ci]; + for(i = 0; i < ncur; ++i,b += BCHNS,++s) *b = *s; + } + si += ncur; + } + else { + for(i = 0; i < ncur; ++i,++si) { + register const S w = *(on++); + for(int ci = 0; ci < ICHNS; ++ci) + bf[ci] = bf[ci]*(1.-w)+sig[ci][si]*w; + bf += BCHNS; + } + } + for(i = 0; i < ncur; ++i) { + *(pos++) = p,p += pf,++o; + } + } + + n -= ncur; + } + curpos = o; + + buf->Dirty(); + } + + if(n) { + register F p = scale(o); + while(n--) *(pos++) = p; + } + + if(lpbang) ToOutBang(3); +} + +V xrecord::s_dsp() +{ + switch(buf->Channels()*1000+inchns) { + case 1001: SETSIGFUN(recfun,TMPLFUN(s_rec,1,1)); break; + case 1002: SETSIGFUN(recfun,TMPLFUN(s_rec,1,2)); break; + case 2001: SETSIGFUN(recfun,TMPLFUN(s_rec,2,1)); break; + case 2002: SETSIGFUN(recfun,TMPLFUN(s_rec,2,2)); break; + case 4001: + case 4002: + case 4003: SETSIGFUN(recfun,TMPLFUN(s_rec,4,-1)); break; + case 4004: SETSIGFUN(recfun,TMPLFUN(s_rec,4,4)); break; + default: SETSIGFUN(recfun,TMPLFUN(s_rec,-1,-1)); break; + } +} + + + + +V xrecord::m_help() +{ + post("%s - part of xsample objects, version " XSAMPLE_VERSION,thisName()); +#ifdef _DEBUG + post("compiled on " __DATE__ " " __TIME__); +#endif + post("(C) Thomas Grill, 2001-2002"); +#ifdef MAXMSP + post("Arguments: %s [channels=1] [buffer]",thisName()); +#else + post("Arguments: %s [buffer]",thisName()); +#endif + post("Inlets: 1:Messages/Audio signal, 2:Trigger signal, 3:Min point, 4: Max point"); + post("Outlets: 1:Position signal, 2:Min point, 3:Max point"); + post("Methods:"); + post("\thelp: shows this help"); + post("\tset [name]: set buffer or reinit"); + post("\tenable 0/1: turn dsp calculation off/on"); + post("\treset: reset min/max recording points and recording offset"); + post("\tprint: print current settings"); + post("\tsigmode 0/1: specify message or signal triggered recording"); + post("\tappend 0/1: reset recording position or append to current position"); + post("\tloop 0/1: switches looping off/on"); + post("\tmixmode 0/1: specify if audio signal should be mixed in"); + post("\tmin {unit}: set minimum recording point"); + post("\tmax {unit}: set maximum recording point"); + post("\tall: select entire buffer length"); + post("\tpos {unit}: set recording position (obeying the current scale mode)"); + post("\tbang/start: start recording"); + post("\tstop: stop recording"); + post("\trefresh: checks buffer and refreshes outlets"); + post("\tunits 0/1/2/3: set units to frames/buffer size/ms/s"); + post("\tsclmode 0/1/2/3: set range of position to units/units in loop/buffer/loop"); + post("\tdraw [{float}]: redraw buffer immediately (arg omitted) or periodic (in ms)"); + post(""); +} + +V xrecord::m_print() +{ + static const C sclmode_txt[][20] = {"units","units in loop","buffer","loop"}; + + // print all current settings + post("%s - current settings:",thisName()); + post("bufname = '%s', length = %.3f, channels = %i",buf->Name(),(F)(buf->Frames()*s2u),buf->Channels()); + post("in channels = %i, frames/unit = %.3f, scale mode = %s",inchns,(F)(1./s2u),sclmode_txt[sclmode]); + post("sigmode = %s, append = %s, loop = %s, mixmode = %s",sigmode?"yes":"no",appmode?"yes":"no",doloop?"yes":"no",mixmode?"yes":"no"); + post(""); +} + + +#ifdef MAXMSP +V xrecord::m_assist(L msg,L arg,C *s) +{ + switch(msg) { + case 1: //ASSIST_INLET: + if(arg < inchns) { + if(arg) + sprintf(s,"Messages and Audio channel 1"); + else + sprintf(s,"Audio channel %li",arg+1); + } + else + switch(arg-inchns) { + case 0: + sprintf(s,"On/Off/Fade/Mix signal (0..1)"); break; + case 1: + sprintf(s,"Starting point of recording"); break; + case 2: + sprintf(s,"Ending point of recording"); break; + } + break; + case 2: //ASSIST_OUTLET: + switch(arg) { + case 0: + sprintf(s,"Current position of recording"); break; + case 1: + sprintf(s,"Starting point (rounded to frame)"); break; + case 2: + sprintf(s,"Ending point (rounded to frame)"); break; + case 3: + sprintf(s,"Bang on loop end/rollover"); break; + } + break; + } +} +#endif + + + diff --git a/externals/grill/xsample/source/xsample.cw b/externals/grill/xsample/source/xsample.cw new file mode 100644 index 00000000..c9e91616 Binary files /dev/null and b/externals/grill/xsample/source/xsample.cw differ diff --git a/externals/grill/xsample/source/xsample.dsp b/externals/grill/xsample/source/xsample.dsp new file mode 100644 index 00000000..6c97b49e --- /dev/null +++ b/externals/grill/xsample/source/xsample.dsp @@ -0,0 +1,127 @@ +# Microsoft Developer Studio Project File - Name="xsample" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=xsample - Win32 Debug +!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "xsample.mak". +!MESSAGE +!MESSAGE Sie knnen beim Ausfhren von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "xsample.mak" CFG="xsample - Win32 Debug" +!MESSAGE +!MESSAGE Fr die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "xsample - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "xsample - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "xsample" +# PROP Scc_LocalPath ".." +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "xsample - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\msvc" +# PROP Intermediate_Dir "..\msvc" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XSAMPLE_EXPORTS" /YX /FD /c +# ADD CPP /nologo /G6 /W3 /O2 /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext\source" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib /nologo /dll /machine:I386 /libpath:"c:\programme\audio\pd\bin" /libpath:"..\..\flext\pd-msvc\\" + +!ELSEIF "$(CFG)" == "xsample - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\msvc-debug" +# PROP Intermediate_Dir "..\msvc-debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XSAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /G6 /W3 /Gm /ZI /Od /I "c:\programme\audio\pd\src" /I "f:\prog\max\flext\source" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "_DEBUG" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib pd.lib flext_d-pdwin.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:\programme\audio\pd\bin\\" /libpath:"..\..\flext\pd-msvc\\" + +!ENDIF + +# Begin Target + +# Name "xsample - Win32 Release" +# Name "xsample - Win32 Debug" +# Begin Group "doc" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\readme.txt +# End Source File +# End Group +# Begin Source File + +SOURCE=.\groove.cpp +# End Source File +# Begin Source File + +SOURCE=.\inter.ci +# End Source File +# Begin Source File + +SOURCE=.\inter.cpp +# End Source File +# Begin Source File + +SOURCE=.\main.cpp +# End Source File +# Begin Source File + +SOURCE=.\main.h +# End Source File +# Begin Source File + +SOURCE=.\play.cpp +# End Source File +# Begin Source File + +SOURCE=.\record.cpp +# End Source File +# End Target +# End Project diff --git a/externals/grill/xsample/source/xsample.mpw b/externals/grill/xsample/source/xsample.mpw new file mode 100644 index 00000000..9e6b625e --- /dev/null +++ b/externals/grill/xsample/source/xsample.mpw @@ -0,0 +1,129 @@ +# xsample - extended sample objects for Max/MSP and pd (pure data) +# Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net) +# +# Makefile for Apple MPW-PR +# +# usage: make -f xsample.mpw +# +# --------------------------------------------- + +MAKEFILE = xsample.mpw +MondoBuild = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified + +ObjDir = ::MPW: +MaxSDK = HD Daten:Prog Stuff:Max/MSP SDK:SDK Examples +flext = :::flext: +Includes = -i :,"{flext}","{MaxSDK}:Max Includes","{MaxSDK}:MSP Includes" +Defines = -d MAXMSP + +Sym-PPC = -sym off +Flags = -bool on -enum int -includes unix -opt speed,unroll,unswitch +WarnOff = -w 35 + +PPCCPlusOptions = {Includes} {Sym-PPC} {Defines} {Flags} {WarnOff} + + +### Source Files ### + +SrcFiles = main.cpp inter.cpp groove.cpp play.cpp record.cpp +Headers = main.h + +### Object Files ### + +Obj-groove = + "{ObjDir}main.cpp.x" + "{ObjDir}inter.cpp.x" + "{ObjDir}groove.cpp.x" + +Obj-play = + "{ObjDir}main.cpp.x" + "{ObjDir}inter.cpp.x" + "{ObjDir}play.cpp.x" + +Obj-record = + "{ObjDir}main.cpp.x" + "{ObjDir}inter.cpp.x" + "{ObjDir}record.cpp.x" + +Obj = + "{ObjDir}main.cpp.x" + "{ObjDir}record.cpp.x" + "{ObjDir}play.cpp.x" + "{ObjDir}inter.cpp.x" + "{ObjDir}groove.cpp.x" + + +### Libraries ### + +LibFiles-Ext = + "{flext}MPW:flext.o" + "{MaxSDK}:Max Includes:MaxLib" + "{MaxSDK}:MSP Includes:MaxAudioLib" + +LibFiles-PPC = + "{SharedLibraries}StdCLib" + "{SharedLibraries}MathLib" + "{PPCLibraries}StdCRuntime.o" + "{PPCLibraries}PPCCRuntime.o" + "{PPCLibraries}MrCPlusLib.o" + + +### Default Rules ### + +{ObjDir} : + +.cpp.x .cpp {MondoBuild} {Headers} + {PPCCPlus} {depDir}{default}.cpp -o {targDir}{default}.cpp.x {PPCCPlusOptions} + + +### Build Rules ### + +all Folder {ObjDir}xsample +single Folder {ObjDir}xgroove~ {ObjDir}xplay~ {ObjDir}xrecord~ + +Folder + if !`Exists {ObjDir}` ; NewFolder {ObjDir} ; end + +{ObjDir}xgroove~ {Obj-groove} {LibFiles-Ext} + PPCLink + -o {Targ} + {deps} + {LibFiles-PPC} + {Sym-PPC} + -mf -d + -t 'iLaF' -c 'max2' + -xm s + -export main -main main + +{ObjDir}xplay~ {Obj-play} {LibFiles-Ext} + PPCLink + -o {Targ} + {deps} + {LibFiles-PPC} + {Sym-PPC} + -mf -d + -t 'iLaF' -c 'max2' + -xm s + -export main -main main + +{ObjDir}xrecord~ {Obj-record} {LibFiles-Ext} + PPCLink + -o {Targ} + {deps} + {LibFiles-PPC} + {Sym-PPC} + -mf -d + -t 'iLaF' -c 'max2' + -xm s + -export main -main main + +{ObjDir}xsample {Obj} {LibFiles-Ext} + PPCLink + -o {Targ} + {deps} + {LibFiles-PPC} + {Sym-PPC} + -mf -d + -t 'iLaF' -c 'max2' + -xm s + -export main -main main -- cgit v1.2.1