From e728a5bc3db296b4b67c2d3e5b56558c42c566a8 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Mon, 21 Jun 2004 14:08:57 +0000 Subject: "" svn path=/trunk/; revision=1826 --- externals/grill/deljoin/deljoin.vcproj | 2 +- externals/grill/delsplit/delsplit.vcproj | 2 +- externals/grill/dyn/dyn.vcproj | 2 +- externals/grill/dyn/readme.txt | 3 + externals/grill/dyn/src/main.cpp | 19 +- externals/grill/flext/changes.txt | 6 + externals/grill/flext/flext.cw | Bin 935395 -> 935395 bytes externals/grill/flext/makefile.pd-mingw | 2 +- externals/grill/flext/source/flatom_app.cpp | 80 +- externals/grill/flext/source/flatom_part.cpp | 18 +- externals/grill/flext/source/flatom_pr.cpp | 132 +- externals/grill/flext/source/flattr_ed.cpp | 980 ++++++------- externals/grill/flext/source/flbase.cpp | 108 +- externals/grill/flext/source/flbase.h | 8 + externals/grill/flext/source/flbind.cpp | 56 +- externals/grill/flext/source/flbuf.cpp | 362 ++--- externals/grill/flext/source/flcwmax-thr.h | 8 +- externals/grill/flext/source/flcwmax-x-thr.h | 8 +- externals/grill/flext/source/flcwmax.h | 8 +- externals/grill/flext/source/flcwpd-x-thr.h | 8 +- externals/grill/flext/source/flcwpd-x.h | 8 +- externals/grill/flext/source/fldefs.h | 20 +- externals/grill/flext/source/fldefs_attradd.h | 46 +- externals/grill/flext/source/fldefs_attrcb.h | 16 +- externals/grill/flext/source/fldefs_attrvar.h | 16 +- externals/grill/flext/source/fldefs_methadd.h | 48 +- externals/grill/flext/source/fldefs_methcall.h | 4 +- externals/grill/flext/source/fldefs_methcb.h | 6 +- externals/grill/flext/source/fldefs_setup.h | 114 +- externals/grill/flext/source/fldoxygen.h | 56 +- externals/grill/flext/source/fldsp.cpp | 160 +- externals/grill/flext/source/flext.cpp | 206 +-- externals/grill/flext/source/flext.h | 4 +- externals/grill/flext/source/flinternal.h | 6 +- externals/grill/flext/source/flitem.cpp | 62 +- externals/grill/flext/source/fllib.cpp | 166 ++- externals/grill/flext/source/flmeth.cpp | 146 +- externals/grill/flext/source/flmsg.cpp | 374 ++--- externals/grill/flext/source/flmspbuffer.h | 102 +- externals/grill/flext/source/flout.cpp | 584 ++++---- externals/grill/flext/source/flprefix.h | 484 +++--- externals/grill/flext/source/flproxy.cpp | 112 +- externals/grill/flext/source/flqueue.cpp | 352 ++--- externals/grill/flext/source/flsimd.cpp | 1861 ++++++++++++------------ externals/grill/flext/source/flsndobj.cpp | 142 +- externals/grill/flext/source/flsndobj.h | 106 +- externals/grill/flext/source/flstdc.h | 5 + externals/grill/flext/source/flstk.cpp | 120 +- externals/grill/flext/source/flstk.h | 94 +- externals/grill/flext/source/flsupport.h | 16 +- externals/grill/flext/source/fltimer.cpp | 202 +-- externals/grill/flext/source/flutil.cpp | 26 +- externals/grill/flext/source/flxlet.cpp | 92 +- externals/grill/pool/config-pd-darwin.txt | 3 + externals/grill/pool/config-pd-mingw.txt | 1 - externals/grill/pool/makefile.pd-darwin | 27 +- externals/grill/pool/makefile.pd-mingw | 9 - externals/grill/pool/pool.cw | Bin 202236 -> 202236 bytes externals/grill/pool/pool.help | Bin 6369 -> 6360 bytes externals/grill/pool/pool.vcproj | 4 +- externals/grill/pool/source/pool.cpp | 12 +- externals/grill/pool/source/pool.h | 4 +- externals/grill/py/pd/attr-1.pd | 66 +- externals/grill/py/pd/script-1.pd | 52 +- externals/grill/py/pd/sendrecv-1.pd | 54 +- externals/grill/py/pd/sendrecv-2.pd | 20 +- externals/grill/py/pd/sendrecv-3.pd | 14 +- externals/grill/py/pd/simple-1.pd | 14 +- externals/grill/py/pd/simple-2.pd | 76 +- externals/grill/py/pd/simple-3.pd | 56 +- externals/grill/py/pd/thread-1.pd | 52 +- externals/grill/py/py.vcproj | 6 +- externals/grill/py/readme.txt | 6 + externals/grill/py/source/bound.cpp | 10 +- externals/grill/py/source/clmeth.cpp | 4 +- externals/grill/py/source/main.cpp | 159 +- externals/grill/py/source/main.h | 26 +- externals/grill/py/source/modmeth.cpp | 10 +- externals/grill/py/source/py.cpp | 4 +- externals/grill/py/source/pyargs.cpp | 12 +- externals/grill/py/source/pyext.cpp | 115 +- externals/grill/py/source/pyext.h | 5 +- externals/grill/vasp/source/buflib.cpp | 26 +- externals/grill/vst/src/VstHost.cpp | 11 +- externals/grill/xsample/maxmsp/xsample.help | Bin 18871 -> 18907 bytes externals/grill/xsample/pd/xgroove~.pd | 77 +- externals/grill/xsample/pd/xrecord~.pd | 158 +- externals/grill/xsample/readme.txt | 7 + externals/grill/xsample/source/groove.cpp | 67 +- externals/grill/xsample/source/main.cpp | 98 +- externals/grill/xsample/source/main.h | 2 +- externals/grill/xsample/xsample.cw | Bin 399047 -> 399047 bytes 92 files changed, 4497 insertions(+), 4338 deletions(-) (limited to 'externals') diff --git a/externals/grill/deljoin/deljoin.vcproj b/externals/grill/deljoin/deljoin.vcproj index 5b2a49ad..68204c3a 100644 --- a/externals/grill/deljoin/deljoin.vcproj +++ b/externals/grill/deljoin/deljoin.vcproj @@ -41,7 +41,7 @@ Name="VCCustomBuildTool"/> -#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 405) -#error You need at least flext version 0.4.5 +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 406) +#error You need at least flext version 0.4.6 #endif -#define DYN_VERSION "0.1.0" +#define DYN_VERSION "0.1.1pre" #if FLEXT_SYS != FLEXT_SYS_PD @@ -96,7 +96,7 @@ protected: void init(dyn *t); - static void px_exit(proxy *px) { if(px->buf) delete[] px->buf; } + static void px_exit(proxy *px) { if(px->buf) FreeAligned(px->buf); } }; // proxy for inbound messages @@ -685,14 +685,13 @@ void dyn::proxy::init(dyn *t) defsig = 0; } - void dyn::proxyin::dsp(proxyin *x,t_signal **sp) { int n = sp[0]->s_n; if(n != x->n) { // if vector size has changed make new buffer - if(x->buf) delete[] x->buf; - x->buf = new t_sample[x->n = n]; + if(x->buf) FreeAligned(x->buf); + x->buf = (t_sample *)NewAligned(sizeof(t_sample)*(x->n = n)); } dsp_add_copy(x->buf,sp[0]->s_vec,n); } @@ -711,8 +710,8 @@ void dyn::proxyout::dsp(proxyout *x,t_signal **sp) int n = sp[0]->s_n; if(n != x->n) { // if vector size has changed make new buffer - if(x->buf) delete[] x->buf; - x->buf = new t_sample[x->n = n]; + if(x->buf) FreeAligned(x->buf); + x->buf = (t_sample *)NewAligned(sizeof(t_sample)*(x->n = n)); } dsp_add_copy(sp[0]->s_vec,x->buf,n); } diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt index 8a9aad20..7e655b85 100644 --- a/externals/grill/flext/changes.txt +++ b/externals/grill/flext/changes.txt @@ -13,6 +13,12 @@ Donations for further development of the package are highly appreciated. Version history: +0.4.7: +- added flext::GetBool (just because flext::GetInt has been there for a while) +- added bool to usable types for creation arguments +- protection for SIMD routines with count=0 +- support exceptions for setup functions, object creation and destruction, method handling + 0.4.6: - added a text edit window for list attributes - finally use global allocator operators (MFC doesn't like it but who cares) diff --git a/externals/grill/flext/flext.cw b/externals/grill/flext/flext.cw index c5dcdac9..b2eddac3 100644 Binary files a/externals/grill/flext/flext.cw and b/externals/grill/flext/flext.cw differ diff --git a/externals/grill/flext/makefile.pd-mingw b/externals/grill/flext/makefile.pd-mingw index ac62dda1..15a02734 100644 --- a/externals/grill/flext/makefile.pd-mingw +++ b/externals/grill/flext/makefile.pd-mingw @@ -58,7 +58,7 @@ TARGET_TD=$(TARGDIR)/$(NAME)_td-pdwin.lib TARGET_S=$(TARGDIR)/$(NAME).dll TARGET_SD=$(TARGDIR)/$(NAME)_d.dll -TARGETS=$(TARGET) $(TARGET_D) $(TARGET_T) $(TARGET_TD) $(TARGET_S) $(TARGET_SD) +TARGETS=$(TARGET) $(TARGET_D) # $(TARGET_T) $(TARGET_TD) $(TARGET_S) $(TARGET_SD) all: $(TARGDIR) $(TARGETS) diff --git a/externals/grill/flext/source/flatom_app.cpp b/externals/grill/flext/source/flatom_app.cpp index 90b4af82..96fe010d 100755 --- a/externals/grill/flext/source/flatom_app.cpp +++ b/externals/grill/flext/source/flatom_app.cpp @@ -17,60 +17,60 @@ WARRANTIES, see the file, "license.txt," in this distribution. flext::AtomList &flext::AtomList::Append(const t_atom &a) { - t_atom *nlst = new t_atom[cnt+1]; - for(int i = 0; i < cnt; ++i) SetAtom(nlst[i],lst[i]); - SetAtom(nlst[cnt],a); - - if(lst) delete[] lst; - lst = nlst; - ++cnt; + t_atom *nlst = new t_atom[cnt+1]; + for(int i = 0; i < cnt; ++i) SetAtom(nlst[i],lst[i]); + SetAtom(nlst[cnt],a); + + if(lst) delete[] lst; + lst = nlst; + ++cnt; - return *this; + return *this; } flext::AtomList &flext::AtomList::Append(int argc,const t_atom *argv) { - if(argc) { - t_atom *nlst = new t_atom[cnt+argc]; - int i; - for(i = 0; i < cnt; ++i) SetAtom(nlst[i],lst[i]); - if(argv) - for(i = 0; i < argc; ++i) SetAtom(nlst[cnt+i],argv[i]); - - if(lst) delete[] lst; - lst = nlst; - cnt += argc; - } - return *this; + if(argc) { + t_atom *nlst = new t_atom[cnt+argc]; + int i; + for(i = 0; i < cnt; ++i) SetAtom(nlst[i],lst[i]); + if(argv) + for(i = 0; i < argc; ++i) SetAtom(nlst[cnt+i],argv[i]); + + if(lst) delete[] lst; + lst = nlst; + cnt += argc; + } + return *this; } flext::AtomList &flext::AtomList::Prepend(const t_atom &a) { - t_atom *nlst = new t_atom[cnt+1]; - for(int i = 0; i < cnt; ++i) SetAtom(nlst[i+1],lst[i]); - SetAtom(nlst[0],a); - - if(lst) delete[] lst; - lst = nlst; - ++cnt; + t_atom *nlst = new t_atom[cnt+1]; + for(int i = 0; i < cnt; ++i) SetAtom(nlst[i+1],lst[i]); + SetAtom(nlst[0],a); + + if(lst) delete[] lst; + lst = nlst; + ++cnt; - return *this; + return *this; } flext::AtomList &flext::AtomList::Prepend(int argc,const t_atom *argv) { - if(argc) { - t_atom *nlst = new t_atom[cnt+argc]; - int i; + if(argc) { + t_atom *nlst = new t_atom[cnt+argc]; + int i; - if(argv) - for(i = 0; i < argc; ++i) SetAtom(nlst[i],argv[i]); - for(i = 0; i < cnt; ++i) SetAtom(nlst[argc+i],lst[i]); - - if(lst) delete[] lst; - lst = nlst; - cnt += argc; - } - return *this; + if(argv) + for(i = 0; i < argc; ++i) SetAtom(nlst[i],argv[i]); + for(i = 0; i < cnt; ++i) SetAtom(nlst[argc+i],lst[i]); + + if(lst) delete[] lst; + lst = nlst; + cnt += argc; + } + return *this; } diff --git a/externals/grill/flext/source/flatom_part.cpp b/externals/grill/flext/source/flatom_part.cpp index 05a3710d..e5c9c533 100755 --- a/externals/grill/flext/source/flatom_part.cpp +++ b/externals/grill/flext/source/flatom_part.cpp @@ -16,22 +16,22 @@ WARRANTIES, see the file, "license.txt," in this distribution. int flext::AtomList::Get(t_atom *argv,int mxsz) const { - int argc = Count(); - if(mxsz >= 0 && argc > mxsz) argc = mxsz; + int argc = Count(); + if(mxsz >= 0 && argc > mxsz) argc = mxsz; - for(int i = 0; i < argc; ++i) SetAtom(argv[i],lst[i]); + for(int i = 0; i < argc; ++i) SetAtom(argv[i],lst[i]); - return argc; + return argc; } flext::AtomList flext::AtomList::GetPart(int offs,int len) const { - if(offs+len > Count()) { - len = Count()-offs; - if(len < 0) len = 0; - } + if(offs+len > Count()) { + len = Count()-offs; + if(len < 0) len = 0; + } - return AtomList(len,Atoms()+offs); + return AtomList(len,Atoms()+offs); } diff --git a/externals/grill/flext/source/flatom_pr.cpp b/externals/grill/flext/source/flatom_pr.cpp index 9d5eeb29..43721388 100644 --- a/externals/grill/flext/source/flatom_pr.cpp +++ b/externals/grill/flext/source/flatom_pr.cpp @@ -25,95 +25,95 @@ WARRANTIES, see the file, "license.txt," in this distribution. // \TODO take bufsz into account! bool flext::PrintAtom(const t_atom &a,char *buf,int bufsz) { - bool ok = true; - if(IsFloat(a)) { - STD::snprintf(buf,bufsz,"%g",GetFloat(a)); - } - else if(IsInt(a)) { - STD::snprintf(buf,bufsz,"%i",GetInt(a)); - } - else if(IsSymbol(a)) { + bool ok = true; + if(IsFloat(a)) { + STD::snprintf(buf,bufsz,"%g",GetFloat(a)); + } + else if(IsInt(a)) { + STD::snprintf(buf,bufsz,"%i",GetInt(a)); + } + else if(IsSymbol(a)) { if(!FLEXT_ASSERT(GetSymbol(a))) *buf = 0; else STD::strncpy(buf,GetString(a),bufsz); - } - else if(IsPointer(a)) { - STD::snprintf(buf,bufsz,"%p",GetPointer(a)); - } + } + else if(IsPointer(a)) { + STD::snprintf(buf,bufsz,"%p",GetPointer(a)); + } #if FLEXT_SYS == FLEXT_SYS_PD - else if(a.a_type == A_DOLLAR) { - STD::snprintf(buf,bufsz,"$%d",a.a_w.w_index); - } - else if(a.a_type == A_DOLLSYM) { - STD::snprintf(buf,bufsz,"$%s",GetString(a)); - } + else if(a.a_type == A_DOLLAR) { + STD::snprintf(buf,bufsz,"$%d",a.a_w.w_index); + } + else if(a.a_type == A_DOLLSYM) { + STD::snprintf(buf,bufsz,"$%s",GetString(a)); + } #elif FLEXT_SYS == FLEXT_SYS_MAX - else if(a.a_type == A_DOLLAR) { - STD::snprintf(buf,bufsz,"$%d",a.a_w.w_long); - } + else if(a.a_type == A_DOLLAR) { + STD::snprintf(buf,bufsz,"$%d",a.a_w.w_long); + } #else //#pragma message("Not implemented") #endif - else { + else { error("flext: atom type unknown"); - ok = false; - } - return ok; + ok = false; + } + return ok; } bool flext::PrintList(int argc,const t_atom *argv,char *buf,int bufsz) { - bool ok = true; + bool ok = true; for(int i = 0; ok && i < argc && bufsz > 0; ++i) { - if(i) { *(buf++) = ' '; --bufsz; } // prepend space - - if(PrintAtom(argv[i],buf,bufsz)) { - int len = strlen(buf); - buf += len,bufsz -= len; - } - else - ok = false; + if(i) { *(buf++) = ' '; --bufsz; } // prepend space + + if(PrintAtom(argv[i],buf,bufsz)) { + int len = strlen(buf); + buf += len,bufsz -= len; + } + else + ok = false; } - *buf = 0; + *buf = 0; return ok; } bool flext::ScanAtom(t_atom &a,const char *buf) { - // skip whitespace - while(*buf && isspace(*buf)) ++buf; - if(!*buf) return false; - - char tmp[1024]; - strcpy(tmp,buf); - char *c = tmp; - - // check for word type (s = 0,1,2 ... int,float,symbol) - int s = 0; - for(; *c && !isspace(*c); ++c) { - if(!isdigit(*c)) - s = (*c != '.' || s == 1)?2:1; - } - - switch(s) { - case 0: // integer + // skip whitespace + while(*buf && isspace(*buf)) ++buf; + if(!*buf) return false; + + char tmp[1024]; + strcpy(tmp,buf); + char *c = tmp; + + // check for word type (s = 0,1,2 ... int,float,symbol) + int s = 0; + for(; *c && !isspace(*c); ++c) { + if(!isdigit(*c)) + s = (*c != '.' || s == 1)?2:1; + } + + switch(s) { + case 0: // integer #if FLEXT_SYS == FLEXT_SYS_MAX - SetInt(a,atol(tmp)); - break; + SetInt(a,atol(tmp)); + break; #endif - case 1: // float - SetFloat(a,(float)atof(tmp)); - break; - default: { // anything else is a symbol - char t = *c; *c = 0; - SetString(a,tmp); - *c = t; - break; - } - } - - return true; + case 1: // float + SetFloat(a,(float)atof(tmp)); + break; + default: { // anything else is a symbol + char t = *c; *c = 0; + SetString(a,tmp); + *c = t; + break; + } + } + + return true; } diff --git a/externals/grill/flext/source/flattr_ed.cpp b/externals/grill/flext/source/flattr_ed.cpp index 797eec19..8a4b98f5 100644 --- a/externals/grill/flext/source/flattr_ed.cpp +++ b/externals/grill/flext/source/flattr_ed.cpp @@ -45,18 +45,18 @@ static void (*ori_vis)(t_gobj *c, t_glist *, int vis) = NULL; void flext_base::SetAttrEditor(t_classid c) { - // widgetbehavior struct MUST be resident... (static is just ok here) + // widgetbehavior struct MUST be resident... (static is just ok here) #ifndef FLEXT_CLONEWIDGET - ori_vis = c->c_wb->w_visfn; - widgetbehavior.w_getrectfn = c->c_wb->w_getrectfn; + ori_vis = c->c_wb->w_visfn; + widgetbehavior.w_getrectfn = c->c_wb->w_getrectfn; widgetbehavior.w_displacefn = c->c_wb->w_displacefn; widgetbehavior.w_selectfn = c->c_wb->w_selectfn; widgetbehavior.w_activatefn = c->c_wb->w_activatefn; widgetbehavior.w_deletefn = c->c_wb->w_deletefn; widgetbehavior.w_clickfn = c->c_wb->w_clickfn; #else - widgetbehavior.w_getrectfn = text_widgetbehavior.w_getrectfn; + widgetbehavior.w_getrectfn = text_widgetbehavior.w_getrectfn; widgetbehavior.w_displacefn = text_widgetbehavior.w_displacefn; widgetbehavior.w_selectfn = text_widgetbehavior.w_selectfn; widgetbehavior.w_activatefn = text_widgetbehavior.w_activatefn; @@ -75,80 +75,80 @@ void flext_base::SetAttrEditor(t_classid c) widgetbehavior.w_visfn = cb_GfxVis; class_setwidget(c, &widgetbehavior); - // generate the script for the property dialog + // generate the script for the property dialog - sys_gui( - "proc flext_apply {id alen} {\n" - // strip "." from the TK id to make a variable name suffix - "set vid [string trimleft $id .]\n" + sys_gui( + "proc flext_apply {id alen} {\n" + // strip "." from the TK id to make a variable name suffix + "set vid [string trimleft $id .]\n" - // make a list of the attribute values (including save flags) + // make a list of the attribute values (including save flags) - "set lst {}\n" - "for {set ix 1} {$ix <= $alen} {incr ix} {\n" - "set var_attr_name [concat [concat var_name_$ix]_$vid ]\n" - "set var_attr_init [concat [concat var_init_$ix]_$vid ]\n" - "set var_attr_val [concat [concat var_val_$ix]_$vid ]\n" - "set var_attr_save [concat [concat var_save_$ix]_$vid ]\n" - "set var_attr_type [concat [concat var_type_$ix]_$vid ]\n" + "set lst {}\n" + "for {set ix 1} {$ix <= $alen} {incr ix} {\n" + "set var_attr_name [concat [concat var_name_$ix]_$vid ]\n" + "set var_attr_init [concat [concat var_init_$ix]_$vid ]\n" + "set var_attr_val [concat [concat var_val_$ix]_$vid ]\n" + "set var_attr_save [concat [concat var_save_$ix]_$vid ]\n" + "set var_attr_type [concat [concat var_type_$ix]_$vid ]\n" - "global $var_attr_name $var_attr_init $var_attr_val $var_attr_save $var_attr_type\n" - - "if { [expr $$var_attr_type] != 0 } {\n" - // attribute is puttable + "global $var_attr_name $var_attr_init $var_attr_val $var_attr_save $var_attr_type\n" + + "if { [expr $$var_attr_type] != 0 } {\n" + // attribute is puttable - "lappend lst [eval concat $$var_attr_name]\n" + "lappend lst [eval concat $$var_attr_name]\n" - // process current value + // process current value "set tmp [eval concat $$var_attr_val]\n" - "set len [llength $tmp]\n" - "if { $len == 1 } {\n" - // it's an atom + "set len [llength $tmp]\n" + "if { $len == 1 } {\n" + // it's an atom // if atom starts with $, replace it by # ($ can't be passed by TCL) "if { [string index $tmp 0] == \"$\" } {\n" "set tmp [string replace $tmp 0 0 #]\n" "}\n" "lappend lst $tmp\n" - "} else {\n" - // it's a list - "set lst [concat $lst {list} $len $tmp]\n" - "}\n" - - // process init value - "set tmp [eval concat $$var_attr_init]\n" - "set len [llength $tmp]\n" - "if { $len == 1 } {\n" - // it's an atom + "} else {\n" + // it's a list + "set lst [concat $lst {list} $len $tmp]\n" + "}\n" + + // process init value + "set tmp [eval concat $$var_attr_init]\n" + "set len [llength $tmp]\n" + "if { $len == 1 } {\n" + // it's an atom // if atom starts with $, replace it by # ($ can't be passed by TCL) "if { [string index $tmp 0] == \"$\" } {\n" "set tmp [string replace $tmp 0 0 #]\n" "}\n" "lappend lst $tmp\n" - "} else {\n" - // it's a list - "set lst [concat $lst {list} $len $tmp]\n" - "}\n" + "} else {\n" + // it's a list + "set lst [concat $lst {list} $len $tmp]\n" + "}\n" - "lappend lst [eval concat $$var_attr_save]\n" - "}\n" - "}\n" + "lappend lst [eval concat $$var_attr_save]\n" + "}\n" + "}\n" - "set cmd [concat $id attributedialog $lst \\;]\n" - "pd $cmd\n" - "}\n" + "set cmd [concat $id attributedialog $lst \\;]\n" + "pd $cmd\n" + "}\n" - "proc flext_cancel {id} {\n" - "set cmd [concat $id cancel \\;]\n" - "pd $cmd\n" - "}\n" + "proc flext_cancel {id} {\n" + "set cmd [concat $id cancel \\;]\n" + "pd $cmd\n" + "}\n" - "proc flext_ok {id alen} {\n" - "flext_apply $id $alen\n" - "flext_cancel $id\n" - "}\n" + "proc flext_ok {id alen} {\n" + "flext_apply $id $alen\n" + "flext_cancel $id\n" + "}\n" "proc flext_help {id} {\n" - "toplevel $id.hw\n" + "toplevel $id.hw\n" "wm title $id.hw \"Flext attribute editor help\"\n" "frame $id.hw.buttons\n" @@ -161,7 +161,7 @@ void flext_base::SetAttrEditor(t_classid c) "button $id.hw.buttons.ok -text OK -command \"destroy $id.hw\"\n" "pack $id.hw.buttons.ok -side left -expand 1\n" - "bind $id.hw {} \"destroy $id.hw\"\n" + "bind $id.hw {} \"destroy $id.hw\"\n" "$id.hw.text tag configure big -font {Arial 10 bold}\n" "$id.hw.text configure -font {Arial 8 bold}\n" @@ -172,22 +172,22 @@ void flext_base::SetAttrEditor(t_classid c) "Ctrl-Button on a text field will open an editor window where text can be entered more comfortably.\n" "\"\n" "$id.hw.text configure -state disabled\n" - "}\n" + "}\n" - "proc flext_copyval {dst src} {\n" - "global $src $dst\n" - "set $dst [expr $$src]\n" - "}\n" + "proc flext_copyval {dst src} {\n" + "global $src $dst\n" + "set $dst [expr $$src]\n" + "}\n" - "proc flext_textcopy {id idtxt var} {\n" - "global $var\n" + "proc flext_textcopy {id idtxt var} {\n" + "global $var\n" "set $var [eval $idtxt get 0.0 end]\n" "destroy $id\n" - "}\n" + "}\n" - "proc flext_textzoom {id var title attr edit} {\n" - "global $var\n" - "toplevel $id.w\n" + "proc flext_textzoom {id var title attr edit} {\n" + "global $var\n" + "toplevel $id.w\n" "wm title $id.w [concat $title \" @\" $attr]\n" // "wm iconname $w \"text\"\n" // "positionWindow $id.w\n" @@ -203,27 +203,27 @@ void flext_base::SetAttrEditor(t_classid c) "$id.w.text insert 0.0 [expr $$var]\n" "$id.w.text mark set insert 0.0\n" - "if { $edit != 0 } then {\n" + "if { $edit != 0 } then {\n" "button $id.w.buttons.ok -text OK -command \"flext_textcopy $id.w $id.w.text $var\"\n" "pack $id.w.buttons.ok -side left -expand 1\n" -// "bind $id.w {} \"flext_textcopy $id.w $id.w.text $var\"\n" +// "bind $id.w {} \"flext_textcopy $id.w $id.w.text $var\"\n" "} " "else { $id.w.text configure -state disabled }\n" "button $id.w.buttons.cancel -text Cancel -command \"destroy $id.w\"\n" "pack $id.w.buttons.cancel -side left -expand 1\n" - "bind $id.w {} \"destroy $id.w\"\n" + "bind $id.w {} \"destroy $id.w\"\n" "}\n" - "proc pdtk_flext_dialog {id title attrlist} {\n" - "set vid [string trimleft $id .]\n" - "set alen [expr [llength $attrlist] / 6 ]\n" + "proc pdtk_flext_dialog {id title attrlist} {\n" + "set vid [string trimleft $id .]\n" + "set alen [expr [llength $attrlist] / 6 ]\n" - "toplevel $id\n" - "wm title $id $title\n" - "wm protocol $id WM_DELETE_WINDOW [concat flext_cancel $id]\n" + "toplevel $id\n" + "wm title $id $title\n" + "wm protocol $id WM_DELETE_WINDOW [concat flext_cancel $id]\n" - "set row 0\n" + "set row 0\n" // set grow parameters "grid columnconfigure $id 0 -weight 1\n" // label @@ -233,266 +233,266 @@ void flext_base::SetAttrEditor(t_classid c) // "grid rowconfigure $id {0 1 2} -weight 0\n" - // set column labels - "label $id.label -text {attribute} -height 2 -font {Helvetica 9 bold}\n" - "label $id.init -text {initial value} -height 2 -font {Helvetica 9 bold}\n" - "label $id.copy -text {copy} -height 2 -font {Helvetica 9 bold}\n" - "label $id.val -text {current value} -height 2 -font {Helvetica 9 bold}\n" - "foreach {i txt} {0 {don't\rsave} 1 {do\rinit} 2 {always\rsave} } {\n" - "label $id.b$i -text $txt -height 2 -font {Helvetica 9 bold}\n" - "}\n" -// "label $id.options -text {options} -height 2\n" - - "grid config $id.label -column 0 -row $row \n" - "grid config $id.init -column 1 -row $row \n" - "grid config $id.copy -column 2 -columnspan 2 -row $row \n" - "grid config $id.val -column 4 -row $row \n" - "foreach i {0 1 2} { grid config $id.b$i -column [expr $i + 5] -row $row }\n" -// "grid config $id.options -column 3 -row 0 \n" - "incr row\n" - - // Separator - "frame $id.sep -relief ridge -bd 1 -height 2\n" - "grid config $id.sep -column 0 -columnspan 8 -row $row -pady 2 -sticky {snew}\n" - "incr row\n" - - "set ix 1\n" - "foreach {an av ai atp asv afl} $attrlist {\n" + // set column labels + "label $id.label -text {attribute} -height 2 -font {Helvetica 9 bold}\n" + "label $id.init -text {initial value} -height 2 -font {Helvetica 9 bold}\n" + "label $id.copy -text {copy} -height 2 -font {Helvetica 9 bold}\n" + "label $id.val -text {current value} -height 2 -font {Helvetica 9 bold}\n" + "foreach {i txt} {0 {don't\rsave} 1 {do\rinit} 2 {always\rsave} } {\n" + "label $id.b$i -text $txt -height 2 -font {Helvetica 9 bold}\n" + "}\n" +// "label $id.options -text {options} -height 2\n" + + "grid config $id.label -column 0 -row $row \n" + "grid config $id.init -column 1 -row $row \n" + "grid config $id.copy -column 2 -columnspan 2 -row $row \n" + "grid config $id.val -column 4 -row $row \n" + "foreach i {0 1 2} { grid config $id.b$i -column [expr $i + 5] -row $row }\n" +// "grid config $id.options -column 3 -row 0 \n" + "incr row\n" + + // Separator + "frame $id.sep -relief ridge -bd 1 -height 2\n" + "grid config $id.sep -column 0 -columnspan 8 -row $row -pady 2 -sticky {snew}\n" + "incr row\n" + + "set ix 1\n" + "foreach {an av ai atp asv afl} $attrlist {\n" "grid rowconfigure $id $row -weight 0\n" // get attribute name - "set var_attr_name [concat [concat var_name_$ix]_$vid ]\n" - "global $var_attr_name\n" - "set $var_attr_name $an\n" - - // get attribute init value (list) - "set var_attr_init [concat [concat var_init_$ix]_$vid ]\n" - "global $var_attr_init\n" - "set $var_attr_init $ai\n" - - // get attribute value (list) - "set var_attr_val [concat [concat var_val_$ix]_$vid ]\n" - "global $var_attr_val\n" - "set $var_attr_val $av\n" - - // get save flag - "set var_attr_save [concat [concat var_save_$ix]_$vid ]\n" - "global $var_attr_save\n" - "set $var_attr_save $asv\n" - - // get type flag - "set var_attr_type [concat [concat var_type_$ix]_$vid ]\n" - "global $var_attr_type\n" - "set $var_attr_type $afl\n" - - // add dialog elements to window - - // attribute label - "label $id.label-$ix -text \"$an :\" -font {Helvetica 8 bold}\n" - "grid config $id.label-$ix -column 0 -row $row -padx 5 -sticky {e}\n" - - "if { $afl != 0 } {\n" - // attribute is puttable - - // entry field for initial value - // entry field for current value - - // choose entry field type - "switch $atp {\n" - "0 - 1 {\n" // int or float - "entry $id.init-$ix -textvariable $var_attr_init\n" - "entry $id.val-$ix -textvariable $var_attr_val\n" - "}\n" - "2 {\n" // boolean - "checkbutton $id.init-$ix -variable $var_attr_init\n" - "checkbutton $id.val-$ix -variable $var_attr_val\n" - "}\n" - "3 {\n" // symbol - "entry $id.init-$ix -textvariable $var_attr_init\n" - "entry $id.val-$ix -textvariable $var_attr_val\n" - "}\n" - "4 - 5 {\n" // list or unknown - "entry $id.init-$ix -textvariable $var_attr_init\n" + "set var_attr_name [concat [concat var_name_$ix]_$vid ]\n" + "global $var_attr_name\n" + "set $var_attr_name $an\n" + + // get attribute init value (list) + "set var_attr_init [concat [concat var_init_$ix]_$vid ]\n" + "global $var_attr_init\n" + "set $var_attr_init $ai\n" + + // get attribute value (list) + "set var_attr_val [concat [concat var_val_$ix]_$vid ]\n" + "global $var_attr_val\n" + "set $var_attr_val $av\n" + + // get save flag + "set var_attr_save [concat [concat var_save_$ix]_$vid ]\n" + "global $var_attr_save\n" + "set $var_attr_save $asv\n" + + // get type flag + "set var_attr_type [concat [concat var_type_$ix]_$vid ]\n" + "global $var_attr_type\n" + "set $var_attr_type $afl\n" + + // add dialog elements to window + + // attribute label + "label $id.label-$ix -text \"$an :\" -font {Helvetica 8 bold}\n" + "grid config $id.label-$ix -column 0 -row $row -padx 5 -sticky {e}\n" + + "if { $afl != 0 } {\n" + // attribute is puttable + + // entry field for initial value + // entry field for current value + + // choose entry field type + "switch $atp {\n" + "0 - 1 {\n" // int or float + "entry $id.init-$ix -textvariable $var_attr_init\n" + "entry $id.val-$ix -textvariable $var_attr_val\n" + "}\n" + "2 {\n" // boolean + "checkbutton $id.init-$ix -variable $var_attr_init\n" + "checkbutton $id.val-$ix -variable $var_attr_val\n" + "}\n" + "3 {\n" // symbol + "entry $id.init-$ix -textvariable $var_attr_init\n" + "entry $id.val-$ix -textvariable $var_attr_val\n" + "}\n" + "4 - 5 {\n" // list or unknown + "entry $id.init-$ix -textvariable $var_attr_init\n" "bind $id.init-$ix {} \" flext_textzoom $id.init-$ix $var_attr_init { $title } $an 1\"\n" - "entry $id.val-$ix -textvariable $var_attr_val\n" + "entry $id.val-$ix -textvariable $var_attr_val\n" "bind $id.val-$ix {} \" flext_textzoom $id.val-$ix $var_attr_val { $title } $an 1\"\n" - "}\n" - "}\n" - - "grid config $id.init-$ix -column 1 -row $row -padx 5 -sticky {ew}\n" - "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n" - - "button $id.b2i-$ix -text {<-} -height 1 -command \" flext_copyval $var_attr_init $var_attr_val \"\n" - "grid config $id.b2i-$ix -column 2 -row $row -sticky {ew}\n" - "button $id.b2c-$ix -text {->} -height 1 -command \" flext_copyval $var_attr_val $var_attr_init \"\n" - "grid config $id.b2c-$ix -column 3 -row $row -sticky {ew}\n" - - // "tk_optionMenu $id.opt-$ix $var_attr_save {don't save} {initialize} {always save}\n" - // "grid config $id.opt-$ix -column 5 -row $ix \n" - - // radiobuttons - "foreach {i c} {0 black 1 blue 2 red} {\n" - "radiobutton $id.b$i-$ix -value $i -foreground $c -variable $var_attr_save \n" - "grid config $id.b$i-$ix -column [expr $i + 5] -row $row \n" - "}\n" - "} else {\n" - // attribute is gettable only - - // entry field for current value (read-only) - - // choose display field type - "switch $atp {\n" - "0 - 1 {\n" // int or float - "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" - "}\n" - "2 {\n" // boolean - "checkbutton $id.val-$ix -variable $var_attr_val -state disabled\n" - "}\n" - "3 {\n" // symbol - "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" - "}\n" - "4 - 5 {\n" // list or unknown - "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" + "}\n" + "}\n" + + "grid config $id.init-$ix -column 1 -row $row -padx 5 -sticky {ew}\n" + "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n" + + "button $id.b2i-$ix -text {<-} -height 1 -command \" flext_copyval $var_attr_init $var_attr_val \"\n" + "grid config $id.b2i-$ix -column 2 -row $row -sticky {ew}\n" + "button $id.b2c-$ix -text {->} -height 1 -command \" flext_copyval $var_attr_val $var_attr_init \"\n" + "grid config $id.b2c-$ix -column 3 -row $row -sticky {ew}\n" + + // "tk_optionMenu $id.opt-$ix $var_attr_save {don't save} {initialize} {always save}\n" + // "grid config $id.opt-$ix -column 5 -row $ix \n" + + // radiobuttons + "foreach {i c} {0 black 1 blue 2 red} {\n" + "radiobutton $id.b$i-$ix -value $i -foreground $c -variable $var_attr_save \n" + "grid config $id.b$i-$ix -column [expr $i + 5] -row $row \n" + "}\n" + "} else {\n" + // attribute is gettable only + + // entry field for current value (read-only) + + // choose display field type + "switch $atp {\n" + "0 - 1 {\n" // int or float + "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" + "}\n" + "2 {\n" // boolean + "checkbutton $id.val-$ix -variable $var_attr_val -state disabled\n" + "}\n" + "3 {\n" // symbol + "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" + "}\n" + "4 - 5 {\n" // list or unknown + "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" "bind $id.val-$ix {} \" flext_textzoom $id.val-$ix $var_attr_val { $title } $an 0\"\n" - "}\n" - "}\n" + "}\n" + "}\n" -// "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" - "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n" +// "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n" + "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n" - "label $id.readonly-$ix -text \"read-only\"\n" - "grid config $id.readonly-$ix -column 5 -columnspan 3 -row $row -padx 5 -sticky {ew}\n" - "}\n" + "label $id.readonly-$ix -text \"read-only\"\n" + "grid config $id.readonly-$ix -column 5 -columnspan 3 -row $row -padx 5 -sticky {ew}\n" + "}\n" - // increase counter - "incr ix\n" - "incr row\n" - "}\n" + // increase counter + "incr ix\n" + "incr row\n" + "}\n" - // Separator - "frame $id.sep2 -relief ridge -bd 1 -height 2\n" + // Separator + "frame $id.sep2 -relief ridge -bd 1 -height 2\n" // "grid rowconfigure $id $row -weight 0\n" - "grid config $id.sep2 -column 0 -columnspan 8 -row $row -pady 5 -sticky {snew}\n" - "incr row\n" + "grid config $id.sep2 -column 0 -columnspan 8 -row $row -pady 5 -sticky {snew}\n" + "incr row\n" - // Buttons - "frame $id.buttonframe\n" - "pack $id.buttonframe -side bottom -fill x\n" + // Buttons + "frame $id.buttonframe\n" + "pack $id.buttonframe -side bottom -fill x\n" - "button $id.buttonframe.cancel -text {Cancel} -width 20 -command \" flext_cancel $id \"\n" - "button $id.buttonframe.apply -text {Apply} -width 20 -command \" flext_apply $id $alen \"\n" - "button $id.buttonframe.ok -text {OK} -width 20 -command \" flext_ok $id $alen \"\n" - "button $id.buttonframe.help -text {Help} -width 10 -command \" flext_help $id \"\n" + "button $id.buttonframe.cancel -text {Cancel} -width 20 -command \" flext_cancel $id \"\n" + "button $id.buttonframe.apply -text {Apply} -width 20 -command \" flext_apply $id $alen \"\n" + "button $id.buttonframe.ok -text {OK} -width 20 -command \" flext_ok $id $alen \"\n" + "button $id.buttonframe.help -text {Help} -width 10 -command \" flext_help $id \"\n" - "pack $id.buttonframe.cancel -side left -expand 1\n" - "pack $id.buttonframe.apply -side left -expand 1\n" - "pack $id.buttonframe.ok -side left -expand 1\n" - "pack $id.buttonframe.help -side left -expand 1\n" + "pack $id.buttonframe.cancel -side left -expand 1\n" + "pack $id.buttonframe.apply -side left -expand 1\n" + "pack $id.buttonframe.ok -side left -expand 1\n" + "pack $id.buttonframe.help -side left -expand 1\n" // "grid rowconfigure $id $row -weight 0\n" - "grid config $id.buttonframe -column 0 -columnspan 8 -row $row -pady 5 -sticky {ew}\n" - - // Key bindings - "bind $id {} \" flext_cancel $id \"\n" - "bind $id {} \" flext_ok $id $alen \"\n" - "bind $id {} \" flext_apply $id $alen \"\n" - "}\n" - ); + "grid config $id.buttonframe -column 0 -columnspan 8 -row $row -pady 5 -sticky {ew}\n" + + // Key bindings + "bind $id {} \" flext_cancel $id \"\n" + "bind $id {} \" flext_ok $id $alen \"\n" + "bind $id {} \" flext_apply $id $alen \"\n" + "}\n" + ); } void flext_base::cb_GfxProperties(t_gobj *c, t_glist *) { - flext_base *th = thisObject(c); - char buf[10000],*b = buf; - - STD::sprintf(b, "pdtk_flext_dialog %%s { "); b += strlen(b); - - t_text *x = (t_text *)c; - FLEXT_ASSERT(x->te_binbuf); - - int argc = binbuf_getnatom(x->te_binbuf); - t_atom *argv = binbuf_getvec(x->te_binbuf); - - PrintList(argc,argv,b,sizeof(buf)+buf-b); b += strlen(b); - - STD::sprintf(b, " } { "); b += strlen(b); - - AtomList la; - th->ListAttrib(la); - int cnt = la.Count(); - - for(int i = 0; i < cnt; ++i) { - const t_symbol *sym = GetSymbol(la[i]); - - // get attribute - AttrItem *gattr = th->FindAttrib(sym,true); - // get puttable attribute - AttrItem *pattr = gattr?gattr->Counterpart():th->FindAttrib(sym,false); - - // get flags - int sv; - const AtomList *initdata; - AttrDataCont::iterator it = th->attrdata->find(sym); - if(it == th->attrdata->end()) - sv = 0,initdata = NULL; - else { - const AttrData &a = *it.data(); - if(a.IsSaved()) - sv = 2; - else if(a.IsInit()) - sv = 1; - else - sv = 0; - initdata = a.IsInitValue()?&a.GetInitValue():NULL; - } - - // get attribute type - int tp; - bool list; - switch((gattr?gattr:pattr)->argtp) { - case a_int: tp = 0; list = false; break; - case a_float: tp = 1; list = false; break; - case a_bool: tp = 2; list = false; break; - case a_symbol: tp = 3; list = true; break; - case a_list: - case a_LIST: tp = 4; list = true; break; - default: - tp = 5; list = true; - FLEXT_ASSERT(false); - } - - STD::sprintf(b,list?"%s {":"%s ",GetString(sym)); b += strlen(b); - - AtomList lv; - if(gattr) { // gettable attribute is present - // Retrieve attribute value - th->GetAttrib(sym,gattr,lv); - - PrintList(lv.Count(),lv.Atoms(),b,sizeof(buf)+buf-b); b += strlen(b); - } - else { - strcpy(b,"{}"); b += strlen(b); - } - - strcpy(b, list?"} {":" "); b += strlen(b); - - if(pattr) { - // if there is initialization data take this, otherwise take the current data - const AtomList &lp = initdata?*initdata:lv; - - PrintList(lp.Count(),lp.Atoms(),b,sizeof(buf)+buf-b); b += strlen(b); - } - else { - strcpy(b,"{}"); b += strlen(b); - } - - - STD::sprintf(b, list?"} %i %i %i ":" %i %i %i ",tp,sv,pattr?(pattr->BothExist()?2:1):0); b += strlen(b); - } - - strcpy(b, " }\n"); - - gfxstub_new((t_pd *)th->thisHdr(), th->thisHdr(), buf); + flext_base *th = thisObject(c); + char buf[10000],*b = buf; + + STD::sprintf(b, "pdtk_flext_dialog %%s { "); b += strlen(b); + + t_text *x = (t_text *)c; + FLEXT_ASSERT(x->te_binbuf); + + int argc = binbuf_getnatom(x->te_binbuf); + t_atom *argv = binbuf_getvec(x->te_binbuf); + + PrintList(argc,argv,b,sizeof(buf)+buf-b); b += strlen(b); + + STD::sprintf(b, " } { "); b += strlen(b); + + AtomList la; + th->ListAttrib(la); + int cnt = la.Count(); + + for(int i = 0; i < cnt; ++i) { + const t_symbol *sym = GetSymbol(la[i]); + + // get attribute + AttrItem *gattr = th->FindAttrib(sym,true); + // get puttable attribute + AttrItem *pattr = gattr?gattr->Counterpart():th->FindAttrib(sym,false); + + // get flags + int sv; + const AtomList *initdata; + AttrDataCont::iterator it = th->attrdata->find(sym); + if(it == th->attrdata->end()) + sv = 0,initdata = NULL; + else { + const AttrData &a = *it.data(); + if(a.IsSaved()) + sv = 2; + else if(a.IsInit()) + sv = 1; + else + sv = 0; + initdata = a.IsInitValue()?&a.GetInitValue():NULL; + } + + // get attribute type + int tp; + bool list; + switch((gattr?gattr:pattr)->argtp) { + case a_int: tp = 0; list = false; break; + case a_float: tp = 1; list = false; break; + case a_bool: tp = 2; list = false; break; + case a_symbol: tp = 3; list = true; break; + case a_list: + case a_LIST: tp = 4; list = true; break; + default: + tp = 5; list = true; + FLEXT_ASSERT(false); + } + + STD::sprintf(b,list?"%s {":"%s ",GetString(sym)); b += strlen(b); + + AtomList lv; + if(gattr) { // gettable attribute is present + // Retrieve attribute value + th->GetAttrib(sym,gattr,lv); + + PrintList(lv.Count(),lv.Atoms(),b,sizeof(buf)+buf-b); b += strlen(b); + } + else { + strcpy(b,"{}"); b += strlen(b); + } + + strcpy(b, list?"} {":" "); b += strlen(b); + + if(pattr) { + // if there is initialization data take this, otherwise take the current data + const AtomList &lp = initdata?*initdata:lv; + + PrintList(lp.Count(),lp.Atoms(),b,sizeof(buf)+buf-b); b += strlen(b); + } + else { + strcpy(b,"{}"); b += strlen(b); + } + + + STD::sprintf(b, list?"} %i %i %i ":" %i %i %i ",tp,sv,pattr?(pattr->BothExist()?2:1):0); b += strlen(b); + } + + strcpy(b, " }\n"); + + gfxstub_new((t_pd *)th->thisHdr(), th->thisHdr(), buf); } //! Strip the attributes off the object command line @@ -501,202 +501,202 @@ void flext_base::cb_GfxVis(t_gobj *c, t_glist *gl, int vis) // show object if it's not a GOP if(!gl->gl_isgraph || gl->gl_havewindow) { - t_text *x = (t_text *)c; - FLEXT_ASSERT(x->te_binbuf); + t_text *x = (t_text *)c; + FLEXT_ASSERT(x->te_binbuf); - int argc = binbuf_getnatom(x->te_binbuf); - t_atom *argv = binbuf_getvec(x->te_binbuf); - int cnt = CheckAttrib(argc,argv); + int argc = binbuf_getnatom(x->te_binbuf); + t_atom *argv = binbuf_getvec(x->te_binbuf); + int cnt = CheckAttrib(argc,argv); - if(cnt) { - t_binbuf *nb = binbuf_new(); - binbuf_restore(nb,cnt,argv); - binbuf_free(x->te_binbuf); - x->te_binbuf = nb; - } + if(cnt) { + t_binbuf *nb = binbuf_new(); + binbuf_restore(nb,cnt,argv); + binbuf_free(x->te_binbuf); + x->te_binbuf = nb; + } - t_rtext *rt = glist_findrtext(gl,x); - rtext_retext(rt); + t_rtext *rt = glist_findrtext(gl,x); + rtext_retext(rt); // now display the changed text with the normal drawing function #ifdef FLEXT_CLONEWIDGET - text_widgetbehavior.w_visfn(c,gl,vis); + text_widgetbehavior.w_visfn(c,gl,vis); #else - ori_vis(c,gl,vis); + ori_vis(c,gl,vis); #endif } } static void BinbufAdd(t_binbuf *b,const t_atom &at) { - char tbuf[MAXPDSTRING]; - if(flext::IsString(at)) - binbuf_addv(b,"s",flext::GetSymbol(at)); - else if(flext::IsFloat(at)) - binbuf_addv(b,"f",flext::GetFloat(at)); - else if(flext::IsInt(at)) - binbuf_addv(b,"i",flext::GetInt(at)); - else if(at.a_type == A_DOLLAR) { - sprintf(tbuf, "$%d", at.a_w.w_index); - binbuf_addv(b,"s",flext::MakeSymbol(tbuf)); - } - else if(at.a_type == A_DOLLSYM) { - sprintf(tbuf, "$%s", at.a_w.w_symbol->s_name); - binbuf_addv(b,"s",flext::MakeSymbol(tbuf)); - } - else - FLEXT_ASSERT(false); + char tbuf[MAXPDSTRING]; + if(flext::IsString(at)) + binbuf_addv(b,"s",flext::GetSymbol(at)); + else if(flext::IsFloat(at)) + binbuf_addv(b,"f",flext::GetFloat(at)); + else if(flext::IsInt(at)) + binbuf_addv(b,"i",flext::GetInt(at)); + else if(at.a_type == A_DOLLAR) { + sprintf(tbuf, "$%d", at.a_w.w_index); + binbuf_addv(b,"s",flext::MakeSymbol(tbuf)); + } + else if(at.a_type == A_DOLLSYM) { + sprintf(tbuf, "$%s", at.a_w.w_symbol->s_name); + binbuf_addv(b,"s",flext::MakeSymbol(tbuf)); + } + else + FLEXT_ASSERT(false); } void flext_base::cb_GfxSave(t_gobj *c, t_binbuf *b) { - flext_base *th = thisObject(c); - t_text *t = (t_text *)c; - binbuf_addv(b, "ssiis", gensym("#X"),gensym("obj"), t->te_xpix, t->te_ypix,MakeSymbol(th->thisName())); - - int argc = binbuf_getnatom(t->te_binbuf); - t_atom *argv = binbuf_getvec(t->te_binbuf); - int i,cnt = CheckAttrib(argc,argv); - - // process the creation arguments - for(i = 1; i < cnt; ++i) BinbufAdd(b,argv[i]); - - // process the attributes - AtomList la; - th->ListAttrib(la); - cnt = la.Count(); - - for(i = 0; i < cnt; ++i) { - const t_symbol *sym = GetSymbol(la[i]); - AtomList lv; - const AtomList *lref = NULL; - AttrDataCont::iterator it = th->attrdata->find(sym); - - if(it != th->attrdata->end()) { - const AttrData &a = *it.data(); - if(a.IsInit() && a.IsInitValue()) { - lref = &a.GetInitValue(); + flext_base *th = thisObject(c); + t_text *t = (t_text *)c; + binbuf_addv(b, "ssiis", gensym("#X"),gensym("obj"), t->te_xpix, t->te_ypix,MakeSymbol(th->thisName())); + + int argc = binbuf_getnatom(t->te_binbuf); + t_atom *argv = binbuf_getvec(t->te_binbuf); + int i,cnt = CheckAttrib(argc,argv); + + // process the creation arguments + for(i = 1; i < cnt; ++i) BinbufAdd(b,argv[i]); + + // process the attributes + AtomList la; + th->ListAttrib(la); + cnt = la.Count(); + + for(i = 0; i < cnt; ++i) { + const t_symbol *sym = GetSymbol(la[i]); + AtomList lv; + const AtomList *lref = NULL; + AttrDataCont::iterator it = th->attrdata->find(sym); + + if(it != th->attrdata->end()) { + const AttrData &a = *it.data(); + if(a.IsInit() && a.IsInitValue()) { + lref = &a.GetInitValue(); /* - // check for $-parameters - lv = lref->Count(); - for(int j = 0; j < lref->Count(); ++j) { - const char *s = IsSymbol((*lref)[j])?GetString((*lref)[j]):NULL; - if(s && s[0] == '$') { // TODO: More refined checking? - // prepend a "\" - char tmp[256]; *tmp = '\\'; - strcpy(tmp+1,s); - SetString(lv[j],tmp); - } - else - lv[i] = (*lref)[j]; - } - - lref = &lv; + // check for $-parameters + lv = lref->Count(); + for(int j = 0; j < lref->Count(); ++j) { + const char *s = IsSymbol((*lref)[j])?GetString((*lref)[j]):NULL; + if(s && s[0] == '$') { // TODO: More refined checking? + // prepend a "\" + char tmp[256]; *tmp = '\\'; + strcpy(tmp+1,s); + SetString(lv[j],tmp); + } + else + lv[i] = (*lref)[j]; + } + + lref = &lv; */ - } - else if(a.IsSaved()) { - AttrItem *attr = th->FindAttrib(sym,true); - - // attribute must be gettable (so that the data can be retrieved) and puttable (so that the data can be inited) - if(attr && attr->BothExist()) { - th->GetAttrib(sym,attr,lv); - lref = &lv; - } - } - } - - if(lref) { - char attrname[256]; *attrname= '@'; - // store name - strcpy(attrname+1,GetString(sym)); - binbuf_addv(b,"s",MakeSymbol(attrname)); - - // store value - for(int j = 0; j < lref->Count(); ++j) BinbufAdd(b,(*lref)[j]); - } - } - - binbuf_addv(b, ";"); + } + else if(a.IsSaved()) { + AttrItem *attr = th->FindAttrib(sym,true); + + // attribute must be gettable (so that the data can be retrieved) and puttable (so that the data can be inited) + if(attr && attr->BothExist()) { + th->GetAttrib(sym,attr,lv); + lref = &lv; + } + } + } + + if(lref) { + char attrname[256]; *attrname= '@'; + // store name + strcpy(attrname+1,GetString(sym)); + binbuf_addv(b,"s",MakeSymbol(attrname)); + + // store value + for(int j = 0; j < lref->Count(); ++j) BinbufAdd(b,(*lref)[j]); + } + } + + binbuf_addv(b, ";"); } bool flext_base::cb_AttrDialog(flext_base *th,int argc,const t_atom *argv) { - int i = 0; - if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) ++i; - - for(; i < argc; ) { - FLEXT_ASSERT(IsSymbol(argv[i])); - - // get name - const t_symbol *aname = GetSymbol(argv[i]); - i++; - - // get current value - int ccnt,coffs; - if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) { - i++; - FLEXT_ASSERT(CanbeInt(argv[i])); - ccnt = GetAInt(argv[i]); - coffs = ++i; - } - else - coffs = i,ccnt = 1; - i += ccnt; - - // get init value - int icnt,ioffs; - if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) { - i++; - FLEXT_ASSERT(CanbeInt(argv[i])); - icnt = GetAInt(argv[i]); - ioffs = ++i; - } - else - ioffs = i,icnt = 1; - i += icnt; - - FLEXT_ASSERT(i < argc); - int sv = GetAInt(argv[i]); - ++i; - - // find puttable attribute - AttrItem *attr = th->FindAttrib(aname,false); - if(attr) { - bool ret = th->SetAttrib(aname,attr,ccnt,argv+coffs); - FLEXT_ASSERT(ret); - - AttrDataCont::iterator it = th->attrdata->find(aname); - - if(sv >= 1) { - // if data not present create it - if(it == th->attrdata->end()) { - AttrDataCont::pair pair; - pair.key() = aname; - pair.data() = new AttrData; - it = th->attrdata->insert(th->attrdata->begin(),pair); - } - - AttrData &a = *it.data(); - a.SetSave(sv == 2); - a.SetInit(true); - a.SetInitValue(icnt,argv+ioffs); - } - else { - if(it != th->attrdata->end()) { - AttrData &a = *it.data(); - // if data is present reset flags - a.SetSave(false); - a.SetInit(false); - - // let init data as is - } - } - } - else { - post("%s - Attribute %s can't be set",th->thisName(),GetString(aname)); - } - } - return true; + int i = 0; + if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) ++i; + + for(; i < argc; ) { + FLEXT_ASSERT(IsSymbol(argv[i])); + + // get name + const t_symbol *aname = GetSymbol(argv[i]); + i++; + + // get current value + int ccnt,coffs; + if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) { + i++; + FLEXT_ASSERT(CanbeInt(argv[i])); + ccnt = GetAInt(argv[i]); + coffs = ++i; + } + else + coffs = i,ccnt = 1; + i += ccnt; + + // get init value + int icnt,ioffs; + if(IsSymbol(argv[i]) && GetSymbol(argv[i]) == sym_list) { + i++; + FLEXT_ASSERT(CanbeInt(argv[i])); + icnt = GetAInt(argv[i]); + ioffs = ++i; + } + else + ioffs = i,icnt = 1; + i += icnt; + + FLEXT_ASSERT(i < argc); + int sv = GetAInt(argv[i]); + ++i; + + // find puttable attribute + AttrItem *attr = th->FindAttrib(aname,false); + if(attr) { + bool ret = th->SetAttrib(aname,attr,ccnt,argv+coffs); + FLEXT_ASSERT(ret); + + AttrDataCont::iterator it = th->attrdata->find(aname); + + if(sv >= 1) { + // if data not present create it + if(it == th->attrdata->end()) { + AttrDataCont::pair pair; + pair.key() = aname; + pair.data() = new AttrData; + it = th->attrdata->insert(th->attrdata->begin(),pair); + } + + AttrData &a = *it.data(); + a.SetSave(sv == 2); + a.SetInit(true); + a.SetInitValue(icnt,argv+ioffs); + } + else { + if(it != th->attrdata->end()) { + AttrData &a = *it.data(); + // if data is present reset flags + a.SetSave(false); + a.SetInit(false); + + // let init data as is + } + } + } + else { + post("%s - Attribute %s can't be set",th->thisName(),GetString(aname)); + } + } + return true; } #endif // FLEXT_SYS_PD diff --git a/externals/grill/flext/source/flbase.cpp b/externals/grill/flext/source/flbase.cpp index 72e07999..04bad89f 100644 --- a/externals/grill/flext/source/flbase.cpp +++ b/externals/grill/flext/source/flbase.cpp @@ -11,7 +11,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. /*! \file flbase.cpp \brief Implementation of the internal flext base classes. - \remark This is all derived from GEM by Mark Danks + \remark This is all derived from GEM by Mark Danks */ #include "flext.h" @@ -21,12 +21,12 @@ WARRANTIES, see the file, "license.txt," in this distribution. #if FLEXT_SYS == FLEXT_SYS_PD #ifdef _MSC_VER - #pragma warning (push) - #pragma warning (disable:4091) + #pragma warning (push) + #pragma warning (disable:4091) #endif #include #ifdef _MSC_VER - #pragma warning (pop) + #pragma warning (pop) #endif #endif @@ -52,9 +52,9 @@ void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; } ///////////////////////////////////////////////////////// flext_obj :: FLEXT_CLASSDEF(flext_obj)() : x_obj(m_holder) - , procattr(m_holdattr) - , init_ok(true) - , m_name(m_holdname) + , procattr(m_holdattr) + , init_ok(true) + , m_name(m_holdname) { #if FLEXT_SYS == FLEXT_SYS_PD m_canvas = canvas_getcurrent(); @@ -69,7 +69,7 @@ flext_obj :: FLEXT_CLASSDEF(flext_obj)() // ///////////////////////////////////////////////////////// flext_obj :: ~FLEXT_CLASSDEF(flext_obj)() { - x_obj = NULL; + x_obj = NULL; } @@ -80,56 +80,56 @@ void flext_obj::Exit() {} void flext_obj::DefineHelp(t_classid c,const char *ref,const char *dir,bool addtilde) { #if FLEXT_SYS == FLEXT_SYS_PD - char tmp[256]; - if(dir) { - strcpy(tmp,dir); - strcat(tmp,"/"); - strcat(tmp,ref); - } - else - strcpy(tmp,ref); - if(addtilde) strcat(tmp,"~"); + char tmp[256]; + if(dir) { + strcpy(tmp,dir); + strcat(tmp,"/"); + strcat(tmp,ref); + } + else + strcpy(tmp,ref); + if(addtilde) strcat(tmp,"~"); ::class_sethelpsymbol(getClass(c),gensym(const_cast(tmp))); #else - // no solution for Max/MSP yet + // no solution for Max/MSP yet #endif } bool flext_obj::GetParamSym(t_atom &dst,const t_symbol *sym,t_canvas *c) { #if FLEXT_SYS == FLEXT_SYS_PD - if(!c) c = canvas_getcurrent(); - - const char *s = GetString(sym); - if((s[0] == '$' || s[0] == '#') && isdigit(s[1])) { - const t_symbol *res; - // patcher parameter detected... get value! - if(s[0] != '$') { - char tmp[MAXPDSTRING]; - strcpy(tmp,s); - tmp[0] = '$'; - res = canvas_realizedollar(c,const_cast(MakeSymbol(tmp))); - } - else - res = canvas_realizedollar(c,const_cast(sym)); - - // check for number - const char *c = GetString(res); - while(*c && (isdigit(*c) || *c == '.')) ++c; - - if(!*c) - SetFloat(dst,(float)atof(GetString(res))); - else - SetSymbol(dst,res); - return true; - } - else + if(!c) c = canvas_getcurrent(); + + const char *s = GetString(sym); + if((s[0] == '$' || s[0] == '#') && isdigit(s[1])) { + const t_symbol *res; + // patcher parameter detected... get value! + if(s[0] != '$') { + char tmp[MAXPDSTRING]; + strcpy(tmp,s); + tmp[0] = '$'; + res = canvas_realizedollar(c,const_cast(MakeSymbol(tmp))); + } + else + res = canvas_realizedollar(c,const_cast(sym)); + + // check for number + const char *c = GetString(res); + while(*c && (isdigit(*c) || *c == '.')) ++c; + + if(!*c) + SetFloat(dst,(float)atof(GetString(res))); + else + SetSymbol(dst,res); + return true; + } + else #else - #pragma message("Not implemented") + #pragma message("Not implemented") #endif - SetSymbol(dst,sym); - return true; + SetSymbol(dst,sym); + return true; } @@ -142,13 +142,13 @@ extern "C" void canvas_getargs(int *argcp, t_atom **argvp); void flext_obj::CanvasArgs(AtomList &args) const { #if FLEXT_SYS == FLEXT_SYS_PD - int argc; - t_atom *argv; - canvas_getargs(&argc,&argv); - args(argc); - for(int i = 0; i < argc; ++i) args[i] = argv[i]; + int argc; + t_atom *argv; + canvas_getargs(&argc,&argv); + args(argc); + for(int i = 0; i < argc; ++i) args[i] = argv[i]; #else - #pragma message("Not implemented") - args(0); + #pragma message("Not implemented") + args(0); #endif } diff --git a/externals/grill/flext/source/flbase.h b/externals/grill/flext/source/flbase.h index 85633f20..a9a9d8e5 100644 --- a/externals/grill/flext/source/flbase.h +++ b/externals/grill/flext/source/flbase.h @@ -443,10 +443,16 @@ fts_module_t __##NAME##_module = {#NAME,#NAME,__##NAME##_initfun,0,0}; #define FLEXTTYPE_int FLEXTTPN_FLOAT #define FLEXTTYPE_int0 FLEXTTPN_DEFFLOAT #define CALLBTYPE_int float +#define FLEXTTYPE_bool FLEXTTPN_FLOAT +#define FLEXTTYPE_bool0 FLEXTTPN_DEFFLOAT +#define CALLBTYPE_bool float #elif FLEXT_SYS == FLEXT_SYS_MAX || FLEXT_SYS == FLEXT_SYS_JMAX #define FLEXTTYPE_int FLEXTTPN_INT #define FLEXTTYPE_int0 FLEXTTPN_DEFINT #define CALLBTYPE_int int +#define FLEXTTYPE_bool FLEXTTPN_INT +#define FLEXTTYPE_bool0 FLEXTTPN_DEFINT +#define CALLBTYPE_bool int #else #error #endif @@ -464,6 +470,8 @@ fts_module_t __##NAME##_module = {#NAME,#NAME,__##NAME##_initfun,0,0}; #define CALLBTP(TP) CALLBTYPE_ ## TP +#define ARGMEMBER_bool(a) GetBool(a) +#define ARGMEMBER_bool0(a) ARGMEMBER_bool(a) #define ARGMEMBER_int(a) GetInt(a) #define ARGMEMBER_int0(a) ARGMEMBER_int(a) #define ARGMEMBER_float(a) GetFloat(a) diff --git a/externals/grill/flext/source/flbind.cpp b/externals/grill/flext/source/flbind.cpp index 5a8f0743..8eefefb4 100644 --- a/externals/grill/flext/source/flbind.cpp +++ b/externals/grill/flext/source/flbind.cpp @@ -27,37 +27,37 @@ t_messlist px_messlist[3]; */ void flext_base::SetupBindProxy() { - // already initialized? - if(!pxbnd_class) { + // already initialized? + if(!pxbnd_class) { #if FLEXT_SYS == FLEXT_SYS_PD - pxbnd_class = class_new(gensym("flext_base bind proxy"),NULL,NULL,sizeof(pxbnd_object),CLASS_PD|CLASS_NOINLET, A_NULL); - add_anything(pxbnd_class,pxbnd_object::px_method); // for symbol-bound methods + pxbnd_class = class_new(gensym("flext_base bind proxy"),NULL,NULL,sizeof(pxbnd_object),CLASS_PD|CLASS_NOINLET, A_NULL); + add_anything(pxbnd_class,pxbnd_object::px_method); // for symbol-bound methods #elif FLEXT_SYS == FLEXT_SYS_MAX - pxbnd_class = new t_class; - - pxbnd_class->c_sym = gensym(""); - pxbnd_class->c_freelist = &px_freelist; - pxbnd_class->c_freefun = NULL; - pxbnd_class->c_size = sizeof(pxbnd_object); - pxbnd_class->c_tiny = 0; - pxbnd_class->c_noinlet = 1; - px_messlist[0].m_sym = (t_symbol *)pxbnd_class; - - px_messlist[1].m_sym = gensym("anything"); - px_messlist[1].m_fun = (method)pxbnd_object::px_method; - px_messlist[1].m_type[0] = A_GIMME; - px_messlist[1].m_type[1] = 0; - - px_messlist[2].m_sym = 0; + pxbnd_class = new t_class; + + pxbnd_class->c_sym = gensym(""); + pxbnd_class->c_freelist = &px_freelist; + pxbnd_class->c_freefun = NULL; + pxbnd_class->c_size = sizeof(pxbnd_object); + pxbnd_class->c_tiny = 0; + pxbnd_class->c_noinlet = 1; + px_messlist[0].m_sym = (t_symbol *)pxbnd_class; + + px_messlist[1].m_sym = gensym("anything"); + px_messlist[1].m_fun = (method)pxbnd_object::px_method; + px_messlist[1].m_type[0] = A_GIMME; + px_messlist[1].m_type[1] = 0; + + px_messlist[2].m_sym = 0; #else #pragma warning("Not implemented!") #endif - } + } } flext_base::BindItem::BindItem(bool (*f)(flext_base *,t_symbol *s,int,t_atom *,void *data),pxbnd_object *p): - Item(NULL),fun(f),px(p) + Item(NULL),fun(f),px(p) {} flext_base::BindItem::~BindItem() @@ -122,13 +122,13 @@ bool flext_base::BindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbo #endif if(px) { - BindItem *mi = new BindItem(fun,px); - bindhead->Add(mi,sym); + BindItem *mi = new BindItem(fun,px); + bindhead->Add(mi,sym); px->init(this,mi,data); #if FLEXT_SYS == FLEXT_SYS_PD - pd_bind(&px->obj.ob_pd,const_cast(sym)); + pd_bind(&px->obj.ob_pd,const_cast(sym)); #elif FLEXT_SYS == FLEXT_SYS_MAX if(!sym->s_thing) const_cast(sym)->s_thing = (t_object *)px; @@ -205,16 +205,16 @@ bool flext_base::UnbindAll() for(ItemSet::iterator si = set.begin(); si != set.end(); ++si) { Item *lst = si.data(); while(lst) { - Item *nxt = lst->nxt; + Item *nxt = lst->nxt; BindItem *it = (BindItem *)lst; it->Unbind(si.key()); delete it; - lst = nxt; + lst = nxt; } } set.clear(); } - return true; + return true; } void flext_base::pxbnd_object::px_method(pxbnd_object *c,const t_symbol *s,int argc,t_atom *argv) diff --git a/externals/grill/flext/source/flbuf.cpp b/externals/grill/flext/source/flbuf.cpp index 6d2f651d..4dc0b6e8 100644 --- a/externals/grill/flext/source/flbuf.cpp +++ b/externals/grill/flext/source/flbuf.cpp @@ -27,25 +27,25 @@ WARRANTIES, see the file, "license.txt," in this distribution. // check if PD API supports buffer dirty time #if defined(PD_DEVEL_VERSION) && defined(PD_MAJOR_VERSION) && defined(PD_MINOR_VERSION) #if PD_MINOR_VERSION >= 36 - #define FLEXT_PDBUFDIRTYTIME + #define FLEXT_PDBUFDIRTYTIME #endif #endif flext::buffer::buffer(const t_symbol *bn,bool delayed): - sym(NULL),data(NULL), - chns(0),frames(0) + sym(NULL),data(NULL), + chns(0),frames(0) { #if FLEXT_SYS == FLEXT_SYS_PD - arr = NULL; - interval = DIRTY_INTERVAL; - isdirty = false; - ticking = false; + arr = NULL; + interval = DIRTY_INTERVAL; + isdirty = false; + ticking = false; tick = clock_new(this,(t_method)cb_tick); #endif - if(bn) Set(bn,delayed); + if(bn) Set(bn,delayed); - ClearDirty(); + ClearDirty(); } flext::buffer::~buffer() @@ -57,167 +57,167 @@ flext::buffer::~buffer() int flext::buffer::Set(const t_symbol *s,bool nameonly) { - int ret = 0; - bool valid = data != NULL; // valid now? (before change) - - if(s && sym != s) { - ret = 1; - data = NULL; - frames = 0; - chns = 0; - } - - if(s && *GetString(s)) sym = s; - - if(!sym) { - if(valid) ret = -1; - } - else if(!nameonly) { + int ret = 0; + bool valid = data != NULL; // valid now? (before change) + + if(s && sym != s) { + ret = 1; + data = NULL; + frames = 0; + chns = 0; + } + + if(s && *GetString(s)) sym = s; + + if(!sym) { + if(valid) ret = -1; + } + else if(!nameonly) { #if FLEXT_SYS == FLEXT_SYS_PD - int frames1; - t_sample *data1; + int frames1; + t_sample *data1; - arr = (t_garray *)pd_findbyclass(const_cast(sym), garray_class); - if(!arr) - { - if (*GetString(sym)) FLEXT_LOG1("buffer: no such array '%s'",GetString(sym)); - sym = NULL; - if(valid) ret = -1; - } - else if(!garray_getfloatarray(arr, &frames1, &data1)) - { - error("buffer: bad template '%s'",GetString(sym)); - data = NULL; - frames = 0; - if(valid) ret = -1; - } - else { + arr = (t_garray *)pd_findbyclass(const_cast(sym), garray_class); + if(!arr) + { + if (*GetString(sym)) FLEXT_LOG1("buffer: no such array '%s'",GetString(sym)); + sym = NULL; + if(valid) ret = -1; + } + else if(!garray_getfloatarray(arr, &frames1, &data1)) + { + error("buffer: bad template '%s'",GetString(sym)); + data = NULL; + frames = 0; + if(valid) ret = -1; + } + else { ret = 0; - garray_usedindsp(arr); - if(frames != frames1) { frames = frames1; if(!ret) ret = 1; } - if(data != data1) { data = data1; if(!ret) ret = 1; } - chns = 1; - } + garray_usedindsp(arr); + if(frames != frames1) { frames = frames1; if(!ret) ret = 1; } + if(data != data1) { data = data1; if(!ret) ret = 1; } + chns = 1; + } #elif FLEXT_SYS == FLEXT_SYS_MAX - if(sym->s_thing) { - const _buffer *p = (const _buffer *)sym->s_thing; - - if(NOGOOD(p) || !p->b_valid) { - post("buffer: buffer object '%s' no good",GetString(sym)); - if(valid) ret = -2; - } - else { + if(sym->s_thing) { + const _buffer *p = (const _buffer *)sym->s_thing; + + if(NOGOOD(p) || !p->b_valid) { + post("buffer: buffer object '%s' no good",GetString(sym)); + if(valid) ret = -2; + } + else { #ifdef FLEXT_DEBUG -// post("flext: buffer object '%s' - valid:%i samples:%i channels:%i frames:%i",GetString(sym),p->b_valid,p->b_frames,p->b_nchans,p->b_frames); +// post("flext: buffer object '%s' - valid:%i samples:%i channels:%i frames:%i",GetString(sym),p->b_valid,p->b_frames,p->b_nchans,p->b_frames); #endif - if(data != p->b_samples) { data = p->b_samples; if(!ret) ret = 1; } - if(chns != p->b_nchans) { chns = p->b_nchans; if(!ret) ret = 1; } - if(frames != p->b_frames) { frames = p->b_frames; if(!ret) ret = 1; } - } - } - else { - FLEXT_LOG1("buffer: symbol '%s' not defined", GetString(sym)); - /*if(valid)*/ ret = -1; - } + if(data != p->b_samples) { data = p->b_samples; if(!ret) ret = 1; } + if(chns != p->b_nchans) { chns = p->b_nchans; if(!ret) ret = 1; } + if(frames != p->b_frames) { frames = p->b_frames; if(!ret) ret = 1; } + } + } + else { + FLEXT_LOG1("buffer: symbol '%s' not defined", GetString(sym)); + /*if(valid)*/ ret = -1; + } #else #error not implemented #endif - } + } - return ret; + return ret; } bool flext::buffer::Valid() const { - if(sym) { + if(sym) { #if FLEXT_SYS == FLEXT_SYS_PD - int frames1; - t_sample *data1; - return arr && garray_getfloatarray(arr, &frames1, &data1) != 0; + int frames1; + t_sample *data1; + return arr && garray_getfloatarray(arr, &frames1, &data1) != 0; #elif FLEXT_SYS == FLEXT_SYS_MAX - const _buffer *p = (const _buffer *)sym->s_thing; - return p && p->b_valid; + const _buffer *p = (const _buffer *)sym->s_thing; + return p && p->b_valid; #else #error #endif - } - else return false; + } + else return false; } bool flext::buffer::Update() { - if(!Ok()) return false; + if(!Ok()) return false; - bool ok = false; + bool ok = false; #if FLEXT_SYS == FLEXT_SYS_PD - int frames1; - t_sample *data1; - if(!garray_getfloatarray(arr, &frames1, &data1)) { - frames = 0; - data = NULL; - chns = 0; - ok = true; - } - else if(data != data1 || frames != frames1) { - frames = frames1; - data = data1; - ok = true; - } + int frames1; + t_sample *data1; + if(!garray_getfloatarray(arr, &frames1, &data1)) { + frames = 0; + data = NULL; + chns = 0; + ok = true; + } + else if(data != data1 || frames != frames1) { + frames = frames1; + data = data1; + ok = true; + } #elif FLEXT_SYS == FLEXT_SYS_MAX - if(sym->s_thing) { - const _buffer *p = (const _buffer *)sym->s_thing; - if(data != p->b_samples || chns != p->b_nchans || frames != p->b_frames) { - data = p->b_samples; - chns = p->b_nchans; - frames = p->b_frames; - ok = true; - } - } + if(sym->s_thing) { + const _buffer *p = (const _buffer *)sym->s_thing; + if(data != p->b_samples || chns != p->b_nchans || frames != p->b_frames) { + data = p->b_samples; + chns = p->b_nchans; + frames = p->b_frames; + ok = true; + } + } #else #error not implemented #endif - return ok; + return ok; } void flext::buffer::Frames(int fr,bool keep,bool zero) { #if FLEXT_SYS == FLEXT_SYS_PD // is this function guaranteed to keep memory and set rest to zero? - ::garray_resize(arr,(float)fr); - Update(); + ::garray_resize(arr,(float)fr); + Update(); #elif FLEXT_SYS == FLEXT_SYS_MAX - t_sample *tmp = NULL; - int sz = frames; - if(fr < sz) sz = fr; + t_sample *tmp = NULL; + int sz = frames; + if(fr < sz) sz = fr; - if(keep) { - // copy buffer data to tmp storage + if(keep) { + // copy buffer data to tmp storage tmp = (t_sample *)NewAligned(sz*sizeof(t_sample)); if(tmp) - CopySamples(tmp,data,sz); - else - error("flext::buffer - not enough memory for keeping buffer~ contents"); - } - - t_atom msg; - _buffer *buf = (_buffer *)sym->s_thing; - // b_msr reflects buffer sample rate... is this what we want? - // Max bug: adding half a sample to prevent roundoff errors.... - float ms = (fr+0.5)/buf->b_msr; - - SetFloat(msg,ms); - ::typedmess((object *)buf,gensym("size"),1,&msg); - - Update(); - - if(tmp) { - // copy data back - CopySamples(data,tmp,sz); - FreeAligned(tmp); + CopySamples(tmp,data,sz); + else + error("flext::buffer - not enough memory for keeping buffer~ contents"); + } + + t_atom msg; + _buffer *buf = (_buffer *)sym->s_thing; + // b_msr reflects buffer sample rate... is this what we want? + // Max bug: adding half a sample to prevent roundoff errors.... + float ms = (fr+0.5)/buf->b_msr; + + SetFloat(msg,ms); + ::typedmess((object *)buf,gensym("size"),1,&msg); + + Update(); + + if(tmp) { + // copy data back + CopySamples(data,tmp,sz); + FreeAligned(tmp); if(zero && sz < fr) ZeroSamples(data+sz,fr-sz); - } + } else if(zero) ZeroSamples(data,fr); #else @@ -229,11 +229,11 @@ void flext::buffer::Frames(int fr,bool keep,bool zero) #if FLEXT_SYS == FLEXT_SYS_PD void flext::buffer::SetRefrIntv(float intv) { - interval = intv; - if(interval == 0 && ticking) { - clock_unset(tick); - ticking = false; - } + interval = intv; + if(interval == 0 && ticking) { + clock_unset(tick); + ticking = false; + } } #elif FLEXT_SYS == FLEXT_SYS_MAX void flext::buffer::SetRefrIntv(float) {} @@ -244,60 +244,60 @@ void flext::buffer::SetRefrIntv(float) {} void flext::buffer::Dirty(bool force) { - if(sym) { + if(sym) { #if FLEXT_SYS == FLEXT_SYS_PD - if((!ticking) && (interval || force)) { - ticking = true; - cb_tick(this); // immediately redraw - } - else { - if(force) clock_delay(tick,0); - isdirty = true; - } + if((!ticking) && (interval || force)) { + ticking = true; + cb_tick(this); // immediately redraw + } + else { + if(force) clock_delay(tick,0); + isdirty = true; + } #elif FLEXT_SYS == FLEXT_SYS_MAX - if(sym->s_thing) { - _buffer *p = (_buffer *)sym->s_thing; - - if(NOGOOD(p)) { - post("buffer: buffer object '%s' no good",sym->s_name); - } - else { - p->b_modtime = gettime(); - } - } - else { - FLEXT_LOG1("buffer: symbol '%s' not defined",sym->s_name); - } + if(sym->s_thing) { + _buffer *p = (_buffer *)sym->s_thing; + + if(NOGOOD(p)) { + post("buffer: buffer object '%s' no good",sym->s_name); + } + else { + p->b_modtime = gettime(); + } + } + else { + FLEXT_LOG1("buffer: symbol '%s' not defined",sym->s_name); + } #else #error Not implemented #endif - } + } } #if FLEXT_SYS == FLEXT_SYS_PD void flext::buffer::cb_tick(buffer *b) { - if(b->arr) garray_redraw(b->arr); + if(b->arr) garray_redraw(b->arr); #ifdef FLEXT_DEBUG - else error("buffer: array is NULL"); + else error("buffer: array is NULL"); #endif - if(b->isdirty && b->interval) { - b->isdirty = false; - b->ticking = true; - clock_delay(b->tick,b->interval); - } - else - b->ticking = false; + if(b->isdirty && b->interval) { + b->isdirty = false; + b->ticking = true; + clock_delay(b->tick,b->interval); + } + else + b->ticking = false; } #endif void flext::buffer::ClearDirty() { #if FLEXT_SYS == FLEXT_SYS_PD - cleantime = clock_getlogicaltime(); + cleantime = clock_getlogicaltime(); #elif FLEXT_SYS == FLEXT_SYS_MAX - cleantime = gettime(); + cleantime = gettime(); #else #error Not implemented #endif @@ -306,24 +306,24 @@ void flext::buffer::ClearDirty() bool flext::buffer::IsDirty() const { #if FLEXT_SYS == FLEXT_SYS_PD - if(!arr) return false; - #ifdef FLEXT_PDBUFDIRTYTIME - return isdirty || garray_updatetime(arr) > cleantime; - #else - // Don't know.... (no method in PD judging whether buffer has been changed from outside flext...) - return true; - #endif + if(!arr) return false; + #ifdef FLEXT_PDBUFDIRTYTIME + return isdirty || garray_updatetime(arr) > cleantime; + #else + // Don't know.... (no method in PD judging whether buffer has been changed from outside flext...) + return true; + #endif #elif FLEXT_SYS == FLEXT_SYS_MAX - if(!sym->s_thing) return false; + if(!sym->s_thing) return false; - _buffer *p = (_buffer *)sym->s_thing; + _buffer *p = (_buffer *)sym->s_thing; #ifdef FLEXT_DEBUG - if(NOGOOD(p)) { - post("buffer: buffer object '%s' no good",sym->s_name); - return false; - } + if(NOGOOD(p)) { + post("buffer: buffer object '%s' no good",sym->s_name); + return false; + } #endif - return p->b_modtime > cleantime; + return p->b_modtime > cleantime; #else #error Not implemented #endif diff --git a/externals/grill/flext/source/flcwmax-thr.h b/externals/grill/flext/source/flcwmax-thr.h index 2e883dbe..4167be9f 100755 --- a/externals/grill/flext/source/flcwmax-thr.h +++ b/externals/grill/flext/source/flcwmax-thr.h @@ -18,12 +18,12 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define FLEXT_THREADS /* - old CodeWarrior version (<= 6) don't have sigset_t defined which - is needed for pthreads + old CodeWarrior version (<= 6) don't have sigset_t defined which + is needed for pthreads */ #if defined(__MWERKS__) && (__MWERKS__ == 1) // read __MWERKS__ numbering starts with CW7 - typedef unsigned int sigset_t; - #define _CW_NOPRECOMP // no precompiled headers + typedef unsigned int sigset_t; + #define _CW_NOPRECOMP // no precompiled headers #endif #include "flcwmax.h" diff --git a/externals/grill/flext/source/flcwmax-x-thr.h b/externals/grill/flext/source/flcwmax-x-thr.h index e737ff19..93b78289 100755 --- a/externals/grill/flext/source/flcwmax-x-thr.h +++ b/externals/grill/flext/source/flcwmax-x-thr.h @@ -18,12 +18,12 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define FLEXT_THREADS /* - old CodeWarrior version (<= 6) don't have sigset_t defined which - is needed for pthreads + old CodeWarrior version (<= 6) don't have sigset_t defined which + is needed for pthreads */ #if defined(__MWERKS__) && (__MWERKS__ == 1) // read __MWERKS__ numbering starts with CW7 - typedef unsigned int sigset_t; - #define _CW_NOPRECOMP // no precompiled headers + typedef unsigned int sigset_t; + #define _CW_NOPRECOMP // no precompiled headers #endif #include "flcwmax-x.h" diff --git a/externals/grill/flext/source/flcwmax.h b/externals/grill/flext/source/flcwmax.h index 56fe03c3..4d108e2e 100644 --- a/externals/grill/flext/source/flcwmax.h +++ b/externals/grill/flext/source/flcwmax.h @@ -16,19 +16,19 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define _FLEXT_CW_MAX_H #ifndef __MWERKS__ - #error "This header file is for CodeWarrior only." + #error "This header file is for CodeWarrior only." #endif #define FLEXT_SYS 1 #define FLEXT_USE_SIMD #ifndef _CW_NOPRECOMP - #include + #include #endif #if /*__option(sym) ||*/ !__option(opt_dead_code) - #pragma message("Optimization disabled -> Compiling a debug version (with FLEXT_DEBUG)") - #define FLEXT_DEBUG + #pragma message("Optimization disabled -> Compiling a debug version (with FLEXT_DEBUG)") + #define FLEXT_DEBUG #endif /* #define _LOG */ diff --git a/externals/grill/flext/source/flcwpd-x-thr.h b/externals/grill/flext/source/flcwpd-x-thr.h index 56a193ef..d3075069 100755 --- a/externals/grill/flext/source/flcwpd-x-thr.h +++ b/externals/grill/flext/source/flcwpd-x-thr.h @@ -17,12 +17,12 @@ WARRANTIES, see the file, "license.txt," in this distribution. #if 0 /* - old CodeWarrior version (<= 6) don't have sigset_t defined which - is needed for pthreads + old CodeWarrior version (<= 6) don't have sigset_t defined which + is needed for pthreads */ #if defined(__MWERKS__) && (__MWERKS__ <= 0x6000) - typedef unsigned int sigset_t; - #define _CW_NOPRECOMP // no precompiled headers + typedef unsigned int sigset_t; + #define _CW_NOPRECOMP // no precompiled headers #endif #endif diff --git a/externals/grill/flext/source/flcwpd-x.h b/externals/grill/flext/source/flcwpd-x.h index 3a5087ae..f6b5192b 100755 --- a/externals/grill/flext/source/flcwpd-x.h +++ b/externals/grill/flext/source/flcwpd-x.h @@ -14,7 +14,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define _FLEXT_CW_PD_X_H #ifndef __MWERKS__ - #error "This header file is for CodeWarrior only." + #error "This header file is for CodeWarrior only." #endif #define FLEXT_SYS 2 @@ -24,12 +24,12 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define _POSIX_C_SOURCE #ifndef _CW_NOPRECOMP -// #include -// #include +// #include +// #include #endif #if __option(sym) || !__option(opt_dead_code) - #define FLEXT_DEBUG + #define FLEXT_DEBUG #endif /* #define _LOG */ diff --git a/externals/grill/flext/source/fldefs.h b/externals/grill/flext/source/fldefs.h index f0e37ab8..4f8a4264 100644 --- a/externals/grill/flext/source/fldefs.h +++ b/externals/grill/flext/source/fldefs.h @@ -15,13 +15,13 @@ WARRANTIES, see the file, "license.txt," in this distribution. #ifndef __FLEXT_DEFS_H #define __FLEXT_DEFS_H -/*! \defgroup FLEXT_DEFS Definitions for basic flext functionality - @{ +/*! \defgroup FLEXT_DEFS Definitions for basic flext functionality + @{ */ /*! \brief Switch for compilation of derived virtual classes - \remark These need dynamic type casts (and RTTI, naturally) - \ingroup FLEXT_GLOBALS + \remark These need dynamic type casts (and RTTI, naturally) + \ingroup FLEXT_GLOBALS */ #ifdef FLEXT_VIRT #define FLEXT_CAST dynamic_cast @@ -29,7 +29,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define FLEXT_CAST static_cast #endif -//! @} FLEXT_DEFS +//! @} FLEXT_DEFS #include "fldefs_hdr.h" @@ -38,8 +38,8 @@ WARRANTIES, see the file, "license.txt," in this distribution. // ==================================================================================== -/*! \defgroup FLEXT_D_METHOD Declarations for flext methods - @{ +/*! \defgroup FLEXT_D_METHOD Declarations for flext methods + @{ */ #include "fldefs_methcb.h" @@ -54,9 +54,9 @@ WARRANTIES, see the file, "license.txt," in this distribution. #ifdef FLEXT_ATTRIBUTES -/*! \defgroup FLEXT_D_ATTRIB Attribute definition - \note These have to reside inside the class declaration - @{ +/*! \defgroup FLEXT_D_ATTRIB Attribute definition + \note These have to reside inside the class declaration + @{ */ #include "fldefs_attrcb.h" diff --git a/externals/grill/flext/source/fldefs_attradd.h b/externals/grill/flext/source/fldefs_attradd.h index 50aef3cb..df2f9407 100644 --- a/externals/grill/flext/source/fldefs_attradd.h +++ b/externals/grill/flext/source/fldefs_attradd.h @@ -17,101 +17,101 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define __FLEXT_DEFS_ATTRADD_H -/*! \defgroup FLEXT_D_CADDATTR Announce object attributes at class scope +/*! \defgroup FLEXT_D_CADDATTR Announce object attributes at class scope \ingroup FLEXT_D_ATTRIB - \note These can only be used at class construction time - @{ + \note These can only be used at class construction time + @{ */ //! Add handler for a gettable attribute -#define FLEXT_CADDATTR_GET(CL,NAME,GFUN) \ +#define FLEXT_CADDATTR_GET(CL,NAME,GFUN) \ \ AddAttrib(CL,NAME,(FLEXT_GET_PRE(GFUN)),NULL) //! Add handler for a settable attribute -#define FLEXT_CADDATTR_SET(CL,NAME,SFUN) \ +#define FLEXT_CADDATTR_SET(CL,NAME,SFUN) \ \ AddAttrib(CL,NAME,NULL,(FLEXT_SET_PRE(SFUN))) //! Add handlers for a both get- and settable attribute -#define FLEXT_CADDATTR_VAR(CL,NAME,GFUN,SFUN) \ +#define FLEXT_CADDATTR_VAR(CL,NAME,GFUN,SFUN) \ \ AddAttrib(CL,NAME,(FLEXT_GET_PRE(GFUN)),(FLEXT_SET_PRE(SFUN))) //! Add handlers for a both get- and settable attribute -#define FLEXT_CADDATTR_VAR1(CL,NAME,FUN) \ +#define FLEXT_CADDATTR_VAR1(CL,NAME,FUN) \ \ AddAttrib(CL,NAME,(FLEXT_GET_PRE(FUN)),(FLEXT_SET_PRE(FUN))) //! Add handler for a gettable enum attribute -#define FLEXT_CADDATTR_GET_E(CL,NAME,GFUN) \ +#define FLEXT_CADDATTR_GET_E(CL,NAME,GFUN) \ \ AddAttrib(CL,NAME,(bool (*)(flext_base *,int &))(FLEXT_GET_PRE(GFUN)),NULL) //! Add handler for a settable enum attribute -#define FLEXT_CADDATTR_SET_E(CL,NAME,SFUN) \ +#define FLEXT_CADDATTR_SET_E(CL,NAME,SFUN) \ \ AddAttrib(CL,NAME,NULL,(bool (*)(flext_base *,int &))(FLEXT_SET_PRE(SFUN))) //! Add handlers for a both get- and settable enum attribute -#define FLEXT_CADDATTR_VAR_E(CL,NAME,GFUN,SFUN) \ +#define FLEXT_CADDATTR_VAR_E(CL,NAME,GFUN,SFUN) \ \ AddAttrib(CL,NAME,(bool (*)(flext_base *,int &))(FLEXT_GET_PRE(GFUN)),(bool (*)(flext_base *,int &))(FLEXT_SET_PRE(SFUN))) //! Add handlers for a both get- and settable enum attribute -#define FLEXT_CADDATTR_VAR1_E(CL,NAME,FUN) \ +#define FLEXT_CADDATTR_VAR1_E(CL,NAME,FUN) \ \ AddAttrib(CL,NAME,(bool (*)(flext_base *,int &))(FLEXT_GET_PRE(FUN)),(bool (*)(flext_base *,int &))(FLEXT_SET_PRE(FUN))) //! @} FLEXT_D_CADDATTR -/*! \defgroup FLEXT_D_ADDATTR Announce object attributes +/*! \defgroup FLEXT_D_ADDATTR Announce object attributes \ingroup FLEXT_D_ATTRIB - \note These can only be used at object construction time - \note (in constructor or in Init() function before call to parent's Init()) - @{ + \note These can only be used at object construction time + \note (in constructor or in Init() function before call to parent's Init()) + @{ */ //! Add handler for a gettable attribute -#define FLEXT_ADDATTR_GET(NAME,GFUN) \ +#define FLEXT_ADDATTR_GET(NAME,GFUN) \ \ AddAttrib(NAME,(FLEXT_GET_PRE(GFUN)),NULL) //! Add handler for a settable attribute -#define FLEXT_ADDATTR_SET(NAME,SFUN) \ +#define FLEXT_ADDATTR_SET(NAME,SFUN) \ \ AddAttrib(NAME,NULL,(FLEXT_SET_PRE(SFUN))) //! Add handlers for a both get- and settable attribute -#define FLEXT_ADDATTR_VAR(NAME,GFUN,SFUN) \ +#define FLEXT_ADDATTR_VAR(NAME,GFUN,SFUN) \ \ AddAttrib(NAME,(FLEXT_GET_PRE(GFUN)),(FLEXT_SET_PRE(SFUN))) //! Add handlers for a both get- and settable attribute -#define FLEXT_ADDATTR_VAR1(NAME,FUN) \ +#define FLEXT_ADDATTR_VAR1(NAME,FUN) \ \ AddAttrib(NAME,(FLEXT_GET_PRE(FUN)),(FLEXT_SET_PRE(FUN))) //! Add handler for a gettable enum attribute -#define FLEXT_ADDATTR_GET_E(NAME,GFUN) \ +#define FLEXT_ADDATTR_GET_E(NAME,GFUN) \ \ AddAttrib(NAME,(bool (*)(flext_base *,int &))(FLEXT_GET_PRE(GFUN)),NULL) //! Add handler for a settable enum attribute -#define FLEXT_ADDATTR_SET_E(NAME,SFUN) \ +#define FLEXT_ADDATTR_SET_E(NAME,SFUN) \ \ AddAttrib(NAME,NULL,(bool (*)(flext_base *,int &))(FLEXT_SET_PRE(SFUN))) //! Add handlers for a both get- and settable enum attribute -#define FLEXT_ADDATTR_VAR_E(NAME,GFUN,SFUN) \ +#define FLEXT_ADDATTR_VAR_E(NAME,GFUN,SFUN) \ \ AddAttrib(NAME,(bool (*)(flext_base *,int &))(FLEXT_GET_PRE(GFUN)),(bool (*)(flext_base *,int &))(FLEXT_SET_PRE(SFUN))) //! Add handlers for a both get- and settable enum attribute -#define FLEXT_ADDATTR_VAR1_E(NAME,FUN) \ +#define FLEXT_ADDATTR_VAR1_E(NAME,FUN) \ \ AddAttrib(NAME,(bool (*)(flext_base *,int &))(FLEXT_GET_PRE(FUN)),(bool (*)(flext_base *,int &))(FLEXT_SET_PRE(FUN))) diff --git a/externals/grill/flext/source/fldefs_attrcb.h b/externals/grill/flext/source/fldefs_attrcb.h index cf9aec4c..85625a23 100644 --- a/externals/grill/flext/source/fldefs_attrcb.h +++ b/externals/grill/flext/source/fldefs_attrcb.h @@ -19,14 +19,14 @@ WARRANTIES, see the file, "license.txt," in this distribution. /*! \brief Declare a attribute set function - \internal + \internal */ #define FLEXT_CALLSET_(FUN,TP) \ static bool FLEXT_SET_PRE(FUN)(flext_base *c,TP &arg) \ { FLEXT_CAST(c)->FUN(arg); return true; } /*! \brief Declare a attribute get function - \internal + \internal */ #define FLEXT_CALLGET_(FUN,TP) \ static bool FLEXT_GET_PRE(FUN)(flext_base *c,TP &arg) \ @@ -34,9 +34,9 @@ static bool FLEXT_GET_PRE(FUN)(flext_base *c,TP &arg) \ -/*! \defgroup FLEXT_DA_CALLSET Definition of attribute set handlers +/*! \defgroup FLEXT_DA_CALLSET Definition of attribute set handlers \ingroup FLEXT_D_ATTRIB - @{ + @{ */ //! Declare a set function for a float attribute @@ -75,9 +75,9 @@ static bool FLEXT_SET_PRE(FUN)(flext_base *c,AtomList *&arg) \ //! @} FLEXT_DA_CALLSET -/*! \defgroup FLEXT_DA_CALLGET Definition of attribute get handlers +/*! \defgroup FLEXT_DA_CALLGET Definition of attribute get handlers \ingroup FLEXT_D_ATTRIB - @{ + @{ */ //! Declare a get function for a float attribute @@ -117,9 +117,9 @@ static bool FLEXT_GET_PRE(FUN)(flext_base *c,AtomList *&arg) \ //! @} FLEXT_DA_CALLGET -/*! \defgroup FLEXT_DA_CALLVAR Definition of attribute transfer handlers (both get and set) +/*! \defgroup FLEXT_DA_CALLVAR Definition of attribute transfer handlers (both get and set) \ingroup FLEXT_D_ATTRIB - @{ + @{ */ //! Declare both get and set functions for a float attribute diff --git a/externals/grill/flext/source/fldefs_attrvar.h b/externals/grill/flext/source/fldefs_attrvar.h index c63fbb35..7f7db5ef 100644 --- a/externals/grill/flext/source/fldefs_attrvar.h +++ b/externals/grill/flext/source/fldefs_attrvar.h @@ -18,14 +18,14 @@ WARRANTIES, see the file, "license.txt," in this distribution. /*! \brief Declare an implicit attribute set function - \internal + \internal */ #define FLEXT_ATTRSET_(VAR,TP) \ static bool FLEXT_SET_PRE(VAR)(flext_base *c,TP &arg) \ { FLEXT_CAST(c)->VAR = arg; return true; } /*! \brief Declare an implicit attribute get function - \internal + \internal */ #define FLEXT_ATTRGET_(VAR,TP) \ static bool FLEXT_GET_PRE(VAR)(flext_base *c,TP &arg) \ @@ -33,9 +33,9 @@ static bool FLEXT_GET_PRE(VAR)(flext_base *c,TP &arg) \ -/*! \defgroup FLEXT_DA_ATTRSET Definition of implicit attribute set handlers +/*! \defgroup FLEXT_DA_ATTRSET Definition of implicit attribute set handlers \ingroup FLEXT_D_ATTRIB - @{ + @{ */ //! Declare an implicit set function for a float attribute @@ -74,9 +74,9 @@ static bool FLEXT_SET_PRE(VAR)(flext_base *c,AtomList *&arg) \ //! @} FLEXT_DA_ATTRSET -/*! \defgroup FLEXT_DA_ATTRGET Definition of implicit attribute get handlers +/*! \defgroup FLEXT_DA_ATTRGET Definition of implicit attribute get handlers \ingroup FLEXT_D_ATTRIB - @{ + @{ */ //! Declare an implicit get function for a float attribute @@ -116,9 +116,9 @@ static bool FLEXT_GET_PRE(VAR)(flext_base *c,AtomList *&arg) \ //! @} FLEXT_DA_ATTRGET -/*! \defgroup FLEXT_DA_ATTRVAR Definition of implicit attribute transfer handlers (both get and set) +/*! \defgroup FLEXT_DA_ATTRVAR Definition of implicit attribute transfer handlers (both get and set) \ingroup FLEXT_D_ATTRIB - @{ + @{ */ //! Declare both implicit get and set functions for a float attribute diff --git a/externals/grill/flext/source/fldefs_methadd.h b/externals/grill/flext/source/fldefs_methadd.h index e9cb93d4..562b72e3 100644 --- a/externals/grill/flext/source/fldefs_methadd.h +++ b/externals/grill/flext/source/fldefs_methadd.h @@ -17,25 +17,25 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define __FLEXT_DEFS_METHADD_H -/*! \defgroup FLEXT_D_CADDMETHOD Add flext methods within class scope +/*! \defgroup FLEXT_D_CADDMETHOD Add flext methods within class scope \ingroup FLEXT_D_METHOD - \note These can only be used at class construction time - @{ + \note These can only be used at class construction time + @{ */ //! Add a method handler for bang #define FLEXT_CADDBANG(CL,IX,M_FUN) \ \ -AddMethod(CL,IX,"bang",FLEXT_CALL_PRE(M_FUN)) +AddMethod(CL,IX,"bang",FLEXT_CALL_PRE(M_FUN)) //! Add a handler for a method with either no, list or anything arguments #define FLEXT_CADDMETHOD(CL,IX,M_FUN) \ -AddMethod(CL,IX,FLEXT_CALL_PRE(M_FUN)) +AddMethod(CL,IX,FLEXT_CALL_PRE(M_FUN)) //! Add a a handler for a method with implicit arguments #define FLEXT_CADDMETHOD_(CL,IX,M_TAG,M_FUN) \ \ -AddMethod(CL,IX,M_TAG,FLEXT_CALL_PRE(M_FUN)) +AddMethod(CL,IX,M_TAG,FLEXT_CALL_PRE(M_FUN)) //! Add a handler for a method with 1 enum type argument #define FLEXT_CADDMETHOD_E(CL,IX,M_TAG,M_FUN) \ @@ -45,7 +45,7 @@ AddMethod(ClMeths(CL),IX,M_TAG,(methfun)(FLEXT_CALL_PRE(M_FUN)),a_int,a_null) //! Add a handler for a method with 1 argument #define FLEXT_CADDMETHOD_1(CL,IX,M_TAG,M_FUN,TP1) \ \ -AddMethod(ClMeths(CL),IX,M_TAG,(methfun)(FLEXT_CALL_PRE(M_FUN)),FLEXTARG(TP1),a_null) +AddMethod(ClMeths(CL),IX,M_TAG,(methfun)(FLEXT_CALL_PRE(M_FUN)),FLEXTARG(TP1),a_null) //! Add a handler for a method with 2 arguments #define FLEXT_CADDMETHOD_2(CL,IX,M_TAG,M_FUN,TP1,TP2) \ @@ -68,7 +68,7 @@ AddMethod(ClMeths(CL),IX,M_TAG,(methfun)(FLEXT_CALL_PRE(M_FUN)),FLEXTARG(TP1),FL AddMethod(ClMeths(CL),IX,M_TAG,(methfun)(FLEXT_CALL_PRE(M_FUN)),FLEXTARG(TP1),FLEXTARG(TP2),FLEXTARG(TP3),FLEXTARG(TP4),FLEXTARG(TP5),a_null) -// Shortcuts +// Shortcuts //! Add a handler for a method with a boolean argument #define FLEXT_CADDMETHOD_B(CL,IX,M_TAG,M_FUN) \ @@ -108,11 +108,11 @@ FLEXT_CADDMETHOD_3(CL,IX,M_TAG,M_FUN,int,int,int) //! @} FLEXT_D_CADDMETHOD -/*! \defgroup FLEXT_D_ADDMETHOD Add flext methods +/*! \defgroup FLEXT_D_ADDMETHOD Add flext methods \ingroup FLEXT_D_METHOD - \note These can only be used at object construction time - \note (in constructor or in Init() function before call to parent's Init()) - @{ + \note These can only be used at object construction time + \note (in constructor or in Init() function before call to parent's Init()) + @{ */ //! Set timer callback @@ -123,37 +123,37 @@ TMR.SetCallback(*this,FLEXT_CALL_PRE(M_FUN)) //! Enable list element distribution over inlets (if no better handler found) #define FLEXT_ADDDIST() \ \ -SetDist(true) +SetDist(true) //! Add a method handler for bang #define FLEXT_ADDBANG(IX,M_FUN) \ \ -AddMethod(IX,"bang",FLEXT_CALL_PRE(M_FUN)) +AddMethod(IX,"bang",FLEXT_CALL_PRE(M_FUN)) //! Add a handler for a method with either no, list or anything arguments #define FLEXT_ADDMETHOD(IX,M_FUN) \ -AddMethod(IX,FLEXT_CALL_PRE(M_FUN)) +AddMethod(IX,FLEXT_CALL_PRE(M_FUN)) /*! \brief Add a handler for a method with a (variable argument) list - \deprecated This definition obscures that _ indicates the usage of a message tag - use FLEXT_ADDMETHOD instead - \note This is already covered by FLEXT_ADDMETHOD, but here for the sake of clarity + \deprecated This definition obscures that _ indicates the usage of a message tag - use FLEXT_ADDMETHOD instead + \note This is already covered by FLEXT_ADDMETHOD, but here for the sake of clarity */ #define FLEXT_ADDMETHOD_V(IX,M_FUN) \ \ -AddMethod(IX,FLEXT_CALL_PRE(M_FUN)) +AddMethod(IX,FLEXT_CALL_PRE(M_FUN)) /*! \brief Add a handler for a method with an anything argument - \deprecated This definition obscures that _ indicates the usage of a message tag - use FLEXT_ADDMETHOD instead - \note This is already covered by FLEXT_ADDMETHOD, but here for the sake of clarity + \deprecated This definition obscures that _ indicates the usage of a message tag - use FLEXT_ADDMETHOD instead + \note This is already covered by FLEXT_ADDMETHOD, but here for the sake of clarity */ #define FLEXT_ADDMETHOD_A(IX,M_FUN) \ \ -AddMethod(IX,FLEXT_CALL_PRE(M_FUN)) +AddMethod(IX,FLEXT_CALL_PRE(M_FUN)) //! Add a a handler for a tagged method with implicit arguments #define FLEXT_ADDMETHOD_(IX,M_TAG,M_FUN) \ \ -AddMethod(IX,M_TAG,FLEXT_CALL_PRE(M_FUN)) +AddMethod(IX,M_TAG,FLEXT_CALL_PRE(M_FUN)) //! Add a handler for a method with 1 enum type argument #define FLEXT_ADDMETHOD_E(IX,M_TAG,M_FUN) \ @@ -163,7 +163,7 @@ AddMethod(ThMeths(),IX,M_TAG,(methfun)(FLEXT_CALL_PRE(M_FUN)),a_int,a_null) //! Add a handler for a method with 1 argument #define FLEXT_ADDMETHOD_1(IX,M_TAG,M_FUN,TP1) \ \ -AddMethod(ThMeths(),IX,M_TAG,(methfun)(FLEXT_CALL_PRE(M_FUN)),FLEXTARG(TP1),a_null) +AddMethod(ThMeths(),IX,M_TAG,(methfun)(FLEXT_CALL_PRE(M_FUN)),FLEXTARG(TP1),a_null) //! Add a handler for a method with 2 arguments #define FLEXT_ADDMETHOD_2(IX,M_TAG,M_FUN,TP1,TP2) \ @@ -186,7 +186,7 @@ AddMethod(ThMeths(),IX,M_TAG,(methfun)(FLEXT_CALL_PRE(M_FUN)),FLEXTARG(TP1),FLEX AddMethod(ThMeths(),IX,M_TAG,(methfun)(FLEXT_CALL_PRE(M_FUN)),FLEXTARG(TP1),FLEXTARG(TP2),FLEXTARG(TP3),FLEXTARG(TP4),FLEXTARG(TP5),a_null) -// Shortcuts +// Shortcuts //! Add a handler for a method with a boolean argument #define FLEXT_ADDMETHOD_B(IX,M_TAG,M_FUN) \ diff --git a/externals/grill/flext/source/fldefs_methcall.h b/externals/grill/flext/source/fldefs_methcall.h index 8b6e1bde..1c4d30c1 100644 --- a/externals/grill/flext/source/fldefs_methcall.h +++ b/externals/grill/flext/source/fldefs_methcall.h @@ -17,9 +17,9 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define __FLEXT_DEFS_METHCALL_H -/*! \defgroup FLEXT_D_CALLMETHOD Call flext methods manually +/*! \defgroup FLEXT_D_CALLMETHOD Call flext methods manually \ingroup FLEXT_D_METHOD - @{ + @{ */ //! Call a (already defined) method with no arguments diff --git a/externals/grill/flext/source/fldefs_methcb.h b/externals/grill/flext/source/fldefs_methcb.h index 45763f59..929a7929 100644 --- a/externals/grill/flext/source/fldefs_methcb.h +++ b/externals/grill/flext/source/fldefs_methcb.h @@ -17,9 +17,9 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define __FLEXT_DEFS_METHCB_H -/*! \defgroup FLEXT_D_CALLBACK Declare callbacks for class methods +/*! \defgroup FLEXT_D_CALLBACK Declare callbacks for class methods \ingroup FLEXT_D_METHOD - @{ + @{ */ //! Set up a method callback with no arguments @@ -83,7 +83,7 @@ static bool FLEXT_CALL_PRE(M_FUN)(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3,TP { FLEXT_CAST(c)->M_FUN(arg1,arg2,arg3,arg4,arg5); return true; } -// Shortcuts +// Shortcuts //! Set up a method callback for 1 float argument #define FLEXT_CALLBACK_F(M_FUN) \ diff --git a/externals/grill/flext/source/fldefs_setup.h b/externals/grill/flext/source/fldefs_setup.h index 255b18ad..9864c3c9 100644 --- a/externals/grill/flext/source/fldefs_setup.h +++ b/externals/grill/flext/source/fldefs_setup.h @@ -18,7 +18,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. // ==================================================================================== -/*! \defgroup FLEXT_D_INSTANCE Class instantiation +/*! \defgroup FLEXT_D_INSTANCE Class instantiation \note For stand-alone externals (not part of a library) the name of your class \note is of importance! It must be the same as the external (excluded an eventual ~ (tilde)) @@ -32,53 +32,53 @@ WARRANTIES, see the file, "license.txt," in this distribution. */ -/*! \defgroup FLEXT_D_NEW Stand-alone class instantiation - Makes an actual instance of a stand-alone class. +/*! \defgroup FLEXT_D_NEW Stand-alone class instantiation + Makes an actual instance of a stand-alone class. */ -/*! \defgroup FLEXT_D_NEW_DSP Dsp class instantiation - Makes an actual instance of a dsp (aka "tilde") class (with signal processing). +/*! \defgroup FLEXT_D_NEW_DSP Dsp class instantiation + Makes an actual instance of a dsp (aka "tilde") class (with signal processing). */ -/*! \defgroup FLEXT_D_LIB Library class instantiation - Makes an actual instance of a class which is part of an object library (and not stand-alone). +/*! \defgroup FLEXT_D_LIB Library class instantiation + Makes an actual instance of a class which is part of an object library (and not stand-alone). */ -/*! \defgroup FLEXT_D_LIB_DSP Dsp library class instantiation - Makes an actual instance of a dsp (aka "tilde") class with signal processing - which is part of an object library (and not stand-alone). +/*! \defgroup FLEXT_D_LIB_DSP Dsp library class instantiation + Makes an actual instance of a dsp (aka "tilde") class with signal processing + which is part of an object library (and not stand-alone). */ // NO ARGUMENTS // ---------------------------------------- /*! \brief Implementation of a flext class with no arguments - \ingroup FLEXT_D_NEW - \param NAME the object's actual name(s) as a string (like "*", "trigger", "noise~", etc.) - \param NEW_CLASS the object's C++ class name + \ingroup FLEXT_D_NEW + \param NAME the object's actual name(s) as a string (like "*", "trigger", "noise~", etc.) + \param NEW_CLASS the object's C++ class name */ -#define FLEXT_NEW(NAME,NEW_CLASS) \ +#define FLEXT_NEW(NAME,NEW_CLASS) \ \ REAL_NEW(NAME,NEW_CLASS,0,0) /*! \brief Implementation of a flext dsp class with no arguments - \ingroup FLEXT_D_NEW_DSP + \ingroup FLEXT_D_NEW_DSP */ -#define FLEXT_NEW_DSP(NAME,NEW_CLASS) \ +#define FLEXT_NEW_DSP(NAME,NEW_CLASS) \ \ REAL_NEW(NAME,NEW_CLASS,1,0) /*! \brief Implementation of a flext class (part of a library) with no arguments - \ingroup FLEXT_D_LIB + \ingroup FLEXT_D_LIB */ #define FLEXT_LIB(NAME,NEW_CLASS) \ \ REAL_NEW(NAME,NEW_CLASS,0,1) /*! \brief Implementation of a flext dsp class (part of a library) with no arguments - \ingroup FLEXT_D_LIB_DSP + \ingroup FLEXT_D_LIB_DSP */ -#define FLEXT_LIB_DSP(NAME,NEW_CLASS) \ +#define FLEXT_LIB_DSP(NAME,NEW_CLASS) \ \ REAL_NEW(NAME,NEW_CLASS,1,1) @@ -87,30 +87,30 @@ REAL_NEW(NAME,NEW_CLASS,1,1) // ---------------------------------------- /*! \brief Implementation of a flext class with a variable argument list - \ingroup FLEXT_D_NEW + \ingroup FLEXT_D_NEW */ -#define FLEXT_NEW_V(NAME,NEW_CLASS) \ +#define FLEXT_NEW_V(NAME,NEW_CLASS) \ \ REAL_NEW_V(NAME,NEW_CLASS,0,0) \ /*! \brief Implementation of a flext dsp class with a variable argument list - \ingroup FLEXT_D_NEW_DSP + \ingroup FLEXT_D_NEW_DSP */ -#define FLEXT_NEW_DSP_V(NAME,NEW_CLASS) \ +#define FLEXT_NEW_DSP_V(NAME,NEW_CLASS) \ \ REAL_NEW_V(NAME,NEW_CLASS,1,0) \ /*! \brief Implementation of a flext class (part of a library) with a variable argument list - \ingroup FLEXT_D_LIB + \ingroup FLEXT_D_LIB */ -#define FLEXT_LIB_V(NAME,NEW_CLASS) \ +#define FLEXT_LIB_V(NAME,NEW_CLASS) \ \ REAL_NEW_V(NAME,NEW_CLASS, 0,1) /*! \brief Implementation of a flext dsp class (part of a library) with a variable argument list - \ingroup FLEXT_D_LIB_DSP + \ingroup FLEXT_D_LIB_DSP */ -#define FLEXT_LIB_DSP_V(NAME,NEW_CLASS) \ +#define FLEXT_LIB_DSP_V(NAME,NEW_CLASS) \ \ REAL_NEW_V(NAME,NEW_CLASS, 1,1) @@ -119,30 +119,30 @@ REAL_NEW_V(NAME,NEW_CLASS, 1,1) // ---------------------------------------- /*! \brief Implementation of a flext class with one argument - \ingroup FLEXT_D_NEW + \ingroup FLEXT_D_NEW */ -#define FLEXT_NEW_1(NAME,NEW_CLASS, TYPE) \ +#define FLEXT_NEW_1(NAME,NEW_CLASS, TYPE) \ \ REAL_NEW_1(NAME,NEW_CLASS, 0, 0,TYPE) \ /*! \brief Implementation of a flext dsp class with one argument - \ingroup FLEXT_D_NEW_DSP + \ingroup FLEXT_D_NEW_DSP */ -#define FLEXT_NEW_DSP_1(NAME,NEW_CLASS, TYPE) \ +#define FLEXT_NEW_DSP_1(NAME,NEW_CLASS, TYPE) \ \ REAL_NEW_1(NAME,NEW_CLASS, 1, 0,TYPE) \ /*! \brief Implementation of a flext class (part of a library) with one argument - \ingroup FLEXT_D_LIB + \ingroup FLEXT_D_LIB */ #define FLEXT_LIB_1(NAME,NEW_CLASS, TYPE) \ \ REAL_NEW_1(NAME,NEW_CLASS, 0,1,TYPE) /*! \brief Implementation of a flext dsp class (part of a library) with one argument - \ingroup FLEXT_D_LIB_DSP + \ingroup FLEXT_D_LIB_DSP */ -#define FLEXT_LIB_DSP_1(NAME,NEW_CLASS, TYPE) \ +#define FLEXT_LIB_DSP_1(NAME,NEW_CLASS, TYPE) \ \ REAL_NEW_1(NAME,NEW_CLASS, 1,1, TYPE) @@ -151,30 +151,30 @@ REAL_NEW_1(NAME,NEW_CLASS, 1,1, TYPE) // ---------------------------------------- /*! \brief Implementation of a flext class with 2 arguments - \ingroup FLEXT_D_NEW + \ingroup FLEXT_D_NEW */ -#define FLEXT_NEW_2(NAME,NEW_CLASS, TYPE1, TYPE2) \ +#define FLEXT_NEW_2(NAME,NEW_CLASS, TYPE1, TYPE2) \ \ REAL_NEW_2(NAME,NEW_CLASS, 0,0, TYPE1, TYPE2) \ /*! \brief Implementation of a flext dsp class with 2 arguments - \ingroup FLEXT_D_NEW_DSP + \ingroup FLEXT_D_NEW_DSP */ -#define FLEXT_NEW_DSP_2(NAME,NEW_CLASS, TYPE1, TYPE2) \ +#define FLEXT_NEW_DSP_2(NAME,NEW_CLASS, TYPE1, TYPE2) \ \ REAL_NEW_2(NAME,NEW_CLASS, 1,0, TYPE1, TYPE2) \ /*! \brief Implementation of a flext class (part of a library) with 2 arguments - \ingroup FLEXT_D_LIB + \ingroup FLEXT_D_LIB */ -#define FLEXT_LIB_2(NAME,NEW_CLASS, TYPE1, TYPE2) \ +#define FLEXT_LIB_2(NAME,NEW_CLASS, TYPE1, TYPE2) \ \ REAL_NEW_2(NAME,NEW_CLASS, 0,1, TYPE1, TYPE2) /*! \brief Implementation of a flext dsp class (part of a library) with 2 arguments - \ingroup FLEXT_D_LIB_DSP + \ingroup FLEXT_D_LIB_DSP */ -#define FLEXT_LIB_DSP_2(NAME,NEW_CLASS, TYPE1, TYPE2) \ +#define FLEXT_LIB_DSP_2(NAME,NEW_CLASS, TYPE1, TYPE2) \ \ REAL_NEW_2(NAME,NEW_CLASS, 1,1, TYPE1, TYPE2) @@ -183,39 +183,39 @@ REAL_NEW_2(NAME,NEW_CLASS, 1,1, TYPE1, TYPE2) // ---------------------------------------- /*! \brief Implementation of a flext class with 3 arguments - \ingroup FLEXT_D_NEW + \ingroup FLEXT_D_NEW */ #define FLEXT_NEW_3(NAME,NEW_CLASS, TYPE1, TYPE2, TYPE3) \ \ REAL_NEW_3(NAME,NEW_CLASS, 0,0, TYPE1, TYPE2, TYPE3) \ /*! \brief Implementation of a flext dsp class with 3 arguments - \ingroup FLEXT_D_NEW_DSP + \ingroup FLEXT_D_NEW_DSP */ -#define FLEXT_NEW_DSP_3(NAME,NEW_CLASS, TYPE1, TYPE2, TYPE3) \ +#define FLEXT_NEW_DSP_3(NAME,NEW_CLASS, TYPE1, TYPE2, TYPE3) \ \ REAL_NEW_3(NAME,NEW_CLASS, 1,0, TYPE1, TYPE2, TYPE3) \ /*! \brief Implementation of a flext class (part of a library) with 3 arguments - \ingroup FLEXT_D_LIB + \ingroup FLEXT_D_LIB */ -#define FLEXT_LIB_3(NAME,NEW_CLASS, TYPE1, TYPE2, TYPE3) \ +#define FLEXT_LIB_3(NAME,NEW_CLASS, TYPE1, TYPE2, TYPE3) \ \ REAL_NEW_3(NAME,NEW_CLASS, 0,1,TYPE1, TYPE2, TYPE3) /*! \brief Implementation of a flext dsp class (part of a library) with 3 arguments - \ingroup FLEXT_D_LIB_DSP + \ingroup FLEXT_D_LIB_DSP */ -#define FLEXT_LIB_DSP_3(NAME,NEW_CLASS, TYPE1, TYPE2, TYPE3) \ +#define FLEXT_LIB_DSP_3(NAME,NEW_CLASS, TYPE1, TYPE2, TYPE3) \ \ REAL_NEW_3(NAME,NEW_CLASS, 1,1, TYPE1, TYPE2, TYPE3) // deprecated stuff -/*! \defgroup FLEXT_D_DEPRECATED Deprecated definitions - \deprecated - @{ +/*! \defgroup FLEXT_D_DEPRECATED Deprecated definitions + \deprecated + @{ */ #define FLEXT_NEW_G FLEXT_NEW_V @@ -239,22 +239,22 @@ REAL_NEW_3(NAME,NEW_CLASS, 1,1, TYPE1, TYPE2, TYPE3) //! @} FLEXT_D_DEPRECATED -/*! \defgroup FLEXT_D_LIBRARY Definitions for library objects - @{ +/*! \defgroup FLEXT_D_LIBRARY Definitions for library objects + @{ */ /*! \brief Specify that to declare the library itself. - \note If you have a library this is compulsory (to register all the objects of the library) + \note If you have a library this is compulsory (to register all the objects of the library) */ #define FLEXT_LIB_SETUP(NAME,SETUPFUN) REAL_LIB_SETUP(NAME,SETUPFUN) /*! \brief Register an object in the library. - \note This is used in the library setup function + \note This is used in the library setup function */ #define FLEXT_SETUP(cl) REAL_SETUP(cl,0) /*! \brief Register a DSP object in the library. - \note This is used in the library setup function + \note This is used in the library setup function */ #define FLEXT_DSP_SETUP(cl) REAL_SETUP(cl,1) diff --git a/externals/grill/flext/source/fldoxygen.h b/externals/grill/flext/source/fldoxygen.h index 27b000c0..c55859db 100644 --- a/externals/grill/flext/source/fldoxygen.h +++ b/externals/grill/flext/source/fldoxygen.h @@ -2,8 +2,8 @@ #define __FLEXT_DOXYGEN_H /*! \file fldoxygen.h - \brief Doxygen definitions - \remark There is no code in here, just documentation stuff. + \brief Doxygen definitions + \remark There is no code in here, just documentation stuff. */ /*! @@ -110,9 +110,9 @@ With these lines, all the necessary definitions from the flext package have been \verbatim class attr1: - public flext_base + public flext_base { - FLEXT_HEADER(attr1,flext_base) + FLEXT_HEADER(attr1,flext_base) \endverbatim A flext class is simply defined by inheriting from the flext_base (see also \ref FLEXT_CLASS) @@ -121,18 +121,18 @@ Additionally some information has to be added using FLEXT_HEADER (see \ref FLEXT \verbatim public: - // constructor - attr1(); + // constructor + attr1(); \endverbatim Normally the constructor takes the creation arguments of an object. Here there are none. \verbatim protected: - void m_trigger(float f); - - // stored argument - float arg; + void m_trigger(float f); + + // stored argument + float arg; \endverbatim These are methods and data elements for internal class usage. Flext doesn't know about them @@ -140,11 +140,11 @@ as long as they are not registered. \verbatim private: - // callback for method "m_trigger" (with one float argument) - FLEXT_CALLBACK_F(m_trigger); + // callback for method "m_trigger" (with one float argument) + FLEXT_CALLBACK_F(m_trigger); - // define attribute callbacks for variable "arg" (with GET and SET properties) - FLEXT_ATTRVAR_F(arg); + // define attribute callbacks for variable "arg" (with GET and SET properties) + FLEXT_ATTRVAR_F(arg); }; \endverbatim @@ -166,23 +166,23 @@ or a DSP object (see \ref FLEXT_D_NEW_DSP) is created and whether it resides in \verbatim attr1::attr1(): - arg(0) // initialize argument + arg(0) // initialize argument { - // define inlets - AddInAnything(); // first inlet of type anything (index 0) - - // define outlets - AddOutFloat(); // one float outlet (has index 0) + // define inlets + AddInAnything(); // first inlet of type anything (index 0) + + // define outlets + AddOutFloat(); // one float outlet (has index 0) \endverbatim - + Every inlet and outlet that the object shall have has to be registered. This is done with the functions in \ref FLEXT_C_IO_ADD. \verbatim - // register methods - FLEXT_ADDMETHOD(0,m_trigger); // register method (for floats) "m_trigger" for inlet 0 + // register methods + FLEXT_ADDMETHOD(0,m_trigger); // register method (for floats) "m_trigger" for inlet 0 - FLEXT_ADDATTR_VAR1("arg",arg); // register attribute "arg" with variable arg + FLEXT_ADDATTR_VAR1("arg",arg); // register attribute "arg" with variable arg } \endverbatim @@ -195,10 +195,10 @@ used are known beforehand (see \ref FLEXT_D_CADDMETHOD and \ref FLEXT_D_CADDATTR \verbatim void attr1::m_trigger(float f) { - float res = arg+f; - - // output value to outlet - ToOutFloat(0,res); // (0 stands for the outlet index 0) + float res = arg+f; + + // output value to outlet + ToOutFloat(0,res); // (0 stands for the outlet index 0) } \endverbatim diff --git a/externals/grill/flext/source/fldsp.cpp b/externals/grill/flext/source/fldsp.cpp index b8dce7ca..3344f4a1 100644 --- a/externals/grill/flext/source/fldsp.cpp +++ b/externals/grill/flext/source/fldsp.cpp @@ -24,50 +24,50 @@ const t_symbol *flext_dsp::dspsym = MakeSymbol("__flext_dspfun__"); void flext_dsp::Setup(t_classid id) { - t_class *c = getClass(id); + t_class *c = getClass(id); #if FLEXT_SYS == FLEXT_SYS_MAX -// dsp_initclass(); - dsp_initboxclass(); - add_dsp(c,cb_dsp); +// dsp_initclass(); + dsp_initboxclass(); + add_dsp(c,cb_dsp); #elif FLEXT_SYS == FLEXT_SYS_PD - CLASS_MAINSIGNALIN(c,flext_hdr,defsig); // float messages going into the left inlet are converted to signal - add_dsp(c,cb_dsp); - add_method1(c,cb_enable,"enable",A_FLOAT); + CLASS_MAINSIGNALIN(c,flext_hdr,defsig); // float messages going into the left inlet are converted to signal + add_dsp(c,cb_dsp); + add_method1(c,cb_enable,"enable",A_FLOAT); #elif FLEXT_SYS == FLEXT_SYS_JMAX - fts_dsp_declare_function(dspsym,dspmeth); - fts_class_message_varargs(c, fts_s_put, cb_dsp); - fts_class_message_varargs(c, MakeSymbol("enable"), cb_enable); + fts_dsp_declare_function(dspsym,dspmeth); + fts_class_message_varargs(c, fts_s_put, cb_dsp); + fts_class_message_varargs(c, MakeSymbol("enable"), cb_enable); #endif } flext_dsp::FLEXT_CLASSDEF(flext_dsp)(): #if FLEXT_SYS == FLEXT_SYS_JMAX - srate(fts_dsp_get_sample_rate()), // should we set it? - blksz(fts_dsp_get_tick_size()), + srate(fts_dsp_get_sample_rate()), // should we set it? + blksz(fts_dsp_get_tick_size()), #else - srate(sys_getsr()), // should we set it? - blksz(sys_getblksize()), + srate(sys_getsr()), // should we set it? + blksz(sys_getblksize()), #endif #if FLEXT_SYS == FLEXT_SYS_PD - chnsin(sys_get_inchannels()), - chnsout(sys_get_outchannels()), + chnsin(sys_get_inchannels()), + chnsout(sys_get_outchannels()), #elif FLEXT_SYS == FLEXT_SYS_MAX - chnsin(sys_getch()), - chnsout(sys_getch()), + chnsin(sys_getch()), + chnsout(sys_getch()), #elif FLEXT_SYS == FLEXT_SYS_JMAX - #pragma message("not implemented") - chnsin(0),chnsout(0), + #pragma message("not implemented") + chnsin(0),chnsout(0), #else #error #endif #if FLEXT_SYS != FLEXT_SYS_MAX - dspon(true), + dspon(true), #endif - invecs(NULL),outvecs(NULL) + invecs(NULL),outvecs(NULL) { #if FLEXT_SYS == FLEXT_SYS_JMAX - fts_dsp_object_init(thisHdr()); + fts_dsp_object_init(thisHdr()); #endif } @@ -75,18 +75,18 @@ flext_dsp::FLEXT_CLASSDEF(flext_dsp)(): flext_dsp::~FLEXT_CLASSDEF(flext_dsp)() { #if FLEXT_SYS == FLEXT_SYS_JMAX - fts_dsp_object_delete(thisHdr()); + fts_dsp_object_delete(thisHdr()); #endif /* #if FLEXT_SYS == FLEXT_SYS_MAX - // switch off dsp as the dsp function might get called afterwards (?!) - thisHdr()->z_disabled = true; - - if(invecs) delete[] invecs; - if(outvecs) delete[] outvecs; + // switch off dsp as the dsp function might get called afterwards (?!) + thisHdr()->z_disabled = true; + + if(invecs) delete[] invecs; + if(outvecs) delete[] outvecs; #elif FLEXT_SYS == FLEXT_SYS_PD - dspon = false; + dspon = false; #endif */ } @@ -98,23 +98,23 @@ void flext_dsp::dspmeth(fts_word_t *w) #else t_int *flext_dsp::dspmeth(t_int *w) { - flext_dsp *obj = (flext_dsp *)w[1]; + flext_dsp *obj = (flext_dsp *)w[1]; /* #ifdef FLEXT_DEBUG - if(!obj->thisHdr()) { - // object is already deleted! - ERRINTERNAL(); - return w+3; - } + if(!obj->thisHdr()) { + // object is already deleted! + ERRINTERNAL(); + return w+3; + } #endif */ #if FLEXT_SYS == FLEXT_SYS_MAX - if(!obj->thisHdr()->z_disabled) + if(!obj->thisHdr()->z_disabled) #else - if(obj->dspon) + if(obj->dspon) #endif - obj->m_signal(obj->blksz,obj->invecs,obj->outvecs); - return w+2; + obj->m_signal(obj->blksz,obj->invecs,obj->outvecs); + return w+2; } #endif @@ -126,72 +126,72 @@ void flext_dsp::cb_dsp(t_class *c,t_signal **sp,short *count) void flext_dsp::cb_dsp(t_class *c,t_signal **sp) #endif { - flext_dsp *obj = thisObject(c); + flext_dsp *obj = thisObject(c); - if(obj->CntInSig()+obj->CntOutSig() == 0) return; + if(obj->CntInSig()+obj->CntOutSig() == 0) return; - // store current dsp parameters + // store current dsp parameters #if FLEXT_SYS == FLEXT_SYS_JMAX - fts_dsp_descr_t *dsp = (fts_dsp_descr_t *)fts_get_pointer(at+0); - obj->srate = fts_dsp_get_input_srate(dsp,0); - obj->blksz = fts_dsp_get_input_size(dsp,0); // is this guaranteed to be the same as sys_getblksize() ? + fts_dsp_descr_t *dsp = (fts_dsp_descr_t *)fts_get_pointer(at+0); + obj->srate = fts_dsp_get_input_srate(dsp,0); + obj->blksz = fts_dsp_get_input_size(dsp,0); // is this guaranteed to be the same as sys_getblksize() ? #else - obj->srate = sp[0]->s_sr; - obj->blksz = sp[0]->s_n; // is this guaranteed to be the same as sys_getblksize() ? + obj->srate = sp[0]->s_sr; + obj->blksz = sp[0]->s_n; // is this guaranteed to be the same as sys_getblksize() ? #endif /* #if FLEXT_SYS == FLEXT_SYS_PD - obj->chnsin = sys_get_inchannels(); - obj->chnsout = sys_get_outchannels(); + obj->chnsin = sys_get_inchannels(); + obj->chnsout = sys_get_outchannels(); #elif FLEXT_SYS == FLEXT_SYS_MAX - obj->chnsin = obj->chnsout = sys_getch(); + obj->chnsin = obj->chnsout = sys_getch(); #elif FLEXT_SYS == FLEXT_SYS_JMAX - #pragma message ("How to query the channels?") + #pragma message ("How to query the channels?") #else #error #endif */ - // store in and out signal vectors - int i; - int in = obj->chnsin = obj->CntInSig(); - int out = obj->chnsout = obj->CntOutSig(); + // store in and out signal vectors + int i; + int in = obj->chnsin = obj->CntInSig(); + int out = obj->chnsout = obj->CntOutSig(); #if FLEXT_SYS == FLEXT_SYS_PD - // min. 1 input channel! (CLASS_MAININLET in pd...) - if(!in) { obj->chnsin = in = 1; } + // min. 1 input channel! (CLASS_MAININLET in pd...) + if(!in) { obj->chnsin = in = 1; } #endif - if(obj->invecs) delete[] obj->invecs; - obj->invecs = new t_signalvec[in]; - for(i = 0; i < in; ++i) - obj->invecs[i] = + if(obj->invecs) delete[] obj->invecs; + obj->invecs = new t_signalvec[in]; + for(i = 0; i < in; ++i) + obj->invecs[i] = #if FLEXT_SYS == FLEXT_SYS_JMAX - fts_dsp_get_input_name(dsp,i); + fts_dsp_get_input_name(dsp,i); #else - sp[i]->s_vec; + sp[i]->s_vec; #endif - if(obj->outvecs) delete[] obj->outvecs; - obj->outvecs = new t_signalvec[out]; - for(i = 0; i < out; ++i) - obj->outvecs[i] = + if(obj->outvecs) delete[] obj->outvecs; + obj->outvecs = new t_signalvec[out]; + for(i = 0; i < out; ++i) + obj->outvecs[i] = #if FLEXT_SYS == FLEXT_SYS_JMAX - fts_dsp_get_output_name(dsp,i); + fts_dsp_get_output_name(dsp,i); #else - sp[in+i]->s_vec; + sp[in+i]->s_vec; #endif - // with the following call derived classes can do their eventual DSP setup - obj->m_dsp(obj->blksz,obj->invecs,obj->outvecs); + // with the following call derived classes can do their eventual DSP setup + obj->m_dsp(obj->blksz,obj->invecs,obj->outvecs); - // set the DSP function + // set the DSP function #if FLEXT_SYS == FLEXT_SYS_JMAX - fts_atom_t args; - fts_set_pointer(args,obj); - fts_dsp_add_function(dspsym,1,args); + fts_atom_t args; + fts_set_pointer(args,obj); + fts_dsp_add_function(dspsym,1,args); #else - dsp_add((t_dspmethod)dspmeth,1,obj); + dsp_add((t_dspmethod)dspmeth,1,obj); #endif } @@ -199,12 +199,12 @@ void flext_dsp::cb_dsp(t_class *c,t_signal **sp) #if FLEXT_SYS == FLEXT_SYS_JMAX void flext_dsp::cb_dsp_init(fts_object_t *c, int winlet, fts_symbol_t *s, int ac, const fts_atom_t *at) { - fts_dsp_add_object(c); + fts_dsp_add_object(c); } void flext_dsp::cb_dsp_delete(fts_object_t *c, int winlet, fts_symbol_t *s, int ac, const fts_atom_t *at) { - fts_dsp_remove_object(c); + fts_dsp_remove_object(c); } #endif */ @@ -213,7 +213,7 @@ void flext_dsp::m_dsp(int /*n*/,t_signalvec const * /*insigs*/,t_signalvec const void flext_dsp::m_signal(int n,t_sample *const * /*insigs*/,t_sample *const *outs) { - for(int i = 0; i < CntOutSig(); ++i) ZeroSamples(outs[i],n); + for(int i = 0; i < CntOutSig(); ++i) ZeroSamples(outs[i],n); } #if FLEXT_SYS != FLEXT_SYS_MAX diff --git a/externals/grill/flext/source/flext.cpp b/externals/grill/flext/source/flext.cpp index b89e464b..eb3f2a35 100644 --- a/externals/grill/flext/source/flext.cpp +++ b/externals/grill/flext/source/flext.cpp @@ -21,160 +21,160 @@ WARRANTIES, see the file, "license.txt," in this distribution. bool flext_base::compatibility = true; flext_base::FLEXT_CLASSDEF(flext_base)(): - inlist(NULL),outlist(NULL), - curtag(NULL), - incnt(0),outcnt(0), - insigs(0),outsigs(0), - distmsgs(false) + inlist(NULL),outlist(NULL), + curtag(NULL), + incnt(0),outcnt(0), + insigs(0),outsigs(0), + distmsgs(false) #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX - ,outlets(NULL),inlets(NULL) + ,outlets(NULL),inlets(NULL) #endif #if FLEXT_SYS == FLEXT_SYS_MAX - ,indesc(NULL),outdesc(NULL) + ,indesc(NULL),outdesc(NULL) #endif { - FLEXT_LOG1("%s - flext logging is on",thisName()); - - t_classid clid = thisClassId(); - clmethhead = ClMeths(clid); - methhead = new ItemCont; - bindhead = NULL; - - if(procattr) { - // initialize when attribute processing is enabled - attrhead = new ItemCont; - clattrhead = ClAttrs(clid); - attrdata = new AttrDataCont; - } - else { - attrhead = clattrhead = NULL; - attrdata = NULL; - } + FLEXT_LOG1("%s - flext logging is on",thisName()); + + t_classid clid = thisClassId(); + clmethhead = ClMeths(clid); + methhead = new ItemCont; + bindhead = NULL; + + if(procattr) { + // initialize when attribute processing is enabled + attrhead = new ItemCont; + clattrhead = ClAttrs(clid); + attrdata = new AttrDataCont; + } + else { + attrhead = clattrhead = NULL; + attrdata = NULL; + } } flext_base::~FLEXT_CLASSDEF(flext_base)() { #if FLEXT_SYS == FLEXT_SYS_MAX // according to David Z. one should do that first... -// if(insigs) dsp_free(thisHdr()); - if(insigs) dsp_freebox(thisHdr()); +// if(insigs) dsp_free(thisHdr()); + if(insigs) dsp_freebox(thisHdr()); #endif #ifdef FLEXT_THREADS - StopThreads(); + StopThreads(); #endif - // send remaining pending messages for this object - QFlush(this); + // send remaining pending messages for this object + QFlush(this); - // delete message lists - if(methhead) delete methhead; - if(bindhead) delete bindhead; // ATTENTION: the object must free all memory associated to bindings itself - if(attrhead) delete attrhead; - if(attrdata) delete attrdata; - - // destroy inlets and outlets and their proxy objects - if(inlist) delete inlist; - if(outlist) delete outlist; + // delete message lists + if(methhead) delete methhead; + if(bindhead) delete bindhead; // ATTENTION: the object must free all memory associated to bindings itself + if(attrhead) delete attrhead; + if(attrdata) delete attrdata; + + // destroy inlets and outlets and their proxy objects + if(inlist) delete inlist; + if(outlist) delete outlist; #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX - if(outlets) delete[] outlets; + if(outlets) delete[] outlets; - if(inlets) { - for(int ix = 0; ix < incnt; ++ix) - if(inlets[ix]) { - // release proxy object + if(inlets) { + for(int ix = 0; ix < incnt; ++ix) + if(inlets[ix]) { + // release proxy object #if FLEXT_SYS == FLEXT_SYS_PD - pd_free(&inlets[ix]->obj.ob_pd); + pd_free(&inlets[ix]->obj.ob_pd); #elif FLEXT_SYS == FLEXT_SYS_MAX - freeobject((object *)inlets[ix]); + freeobject((object *)inlets[ix]); #endif - } - delete[] inlets; - } + } + delete[] inlets; + } #endif #if FLEXT_SYS == FLEXT_SYS_MAX - if(indesc) { - for(int i = 0; i < incnt; ++i) if(indesc[i]) delete[] indesc[i]; - delete[] indesc; - } - if(outdesc) { - for(int i = 0; i < outcnt; ++i) if(outdesc[i]) delete[] outdesc[i]; - delete[] outdesc; - } + if(indesc) { + for(int i = 0; i < incnt; ++i) if(indesc[i]) delete[] indesc[i]; + delete[] indesc; + } + if(outdesc) { + for(int i = 0; i < outcnt; ++i) if(outdesc[i]) delete[] outdesc[i]; + delete[] outdesc; + } #endif } /*! This virtual function is called after the object has been created, that is, - after the constructor has been processed. - It creates the inlets and outlets and the message and attribute lists. - \note You can override it in your own class, but be sure to call it, - \note otherwise no inlets/outlets will be created - \note All inlet, outlets, method and attribute declarations must be made before a call to Init! - \remark Creation of inlets/outlets can't be done upon declaration, as Max/MSP needs creation - \remark in reverse. + after the constructor has been processed. + It creates the inlets and outlets and the message and attribute lists. + \note You can override it in your own class, but be sure to call it, + \note otherwise no inlets/outlets will be created + \note All inlet, outlets, method and attribute declarations must be made before a call to Init! + \remark Creation of inlets/outlets can't be done upon declaration, as Max/MSP needs creation + \remark in reverse. */ bool flext_base::Init() { - bool ok = flext_obj::Init(); + bool ok = flext_obj::Init(); - if(ok) ok = InitInlets() && InitOutlets(); + if(ok) ok = InitInlets() && InitOutlets(); - if(ok) { - if(procattr && m_holdaargc && m_holdaargv) { - // initialize creation attributes - ok = InitAttrib(m_holdaargc,m_holdaargv); - } - } + if(ok) { + if(procattr && m_holdaargc && m_holdaargv) { + // initialize creation attributes + ok = InitAttrib(m_holdaargc,m_holdaargv); + } + } - return ok; + return ok; } /*! Set up proxy classes and basic methods at class creation time - This ensures that they are processed before the registered flext messages + This ensures that they are processed before the registered flext messages */ void flext_base::Setup(t_classid id) { - t_class *c = getClass(id); + t_class *c = getClass(id); #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX - add_method(c,cb_help,"help"); - add_loadbang(c,cb_loadbang); + add_method(c,cb_help,"help"); + add_loadbang(c,cb_loadbang); #if FLEXT_SYS == FLEXT_SYS_MAX - add_assist(c,cb_assist); + add_assist(c,cb_assist); #endif #else - fts_class_message_varargs(c,MakeSymbol("help"),cb_help); - #pragma message ("no implementation of loadbang or assist") + fts_class_message_varargs(c,MakeSymbol("help"),cb_help); + #pragma message ("no implementation of loadbang or assist") #endif - if(process_attributes) { - AddMethod(id,0,"getattributes",cb_ListAttrib); - AddMethod(id,0,"getmethods",cb_ListMethods); + if(process_attributes) { + AddMethod(id,0,"getattributes",cb_ListAttrib); + AddMethod(id,0,"getmethods",cb_ListMethods); #if FLEXT_SYS == FLEXT_SYS_PD && !defined(FLEXT_NOATTREDIT) - AddMethod(id,0,"attributedialog",cb_AttrDialog); - SetAttrEditor(id); + AddMethod(id,0,"attributedialog",cb_AttrDialog); + SetAttrEditor(id); #endif - } + } - SetProxies(c); + SetProxies(c); - StartQueue(); + StartQueue(); } #if FLEXT_SYS == FLEXT_SYS_JMAX -void flext_base::cb_help(fts_object_t *c,int, fts_symbol_t, int, const fts_atom_t *) { thisObject(c)->m_help(); } +void flext_base::cb_help(fts_object_t *c,int, fts_symbol_t, int, const fts_atom_t *) { thisObject(c)->m_help(); } #else -void flext_base::cb_help(t_class *c) { thisObject(c)->m_help(); } -void flext_base::cb_loadbang(t_class *c) { thisObject(c)->m_loadbang(); } +void flext_base::cb_help(t_class *c) { thisObject(c)->m_help(); } +void flext_base::cb_loadbang(t_class *c) { thisObject(c)->m_loadbang(); } #endif void flext_base::m_help() { - // This should better be overloaded - post("%s (using flext " FLEXT_VERSTR ") - compiled on %s %s",thisName(),__DATE__,__TIME__); + // This should better be overloaded + post("%s (using flext " FLEXT_VERSTR ") - compiled on %s %s",thisName(),__DATE__,__TIME__); } void flext_base::m_loadbang() {} @@ -186,16 +186,16 @@ void flext_base::cb_assist(t_class *c,void * /*b*/,long msg,long arg,char *s) { void flext_base::m_assist(long msg,long arg,char *s) { #if FLEXT_SYS == FLEXT_SYS_MAX - switch(msg) { - case 1: //ASSIST_INLET: - strcpy(s,arg < incnt && indesc[arg]?indesc[arg]:""); - break; - case 2: //ASSIST_OUTLET: - if(arg < outcnt) - strcpy(s,outdesc[arg]?outdesc[arg]:""); - else - strcpy(s,arg == outcnt && procattr?"Attributes":""); - break; - } + switch(msg) { + case 1: //ASSIST_INLET: + strcpy(s,arg < incnt && indesc[arg]?indesc[arg]:""); + break; + case 2: //ASSIST_OUTLET: + if(arg < outcnt) + strcpy(s,outdesc[arg]?outdesc[arg]:""); + else + strcpy(s,arg == outcnt && procattr?"Attributes":""); + break; + } #endif } diff --git a/externals/grill/flext/source/flext.h b/externals/grill/flext/source/flext.h index 4f4f166c..41996a0d 100644 --- a/externals/grill/flext/source/flext.h +++ b/externals/grill/flext/source/flext.h @@ -23,10 +23,10 @@ WARRANTIES, see the file, "license.txt," in this distribution. */ //! \brief flext version number -#define FLEXT_VERSION 406 +#define FLEXT_VERSION 407 //! \brief flext version string -#define FLEXT_VERSTR "0.4.6" +#define FLEXT_VERSTR "0.4.7pre" //! @} diff --git a/externals/grill/flext/source/flinternal.h b/externals/grill/flext/source/flinternal.h index 29887f8e..0bdc3bf6 100644 --- a/externals/grill/flext/source/flinternal.h +++ b/externals/grill/flext/source/flinternal.h @@ -10,10 +10,10 @@ WARRANTIES, see the file, "license.txt," in this distribution. /*! \file flinternal.h \brief Definitions for internal flext usage - \internal + \internal Here, a few shortcuts for common Max/MSP or PD library calls and type definitions - are declared + are declared */ #ifndef __FLEXT_INTERNALS_H @@ -26,7 +26,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define object_new(clss) pd_new(clss) #define object_free(obj) pd_free(&(obj)->ob_pd) - + #define add_dsp(clss,meth) class_addmethod(clss, (t_method)meth,gensym("dsp"),A_NULL) diff --git a/externals/grill/flext/source/flitem.cpp b/externals/grill/flext/source/flitem.cpp index c8697279..8970e1c3 100755 --- a/externals/grill/flext/source/flitem.cpp +++ b/externals/grill/flext/source/flitem.cpp @@ -18,57 +18,57 @@ WARRANTIES, see the file, "license.txt," in this distribution. flext_base::Item::~Item() { - if(nxt) delete nxt; + if(nxt) delete nxt; } flext_base::ItemSet::ItemSet() {} flext_base::ItemSet::~ItemSet() { - for(iterator it = begin(); it != end(); ++it) - if(it.data()) delete it.data(); + for(iterator it = begin(); it != end(); ++it) + if(it.data()) delete it.data(); } flext_base::ItemCont::ItemCont(): - memsize(0),size(0),members(0),cont(NULL) + memsize(0),size(0),members(0),cont(NULL) {} flext_base::ItemCont::~ItemCont() { - if(cont) { - for(int i = 0; i < size; ++i) delete cont[i]; - delete[] cont; - } + if(cont) { + for(int i = 0; i < size; ++i) delete cont[i]; + delete[] cont; + } } void flext_base::ItemCont::Resize(int nsz) { - if(nsz > memsize) { - int nmemsz = nsz+10; // increment maximum allocation size - ItemSet **ncont = new ItemSet *[nmemsz]; // make new array - if(cont) { - memcpy(ncont,cont,size*sizeof(*cont)); // copy existing entries - delete[] cont; - } - cont = ncont; // set current array - memsize = nmemsz; // set new allocation size - } - - // make new items - while(size < nsz) cont[size++] = new ItemSet; + if(nsz > memsize) { + int nmemsz = nsz+10; // increment maximum allocation size + ItemSet **ncont = new ItemSet *[nmemsz]; // make new array + if(cont) { + memcpy(ncont,cont,size*sizeof(*cont)); // copy existing entries + delete[] cont; + } + cont = ncont; // set current array + memsize = nmemsz; // set new allocation size + } + + // make new items + while(size < nsz) cont[size++] = new ItemSet; } void flext_base::ItemCont::Add(Item *item,const t_symbol *tag,int inlet) { if(!Contained(inlet)) Resize(inlet+2); ItemSet &set = GetInlet(inlet); - Item *&lst = set[tag]; - if(!lst) - lst = item; - else - for(;;) - if(!lst->nxt) { lst->nxt = item; break; } - else lst = lst->nxt; + Item *&lst = set[tag]; + if(!lst) + lst = item; + else + for(;;) + if(!lst->nxt) { lst->nxt = item; break; } + else lst = lst->nxt; members++; } @@ -80,9 +80,9 @@ bool flext_base::ItemCont::Remove(Item *item,const t_symbol *tag,int inlet) if(it != set.end()) { for(Item *lit = it.data(),*prv = NULL; lit; prv = lit,lit = lit->nxt) { if(lit == item) { - if(prv) prv->nxt = lit->nxt; - else it.data() = lit->nxt; - + if(prv) prv->nxt = lit->nxt; + else it.data() = lit->nxt; + lit->nxt = NULL; delete lit; return true; } diff --git a/externals/grill/flext/source/fllib.cpp b/externals/grill/flext/source/fllib.cpp index 203f4aa9..f9d2f84b 100755 --- a/externals/grill/flext/source/fllib.cpp +++ b/externals/grill/flext/source/fllib.cpp @@ -170,7 +170,19 @@ void flext_obj::lib_init(const char *name,void setupfun(),bool attr) sizeof(flext_hdr),NULL,A_GIMME,A_NULL); #endif process_attributes = attr; - setupfun(); + + try { + setupfun(); + } + catch(std::exception &x) { + error("%s - Exception at library setup: %s",name,x.what()); + } + catch(const char *txt) { + error("%s - Exception at library setup: %s",name,txt); + } + catch(...) { + error("%s - Unknown exception at library setup",name); + } } #if FLEXT_SYS == FLEXT_SYS_JMAX @@ -287,8 +299,19 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha #endif } - // call class setup function - setupfun(clid); + try { + // call class setup function + setupfun(clid); + } + catch(std::exception &x) { + error("%s - Exception while initializing class: %s",idname,x.what()); + } + catch(const char *txt) { + error("%s - Exception while initializing class: %s",idname,txt); + } + catch(...) { + error("%s - Unknown exception while initializing class",idname); + } } @@ -370,65 +393,81 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) error("%s: Creation arguments do not match",GetString(s)); } + if(ok) { - t_classid clid; + try { + t_classid clid; #if FLEXT_SYS == FLEXT_SYS_PD - clid = lo->clss; - obj = (flext_hdr *)::pd_new(lo->clss); + clid = lo->clss; + obj = (flext_hdr *)::pd_new(lo->clss); #elif FLEXT_SYS == FLEXT_SYS_MAX - clid = lo; - obj = (flext_hdr *)::newobject(lo->clss); + clid = lo; + obj = (flext_hdr *)::newobject(lo->clss); #elif FLEXT_SYS == FLEXT_SYS_JMAX - clid = lo->clss; + clid = lo->clss; #else #error #endif - flext_obj::m_holder = obj; - flext_obj::m_holdname = s; - flext_obj::m_holdattr = lo->attr; - - // get actual flext object (newfun calls "new flext_obj()") - if(lo->argc >= 0) - obj->data = lo->newfun(lo->argc,args); - else - obj->data = lo->newfun(argc,argv); - - flext_obj::m_holder = NULL; - flext_obj::m_holdname = NULL; - flext_obj::m_holdattr = false; - - ok = obj->data && - // check constructor exit flag - obj->data->InitOk(); - - if(ok) { - if(lo->attr) { - // DON'T convert eventual patcher args here... this is done by the actual attribute stuff - // so that the initial $- or #- be preserved! - - // store creation args for attribute initialization (inside flext_base::Init()) - flext_obj::m_holdaargc = _argc_-argc; - flext_obj::m_holdaargv = argv+argc; - } - else { - flext_obj::m_holdaargc = 0; - flext_obj::m_holdaargv = NULL; - } - - // call virtual init function - // here, inlets, outlets, methods and attributes can be set up - ok = obj->data->Init(); - - // call another virtual init function - if(ok) ok = obj->data->Finalize(); - - flext_obj::m_holdaargc = 0; - flext_obj::m_holdaargv = NULL; - } - - if(!ok) { + flext_obj::m_holder = obj; + flext_obj::m_holdname = s; + flext_obj::m_holdattr = lo->attr; + + // get actual flext object (newfun calls "new flext_obj()") + if(lo->argc >= 0) + obj->data = lo->newfun(lo->argc,args); + else + obj->data = lo->newfun(argc,argv); + + flext_obj::m_holder = NULL; + flext_obj::m_holdname = NULL; + flext_obj::m_holdattr = false; + + ok = obj->data && + // check constructor exit flag + obj->data->InitOk(); + + if(ok) { + if(lo->attr) { + // DON'T convert eventual patcher args here... this is done by the actual attribute stuff + // so that the initial $- or #- be preserved! + + // store creation args for attribute initialization (inside flext_base::Init()) + flext_obj::m_holdaargc = _argc_-argc; + flext_obj::m_holdaargv = argv+argc; + } + else { + flext_obj::m_holdaargc = 0; + flext_obj::m_holdaargv = NULL; + } + + // call virtual init function + // here, inlets, outlets, methods and attributes can be set up + ok = obj->data->Init(); + + // call another virtual init function + if(ok) ok = obj->data->Finalize(); + + flext_obj::m_holdaargc = 0; + flext_obj::m_holdaargv = NULL; + } + + } //try + catch(std::exception &x) { + error("%s - Exception while creating object: %s",GetString(s),x.what()); + ok = false; + } + catch(const char *txt) { + error("%s - Exception while creating object: %s",GetString(s),txt); + ok = false; + } + catch(...) { + error("%s - Unknown exception while creating object",GetString(s)); + ok = false; + } + + if(!ok) { // there was some init error, free object lo->freefun(obj); obj = NULL; @@ -460,11 +499,22 @@ void flext_obj::obj_free(flext_hdr *h) libclass *lcl = FindName(name); if(lcl) { - // call virtual exit function - hdr->data->Exit(); - - // now call object destructor and deallocate - lcl->freefun(hdr); + try { + // call virtual exit function + hdr->data->Exit(); + + // now call object destructor and deallocate + lcl->freefun(hdr); + } //try + catch(std::exception &x) { + error("%s - Exception while destroying object: %s",GetString(name),x.what()); + } + catch(const char *txt) { + error("%s - Exception while destroying object: %s",GetString(name),txt); + } + catch(...) { + error("%s - Unknown exception while destroying object",GetString(name)); + } } #ifdef FLEXT_DEBUG else diff --git a/externals/grill/flext/source/flmeth.cpp b/externals/grill/flext/source/flmeth.cpp index 776461dd..21e15f5c 100755 --- a/externals/grill/flext/source/flmeth.cpp +++ b/externals/grill/flext/source/flmeth.cpp @@ -21,125 +21,125 @@ WARRANTIES, see the file, "license.txt," in this distribution. flext_base::MethItem::MethItem(AttrItem *conn): - Item(conn),index(0), - argc(0),args(NULL) - ,fun(NULL) + Item(conn),index(0), + argc(0),args(NULL) + ,fun(NULL) {} flext_base::MethItem::~MethItem() { - if(args) delete[] args; + if(args) delete[] args; } void flext_base::MethItem::SetArgs(methfun _fun,int _argc,metharg *_args) { - fun = _fun; - if(args) delete[] args; - argc = _argc,args = _args; + fun = _fun; + if(args) delete[] args; + argc = _argc,args = _args; } void flext_base::AddMethodDef(int inlet,const char *tag) { const t_symbol *t = tag?MakeSymbol(tag):NULL; - methhead->Add(new MethItem,t,inlet); + methhead->Add(new MethItem,t,inlet); } /*! \brief Add a method to the queue */ void flext_base::AddMethod(ItemCont *ma,int inlet,const char *tag,methfun fun,metharg tp,...) { - va_list marker; - - // at first just count the arg type list (in argc) - int argc = 0; - va_start(marker,tp); - metharg *args = NULL,arg = tp; - for(; arg != a_null; ++argc) arg = (metharg)va_arg(marker,int); //metharg); - va_end(marker); - - if(argc > 0) { - if(argc > FLEXT_MAXMETHARGS) { - error("flext - method %s: only %i arguments are type-checkable: use variable argument list for more",tag?tag:"?",FLEXT_MAXMETHARGS); - argc = FLEXT_MAXMETHARGS; - } - - args = new metharg[argc]; - - va_start(marker,tp); - metharg a = tp; - for(int ix = 0; ix < argc; ++ix) { + va_list marker; + + // at first just count the arg type list (in argc) + int argc = 0; + va_start(marker,tp); + metharg *args = NULL,arg = tp; + for(; arg != a_null; ++argc) arg = (metharg)va_arg(marker,int); //metharg); + va_end(marker); + + if(argc > 0) { + if(argc > FLEXT_MAXMETHARGS) { + error("flext - method %s: only %i arguments are type-checkable: use variable argument list for more",tag?tag:"?",FLEXT_MAXMETHARGS); + argc = FLEXT_MAXMETHARGS; + } + + args = new metharg[argc]; + + va_start(marker,tp); + metharg a = tp; + for(int ix = 0; ix < argc; ++ix) { #ifdef FLEXT_DEBUG - if(a == a_list && ix > 0) { - ERRINTERNAL(); - } + if(a == a_list && ix > 0) { + ERRINTERNAL(); + } #endif #if FLEXT_SYS == FLEXT_SYS_PD - if(a == a_pointer && flext_base::compatibility) { - post("Pointer arguments are not allowed in compatibility mode"); - } + if(a == a_pointer && flext_base::compatibility) { + post("Pointer arguments are not allowed in compatibility mode"); + } #endif - args[ix] = a; - a = (metharg)va_arg(marker,int); //metharg); - } - va_end(marker); - } - - MethItem *mi = new MethItem; + args[ix] = a; + a = (metharg)va_arg(marker,int); //metharg); + } + va_end(marker); + } + + MethItem *mi = new MethItem; mi->index = ma->Members(); - mi->SetArgs(fun,argc,args); - ma->Add(mi,MakeSymbol(tag),inlet); + mi->SetArgs(fun,argc,args); + ma->Add(mi,MakeSymbol(tag),inlet); } void flext_base::ListMethods(AtomList &la,int inlet) const { - typedef DataMap MethList; - MethList list[2]; + typedef DataMap MethList; + MethList list[2]; - int i; - for(i = 0; i <= 1; ++i) { - ItemCont *a = i?methhead:clmethhead; - if(a && a->Contained(inlet)) { + int i; + for(i = 0; i <= 1; ++i) { + ItemCont *a = i?methhead:clmethhead; + if(a && a->Contained(inlet)) { ItemSet &ai = a->GetInlet(inlet); for(ItemSet::iterator as = ai.begin(); as != ai.end(); ++as) { for(Item *al = as.data(); al; al = al->nxt) { - MethItem *aa = (MethItem *)al; + MethItem *aa = (MethItem *)al; - // check it's not related to an attribute + // check it's not related to an attribute if(!aa->IsAttr()) { list[i][aa->index] = as.key(); break; } } - } - } - } - - la(list[0].size()+list[1].size()); - int ix = 0; - MethList::iterator it; - for(i = 0; i <= 1; ++i) - for(it = list[i].begin(); it != list[i].end(); ++it) - SetSymbol(la[ix++],it.data()); + } + } + } + + la(list[0].size()+list[1].size()); + int ix = 0; + MethList::iterator it; + for(i = 0; i <= 1; ++i) + for(it = list[i].begin(); it != list[i].end(); ++it) + SetSymbol(la[ix++],it.data()); } bool flext_base::ListMethods(int inlet) const { - if(procattr) { - AtomList la; - ListMethods(la,inlet); - ToOutAnything(GetOutAttr(),MakeSymbol("methods"),la.Count(),la.Atoms()); - return true; - } - else - return false; + if(procattr) { + AtomList la; + ListMethods(la,inlet); + ToOutAnything(GetOutAttr(),MakeSymbol("methods"),la.Count(),la.Atoms()); + return true; + } + else + return false; } bool flext_base::cb_ListMethods(flext_base *c,int argc,const t_atom *argv) { - if(argc == 0 || (argc == 1 && CanbeInt(argv[0]))) - return c->ListMethods(argc?GetAInt(argv[0]):0); - else - return false; + if(argc == 0 || (argc == 1 && CanbeInt(argv[0]))) + return c->ListMethods(argc?GetAInt(argv[0]):0); + else + return false; } diff --git a/externals/grill/flext/source/flmsg.cpp b/externals/grill/flext/source/flmsg.cpp index e586274e..3191edc0 100755 --- a/externals/grill/flext/source/flmsg.cpp +++ b/externals/grill/flext/source/flmsg.cpp @@ -16,60 +16,60 @@ WARRANTIES, see the file, "license.txt," in this distribution. bool flext_base::CallMeth(const MethItem &m,int argc,const t_atom *argv) { - bool ret = false; - int ix; - t_any aargs[FLEXT_MAXMETHARGS]; - bool ok = true; - for(ix = 0; ix < argc && ok; ++ix) { - switch(m.args[ix]) { - case a_float: { - if(IsFloat(argv[ix])) aargs[ix].ft = GetFloat(argv[ix]); - else if(IsInt(argv[ix])) aargs[ix].ft = (float)GetInt(argv[ix]); - else ok = false; - - if(ok) FLEXT_LOG2("int arg %i = %f",ix,aargs[ix].ft); - break; - } - case a_int: { - if(IsFloat(argv[ix])) aargs[ix].it = (int)GetFloat(argv[ix]); - else if(IsInt(argv[ix])) aargs[ix].it = GetInt(argv[ix]); - else ok = false; - - if(ok) FLEXT_LOG2("float arg %i = %i",ix,aargs[ix].it); - break; - } - case a_symbol: { - if(IsSymbol(argv[ix])) aargs[ix].st = GetSymbol(argv[ix]); - else ok = false; - - if(ok) FLEXT_LOG2("symbol arg %i = %s",ix,GetString(aargs[ix].st)); - break; - } + bool ret = false; + int ix; + t_any aargs[FLEXT_MAXMETHARGS]; + bool ok = true; + for(ix = 0; ix < argc && ok; ++ix) { + switch(m.args[ix]) { + case a_float: { + if(IsFloat(argv[ix])) aargs[ix].ft = GetFloat(argv[ix]); + else if(IsInt(argv[ix])) aargs[ix].ft = (float)GetInt(argv[ix]); + else ok = false; + + if(ok) FLEXT_LOG2("int arg %i = %f",ix,aargs[ix].ft); + break; + } + case a_int: { + if(IsFloat(argv[ix])) aargs[ix].it = (int)GetFloat(argv[ix]); + else if(IsInt(argv[ix])) aargs[ix].it = GetInt(argv[ix]); + else ok = false; + + if(ok) FLEXT_LOG2("float arg %i = %i",ix,aargs[ix].it); + break; + } + case a_symbol: { + if(IsSymbol(argv[ix])) aargs[ix].st = GetSymbol(argv[ix]); + else ok = false; + + if(ok) FLEXT_LOG2("symbol arg %i = %s",ix,GetString(aargs[ix].st)); + break; + } #if FLEXT_SYS == FLEXT_SYS_PD - case a_pointer: { - if(IsPointer(argv[ix])) aargs[ix].pt = (t_gpointer *)GetPointer(argv[ix]); - else ok = false; - break; - } + case a_pointer: { + if(IsPointer(argv[ix])) aargs[ix].pt = (t_gpointer *)GetPointer(argv[ix]); + else ok = false; + break; + } #endif - default: - error("Argument type illegal"); - ok = false; - } - } - - if(ok && ix == argc) { - switch(argc) { - case 0: ret = ((methfun_0)m.fun)(this); break; - case 1: ret = ((methfun_1)m.fun)(this,aargs[0]); break; - case 2: ret = ((methfun_2)m.fun)(this,aargs[0],aargs[1]); break; - case 3: ret = ((methfun_3)m.fun)(this,aargs[0],aargs[1],aargs[2]); break; - case 4: ret = ((methfun_4)m.fun)(this,aargs[0],aargs[1],aargs[2],aargs[3]); break; - case 5: ret = ((methfun_5)m.fun)(this,aargs[0],aargs[1],aargs[2],aargs[3],aargs[4]); break; - } - } - - return ret; + default: + error("Argument type illegal"); + ok = false; + } + } + + if(ok && ix == argc) { + switch(argc) { + case 0: ret = ((methfun_0)m.fun)(this); break; + case 1: ret = ((methfun_1)m.fun)(this,aargs[0]); break; + case 2: ret = ((methfun_2)m.fun)(this,aargs[0],aargs[1]); break; + case 3: ret = ((methfun_3)m.fun)(this,aargs[0],aargs[1],aargs[2]); break; + case 4: ret = ((methfun_4)m.fun)(this,aargs[0],aargs[1],aargs[2],aargs[3]); break; + case 5: ret = ((methfun_5)m.fun)(this,aargs[0],aargs[1],aargs[2],aargs[3],aargs[4]); break; + } + } + + return ret; } bool flext_base::TryMethTag(Item *lst,const t_symbol *tag,int argc,const t_atom *argv) @@ -78,29 +78,29 @@ bool flext_base::TryMethTag(Item *lst,const t_symbol *tag,int argc,const t_atom MethItem *m = (MethItem *)lst; // FLEXT_LOG3("found method tag %s: inlet=%i, argc=%i",GetString(tag),m->inlet,argc); - - if(m->attr) { - // attributes are treated differently - - if(m->attr->IsGet()) - return DumpAttrib(tag,m->attr); - else - return SetAttrib(tag,m->attr,argc,argv); - } - else { - if(m->argc == 1) { - // try list - if(m->args[0] == a_list && ((methfun_V)m->fun)(this,argc,const_cast(argv))) return true; - - // try anything - if(m->args[0] == a_any && ((methfun_A)m->fun)(this,tag,argc,const_cast(argv))) return true; - } - - // try matching number of args - if(argc == m->argc && CallMeth(*m,argc,argv)) return true; - } - } - return false; + + if(m->attr) { + // attributes are treated differently + + if(m->attr->IsGet()) + return DumpAttrib(tag,m->attr); + else + return SetAttrib(tag,m->attr,argc,argv); + } + else { + if(m->argc == 1) { + // try list + if(m->args[0] == a_list && ((methfun_V)m->fun)(this,argc,const_cast(argv))) return true; + + // try anything + if(m->args[0] == a_any && ((methfun_A)m->fun)(this,tag,argc,const_cast(argv))) return true; + } + + // try matching number of args + if(argc == m->argc && CallMeth(*m,argc,argv)) return true; + } + } + return false; } bool flext_base::TryMethSym(Item *lst,const t_symbol *s) @@ -108,14 +108,14 @@ bool flext_base::TryMethSym(Item *lst,const t_symbol *s) for(; lst; lst = lst->nxt) { MethItem *m = (MethItem *)lst; - if(!m->IsAttr()) { -// FLEXT_LOG3("found symbol method for %s: inlet=%i, symbol=%s",GetString(m->tag),m->inlet,GetString(s)); + if(!m->IsAttr()) { +// FLEXT_LOG3("found symbol method for %s: inlet=%i, symbol=%s",GetString(m->tag),m->inlet,GetString(s)); - t_any sym; sym.st = const_cast(s); - if(((methfun_1)m->fun)(this,sym)) return true; - } - } - return false; + t_any sym; sym.st = const_cast(s); + if(((methfun_1)m->fun)(this,sym)) return true; + } + } + return false; } bool flext_base::TryMethAny(Item *lst,const t_symbol *s,int argc,const t_atom *argv) @@ -123,141 +123,153 @@ bool flext_base::TryMethAny(Item *lst,const t_symbol *s,int argc,const t_atom *a for(; lst; lst = lst->nxt) { MethItem *m = (MethItem *)lst; - if(!m->IsAttr() && m->argc == 1 && m->args[0] == a_any) { -// FLEXT_LOG4("found any method for %s: inlet=%i, symbol=%s, argc=%i",GetString(m->tag),m->inlet,GetString(s),argc); + if(!m->IsAttr() && m->argc == 1 && m->args[0] == a_any) { +// FLEXT_LOG4("found any method for %s: inlet=%i, symbol=%s, argc=%i",GetString(m->tag),m->inlet,GetString(s),argc); - if(((methfun_A)m->fun)(this,s,argc,const_cast(argv))) return true; - } + if(((methfun_A)m->fun)(this,s,argc,const_cast(argv))) return true; + } } return false; } /*! \brief Find a method item for a specific tag and arguments - \remark All attributes are also stored in the method list and retrieved by a member of the method item + \remark All attributes are also stored in the method list and retrieved by a member of the method item */ bool flext_base::FindMeth(int inlet,const t_symbol *s,int argc,const t_atom *argv) { Item *lst; - // search for exactly matching tag - if((lst = methhead->FindList(s,inlet)) != NULL && TryMethTag(lst,s,argc,argv)) return true; - if((lst = clmethhead->FindList(s,inlet)) != NULL && TryMethTag(lst,s,argc,argv)) return true; - - // if no list args, then search for pure symbol - if(!argc) { - if((lst = methhead->FindList(sym_symbol,inlet)) != NULL && TryMethSym(lst,s)) return true; - if((lst = clmethhead->FindList(sym_symbol,inlet)) != NULL && TryMethSym(lst,s)) return true; - } - - // otherwise search for anything - if((lst = methhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(lst,s,argc,argv)) return true; - if((lst = clmethhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(lst,s,argc,argv)) return true; - - // if nothing found try any inlet - return inlet >= 0 && FindMeth(-1,s,argc,argv); + // search for exactly matching tag + if((lst = methhead->FindList(s,inlet)) != NULL && TryMethTag(lst,s,argc,argv)) return true; + if((lst = clmethhead->FindList(s,inlet)) != NULL && TryMethTag(lst,s,argc,argv)) return true; + + // if no list args, then search for pure symbol + if(!argc) { + if((lst = methhead->FindList(sym_symbol,inlet)) != NULL && TryMethSym(lst,s)) return true; + if((lst = clmethhead->FindList(sym_symbol,inlet)) != NULL && TryMethSym(lst,s)) return true; + } + + // otherwise search for anything + if((lst = methhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(lst,s,argc,argv)) return true; + if((lst = clmethhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(lst,s,argc,argv)) return true; + + // if nothing found try any inlet + return inlet >= 0 && FindMeth(-1,s,argc,argv); } /*! \brief All the message processing - The messages of all the inlets go here and are promoted to the registered callback functions + The messages of all the inlets go here and are promoted to the registered callback functions */ bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,const t_atom *argv) { - static bool trap = false; + static bool trap = false; + + curtag = s; + +// post("methodmain inlet:%i args:%i symbol:%s",inlet,argc,s?GetString(s):""); - curtag = s; + bool ret = FindMeth(inlet,s,argc,argv); + if(ret) goto end; -// post("methodmain inlet:%i args:%i symbol:%s",inlet,argc,s?GetString(s):""); - - bool ret = FindMeth(inlet,s,argc,argv); - if(ret) goto end; + try { #if FLEXT_SYS == FLEXT_SYS_MAX - // If float message is not explicitly handled: try int handler instead - if(argc == 1 && s == sym_float && !trap) { - t_atom fl; - SetInt(fl,GetAInt(argv[0])); - trap = true; - ret = m_methodmain(inlet,sym_int,1,&fl); - trap = false; - } - if(ret) goto end; - - // If int message is not explicitly handled: try float handler instead - if(argc == 1 && s == sym_int && !trap) { - t_atom fl; - SetFloat(fl,GetAFloat(argv[0])); - trap = true; - ret = m_methodmain(inlet,sym_float,1,&fl); - trap = false; - } - if(ret) goto end; + // If float message is not explicitly handled: try int handler instead + if(argc == 1 && s == sym_float && !trap) { + t_atom fl; + SetInt(fl,GetAInt(argv[0])); + trap = true; + ret = m_methodmain(inlet,sym_int,1,&fl); + trap = false; + } + if(ret) goto end; + + // If int message is not explicitly handled: try float handler instead + if(argc == 1 && s == sym_int && !trap) { + t_atom fl; + SetFloat(fl,GetAFloat(argv[0])); + trap = true; + ret = m_methodmain(inlet,sym_float,1,&fl); + trap = false; + } + if(ret) goto end; #endif - - // If float or int message is not explicitly handled: try list handler instead - if(!trap && argc == 1 && (s == sym_float + + // If float or int message is not explicitly handled: try list handler instead + if(!trap && argc == 1 && (s == sym_float #if FLEXT_SYS == FLEXT_SYS_MAX - || s == sym_int + || s == sym_int #endif - )) { - t_atom list; - if(s == sym_float) - SetFloat(list,GetFloat(argv[0])); + )) { + t_atom list; + if(s == sym_float) + SetFloat(list,GetFloat(argv[0])); #if FLEXT_SYS == FLEXT_SYS_MAX - else if(s == sym_int) - SetInt(list,GetInt(argv[0])); + else if(s == sym_int) + SetInt(list,GetInt(argv[0])); #endif - trap = true; - ret = m_methodmain(inlet,sym_list,1,&list); - trap = false; - } - if(ret) goto end; - - // If symbol message (pure anything without args) is not explicitly handled: try list handler instead - if(!trap && argc == 0) { - t_atom list; - SetSymbol(list,s); - trap = true; - ret = m_methodmain(inlet,sym_list,1,&list); - trap = false; - } - if(ret) goto end; - - // if distmsgs is switched on then distribute list elements over inlets (Max/MSP behavior) - if(distmsgs && !trap && inlet == 0 && s == sym_list && insigs <= 1) { - int i = incnt; - if(i > argc) i = argc; - for(--i; i >= 0; --i) { // right to left distribution - const t_symbol *sym = NULL; - if(IsFloat(argv[i])) sym = sym_float; - else if(IsInt(argv[i])) sym = sym_int; - else if(IsSymbol(argv[i])) sym = sym_symbol; + trap = true; + ret = m_methodmain(inlet,sym_list,1,&list); + trap = false; + } + if(ret) goto end; + + // If symbol message (pure anything without args) is not explicitly handled: try list handler instead + if(!trap && argc == 0) { + t_atom list; + SetSymbol(list,s); + trap = true; + ret = m_methodmain(inlet,sym_list,1,&list); + trap = false; + } + if(ret) goto end; + + // if distmsgs is switched on then distribute list elements over inlets (Max/MSP behavior) + if(distmsgs && !trap && inlet == 0 && s == sym_list && insigs <= 1) { + int i = incnt; + if(i > argc) i = argc; + for(--i; i >= 0; --i) { // right to left distribution + const t_symbol *sym = NULL; + if(IsFloat(argv[i])) sym = sym_float; + else if(IsInt(argv[i])) sym = sym_int; + else if(IsSymbol(argv[i])) sym = sym_symbol; #if FLEXT_SYS == FLEXT_SYS_PD - else if(IsPointer(argv[i])) sym = sym_pointer; // can pointer atoms occur here? + else if(IsPointer(argv[i])) sym = sym_pointer; // can pointer atoms occur here? #endif - if(sym) { - trap = true; - m_methodmain(i,sym,1,argv+i); - trap = false; - } - } - - ret = true; - } - - if(!ret && !trap) ret = m_method_(inlet,s,argc,argv); - + if(sym) { + trap = true; + m_methodmain(i,sym,1,argv+i); + trap = false; + } + } + + ret = true; + } + + if(!ret && !trap) ret = m_method_(inlet,s,argc,argv); + } + catch(std::exception &x) { + error("%s - Exception while processing method: %s",thisName(),x.what()); + } + catch(const char *txt) { + error("%s - Exception while processing method: %s",thisName(),txt); + } + catch(...) { + error("%s - Unknown exception while processing method",thisName()); + } + end: - curtag = NULL; + curtag = NULL; - return ret; // true if appropriate handler was found and called + return ret; // true if appropriate handler was found and called } bool flext_base::m_method_(int inlet,const t_symbol *s,int argc,const t_atom *argv) { //#ifdef FLEXT_DEBUG - post("%s: message unhandled - inlet:%i args:%i symbol:%s",thisName(),inlet,argc,s?GetString(s):""); + post("%s: message unhandled - inlet:%i args:%i symbol:%s",thisName(),inlet,argc,s?GetString(s):""); //#endif - return false; + return false; } diff --git a/externals/grill/flext/source/flmspbuffer.h b/externals/grill/flext/source/flmspbuffer.h index c09f690f..88023806 100755 --- a/externals/grill/flext/source/flmspbuffer.h +++ b/externals/grill/flext/source/flmspbuffer.h @@ -10,71 +10,71 @@ WARRANTIES, see the file, "license.txt," in this distribution. /*! \file flmspbuffer.h \brief Definition of the Max/MSP buffer structure - \internal + \internal - This file comes from David Zicarellis inofficial package index.sit - The latter is not easily found so i included the original file buffer.h with flext + This file comes from David Zicarellis inofficial package index.sit + The latter is not easily found so i included the original file buffer.h with flext */ #if (FLEXT_SYS == FLEXT_SYS_MAX) && !defined(__FLEXT_MSPBUFFER_H) #define __FLEXT_MSPBUFFER_H enum { - MAXCHAN = 4 + MAXCHAN = 4 }; enum { - bi_basefreq = 0, - bi_detune, - bi_lowfreq, - bi_hifreq, - bi_lowvel, - bi_hivel, - bi_gain, - bi_numparams + bi_basefreq = 0, + bi_detune, + bi_lowfreq, + bi_hifreq, + bi_lowvel, + bi_hivel, + bi_gain, + bi_numparams }; typedef struct _buffer { - t_object b_obj; // doesn't have any signals so it doesn't need to be pxobject - long b_valid; // flag is off during read replacement or editing operation - float *b_samples; // stored with interleaved channels if multi-channel - long b_frames; // number of sample frames (each one is sizeof(float) * b_nchans bytes) - long b_nchans; // number of channels - long b_size; // size of buffer in floats - float b_sr; // sampling rate of the buffer - float b_1oversr; // 1 / sr - float b_msr; // sr * .001 - // Mac-specific stuff - float *b_memory; // pointer to where memory starts (initial padding for interp) - t_symbol *b_name; - short b_vol; - short b_space; - // looping info (from AIFF file) - long b_susloopstart; // in samples - long b_susloopend; // in samples - long b_relloopstart; // in samples - long b_relloopend; // in samples - // instrument info (from AIFF file) - short b_inst[bi_numparams]; - // window stuff - void *b_wind; - double b_pixperfr; - double b_frperpix; - long b_imagesize; - Point b_scroll; - long b_scrollscale; - long b_selbegin[MAXCHAN]; - long b_selend[MAXCHAN]; - long b_zoom; - long b_zim[11]; - void *b_mouseout; - long b_format; // 'AIFF' or 'Sd2f' - t_symbol *b_filename; // last file read (not written) for readagain message - long b_oldnchans; // used for resizing window in case of # of channels change - void *b_doneout; - long b_outputbytes; // number of bytes used for output sample (1-4) - long b_modtime; // last modified time ("dirty" method) + t_object b_obj; // doesn't have any signals so it doesn't need to be pxobject + long b_valid; // flag is off during read replacement or editing operation + float *b_samples; // stored with interleaved channels if multi-channel + long b_frames; // number of sample frames (each one is sizeof(float) * b_nchans bytes) + long b_nchans; // number of channels + long b_size; // size of buffer in floats + float b_sr; // sampling rate of the buffer + float b_1oversr; // 1 / sr + float b_msr; // sr * .001 + // Mac-specific stuff + float *b_memory; // pointer to where memory starts (initial padding for interp) + t_symbol *b_name; + short b_vol; + short b_space; + // looping info (from AIFF file) + long b_susloopstart; // in samples + long b_susloopend; // in samples + long b_relloopstart; // in samples + long b_relloopend; // in samples + // instrument info (from AIFF file) + short b_inst[bi_numparams]; + // window stuff + void *b_wind; + double b_pixperfr; + double b_frperpix; + long b_imagesize; + Point b_scroll; + long b_scrollscale; + long b_selbegin[MAXCHAN]; + long b_selend[MAXCHAN]; + long b_zoom; + long b_zim[11]; + void *b_mouseout; + long b_format; // 'AIFF' or 'Sd2f' + t_symbol *b_filename; // last file read (not written) for readagain message + long b_oldnchans; // used for resizing window in case of # of channels change + void *b_doneout; + long b_outputbytes; // number of bytes used for output sample (1-4) + long b_modtime; // last modified time ("dirty" method) } t_buffer; #define BUFWIND(x) ((t_wind *)(x->b_wind)) diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp index fcfaa6c8..245de189 100644 --- a/externals/grill/flext/source/flout.cpp +++ b/externals/grill/flext/source/flout.cpp @@ -58,349 +58,349 @@ void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *ar bool flext_base::InitInlets() { - bool ok = true; + bool ok = true; - // ---------------------------------- - // create inlets - // ---------------------------------- + // ---------------------------------- + // create inlets + // ---------------------------------- - incnt = insigs = 0; + incnt = insigs = 0; // digest inlist { - xlet *xi; - incnt = 0; - for(xi = inlist; xi; xi = xi->nxt) ++incnt; - xlet::type *list = new xlet::type[incnt]; - int i; - for(xi = inlist,i = 0; xi; xi = xi->nxt,++i) list[i] = xi->tp; - -#if FLEXT_SYS == FLEXT_SYS_MAX - // copy inlet descriptions - indesc = new char *[incnt]; - for(xi = inlist,i = 0; xi; xi = xi->nxt,++i) { - int l = xi->desc?strlen(xi->desc):0; - if(l) { - indesc[i] = new char[l+1]; - memcpy(indesc[i],xi->desc,l); - indesc[i][l] = 0; - } - else - indesc[i] = NULL; - } + xlet *xi; + incnt = 0; + for(xi = inlist; xi; xi = xi->nxt) ++incnt; + xlet::type *list = new xlet::type[incnt]; + int i; + for(xi = inlist,i = 0; xi; xi = xi->nxt,++i) list[i] = xi->tp; + +#if FLEXT_SYS == FLEXT_SYS_MAX + // copy inlet descriptions + indesc = new char *[incnt]; + for(xi = inlist,i = 0; xi; xi = xi->nxt,++i) { + int l = xi->desc?strlen(xi->desc):0; + if(l) { + indesc[i] = new char[l+1]; + memcpy(indesc[i],xi->desc,l); + indesc[i][l] = 0; + } + else + indesc[i] = NULL; + } #endif - delete inlist; inlist = NULL; - + delete inlist; inlist = NULL; + #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX - inlets = new px_object *[incnt]; - for(i = 0; i < incnt; ++i) inlets[i] = NULL; + inlets = new px_object *[incnt]; + for(i = 0; i < incnt; ++i) inlets[i] = NULL; #endif - - // type info is now in list array + + // type info is now in list array #if FLEXT_SYS == FLEXT_SYS_PD - { - int cnt = 0; - - if(incnt >= 1) { - switch(list[0]) { - case xlet::tp_sig: - ++insigs; - break; - default: - // leftmost inlet is already there... - break; - } - ++cnt; - } - - for(int ix = 1; ix < incnt; ++ix,++cnt) { - switch(list[ix]) { - case xlet::tp_float: - case xlet::tp_int: { - char sym[] = "ft??"; - if(ix >= 10) { - if(compatibility) { - // Max allows max. 9 inlets - post("%s: Only 9 float/int inlets allowed in compatibility mode",thisName()); - ok = false; - } - else { - if(ix > 99) - post("%s: Inlet index > 99 not allowed for float/int inlets",thisName()); - sym[2] = '0'+ix/10,sym[3] = '0'+ix%10; - } - } - else - sym[2] = '0'+ix,sym[3] = 0; - if(ok) inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_float, gensym(sym)); - break; - } - case xlet::tp_sym: - (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages - inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, (t_symbol *)sym_symbol, (t_symbol *)sym_symbol); - break; - case xlet::tp_list: - (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages - inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, (t_symbol *)sym_list, (t_symbol *)sym_list); - break; - case xlet::tp_any: - (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages - inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, 0, 0); - break; - case xlet::tp_sig: - if(compatibility && list[ix-1] != xlet::tp_sig) { - post("%s: All signal inlets must be left-aligned in compatibility mode",thisName()); - ok = false; - } - else { - // pd doesn't seem to be able to handle signals and messages into the same inlet... - - inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_signal, (t_symbol *)sym_signal); - ++insigs; - } - break; - default: - error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]); - ok = false; - } - } - - incnt = cnt; - } + { + int cnt = 0; + + if(incnt >= 1) { + switch(list[0]) { + case xlet::tp_sig: + ++insigs; + break; + default: + // leftmost inlet is already there... + break; + } + ++cnt; + } + + for(int ix = 1; ix < incnt; ++ix,++cnt) { + switch(list[ix]) { + case xlet::tp_float: + case xlet::tp_int: { + char sym[] = "ft??"; + if(ix >= 10) { + if(compatibility) { + // Max allows max. 9 inlets + post("%s: Only 9 float/int inlets allowed in compatibility mode",thisName()); + ok = false; + } + else { + if(ix > 99) + post("%s: Inlet index > 99 not allowed for float/int inlets",thisName()); + sym[2] = '0'+ix/10,sym[3] = '0'+ix%10; + } + } + else + sym[2] = '0'+ix,sym[3] = 0; + if(ok) inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_float, gensym(sym)); + break; + } + case xlet::tp_sym: + (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages + inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, (t_symbol *)sym_symbol, (t_symbol *)sym_symbol); + break; + case xlet::tp_list: + (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages + inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, (t_symbol *)sym_list, (t_symbol *)sym_list); + break; + case xlet::tp_any: + (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages + inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, 0, 0); + break; + case xlet::tp_sig: + if(compatibility && list[ix-1] != xlet::tp_sig) { + post("%s: All signal inlets must be left-aligned in compatibility mode",thisName()); + ok = false; + } + else { + // pd doesn't seem to be able to handle signals and messages into the same inlet... + + inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_signal, (t_symbol *)sym_signal); + ++insigs; + } + break; + default: + error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]); + ok = false; + } + } + + incnt = cnt; + } #elif FLEXT_SYS == FLEXT_SYS_MAX - { - int ix,cnt; - // count leftmost signal inlets - while(insigs < incnt && list[insigs] == xlet::tp_sig) ++insigs; - - for(cnt = 0,ix = incnt-1; ix >= insigs; --ix,++cnt) { - if(ix == 0) { - if(list[ix] != xlet::tp_any) { - error("%s: Leftmost inlet must be of type signal or anything",thisName()); - ok = false; - } - } - else { - switch(list[ix]) { - case xlet::tp_sig: - error("%s: All signal inlets must be left-aligned",thisName()); - ok = false; - break; - case xlet::tp_float: - if(ix >= 10) { - post("%s: Only 9 float inlets possible",thisName()); - ok = false; - } - else - floatin(x_obj,ix); - break; - case xlet::tp_int: - if(ix >= 10) { - post("%s: Only 9 int inlets possible",thisName()); - ok = false; - } - else - intin(x_obj,ix); - break; - case xlet::tp_any: // non-leftmost - case xlet::tp_sym: - case xlet::tp_list: - inlets[ix] = (px_object *)proxy_new(x_obj,ix,&((flext_hdr *)x_obj)->curinlet); - break; - default: - error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]); - ok = false; - } - } - } - -// incnt = cnt; - - if(insigs) -// dsp_setup(thisHdr(),insigs); // signal inlets - dsp_setupbox(thisHdr(),insigs); // signal inlets - } + { + int ix,cnt; + // count leftmost signal inlets + while(insigs < incnt && list[insigs] == xlet::tp_sig) ++insigs; + + for(cnt = 0,ix = incnt-1; ix >= insigs; --ix,++cnt) { + if(ix == 0) { + if(list[ix] != xlet::tp_any) { + error("%s: Leftmost inlet must be of type signal or anything",thisName()); + ok = false; + } + } + else { + switch(list[ix]) { + case xlet::tp_sig: + error("%s: All signal inlets must be left-aligned",thisName()); + ok = false; + break; + case xlet::tp_float: + if(ix >= 10) { + post("%s: Only 9 float inlets possible",thisName()); + ok = false; + } + else + floatin(x_obj,ix); + break; + case xlet::tp_int: + if(ix >= 10) { + post("%s: Only 9 int inlets possible",thisName()); + ok = false; + } + else + intin(x_obj,ix); + break; + case xlet::tp_any: // non-leftmost + case xlet::tp_sym: + case xlet::tp_list: + inlets[ix] = (px_object *)proxy_new(x_obj,ix,&((flext_hdr *)x_obj)->curinlet); + break; + default: + error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]); + ok = false; + } + } + } + +// incnt = cnt; + + if(insigs) +// dsp_setup(thisHdr(),insigs); // signal inlets + dsp_setupbox(thisHdr(),insigs); // signal inlets + } #elif FLEXT_SYS == FLEXT_SYS_JMAX - { - t_class *cl = thisClass(); - int cnt = 0; - for(int ix = 0; ix < incnt; ++ix,++cnt) { - switch(list[ix]) { - case xlet::tp_float: - case xlet::tp_int: -// fts_class_inlet_number(cl, ix, jmax_proxy); - break; - case xlet::tp_sym: -// fts_class_inlet_symbol(cl, ix, jmax_proxy); - break; - case xlet::tp_sig: - if(compatibility && list[ix-1] != xlet::tp_sig) { - post("%s: All signal inlets must be left-aligned in compatibility mode",thisName()); - ok = false; - } - else { - if(!insigs) fts_dsp_declare_inlet(cl,0); - ++insigs; - } - // no break -> let a signal inlet also accept any messages - case xlet::tp_list: - case xlet::tp_any: -// fts_class_inlet_varargs(cl,ix, jmax_proxy); - break; - default: - error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]); - ok = false; - } - } - - incnt = cnt; - - fts_object_set_inlets_number((fts_object_t *)thisHdr(), incnt); - } + { + t_class *cl = thisClass(); + int cnt = 0; + for(int ix = 0; ix < incnt; ++ix,++cnt) { + switch(list[ix]) { + case xlet::tp_float: + case xlet::tp_int: +// fts_class_inlet_number(cl, ix, jmax_proxy); + break; + case xlet::tp_sym: +// fts_class_inlet_symbol(cl, ix, jmax_proxy); + break; + case xlet::tp_sig: + if(compatibility && list[ix-1] != xlet::tp_sig) { + post("%s: All signal inlets must be left-aligned in compatibility mode",thisName()); + ok = false; + } + else { + if(!insigs) fts_dsp_declare_inlet(cl,0); + ++insigs; + } + // no break -> let a signal inlet also accept any messages + case xlet::tp_list: + case xlet::tp_any: +// fts_class_inlet_varargs(cl,ix, jmax_proxy); + break; + default: + error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]); + ok = false; + } + } + + incnt = cnt; + + fts_object_set_inlets_number((fts_object_t *)thisHdr(), incnt); + } #else #error #endif - delete[] list; - } + delete[] list; + } - return ok; + return ok; } bool flext_base::InitOutlets() { - bool ok = true; + bool ok = true; - // ---------------------------------- - // create outlets - // ---------------------------------- + // ---------------------------------- + // create outlets + // ---------------------------------- - outcnt = outsigs = 0; - + outcnt = outsigs = 0; + #if FLEXT_SYS == FLEXT_SYS_MAX - // for Max/MSP the rightmost outlet has to be created first - outlet *attrtmp = NULL; - if(procattr) - attrtmp = (outlet *)newout_anything(thisHdr()); + // for Max/MSP the rightmost outlet has to be created first + outlet *attrtmp = NULL; + if(procattr) + attrtmp = (outlet *)newout_anything(thisHdr()); #endif // digest outlist - { - xlet *xi; - - // count outlets - outcnt = 0; - for(xi = outlist; xi; xi = xi->nxt) ++outcnt; - - xlet::type *list = new xlet::type[outcnt]; - int i; - for(xi = outlist,i = 0; xi; xi = xi->nxt,++i) list[i] = xi->tp; - -#if FLEXT_SYS == FLEXT_SYS_MAX - // copy outlet descriptions - outdesc = new char *[outcnt]; - for(xi = outlist,i = 0; xi; xi = xi->nxt,++i) { - int l = xi->desc?strlen(xi->desc):0; - if(l) { - outdesc[i] = new char[l+1]; - memcpy(outdesc[i],xi->desc,l); - outdesc[i][l] = 0; - } - else - outdesc[i] = NULL; - } + { + xlet *xi; + + // count outlets + outcnt = 0; + for(xi = outlist; xi; xi = xi->nxt) ++outcnt; + + xlet::type *list = new xlet::type[outcnt]; + int i; + for(xi = outlist,i = 0; xi; xi = xi->nxt,++i) list[i] = xi->tp; + +#if FLEXT_SYS == FLEXT_SYS_MAX + // copy outlet descriptions + outdesc = new char *[outcnt]; + for(xi = outlist,i = 0; xi; xi = xi->nxt,++i) { + int l = xi->desc?strlen(xi->desc):0; + if(l) { + outdesc[i] = new char[l+1]; + memcpy(outdesc[i],xi->desc,l); + outdesc[i][l] = 0; + } + else + outdesc[i] = NULL; + } #endif - delete outlist; outlist = NULL; - + delete outlist; outlist = NULL; + #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX - outlets = new outlet *[outcnt+(procattr?1:0)]; + outlets = new outlet *[outcnt+(procattr?1:0)]; - // type info is now in list array + // type info is now in list array #if FLEXT_SYS == FLEXT_SYS_PD - for(int ix = 0; ix < outcnt; ++ix) + for(int ix = 0; ix < outcnt; ++ix) #elif FLEXT_SYS == FLEXT_SYS_MAX - for(int ix = outcnt-1; ix >= 0; --ix) + for(int ix = outcnt-1; ix >= 0; --ix) #else #error #endif - { - switch(list[ix]) { - case xlet::tp_float: - outlets[ix] = (outlet *)newout_float(&x_obj->obj); - break; - case xlet::tp_int: - outlets[ix] = (outlet *)newout_flint(&x_obj->obj); - break; - case xlet::tp_sig: - outlets[ix] = (outlet *)newout_signal(&x_obj->obj); - ++outsigs; - break; - case xlet::tp_sym: - outlets[ix] = (outlet *)newout_symbol(&x_obj->obj); - break; - case xlet::tp_list: - outlets[ix] = (outlet *)newout_list(&x_obj->obj); - break; - case xlet::tp_any: - outlets[ix] = (outlet *)newout_anything(&x_obj->obj); - break; + { + switch(list[ix]) { + case xlet::tp_float: + outlets[ix] = (outlet *)newout_float(&x_obj->obj); + break; + case xlet::tp_int: + outlets[ix] = (outlet *)newout_flint(&x_obj->obj); + break; + case xlet::tp_sig: + outlets[ix] = (outlet *)newout_signal(&x_obj->obj); + ++outsigs; + break; + case xlet::tp_sym: + outlets[ix] = (outlet *)newout_symbol(&x_obj->obj); + break; + case xlet::tp_list: + outlets[ix] = (outlet *)newout_list(&x_obj->obj); + break; + case xlet::tp_any: + outlets[ix] = (outlet *)newout_anything(&x_obj->obj); + break; #ifdef FLEXT_DEBUG - default: - ERRINTERNAL(); - ok = false; + default: + ERRINTERNAL(); + ok = false; #endif - } - } + } + } #elif FLEXT_SYS == FLEXT_SYS_JMAX - t_class *cl = thisClass(); - for(int ix = 0; ix < outcnt; ++ix) { - switch(list[ix]) { - case xlet::tp_float: - case xlet::tp_int: -// fts_class_outlet_number(cl, ix); - break; - case xlet::tp_sym: -// fts_class_outlet_symbol(cl, ix); - break; - case xlet::tp_list: - case xlet::tp_any: -// fts_class_outlet_anything(cl, ix); - break; - case xlet::tp_sig: - if(!outsigs) fts_dsp_declare_outlet(cl,0); - ++outsigs; - break; + t_class *cl = thisClass(); + for(int ix = 0; ix < outcnt; ++ix) { + switch(list[ix]) { + case xlet::tp_float: + case xlet::tp_int: +// fts_class_outlet_number(cl, ix); + break; + case xlet::tp_sym: +// fts_class_outlet_symbol(cl, ix); + break; + case xlet::tp_list: + case xlet::tp_any: +// fts_class_outlet_anything(cl, ix); + break; + case xlet::tp_sig: + if(!outsigs) fts_dsp_declare_outlet(cl,0); + ++outsigs; + break; #ifdef FLEXT_DEBUG - default: - ERRINTERNAL(); - ok = false; + default: + ERRINTERNAL(); + ok = false; #endif - } - } + } + } - fts_object_set_outlets_number((fts_object_t *)thisHdr(), outcnt+(procattr?1:0)); + fts_object_set_outlets_number((fts_object_t *)thisHdr(), outcnt+(procattr?1:0)); #endif - delete[] list; - } + delete[] list; + } #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX - if(procattr) { - // attribute dump outlet is the last one - outlets[outcnt] = + if(procattr) { + // attribute dump outlet is the last one + outlets[outcnt] = #if FLEXT_SYS == FLEXT_SYS_PD - // attribute dump outlet is the last one - (outlet *)newout_anything(&x_obj->obj); + // attribute dump outlet is the last one + (outlet *)newout_anything(&x_obj->obj); #elif FLEXT_SYS == FLEXT_SYS_MAX - attrtmp; + attrtmp; #endif - } + } #endif - - return ok; + + return ok; } diff --git a/externals/grill/flext/source/flprefix.h b/externals/grill/flext/source/flprefix.h index a61ec8d7..626ff70a 100755 --- a/externals/grill/flext/source/flprefix.h +++ b/externals/grill/flext/source/flprefix.h @@ -16,44 +16,44 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define __FLEXT_PREFIX_H // --- definitions for FLEXT_SYS --------------------- -#define FLEXT_SYS_UNKNOWN 0 +#define FLEXT_SYS_UNKNOWN 0 #ifndef FLEXT_SYS_MAX - #define FLEXT_SYS_MAX 1 + #define FLEXT_SYS_MAX 1 #else - // already defined - #undef FLEXT_SYS_MAX - #define FLEXT_SYS_MAX 1 - #define FLEXT_SYS FLEXT_SYS_MAX + // already defined + #undef FLEXT_SYS_MAX + #define FLEXT_SYS_MAX 1 + #define FLEXT_SYS FLEXT_SYS_MAX #endif #ifndef FLEXT_SYS_PD - #define FLEXT_SYS_PD 2 + #define FLEXT_SYS_PD 2 #else - // already defined - #undef FLEXT_SYS_PD - #define FLEXT_SYS_PD 2 - #define FLEXT_SYS FLEXT_SYS_PD + // already defined + #undef FLEXT_SYS_PD + #define FLEXT_SYS_PD 2 + #define FLEXT_SYS FLEXT_SYS_PD #endif #ifndef FLEXT_SYS_JMAX - #define FLEXT_SYS_JMAX 3 + #define FLEXT_SYS_JMAX 3 #else - // already defined - #undef FLEXT_SYS_JMAX - #define FLEXT_SYS_JMAX 3 - #define FLEXT_SYS FLEXT_SYS_JMAX + // already defined + #undef FLEXT_SYS_JMAX + #define FLEXT_SYS_JMAX 3 + #define FLEXT_SYS FLEXT_SYS_JMAX #endif // --- definitions for FLEXT_OS ---------------------- -#define FLEXT_OS_UNKNOWN 0 -#define FLEXT_OS_WIN 1 -#define FLEXT_OS_MAC 2 -#define FLEXT_OS_LINUX 3 -#define FLEXT_OS_IRIX 4 +#define FLEXT_OS_UNKNOWN 0 +#define FLEXT_OS_WIN 1 +#define FLEXT_OS_MAC 2 +#define FLEXT_OS_LINUX 3 +#define FLEXT_OS_IRIX 4 // --- definitions for FLEXT_OS_API --------------------- -#define FLEXT_OSAPI_UNKNOWN 0 +#define FLEXT_OSAPI_UNKNOWN 0 #define FLEXT_OSAPI_UNIX_POSIX 1 @@ -62,36 +62,36 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define FLEXT_OSAPI_MAC_MACH 4 #define FLEXT_OSAPI_WIN_NATIVE 5 // WIN32 Platform -#define FLEXT_OSAPI_WIN_POSIX 6 // POSIX API (e.g. cygwin) +#define FLEXT_OSAPI_WIN_POSIX 6 // POSIX API (e.g. cygwin) // --- definitions for FLEXT_CPU --------------------- -#define FLEXT_CPU_UNKNOWN 0 +#define FLEXT_CPU_UNKNOWN 0 #define FLEXT_CPU_INTEL 1 -#define FLEXT_CPU_PPC 2 -#define FLEXT_CPU_MIPS 3 -#define FLEXT_CPU_ALPHA 4 +#define FLEXT_CPU_PPC 2 +#define FLEXT_CPU_MIPS 3 +#define FLEXT_CPU_ALPHA 4 // --- definitions for FLEXT_THREADS ----------------- #define FLEXT_THR_POSIX 1 // pthreads -#define FLEXT_THR_WIN32 2 // Win32 native -#define FLEXT_THR_MP 3 // MacOS MPThreads +#define FLEXT_THR_WIN32 2 // Win32 native +#define FLEXT_THR_MP 3 // MacOS MPThreads // --------------------------------------------------- // support old definitions #ifndef FLEXT_SYS - #if defined(MAXMSP) - #define FLEXT_SYS FLEXT_SYS_MAX - // #undef MAXMSP - #elif defined(PD) - #define FLEXT_SYS FLEXT_SYS_PD - // #undef PD - // #undef NT - #endif + #if defined(MAXMSP) + #define FLEXT_SYS FLEXT_SYS_MAX + // #undef MAXMSP + #elif defined(PD) + #define FLEXT_SYS FLEXT_SYS_PD + // #undef PD + // #undef NT + #endif #endif #if defined(_DEBUG) && !defined(FLEXT_DEBUG) - #define FLEXT_DEBUG + #define FLEXT_DEBUG #endif // --------------------------------------------------- @@ -101,268 +101,268 @@ WARRANTIES, see the file, "license.txt," in this distribution. #elif FLEXT_SYS == FLEXT_SYS_PD #elif FLEXT_SYS == FLEXT_SYS_JMAX #else - #error "System must be defined by either FLEXT_SYS_MAX, FLEXT_SYS_PD or FLEXT_SYS_JMAX" + #error "System must be defined by either FLEXT_SYS_MAX, FLEXT_SYS_PD or FLEXT_SYS_JMAX" #endif // Definition of OS/CPU #if defined(_MSC_VER) || (defined(__ICC) && (FLEXT_OS == FLEXT_OS_WIN || defined(_WIN32))) - // Microsoft C++ + // Microsoft C++ // and Intel C++ (as guessed) - - #ifndef FLEXT_CPU - #if defined(_M_IX86) - #define FLEXT_CPU FLEXT_CPU_INTEL - #elif defined(_M_PPC) - #define FLEXT_CPU FLEXT_CPU_PPC - #elif defined(_M_MRX000) - #define FLEXT_CPU FLEXT_CPU_MIPS - #elif defined(_M_ALPHA) - #define FLEXT_CPU FLEXT_CPU_ALPHA - #else - #define FLEXT_CPU FLEXT_CPU_UNKNOWN - #endif - #endif - - #ifndef FLEXT_OS - #if defined(_WIN32) - #define FLEXT_OS FLEXT_OS_WIN - #define FLEXT_OSAPI FLEXT_OSAPI_WIN_NATIVE - #else - #define FLEXT_OS FLEXT_OS_UNKNOWN - #define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN - #endif - #endif + + #ifndef FLEXT_CPU + #if defined(_M_IX86) + #define FLEXT_CPU FLEXT_CPU_INTEL + #elif defined(_M_PPC) + #define FLEXT_CPU FLEXT_CPU_PPC + #elif defined(_M_MRX000) + #define FLEXT_CPU FLEXT_CPU_MIPS + #elif defined(_M_ALPHA) + #define FLEXT_CPU FLEXT_CPU_ALPHA + #else + #define FLEXT_CPU FLEXT_CPU_UNKNOWN + #endif + #endif + + #ifndef FLEXT_OS + #if defined(_WIN32) + #define FLEXT_OS FLEXT_OS_WIN + #define FLEXT_OSAPI FLEXT_OSAPI_WIN_NATIVE + #else + #define FLEXT_OS FLEXT_OS_UNKNOWN + #define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN + #endif + #endif #elif defined(__BORLANDC__) - // Borland C++ + // Borland C++ - #ifndef FLEXT_CPU - #define FLEXT_CPU FLEXT_CPU_INTEL - #endif - #ifndef FLEXT_OS - #define FLEXT_OS FLEXT_OS_WIN - #define FLEXT_OSAPI FLEXT_OSAPI_WIN_NATIVE - #else - #define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN - #endif + #ifndef FLEXT_CPU + #define FLEXT_CPU FLEXT_CPU_INTEL + #endif + #ifndef FLEXT_OS + #define FLEXT_OS FLEXT_OS_WIN + #define FLEXT_OSAPI FLEXT_OSAPI_WIN_NATIVE + #else + #define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN + #endif #elif defined(__MWERKS__) - // Metrowerks CodeWarrior - - #ifdef __MACH__ - // quick fix for OSX Mach-O - #define TARGET_CPU_PPC 1 - #define TARGET_OS_MAC 1 - #define TARGET_API_MAC_OSX 1 - #else - #ifndef __CONDITIONALMACROS__ - #include - #endif - #endif - - #ifndef FLEXT_CPU - #if TARGET_CPU_X86 - #define FLEXT_CPU FLEXT_CPU_INTEL - #elif TARGET_CPU_PPC - #define FLEXT_CPU FLEXT_CPU_PPC - #elif TARGET_CPU_MIPS - #define FLEXT_CPU FLEXT_CPU_MIPS - #elif TARGET_CPU_ALPHA - #define FLEXT_CPU FLEXT_CPU_ALPHA - #else - #define FLEXT_CPU FLEXT_CPU_UNKNOWN - #endif - #endif - - #ifndef FLEXT_OS - #if TARGET_OS_MAC - #define FLEXT_OS FLEXT_OS_MAC - #elif TARGET_OS_WIN32 - // assume Windows - #define FLEXT_OS FLEXT_OS_WIN - #else - #define FLEXT_OS FLEXT_OS_UNKNOWN - #endif - #endif - - #ifndef FLEXT_OSAPI - #if TARGET_API_MAC_MACH - // this is for Mach-O - // this has the precedence (MACH also supports Carbon, of course) - #define FLEXT_OSAPI FLEXT_OSAPI_MAC_MACH - #elif TARGET_API_MAC_CARBON - // this is for CFM - #define FLEXT_OSAPI FLEXT_OSAPI_MAC_CARBON - #else - #define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN - #endif - #endif - - // This is important for method and attribute callbacks - #pragma enumsalwaysint on - // This is important for everything - #pragma bool on + // Metrowerks CodeWarrior + + #ifdef __MACH__ + // quick fix for OSX Mach-O + #define TARGET_CPU_PPC 1 + #define TARGET_OS_MAC 1 + #define TARGET_API_MAC_OSX 1 + #else + #ifndef __CONDITIONALMACROS__ + #include + #endif + #endif + + #ifndef FLEXT_CPU + #if TARGET_CPU_X86 + #define FLEXT_CPU FLEXT_CPU_INTEL + #elif TARGET_CPU_PPC + #define FLEXT_CPU FLEXT_CPU_PPC + #elif TARGET_CPU_MIPS + #define FLEXT_CPU FLEXT_CPU_MIPS + #elif TARGET_CPU_ALPHA + #define FLEXT_CPU FLEXT_CPU_ALPHA + #else + #define FLEXT_CPU FLEXT_CPU_UNKNOWN + #endif + #endif + + #ifndef FLEXT_OS + #if TARGET_OS_MAC + #define FLEXT_OS FLEXT_OS_MAC + #elif TARGET_OS_WIN32 + // assume Windows + #define FLEXT_OS FLEXT_OS_WIN + #else + #define FLEXT_OS FLEXT_OS_UNKNOWN + #endif + #endif + + #ifndef FLEXT_OSAPI + #if TARGET_API_MAC_MACH + // this is for Mach-O + // this has the precedence (MACH also supports Carbon, of course) + #define FLEXT_OSAPI FLEXT_OSAPI_MAC_MACH + #elif TARGET_API_MAC_CARBON + // this is for CFM + #define FLEXT_OSAPI FLEXT_OSAPI_MAC_CARBON + #else + #define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN + #endif + #endif + + // This is important for method and attribute callbacks + #pragma enumsalwaysint on + // This is important for everything + #pragma bool on #elif defined(__GNUG__) || (defined(__ICC) && (FLEXT_OS == FLEXT_OS_LINUX || defined(linux) || defined(__linux__))) - // GNU C++ + // GNU C++ // and Intel (as suggested by Tim Blechmann) - #ifndef FLEXT_CPU - #if defined(_X86_) || defined(__i386__) || defined(__i586__) || defined(__i686__) - #define FLEXT_CPU FLEXT_CPU_INTEL - #elif defined(__POWERPC__) - #define FLEXT_CPU FLEXT_CPU_PPC - #elif defined(__MIPS__) - #define FLEXT_CPU FLEXT_CPU_MIPS - #else - #define FLEXT_CPU FLEXT_CPU_UNKNOWN - #endif - #endif - - #ifndef FLEXT_OS - #if defined(linux) || defined(__linux__) - #define FLEXT_OS FLEXT_OS_LINUX - #elif defined(__CYGWIN__) || defined(__CYGWIN32__) || defined(__MINGW32__) - #define FLEXT_OS FLEXT_OS_WIN - #elif defined(__APPLE__) && defined(__MACH__) - #define FLEXT_OS FLEXT_OS_MAC - // how about IRIX?? - #else - #define FLEXT_OS FLEXT_OS_UNKNOWN - #endif - #endif - - #ifndef FLEXT_OSAPI - #if FLEXT_OS == FLEXT_OS_MAC - #define FLEXT_OSAPI FLEXT_OSAPI_MAC_MACH - #elif FLEXT_OS == FLEXT_OS_WIN + #ifndef FLEXT_CPU + #if defined(_X86_) || defined(__i386__) || defined(__i586__) || defined(__i686__) + #define FLEXT_CPU FLEXT_CPU_INTEL + #elif defined(__POWERPC__) + #define FLEXT_CPU FLEXT_CPU_PPC + #elif defined(__MIPS__) + #define FLEXT_CPU FLEXT_CPU_MIPS + #else + #define FLEXT_CPU FLEXT_CPU_UNKNOWN + #endif + #endif + + #ifndef FLEXT_OS + #if defined(linux) || defined(__linux__) + #define FLEXT_OS FLEXT_OS_LINUX + #elif defined(__CYGWIN__) || defined(__CYGWIN32__) || defined(__MINGW32__) + #define FLEXT_OS FLEXT_OS_WIN + #elif defined(__APPLE__) && defined(__MACH__) + #define FLEXT_OS FLEXT_OS_MAC + // how about IRIX?? + #else + #define FLEXT_OS FLEXT_OS_UNKNOWN + #endif + #endif + + #ifndef FLEXT_OSAPI + #if FLEXT_OS == FLEXT_OS_MAC + #define FLEXT_OSAPI FLEXT_OSAPI_MAC_MACH + #elif FLEXT_OS == FLEXT_OS_WIN #if defined(__MINGW32__) - #define FLEXT_OSAPI FLEXT_OSAPI_WIN_NATIVE + #define FLEXT_OSAPI FLEXT_OSAPI_WIN_NATIVE #else - #define FLEXT_OSAPI FLEXT_OSAPI_WIN_POSIX + #define FLEXT_OSAPI FLEXT_OSAPI_WIN_POSIX #endif - #elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX - #define FLEXT_OSAPI FLEXT_OSAPI_UNIX_POSIX - #else - #define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN - #endif - #endif + #elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX + #define FLEXT_OSAPI FLEXT_OSAPI_UNIX_POSIX + #else + #define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN + #endif + #endif #elif defined(__MRC__) && defined(MPW_CPLUS) - // Apple MPW MrCpp - - #if __MRC__ < 0x500 - #error Apple MPW MrCpp v.5.0.0 or later compiler required - #endif - - #ifndef FLEXT_CPU - #if defined(__POWERPC__) - #define FLEXT_CPU FLEXT_CPU_PPC - #else - #define FLEXT_CPU FLEXT_CPU_UNKNOWN - #endif - #endif - - #ifndef FLEXT_OS - #if defined(macintosh) - #define FLEXT_OS FLEXT_OS_MAC - #else - #define FLEXT_OS FLEXT_OS_UNKNOWN - #endif - #endif - - #ifndef FLEXT_OSAPI - #if FLEXT_OS == FLEXT_OS_MAC - #define FLEXT_OSAPI FLEXT_OSAPI_MAC_CLASSIC - #else - #define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN - #endif - #endif + // Apple MPW MrCpp + + #if __MRC__ < 0x500 + #error Apple MPW MrCpp v.5.0.0 or later compiler required + #endif + + #ifndef FLEXT_CPU + #if defined(__POWERPC__) + #define FLEXT_CPU FLEXT_CPU_PPC + #else + #define FLEXT_CPU FLEXT_CPU_UNKNOWN + #endif + #endif + + #ifndef FLEXT_OS + #if defined(macintosh) + #define FLEXT_OS FLEXT_OS_MAC + #else + #define FLEXT_OS FLEXT_OS_UNKNOWN + #endif + #endif + + #ifndef FLEXT_OSAPI + #if FLEXT_OS == FLEXT_OS_MAC + #define FLEXT_OSAPI FLEXT_OSAPI_MAC_CLASSIC + #else + #define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN + #endif + #endif #endif #if FLEXT_OS == FLEXT_OS_WIN -// #pragma message("Compiling for Windows") - - #if FLEXT_SYS == FLEXT_SYS_MAX -// #define WIN_VERSION 1 - #elif FLEXT_SYS == FLEXT_SYS_PD -// #define PD -// #define NT - #endif +// #pragma message("Compiling for Windows") + + #if FLEXT_SYS == FLEXT_SYS_MAX +// #define WIN_VERSION 1 + #elif FLEXT_SYS == FLEXT_SYS_PD +// #define PD +// #define NT + #endif #elif FLEXT_OS == FLEXT_OS_LINUX -// #pragma message("Compiling for Linux") +// #pragma message("Compiling for Linux") - #if FLEXT_SYS == FLEXT_SYS_PD -// #define PD - #else - #error "Flext SYS/OS combination unknown" - #endif + #if FLEXT_SYS == FLEXT_SYS_PD +// #define PD + #else + #error "Flext SYS/OS combination unknown" + #endif #elif FLEXT_OS == FLEXT_OS_IRIX -// #pragma message("Compiling for Irix") +// #pragma message("Compiling for Irix") - #if FLEXT_SYS == FLEXT_SYS_PD -// #define PD - #else - #error "Flext SYS/OS combination unknown" - #endif + #if FLEXT_SYS == FLEXT_SYS_PD +// #define PD + #else + #error "Flext SYS/OS combination unknown" + #endif #elif FLEXT_OS == FLEXT_OS_MAC -// #pragma message("Compiling for MacOS") +// #pragma message("Compiling for MacOS") - #if FLEXT_SYS == FLEXT_SYS_PD -// #define PD - #endif + #if FLEXT_SYS == FLEXT_SYS_PD +// #define PD + #endif #else - #error "Operating system could not be determined" + #error "Operating system could not be determined" #endif #if FLEXT_SYS == FLEXT_SYS_MAX -// #pragma message("Compiling for Max/MSP") +// #pragma message("Compiling for Max/MSP") #elif FLEXT_SYS == FLEXT_SYS_PD -// #pragma message("Compiling for PD") +// #pragma message("Compiling for PD") #endif // ----- set threading model ----- // shared builds are always threaded (although this not be so....) #ifdef FLEXT_SHARED - #undef FLEXT_THREADS - #define FLEXT_THREADS + #undef FLEXT_THREADS + #define FLEXT_THREADS /* - // and also enabled for virtual daughter-classes?? - #undef FLEXT_VIRT - #define FLEXT_VIRT + // and also enabled for virtual daughter-classes?? + #undef FLEXT_VIRT + #define FLEXT_VIRT */ #endif #ifdef FLEXT_THREADS - #undef FLEXT_THREADS - #if FLEXT_OS == FLEXT_OS_MAC && FLEXT_SYS == FLEXT_SYS_MAX - // Max crashes with posix threads (because it's in the CFM model) - #define FLEXT_THREADS FLEXT_THR_MP - #elif FLEXT_SYS == FLEXT_SYS_MAX && FLEXT_OS == FLEXT_OS_WIN - // for wmax use native Windows threads - #define FLEXT_THREADS FLEXT_THR_WIN32 - #else - #define FLEXT_THREADS FLEXT_THR_POSIX - #endif + #undef FLEXT_THREADS + #if FLEXT_OS == FLEXT_OS_MAC && FLEXT_SYS == FLEXT_SYS_MAX + // Max crashes with posix threads (because it's in the CFM model) + #define FLEXT_THREADS FLEXT_THR_MP + #elif FLEXT_SYS == FLEXT_SYS_MAX && FLEXT_OS == FLEXT_OS_WIN + // for wmax use native Windows threads + #define FLEXT_THREADS FLEXT_THR_WIN32 + #else + #define FLEXT_THREADS FLEXT_THR_POSIX + #endif #endif // ----- macros for class names ----- /* With linux (flat linker namespace) and more than one flext-based external loaded all calls to static exported functions refer to the first instance loaded! - Therefore different class names are used so that the correct type of flext function is called. + Therefore different class names are used so that the correct type of flext function is called. */ #if defined(FLEXT_SHARED) - #define FLEXT_CLASSDEF(CL) CL##_shared + #define FLEXT_CLASSDEF(CL) CL##_shared #elif defined(FLEXT_THREADS) - #define FLEXT_CLASSDEF(CL) CL##_multi + #define FLEXT_CLASSDEF(CL) CL##_multi #else - #define FLEXT_CLASSDEF(CL) CL##_single + #define FLEXT_CLASSDEF(CL) CL##_single #endif // std namespace diff --git a/externals/grill/flext/source/flproxy.cpp b/externals/grill/flext/source/flproxy.cpp index 4406fd07..c2f906b3 100755 --- a/externals/grill/flext/source/flproxy.cpp +++ b/externals/grill/flext/source/flproxy.cpp @@ -24,18 +24,18 @@ t_class *flext_base::px_class = NULL; void flext_base::px_object::px_method(px_object *obj,const t_symbol *s,int argc,t_atom *argv) { - obj->base->m_methodmain(obj->index,s,argc,argv); + obj->base->m_methodmain(obj->index,s,argc,argv); } void flext_base::cb_px_anything(t_class *c,const t_symbol *s,int argc,t_atom *argv) { - thisObject(c)->m_methodmain(0,s,argc,argv); + thisObject(c)->m_methodmain(0,s,argc,argv); } #define DEF_IN_FT(IX) \ void flext_base::cb_px_ft ## IX(t_class *c,float v) { \ - t_atom atom; SETFLOAT(&atom,v); \ - thisObject(c)->m_methodmain(IX,sym_float,1,&atom); \ + t_atom atom; SETFLOAT(&atom,v); \ + thisObject(c)->m_methodmain(IX,sym_float,1,&atom); \ } #define ADD_IN_FT(IX) \ @@ -45,11 +45,11 @@ add_method1(c,cb_px_ft ## IX,"ft" #IX,A_FLOAT) void flext_base::cb_px_anything(t_class *c,const t_symbol *s,short argc,t_atom *argv) { - // check if inlet allows anything (or list) - - flext_base *o = thisObject(c); - int ci = ((flext_hdr *)o->x_obj)->curinlet; - o->m_methodmain(ci,s,argc,argv); + // check if inlet allows anything (or list) + + flext_base *o = thisObject(c); + int ci = ((flext_hdr *)o->x_obj)->curinlet; + o->m_methodmain(ci,s,argc,argv); } #if 0 //FLEXT_OS == FLEXT_OS_WIN @@ -57,45 +57,45 @@ void flext_base::cb_px_anything(t_class *c,const t_symbol *s,short argc,t_atom * void flext_base::cb_px_int(t_class *c,long v) { - flext_base *o = thisObject(c); - int ci = proxy_getinlet((t_object *)o->x_obj); - // check if inlet allows int type - t_atom atom; - SetInt(atom,v); - o->m_methodmain(ci,sym_int,1,&atom); + flext_base *o = thisObject(c); + int ci = proxy_getinlet((t_object *)o->x_obj); + // check if inlet allows int type + t_atom atom; + SetInt(atom,v); + o->m_methodmain(ci,sym_int,1,&atom); } void flext_base::cb_px_float(t_class *c,double v) { - flext_base *o = thisObject(c); - int ci = proxy_getinlet((t_object *)o->x_obj); - // check if inlet allows float type - t_atom atom; - SetFloat(atom,v); - o->m_methodmain(ci,sym_float,1,&atom); + flext_base *o = thisObject(c); + int ci = proxy_getinlet((t_object *)o->x_obj); + // check if inlet allows float type + t_atom atom; + SetFloat(atom,v); + o->m_methodmain(ci,sym_float,1,&atom); } #else void flext_base::cb_px_int(t_class *c,long v) { - // check if inlet allows int type - t_atom atom; - SetInt(atom,v); - cb_px_anything(c,sym_int,1,&atom); + // check if inlet allows int type + t_atom atom; + SetInt(atom,v); + cb_px_anything(c,sym_int,1,&atom); } void flext_base::cb_px_float(t_class *c,double v) { - // check if inlet allows float type - t_atom atom; - SetFloat(atom,v); - cb_px_anything(c,sym_float,1,&atom); + // check if inlet allows float type + t_atom atom; + SetFloat(atom,v); + cb_px_anything(c,sym_float,1,&atom); } #endif void flext_base::cb_px_bang(t_class *c) { - // check if inlet allows bang - cb_px_anything(c,sym_bang,0,NULL); + // check if inlet allows bang + cb_px_anything(c,sym_bang,0,NULL); } @@ -123,50 +123,50 @@ DEF_IN_FT(9) void flext_base::SetProxies(t_class *c) { - // proxy for extra inlets + // proxy for extra inlets #if FLEXT_SYS == FLEXT_SYS_PD - add_anything(c,cb_px_anything); // for leftmost inlet + add_anything(c,cb_px_anything); // for leftmost inlet px_class = class_new(gensym("flext_base proxy"),NULL,NULL,sizeof(px_object),CLASS_PD|CLASS_NOINLET, A_NULL); - add_anything(px_class,px_object::px_method); // for other inlets + add_anything(px_class,px_object::px_method); // for other inlets #elif FLEXT_SYS == FLEXT_SYS_MAX - add_bang(c,cb_px_bang); - add_method1(c,cb_px_int,"int",A_INT); - add_method1(c,cb_px_float,"float",A_FLOAT); - add_methodG(c,cb_px_anything,"list"); - add_anything(c,cb_px_anything); + add_bang(c,cb_px_bang); + add_method1(c,cb_px_int,"int",A_INT); + add_method1(c,cb_px_float,"float",A_FLOAT); + add_methodG(c,cb_px_anything,"list"); + add_anything(c,cb_px_anything); #else #error Not implemented! -#endif +#endif #if 0 //FLEXT_SYS == FLEXT_SYS_MAX && FLEXT_OS == FLEXT_OS_WIN - // could also work for OSX! - addint((method)cb_px_int); - addfloat((method)cb_px_float); + // could also work for OSX! + addint((method)cb_px_int); + addfloat((method)cb_px_float); #else - // setup non-leftmost ints and floats - ADD_IN_FT(1); - ADD_IN_FT(2); - ADD_IN_FT(3); - ADD_IN_FT(4); - ADD_IN_FT(5); - ADD_IN_FT(6); - ADD_IN_FT(7); - ADD_IN_FT(8); - ADD_IN_FT(9); + // setup non-leftmost ints and floats + ADD_IN_FT(1); + ADD_IN_FT(2); + ADD_IN_FT(3); + ADD_IN_FT(4); + ADD_IN_FT(5); + ADD_IN_FT(6); + ADD_IN_FT(7); + ADD_IN_FT(8); + ADD_IN_FT(9); #endif } #elif FLEXT_SYS == FLEXT_SYS_JMAX void flext_base::jmax_proxy(fts_object_t *c, int winlet, fts_symbol_t s, int argc, const fts_atom_t *argv) { - flext_base *o = thisObject(c); - o->m_methodmain(winlet,s,argc,argv); + flext_base *o = thisObject(c); + o->m_methodmain(winlet,s,argc,argv); } void flext_base::SetProxies(t_class *c) { - fts_class_set_default_handler(c, jmax_proxy); + fts_class_set_default_handler(c, jmax_proxy); } #endif diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp index aaf82fef..41941734 100755 --- a/externals/grill/flext/source/flqueue.cpp +++ b/externals/grill/flext/source/flqueue.cpp @@ -27,43 +27,43 @@ flext::thrid_t flext::thrmsgid = 0; class qmsg { public: - qmsg(flext_base *b): nxt(NULL),th(b),tp(tp_none) {} - ~qmsg(); - - qmsg *nxt; - - void Clear(); - - void SetBang(int o) { Clear(); out = o; tp = tp_bang; } - void SetFloat(int o,float f) { Clear(); out = o; tp = tp_float; _float = f; } - void SetInt(int o,int i) { Clear(); out = o; tp = tp_int; _int = i; } - void SetSymbol(int o,const t_symbol *s) { Clear(); out = o; tp = tp_sym; _sym = s; } - void SetList(int o,int argc,const t_atom *argv) { Clear(); out = o; tp = tp_list; _list.argc = argc,_list.argv = flext::CopyList(argc,argv); } - void SetAny(int o,const t_symbol *s,int argc,const t_atom *argv) { Clear(); out = o; tp = tp_any; _any.s = s,_any.argc = argc,_any.argv = flext::CopyList(argc,argv); } - - flext_base *th; - int out; - enum { tp_none,tp_bang,tp_float,tp_int,tp_sym,tp_list,tp_any } tp; - union { - float _float; - int _int; - const t_symbol *_sym; - struct { int argc; t_atom *argv; } _list; - struct { const t_symbol *s; int argc; t_atom *argv; } _any; - }; + qmsg(flext_base *b): nxt(NULL),th(b),tp(tp_none) {} + ~qmsg(); + + qmsg *nxt; + + void Clear(); + + void SetBang(int o) { Clear(); out = o; tp = tp_bang; } + void SetFloat(int o,float f) { Clear(); out = o; tp = tp_float; _float = f; } + void SetInt(int o,int i) { Clear(); out = o; tp = tp_int; _int = i; } + void SetSymbol(int o,const t_symbol *s) { Clear(); out = o; tp = tp_sym; _sym = s; } + void SetList(int o,int argc,const t_atom *argv) { Clear(); out = o; tp = tp_list; _list.argc = argc,_list.argv = flext::CopyList(argc,argv); } + void SetAny(int o,const t_symbol *s,int argc,const t_atom *argv) { Clear(); out = o; tp = tp_any; _any.s = s,_any.argc = argc,_any.argv = flext::CopyList(argc,argv); } + + flext_base *th; + int out; + enum { tp_none,tp_bang,tp_float,tp_int,tp_sym,tp_list,tp_any } tp; + union { + float _float; + int _int; + const t_symbol *_sym; + struct { int argc; t_atom *argv; } _list; + struct { const t_symbol *s; int argc; t_atom *argv; } _any; + }; }; qmsg::~qmsg() { - Clear(); - if(nxt) delete nxt; + Clear(); + if(nxt) delete nxt; } void qmsg::Clear() { - if(tp == tp_list) { if(_list.argv) delete[] _list.argv; } - else if(tp == tp_any) { if(_any.argv) delete[] _any.argv; } - tp = tp_none; + if(tp == tp_list) { if(_list.argv) delete[] _list.argv; } + else if(tp == tp_any) { if(_any.argv) delete[] _any.argv; } + tp = tp_none; } static volatile int qcnt = 0; @@ -83,94 +83,94 @@ static flext::ThrMutex qmutex; static void QWork(bool qlock,bool syslock) { - for(;;) { - // Since qcnt can only be increased from any other function than QWork - // qc will be a minimum guaranteed number of present queue elements. - // On the other hand, if new queue elements are added by the methods called - // in the loop, these will be sent in the next tick to avoid recursion overflow. - int qc = qcnt; - if(!qc) break; - - #ifdef FLEXT_QTHR - if(syslock) sys_lock(); - #endif - - for(int i = 0; i < qc && qhead; ++i) { - #ifdef FLEXT_THREADS - if(qlock) qmutex.Lock(); - #endif - qmsg *m = qhead; - qcnt--; - qhead = m->nxt; - if(!qhead) qtail = NULL; - m->nxt = NULL; - #ifdef FLEXT_THREADS - if(qlock) qmutex.Unlock(); - #endif - - if(m->out < 0) { - // message to self - - const int n = -1-m->out; - t_atom tmp; - - switch(m->tp) { - case qmsg::tp_bang: - m->th->m_methodmain(n,flext::sym_bang,0,&tmp); - break; - case qmsg::tp_float: - flext::SetFloat(tmp,m->_float); - m->th->m_methodmain(n,flext::sym_float,1,&tmp); - break; - case qmsg::tp_int: - flext::SetInt(tmp,m->_int); - #if FLEXT_SYS == FLEXT_SYS_PD - m->th->m_methodmain(n,flext::sym_float,1,&tmp); - #elif FLEXT_SYS == FLEXT_SYS_MAX - m->th->m_methodmain(n,flext::sym_int,1,&tmp); - #else - #error Not implemented! - #endif - case qmsg::tp_sym: - flext::SetSymbol(tmp,m->_sym); - m->th->m_methodmain(n,flext::sym_symbol,1,&tmp); - break; - case qmsg::tp_list: - m->th->m_methodmain(n,flext::sym_list,m->_list.argc,m->_list.argv); - break; - case qmsg::tp_any: - m->th->m_methodmain(n,m->_any.s,m->_any.argc,m->_any.argv); - break; - #ifdef FLEXT_DEBUG - default: ERRINTERNAL(); - #endif - } - } - else { - // message to outlet - - switch(m->tp) { - case qmsg::tp_bang: m->th->ToSysBang(m->out); break; - case qmsg::tp_float: m->th->ToSysFloat(m->out,m->_float); break; - case qmsg::tp_int: m->th->ToSysInt(m->out,m->_int); break; - case qmsg::tp_sym: m->th->ToSysSymbol(m->out,m->_sym); break; - case qmsg::tp_list: m->th->ToSysList(m->out,m->_list.argc,m->_list.argv); break; - case qmsg::tp_any: m->th->ToSysAnything(m->out,m->_any.s,m->_any.argc,m->_any.argv); break; - #ifdef FLEXT_DEBUG - default: ERRINTERNAL(); - #endif - } - } - - // delete processed queue element - delete m; - } // inner loop - - #ifdef FLEXT_QTHR - if(syslock) sys_unlock(); - #endif - - } // for(;;) + for(;;) { + // Since qcnt can only be increased from any other function than QWork + // qc will be a minimum guaranteed number of present queue elements. + // On the other hand, if new queue elements are added by the methods called + // in the loop, these will be sent in the next tick to avoid recursion overflow. + int qc = qcnt; + if(!qc) break; + + #ifdef FLEXT_QTHR + if(syslock) sys_lock(); + #endif + + for(int i = 0; i < qc && qhead; ++i) { + #ifdef FLEXT_THREADS + if(qlock) qmutex.Lock(); + #endif + qmsg *m = qhead; + qcnt--; + qhead = m->nxt; + if(!qhead) qtail = NULL; + m->nxt = NULL; + #ifdef FLEXT_THREADS + if(qlock) qmutex.Unlock(); + #endif + + if(m->out < 0) { + // message to self + + const int n = -1-m->out; + t_atom tmp; + + switch(m->tp) { + case qmsg::tp_bang: + m->th->m_methodmain(n,flext::sym_bang,0,&tmp); + break; + case qmsg::tp_float: + flext::SetFloat(tmp,m->_float); + m->th->m_methodmain(n,flext::sym_float,1,&tmp); + break; + case qmsg::tp_int: + flext::SetInt(tmp,m->_int); + #if FLEXT_SYS == FLEXT_SYS_PD + m->th->m_methodmain(n,flext::sym_float,1,&tmp); + #elif FLEXT_SYS == FLEXT_SYS_MAX + m->th->m_methodmain(n,flext::sym_int,1,&tmp); + #else + #error Not implemented! + #endif + case qmsg::tp_sym: + flext::SetSymbol(tmp,m->_sym); + m->th->m_methodmain(n,flext::sym_symbol,1,&tmp); + break; + case qmsg::tp_list: + m->th->m_methodmain(n,flext::sym_list,m->_list.argc,m->_list.argv); + break; + case qmsg::tp_any: + m->th->m_methodmain(n,m->_any.s,m->_any.argc,m->_any.argv); + break; + #ifdef FLEXT_DEBUG + default: ERRINTERNAL(); + #endif + } + } + else { + // message to outlet + + switch(m->tp) { + case qmsg::tp_bang: m->th->ToSysBang(m->out); break; + case qmsg::tp_float: m->th->ToSysFloat(m->out,m->_float); break; + case qmsg::tp_int: m->th->ToSysInt(m->out,m->_int); break; + case qmsg::tp_sym: m->th->ToSysSymbol(m->out,m->_sym); break; + case qmsg::tp_list: m->th->ToSysList(m->out,m->_list.argc,m->_list.argv); break; + case qmsg::tp_any: m->th->ToSysAnything(m->out,m->_any.s,m->_any.argc,m->_any.argv); break; + #ifdef FLEXT_DEBUG + default: ERRINTERNAL(); + #endif + } + } + + // delete processed queue element + delete m; + } // inner loop + + #ifdef FLEXT_QTHR + if(syslock) sys_unlock(); + #endif + + } // for(;;) } #if !defined(FLEXT_QTHR) @@ -181,11 +181,11 @@ static void QTick(fts_object_t *c,int winlet, fts_symbol_t s, int ac, const fts_ static void QTick(flext_base *c) { #endif -// post("qtick"); +// post("qtick"); #ifdef FLEXT_THREADS - FLEXT_ASSERT(flext::IsSystemThread()); + FLEXT_ASSERT(flext::IsSystemThread()); #endif - QWork(true,false); + QWork(true,false); } #endif @@ -196,48 +196,48 @@ But then the order of sent messages is not as intended void flext_base::QFlush(flext_base *th) { #ifdef FLEXT_THREADS - if(!IsSystemThread()) { - error("flext - Queue flush called by wrong thread!"); - return; - } + if(!IsSystemThread()) { + error("flext - Queue flush called by wrong thread!"); + return; + } #endif #ifdef FLEXT_THREADS - qmutex.Lock(); + qmutex.Lock(); #endif - while(qcnt) QWork(false,false); + while(qcnt) QWork(false,false); #ifdef FLEXT_THREADS - qmutex.Unlock(); + qmutex.Unlock(); #endif } static void Queue(qmsg *m) { -// post("Queue"); +// post("Queue"); #ifdef FLEXT_THREADS - qmutex.Lock(); + qmutex.Lock(); #endif - if(qtail) qtail->nxt = m; - else qhead = m; - qtail = m; - qcnt++; + if(qtail) qtail->nxt = m; + else qhead = m; + qtail = m; + qcnt++; #ifdef FLEXT_THREADS - qmutex.Unlock(); + qmutex.Unlock(); #endif #if FLEXT_SYS == FLEXT_SYS_PD #ifdef FLEXT_QTHR // wake up a worker thread // (instead of triggering the clock) - qthrcond.Signal(); - #else - clock_delay(qclk,0); + qthrcond.Signal(); + #else + clock_delay(qclk,0); #endif #elif FLEXT_SYS == FLEXT_SYS_MAX - qelem_set(qclk); + qelem_set(qclk); #elif FLEXT_SYS == FLEXT_SYS_JMAX - // this is dangerous because there may be other timers on this object! - fts_timebase_add_call(fts_get_timebase(), (fts_object_t *)thisHdr(), QTick, NULL, 0); + // this is dangerous because there may be other timers on this object! + fts_timebase_add_call(fts_get_timebase(), (fts_object_t *)thisHdr(), QTick, NULL, 0); #else #error Not implemented #endif @@ -247,28 +247,28 @@ static void Queue(qmsg *m) void flext_base::QWorker(thr_params *) { thrmsgid = GetThreadId(); - for(;;) { - qthrcond.Wait(); - QWork(true,true); - } + for(;;) { + qthrcond.Wait(); + QWork(true,true); + } } #endif void flext_base::StartQueue() { - static bool started = false; - if(started) return; - else started = true; + static bool started = false; + if(started) return; + else started = true; - // message queue ticker - qhead = qtail = NULL; - qcnt = 0; + // message queue ticker + qhead = qtail = NULL; + qcnt = 0; #ifdef FLEXT_QTHR - LaunchThread(QWorker,NULL); + LaunchThread(QWorker,NULL); #else #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX - qclk = (t_qelem *)(qelem_new(NULL,(t_method)QTick)); + qclk = (t_qelem *)(qelem_new(NULL,(t_method)QTick)); #else #error Not implemented! #endif @@ -277,50 +277,50 @@ void flext_base::StartQueue() void flext_base::ToQueueBang(int o) const { - FLEXT_ASSERT(o >= 0); - qmsg *m = new qmsg(const_cast(this)); - m->SetBang(o); - Queue(m); + FLEXT_ASSERT(o >= 0); + qmsg *m = new qmsg(const_cast(this)); + m->SetBang(o); + Queue(m); } void flext_base::ToQueueFloat(int o,float f) const { - FLEXT_ASSERT(o >= 0); - qmsg *m = new qmsg(const_cast(this)); - m->SetFloat(o,f); - Queue(m); + FLEXT_ASSERT(o >= 0); + qmsg *m = new qmsg(const_cast(this)); + m->SetFloat(o,f); + Queue(m); } void flext_base::ToQueueInt(int o,int f) const { - FLEXT_ASSERT(o >= 0); - qmsg *m = new qmsg(const_cast(this)); - m->SetInt(o,f); - Queue(m); + FLEXT_ASSERT(o >= 0); + qmsg *m = new qmsg(const_cast(this)); + m->SetInt(o,f); + Queue(m); } void flext_base::ToQueueSymbol(int o,const t_symbol *s) const { - FLEXT_ASSERT(o >= 0); - qmsg *m = new qmsg(const_cast(this)); - m->SetSymbol(o,s); - Queue(m); + FLEXT_ASSERT(o >= 0); + qmsg *m = new qmsg(const_cast(this)); + m->SetSymbol(o,s); + Queue(m); } void flext_base::ToQueueList(int o,int argc,const t_atom *argv) const { - FLEXT_ASSERT(o >= 0); - qmsg *m = new qmsg(const_cast(this)); - m->SetList(o,argc,argv); - Queue(m); + FLEXT_ASSERT(o >= 0); + qmsg *m = new qmsg(const_cast(this)); + m->SetList(o,argc,argv); + Queue(m); } void flext_base::ToQueueAnything(int o,const t_symbol *s,int argc,const t_atom *argv) const { - FLEXT_ASSERT(o >= 0); - qmsg *m = new qmsg(const_cast(this)); - m->SetAny(o,s,argc,argv); - Queue(m); + FLEXT_ASSERT(o >= 0); + qmsg *m = new qmsg(const_cast(this)); + m->SetAny(o,s,argc,argv); + Queue(m); } diff --git a/externals/grill/flext/source/flsimd.cpp b/externals/grill/flext/source/flsimd.cpp index c14bc1b1..d3487790 100755 --- a/externals/grill/flext/source/flsimd.cpp +++ b/externals/grill/flext/source/flsimd.cpp @@ -9,7 +9,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. */ /*! \file flsimd.cpp - \brief flext SIMD support functions + \brief flext SIMD support functions If FLEXT_USE_SIMD is defined at compilation, SIMD instructions are used wherever feasible. If used with MSVC++ the "Processor Pack" must be installed. @@ -36,20 +36,20 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include // SSE2 #include // 3DNow! #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__MWERKS__) && defined(__ALTIVEC__) - #if FLEXT_OSAPI == FLEXT_OSAPI_MAC_MACH - #include - #include - #else - #include - #endif + #if FLEXT_OSAPI == FLEXT_OSAPI_MAC_MACH + #include + #include + #else + #include + #endif - #pragma altivec_model on + #pragma altivec_model on - #include - #include + #include + #include #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__GNUG__) && defined(__ALTIVEC__) - #include - #include + #include + #include #endif #endif // FLEXT_USE_SIMD @@ -57,7 +57,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. static unsigned long setsimdcaps(); /*! \brief Holds SIMD capability flags - \internal + \internal */ unsigned long flext::simdcaps = setsimdcaps(); @@ -259,7 +259,7 @@ static int _cpuid (_p_info *pinfo) /*! \brief Determine SIMD capabilities - \internal + \internal */ static unsigned long setsimdcaps() { @@ -275,23 +275,23 @@ static unsigned long setsimdcaps() #if FLEXT_OSAPI == FLEXT_OSAPI_MAC_MACH - int selectors[2] = { CTL_HW, HW_VECTORUNIT }; - int hasVectorUnit = 0; - size_t length = sizeof(hasVectorUnit); - int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0); + int selectors[2] = { CTL_HW, HW_VECTORUNIT }; + int hasVectorUnit = 0; + size_t length = sizeof(hasVectorUnit); + int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0); - if(!error && hasVectorUnit != 0) simdflags += flext::simd_altivec; - - #else + if(!error && hasVectorUnit != 0) simdflags += flext::simd_altivec; + + #else - long cpuAttributes; - Boolean hasAltiVec = false; - OSErr err = Gestalt( gestaltPowerPCProcessorFeatures, &cpuAttributes ); + long cpuAttributes; + Boolean hasAltiVec = false; + OSErr err = Gestalt( gestaltPowerPCProcessorFeatures, &cpuAttributes ); - if( noErr == err ) - if(( 1 << gestaltPowerPCHasVectorInstructions) & cpuAttributes) simdflags += flext::simd_altivec; + if( noErr == err ) + if(( 1 << gestaltPowerPCHasVectorInstructions) & cpuAttributes) simdflags += flext::simd_altivec; - #endif + #endif #endif return simdflags; } @@ -304,53 +304,53 @@ static unsigned long setsimdcaps() //! Load a vector from an unaligned location in memory inline vector unsigned char LoadUnaligned( vector unsigned char *v ) { - vector unsigned char permuteVector = vec_lvsl( 0, (int*) v ); - vector unsigned char low = vec_ld( 0, v ); - vector unsigned char high = vec_ld( 16, v ); - return vec_perm( low, high, permuteVector ); + vector unsigned char permuteVector = vec_lvsl( 0, (int*) v ); + vector unsigned char low = vec_ld( 0, v ); + vector unsigned char high = vec_ld( 16, v ); + return vec_perm( low, high, permuteVector ); } //! Store a vector to an unaligned location in memory inline void StoreUnaligned( vector unsigned char v, vector unsigned char *where) { - // Load the surrounding area - vector unsigned char low = vec_ld( 0, where ); - vector unsigned char high = vec_ld( 16, where ); - // Prepare the constants that we need - vector unsigned char permuteVector = vec_lvsr( 0, (int*) where ); - - vector unsigned char oxFF = (vector unsigned char)vec_splat_s8( -1 ); - vector unsigned char ox00 = (vector unsigned char)vec_splat_s8( 0 ); - // Make a mask for which parts of the vectors to swap out - vector unsigned char mask = vec_perm( ox00, oxFF, permuteVector ); - // Right rotate our input data - v = vec_perm( v, v, permuteVector ); - // Insert our data into the low and high vectors - low = vec_sel( v, low, mask ); - high = vec_sel( high, v, mask ); - // Store the two aligned result vectors - vec_st( low, 0, where ); - vec_st( high, 16, where ); + // Load the surrounding area + vector unsigned char low = vec_ld( 0, where ); + vector unsigned char high = vec_ld( 16, where ); + // Prepare the constants that we need + vector unsigned char permuteVector = vec_lvsr( 0, (int*) where ); + + vector unsigned char oxFF = (vector unsigned char)vec_splat_s8( -1 ); + vector unsigned char ox00 = (vector unsigned char)vec_splat_s8( 0 ); + // Make a mask for which parts of the vectors to swap out + vector unsigned char mask = vec_perm( ox00, oxFF, permuteVector ); + // Right rotate our input data + v = vec_perm( v, v, permuteVector ); + // Insert our data into the low and high vectors + low = vec_sel( v, low, mask ); + high = vec_sel( high, v, mask ); + // Store the two aligned result vectors + vec_st( low, 0, where ); + vec_st( high, 16, where ); } inline vector float LoadUnaligned(const float *v ) { - return (vector float)LoadUnaligned((vector unsigned char *)v); + return (vector float)LoadUnaligned((vector unsigned char *)v); } inline void StoreUnaligned( vector float v,float *where) { - return StoreUnaligned((vector unsigned char)v,(vector unsigned char *)where); + return StoreUnaligned((vector unsigned char)v,(vector unsigned char *)where); } inline bool IsVectorAligned(const void *where) { - return reinterpret_cast(where)&(sizeof(vector float)-1) == 0; + return reinterpret_cast(where)&(sizeof(vector float)-1) == 0; } inline vector float LoadValue(const float &f) { - return IsVectorAligned(&f)?vec_splat(vec_ld(0,(vector float *)&f),0):LoadUnaligned(&f); + return IsVectorAligned(&f)?vec_splat(vec_ld(0,(vector float *)&f),0):LoadUnaligned(&f); } #endif @@ -375,133 +375,136 @@ void flext::CopySamples(t_sample *dst,const t_sample *src,int cnt) if(GetSIMDCapabilities()&simd_sse) { // single precision - __asm { - mov eax,dword ptr [src] - prefetcht0 [eax+0] - prefetcht0 [eax+32] - } - - int n = cnt>>4; + int n = cnt>>4; cnt -= n<<4; - if((reinterpret_cast(src)&(__alignof(__m128)-1)) == 0) { - if((reinterpret_cast(dst)&(__alignof(__m128)-1)) == 0) { - // aligned src, aligned dst - __asm { - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ecx,[n] + if(!n) goto zero; + + __asm { + mov eax,dword ptr [src] + prefetcht0 [eax+0] + prefetcht0 [eax+32] + } + + if((reinterpret_cast(src)&(__alignof(__m128)-1)) == 0) { + if((reinterpret_cast(dst)&(__alignof(__m128)-1)) == 0) { + // aligned src, aligned dst + __asm { + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ecx,[n] loopaa: - prefetcht0 [eax+64] - prefetcht0 [eax+96] - movaps xmm0,xmmword ptr[eax] - movaps xmmword ptr[edx],xmm0 - movaps xmm1,xmmword ptr[eax+4*4] - movaps xmmword ptr[edx+4*4],xmm1 - movaps xmm2,xmmword ptr[eax+8*4] - movaps xmmword ptr[edx+8*4],xmm2 - movaps xmm3,xmmword ptr[eax+12*4] - movaps xmmword ptr[edx+12*4],xmm3 - - add eax,16*4 - add edx,16*4 - loop loopaa - } - } - else { - // aligned src, unaligned dst - __asm { - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ecx,[n] + prefetcht0 [eax+64] + prefetcht0 [eax+96] + movaps xmm0,xmmword ptr[eax] + movaps xmmword ptr[edx],xmm0 + movaps xmm1,xmmword ptr[eax+4*4] + movaps xmmword ptr[edx+4*4],xmm1 + movaps xmm2,xmmword ptr[eax+8*4] + movaps xmmword ptr[edx+8*4],xmm2 + movaps xmm3,xmmword ptr[eax+12*4] + movaps xmmword ptr[edx+12*4],xmm3 + + add eax,16*4 + add edx,16*4 + loop loopaa + } + } + else { + // aligned src, unaligned dst + __asm { + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ecx,[n] loopau: - prefetcht0 [eax+64] - prefetcht0 [eax+96] - movaps xmm0,xmmword ptr[eax] - movups xmmword ptr[edx],xmm0 - movaps xmm1,xmmword ptr[eax+4*4] - movups xmmword ptr[edx+4*4],xmm1 - movaps xmm2,xmmword ptr[eax+8*4] - movups xmmword ptr[edx+8*4],xmm2 - movaps xmm3,xmmword ptr[eax+12*4] - movups xmmword ptr[edx+12*4],xmm3 - - add eax,16*4 - add edx,16*4 - loop loopau - } - } - } - else { - if((reinterpret_cast(dst)&(__alignof(__m128)-1)) == 0) { - // unaligned src, aligned dst - __asm { - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ecx,[n] + prefetcht0 [eax+64] + prefetcht0 [eax+96] + movaps xmm0,xmmword ptr[eax] + movups xmmword ptr[edx],xmm0 + movaps xmm1,xmmword ptr[eax+4*4] + movups xmmword ptr[edx+4*4],xmm1 + movaps xmm2,xmmword ptr[eax+8*4] + movups xmmword ptr[edx+8*4],xmm2 + movaps xmm3,xmmword ptr[eax+12*4] + movups xmmword ptr[edx+12*4],xmm3 + + add eax,16*4 + add edx,16*4 + loop loopau + } + } + } + else { + if((reinterpret_cast(dst)&(__alignof(__m128)-1)) == 0) { + // unaligned src, aligned dst + __asm { + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ecx,[n] loopua: - prefetcht0 [eax+64] - prefetcht0 [eax+96] - movups xmm0,xmmword ptr[eax] - movaps xmmword ptr[edx],xmm0 - movups xmm1,xmmword ptr[eax+4*4] - movaps xmmword ptr[edx+4*4],xmm1 - movups xmm2,xmmword ptr[eax+8*4] - movaps xmmword ptr[edx+8*4],xmm2 - movups xmm3,xmmword ptr[eax+12*4] - movaps xmmword ptr[edx+12*4],xmm3 - - add eax,16*4 - add edx,16*4 - loop loopua - } - } - else { - // unaligned src, unaligned dst - __asm { - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ecx,[n] + prefetcht0 [eax+64] + prefetcht0 [eax+96] + movups xmm0,xmmword ptr[eax] + movaps xmmword ptr[edx],xmm0 + movups xmm1,xmmword ptr[eax+4*4] + movaps xmmword ptr[edx+4*4],xmm1 + movups xmm2,xmmword ptr[eax+8*4] + movaps xmmword ptr[edx+8*4],xmm2 + movups xmm3,xmmword ptr[eax+12*4] + movaps xmmword ptr[edx+12*4],xmm3 + + add eax,16*4 + add edx,16*4 + loop loopua + } + } + else { + // unaligned src, unaligned dst + __asm { + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ecx,[n] loopuu: - prefetcht0 [eax+64] - prefetcht0 [eax+96] - movups xmm0,xmmword ptr[eax] - movups xmmword ptr[edx],xmm0 - movups xmm1,xmmword ptr[eax+4*4] - movups xmmword ptr[edx+4*4],xmm1 - movups xmm2,xmmword ptr[eax+8*4] - movups xmmword ptr[edx+8*4],xmm2 - movups xmm3,xmmword ptr[eax+12*4] - movups xmmword ptr[edx+12*4],xmm3 - - add eax,16*4 - add edx,16*4 - loop loopuu - } - } - } - while(cnt--) *(dst++) = *(src++); + prefetcht0 [eax+64] + prefetcht0 [eax+96] + movups xmm0,xmmword ptr[eax] + movups xmmword ptr[edx],xmm0 + movups xmm1,xmmword ptr[eax+4*4] + movups xmmword ptr[edx+4*4],xmm1 + movups xmm2,xmmword ptr[eax+8*4] + movups xmmword ptr[edx+8*4],xmm2 + movups xmm3,xmmword ptr[eax+12*4] + movups xmmword ptr[edx+12*4],xmm3 + + add eax,16*4 + add edx,16*4 + loop loopuu + } + } + } +zero: + while(cnt--) *(dst++) = *(src++); } else #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__VECTOROPS__) if(true) { - int n = cnt>>2,n4 = n<<2; - vScopy(n4,(vector float *)src,(vector float *)dst); - cnt -= n4,src += n4,dst += n4; - while(cnt--) *(dst++) = *(src++); - } - else + int n = cnt>>2,n4 = n<<2; + vScopy(n4,(vector float *)src,(vector float *)dst); + cnt -= n4,src += n4,dst += n4; + while(cnt--) *(dst++) = *(src++); + } + else #endif // _MSC_VER #endif // FLEXT_USE_SIMD { - int n = cnt>>3; - cnt -= n<<3; - while(n--) { - dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2]; dst[3] = src[3]; - dst[4] = src[4]; dst[5] = src[5]; dst[6] = src[6]; dst[7] = src[7]; - src += 8,dst += 8; - } - while(cnt--) *(dst++) = *(src++); + int n = cnt>>3; + cnt -= n<<3; + while(n--) { + dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2]; dst[3] = src[3]; + dst[4] = src[4]; dst[5] = src[5]; dst[6] = src[6]; dst[7] = src[7]; + src += 8,dst += 8; + } + while(cnt--) *(dst++) = *(src++); } #endif } @@ -513,146 +516,146 @@ static const vector float zero = (vector float)(0); static void SetAltivec(t_sample *dst,int cnt,t_sample s) { - vector float svec = LoadValue(s); - int n = cnt>>4; + vector float svec = LoadValue(s); + int n = cnt>>4; cnt -= n<<4; - while(n--) { - vec_st(svec,0,dst); - vec_st(svec,16,dst); - vec_st(svec,32,dst); - vec_st(svec,48,dst); - dst += 16; - } + while(n--) { + vec_st(svec,0,dst); + vec_st(svec,16,dst); + vec_st(svec,32,dst); + vec_st(svec,48,dst); + dst += 16; + } while(cnt--) *(dst++) = s; } static void MulAltivec(t_sample *dst,const t_sample *src,t_sample op,int cnt) { - const vector float arg = LoadValue(op); - int n = cnt>>4; + const vector float arg = LoadValue(op); + int n = cnt>>4; cnt -= n<<4; - for(; n--; src += 16,dst += 16) { - vector float a1 = vec_ld( 0,src); - vector float a2 = vec_ld(16,src); - vector float a3 = vec_ld(32,src); - vector float a4 = vec_ld(48,src); - - a1 = vec_madd(a1,arg,zero); - a2 = vec_madd(a2,arg,zero); - a3 = vec_madd(a3,arg,zero); - a4 = vec_madd(a4,arg,zero); - - vec_st(a1, 0,dst); - vec_st(a2,16,dst); - vec_st(a3,32,dst); - vec_st(a4,48,dst); - } + for(; n--; src += 16,dst += 16) { + vector float a1 = vec_ld( 0,src); + vector float a2 = vec_ld(16,src); + vector float a3 = vec_ld(32,src); + vector float a4 = vec_ld(48,src); + + a1 = vec_madd(a1,arg,zero); + a2 = vec_madd(a2,arg,zero); + a3 = vec_madd(a3,arg,zero); + a4 = vec_madd(a4,arg,zero); + + vec_st(a1, 0,dst); + vec_st(a2,16,dst); + vec_st(a3,32,dst); + vec_st(a4,48,dst); + } while(cnt--) *(dst++) = *(src++)*op; } static void MulAltivec(t_sample *dst,const t_sample *src,const t_sample *op,int cnt) { - int n = cnt>>4; + int n = cnt>>4; cnt -= n<<4; - - for(; n--; src += 16,op += 16,dst += 16) { - vector float a1 = vec_ld( 0,src),b1 = vec_ld( 0,op); - vector float a2 = vec_ld(16,src),b2 = vec_ld(16,op); - vector float a3 = vec_ld(32,src),b3 = vec_ld(32,op); - vector float a4 = vec_ld(48,src),b4 = vec_ld(48,op); - - a1 = vec_madd(a1,b1,zero); - a2 = vec_madd(a2,b2,zero); - a3 = vec_madd(a3,b3,zero); - a4 = vec_madd(a4,b4,zero); - - vec_st(a1, 0,dst); - vec_st(a2,16,dst); - vec_st(a3,32,dst); - vec_st(a4,48,dst); - } - while(cnt--) *(dst++) = *(src++) * *(op++); + + for(; n--; src += 16,op += 16,dst += 16) { + vector float a1 = vec_ld( 0,src),b1 = vec_ld( 0,op); + vector float a2 = vec_ld(16,src),b2 = vec_ld(16,op); + vector float a3 = vec_ld(32,src),b3 = vec_ld(32,op); + vector float a4 = vec_ld(48,src),b4 = vec_ld(48,op); + + a1 = vec_madd(a1,b1,zero); + a2 = vec_madd(a2,b2,zero); + a3 = vec_madd(a3,b3,zero); + a4 = vec_madd(a4,b4,zero); + + vec_st(a1, 0,dst); + vec_st(a2,16,dst); + vec_st(a3,32,dst); + vec_st(a4,48,dst); + } + while(cnt--) *(dst++) = *(src++) * *(op++); } static void AddAltivec(t_sample *dst,const t_sample *src,t_sample op,int cnt) { - const vector float arg = LoadValue(op); - int n = cnt>>4; + const vector float arg = LoadValue(op); + int n = cnt>>4; cnt -= n<<4; - for(; n--; src += 16,dst += 16) { - vector float a1 = vec_ld( 0,src); - vector float a2 = vec_ld(16,src); - vector float a3 = vec_ld(32,src); - vector float a4 = vec_ld(48,src); - - a1 = vec_add(a1,arg); - a2 = vec_add(a2,arg); - a3 = vec_add(a3,arg); - a4 = vec_add(a4,arg); - - vec_st(a1, 0,dst); - vec_st(a2,16,dst); - vec_st(a3,32,dst); - vec_st(a4,48,dst); - } + for(; n--; src += 16,dst += 16) { + vector float a1 = vec_ld( 0,src); + vector float a2 = vec_ld(16,src); + vector float a3 = vec_ld(32,src); + vector float a4 = vec_ld(48,src); + + a1 = vec_add(a1,arg); + a2 = vec_add(a2,arg); + a3 = vec_add(a3,arg); + a4 = vec_add(a4,arg); + + vec_st(a1, 0,dst); + vec_st(a2,16,dst); + vec_st(a3,32,dst); + vec_st(a4,48,dst); + } while(cnt--) *(dst++) = *(src++)+op; } static void AddAltivec(t_sample *dst,const t_sample *src,const t_sample *op,int cnt) { - int n = cnt>>4; + int n = cnt>>4; cnt -= n<<4; - - for(; n--; src += 16,op += 16,dst += 16) { - vector float a1 = vec_ld( 0,src),b1 = vec_ld( 0,op); - vector float a2 = vec_ld(16,src),b2 = vec_ld(16,op); - vector float a3 = vec_ld(32,src),b3 = vec_ld(32,op); - vector float a4 = vec_ld(48,src),b4 = vec_ld(48,op); - - a1 = vec_add(a1,b1); - a2 = vec_add(a2,b2); - a3 = vec_add(a3,b3); - a4 = vec_add(a4,b4); - - vec_st(a1, 0,dst); - vec_st(a2,16,dst); - vec_st(a3,32,dst); - vec_st(a4,48,dst); - } - while(cnt--) *(dst++) = *(src++) + *(op++); + + for(; n--; src += 16,op += 16,dst += 16) { + vector float a1 = vec_ld( 0,src),b1 = vec_ld( 0,op); + vector float a2 = vec_ld(16,src),b2 = vec_ld(16,op); + vector float a3 = vec_ld(32,src),b3 = vec_ld(32,op); + vector float a4 = vec_ld(48,src),b4 = vec_ld(48,op); + + a1 = vec_add(a1,b1); + a2 = vec_add(a2,b2); + a3 = vec_add(a3,b3); + a4 = vec_add(a4,b4); + + vec_st(a1, 0,dst); + vec_st(a2,16,dst); + vec_st(a3,32,dst); + vec_st(a4,48,dst); + } + while(cnt--) *(dst++) = *(src++) + *(op++); } static void ScaleAltivec(t_sample *dst,const t_sample *src,t_sample opmul,t_sample opadd,int cnt) { - const vector float argmul = LoadValue(opmul); - const vector float argadd = LoadValue(opadd); - int n = cnt>>4; + const vector float argmul = LoadValue(opmul); + const vector float argadd = LoadValue(opadd); + int n = cnt>>4; cnt -= n<<4; - for(; n--; src += 16,dst += 16) { - vector float a1 = vec_ld( 0,src); - vector float a2 = vec_ld(16,src); - vector float a3 = vec_ld(32,src); - vector float a4 = vec_ld(48,src); - - a1 = vec_madd(a1,argmul,argadd); - a2 = vec_madd(a2,argmul,argadd); - a3 = vec_madd(a3,argmul,argadd); - a4 = vec_madd(a4,argmul,argadd); - - vec_st(a1, 0,dst); - vec_st(a2,16,dst); - vec_st(a3,32,dst); - vec_st(a4,48,dst); - } - - while(cnt--) *(dst++) = *(src++)*opmul+opadd; + for(; n--; src += 16,dst += 16) { + vector float a1 = vec_ld( 0,src); + vector float a2 = vec_ld(16,src); + vector float a3 = vec_ld(32,src); + vector float a4 = vec_ld(48,src); + + a1 = vec_madd(a1,argmul,argadd); + a2 = vec_madd(a2,argmul,argadd); + a3 = vec_madd(a3,argmul,argadd); + a4 = vec_madd(a4,argmul,argadd); + + vec_st(a1, 0,dst); + vec_st(a2,16,dst); + vec_st(a3,32,dst); + vec_st(a4,48,dst); + } + + while(cnt--) *(dst++) = *(src++)*opmul+opadd; } #endif @@ -671,62 +674,64 @@ void flext::SetSamples(t_sample *dst,int cnt,t_sample s) if(GetSIMDCapabilities()&simd_sse) { // single precision - int n = cnt>>4; + int n = cnt>>4; cnt -= n<<4; + if(!n) goto zero; __asm { - movss xmm0,xmmword ptr [s] - shufps xmm0,xmm0,0 - } + movss xmm0,xmmword ptr [s] + shufps xmm0,xmm0,0 + } if((reinterpret_cast(dst)&(__alignof(__m128)-1)) == 0) { // aligned version - __asm { - mov ecx,[n] - mov edx,dword ptr [dst] + __asm { + mov ecx,[n] + mov edx,dword ptr [dst] loopa: - movaps xmmword ptr[edx],xmm0 - movaps xmmword ptr[edx+4*4],xmm0 - movaps xmmword ptr[edx+8*4],xmm0 - movaps xmmword ptr[edx+12*4],xmm0 - - add edx,16*4 - loop loopa - } + movaps xmmword ptr[edx],xmm0 + movaps xmmword ptr[edx+4*4],xmm0 + movaps xmmword ptr[edx+8*4],xmm0 + movaps xmmword ptr[edx+12*4],xmm0 + + add edx,16*4 + loop loopa + } } else { // unaligned version - __asm { - mov ecx,[n] - mov edx,dword ptr [dst] + __asm { + mov ecx,[n] + mov edx,dword ptr [dst] loopu: - movups xmmword ptr[edx],xmm0 - movups xmmword ptr[edx+4*4],xmm0 - movups xmmword ptr[edx+8*4],xmm0 - movups xmmword ptr[edx+12*4],xmm0 - - add edx,16*4 - loop loopu - } + movups xmmword ptr[edx],xmm0 + movups xmmword ptr[edx+4*4],xmm0 + movups xmmword ptr[edx+8*4],xmm0 + movups xmmword ptr[edx+12*4],xmm0 + + add edx,16*4 + loop loopu + } } - while(cnt--) *(dst++) = s; +zero: + while(cnt--) *(dst++) = s; } else #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__ALTIVEC__) if(GetSIMDCapabilities()&simd_altivec && IsVectorAligned(dst)) - SetAltivec(dst,cnt,s); - else + SetAltivec(dst,cnt,s); + else #endif #endif // FLEXT_USE_SIMD { - int n = cnt>>3; - cnt -= n<<3; - while(n--) { - dst[0] = dst[1] = dst[2] = dst[3] = dst[4] = dst[5] = dst[6] = dst[7] = s; - dst += 8; - } - - while(cnt--) *(dst++) = s; + int n = cnt>>3; + cnt -= n<<3; + while(n--) { + dst[0] = dst[1] = dst[2] = dst[3] = dst[4] = dst[5] = dst[6] = dst[7] = s; + dst += 8; + } + + while(cnt--) *(dst++) = s; } #endif } @@ -750,118 +755,121 @@ void flext::MulSamples(t_sample *dst,const t_sample *src,t_sample op,int cnt) // single precision __m128 a = _mm_load1_ps(&op); - int n = cnt>>4; + int n = cnt>>4; cnt -= n<<4; + if(!n) goto zero; + __asm { - mov eax,dword ptr [src] - prefetcht0 [eax+0] - prefetcht0 [eax+32] + mov eax,dword ptr [src] + prefetcht0 [eax+0] + prefetcht0 [eax+32] - movss xmm0,xmmword ptr [op] - shufps xmm0,xmm0,0 - } + movss xmm0,xmmword ptr [op] + shufps xmm0,xmm0,0 + } if((reinterpret_cast(src)&(__alignof(__m128)-1)) == 0 && (reinterpret_cast(dst)&(__alignof(__m128)-1)) == 0 ) { // aligned version __asm { - mov ecx,[n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] + mov ecx,[n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] loopa: - prefetcht0 [eax+64] - prefetcht0 [eax+96] + prefetcht0 [eax+64] + prefetcht0 [eax+96] - movaps xmm1,xmmword ptr[eax] - mulps xmm1,xmm0 - movaps xmmword ptr[edx],xmm1 + movaps xmm1,xmmword ptr[eax] + mulps xmm1,xmm0 + movaps xmmword ptr[edx],xmm1 - movaps xmm2,xmmword ptr[eax+4*4] - mulps xmm2,xmm0 - movaps xmmword ptr[edx+4*4],xmm2 + movaps xmm2,xmmword ptr[eax+4*4] + mulps xmm2,xmm0 + movaps xmmword ptr[edx+4*4],xmm2 - movaps xmm3,xmmword ptr[eax+8*4] - mulps xmm3,xmm0 - movaps xmmword ptr[edx+8*4],xmm3 + movaps xmm3,xmmword ptr[eax+8*4] + mulps xmm3,xmm0 + movaps xmmword ptr[edx+8*4],xmm3 - movaps xmm4,xmmword ptr[eax+12*4] - mulps xmm4,xmm0 - movaps xmmword ptr[edx+12*4],xmm4 + movaps xmm4,xmmword ptr[eax+12*4] + mulps xmm4,xmm0 + movaps xmmword ptr[edx+12*4],xmm4 - add eax,16*4 - add edx,16*4 - loop loopa + add eax,16*4 + add edx,16*4 + loop loopa } } else { // unaligned version __asm { - mov ecx,[n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] + mov ecx,[n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] loopu: - prefetcht0 [eax+64] - prefetcht0 [eax+96] + prefetcht0 [eax+64] + prefetcht0 [eax+96] - movups xmm1,xmmword ptr[eax] - mulps xmm1,xmm0 - movups xmmword ptr[edx],xmm1 + movups xmm1,xmmword ptr[eax] + mulps xmm1,xmm0 + movups xmmword ptr[edx],xmm1 - movups xmm2,xmmword ptr[eax+4*4] - mulps xmm2,xmm0 - movups xmmword ptr[edx+4*4],xmm2 + movups xmm2,xmmword ptr[eax+4*4] + mulps xmm2,xmm0 + movups xmmword ptr[edx+4*4],xmm2 - movups xmm3,xmmword ptr[eax+8*4] - mulps xmm3,xmm0 - movups xmmword ptr[edx+8*4],xmm3 + movups xmm3,xmmword ptr[eax+8*4] + mulps xmm3,xmm0 + movups xmmword ptr[edx+8*4],xmm3 - movups xmm4,xmmword ptr[eax+12*4] - mulps xmm4,xmm0 - movups xmmword ptr[edx+12*4],xmm4 + movups xmm4,xmmword ptr[eax+12*4] + mulps xmm4,xmm0 + movups xmmword ptr[edx+12*4],xmm4 - add eax,16*4 - add edx,16*4 - loop loopu - } + add eax,16*4 + add edx,16*4 + loop loopu + } } - while(cnt--) *(dst++) = *(src++)*op; +zero: + while(cnt--) *(dst++) = *(src++)*op; } else #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__VDSP__) if(true) { - vsmul(src,1,&op,dst,1,cnt); - } - else + vsmul(src,1,&op,dst,1,cnt); + } + else #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__ALTIVEC__) if(GetSIMDCapabilities()&simd_altivec && IsVectorAligned(src) && IsVectorAligned(dst)) - MulAltivec(dst,src,op,cnt); - else + MulAltivec(dst,src,op,cnt); + else #endif // _MSC_VER #endif // FLEXT_USE_SIMD { - int n = cnt>>3; - cnt -= n<<3; - - if(src == dst) { - while(n--) { - dst[0] *= op; dst[1] *= op; dst[2] *= op; dst[3] *= op; - dst[4] *= op; dst[5] *= op; dst[6] *= op; dst[7] *= op; - dst += 8; - } - while(cnt--) *(dst++) *= op; - } - else { - while(n--) { - dst[0] = src[0]*op; dst[1] = src[1]*op; - dst[2] = src[2]*op; dst[3] = src[3]*op; - dst[4] = src[4]*op; dst[5] = src[5]*op; - dst[6] = src[6]*op; dst[7] = src[7]*op; - src += 8,dst += 8; - } - while(cnt--) *(dst++) = *(src++)*op; - } + int n = cnt>>3; + cnt -= n<<3; + + if(src == dst) { + while(n--) { + dst[0] *= op; dst[1] *= op; dst[2] *= op; dst[3] *= op; + dst[4] *= op; dst[5] *= op; dst[6] *= op; dst[7] *= op; + dst += 8; + } + while(cnt--) *(dst++) *= op; + } + else { + while(n--) { + dst[0] = src[0]*op; dst[1] = src[1]*op; + dst[2] = src[2]*op; dst[3] = src[3]*op; + dst[4] = src[4]*op; dst[5] = src[5]*op; + dst[6] = src[6]*op; dst[7] = src[7]*op; + src += 8,dst += 8; + } + while(cnt--) *(dst++) = *(src++)*op; + } } #endif } @@ -883,214 +891,217 @@ void flext::MulSamples(t_sample *dst,const t_sample *src,const t_sample *op,int #ifdef _MSC_VER if(GetSIMDCapabilities()&simd_sse) { // single precision - int n = cnt>>4; + int n = cnt>>4; cnt -= n<<4; - __asm { - mov eax,[src] - mov ebx,[op] - prefetcht0 [eax+0] - prefetcht0 [ebx+0] - prefetcht0 [eax+32] - prefetcht0 [ebx+32] - } + if(!n) goto zero; + + __asm { + mov eax,[src] + mov ebx,[op] + prefetcht0 [eax+0] + prefetcht0 [ebx+0] + prefetcht0 [eax+32] + prefetcht0 [ebx+32] + } if((reinterpret_cast(src)&(__alignof(__m128)-1)) == 0 && (reinterpret_cast(dst)&(__alignof(__m128)-1)) == 0 - ) { - if((reinterpret_cast(op)&(__alignof(__m128)-1)) == 0) { - __asm { - mov ecx,[n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ebx,dword ptr [op] - loopaa: - prefetcht0 [eax+64] - prefetcht0 [ebx+64] - prefetcht0 [eax+96] - prefetcht0 [ebx+96] - - movaps xmm0,xmmword ptr[eax] - movaps xmm1,xmmword ptr[ebx] - mulps xmm0,xmm1 - movaps xmmword ptr[edx],xmm0 - - movaps xmm2,xmmword ptr[eax+4*4] - movaps xmm3,xmmword ptr[ebx+4*4] - mulps xmm2,xmm3 - movaps xmmword ptr[edx+4*4],xmm2 - - movaps xmm4,xmmword ptr[eax+8*4] - movaps xmm5,xmmword ptr[ebx+8*4] - mulps xmm4,xmm5 - movaps xmmword ptr[edx+8*4],xmm4 - - movaps xmm6,xmmword ptr[eax+12*4] - movaps xmm7,xmmword ptr[ebx+12*4] - mulps xmm6,xmm7 - movaps xmmword ptr[edx+12*4],xmm6 - - add eax,16*4 - add ebx,16*4 - add edx,16*4 - loop loopaa - } - } - else { - __asm { - mov ecx,[n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ebx,dword ptr [op] - loopau: - prefetcht0 [eax+64] - prefetcht0 [ebx+64] - prefetcht0 [eax+96] - prefetcht0 [ebx+96] - - movaps xmm0,xmmword ptr[eax] - movups xmm1,xmmword ptr[ebx] - mulps xmm0,xmm1 - movaps xmmword ptr[edx],xmm0 - - movaps xmm2,xmmword ptr[eax+4*4] - movups xmm3,xmmword ptr[ebx+4*4] - mulps xmm2,xmm3 - movaps xmmword ptr[edx+4*4],xmm2 - - movaps xmm4,xmmword ptr[eax+8*4] - movups xmm5,xmmword ptr[ebx+8*4] - mulps xmm4,xmm5 - movaps xmmword ptr[edx+8*4],xmm4 - - movaps xmm6,xmmword ptr[eax+12*4] - movups xmm7,xmmword ptr[ebx+12*4] - mulps xmm6,xmm7 - movaps xmmword ptr[edx+12*4],xmm6 - - add eax,16*4 - add ebx,16*4 - add edx,16*4 - loop loopau - } - } - } + ) { + if((reinterpret_cast(op)&(__alignof(__m128)-1)) == 0) { + __asm { + mov ecx,[n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ebx,dword ptr [op] + loopaa: + prefetcht0 [eax+64] + prefetcht0 [ebx+64] + prefetcht0 [eax+96] + prefetcht0 [ebx+96] + + movaps xmm0,xmmword ptr[eax] + movaps xmm1,xmmword ptr[ebx] + mulps xmm0,xmm1 + movaps xmmword ptr[edx],xmm0 + + movaps xmm2,xmmword ptr[eax+4*4] + movaps xmm3,xmmword ptr[ebx+4*4] + mulps xmm2,xmm3 + movaps xmmword ptr[edx+4*4],xmm2 + + movaps xmm4,xmmword ptr[eax+8*4] + movaps xmm5,xmmword ptr[ebx+8*4] + mulps xmm4,xmm5 + movaps xmmword ptr[edx+8*4],xmm4 + + movaps xmm6,xmmword ptr[eax+12*4] + movaps xmm7,xmmword ptr[ebx+12*4] + mulps xmm6,xmm7 + movaps xmmword ptr[edx+12*4],xmm6 + + add eax,16*4 + add ebx,16*4 + add edx,16*4 + loop loopaa + } + } + else { + __asm { + mov ecx,[n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ebx,dword ptr [op] + loopau: + prefetcht0 [eax+64] + prefetcht0 [ebx+64] + prefetcht0 [eax+96] + prefetcht0 [ebx+96] + + movaps xmm0,xmmword ptr[eax] + movups xmm1,xmmword ptr[ebx] + mulps xmm0,xmm1 + movaps xmmword ptr[edx],xmm0 + + movaps xmm2,xmmword ptr[eax+4*4] + movups xmm3,xmmword ptr[ebx+4*4] + mulps xmm2,xmm3 + movaps xmmword ptr[edx+4*4],xmm2 + + movaps xmm4,xmmword ptr[eax+8*4] + movups xmm5,xmmword ptr[ebx+8*4] + mulps xmm4,xmm5 + movaps xmmword ptr[edx+8*4],xmm4 + + movaps xmm6,xmmword ptr[eax+12*4] + movups xmm7,xmmword ptr[ebx+12*4] + mulps xmm6,xmm7 + movaps xmmword ptr[edx+12*4],xmm6 + + add eax,16*4 + add ebx,16*4 + add edx,16*4 + loop loopau + } + } + } else { - if((reinterpret_cast(op)&(__alignof(__m128)-1)) == 0) { - __asm { - mov ecx,[n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ebx,dword ptr [op] - loopua: - prefetcht0 [eax+64] - prefetcht0 [ebx+64] - prefetcht0 [eax+96] - prefetcht0 [ebx+96] - - movups xmm0,xmmword ptr[eax] - movaps xmm1,xmmword ptr[ebx] - mulps xmm0,xmm1 - movups xmmword ptr[edx],xmm0 - - movups xmm2,xmmword ptr[eax+4*4] - movaps xmm3,xmmword ptr[ebx+4*4] - mulps xmm2,xmm3 - movups xmmword ptr[edx+4*4],xmm2 - - movups xmm4,xmmword ptr[eax+8*4] - movaps xmm5,xmmword ptr[ebx+8*4] - mulps xmm4,xmm5 - movups xmmword ptr[edx+8*4],xmm4 - - movups xmm6,xmmword ptr[eax+12*4] - movaps xmm7,xmmword ptr[ebx+12*4] - mulps xmm6,xmm7 - movups xmmword ptr[edx+12*4],xmm6 - - add eax,16*4 - add ebx,16*4 - add edx,16*4 - loop loopua - } - } - else { - __asm { - mov ecx,[n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ebx,dword ptr [op] + if((reinterpret_cast(op)&(__alignof(__m128)-1)) == 0) { + __asm { + mov ecx,[n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ebx,dword ptr [op] + loopua: + prefetcht0 [eax+64] + prefetcht0 [ebx+64] + prefetcht0 [eax+96] + prefetcht0 [ebx+96] + + movups xmm0,xmmword ptr[eax] + movaps xmm1,xmmword ptr[ebx] + mulps xmm0,xmm1 + movups xmmword ptr[edx],xmm0 + + movups xmm2,xmmword ptr[eax+4*4] + movaps xmm3,xmmword ptr[ebx+4*4] + mulps xmm2,xmm3 + movups xmmword ptr[edx+4*4],xmm2 + + movups xmm4,xmmword ptr[eax+8*4] + movaps xmm5,xmmword ptr[ebx+8*4] + mulps xmm4,xmm5 + movups xmmword ptr[edx+8*4],xmm4 + + movups xmm6,xmmword ptr[eax+12*4] + movaps xmm7,xmmword ptr[ebx+12*4] + mulps xmm6,xmm7 + movups xmmword ptr[edx+12*4],xmm6 + + add eax,16*4 + add ebx,16*4 + add edx,16*4 + loop loopua + } + } + else { + __asm { + mov ecx,[n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ebx,dword ptr [op] loopuu: - prefetcht0 [eax+64] - prefetcht0 [ebx+64] - prefetcht0 [eax+96] - prefetcht0 [ebx+96] - - movups xmm0,xmmword ptr[eax] - movups xmm1,xmmword ptr[ebx] - mulps xmm0,xmm1 - movups xmmword ptr[edx],xmm0 - - movups xmm2,xmmword ptr[eax+4*4] - movups xmm3,xmmword ptr[ebx+4*4] - mulps xmm2,xmm3 - movups xmmword ptr[edx+4*4],xmm2 - - movups xmm4,xmmword ptr[eax+8*4] - movups xmm5,xmmword ptr[ebx+8*4] - mulps xmm4,xmm5 - movups xmmword ptr[edx+8*4],xmm4 - - movups xmm6,xmmword ptr[eax+12*4] - movups xmm7,xmmword ptr[ebx+12*4] - mulps xmm6,xmm7 - movups xmmword ptr[edx+12*4],xmm6 - - add eax,16*4 - add ebx,16*4 - add edx,16*4 - loop loopuu - } - } + prefetcht0 [eax+64] + prefetcht0 [ebx+64] + prefetcht0 [eax+96] + prefetcht0 [ebx+96] + + movups xmm0,xmmword ptr[eax] + movups xmm1,xmmword ptr[ebx] + mulps xmm0,xmm1 + movups xmmword ptr[edx],xmm0 + + movups xmm2,xmmword ptr[eax+4*4] + movups xmm3,xmmword ptr[ebx+4*4] + mulps xmm2,xmm3 + movups xmmword ptr[edx+4*4],xmm2 + + movups xmm4,xmmword ptr[eax+8*4] + movups xmm5,xmmword ptr[ebx+8*4] + mulps xmm4,xmm5 + movups xmmword ptr[edx+8*4],xmm4 + + movups xmm6,xmmword ptr[eax+12*4] + movups xmm7,xmmword ptr[ebx+12*4] + mulps xmm6,xmm7 + movups xmmword ptr[edx+12*4],xmm6 + + add eax,16*4 + add ebx,16*4 + add edx,16*4 + loop loopuu + } + } } - while(cnt--) *(dst++) = *(src++) * *(op++); +zero: + while(cnt--) *(dst++) = *(src++) * *(op++); } else #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__VDSP__) if(true) { - vmul(src,1,op,1,dst,1,cnt); - } - else + vmul(src,1,op,1,dst,1,cnt); + } + else #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__ALTIVEC__) if(GetSIMDCapabilities()&simd_altivec && IsVectorAligned(src) && IsVectorAligned(op) && IsVectorAligned(dst)) - MulAltivec(dst,src,op,cnt); - else + MulAltivec(dst,src,op,cnt); + else #endif // _MSC_VER #endif // FLEXT_USE_SIMD { - int n = cnt>>3; - cnt -= n<<3; - - if(src == dst) { - while(n--) { - dst[0] *= op[0]; dst[1] *= op[1]; - dst[2] *= op[2]; dst[3] *= op[3]; - dst[4] *= op[4]; dst[5] *= op[5]; - dst[6] *= op[6]; dst[7] *= op[7]; - dst += 8,op += 8; - } - while(cnt--) *(dst++) *= *(op++); - } - else { - while(n--) { - dst[0] = src[0]*op[0]; dst[1] = src[1]*op[1]; - dst[2] = src[2]*op[2]; dst[3] = src[3]*op[3]; - dst[4] = src[4]*op[4]; dst[5] = src[5]*op[5]; - dst[6] = src[6]*op[6]; dst[7] = src[7]*op[7]; - src += 8,dst += 8,op += 8; - } - while(cnt--) *(dst++) = *(src++) * *(op++); - } + int n = cnt>>3; + cnt -= n<<3; + + if(src == dst) { + while(n--) { + dst[0] *= op[0]; dst[1] *= op[1]; + dst[2] *= op[2]; dst[3] *= op[3]; + dst[4] *= op[4]; dst[5] *= op[5]; + dst[6] *= op[6]; dst[7] *= op[7]; + dst += 8,op += 8; + } + while(cnt--) *(dst++) *= *(op++); + } + else { + while(n--) { + dst[0] = src[0]*op[0]; dst[1] = src[1]*op[1]; + dst[2] = src[2]*op[2]; dst[3] = src[3]*op[3]; + dst[4] = src[4]*op[4]; dst[5] = src[5]*op[5]; + dst[6] = src[6]*op[6]; dst[7] = src[7]*op[7]; + src += 8,dst += 8,op += 8; + } + while(cnt--) *(dst++) = *(src++) * *(op++); + } } #endif } @@ -1112,113 +1123,113 @@ void flext::AddSamples(t_sample *dst,const t_sample *src,t_sample op,int cnt) #ifdef _MSC_VER if(GetSIMDCapabilities()&simd_sse) { // single precision - int n = cnt>>4; + int n = cnt>>4; cnt -= n<<4; __asm { - mov eax,[src] - prefetcht0 [eax+0] - prefetcht0 [eax+32] + mov eax,[src] + prefetcht0 [eax+0] + prefetcht0 [eax+32] - movss xmm0,xmmword ptr [op] - shufps xmm0,xmm0,0 - } + movss xmm0,xmmword ptr [op] + shufps xmm0,xmm0,0 + } if((reinterpret_cast(src)&(__alignof(__m128)-1)) == 0 && (reinterpret_cast(dst)&(__alignof(__m128)-1)) == 0 ) { // aligned version - __asm { - mov ecx,[n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] + __asm { + mov ecx,[n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] loopa: - prefetcht0 [eax+64] - prefetcht0 [eax+96] + prefetcht0 [eax+64] + prefetcht0 [eax+96] - movaps xmm1,xmmword ptr[eax] - addps xmm1,xmm0 - movaps xmmword ptr[edx],xmm1 + movaps xmm1,xmmword ptr[eax] + addps xmm1,xmm0 + movaps xmmword ptr[edx],xmm1 - movaps xmm2,xmmword ptr[eax+4*4] - addps xmm2,xmm0 - movaps xmmword ptr[edx+4*4],xmm2 + movaps xmm2,xmmword ptr[eax+4*4] + addps xmm2,xmm0 + movaps xmmword ptr[edx+4*4],xmm2 - movaps xmm3,xmmword ptr[eax+8*4] - addps xmm3,xmm0 - movaps xmmword ptr[edx+8*4],xmm3 + movaps xmm3,xmmword ptr[eax+8*4] + addps xmm3,xmm0 + movaps xmmword ptr[edx+8*4],xmm3 - movaps xmm4,xmmword ptr[eax+12*4] - addps xmm4,xmm0 - movaps xmmword ptr[edx+12*4],xmm4 + movaps xmm4,xmmword ptr[eax+12*4] + addps xmm4,xmm0 + movaps xmmword ptr[edx+12*4],xmm4 - add eax,16*4 - add edx,16*4 - loop loopa + add eax,16*4 + add edx,16*4 + loop loopa } } else { // unaligned version - __asm { - mov ecx,[n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] + __asm { + mov ecx,[n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] loopu: - prefetcht0 [eax+64] - prefetcht0 [eax+96] + prefetcht0 [eax+64] + prefetcht0 [eax+96] - movups xmm1,xmmword ptr[eax] - addps xmm1,xmm0 - movups xmmword ptr[edx],xmm1 + movups xmm1,xmmword ptr[eax] + addps xmm1,xmm0 + movups xmmword ptr[edx],xmm1 - movups xmm2,xmmword ptr[eax+4*4] - addps xmm2,xmm0 - movups xmmword ptr[edx+4*4],xmm2 + movups xmm2,xmmword ptr[eax+4*4] + addps xmm2,xmm0 + movups xmmword ptr[edx+4*4],xmm2 - movups xmm3,xmmword ptr[eax+8*4] - addps xmm3,xmm0 - movups xmmword ptr[edx+8*4],xmm3 + movups xmm3,xmmword ptr[eax+8*4] + addps xmm3,xmm0 + movups xmmword ptr[edx+8*4],xmm3 - movups xmm4,xmmword ptr[eax+12*4] - addps xmm4,xmm0 - movups xmmword ptr[edx+12*4],xmm4 + movups xmm4,xmmword ptr[eax+12*4] + addps xmm4,xmm0 + movups xmmword ptr[edx+12*4],xmm4 - add eax,16*4 - add edx,16*4 - loop loopu - } + add eax,16*4 + add edx,16*4 + loop loopu + } } - while(cnt--) *(dst++) = *(src++)+op; + while(cnt--) *(dst++) = *(src++)+op; } else #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__ALTIVEC__) if(GetSIMDCapabilities()&simd_altivec && IsVectorAligned(src) && IsVectorAligned(dst)) - AddAltivec(dst,src,op,cnt); - else + AddAltivec(dst,src,op,cnt); + else #endif // _MSC_VER #endif // FLEXT_USE_SIMD { - int n = cnt>>3; - cnt -= n<<3; - - if(src == dst) { - while(n--) { - dst[0] += op; dst[1] += op; dst[2] += op; dst[3] += op; - dst[4] += op; dst[5] += op; dst[6] += op; dst[7] += op; - dst += 8; - } - while(cnt--) *(dst++) += op; - } - else { - while(n--) { - dst[0] = src[0]+op; dst[1] = src[1]+op; - dst[2] = src[2]+op; dst[3] = src[3]+op; - dst[4] = src[4]+op; dst[5] = src[5]+op; - dst[6] = src[6]+op; dst[7] = src[7]+op; - src += 8,dst += 8; - } - while(cnt--) *(dst++) = *(src++)+op; - } + int n = cnt>>3; + cnt -= n<<3; + + if(src == dst) { + while(n--) { + dst[0] += op; dst[1] += op; dst[2] += op; dst[3] += op; + dst[4] += op; dst[5] += op; dst[6] += op; dst[7] += op; + dst += 8; + } + while(cnt--) *(dst++) += op; + } + else { + while(n--) { + dst[0] = src[0]+op; dst[1] = src[1]+op; + dst[2] = src[2]+op; dst[3] = src[3]+op; + dst[4] = src[4]+op; dst[5] = src[5]+op; + dst[6] = src[6]+op; dst[7] = src[7]+op; + src += 8,dst += 8; + } + while(cnt--) *(dst++) = *(src++)+op; + } } #endif } @@ -1239,216 +1250,216 @@ void flext::AddSamples(t_sample *dst,const t_sample *src,const t_sample *op,int #ifdef FLEXT_USE_SIMD #ifdef _MSC_VER if(GetSIMDCapabilities()&simd_sse) { - // Prefetch cache - __asm { - mov eax,dword ptr [src] - mov ebx,dword ptr [op] - prefetcht0 [eax] - prefetcht0 [ebx] - prefetcht0 [eax+32] - prefetcht0 [ebx+32] - } + // Prefetch cache + __asm { + mov eax,dword ptr [src] + mov ebx,dword ptr [op] + prefetcht0 [eax] + prefetcht0 [ebx] + prefetcht0 [eax+32] + prefetcht0 [ebx+32] + } // single precision - int n = cnt>>4; + int n = cnt>>4; cnt -= n<<4; if((reinterpret_cast(src)&(__alignof(__m128)-1)) == 0 && (reinterpret_cast(dst)&(__alignof(__m128)-1)) == 0 - ) { - if((reinterpret_cast(op)&(__alignof(__m128)-1)) == 0) { - __asm { - mov ecx,dword ptr [n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ebx,dword ptr [op] - loopaa: - prefetcht0 [eax+64] - prefetcht0 [ebx+64] - prefetcht0 [eax+96] - prefetcht0 [ebx+96] - - movaps xmm0,xmmword ptr[eax] - movaps xmm1,xmmword ptr[ebx] - addps xmm0,xmm1 - movaps xmmword ptr[edx],xmm0 - - movaps xmm2,xmmword ptr[eax+4*4] - movaps xmm3,xmmword ptr[ebx+4*4] - addps xmm2,xmm3 - movaps xmmword ptr[edx+4*4],xmm2 - - movaps xmm4,xmmword ptr[eax+8*4] - movaps xmm5,xmmword ptr[ebx+8*4] - addps xmm4,xmm5 - movaps xmmword ptr[edx+8*4],xmm4 - - movaps xmm6,xmmword ptr[eax+12*4] - movaps xmm7,xmmword ptr[ebx+12*4] - addps xmm6,xmm7 - movaps xmmword ptr[edx+12*4],xmm6 - - add eax,16*4 - add ebx,16*4 - add edx,16*4 - loop loopaa - } - } - else { - __asm { - mov ecx,dword ptr [n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ebx,dword ptr [op] - loopau: - prefetcht0 [eax+64] - prefetcht0 [ebx+64] - prefetcht0 [eax+96] - prefetcht0 [ebx+96] - - movaps xmm0,xmmword ptr[eax] - movups xmm1,xmmword ptr[ebx] - addps xmm0,xmm1 - movaps xmmword ptr[edx],xmm0 - - movaps xmm2,xmmword ptr[eax+4*4] - movups xmm3,xmmword ptr[ebx+4*4] - addps xmm2,xmm3 - movaps xmmword ptr[edx+4*4],xmm2 - - movaps xmm4,xmmword ptr[eax+8*4] - movups xmm5,xmmword ptr[ebx+8*4] - addps xmm4,xmm5 - movaps xmmword ptr[edx+8*4],xmm4 - - movaps xmm6,xmmword ptr[eax+12*4] - movups xmm7,xmmword ptr[ebx+12*4] - addps xmm6,xmm7 - movaps xmmword ptr[edx+12*4],xmm6 - - add eax,16*4 - add ebx,16*4 - add edx,16*4 - loop loopau - } - } + ) { + if((reinterpret_cast(op)&(__alignof(__m128)-1)) == 0) { + __asm { + mov ecx,dword ptr [n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ebx,dword ptr [op] + loopaa: + prefetcht0 [eax+64] + prefetcht0 [ebx+64] + prefetcht0 [eax+96] + prefetcht0 [ebx+96] + + movaps xmm0,xmmword ptr[eax] + movaps xmm1,xmmword ptr[ebx] + addps xmm0,xmm1 + movaps xmmword ptr[edx],xmm0 + + movaps xmm2,xmmword ptr[eax+4*4] + movaps xmm3,xmmword ptr[ebx+4*4] + addps xmm2,xmm3 + movaps xmmword ptr[edx+4*4],xmm2 + + movaps xmm4,xmmword ptr[eax+8*4] + movaps xmm5,xmmword ptr[ebx+8*4] + addps xmm4,xmm5 + movaps xmmword ptr[edx+8*4],xmm4 + + movaps xmm6,xmmword ptr[eax+12*4] + movaps xmm7,xmmword ptr[ebx+12*4] + addps xmm6,xmm7 + movaps xmmword ptr[edx+12*4],xmm6 + + add eax,16*4 + add ebx,16*4 + add edx,16*4 + loop loopaa + } + } + else { + __asm { + mov ecx,dword ptr [n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ebx,dword ptr [op] + loopau: + prefetcht0 [eax+64] + prefetcht0 [ebx+64] + prefetcht0 [eax+96] + prefetcht0 [ebx+96] + + movaps xmm0,xmmword ptr[eax] + movups xmm1,xmmword ptr[ebx] + addps xmm0,xmm1 + movaps xmmword ptr[edx],xmm0 + + movaps xmm2,xmmword ptr[eax+4*4] + movups xmm3,xmmword ptr[ebx+4*4] + addps xmm2,xmm3 + movaps xmmword ptr[edx+4*4],xmm2 + + movaps xmm4,xmmword ptr[eax+8*4] + movups xmm5,xmmword ptr[ebx+8*4] + addps xmm4,xmm5 + movaps xmmword ptr[edx+8*4],xmm4 + + movaps xmm6,xmmword ptr[eax+12*4] + movups xmm7,xmmword ptr[ebx+12*4] + addps xmm6,xmm7 + movaps xmmword ptr[edx+12*4],xmm6 + + add eax,16*4 + add ebx,16*4 + add edx,16*4 + loop loopau + } + } } else { - if((reinterpret_cast(op)&(__alignof(__m128)-1)) == 0) { - __asm { - mov ecx,dword ptr [n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ebx,dword ptr [op] - loopua: - prefetcht0 [eax+64] - prefetcht0 [ebx+64] - prefetcht0 [eax+96] - prefetcht0 [ebx+96] - - movups xmm0,xmmword ptr[eax] - movaps xmm1,xmmword ptr[ebx] - addps xmm0,xmm1 - movups xmmword ptr[edx],xmm0 - - movups xmm2,xmmword ptr[eax+4*4] - movaps xmm3,xmmword ptr[ebx+4*4] - addps xmm2,xmm3 - movups xmmword ptr[edx+4*4],xmm2 - - movups xmm4,xmmword ptr[eax+8*4] - movaps xmm5,xmmword ptr[ebx+8*4] - addps xmm4,xmm5 - movups xmmword ptr[edx+8*4],xmm4 - - movups xmm6,xmmword ptr[eax+12*4] - movaps xmm7,xmmword ptr[ebx+12*4] - addps xmm6,xmm7 - movups xmmword ptr[edx+12*4],xmm6 - - add eax,16*4 - add ebx,16*4 - add edx,16*4 - loop loopua - } - } - else { - __asm { - mov ecx,dword ptr [n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] - mov ebx,dword ptr [op] - loopuu: - prefetcht0 [eax+64] - prefetcht0 [ebx+64] - prefetcht0 [eax+96] - prefetcht0 [ebx+96] - - movups xmm0,xmmword ptr[eax] - movups xmm1,xmmword ptr[ebx] - addps xmm0,xmm1 - movups xmmword ptr[edx],xmm0 - - movups xmm2,xmmword ptr[eax+4*4] - movups xmm3,xmmword ptr[ebx+4*4] - addps xmm2,xmm3 - movups xmmword ptr[edx+4*4],xmm2 - - movups xmm4,xmmword ptr[eax+8*4] - movups xmm5,xmmword ptr[ebx+8*4] - addps xmm4,xmm5 - movups xmmword ptr[edx+8*4],xmm4 - - movups xmm6,xmmword ptr[eax+12*4] - movups xmm7,xmmword ptr[ebx+12*4] - addps xmm6,xmm7 - movups xmmword ptr[edx+12*4],xmm6 - - add eax,16*4 - add ebx,16*4 - add edx,16*4 - loop loopuu - } - } + if((reinterpret_cast(op)&(__alignof(__m128)-1)) == 0) { + __asm { + mov ecx,dword ptr [n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ebx,dword ptr [op] + loopua: + prefetcht0 [eax+64] + prefetcht0 [ebx+64] + prefetcht0 [eax+96] + prefetcht0 [ebx+96] + + movups xmm0,xmmword ptr[eax] + movaps xmm1,xmmword ptr[ebx] + addps xmm0,xmm1 + movups xmmword ptr[edx],xmm0 + + movups xmm2,xmmword ptr[eax+4*4] + movaps xmm3,xmmword ptr[ebx+4*4] + addps xmm2,xmm3 + movups xmmword ptr[edx+4*4],xmm2 + + movups xmm4,xmmword ptr[eax+8*4] + movaps xmm5,xmmword ptr[ebx+8*4] + addps xmm4,xmm5 + movups xmmword ptr[edx+8*4],xmm4 + + movups xmm6,xmmword ptr[eax+12*4] + movaps xmm7,xmmword ptr[ebx+12*4] + addps xmm6,xmm7 + movups xmmword ptr[edx+12*4],xmm6 + + add eax,16*4 + add ebx,16*4 + add edx,16*4 + loop loopua + } + } + else { + __asm { + mov ecx,dword ptr [n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] + mov ebx,dword ptr [op] + loopuu: + prefetcht0 [eax+64] + prefetcht0 [ebx+64] + prefetcht0 [eax+96] + prefetcht0 [ebx+96] + + movups xmm0,xmmword ptr[eax] + movups xmm1,xmmword ptr[ebx] + addps xmm0,xmm1 + movups xmmword ptr[edx],xmm0 + + movups xmm2,xmmword ptr[eax+4*4] + movups xmm3,xmmword ptr[ebx+4*4] + addps xmm2,xmm3 + movups xmmword ptr[edx+4*4],xmm2 + + movups xmm4,xmmword ptr[eax+8*4] + movups xmm5,xmmword ptr[ebx+8*4] + addps xmm4,xmm5 + movups xmmword ptr[edx+8*4],xmm4 + + movups xmm6,xmmword ptr[eax+12*4] + movups xmm7,xmmword ptr[ebx+12*4] + addps xmm6,xmm7 + movups xmmword ptr[edx+12*4],xmm6 + + add eax,16*4 + add ebx,16*4 + add edx,16*4 + loop loopuu + } + } } - while(cnt--) *(dst++) = *(src++) + *(op++); + while(cnt--) *(dst++) = *(src++) + *(op++); } else #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__VDSP__) if(true) { - vadd(src,1,op,1,dst,1,cnt); - } - else + vadd(src,1,op,1,dst,1,cnt); + } + else #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__ALTIVEC__) if(GetSIMDCapabilities()&simd_altivec && IsVectorAligned(src) && IsVectorAligned(op) && IsVectorAligned(dst)) - AddAltivec(dst,src,op,cnt); - else + AddAltivec(dst,src,op,cnt); + else #endif // _MSC_VER #endif // FLEXT_USE_SIMD { - int n = cnt>>3; - cnt -= n<<3; - - if(dst == src) { - while(n--) { - dst[0] += op[0]; dst[1] += op[1]; - dst[2] += op[2]; dst[3] += op[3]; - dst[4] += op[4]; dst[5] += op[5]; - dst[6] += op[6]; dst[7] += op[7]; - dst += 8,op += 8; - } - while(cnt--) *(dst++) += *(op++); - } - else { - while(n--) { - dst[0] = src[0]+op[0]; dst[1] = src[1]+op[1]; - dst[2] = src[2]+op[2]; dst[3] = src[3]+op[3]; - dst[4] = src[4]+op[4]; dst[5] = src[5]+op[5]; - dst[6] = src[6]+op[6]; dst[7] = src[7]+op[7]; - src += 8,dst += 8,op += 8; - } - while(cnt--) *(dst++) = *(src++) + *(op++); - } + int n = cnt>>3; + cnt -= n<<3; + + if(dst == src) { + while(n--) { + dst[0] += op[0]; dst[1] += op[1]; + dst[2] += op[2]; dst[3] += op[3]; + dst[4] += op[4]; dst[5] += op[5]; + dst[6] += op[6]; dst[7] += op[7]; + dst += 8,op += 8; + } + while(cnt--) *(dst++) += *(op++); + } + else { + while(n--) { + dst[0] = src[0]+op[0]; dst[1] = src[1]+op[1]; + dst[2] = src[2]+op[2]; dst[3] = src[3]+op[3]; + dst[4] = src[4]+op[4]; dst[5] = src[5]+op[5]; + dst[6] = src[6]+op[6]; dst[7] = src[7]+op[7]; + src += 8,dst += 8,op += 8; + } + while(cnt--) *(dst++) = *(src++) + *(op++); + } } #endif } @@ -1472,112 +1483,112 @@ void flext::ScaleSamples(t_sample *dst,const t_sample *src,t_sample opmul,t_samp #ifdef _MSC_VER if(GetSIMDCapabilities()&simd_sse) { // single precision - int n = cnt>>4; + int n = cnt>>4; cnt -= n<<4; __asm { - mov eax,dword ptr [src] - prefetcht0 [eax+0] - prefetcht0 [eax+32] - - movss xmm0,xmmword ptr [opadd] - shufps xmm0,xmm0,0 - movss xmm1,xmmword ptr [opmul] - shufps xmm1,xmm1,0 - } + mov eax,dword ptr [src] + prefetcht0 [eax+0] + prefetcht0 [eax+32] + + movss xmm0,xmmword ptr [opadd] + shufps xmm0,xmm0,0 + movss xmm1,xmmword ptr [opmul] + shufps xmm1,xmm1,0 + } if((reinterpret_cast(src)&(__alignof(__m128)-1)) == 0 && (reinterpret_cast(dst)&(__alignof(__m128)-1)) == 0 ) { // aligned version - __asm { - mov ecx,dword ptr [n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] + __asm { + mov ecx,dword ptr [n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] loopa: - prefetcht0 [eax+64] - prefetcht0 [eax+96] - - movaps xmm2,xmmword ptr[eax] - mulps xmm2,xmm1 - addps xmm2,xmm0 - movaps xmmword ptr[edx],xmm2 - - movaps xmm3,xmmword ptr[eax+4*4] - mulps xmm3,xmm1 - addps xmm3,xmm0 - movaps xmmword ptr[edx+4*4],xmm3 - - movaps xmm4,xmmword ptr[eax+8*4] - mulps xmm4,xmm1 - addps xmm4,xmm0 - movaps xmmword ptr[edx+8*4],xmm4 - - movaps xmm5,xmmword ptr[eax+12*4] - mulps xmm5,xmm1 - addps xmm5,xmm0 - movaps xmmword ptr[edx+12*4],xmm5 - - add eax,16*4 - add edx,16*4 - loop loopa - } + prefetcht0 [eax+64] + prefetcht0 [eax+96] + + movaps xmm2,xmmword ptr[eax] + mulps xmm2,xmm1 + addps xmm2,xmm0 + movaps xmmword ptr[edx],xmm2 + + movaps xmm3,xmmword ptr[eax+4*4] + mulps xmm3,xmm1 + addps xmm3,xmm0 + movaps xmmword ptr[edx+4*4],xmm3 + + movaps xmm4,xmmword ptr[eax+8*4] + mulps xmm4,xmm1 + addps xmm4,xmm0 + movaps xmmword ptr[edx+8*4],xmm4 + + movaps xmm5,xmmword ptr[eax+12*4] + mulps xmm5,xmm1 + addps xmm5,xmm0 + movaps xmmword ptr[edx+12*4],xmm5 + + add eax,16*4 + add edx,16*4 + loop loopa + } } else { // unaligned version - __asm { - mov ecx,dword ptr [n] - mov eax,dword ptr [src] - mov edx,dword ptr [dst] + __asm { + mov ecx,dword ptr [n] + mov eax,dword ptr [src] + mov edx,dword ptr [dst] loopu: - prefetcht0 [eax+64] - prefetcht0 [eax+96] - - movups xmm2,xmmword ptr[eax] - mulps xmm2,xmm1 - addps xmm2,xmm0 - movups xmmword ptr[edx],xmm2 - - movups xmm3,xmmword ptr[eax+4*4] - mulps xmm3,xmm1 - addps xmm3,xmm0 - movups xmmword ptr[edx+4*4],xmm3 - - movups xmm4,xmmword ptr[eax+8*4] - mulps xmm4,xmm1 - addps xmm4,xmm0 - movups xmmword ptr[edx+8*4],xmm4 - - movups xmm5,xmmword ptr[eax+12*4] - mulps xmm5,xmm1 - addps xmm5,xmm0 - movups xmmword ptr[edx+12*4],xmm5 - - add eax,16*4 - add edx,16*4 - loop loopu - } + prefetcht0 [eax+64] + prefetcht0 [eax+96] + + movups xmm2,xmmword ptr[eax] + mulps xmm2,xmm1 + addps xmm2,xmm0 + movups xmmword ptr[edx],xmm2 + + movups xmm3,xmmword ptr[eax+4*4] + mulps xmm3,xmm1 + addps xmm3,xmm0 + movups xmmword ptr[edx+4*4],xmm3 + + movups xmm4,xmmword ptr[eax+8*4] + mulps xmm4,xmm1 + addps xmm4,xmm0 + movups xmmword ptr[edx+8*4],xmm4 + + movups xmm5,xmmword ptr[eax+12*4] + mulps xmm5,xmm1 + addps xmm5,xmm0 + movups xmmword ptr[edx+12*4],xmm5 + + add eax,16*4 + add edx,16*4 + loop loopu + } } - while(cnt--) *(dst++) = *(src++)*opmul+opadd; + while(cnt--) *(dst++) = *(src++)*opmul+opadd; } else #elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__ALTIVEC__) if(GetSIMDCapabilities()&simd_altivec && IsVectorAligned(src) && IsVectorAligned(dst)) - ScaleAltivec(dst,src,opmul,opadd,cnt); - else + ScaleAltivec(dst,src,opmul,opadd,cnt); + else #endif // _MSC_VER #endif // FLEXT_USE_SIMD { - int n = cnt>>3; - cnt -= n<<3; - while(n--) { - dst[0] = src[0]*opmul+opadd; dst[1] = src[1]*opmul+opadd; - dst[2] = src[2]*opmul+opadd; dst[3] = src[3]*opmul+opadd; - dst[4] = src[4]*opmul+opadd; dst[5] = src[5]*opmul+opadd; - dst[6] = src[6]*opmul+opadd; dst[7] = src[7]*opmul+opadd; - src += 8,dst += 8; - } - while(cnt--) *(dst++) = *(src++)*opmul+opadd; + int n = cnt>>3; + cnt -= n<<3; + while(n--) { + dst[0] = src[0]*opmul+opadd; dst[1] = src[1]*opmul+opadd; + dst[2] = src[2]*opmul+opadd; dst[3] = src[3]*opmul+opadd; + dst[4] = src[4]*opmul+opadd; dst[5] = src[5]*opmul+opadd; + dst[6] = src[6]*opmul+opadd; dst[7] = src[7]*opmul+opadd; + src += 8,dst += 8; + } + while(cnt--) *(dst++) = *(src++)*opmul+opadd; } #endif } diff --git a/externals/grill/flext/source/flsndobj.cpp b/externals/grill/flext/source/flsndobj.cpp index e5203556..82e6048b 100644 --- a/externals/grill/flext/source/flsndobj.cpp +++ b/externals/grill/flext/source/flsndobj.cpp @@ -13,84 +13,84 @@ WARRANTIES, see the file, "license.txt," in this distribution. flext_sndobj::flext_sndobj(): - inobjs(0),outobjs(0), - inobj(NULL),tmpobj(NULL),outobj(NULL), - smprt(0),blsz(0) + inobjs(0),outobjs(0), + inobj(NULL),tmpobj(NULL),outobj(NULL), + smprt(0),blsz(0) {} bool flext_sndobj::Init() { - bool ret = flext_dsp::Init(); - inobjs = CntInSig(); - outobjs = CntOutSig(); - return ret; + bool ret = flext_dsp::Init(); + inobjs = CntInSig(); + outobjs = CntOutSig(); + return ret; } void flext_sndobj::Exit() { - ClearObjs(); - flext_dsp::Exit(); + ClearObjs(); + flext_dsp::Exit(); } void flext_sndobj::ClearObjs() { - FreeObjs(); - - if(inobj) { - for(int i = 0; i < inobjs; ++i) delete inobj[i]; - delete[] inobj; inobj = NULL; - } - if(tmpobj) { - for(int i = 0; i < inobjs; ++i) delete tmpobj[i]; - delete[] tmpobj; tmpobj = NULL; - } - if(outobj) { - for(int i = 0; i < outobjs; ++i) delete outobj[i]; - delete[] outobj; outobj = NULL; - } + FreeObjs(); + + if(inobj) { + for(int i = 0; i < inobjs; ++i) delete inobj[i]; + delete[] inobj; inobj = NULL; + } + if(tmpobj) { + for(int i = 0; i < inobjs; ++i) delete tmpobj[i]; + delete[] tmpobj; tmpobj = NULL; + } + if(outobj) { + for(int i = 0; i < outobjs; ++i) delete outobj[i]; + delete[] outobj; outobj = NULL; + } } void flext_sndobj::m_dsp(int n,t_sample *const *in,t_sample *const *out) { - // called on every rebuild of the dsp chain - - int i; - if(Blocksize() != blsz || Samplerate() != smprt) { - // block size or sample rate has changed... rebuild all objects - - ClearObjs(); - - blsz = Blocksize(); - smprt = Samplerate(); - - // set up sndobjs for inlets and outlets - if(inobjs) { - inobj = new Inlet *[inobjs]; - tmpobj = new SndObj *[inobjs]; - for(i = 0; i < inobjs; ++i) { - inobj[i] = new Inlet(in[i],blsz,smprt); - tmpobj[i] = new SndObj(NULL,blsz,smprt); - } - } - if(outobjs) { - outobj = new Outlet *[outobjs]; - for(i = 0; i < outobjs; ++i) outobj[i] = new Outlet(out[i],blsz,smprt); - } - - if(!NewObjs()) ClearObjs(); - } - else { - // assign changed input/output vectors - - for(i = 0; i < inobjs; ++i) inobj[i]->SetBuf(in[i]); - for(i = 0; i < outobjs; ++i) outobj[i]->SetBuf(out[i]); - } + // called on every rebuild of the dsp chain + + int i; + if(Blocksize() != blsz || Samplerate() != smprt) { + // block size or sample rate has changed... rebuild all objects + + ClearObjs(); + + blsz = Blocksize(); + smprt = Samplerate(); + + // set up sndobjs for inlets and outlets + if(inobjs) { + inobj = new Inlet *[inobjs]; + tmpobj = new SndObj *[inobjs]; + for(i = 0; i < inobjs; ++i) { + inobj[i] = new Inlet(in[i],blsz,smprt); + tmpobj[i] = new SndObj(NULL,blsz,smprt); + } + } + if(outobjs) { + outobj = new Outlet *[outobjs]; + for(i = 0; i < outobjs; ++i) outobj[i] = new Outlet(out[i],blsz,smprt); + } + + if(!NewObjs()) ClearObjs(); + } + else { + // assign changed input/output vectors + + for(i = 0; i < inobjs; ++i) inobj[i]->SetBuf(in[i]); + for(i = 0; i < outobjs; ++i) outobj[i]->SetBuf(out[i]); + } } void flext_sndobj::m_signal(int n,t_sample *const *in,t_sample *const *out) { - for(int i = 0; i < inobjs; ++i) *tmpobj[i] << *inobj[i]; - ProcessObjs(); + for(int i = 0; i < inobjs; ++i) *tmpobj[i] << *inobj[i]; + ProcessObjs(); } @@ -100,12 +100,12 @@ flext_sndobj::Inlet::Inlet(const t_sample *b,int vecsz,float sr): short flext_sndobj::Inlet::Read() { - if(!m_error) { - for(m_vecpos = 0; m_vecpos < m_samples; m_vecpos++) - m_output[m_vecpos] = buf[m_vecpos]; - return 1; - } - else return 0; + if(!m_error) { + for(m_vecpos = 0; m_vecpos < m_samples; m_vecpos++) + m_output[m_vecpos] = buf[m_vecpos]; + return 1; + } + else return 0; } short flext_sndobj::Inlet::Write() { return 0; } @@ -119,13 +119,13 @@ short flext_sndobj::Outlet::Read() { return 0; } short flext_sndobj::Outlet::Write() { - if(!m_error) { - if(m_IOobjs[0]) - for(m_vecpos = 0; m_vecpos < m_samples; m_vecpos++) - buf[m_vecpos] = m_IOobjs[0]->Output(m_vecpos); - return 1; - } - else return 0; + if(!m_error) { + if(m_IOobjs[0]) + for(m_vecpos = 0; m_vecpos < m_samples; m_vecpos++) + buf[m_vecpos] = m_IOobjs[0]->Output(m_vecpos); + return 1; + } + else return 0; } diff --git a/externals/grill/flext/source/flsndobj.h b/externals/grill/flext/source/flsndobj.h index 960267be..f45080d5 100644 --- a/externals/grill/flext/source/flsndobj.h +++ b/externals/grill/flext/source/flsndobj.h @@ -21,69 +21,69 @@ WARRANTIES, see the file, "license.txt," in this distribution. class FLEXT_SHARE flext_sndobj: - public flext_dsp + public flext_dsp { - FLEXT_HEADER(flext_sndobj,flext_dsp) + FLEXT_HEADER(flext_sndobj,flext_dsp) public: - flext_sndobj(); + flext_sndobj(); - // these have to be overridden in child classes - virtual bool NewObjs() { return true; } - virtual void FreeObjs() {} - virtual void ProcessObjs() {} + // these have to be overridden in child classes + virtual bool NewObjs() { return true; } + virtual void FreeObjs() {} + virtual void ProcessObjs() {} - // inputs and outputs - SndObj &InObj(int i) { return *tmpobj[i]; } - SndIO &OutObj(int i) { return *outobj[i]; } + // inputs and outputs + SndObj &InObj(int i) { return *tmpobj[i]; } + SndIO &OutObj(int i) { return *outobj[i]; } protected: - virtual bool Init(); - virtual void Exit(); + virtual bool Init(); + virtual void Exit(); - virtual void m_dsp(int n,t_sample *const *in,t_sample *const *out); - virtual void m_signal(int n,t_sample *const *in,t_sample *const *out); + virtual void m_dsp(int n,t_sample *const *in,t_sample *const *out); + virtual void m_signal(int n,t_sample *const *in,t_sample *const *out); private: - //! SndObj for reading from inlet buffer - class Inlet: - public SndIO - { - public: - Inlet(const t_sample *b,int vecsz,float sr); - virtual short Read(); - virtual short Write(); - - void SetBuf(const t_sample *b) { buf = b; } - - private: - const t_sample *buf; - }; - - //! SndObj for writing to outlet buffer - class Outlet: - public SndIO - { - public: - Outlet(t_sample *b,int vecsz,float sr); - virtual short Read(); - virtual short Write(); - - void SetBuf(t_sample *b) { buf = b; } - - private: - t_sample *buf; - }; - - void ClearObjs(); - - int inobjs,outobjs; - SndObj **tmpobj; - Inlet **inobj; - Outlet **outobj; - - float smprt; - int blsz; + //! SndObj for reading from inlet buffer + class Inlet: + public SndIO + { + public: + Inlet(const t_sample *b,int vecsz,float sr); + virtual short Read(); + virtual short Write(); + + void SetBuf(const t_sample *b) { buf = b; } + + private: + const t_sample *buf; + }; + + //! SndObj for writing to outlet buffer + class Outlet: + public SndIO + { + public: + Outlet(t_sample *b,int vecsz,float sr); + virtual short Read(); + virtual short Write(); + + void SetBuf(t_sample *b) { buf = b; } + + private: + t_sample *buf; + }; + + void ClearObjs(); + + int inobjs,outobjs; + SndObj **tmpobj; + Inlet **inobj; + Outlet **outobj; + + float smprt; + int blsz; }; #endif diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h index 13ac68b5..19586a4a 100644 --- a/externals/grill/flext/source/flstdc.h +++ b/externals/grill/flext/source/flstdc.h @@ -99,10 +99,15 @@ typedef t_clock t_qelem; #endif +// necessary for the old OS9 SDK +extern "C" { + #include "ext.h" #include "ext_user.h" #include "z_dsp.h" +} // extern "C" + #undef WIN_VERSION diff --git a/externals/grill/flext/source/flstk.cpp b/externals/grill/flext/source/flstk.cpp index 42f2fa85..24739b28 100644 --- a/externals/grill/flext/source/flstk.cpp +++ b/externals/grill/flext/source/flstk.cpp @@ -12,105 +12,105 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flstk.h" flext_stk::flext_stk(): - inobjs(0),outobjs(0), - inobj(NULL),outobj(NULL), - smprt(0),blsz(0) + inobjs(0),outobjs(0), + inobj(NULL),outobj(NULL), + smprt(0),blsz(0) {} bool flext_stk::Init() { - bool ret = flext_dsp::Init(); - inobjs = CntInSig(); - outobjs = CntOutSig(); - return ret; + bool ret = flext_dsp::Init(); + inobjs = CntInSig(); + outobjs = CntOutSig(); + return ret; } void flext_stk::Exit() { - ClearObjs(); - flext_dsp::Exit(); + ClearObjs(); + flext_dsp::Exit(); } void flext_stk::ClearObjs() { - FreeObjs(); - - if(inobj) { - for(int i = 0; i < inobjs; ++i) delete inobj[i]; - delete[] inobj; inobj = NULL; - } - if(outobj) { - for(int i = 0; i < outobjs; ++i) delete outobj[i]; - delete[] outobj; outobj = NULL; - } + FreeObjs(); + + if(inobj) { + for(int i = 0; i < inobjs; ++i) delete inobj[i]; + delete[] inobj; inobj = NULL; + } + if(outobj) { + for(int i = 0; i < outobjs; ++i) delete outobj[i]; + delete[] outobj; outobj = NULL; + } } void flext_stk::m_dsp(int n,t_sample *const *in,t_sample *const *out) { - // called on every rebuild of the dsp chain - - int i; - - if(Blocksize() != blsz || Samplerate() != smprt) { - // block size or sample rate has changed... rebuild all objects - - ClearObjs(); - - smprt = Samplerate(); - blsz = Blocksize(); - Stk::setSampleRate(smprt); - - // set up sndobjs for inlets and outlets - if(inobjs) { - inobj = new Input *[inobjs]; - for(i = 0; i < inobjs; ++i) - inobj[i] = new Input(in[i],blsz); - } - if(outobjs) { - outobj = new Output *[outobjs]; - for(i = 0; i < outobjs; ++i) - outobj[i] = new Output(out[i],blsz); - } - - if(!NewObjs()) ClearObjs(); - } - else { - // assign changed input/output vectors - - for(i = 0; i < inobjs; ++i) inobj[i]->SetBuf(in[i]); - for(i = 0; i < outobjs; ++i) outobj[i]->SetBuf(out[i]); - } + // called on every rebuild of the dsp chain + + int i; + + if(Blocksize() != blsz || Samplerate() != smprt) { + // block size or sample rate has changed... rebuild all objects + + ClearObjs(); + + smprt = Samplerate(); + blsz = Blocksize(); + Stk::setSampleRate(smprt); + + // set up sndobjs for inlets and outlets + if(inobjs) { + inobj = new Input *[inobjs]; + for(i = 0; i < inobjs; ++i) + inobj[i] = new Input(in[i],blsz); + } + if(outobjs) { + outobj = new Output *[outobjs]; + for(i = 0; i < outobjs; ++i) + outobj[i] = new Output(out[i],blsz); + } + + if(!NewObjs()) ClearObjs(); + } + else { + // assign changed input/output vectors + + for(i = 0; i < inobjs; ++i) inobj[i]->SetBuf(in[i]); + for(i = 0; i < outobjs; ++i) outobj[i]->SetBuf(out[i]); + } } void flext_stk::m_signal(int n,t_sample *const *in,t_sample *const *out) { - if(inobjs || outobjs) ProcessObjs(blsz); + if(inobjs || outobjs) ProcessObjs(blsz); } // inlet class flext_stk::Input::Input(const t_sample *b,int v): - buf(b),vecsz(v), - index(0) + buf(b),vecsz(v), + index(0) {} MY_FLOAT *flext_stk::Input::tick(MY_FLOAT *vector,unsigned int vectorSize) { - for(unsigned int i = 0; i < vectorSize; i++) vector[i] = tick(); - return vector; + for(unsigned int i = 0; i < vectorSize; i++) vector[i] = tick(); + return vector; } // outlet class flext_stk::Output::Output(t_sample *b,int v): - buf(b),vecsz(v), - index(0) + buf(b),vecsz(v), + index(0) {} void flext_stk::Output::tick(const MY_FLOAT *vector,unsigned int vectorSize) { - for(unsigned int i = 0; i < vectorSize; i++) tick(vector[i]); + for(unsigned int i = 0; i < vectorSize; i++) tick(vector[i]); } diff --git a/externals/grill/flext/source/flstk.h b/externals/grill/flext/source/flstk.h index d6bad079..a610e9c6 100644 --- a/externals/grill/flext/source/flstk.h +++ b/externals/grill/flext/source/flstk.h @@ -15,81 +15,81 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include class FLEXT_SHARE flext_stk: - public flext_dsp + public flext_dsp { - FLEXT_HEADER(flext_stk,flext_dsp) + FLEXT_HEADER(flext_stk,flext_dsp) public: - flext_stk(); + flext_stk(); - // these have to be overridden in child classes - virtual bool NewObjs() { return true; } - virtual void FreeObjs() {} - virtual void ProcessObjs(int blocksize) {} + // these have to be overridden in child classes + virtual bool NewObjs() { return true; } + virtual void FreeObjs() {} + virtual void ProcessObjs(int blocksize) {} protected: - virtual bool Init(); - virtual void Exit(); + virtual bool Init(); + virtual void Exit(); - //! STK object for reading from inlet buffer - class Input: - public Stk - { - public: - Input(const t_sample *b,int vecsz); + //! STK object for reading from inlet buffer + class Input: + public Stk + { + public: + Input(const t_sample *b,int vecsz); - inline MY_FLOAT lastOut() const { return (MY_FLOAT)buf[index]; } + inline MY_FLOAT lastOut() const { return (MY_FLOAT)buf[index]; } - inline MY_FLOAT tick() { - if(++index >= vecsz) index = 0; - return lastOut(); + inline MY_FLOAT tick() { + if(++index >= vecsz) index = 0; + return lastOut(); } - MY_FLOAT *tick(MY_FLOAT *vector,unsigned int vectorSize); + MY_FLOAT *tick(MY_FLOAT *vector,unsigned int vectorSize); - inline void SetBuf(const t_sample *b) { buf = b; } + inline void SetBuf(const t_sample *b) { buf = b; } - private: - const t_sample *buf; - int vecsz,index; - }; + private: + const t_sample *buf; + int vecsz,index; + }; - //! STK object for writing to outlet buffer - class Output: - public Stk - { - public: - Output(t_sample *b,int vecsz); + //! STK object for writing to outlet buffer + class Output: + public Stk + { + public: + Output(t_sample *b,int vecsz); inline void tick(MY_FLOAT s) { buf[index] = (t_sample)s; if(++index >= vecsz) index = 0; } - void tick(const MY_FLOAT *vector,unsigned int vectorSize); + void tick(const MY_FLOAT *vector,unsigned int vectorSize); - inline void SetBuf(t_sample *b) { buf = b; } + inline void SetBuf(t_sample *b) { buf = b; } - private: - t_sample *buf; - int vecsz,index; - }; + private: + t_sample *buf; + int vecsz,index; + }; - Input &Inlet(int ix) { return *inobj[ix]; } - Output &Outlet(int ix) { return *outobj[ix]; } + Input &Inlet(int ix) { return *inobj[ix]; } + Output &Outlet(int ix) { return *outobj[ix]; } private: - virtual void m_dsp(int n,t_sample *const *in,t_sample *const *out); - virtual void m_signal(int n,t_sample *const *in,t_sample *const *out); + virtual void m_dsp(int n,t_sample *const *in,t_sample *const *out); + virtual void m_signal(int n,t_sample *const *in,t_sample *const *out); - void ClearObjs(); + void ClearObjs(); - int inobjs,outobjs; - Input **inobj; - Output **outobj; + int inobjs,outobjs; + Input **inobj; + Output **outobj; - float smprt; - int blsz; + float smprt; + int blsz; }; #endif diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index cd92aaa4..14ddad47 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -419,13 +419,6 @@ public: //! Check whether the atom can be represented as an integer static bool CanbeInt(const t_atom &a) { return IsFloat(a) || IsInt(a); } - //! Set the atom to represent a boolean - static void SetBool(t_atom &a,bool v) { SetInt(a,v?1:0); } - //! Check whether the atom can be represented as a boolean - static bool CanbeBool(const t_atom &a) { return CanbeInt(a); } - //! Check for an boolean and get its value - static bool GetABool(const t_atom &a) { return GetAInt(a) != 0; } - #if FLEXT_SYS == FLEXT_SYS_PD //! Check for a float and get its value static float GetAFloat(const t_atom &a,float def = 0) { return IsFloat(a)?GetFloat(a):def; } @@ -500,6 +493,15 @@ public: #error "Platform not supported" #endif + //! Set the atom to represent a boolean + static void SetBool(t_atom &a,bool v) { SetInt(a,v?1:0); } + //! Check whether the atom can be represented as a boolean + static bool CanbeBool(const t_atom &a) { return CanbeInt(a); } + //! Check for an boolean and get its value + static bool GetABool(const t_atom &a) { return GetAInt(a) != 0; } + //! Check for an boolean and get its value + static bool GetBool(const t_atom &a) { return GetInt(a) != 0; } + // --- atom list stuff ------------------------------------------- //! Class representing a list of atoms diff --git a/externals/grill/flext/source/fltimer.cpp b/externals/grill/flext/source/fltimer.cpp index 3ce05ed9..9cab8e90 100755 --- a/externals/grill/flext/source/fltimer.cpp +++ b/externals/grill/flext/source/fltimer.cpp @@ -9,7 +9,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. */ /*! \file fltimer.cpp - \brief flext timer functions and classes + \brief flext timer functions and classes */ #include "flext.h" @@ -29,24 +29,24 @@ WARRANTIES, see the file, "license.txt," in this distribution. double flext::GetTime() { #if FLEXT_SYS == FLEXT_SYS_PD - return clock_gettimesince(0)*0.001; + return clock_gettimesince(0)*0.001; #elif FLEXT_SYS == FLEXT_SYS_MAX - double tm; - clock_getftime(&tm); - return tm*0.001; + double tm; + clock_getftime(&tm); + return tm*0.001; #else - #error Not implemented + #error Not implemented #endif } double flext::GetTimeGrain() { #if FLEXT_SYS == FLEXT_SYS_PD - return 0; + return 0; #elif FLEXT_SYS == FLEXT_SYS_MAX - return 0.001; + return 0.001; #else - #error Not implemented + #error Not implemented #endif } @@ -55,13 +55,13 @@ static double starttime = getstarttime(); static double getstarttime() { - starttime = 0; - return flext::GetOSTime(); + starttime = 0; + return flext::GetOSTime(); } double flext::GetOSTime() { - double tm; + double tm; #if FLEXT_OS == FLEXT_OS_WIN LARGE_INTEGER frq,cnt; @@ -75,37 +75,37 @@ double flext::GetOSTime() tm = (double)((LARGE_INTEGER *)&fltm)->QuadPart*0.001; } #elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || FLEXT_OSAPI == FLEXT_OSAPI_MAC_MACH // POSIX - timeval tmv; - gettimeofday(&tmv,NULL); - tm = tmv.tv_sec+tmv.tv_usec*1.e-6; + timeval tmv; + gettimeofday(&tmv,NULL); + tm = tmv.tv_sec+tmv.tv_usec*1.e-6; #elif FLEXT_OS == FLEXT_OS_MAC // that's just for OS9 & Carbon! - UnsignedWide tick; - Microseconds(&tick); - tm = (tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo)*1.e-6; + UnsignedWide tick; + Microseconds(&tick); + tm = (tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo)*1.e-6; #else - #error Not implemented + #error Not implemented #endif - return tm-starttime; + return tm-starttime; } void flext::Sleep(double s) { #if FLEXT_OS == FLEXT_OS_WIN - ::Sleep((long)(s*1000.)); + ::Sleep((long)(s*1000.)); #elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || FLEXT_OSAPI == FLEXT_OSAPI_MAC_MACH // POSIX - usleep((long)(s*1000000.)); + usleep((long)(s*1000000.)); #elif FLEXT_OS == FLEXT_OS_MAC // that's just for OS9 & Carbon! - UnsignedWide tick; - Microseconds(&tick); - double target = tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo+s*1.e6; - for(;;) { - // this is just a loop running until the time has passed - stone age (but we yield at least) - Microseconds(&tick); - if(target <= tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo) break; - YieldToAnyThread(); // yielding surely reduces the timing precision (but we're civilized) - } + UnsignedWide tick; + Microseconds(&tick); + double target = tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo+s*1.e6; + for(;;) { + // this is just a loop running until the time has passed - stone age (but we yield at least) + Microseconds(&tick); + if(target <= tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo) break; + YieldToAnyThread(); // yielding surely reduces the timing precision (but we're civilized) + } #else - #error Not implemented + #error Not implemented #endif } @@ -113,134 +113,134 @@ void flext::Sleep(double s) /* \param qu determines whether timed messages should be queued (low priority - only when supported by the system). */ flext::Timer::Timer(bool qu): - queued(qu), - clss(NULL),userdata(NULL), - period(0) + queued(qu), + clss(NULL),userdata(NULL), + period(0) { #if FLEXT_SYS == FLEXT_SYS_PD - clk = (t_clock *)clock_new(this,(t_method)callback); + clk = (t_clock *)clock_new(this,(t_method)callback); #elif FLEXT_SYS == FLEXT_SYS_MAX - clk = (t_clock *)clock_new(this,(t_method)callback); - if(queued) qelem = (t_qelem *)qelem_new(this,(method)queuefun); + clk = (t_clock *)clock_new(this,(t_method)callback); + if(queued) qelem = (t_qelem *)qelem_new(this,(method)queuefun); #else - #error Not implemented + #error Not implemented #endif } flext::Timer::~Timer() { #if FLEXT_SYS == FLEXT_SYS_PD - clock_free(clk); + clock_free(clk); #elif FLEXT_SYS == FLEXT_SYS_MAX - clock_free(clk); - if(queued) ::qelem_free(qelem); + clock_free(clk); + if(queued) ::qelem_free(qelem); #else - #error Not implemented + #error Not implemented #endif } bool flext::Timer::Reset() { #if FLEXT_SYS == FLEXT_SYS_PD - clock_unset(clk); + clock_unset(clk); #elif FLEXT_SYS == FLEXT_SYS_MAX - clock_unset(clk); - if(queued) ::qelem_unset(qelem); + clock_unset(clk); + if(queued) ::qelem_unset(qelem); #else - #error Not implemented + #error Not implemented #endif - return true; + return true; } /*! \param tm absolute time (in seconds) - \param data user data - \param dopast if set events with times lying in the past will be triggered immediately, if not set they are ignored - \return true on success + \param data user data + \param dopast if set events with times lying in the past will be triggered immediately, if not set they are ignored + \return true on success */ bool flext::Timer::At(double tm,void *data,bool dopast) { - userdata = data; - period = 0; + userdata = data; + period = 0; #if FLEXT_SYS == FLEXT_SYS_PD - const double ms = tm*1000.; - if(dopast || clock_gettimesince(ms) <= 0) - clock_set(clk,ms); + const double ms = tm*1000.; + if(dopast || clock_gettimesince(ms) <= 0) + clock_set(clk,ms); #elif FLEXT_SYS == FLEXT_SYS_MAX - const double ms = tm*1000.; - double cur; - clock_getftime(&cur); - if(cur <= ms) - clock_fdelay(clk,ms-cur); - else if(dopast) // trigger timer is past - clock_fdelay(clk,0); + const double ms = tm*1000.; + double cur; + clock_getftime(&cur); + if(cur <= ms) + clock_fdelay(clk,ms-cur); + else if(dopast) // trigger timer is past + clock_fdelay(clk,0); #else - #error Not implemented + #error Not implemented #endif - return true; + return true; } /*! \param tm relative time (in seconds) - \param data user data - \return true on success + \param data user data + \return true on success */ bool flext::Timer::Delay(double tm,void *data) { - userdata = data; - period = 0; + userdata = data; + period = 0; #if FLEXT_SYS == FLEXT_SYS_PD - clock_delay(clk,tm*1000); + clock_delay(clk,tm*1000); #elif FLEXT_SYS == FLEXT_SYS_MAX - clock_fdelay(clk,tm*1000.); + clock_fdelay(clk,tm*1000.); #else - #error Not implemented + #error Not implemented #endif - return true; + return true; } /*! \param tm relative time between periodic events (in seconds) - \param data user data - \return true on success - \note the first event will be delayed by tm + \param data user data + \return true on success + \note the first event will be delayed by tm */ bool flext::Timer::Periodic(double tm,void *data) { - userdata = data; - period = tm; + userdata = data; + period = tm; #if FLEXT_SYS == FLEXT_SYS_PD - clock_delay(clk,tm*1000); + clock_delay(clk,tm*1000); #elif FLEXT_SYS == FLEXT_SYS_MAX - clock_fdelay(clk,tm*1000.); + clock_fdelay(clk,tm*1000.); #else - #error Not implemented + #error Not implemented #endif - return true; + return true; } /*! \brief Callback function for system clock. - \todo Make periodic events scheduled as such. + \todo Make periodic events scheduled as such. */ void flext::Timer::callback(Timer *tmr) { - if(tmr->period) { - // clearly it would be more precise if the periodic event is scheduled as such - // and not retriggered every time + if(tmr->period) { + // clearly it would be more precise if the periodic event is scheduled as such + // and not retriggered every time #if FLEXT_SYS == FLEXT_SYS_PD - clock_delay(tmr->clk,tmr->period*1000); + clock_delay(tmr->clk,tmr->period*1000); #elif FLEXT_SYS == FLEXT_SYS_MAX - clock_fdelay(tmr->clk,tmr->period*1000.); + clock_fdelay(tmr->clk,tmr->period*1000.); #else - #error Not implemented + #error Not implemented #endif - } + } - if(tmr->cback) { + if(tmr->cback) { #if FLEXT_SYS == FLEXT_SYS_MAX - if(tmr->queued) - qelem_set(tmr->qelem); - else + if(tmr->queued) + qelem_set(tmr->qelem); + else #endif - tmr->Work(); - } + tmr->Work(); + } } #if FLEXT_SYS == FLEXT_SYS_MAX @@ -250,13 +250,13 @@ void flext::Timer::queuefun(Timer *tmr) { tmr->Work(); } #endif /*! \brief Virtual worker function - by default it calls the user callback function. - \remark The respective callback parameter format is chosen depending on whether clss is defined or not. + \remark The respective callback parameter format is chosen depending on whether clss is defined or not. */ void flext::Timer::Work() { - if(clss) - ((bool (*)(flext_base *,void *))cback)(clss,userdata); - else - cback(userdata); + if(clss) + ((bool (*)(flext_base *,void *))cback)(clss,userdata); + else + cback(userdata); } diff --git a/externals/grill/flext/source/flutil.cpp b/externals/grill/flext/source/flutil.cpp index 3c7c704d..2e80b6e6 100644 --- a/externals/grill/flext/source/flutil.cpp +++ b/externals/grill/flext/source/flutil.cpp @@ -18,11 +18,11 @@ WARRANTIES, see the file, "license.txt," in this distribution. #if FLEXT_OS == FLEXT_OS_WIN #include #elif FLEXT_OS == FLEXT_OS_MAC - #if FLEXT_OSAPI != FLEXT_OSAPI_MAC_MACH - #include - #else - #include - #endif + #if FLEXT_OSAPI != FLEXT_OSAPI_MAC_MACH + #include + #else + #include + #endif #endif void flext::CopyMem(void *dst,const void *src,int bytes) @@ -30,9 +30,9 @@ void flext::CopyMem(void *dst,const void *src,int bytes) #if FLEXT_OS == FLEXT_OS_WIN MoveMemory(dst,src,bytes); #elif FLEXT_OS == FLEXT_OS_MAC - BlockMoveData(src,dst,bytes); + BlockMoveData(src,dst,bytes); #else - memcpy(dst,src,bytes); + memcpy(dst,src,bytes); #endif } @@ -43,22 +43,22 @@ void flext::ZeroMem(void *dst,int bytes) #elif FLEXT_OS == FLEXT_OS_MAC BlockZero(dst,bytes); #else - memset(dst,0,bytes); + memset(dst,0,bytes); #endif } bool flext::Forward(const t_symbol *recv,const t_symbol *s,int argc,const t_atom *argv) { - void *cl = recv->s_thing; - if(!cl) return false; + void *cl = recv->s_thing; + if(!cl) return false; #if FLEXT_SYS == FLEXT_SYS_PD - pd_typedmess((t_class **)cl,(t_symbol *)s,argc,(t_atom *)argv); + pd_typedmess((t_class **)cl,(t_symbol *)s,argc,(t_atom *)argv); #elif FLEXT_SYS == FLEXT_SYS_MAX - typedmess(recv->s_thing,(t_symbol *)s,argc,(t_atom *)argv); + typedmess(recv->s_thing,(t_symbol *)s,argc,(t_atom *)argv); #else #error Not implemented #endif - return true; + return true; } diff --git a/externals/grill/flext/source/flxlet.cpp b/externals/grill/flext/source/flxlet.cpp index 76c02afb..1d57177c 100755 --- a/externals/grill/flext/source/flxlet.cpp +++ b/externals/grill/flext/source/flxlet.cpp @@ -19,78 +19,78 @@ WARRANTIES, see the file, "license.txt," in this distribution. flext_base::xlet::xlet(type t,const char *d): - tp(t),nxt(NULL) + tp(t),nxt(NULL) { - if(d) { - int ln = strlen(d); - desc = new char[ln+1]; - memcpy(desc,d,ln); - desc[ln] = 0; - } - else desc = NULL; + if(d) { + int ln = strlen(d); + desc = new char[ln+1]; + memcpy(desc,d,ln); + desc[ln] = 0; + } + else desc = NULL; } flext_base::xlet::~xlet() { - if(desc) delete[] desc; - if(nxt) delete nxt; + if(desc) delete[] desc; + if(nxt) delete nxt; } void flext_base::AddXlet(xlet::type tp,int mult,const char *desc,xlet *&root) { - if(!root && mult) { root = new xlet(tp,desc); --mult; } - if(mult) { - xlet *xi = root; - while(xi->nxt) xi = xi->nxt; - while(mult--) xi = xi->nxt = new xlet(tp,desc); - } + if(!root && mult) { root = new xlet(tp,desc); --mult; } + if(mult) { + xlet *xi = root; + while(xi->nxt) xi = xi->nxt; + while(mult--) xi = xi->nxt = new xlet(tp,desc); + } } void flext_base::DescXlet(int ix,const char *d,xlet *&root) { - xlet *xi = root; - for(int i = 0; xi && i < ix; xi = xi->nxt,++i) {} - - if(xi) { - if(xi->desc) delete[] xi->desc; - int ln = strlen(d); - xi->desc = new char[ln+1]; - memcpy(xi->desc,d,ln); - xi->desc[ln] = 0; - } + xlet *xi = root; + for(int i = 0; xi && i < ix; xi = xi->nxt,++i) {} + + if(xi) { + if(xi->desc) delete[] xi->desc; + int ln = strlen(d); + xi->desc = new char[ln+1]; + memcpy(xi->desc,d,ln); + xi->desc[ln] = 0; + } } unsigned long flext_base::XletCode(xlet::type tp,...) { - unsigned long code = 0; + unsigned long code = 0; - va_list marker; - va_start(marker,tp); - int cnt = 0; - xlet::type arg = tp; - for(; arg; ++cnt) { + va_list marker; + va_start(marker,tp); + int cnt = 0; + xlet::type arg = tp; + for(; arg; ++cnt) { #ifdef FLEXT_DEBUG - if(cnt > 9) { - error("%s - Too many in/outlets defined - truncated to 9",thisName()); - break; - } -#endif - - code = code*10+(int)arg; - arg = (xlet::type)va_arg(marker,int); - } - va_end(marker); - - return code; + if(cnt > 9) { + error("%s - Too many in/outlets defined - truncated to 9",thisName()); + break; + } +#endif + + code = code*10+(int)arg; + arg = (xlet::type)va_arg(marker,int); + } + va_end(marker); + + return code; } void flext_base::AddInlets(unsigned long code) { - for(; code; code /= 10) AddInlet((xlet::type)(code%10)); + for(; code; code /= 10) AddInlet((xlet::type)(code%10)); } void flext_base::AddOutlets(unsigned long code) { - for(; code; code /= 10) AddOutlet((xlet::type)(code%10)); + for(; code; code /= 10) AddOutlet((xlet::type)(code%10)); } diff --git a/externals/grill/pool/config-pd-darwin.txt b/externals/grill/pool/config-pd-darwin.txt index 4e8cbb45..62f4a9e8 100644 --- a/externals/grill/pool/config-pd-darwin.txt +++ b/externals/grill/pool/config-pd-darwin.txt @@ -27,4 +27,7 @@ INSTPATH=/usr/local/lib/pd/extra # (check if they match your system!) UFLAGS=-malign-power -maltivec +# use shared flext library +FLEXT_SHARED=1 + diff --git a/externals/grill/pool/config-pd-mingw.txt b/externals/grill/pool/config-pd-mingw.txt index b15de586..18d6800e 100755 --- a/externals/grill/pool/config-pd-mingw.txt +++ b/externals/grill/pool/config-pd-mingw.txt @@ -22,4 +22,3 @@ UFLAGS= # define for shared build FLEXT_SHARED=1 - diff --git a/externals/grill/pool/makefile.pd-darwin b/externals/grill/pool/makefile.pd-darwin index b602933a..248e4bf8 100644 --- a/externals/grill/pool/makefile.pd-darwin +++ b/externals/grill/pool/makefile.pd-darwin @@ -12,16 +12,25 @@ CONFIG=config-pd-darwin.txt include $(CONFIG) -FLEXTLIB=$(FLEXTPATH)/flext.a - # compiler+linker stuff INCLUDES=$(PDPATH) LIBPATH= FLAGS=-DFLEXT_SYS=2 -CFLAGS=-O6 ${UFLAGS} -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes +CFLAGS=-O2 ${UFLAGS} -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes LIBS=m -LDFLAGS=-bundle -bundle_loader $(PD) FRAMEWORKS=Carbon +LDFLAGS+=-bundle -bundle_loader $(PD) + +ifdef FLEXT_SHARED +CFLAGS+=-dynamic -DFLEXT_SHARED +LDFLAGS+=-dynamic -L$(FLEXTPATH) +FLEXTLIB=-lflext + +else + +FLEXTLIB=$(FLEXTPATH)/libflext.a + +endif # --------------------------------------------- @@ -36,7 +45,7 @@ TARGET=$(TARGDIR)/$(NAME).pd_darwin # default target all: $(TARGDIR) $(TARGET) -$(patsubst %,$(SRCDIR)/%,$(SRCS)): $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(FLEXTLIB) $(CONFIG) +$(patsubst %,$(SRCDIR)/%,$(SRCS)): $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(CONFIG) touch $@ $(TARGDIR): @@ -45,8 +54,8 @@ $(TARGDIR): $(TARGDIR)/%.o : $(SRCDIR)/%.cpp $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@ -$(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) $(FLEXTLIB) - $(CXX) $(LDFLAGS) $^ $(patsubst %,-framework %,$(FRAMEWORKS)) $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@ +$(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) + $(CXX) $(LDFLAGS) $^ $(patsubst %,-framework %,$(FRAMEWORKS)) $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) $(FLEXTLIB) -o $@ chmod 755 $@ $(INSTPATH): @@ -56,8 +65,8 @@ install:: $(INSTPATH) install:: $(TARGET) cp $^ $(INSTPATH) -# chown root.root $(patsubst %,$(INSTPATH)/%,$(notdir $^)) -# chmod 755 $(patsubst %,$(INSTPATH)/%,$(notdir $^)) + chmod 755 $(patsubst %,$(INSTPATH)/%,$(notdir $^)) + chown root $(patsubst %,$(INSTPATH)/%,$(notdir $^)) .PHONY: clean clean: diff --git a/externals/grill/pool/makefile.pd-mingw b/externals/grill/pool/makefile.pd-mingw index ff2d2e55..c8d3a784 100755 --- a/externals/grill/pool/makefile.pd-mingw +++ b/externals/grill/pool/makefile.pd-mingw @@ -57,12 +57,3 @@ install:: $(TARGET) .PHONY: clean clean: rm -f $(TARGDIR)/*.o $(TARGET) - - - - - - - - - diff --git a/externals/grill/pool/pool.cw b/externals/grill/pool/pool.cw index 8f88ff0c..57c4c1a1 100755 Binary files a/externals/grill/pool/pool.cw and b/externals/grill/pool/pool.cw differ diff --git a/externals/grill/pool/pool.help b/externals/grill/pool/pool.help index 9ec9715f..21dd9838 100755 Binary files a/externals/grill/pool/pool.help and b/externals/grill/pool/pool.help differ diff --git a/externals/grill/pool/pool.vcproj b/externals/grill/pool/pool.vcproj index 45d0b3d1..606e39e4 100644 --- a/externals/grill/pool/pool.vcproj +++ b/externals/grill/pool/pool.vcproj @@ -176,11 +176,11 @@ Name="VCCustomBuildTool"/> diff --git a/externals/grill/pool/source/pool.cpp b/externals/grill/pool/source/pool.cpp index bda4407a..fd4b4a83 100644 --- a/externals/grill/pool/source/pool.cpp +++ b/externals/grill/pool/source/pool.cpp @@ -623,7 +623,7 @@ static bool gettag(istream &is,xmltag &tag) if(c == '>') { // if third character is > then check also the former two int i; - for(i = 0; i < 2 && cmp[(ic+i)%2] == commend[i]; ++i); + for(i = 0; i < 2 && cmp[(ic+i)%2] == commend[i]; ++i) {} if(i == 2) break; // match: comment end found! } else @@ -647,17 +647,17 @@ static bool gettag(istream &is,xmltag &tag) char *tb = tmp,*te = t-1,*tf; - for(; isspace(*tb); ++tb); + for(; isspace(*tb); ++tb) {} if(*tb == '/') { // slash at the beginning -> end tag tag.type = xmltag::t_end; - for(++tb; isspace(*tb); ++tb); + for(++tb; isspace(*tb); ++tb) {} } else { - for(; isspace(*te); --te); + for(; isspace(*te); --te) {} if(*te == '/') { // slash at the end -> empty tag - for(--te; isspace(*te); --te); + for(--te; isspace(*te); --te) {} tag.type = xmltag::t_empty; } else @@ -666,7 +666,7 @@ static bool gettag(istream &is,xmltag &tag) } // copy tag text without slashes - for(tf = tb; tf <= te && *tf && !isspace(*tf); ++tf); + for(tf = tb; tf <= te && *tf && !isspace(*tf); ++tf) {} tag.tag.assign(tb,tf-tb); while(isspace(*tf)) ++tf; tag.attr.assign(tf,te-tf+1); diff --git a/externals/grill/pool/source/pool.h b/externals/grill/pool/source/pool.h index 64445c06..fb1c290e 100644 --- a/externals/grill/pool/source/pool.h +++ b/externals/grill/pool/source/pool.h @@ -15,8 +15,8 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include -#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 405) -#error You need at least flext version 0.4.5 +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 406) +#error You need at least flext version 0.4.6 #endif #include diff --git a/externals/grill/py/pd/attr-1.pd b/externals/grill/py/pd/attr-1.pd index f302db7e..bf797c70 100644 --- a/externals/grill/py/pd/attr-1.pd +++ b/externals/grill/py/pd/attr-1.pd @@ -1,32 +1,34 @@ -#N canvas 114 127 687 417 12; -#X obj 224 370 pyext simple ex3; -#X obj 392 371 print A; -#X msg 252 180 get tmp; -#X msg 369 210 get _inlets; -#X msg 253 204 set tmp 3; -#X msg 368 234 set _inlets 4; -#X msg 18 179 dir; -#X msg 15 282 getattributes; -#X msg 15 309 getmethods; -#X msg 18 207 dir+; -#X text 15 48 This demonstrates the usage of attributes. See the simple.py -file.; -#X text 252 161 access a class variable; -#X text 368 191 try to get/set internal stuff; -#X text 479 234 (NOT allowed!); -#X text 16 15 py/pyext - Python script objects \, (C)2003 Thomas Grill -; -#X text 16 261 get attributes and methods; -#X text 51 178 Python module dict; -#X text 59 208 Python class dict; -#X text 17 101 All attribute-related methods dump eventual output to -the attribute outlet (which is the right-most one); -#X connect 0 1 1 0; -#X connect 2 0 0 0; -#X connect 3 0 0 0; -#X connect 4 0 0 0; -#X connect 5 0 0 0; -#X connect 6 0 0 0; -#X connect 7 0 0 0; -#X connect 8 0 0 0; -#X connect 9 0 0 0; +#N canvas 114 127 693 451 12; +#X obj 224 397 pyext simple ex3; +#X obj 392 398 print A; +#X msg 252 207 get tmp; +#X msg 369 237 get _inlets; +#X msg 253 231 set tmp 3; +#X msg 368 261 set _inlets 4; +#X msg 18 206 dir; +#X msg 15 312 getattributes; +#X msg 15 336 getmethods; +#X msg 18 234 dir+; +#X text 15 75 This demonstrates the usage of attributes. See the simple.py +file.; +#X text 252 188 access a class variable; +#X text 368 218 try to get/set internal stuff; +#X text 479 261 (NOT allowed!); +#X text 16 288 get attributes and methods; +#X text 51 205 Python module dict; +#X text 59 235 Python class dict; +#X text 17 128 All attribute-related methods dump eventual output to +the attribute outlet (which is the right-most one); +#X obj 16 13 cnv 15 650 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 235 32 http://www.parasitaere-kapazitaeten.net; +#X text 235 16 Python script objects \, (C)2003-2004 Thomas Grill; +#X connect 0 1 1 0; +#X connect 2 0 0 0; +#X connect 3 0 0 0; +#X connect 4 0 0 0; +#X connect 5 0 0 0; +#X connect 6 0 0 0; +#X connect 7 0 0 0; +#X connect 8 0 0 0; +#X connect 9 0 0 0; diff --git a/externals/grill/py/pd/script-1.pd b/externals/grill/py/pd/script-1.pd index 4ac23971..d0d7e5b2 100644 --- a/externals/grill/py/pd/script-1.pd +++ b/externals/grill/py/pd/script-1.pd @@ -1,4 +1,4 @@ -#N canvas 297 17 676 527 12; +#N canvas 297 17 680 522 12; #X obj 39 278 print; #X obj 345 251 print; #X msg 499 149 freakhole; @@ -21,9 +21,7 @@ #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 +#X text 21 69 This demonstrates simple scripting. See the script.py file.; #X obj 39 241 py script strcat; #X obj 43 424 py script addall; @@ -33,24 +31,28 @@ file.; #X msg 21 159 dir; #X obj 146 279 print A; #X msg 58 160 dir+; -#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 22 1 28 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; -#X connect 27 0 22 0; -#X connect 29 0 22 0; +#X obj 16 13 cnv 15 630 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 235 32 http://www.parasitaere-kapazitaeten.net; +#X text 235 16 Python script objects \, (C)2003-2004 Thomas Grill; +#X connect 2 0 25 1; +#X connect 3 0 21 1; +#X connect 4 0 21 1; +#X connect 6 0 22 1; +#X connect 7 0 22 1; +#X connect 9 0 23 0; +#X connect 11 0 24 0; +#X connect 12 0 21 1; +#X connect 13 0 25 0; +#X connect 14 0 23 0; +#X connect 15 0 23 0; +#X connect 17 0 25 1; +#X connect 19 0 21 0; +#X connect 21 0 0 0; +#X connect 21 1 27 0; +#X connect 22 0 5 0; +#X connect 23 0 8 0; +#X connect 24 0 10 0; +#X connect 25 0 1 0; +#X connect 26 0 21 0; +#X connect 28 0 21 0; diff --git a/externals/grill/py/pd/sendrecv-1.pd b/externals/grill/py/pd/sendrecv-1.pd index d2d4b50a..56810c74 100644 --- a/externals/grill/py/pd/sendrecv-1.pd +++ b/externals/grill/py/pd/sendrecv-1.pd @@ -1,25 +1,29 @@ -#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; +#N canvas 145 126 642 317 12; +#X msg 125 117 reload mi ma; +#X floatatom 48 238 5 0 0 0 - - -; +#X floatatom 297 239 5 0 0 0 - - -; +#X obj 297 263 s mi; +#X floatatom 143 265 5 0 0 0 - - -; +#X floatatom 382 267 5 0 0 0 - - -; +#X obj 382 240 r ma; +#X obj 48 262 s he; +#X obj 143 238 r hu; +#X text 233 116 reload with different args; +#X msg 20 82 help; +#X msg 19 114 doc; +#X msg 58 114 doc+; +#X obj 49 165 pyext sendrecv ex1 he hu; +#X text 30 218 scroll here; +#X text 292 219 or here; +#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 213 32 http://www.parasitaere-kapazitaeten.net; +#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill; +#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 index 9f015b4c..a257d5e8 100644 --- a/externals/grill/py/pd/sendrecv-2.pd +++ b/externals/grill/py/pd/sendrecv-2.pd @@ -1,8 +1,12 @@ -#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; +#N canvas 133 322 643 185 12; +#X obj 152 98 pyext sendrecv ex2 huha; +#X floatatom 152 128 5 0 0 0 - - -; +#X floatatom 33 96 5 0 0 0 - - -; +#X obj 32 123 s huha; +#X text 20 77 scroll here; +#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 213 32 http://www.parasitaere-kapazitaeten.net; +#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill; +#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 index 0f42edfc..037895fb 100644 --- a/externals/grill/py/pd/sendrecv-3.pd +++ b/externals/grill/py/pd/sendrecv-3.pd @@ -1,5 +1,9 @@ -#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; +#N canvas 294 237 640 319 12; +#X obj 410 265 pyext sendrecv ex3; +#X obj 564 262 bng 25 250 50 0 empty ugh empty 0 -6 0 8 -258699 -1 +-1; +#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 213 32 http://www.parasitaere-kapazitaeten.net; +#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill; +#X connect 1 0 0 1; diff --git a/externals/grill/py/pd/simple-1.pd b/externals/grill/py/pd/simple-1.pd index 2d60db5b..f4b10cae 100644 --- a/externals/grill/py/pd/simple-1.pd +++ b/externals/grill/py/pd/simple-1.pd @@ -1,7 +1,7 @@ -#N canvas 156 192 650 389 12; +#N canvas 156 192 662 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 floatatom 52 155 5 0 0 0 - - -; #X text 388 337 watch the console output!; #X msg 52 186 2 3 4; #X msg 277 131 ho; @@ -16,13 +16,15 @@ #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 +#X text 16 69 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 obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 213 32 http://www.parasitaere-kapazitaeten.net; +#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill; #X connect 0 0 9 1; #X connect 1 0 9 1; #X connect 3 0 9 1; @@ -37,5 +39,5 @@ file.; #X connect 13 0 9 3; #X connect 14 0 9 3; #X connect 15 0 9 0; +#X connect 18 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 index e20be506..31680d87 100644 --- a/externals/grill/py/pd/simple-2.pd +++ b/externals/grill/py/pd/simple-2.pd @@ -1,37 +1,39 @@ -#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; +#N canvas 95 223 650 390 12; +#X floatatom 202 113 5 0 0 0 - - -; +#X text 338 286 watch the console output!; +#X msg 20 115 help; +#X text 16 69 This demonstrates message handling. See the simple.py +file.; +#X msg 19 140 doc; +#X msg 55 141 doc+; +#X floatatom 259 113 5 0 0 0 - - -; +#X msg 169 235 msg 2; +#X obj 123 289 pyext simple ex2; +#X floatatom 123 334 5 0 0 0 - - -; +#X floatatom 240 335 5 0 0 0 - - -; +#X msg 100 204 msg 1 3; +#X msg 234 220 msg a b; +#X msg 120 174 hello; +#X msg 193 180 hello; +#X msg 266 179 msg; +#X msg 325 154 hello 3; +#X text 338 189 special case: 'hello' handler doesn't like args \, +so _anything_ is called!; +#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 213 32 http://www.parasitaere-kapazitaeten.net; +#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill; +#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 11 0 8 1; +#X connect 12 0 8 3; +#X connect 13 0 8 1; +#X connect 14 0 8 3; +#X connect 15 0 8 2; +#X connect 16 0 8 3; diff --git a/externals/grill/py/pd/simple-3.pd b/externals/grill/py/pd/simple-3.pd index 450a3ec9..9cdb3f1b 100644 --- a/externals/grill/py/pd/simple-3.pd +++ b/externals/grill/py/pd/simple-3.pd @@ -1,27 +1,29 @@ -#N canvas 384 270 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 0 - - -; -#X text 17 22 py/pyext - Python script objects \, (C)2002 Thomas Grill -; -#X floatatom 316 119 5 0 0 0 - - -; -#X floatatom 399 119 5 0 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; +#N canvas 136 275 649 361 12; +#X msg 73 266 help; +#X text 17 80 This demonstrates message handling. See the simple.py +file.; +#X msg 72 291 doc; +#X msg 108 292 doc+; +#X floatatom 258 305 5 0 0 0 - - -; +#X floatatom 316 119 5 0 0 0 - - -; +#X floatatom 399 119 5 0 0 0 - - -; +#X obj 210 266 pyext simple ex3 1; +#X msg 24 182 reload.; +#X msg 24 210 reload -10; +#X text 95 181 reload script and keep arguments; +#X text 113 211 reload script with new arguments; +#X text 281 140 triggers; +#X text 310 304 result; +#X text 410 140 sets argument; +#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 213 32 http://www.parasitaere-kapazitaeten.net; +#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill; +#X connect 0 0 7 0; +#X connect 2 0 7 0; +#X connect 3 0 7 0; +#X connect 5 0 7 1; +#X connect 6 0 7 2; +#X connect 7 0 4 0; +#X connect 8 0 7 0; +#X connect 9 0 7 0; diff --git a/externals/grill/py/pd/thread-1.pd b/externals/grill/py/pd/thread-1.pd index be775852..b2daa5f0 100644 --- a/externals/grill/py/pd/thread-1.pd +++ b/externals/grill/py/pd/thread-1.pd @@ -1,32 +1,34 @@ -#N canvas 440 61 590 402 12; -#X msg 38 265 help; -#X msg 37 290 doc; -#X msg 73 291 doc+; -#X floatatom 145 323 5 0 0 0 - - -; -#X text 14 44 This demonstrates threading. See the threads.py file. +#N canvas 135 178 644 401 12; +#X msg 35 292 help; +#X msg 34 317 doc; +#X msg 70 318 doc+; +#X floatatom 142 340 5 0 0 0 - - -; +#X text 17 66 This demonstrates threading. See the threads.py file. ; -#X obj 140 216 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 +#X obj 137 243 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 0 - - -; -#X obj 275 123 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1 +#X msg 137 263 detach \$1; +#X floatatom 250 341 5 0 0 0 - - -; +#X obj 272 150 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 +#X obj 143 154 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 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 obj 145 279 pyext threads ex1; -#X text 93 101 - blocking!! -; -#X text 16 14 py/pyext - Python script objects \, (C)2002 \, 2003 Thomas -Grill; +#X obj 143 181 t b b b; +#X obj 272 177 t b b b; +#X obj 286 206 1; +#X obj 157 208 0; +#X text 84 114 without threads; +#X text 248 112 with threads; +#X text 249 129 non-blocking; +#X text 175 362 watch that!; +#X msg 411 154 stop; +#X text 381 133 you can even stop it; +#X obj 142 306 pyext threads ex1; +#X text 90 128 - blocking!! -; +#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 213 32 http://www.parasitaere-kapazitaeten.net; +#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill; #X connect 0 0 20 0; #X connect 1 0 20 0; #X connect 2 0 20 0; diff --git a/externals/grill/py/py.vcproj b/externals/grill/py/py.vcproj index 92f66da5..cbc08f0f 100644 --- a/externals/grill/py/py.vcproj +++ b/externals/grill/py/py.vcproj @@ -88,7 +88,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="c:\programme\audio\pd\src;f:\prog\max\flext\source;C:\Programme\prog\Python23\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=2;FLEXT_THREADS;_USEFLEXTBINDING" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=2;FLEXT_THREADS" BasicRuntimeChecks="3" RuntimeLibrary="1" RuntimeTypeInfo="TRUE" @@ -103,10 +103,10 @@ +typedef std::set FuncSet; + struct bounddata { PyObject *self; - std::set funcs; + FuncSet funcs; }; bool pyext::boundmeth(flext_base *,t_symbol *sym,int argc,t_atom *argv,void *data) @@ -25,10 +27,10 @@ bool pyext::boundmeth(flext_base *,t_symbol *sym,int argc,t_atom *argv,void *dat PY_LOCK - PyObject *args = MakePyArgs(sym,AtomList(argc,argv),-1,obj->self != NULL); + PyObject *args = MakePyArgs(sym,argc,argv,-1,obj->self != NULL); // call all functions bound by this symbol - for(std::set::iterator it = obj->funcs.begin(); it != obj->funcs.end(); ++it) { + for(FuncSet::iterator it = obj->funcs.begin(); it != obj->funcs.end(); ++it) { PyObject *ret = PyObject_CallObject(*it,args); if(!ret) { PyErr_Print(); @@ -135,7 +137,7 @@ V pyext::ClearBinding() while(GetThis(pyobj)->UnbindMethod(sym,NULL,&data)) { bounddata *bdt = (bounddata *)data; if(bdt) { - for(std::set::iterator it = bdt->funcs.begin(); it != bdt->funcs.end(); ++it) { + for(FuncSet::iterator it = bdt->funcs.begin(); it != bdt->funcs.end(); ++it) { PyObject *func = *it; if(PyMethod_Check(func)) Py_DECREF(func); } diff --git a/externals/grill/py/source/clmeth.cpp b/externals/grill/py/source/clmeth.cpp index a17c010a..d3b909ff 100644 --- a/externals/grill/py/source/clmeth.cpp +++ b/externals/grill/py/source/clmeth.cpp @@ -161,8 +161,10 @@ PyObject *pyext::pyext_outlet(PyObject *,PyObject *args) // 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); +// ext->ToOutAnything(o-1,GetSymbol((*lst)[0]),lst->Count()-1,lst->Atoms()+1); else ext->ToQueueList(o-1,*lst); +// ext->ToOutList(o-1,*lst); } else post("pyext: outlet index out of range"); @@ -230,7 +232,7 @@ PyObject *pyext::pyext_stop(PyObject *,PyObject *args) //! Query whether threading is enabled PyObject *pyext::pyext_isthreaded(PyObject *,PyObject *) { - return Py_BuildValue("i", + return PyInt_FromLong( #ifdef FLEXT_THREADED 1 #else diff --git a/externals/grill/py/source/main.cpp b/externals/grill/py/source/main.cpp index e552bc5a..0434f682 100644 --- a/externals/grill/py/source/main.cpp +++ b/externals/grill/py/source/main.cpp @@ -10,82 +10,83 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "main.h" + +static PyMethodDef StdOut_Methods[] = +{ + { "write", py::StdOut_Write, 1 }, + { NULL, NULL, } +}; + V py::lib_setup() { post(""); post("py/pyext %s - python script objects, (C)2002-2004 Thomas Grill",PY__VERSION); post(""); + // ------------------------------------------------------------- + + Py_Initialize(); + +#if 0 //def FLEXT_DEBUG + Py_DebugFlag = 1; + Py_VerboseFlag = 1; +#endif + +#ifdef FLEXT_THREADS + // enable thread support and acquire the global thread lock + PyEval_InitThreads(); + + // get thread state + pythrmain = PyThreadState_Get(); + // get main interpreter state + pystate = pythrmain->interp; + + // add thread state of main thread to map + pythrmap[GetThreadId()] = pythrmain; +#endif + + // register/initialize pyext module only once! + module_obj = Py_InitModule(PYEXT_MODULE, func_tbl); + module_dict = PyModule_GetDict(module_obj); // borrowed reference + + PyModule_AddStringConstant(module_obj,"__doc__",(C *)py_doc); + + // redirect stdout + PyObject* py_out = Py_InitModule("stdout", StdOut_Methods); + PySys_SetObject("stdout", py_out); + +#ifdef FLEXT_THREADS + // release global lock + PyEval_ReleaseLock(); +#endif + + // ------------------------------------------------------------- + FLEXT_SETUP(pyobj); FLEXT_SETUP(pyext); - - pyref = 0; } FLEXT_LIB_SETUP(py,py::lib_setup) -PyInterpreterState *py::pystate = NULL; #ifdef FLEXT_THREADS -std::map py::pythrmap; +PyInterpreterState *py::pystate = NULL; +PyThreadState *py::pythrmain = NULL; +PyThrMap py::pythrmap; #endif -I py::pyref = 0; PyObject *py::module_obj = NULL; PyObject *py::module_dict = NULL; -static PyMethodDef StdOut_Methods[] = -{ - { "write", py::StdOut_Write, 1 }, - { NULL, NULL, } -}; - - py::py(): module(NULL), detach(false),shouldexit(false),thrcount(0), stoptick(0) { - Lock(); - - if(!(pyref++)) { - Py_Initialize(); - - #ifdef FLEXT_THREADS - // enable thread support and acquire the global thread lock - PyEval_InitThreads(); - - // get thread state - PyThreadState *pythrmain = PyThreadState_Get(); - // get main interpreter state - pystate = pythrmain->interp; - - // release global lock - PyEval_ReleaseLock(); - - // add thread state of main thread to map - pythrmap[GetThreadId()] = pythrmain; - #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); - - // redirect stdout - PyObject* py_out = Py_InitModule("stdout", StdOut_Methods); - PySys_SetObject("stdout", py_out); - } - else { - PY_LOCK - Py_INCREF(module_obj); - Py_INCREF(module_dict); - PY_UNLOCK - } - - Unlock(); + PY_LOCK + Py_INCREF(module_obj); + PY_UNLOCK FLEXT_ADDTIMER(stoptmr,tick); } @@ -104,38 +105,7 @@ py::~py() post("%s - Okay, all threads have terminated",thisName()); } - Lock(); - - if(!(--pyref)) { - // no more py/pyext objects left... shut down Python - - module_obj = NULL; - module_dict = NULL; - - Py_XDECREF(module); - - PyEval_AcquireLock(); - -#ifdef FLEXT_THREADS - PyThreadState_Swap(pythrmap[GetThreadId()]); -#endif - -#if 0 //def FLEXT_DEBUG - // need not necessarily do that.... - Py_Finalize(); -#endif - -#ifdef FLEXT_THREADS - // reset thread state map - pythrmap.clear(); -#endif - } - else { - Py_DECREF(module_obj); - Py_DECREF(module_dict); - } - - Unlock(); + Py_XDECREF(module_obj); } @@ -229,16 +199,31 @@ V py::ImportModule(const C *name) { if(!name) return; - module = PyImport_ImportModule((C *)name); + module = PyImport_ImportModule((C *)name); // increases module_obj ref count by one if (!module) { + PyErr_Print(); dict = NULL; } else - dict = PyModule_GetDict(module); // borrowed - + dict = PyModule_GetDict(module); } +V py::UnimportModule() +{ + if(!module) return; + + assert(dict && module_obj && module_dict); + + Py_DECREF(module); + + // reference count to module is not 0 here, altough probably the last instance was unloaded + // Python retains one reference to the module all the time + // we don't care + + module = NULL; + dict = NULL; +} V py::ReloadModule() { @@ -262,7 +247,7 @@ V py::ReloadModule() V py::GetModulePath(const C *mod,C *dir,I len) { #if FLEXT_SYS == FLEXT_SYS_PD - // uarghh... pd doesn't show it's path for extra modules + // uarghh... pd doesn't show its path for extra modules C *name; I fd = open_via_path("",mod,".py",dir,&name,len,0); diff --git a/externals/grill/py/source/main.h b/externals/grill/py/source/main.h index d6ca52cb..2e8419d3 100644 --- a/externals/grill/py/source/main.h +++ b/externals/grill/py/source/main.h @@ -50,6 +50,8 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "main.h" +typedef std::map PyThrMap; + class py: public flext_base { @@ -60,7 +62,7 @@ public: ~py(); static V lib_setup(); - static PyObject *MakePyArgs(const t_symbol *s,const AtomList &args,I inlet = -1,BL withself = false); + static PyObject *MakePyArgs(const t_symbol *s,int argc,const t_atom *argv,I inlet = -1,BL withself = false); static AtomList *GetPyArgs(PyObject *pValue,PyObject **self = NULL); protected: @@ -74,7 +76,6 @@ protected: PyObject *module,*dict; // inherited user class module and associated dictionary - static I pyref; static const C *py_doc; V GetDir(PyObject *obj,AtomList &lst); @@ -83,6 +84,7 @@ protected: V AddToPath(const C *dir); V SetArgs(I argc,const t_atom *argv); V ImportModule(const C *name); + V UnimportModule(); V ReloadModule(); V Register(const C *reg); @@ -124,16 +126,17 @@ protected: V tick(V *); public: - static PyInterpreterState *pystate; #ifdef FLEXT_THREADS - static std::map pythrmap; + static PyInterpreterState *pystate; + static PyThreadState *pythrmain; + static PyThrMap pythrmap; ThrMutex mutex; - V Lock() { mutex.Unlock(); } - V Unlock() { mutex.Unlock(); } + inline V Lock() { mutex.Unlock(); } + inline V Unlock() { mutex.Unlock(); } #else - V Lock() {} - V Unlock() {} + inline V Lock() {} + inline V Unlock() {} #endif static PyObject* StdOut_Write(PyObject* Self, PyObject* Args); @@ -152,11 +155,14 @@ protected: #ifdef FLEXT_THREADS +// if thread is not found in the thread map, the state of the system thread is used +// we have yet to see if this has bad side-effects + #define PY_LOCK \ { \ PyEval_AcquireLock(); \ - PyThreadState *__st = pythrmap[GetThreadId()]; \ - FLEXT_ASSERT(__st != NULL); \ + PyThrMap::iterator it = pythrmap.find(GetThreadId()); \ + PyThreadState *__st = it != pythrmap.end()?it->second:pythrmain; \ PyThreadState *__oldst = PyThreadState_Swap(__st); #define PY_UNLOCK \ diff --git a/externals/grill/py/source/modmeth.cpp b/externals/grill/py/source/modmeth.cpp index f7dae309..b3a98c98 100644 --- a/externals/grill/py/source/modmeth.cpp +++ b/externals/grill/py/source/modmeth.cpp @@ -142,11 +142,15 @@ PyObject *py::py_send(PyObject *,PyObject *args) AtomList *lst = GetPyArgs(val); if(lst) { - if(!Forward(recv,*lst)) + bool ok; + if(lst->Count() && IsSymbol((*lst)[0])) + ok = Forward(recv,GetSymbol((*lst)[0]),lst->Count()-1,lst->Atoms()+1); + else + ok = Forward(recv,*lst); + #ifdef FLEXT_DEBUG + if(!ok) post("py/pyext - Receiver doesn't exist"); -#else - {} #endif } else diff --git a/externals/grill/py/source/py.cpp b/externals/grill/py/source/py.cpp index e7524ce1..8b14a485 100644 --- a/externals/grill/py/source/py.cpp +++ b/externals/grill/py/source/py.cpp @@ -2,7 +2,7 @@ py/pyext - python script object for PD and Max/MSP -Copyright (c) 2002-2004 Thomas Grill (xovo@gmx.net) +Copyright (c)2002-2004 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. @@ -297,7 +297,7 @@ BL pyobj::work(const t_symbol *s,I argc,const t_atom *argv) PY_LOCK if(function) { - PyObject *pArgs = MakePyArgs(s,AtomList(argc,argv)); + PyObject *pArgs = MakePyArgs(s,argc,argv); PyObject *pValue = PyObject_CallObject(function, pArgs); rargs = GetPyArgs(pValue); diff --git a/externals/grill/py/source/pyargs.cpp b/externals/grill/py/source/pyargs.cpp index 8fe68cbd..1b204273 100644 --- a/externals/grill/py/source/pyargs.cpp +++ b/externals/grill/py/source/pyargs.cpp @@ -27,7 +27,7 @@ static PyObject *MakePyAtom(const t_atom &at) return NULL; } -PyObject *py::MakePyArgs(const t_symbol *s,const AtomList &args,I inlet,BL withself) +PyObject *py::MakePyArgs(const t_symbol *s,int argc,const t_atom *argv,I inlet,BL withself) { PyObject *pArgs; @@ -41,7 +41,7 @@ PyObject *py::MakePyArgs(const t_symbol *s,const AtomList &args,I inlet,BL withs */ { BL any = IsAnything(s); - pArgs = PyTuple_New(args.Count()+(any?1:0)+(inlet >= 0?1:0)); + pArgs = PyTuple_New(argc+(any?1:0)+(inlet >= 0?1:0)); I pix = 0; @@ -54,8 +54,8 @@ PyObject *py::MakePyArgs(const t_symbol *s,const AtomList &args,I inlet,BL withs 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(!withself || argc < (any?1:2)) tmp = pArgs,ix = pix; + else tmp = PyTuple_New(argc+(any?1:0)),ix = 0; if(any) { PyObject *pValue = PyString_FromString(GetString(s)); @@ -64,8 +64,8 @@ PyObject *py::MakePyArgs(const t_symbol *s,const AtomList &args,I inlet,BL withs PyTuple_SetItem(tmp, ix++, pValue); } - for(I i = 0; i < args.Count(); ++i) { - PyObject *pValue = MakePyAtom(args[i]); + for(I i = 0; i < argc; ++i) { + PyObject *pValue = MakePyAtom(argv[i]); if(!pValue) { post("py/pyext: cannot convert argument %i",any?i+1:i); continue; diff --git a/externals/grill/py/source/pyext.cpp b/externals/grill/py/source/pyext.cpp index 7dd4d805..66428054 100644 --- a/externals/grill/py/source/pyext.cpp +++ b/externals/grill/py/source/pyext.cpp @@ -34,6 +34,43 @@ V pyext::Setup(t_classid c) FLEXT_CADDMETHOD_(c,0,"set",m_set); FLEXT_CADDATTR_VAR1(c,"respond",respond); + + + // ---------------------------------------------------- + + // 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); + 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); // increases class_obj ref count by 1 + 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 + // after merge so that it's not in class_dict as well... + PyDict_SetItemString(module_dict, PYEXT_CLASS,class_obj); // increases class_obj ref count by 1 + + PyDict_SetItemString(class_dict,"__doc__",PyString_FromString(pyext_doc)); } pyext *pyext::GetThis(PyObject *self) @@ -60,7 +97,6 @@ static short patcher_myvol(t_patcher *x) #endif -I pyext::pyextref = 0; PyObject *pyext::class_obj = NULL; PyObject *pyext::class_dict = NULL; @@ -71,53 +107,14 @@ pyext::pyext(I argc,const t_atom *argv): { int apre = 0; - 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); - } - if(argc >= apre+2 && CanbeInt(argv[apre]) && CanbeInt(argv[apre+1])) { inlets = GetAInt(argv[apre]); outlets = GetAInt(argv[apre+1]); apre += 2; } + PY_LOCK + // init script module if(argc > apre) { char dir[1024]; @@ -151,7 +148,7 @@ pyext::pyext(I argc,const t_atom *argv): ++apre; } - Register("_pyext"); + Register("_pyext"); // t_symbol *sobj = NULL; if(argc > apre) { @@ -168,7 +165,7 @@ pyext::pyext(I argc,const t_atom *argv): if(argc > apre) args(argc-apre,argv+apre); if(methname) { - SetClssMeth(); + MakeInstance(); if(inlets < 0 && outlets < 0) { // now get number of inlets and outlets @@ -222,22 +219,15 @@ pyext::~pyext() PY_LOCK ClearBinding(); - Unregister("_pyext"); + UnimportModule(); - Py_XDECREF(pyobj); - Py_XDECREF(class_obj); - Py_XDECREF(class_dict); - - if(!--pyextref) { - class_obj = NULL; - class_dict = NULL; - } + Py_XDECREF(pyobj); // opposite of SetClssMeth PY_UNLOCK } -BL pyext::SetClssMeth() //I argc,t_atom *argv) +BL pyext::MakeInstance() { // pyobj should already have been decref'd / cleared before getting here!! @@ -250,7 +240,6 @@ BL pyext::SetClssMeth() //I argc,t_atom *argv) // make instance, but don't call __init__ pyobj = PyInstance_NewRaw(pref,NULL); - Py_DECREF(pref); if(pyobj == NULL) PyErr_Print(); else { @@ -260,8 +249,9 @@ BL pyext::SetClssMeth() //I argc,t_atom *argv) // 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 *pargs = MakePyArgs(NULL,args.Count(),args.Atoms(),-1,true); + if (pargs == NULL) + PyErr_Print(); PyObject *init; init = PyObject_GetAttrString(pyobj,"__init__"); // get ref @@ -300,7 +290,7 @@ V pyext::Reload() SetArgs(0,NULL); ReloadModule(); - SetClssMeth(); + MakeInstance(); } @@ -367,7 +357,7 @@ void pyext::m_set(int argc,const t_atom *argv) post("%s - set: Python variable %s not found",thisName(),ch); } else { - PyObject *pval = MakePyArgs(NULL,AtomList(argc-1,argv+1),-1,false); + PyObject *pval = MakePyArgs(NULL,argc-1,argv+1,-1,false); if(!pval) PyErr_Print(); @@ -438,17 +428,13 @@ PyObject *pyext::call(const C *meth,I inlet,const t_symbol *s,I argc,const t_ato PyErr_Clear(); // no method found } else { - PyObject *pargs = MakePyArgs(s,AtomList(argc,argv),inlet?inlet:-1,true); + PyObject *pargs = MakePyArgs(s,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 FLEXT_DEBUG PyErr_Print(); -#else - PyErr_Clear(); -#endif Py_DECREF(pargs); } @@ -470,7 +456,6 @@ V pyext::work_wrapper(V *data) // --- make new Python thread --- // get the global lock PyEval_AcquireLock(); - // get a reference to the PyInterpreterState // create a thread state object for this thread PyThreadState *newthr = PyThreadState_New(pystate); // free the lock diff --git a/externals/grill/py/source/pyext.h b/externals/grill/py/source/pyext.h index 976ef0a6..d05ea7e5 100644 --- a/externals/grill/py/source/pyext.h +++ b/externals/grill/py/source/pyext.h @@ -51,7 +51,7 @@ protected: V ms_args(const AtomList &a) { m_reload_(a.Count(),a.Atoms()); } V m_dir_() { m__dir(pyobj); } V mg_dir_(AtomList &lst) { GetDir(pyobj,lst); } - V m_doc_() { m__doc(pyobj); } + V m_doc_() { m__doc(((PyInstanceObject *)pyobj)->in_class->cl_dict); } virtual V m_help(); V m_get(const t_symbol *s); @@ -66,13 +66,12 @@ private: static pyext *GetThis(PyObject *self); V ClearBinding(); - BL SetClssMeth(); //I argc,t_atom *argv); + BL MakeInstance(); 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; diff --git a/externals/grill/vasp/source/buflib.cpp b/externals/grill/vasp/source/buflib.cpp index 41754a20..a6b3d082 100644 --- a/externals/grill/vasp/source/buflib.cpp +++ b/externals/grill/vasp/source/buflib.cpp @@ -60,7 +60,7 @@ static FreeEntry *freehead = NULL,*freetail = NULL; static I libcnt = 0,libtick = 0; #ifdef FLEXT_THREADS -static flext::ThrMutex libmtx; +static flext::ThrMutex libmtx,freemtx; #endif static V FreeLibSym(const t_symbol *s); @@ -73,7 +73,7 @@ BufEntry::BufEntry(const t_symbol *s,I fr,BL zero): alloc(fr),len(fr), refcnt(0),nxt(NULL) { - data = (S *)NewAligned(fr*sizeof(S)); + data = (S *)NewAligned(len*sizeof(*data)); if(zero) flext::ZeroMem(data,len*sizeof(*data)); } @@ -197,6 +197,11 @@ static V LibTick(V *) static const t_symbol *GetLibSym() { +#ifdef FLEXT_THREADS + freemtx.Lock(); +#endif + const t_symbol *ret; + if(freehead) { // reuse from free-list FreeEntry *r = freehead; @@ -204,7 +209,7 @@ static const t_symbol *GetLibSym() if(!freehead) freetail = NULL; const t_symbol *s = r->sym; delete r; - return s; + ret = s; } else { // allocate new symbol @@ -214,8 +219,13 @@ static const t_symbol *GetLibSym() else // better hash lookup for 4 digits STD::sprintf(tmp,"vasp!%04x",libcnt); libcnt++; - return gensym(tmp); + ret = gensym(tmp); } + +#ifdef FLEXT_THREADS + freemtx.Unlock(); +#endif + return ret; } static V FreeLibSym(const t_symbol *sym) @@ -224,10 +234,18 @@ static V FreeLibSym(const t_symbol *sym) // post("free %s",flext::GetString(sym)); #endif +#ifdef FLEXT_THREADS + freemtx.Lock(); +#endif + FreeEntry *f = new FreeEntry(sym); if(!freehead) freehead = f; else freetail->nxt = f; freetail = f; + +#ifdef FLEXT_THREADS + freemtx.Unlock(); +#endif } diff --git a/externals/grill/vst/src/VstHost.cpp b/externals/grill/vst/src/VstHost.cpp index a5581e38..1d4b6543 100644 --- a/externals/grill/vst/src/VstHost.cpp +++ b/externals/grill/vst/src/VstHost.cpp @@ -344,7 +344,11 @@ void VSTPlugin::process( float **inputs, float **outputs, long sampleframes ) // Host callback dispatcher long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt) { - switch (opcode) { +#if 1 //def FLEXT_DEBUG + post("VST -> host: Eff = 0x%.8X, Opcode = %d, Index = %d, Value = %d, PTR = %.8X, OPT = %.3f\n",(int)effect, opcode,index,value,(int)ptr,opt); +#endif + + switch (opcode) { case audioMasterAutomate: // 0 // index, value given //! \todo set effect parameter @@ -362,10 +366,9 @@ long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, voi return 0; // 0 means connected case audioMasterGetTime: // 7 return 0; // not supported + case audioMasterGetNumAutomatableParameters: // 11 + return 0; // not supported default: -#ifdef FLEXT_DEBUG - post("VST -> host: Eff = 0x%.8X, Opcode = %d, Index = %d, Value = %d, PTR = %.8X, OPT = %.3f\n",(int)effect, opcode,index,value,(int)ptr,opt); -#endif return 0; } } diff --git a/externals/grill/xsample/maxmsp/xsample.help b/externals/grill/xsample/maxmsp/xsample.help index bced9b5c..47fae9fb 100755 Binary files a/externals/grill/xsample/maxmsp/xsample.help and b/externals/grill/xsample/maxmsp/xsample.help differ diff --git a/externals/grill/xsample/pd/xgroove~.pd b/externals/grill/xsample/pd/xgroove~.pd index a12122af..86d879b5 100644 --- a/externals/grill/xsample/pd/xgroove~.pd +++ b/externals/grill/xsample/pd/xgroove~.pd @@ -1,55 +1,14 @@ -#N canvas 312 42 925 590 12; +#N canvas 69 62 929 594 12; #X obj 215 253 hsl 128 15 0.001 3 1 1 empty empty speed 0 -8 0 10 -225271 --1 -1 9500 1; +-1 -1 10800 1; #X floatatom 212 271 8 0 0 0 - - -; #X msg 603 169 loop \$1; #X obj 28 72 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1 -1; #X msg 27 92 stop; #N canvas 0 0 450 300 graph7 0; -#X array \$0-buf 300 float 1; -#A 0 -0.839747 -0.754139 -0.653263 -0.539126 -0.414078 -0.280635 -0.141504 -0.000492073 0.142479 0.281579 0.414975 0.539954 0.654004 0.754786 0.840279 -0.908753 0.958789 0.989418 0.999981 0.990281 0.960531 0.911285 0.843594 -0.758801 0.658626 0.545119 0.420547 0.287463 0.148552 0.00662906 -0.135428 --0.274738 -0.408483 -0.533953 -0.648592 -0.750102 -0.836398 -0.905748 --0.956757 -0.988351 -0.999937 -0.991251 -0.962473 -0.914213 -0.847394 --0.763422 -0.663977 -0.55107 -0.427008 -0.29428 -0.155594 -0.013755 -0.128363 0.267882 0.401968 0.527909 0.643161 0.745362 0.832475 0.902708 -0.954646 0.987258 0.999832 0.992166 0.964387 0.917059 0.851166 0.767999 -0.669283 0.557004 0.43343 0.301082 0.162624 0.0208751 -0.121299 -0.261011 --0.39544 -0.521849 -0.637684 -0.740608 -0.828501 -0.899623 -0.952507 --0.986084 -0.999701 -0.993024 -0.966246 -0.919884 -0.854871 -0.772553 --0.674559 -0.562905 -0.439846 -0.307865 -0.169653 -0.0279992 0.114221 -0.254129 0.38888 0.515759 0.632181 0.73579 0.824504 0.896483 0.950313 -0.984882 0.999483 0.993853 0.968051 0.92265 0.858553 0.777044 0.679806 -0.568776 0.446226 0.314637 0.176665 0.0351171 -0.107144 -0.247232 -0.382316 --0.509641 -0.626648 -0.730953 -0.82044 -0.89332 -0.948068 -0.983621 --0.999242 -0.9946 -0.969825 -0.925372 -0.862179 -0.781519 -0.685006 --0.574627 -0.452593 -0.32139 -0.183677 -0.0422376 0.100056 0.240322 -0.375716 0.503506 0.621075 0.72607 0.816351 0.890079 0.945791 0.982309 -0.998936 0.995323 0.971523 0.928057 0.865764 0.785935 0.690186 0.580434 -0.458934 0.328126 0.19067 0.0493521 -0.0929673 -0.233403 -0.369109 --0.497332 -0.615488 -0.721152 -0.812215 -0.886819 -0.94344 -0.980963 --0.998583 -0.995978 -0.973199 -0.930676 -0.869315 -0.790322 -0.695317 --0.586232 -0.465249 -0.33485 -0.197662 -0.0564676 0.0858711 0.226467 -0.362476 0.49114 0.609846 0.716207 0.808035 0.883498 0.941064 0.979541 -0.99819 0.99659 0.974801 0.933271 0.872803 0.794669 0.70042 0.591977 -0.471549 0.341549 0.204637 0.0635763 -0.0787726 -0.219528 -0.355829 --0.484923 -0.604193 -0.711208 -0.803828 -0.88014 -0.938624 -0.978096 --0.997725 -0.997158 -0.976368 -0.935795 -0.876273 -0.798968 -0.70549 --0.597709 -0.477813 -0.348244 -0.211606 -0.0706864 0.0716672 0.212567 -0.349164 0.478677 0.598495 0.706189 0.799558 0.876742 0.936143 0.976578 -0.997236 0.997659 0.977886 0.938285 0.879669 0.803244 0.710514 0.603402 -0.48406 0.354905 0.218564 0.0777877 -0.0645622 -0.205605 -0.342478 --0.472418 -0.592775 -0.701123 -0.795272 -0.873285 -0.933621 -0.975024 --0.996669 -0.998136 -0.979343 -0.940727 -0.88304 -0.807454 -0.715522 --0.609067 -0.490282 -0.361561 -0.225509 -0.0848913 0.0574491 0.198624 -0.335778 0.466119 0.587025 0.696025 0.790922 0.869805 0.931036 0.97342 -0.996069 0.998529 0.980775 0.943112 0.886359 0.811641 0.720466 0.614708 -0.496475 0.368189 0.232443 0.0919834 -0.0503387 -0.19164 -0.329058 --0.459814 -0.581239 -0.690897; -#X coords 0 1 299 -1 300 150 1; +#X array \$0-buf 10000 float 0; +#X coords 0 1 9999 -1 300 150 1; #X restore 573 269 graph; #X obj 44 529 dac~; #X msg 120 73 reset; @@ -80,18 +39,18 @@ #X restore 573 447 graph; #X obj 53 498 *~; #X obj 89 486 hsl 128 15 0.0001 1 1 0 empty empty volume -2 -6 0 8 --261689 -1 -1 0 1; +-261689 -1 -1 10900 1; #X obj 86 504 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 -10 -261689 -1 -1 0 256; +10 -261689 -1 -1 0.271063 256; #X msg 25 249 pos \$1; #X msg 63 220 200; #X msg 25 221 100; #X obj 511 224 nbx 5 14 0 1e+037 0 1 empty empty frq 0 -6 0 10 -228992 --1 -1 1100 256; -#N canvas 83 212 407 313 loopzone 0; +-1 -1 144 256; +#N canvas 19 334 415 321 loopzone 0; #X msg 28 84 xzone \$1; #X obj 31 43 hsl 128 15 0 300 0 0 empty empty empty -2 -6 0 8 -262131 --1 -1 0 1; +-1 -1 12700 1; #X floatatom 28 64 5 0 0 0 - - -; #X msg 203 207 xfade \$1; #X obj 203 142 vdl 15 0 0 4 empty empty empty 0 -6 0 8 -262144 -1 -1 @@ -130,10 +89,10 @@ #X text 354 75 (pos message and position outlet); #X text 622 148 bidirectional; #X text 244 111 buffer size; -#X obj 574 419 hsl 300 15 0 300 0 0 empty bufpos empty -2 -6 0 8 -262144 --1 -1 0 1; +#X obj 574 419 hsl 300 15 0 10000 0 0 empty bufpos empty -2 -6 0 8 +-262144 -1 -1 20832 1; #X obj 236 527 nbx 5 14 -1e+037 1e+037 0 0 empty empty position 0 -6 -0 10 -228992 -1 -1 0 256; +0 10 -228992 -1 -1 6967.26 256; #N canvas 0 0 470 320 watch 0; #X obj 163 18 loadbang; #X obj 88 80 snapshot~; @@ -153,26 +112,28 @@ #X connect 6 0 1 0; #X restore 235 492 pd watch; #X text 377 111 units in loop; -#N canvas 0 0 842 609 genosc 0; +#N canvas 97 34 266 202 genosc 0; #X obj 38 29 inlet; #X obj 64 94 osc~ 1000; #X obj 38 54 route bang; #X obj 37 134 tabwrite~ \$0-buf; +#X obj 158 94 loadbang; #X connect 0 0 2 0; #X connect 1 0 3 0; #X connect 2 0 3 0; -#X connect 2 1 1 1; +#X connect 2 1 1 0; +#X connect 4 0 3 0; #X restore 491 244 pd genosc; #X text 600 97 loop mode; #X text 23 201 set position; #X obj 299 426 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -262131 -1 -1 0 256; #X obj 356 426 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -262131 --1 -1 300 256; +-1 -1 10000 256; #X obj 298 309 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -225271 --1 -1 78 256; +-1 -1 0 256; #X obj 355 309 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -225271 --1 -1 276 256; +-1 -1 30000 256; #X text 244 95 frames (def.); #X text 377 96 units in buffer (def.); #X text 622 132 forward (def.); diff --git a/externals/grill/xsample/pd/xrecord~.pd b/externals/grill/xsample/pd/xrecord~.pd index 595536b7..f1145fb8 100644 --- a/externals/grill/xsample/pd/xrecord~.pd +++ b/externals/grill/xsample/pd/xrecord~.pd @@ -1,11 +1,7 @@ -#N canvas 58 17 865 647 12; +#N canvas 58 17 869 651 12; #X obj 18 83 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1 -1; #X msg 17 103 stop; -#X floatatom 169 316 5 0 0 0 - - -; -#X floatatom 223 316 5 0 0 0 - - -; -#X floatatom 194 238 5 0 0 0 - - -; -#X floatatom 243 239 5 0 0 0 - - -; #N canvas 0 0 450 300 graph7 0; #X array \$0-buf 10000 float 0; #X coords 0 1 9999 -1 200 140 1; @@ -24,10 +20,6 @@ #X obj 427 332 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1 -1; #X msg 426 352 stop; -#X floatatom 581 542 5 0 0 0 - - -; -#X floatatom 635 542 5 0 0 0 - - -; -#X floatatom 584 484 5 0 0 0 - - -; -#X floatatom 633 485 5 0 0 0 - - -; #X msg 425 391 reset; #X obj 516 575 snapshot~; #X floatatom 516 605 7 0 0 0 - - -; @@ -58,8 +50,6 @@ #X obj 759 92 tgl 15 0 empty empty empty 20 8 0 8 -225271 -1 -1 0 1 ; #X obj 777 88 adc~; -#X text 202 217 min/max position; -#X text 170 335 min/max position; #X text 266 164 looping on/off; #X text 241 133 display refresh; #X text 56 81 start; @@ -73,12 +63,12 @@ #X text 509 242 click to activate auto update; #X text 448 328 start; #X text 466 352 stop; -#X msg 157 238 all; +#X msg 152 239 all; #X msg 504 263 100; -#X obj 537 483 line~; -#X msg 536 458 \$1 20; +#X obj 554 497 line~; +#X msg 554 472 \$1 20; #X msg 13 203 getattributes; -#X obj 224 279 print A; +#X obj 236 281 print A; #X msg 14 231 getbuffer; #X obj 583 116 *~ 1; #X obj 582 93 tgl 15 1 empty empty empty 20 8 0 8 -225271 -1 -1 0 1 @@ -90,67 +80,89 @@ #X text 582 396 by the trigger signal; #X text 581 383 the amount of mixing-in is given; #X obj 95 280 xrecord~ \$0-buf; -#X obj 516 515 xrecord~ \$0-buf; +#X obj 516 529 xrecord~ \$0-buf; #X obj 18 12 cnv 15 800 40 empty empty xrecord~ 10 22 0 24 -260818 -1 0; #X text 224 31 http://www.parasitaere-kapazitaeten.net; #X text 224 12 buffer-based signal recorder \, (C)2001-2004 Thomas Grill; -#X connect 0 0 77 0; -#X connect 1 0 77 0; -#X connect 4 0 77 2; -#X connect 5 0 77 3; -#X connect 7 0 77 0; +#X text 202 253 min/max points; +#X obj 201 241 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -225271 +-1 -1 78 256; +#X obj 258 241 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -225271 +-1 -1 276 256; +#X obj 190 365 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -262131 +-1 -1 0 256; +#X obj 247 365 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -262131 +-1 -1 10000 256; +#X text 192 378 min/max points; +#X obj 224 321 bng 15 250 50 0 empty empty loop_bang 0 -6 0 8 -262131 +-1 -1; +#X text 294 284 print attributes; +#X obj 617 574 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -262131 +-1 -1 0 256; +#X obj 674 574 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -262131 +-1 -1 10000 256; +#X obj 618 500 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -225271 +-1 -1 78 256; +#X obj 675 500 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -225271 +-1 -1 276 256; +#X connect 0 0 67 0; +#X connect 1 0 67 0; +#X connect 3 0 67 0; +#X connect 4 0 5 0; +#X connect 6 0 30 0; +#X connect 7 0 67 0; #X connect 8 0 9 0; -#X connect 10 0 38 0; -#X connect 11 0 77 0; -#X connect 12 0 13 0; -#X connect 13 0 77 0; -#X connect 14 0 16 0; -#X connect 15 0 16 0; -#X connect 16 0 77 0; -#X connect 17 0 78 0; -#X connect 18 0 78 0; -#X connect 21 0 78 2; -#X connect 22 0 78 3; -#X connect 23 0 78 0; -#X connect 24 0 25 0; -#X connect 26 0 37 0; -#X connect 27 0 28 0; -#X connect 28 0 78 0; -#X connect 29 0 30 0; -#X connect 30 0 78 0; -#X connect 31 0 32 0; -#X connect 32 0 78 0; -#X connect 33 0 78 0; -#X connect 34 0 36 0; -#X connect 34 0 66 0; -#X connect 35 0 78 0; -#X connect 37 0 24 0; -#X connect 38 0 8 0; -#X connect 39 0 43 0; -#X connect 40 0 77 0; -#X connect 41 0 78 0; -#X connect 43 0 42 0; -#X connect 44 0 43 1; -#X connect 45 0 42 0; -#X connect 46 0 45 1; -#X connect 47 0 45 0; -#X connect 47 1 45 0; -#X connect 63 0 77 0; -#X connect 64 0 30 0; -#X connect 65 0 78 1; -#X connect 66 0 65 0; -#X connect 67 0 77 0; -#X connect 69 0 77 0; -#X connect 70 0 42 0; -#X connect 71 0 70 1; -#X connect 72 0 70 0; -#X connect 73 0 35 0; -#X connect 77 0 8 0; -#X connect 77 1 2 0; -#X connect 77 2 3 0; -#X connect 77 4 68 0; -#X connect 78 0 24 0; -#X connect 78 1 19 0; -#X connect 78 2 20 0; +#X connect 9 0 67 0; +#X connect 10 0 12 0; +#X connect 11 0 12 0; +#X connect 12 0 67 0; +#X connect 13 0 68 0; +#X connect 14 0 68 0; +#X connect 15 0 68 0; +#X connect 16 0 17 0; +#X connect 18 0 29 0; +#X connect 19 0 20 0; +#X connect 20 0 68 0; +#X connect 21 0 22 0; +#X connect 22 0 68 0; +#X connect 23 0 24 0; +#X connect 24 0 68 0; +#X connect 25 0 68 0; +#X connect 26 0 28 0; +#X connect 26 0 56 0; +#X connect 27 0 68 0; +#X connect 29 0 16 0; +#X connect 30 0 4 0; +#X connect 31 0 35 0; +#X connect 32 0 67 0; +#X connect 33 0 68 0; +#X connect 35 0 34 0; +#X connect 36 0 35 1; +#X connect 37 0 34 0; +#X connect 38 0 37 1; +#X connect 39 0 37 0; +#X connect 39 1 37 0; +#X connect 53 0 67 0; +#X connect 54 0 22 0; +#X connect 55 0 68 1; +#X connect 56 0 55 0; +#X connect 57 0 67 0; +#X connect 59 0 67 0; +#X connect 60 0 34 0; +#X connect 61 0 60 1; +#X connect 62 0 60 0; +#X connect 63 0 27 0; +#X connect 67 0 4 0; +#X connect 67 1 75 0; +#X connect 67 2 76 0; +#X connect 67 3 78 0; +#X connect 67 4 58 0; +#X connect 68 0 16 0; +#X connect 68 1 80 0; +#X connect 68 2 81 0; +#X connect 73 0 67 2; +#X connect 74 0 67 3; +#X connect 82 0 68 2; +#X connect 83 0 68 3; diff --git a/externals/grill/xsample/readme.txt b/externals/grill/xsample/readme.txt index 20aa53df..b8bb2893 100644 --- a/externals/grill/xsample/readme.txt +++ b/externals/grill/xsample/readme.txt @@ -115,6 +115,13 @@ Goals/features of the package: Version history: +0.3.1: +- added mixmode=2 to Max/MSP help files +- fixed limit consideration for loopmode=0 and 2. +- fixed buggy sampling in crossfade zones (and simplified it a lot) +- different initialization on buffer absence +- renew units and scalemode on buffer change + 0.3.0: - added resources to MaxMSP build - xgroove~, xrecord~: introduced a loop/end bang outlet diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp index f96b33bb..a3f2ed02 100644 --- a/externals/grill/xsample/source/groove.cpp +++ b/externals/grill/xsample/source/groove.cpp @@ -17,7 +17,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #endif -#define XZONE_TABLE 64 +#define XZONE_TABLE 512 class xgroove: @@ -300,7 +300,7 @@ V xgroove::m_max(F mx) V xgroove::m_pos(F pos) { - setpos(pos?pos/s2u:0); + setpos(pos && s2u?pos/s2u:0); } V xgroove::m_all() @@ -329,7 +329,7 @@ V xgroove::ms_xfade(I xf) V xgroove::ms_xzone(F xz) { bufchk(); - _xzone = xz < 0?0:xz/s2u; + _xzone = xz < 0 || !s2u?0:xz/s2u; // do_xzone(); s_dsp(); } @@ -642,6 +642,11 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) // adapt the playing bounds to the current cross-fade zone const L smin = znsmin,smax = znsmax,plen = smax-smin; + // temporary storage + const L cmin = curmin,cmax = curmax; + // hack -> set curmin/curmax to loop extremes so that sampling functions (playfun) don't get confused + curmin = smin,curmax = smax; + if(buf && plen > 0) { BL inzn = false; register D o = curpos; @@ -661,17 +666,24 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) lpbang = true; } +#if 1 if(o < lmin) { register F inp; if(o < lmin2) { + // in first half of early cross-fade zone + // this happens only once, then the offset is normalized to the end + // of the loop (before mid of late crossfade) + o += lsh; - lpbang = true; // now lmax <= o <= lmax2 + lpbang = true; inp = xz-(F)(o-lmax); // 0 <= inp < xz znpos[i] = lmin-inp; } - else { // in early cross-fade zone + else { + // in second half of early cross-fade zone + inp = xz+(F)(o-lmin); // 0 <= inp < xz znpos[i] = lmax+inp; } @@ -681,14 +693,18 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) else if(!(o < lmax)) { register F inp; if(!(o < lmax2)) { + // in second half of late cross-fade zone + // this happens only once, then the offset is normalized to the beginning + // of the loop (after mid of early crossfade) o -= lsh; - lpbang = true; // now lmin2 <= o <= lmin + lpbang = true; inp = xz+(F)(o-lmin); // 0 <= inp < xz znpos[i] = lmax+inp; } - else { // in late cross-fade zone + else { + // in first half of late cross-fade zone inp = xz-(F)(o-lmax); // 0 <= inp < xz znpos[i] = lmin-inp; } @@ -701,6 +717,27 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) const S spd = speed[i]; // must be first because the vector is reused for output! pos[i] = o; o += spd; +#else + if(o >= lmax) { + o -= lsh; + lpbang = true; + } + + if(o < lmin) { + register F inp = (F)(o-smin); // 0 <= inp < xz + znpos[i] = lmax+inp; + znidx[i] = inp*xf; + inzn = true; + } + else { + znpos[i] = 0; + znidx[i] = XZONE_TABLE; + } + + const S spd = speed[i]; // must be first because the vector is reused for output! + pos[i] = o; + o += spd; +#endif } // normalize and store current playing position @@ -736,6 +773,8 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) else s_pos_off(n,invecs,outvecs); + curmin = cmin,curmax = cmax; + if(lpbang) ToOutBang(outchns+3); } @@ -787,12 +826,14 @@ V xgroove::s_pos_bidir(I n,S *const *invecs,S *const *outvecs) V xgroove::s_dsp() { if(doplay) { + // xzone might not be set yet (is done in do_xzone() ) + do_xzone(); // recalculate (s2u may have been 0 before) + switch(loopmode) { - case xsl_once: SETSIGFUN(posfun,SIGFUN(s_pos_once)); break; + case xsl_once: + SETSIGFUN(posfun,SIGFUN(s_pos_once)); + break; case xsl_loop: - // xzone might not be set yet (is done in do_xzone() ) - do_xzone(); // recalculate (s2u may have been 0 before) - if(xzone > 0) { const I blksz = Blocksize(); @@ -823,7 +864,9 @@ V xgroove::s_dsp() else SETSIGFUN(posfun,SIGFUN(s_pos_loop)); break; - case xsl_bidir: SETSIGFUN(posfun,SIGFUN(s_pos_bidir)); break; + case xsl_bidir: + SETSIGFUN(posfun,SIGFUN(s_pos_bidir)); + break; } } else diff --git a/externals/grill/xsample/source/main.cpp b/externals/grill/xsample/source/main.cpp index 258fb37a..3cec1b66 100644 --- a/externals/grill/xsample/source/main.cpp +++ b/externals/grill/xsample/source/main.cpp @@ -60,7 +60,7 @@ xsample::xsample(): unitmode(xsu_sample), // PD defaults to samples #endif sclmode(xss_unitsinbuf), - curmin(0),curmax(1<<30) + curmin(0),curmax(1<<31) {} xsample::~xsample() @@ -98,6 +98,8 @@ BL xsample::m_refresh() if(buf->Set()) { s_dsp(); ret = true; } // channel count may have changed else ret = false; + m_units(); + m_sclmode(); // realize positions... 2 times bufchk()!! m_min((F)curmin*s2u); // also checks pos m_max((F)curmax*s2u); // also checks pos @@ -129,70 +131,72 @@ V xsample::m_units(xs_unit mode) { if(mode != xsu__) unitmode = mode; - if(bufchk()) - 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()); - } + switch(unitmode) { + case xsu_sample: // samples + s2u = 1; + break; + case xsu_buffer: // buffer size + s2u = bufchk()?1.f/buf->Frames():0; + 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) { if(mode != xss__) sclmode = mode; - if(bufchk()) - 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 = curmin != curmax?1.f/(curmax-curmin):0; - break; - default: - post("%s: Unknown scale mode",thisName()); - } + 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 = (bufchk() && buf->Frames())?1.f/buf->Frames():0; + break; + case 3: // unity between recmin and recmax + sclmin = curmin; sclmul = curmin != curmax?1.f/(curmax-curmin):0; + break; + default: + post("%s: Unknown scale mode",thisName()); + } } V xsample::m_min(F mn) { - if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed) +// if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed) - mn /= s2u; // conversion to samples - if(mn < 0) mn = 0; - else if(mn > curmax) mn = (F)curmax; - curmin = (I)(mn+.5); + if(s2u) { + mn /= s2u; // conversion to samples + if(mn < 0) mn = 0; + else if(mn > curmax) mn = (F)curmax; + curmin = (I)(mn+.5); - m_sclmode(); + m_sclmode(); + } } V xsample::m_max(F mx) { - if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed) +// if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed) - mx /= s2u; // conversion to samples - if(mx > buf->Frames()) mx = (F)buf->Frames(); - else if(mx < curmin) mx = (F)curmin; - curmax = (I)(mx+.5); + if(s2u) { + mx /= s2u; // conversion to samples + if(mx > buf->Frames()) mx = (F)buf->Frames(); + else if(mx < curmin) mx = (F)curmin; + curmax = (I)(mx+.5); - m_sclmode(); + m_sclmode(); + } } V xsample::m_all() diff --git a/externals/grill/xsample/source/main.h b/externals/grill/xsample/source/main.h index daa99b5d..c6511139 100644 --- a/externals/grill/xsample/source/main.h +++ b/externals/grill/xsample/source/main.h @@ -12,7 +12,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define __XSAMPLE_H -#define XSAMPLE_VERSION "0.3.0" +#define XSAMPLE_VERSION "0.3.1pre3" #define FLEXT_ATTRIBUTES 1 diff --git a/externals/grill/xsample/xsample.cw b/externals/grill/xsample/xsample.cw index 78e49d4e..a74428fd 100755 Binary files a/externals/grill/xsample/xsample.cw and b/externals/grill/xsample/xsample.cw differ -- cgit v1.2.1