diff options
Diffstat (limited to 'externals/grill')
46 files changed, 1239 insertions, 182 deletions
diff --git a/externals/grill/flext/flext.cw b/externals/grill/flext/flext.cw Binary files differindex 488b8fc2..3bb70947 100644 --- a/externals/grill/flext/flext.cw +++ b/externals/grill/flext/flext.cw diff --git a/externals/grill/flext/readme.txt b/externals/grill/flext/readme.txt index 1f6f8fee..a3828937 100644 --- a/externals/grill/flext/readme.txt +++ b/externals/grill/flext/readme.txt @@ -101,7 +101,11 @@ Version history: 0.4.1: - full port for Max@OSX -- completely redesigned message and attribute handling: now hashed and a much more efficient +- completely redesigned message and attribute handling: now hashed and much more efficient +- added some prerequisites for usage of flext as a shared library +- completed Max/MSPs inlet/outlet assist description functionality +- Max/MSP signal objects: fixed bug of reporting wrong number of inlets +- put overloaded new/delete into flext support class - introduced "Finalize" virtual method, called after all "Init" methods - fixed crash issue in flext_dsp when there are NO signal inlets or outlets defined (this is possibly only a problem for the signal2 tutorial example) @@ -124,6 +128,7 @@ Version history: - implemented threading support with the MacOS MP thread library - stripped the ThrMutex and ThrCond classes of non-portable (and irrelevant) functionality - simplified "ToQueue*" and threaded "ToOut*" message queue mechanism for Max/MSP +- deprecated FLEXT_ADDMETHOD_V and FLEXT_ADDMETHOD_A definitions which only lead to confusion 0.4.0: - the use of the const keyword is enforced (e.g. the preferred type for symbols is now "const t_symbol *") @@ -289,6 +294,7 @@ general: - add log messages for debugging version - feed assist function with in/outlet description - MaxMSP: how to call separate help files for objects in a library? +- use PD's t_float type for floating point values (and what about t_int?) bugs: - PD: problems with timed buffer redrawing (takes a lot of cpu time) @@ -300,7 +306,9 @@ tests: - PD: figure out what "pointer" messages do and where they occur - some more mutexes needed for thread safety? - buffer resize: flext_base::buffer::Frames(): should we use buffer or system sample rate? + - what about FLEXT_ADDMETHOD_V (for var arg lists) and FLEXT_ADDMETHOD_A (anythings)... nonsense? + -> yes, these definitions obscure the meaning of _ as an indication for usage of a message tag features: - abstraction for clock functions diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp index 5612ab33..c6e88fe5 100644 --- a/externals/grill/flext/source/flattr.cpp +++ b/externals/grill/flext/source/flattr.cpp @@ -21,9 +21,9 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define STD #endif -flext_base::attritem::attritem(const t_symbol *t,metharg tp,methfun f,bool g): +flext_base::attritem::attritem(const t_symbol *t,metharg tp,methfun f,int fl): item(t,0,NULL),argtp(tp), - fun(f),isget(g) + fun(f),flags(fl) { } @@ -57,7 +57,7 @@ void flext_base::AddAttrib(itemarr *aa,itemarr *ma,const char *attr,metharg tp,m // if(sfun) // if commented out, there will be a warning at run-time (more user-friendly) { - attritem *a = new attritem(asym,tp,sfun,false); + attritem *a = new attritem(asym,tp,sfun,attritem::afl_bothexist|attritem::afl_set); aa->Add(a); // bind attribute to a method @@ -68,7 +68,7 @@ void flext_base::AddAttrib(itemarr *aa,itemarr *ma,const char *attr,metharg tp,m // if(gfun) // if commented out, there will be a warning at run-time (more user-friendly) { - attritem *a = new attritem(asym,tp,gfun,true); + attritem *a = new attritem(asym,tp,gfun,attritem::afl_bothexist|attritem::afl_get); aa->Add(a); static char tmp[256] = "get"; @@ -124,17 +124,22 @@ bool flext_base::ListAttrib() int ccnt = clattrhead?clattrhead->Count():0; AtomList la(ccnt+cnt); - for(int i = 0,ix = 0; i <= 1; ++i) { + int ix = 0; + for(int i = 0; i <= 1; ++i) { itemarr *a = i?attrhead:clattrhead; if(a) { for(int ai = 0; ai < a->Size(); ++ai) { for(item *l = a->Item(ai); l; l = l->nxt) - SetSymbol(la[ix++],l->tag); + { + attritem *a = (attritem *)l; + if(!a->BothExist() || a->IsGet()) + SetSymbol(la[ix++],a->tag); + } } } } - ToOutAnything(outattr,MakeSymbol("attributes"),la.Count(),la.Atoms()); + ToOutAnything(outattr,MakeSymbol("attributes"),ix,la.Atoms()); return true; } else @@ -145,10 +150,10 @@ bool flext_base::SetAttrib(const t_symbol *tag,int argc,const t_atom *argv) { // search for matching attribute attritem *a = (attritem *)attrhead->Find(tag); - while(a && (a->tag != tag || a->inlet != 0 || a->isget)) a = (attritem *)a->nxt; + while(a && (a->tag != tag || a->inlet != 0 || a->IsGet())) a = (attritem *)a->nxt; if(!a) { a = (attritem *)clattrhead->Find(tag); - while(a && (a->tag != tag || a->inlet != 0 || a->isget)) a = (attritem *)a->nxt; + while(a && (a->tag != tag || a->inlet != 0 || a->IsGet())) a = (attritem *)a->nxt; } if(a) diff --git a/externals/grill/flext/source/flbase.cpp b/externals/grill/flext/source/flbase.cpp index 3b43c1fe..9840bfc2 100644 --- a/externals/grill/flext/source/flbase.cpp +++ b/externals/grill/flext/source/flbase.cpp @@ -31,6 +31,8 @@ int flext_obj::m_holdaargc = 0; const t_atom *flext_obj::m_holdaargv = NULL; bool flext_obj::process_attributes = false; +void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; } + ///////////////////////////////////////////////////////// // Constructor // @@ -79,46 +81,6 @@ void flext_obj::DefineHelp(t_class *c,const char *ref,const char *dir,bool addti } -///////////////////////////////////////////////////////// -// overloaded new/delete memory allocation methods -// -///////////////////////////////////////////////////////// - -void *flext_obj::operator new(size_t bytes) -{ - bytes += sizeof(size_t); - char *blk = (char *)getbytes(bytes); - *(size_t *)blk = bytes; - return blk+sizeof(size_t); -} - -void flext_obj::operator delete(void *blk) -{ - char *ori = (char *)blk-sizeof(size_t); - size_t bytes = *(size_t *)ori; - freebytes(ori,bytes); -} - -void *flext_obj::NewAligned(size_t bytes,int bitalign) -{ - const size_t ovh = sizeof(size_t)+sizeof(char *); - const unsigned long alignovh = bitalign/8-1; - bytes += ovh+alignovh; - char *blk = (char *)getbytes(bytes); - char *ablk = reinterpret_cast<char *>((reinterpret_cast<unsigned long>(blk)+ovh+alignovh) & ~alignovh); - *(char **)(ablk-sizeof(size_t)-sizeof(char *)) = blk; - *(size_t *)(ablk-sizeof(size_t)) = bytes; - return ablk; -} - -void flext_obj::FreeAligned(void *blk) -{ - char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *)); - size_t bytes = *(size_t *)((char *)blk-sizeof(size_t)); - freebytes(ori,bytes); -} - - diff --git a/externals/grill/flext/source/flbase.h b/externals/grill/flext/source/flbase.h index 96a89d30..8b8577ea 100644 --- a/externals/grill/flext/source/flbase.h +++ b/externals/grill/flext/source/flbase.h @@ -20,7 +20,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flstdc.h" #include "flsupport.h" -class FLEXT_EXT flext_obj; +class FLEXT_SHARE flext_obj; // ---------------------------------------------------------------------------- /*! \brief The obligatory PD or Max/MSP object header @@ -32,7 +32,7 @@ class FLEXT_EXT flext_obj; */ // ---------------------------------------------------------------------------- -struct FLEXT_EXT flext_hdr +struct FLEXT_SHARE flext_hdr { /*! \defgroup FLEXT_OBJHEADER Actual PD or Max/MSP object \internal @@ -85,7 +85,7 @@ struct FLEXT_EXT flext_hdr */ // ---------------------------------------------------------------------------- -class FLEXT_EXT flext_obj: +class FLEXT_SHARE flext_obj: public flext { public: @@ -113,7 +113,7 @@ class FLEXT_EXT flext_obj: /*! \brief Enable/disable attribute procession (default = false) \note Use that in the static class setup function (also library setup function) */ - static void ProcessAttributes(bool attr) { process_attributes = attr; } + static void ProcessAttributes(bool attr); //{ process_attributes = attr; } //! Virtual function called at creation time (but after the constructor) // this also guarantees that there are no instances of flext_obj @@ -134,7 +134,7 @@ class FLEXT_EXT flext_obj: */ //! Get the object's canvas - t_canvas *thisCanvas() { return(m_canvas); } + t_canvas *thisCanvas() { return m_canvas; } //! Get the PD or Max/MSP object t_sigobj *thisHdr() { return &x_obj->obj; } @@ -155,31 +155,6 @@ class FLEXT_EXT flext_obj: //! @} FLEXT_O_INFO -// --- memory ------------------------------------------------------- - - /*! \defgroup FLEXT_O_MEMORY Memory allocation functions - @{ - */ - - /*! Overloaded new memory allocation method - \warning Max/MSP (or MacOS) allows only 16K in overdrive mode! - */ - void *operator new(size_t bytes); - //! Overloaded delete method - void operator delete(void *blk); - - #ifndef __MRC__ // doesn't allow new[] overloading?! - void *operator new[](size_t bytes) { return operator new(bytes); } - void operator delete[](void *blk) { operator delete(blk); } - #endif - - //! Get an aligned memory block - static void *NewAligned(size_t bytes,int bitalign = 128); - //! Free an aligned memory block - static void FreeAligned(void *blk); - - //! @} FLEXT_O_MEMORY - // --- help ------------------------------------------------------- /*! \defgroup FLEXT_O_HELP Help/assistance functionality diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h index b0376ed3..208a37fd 100644 --- a/externals/grill/flext/source/flclass.h +++ b/externals/grill/flext/source/flclass.h @@ -40,7 +40,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. */ -class FLEXT_EXT flext_base: +class FLEXT_SHARE flext_base: public flext_obj { FLEXT_HEADER_S(flext_base,flext_obj,Setup) @@ -307,7 +307,7 @@ public: typedef bool (*methfun)(flext_base *c); - /*! \defgroup FLEXT_C_ADDMETHOD Method handling + /*! \defgroup FLEXT_C_ADDMETHOD Method handling (object scope) \internal @{ */ @@ -342,6 +342,16 @@ public: void AddMethod(int inlet,const char *tag,bool (*m)(flext_base *,float &)) { AddMethod(ThMeths(),inlet,tag,(methfun)m,a_float,a_null); } // method+float void AddMethod(int inlet,const char *tag,bool (*m)(flext_base *,int &)) { AddMethod(ThMeths(),inlet,tag,(methfun)m,a_int,a_null); } // method+int + //! Set Max/MSP style of distributing list elements over (message) inlets + void SetDist(bool d = true) { distmsgs = d; } + +//! @} FLEXT_C_ADDMETHOD + + /*! \defgroup FLEXT_C_CADDMETHOD Method handling (class scope) + \internal + @{ + */ + static void AddMethod(t_class *c,int inlet,bool (*m)(flext_base *,int,t_atom *)) { AddMethod(ClMeths(c),inlet,"list",(methfun)m,a_list,a_null); } static void AddMethod(t_class *c,int inlet,bool (*m)(flext_base *,int,const t_atom *)) { AddMethod(ClMeths(c),inlet,"list",(methfun)m,a_list,a_null); } static void AddMethod(t_class *c,int inlet,const char *tag,bool (*m)(flext_base *)) { AddMethod(ClMeths(c),inlet,tag,(methfun)m,a_null); } // pure method @@ -370,11 +380,7 @@ public: static void AddMethod(t_class *c,int inlet,const char *tag,bool (*m)(flext_base *,float &)) { AddMethod(ClMeths(c),inlet,tag,(methfun)m,a_float,a_null); } // method+float static void AddMethod(t_class *c,int inlet,const char *tag,bool (*m)(flext_base *,int &)) { AddMethod(ClMeths(c),inlet,tag,(methfun)m,a_int,a_null); } // method+int - - //! Set Max/MSP style of distributing list elements over (message) inlets - void SetDist(bool d = true) { distmsgs = d; } - -//! @} FLEXT_C_ADDMETHOD +//! @} FLEXT_C_CADDMETHOD // --- bind/unbind --------------------------------------- @@ -461,7 +467,7 @@ protected: xlet *nxt; }; - /*! \defgroup FLEXT_C_ATTR Attribute handling methods + /*! \defgroup FLEXT_C_ATTR Attribute handling methods (object scope) @{ */ @@ -472,6 +478,12 @@ protected: void AddAttrib(const char *attr,bool (*get)(flext_base *,AtomList *&),bool (*set)(flext_base *,AtomList *&)) { AddAttrib(attr,a_LIST,(methfun)get,(methfun)set); } void AddAttrib(const char *attr,bool (*get)(flext_base *,AtomAnything *&),bool (*set)(flext_base *,AtomAnything *&)) { AddAttrib(attr,a_ANY,(methfun)get,(methfun)set); } +//! @} FLEXT_C_ATTR + + /*! \defgroup FLEXT_C_CATTR Attribute handling methods (class scope) + @{ + */ + static void AddAttrib(t_class *c,const char *attr,bool (*get)(flext_base *,float &),bool (*set)(flext_base *,float &)) { AddAttrib(c,attr,a_float,(methfun)get,(methfun)set); } static void AddAttrib(t_class *c,const char *attr,bool (*get)(flext_base *,int &),bool (*set)(flext_base *,int &)) { AddAttrib(c,attr,a_int,(methfun)get,(methfun)set); } static void AddAttrib(t_class *c,const char *attr,bool (*get)(flext_base *,const t_symbol *&),bool (*set)(flext_base *,const t_symbol *&)) { AddAttrib(c,attr,a_symbol,(methfun)get,(methfun)set); } @@ -479,7 +491,7 @@ protected: static void AddAttrib(t_class *c,const char *attr,bool (*get)(flext_base *,AtomList *&),bool (*set)(flext_base *,AtomList *&)) { AddAttrib(c,attr,a_LIST,(methfun)get,(methfun)set); } static void AddAttrib(t_class *c,const char *attr,bool (*get)(flext_base *,AtomAnything *&),bool (*set)(flext_base *,AtomAnything *&)) { AddAttrib(c,attr,a_ANY,(methfun)get,(methfun)set); } -//! @} FLEXT_C_ATTR +//! @} FLEXT_C_CATTR /*! \addtogroup FLEXT_C_INOUT @{ @@ -570,10 +582,19 @@ protected: class attritem: public item { public: - attritem(const t_symbol *tag,metharg tp,methfun fun,bool get); + attritem(const t_symbol *tag,metharg tp,methfun fun,int flags); ~attritem(); - bool isget; + enum { + afl_getset = 0x01, afl_get = 0x00, afl_set = 0x01, + afl_bothexist = 0x02 + }; + + bool IsGet() const { return (flags&afl_getset) == afl_get; } + bool IsSet() const { return (flags&afl_getset) == afl_set; } + bool BothExist() const { return (flags&afl_bothexist) != 0; } + + int flags; metharg argtp; methfun fun; }; @@ -719,6 +740,8 @@ private: static void cb_loadbang(t_class *c); #if FLEXT_SYS == FLEXT_SYS_MAX + char **indesc,**outdesc; + static void cb_assist(t_class *c,void *b,long msg,long arg,char *s); #endif }; diff --git a/externals/grill/flext/source/fldefs.h b/externals/grill/flext/source/fldefs.h index 49f44366..66c56123 100644 --- a/externals/grill/flext/source/fldefs.h +++ b/externals/grill/flext/source/fldefs.h @@ -671,20 +671,10 @@ FLEXT_THREAD_1(M_FUN,t_symptr) \ AddMethod(CL,IX,"bang",FLEXT_CALL_PRE(M_FUN)) -//! Add a handler for a method with no arguments +//! 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)) -//! Add a handler for a method with a (variable argument) list -#define FLEXT_CADDMETHOD_V(CL,IX,M_FUN) \ -\ -AddMethod(CL,IX,FLEXT_CALL_PRE(M_FUN)) - -//! Add a handler for a method with an anything argument -#define FLEXT_CADDMETHOD_A(CL,IX,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) \ \ @@ -777,21 +767,29 @@ SetDist(true) \ AddMethod(IX,"bang",FLEXT_CALL_PRE(M_FUN)) -//! Add a handler for a method with no arguments +//! 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)) -//! Add a handler for a method with a (variable argument) list +#if 0 +// FLEXT_ADDMETHOD_V and FLEXT_ADDMETHOD_A definitions obscure that _ indicates the usage of a message tag + +/*! \brief Add a handler for a method with a (variable argument) list + \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)) -//! Add a handler for a method with an anything argument +/*! \brief Add a handler for a method with an anything argument + \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)) +#endif -//! Add a a handler for a method with implicit arguments +//! 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)) diff --git a/externals/grill/flext/source/fldsp.h b/externals/grill/flext/source/fldsp.h index 4926d873..6299544a 100644 --- a/externals/grill/flext/source/fldsp.h +++ b/externals/grill/flext/source/fldsp.h @@ -24,7 +24,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. /*! \brief Flext dsp enabled base object */ -class FLEXT_EXT flext_dsp: +class FLEXT_SHARE flext_dsp: public flext_base { FLEXT_HEADER_S(flext_dsp,flext_base,Setup) @@ -105,11 +105,21 @@ public: */ void AddInSignal(int m = 1) { AddInlet(xlet::tp_sig,m); } + /*! \brief Add signal inlet (with description) + \param desc Description of inlet + */ + void AddInSignal(const char *desc) { AddInlet(xlet::tp_sig,1,desc); } + /*! \brief Add signal outlet(s) \param m Number of inlets to add */ void AddOutSignal(int m = 1) { AddOutlet(xlet::tp_sig,m); } + /*! \brief Add signal outlet (with description) + \param desc Description of outlet + */ + void AddOutSignal(const char *desc) { AddOutlet(xlet::tp_sig,1,desc); } + //! @} //! @} diff --git a/externals/grill/flext/source/flext.cpp b/externals/grill/flext/source/flext.cpp index 5ffaaae4..08e4cdd1 100644 --- a/externals/grill/flext/source/flext.cpp +++ b/externals/grill/flext/source/flext.cpp @@ -14,7 +14,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flext.h" #include "flinternal.h" - +#include <string.h> // === flext_base ============================================ @@ -30,6 +30,9 @@ flext_base::flext_base(): methhead(new itemarr),attrhead(new itemarr), //attrcnt(0), clmethhead(ClMeths(thisClass())),clattrhead(ClAttrs(thisClass())), inlets(NULL) +#if FLEXT_SYS == FLEXT_SYS_MAX + ,indesc(NULL),outdesc(NULL) +#endif { LOG1("%s - flext logging is on",thisName()); @@ -71,6 +74,15 @@ flext_base::~flext_base() } #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(insigs) dsp_free(thisHdr()); if(insigs) dsp_freebox(thisHdr()); #endif @@ -81,7 +93,7 @@ flext_base::~flext_base() 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 - \mote All inlet, outlets, method and attribute declarations must be made before a call to Init! + \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. */ @@ -135,9 +147,6 @@ void flext_base::Setup(t_class *c) void flext_base::cb_help(t_class *c) { thisObject(c)->m_help(); } void flext_base::cb_loadbang(t_class *c) { thisObject(c)->m_loadbang(); } -#if FLEXT_SYS == FLEXT_SYS_MAX -void flext_base::cb_assist(t_class *c,void * /*b*/,long msg,long arg,char *s) { thisObject(c)->m_assist(msg,arg,s); } -#endif void flext_base::m_help() { @@ -147,6 +156,20 @@ void flext_base::m_help() void flext_base::m_loadbang() {} -void flext_base::m_assist(long /*msg*/,long /*arg*/,char * /*s*/) {} - +#if FLEXT_SYS == FLEXT_SYS_MAX +void flext_base::cb_assist(t_class *c,void * /*b*/,long msg,long arg,char *s) { thisObject(c)->m_assist(msg,arg,s); } +#endif +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: + strcpy(s,arg < outcnt && outdesc[arg]?outdesc[arg]:""); + break; + } +#endif +} diff --git a/externals/grill/flext/source/flmsg.cpp b/externals/grill/flext/source/flmsg.cpp index a1c049d2..57f21d03 100755 --- a/externals/grill/flext/source/flmsg.cpp +++ b/externals/grill/flext/source/flmsg.cpp @@ -81,7 +81,7 @@ bool flext_base::TryMethTag(const methitem *m,int inlet,const t_symbol *t,int ar if(m->attr) { // attributes are treated differently - if(m->attr->isget) + if(m->attr->IsGet()) return GetAttrib(m->attr); else return SetAttrib(m->attr,argc,argv); diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp index e8341e9e..2ad12597 100644 --- a/externals/grill/flext/source/flout.cpp +++ b/externals/grill/flext/source/flout.cpp @@ -14,7 +14,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flext.h" #include "flinternal.h" - +#include <string.h> #ifndef FLEXT_THREADS void flext_base::ToOutBang(outlet *o) const { CRITON(); outlet_bang((t_outlet *)o); CRITOFF(); } @@ -50,6 +50,22 @@ bool flext_base::InitInlets() 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; inlets = new px_object *[incnt]; @@ -174,7 +190,7 @@ bool flext_base::InitInlets() } } - incnt = cnt; +// incnt = cnt; if(insigs) // dsp_setup(thisHdr(),insigs); // signal inlets @@ -216,6 +232,22 @@ bool flext_base::InitOutlets() 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; outlets = new outlet *[outcnt]; @@ -256,7 +288,7 @@ bool flext_base::InitOutlets() #endif } } - + delete[] list; } diff --git a/externals/grill/flext/source/flsndobj.h b/externals/grill/flext/source/flsndobj.h index c56ba07b..fde0d177 100644 --- a/externals/grill/flext/source/flsndobj.h +++ b/externals/grill/flext/source/flsndobj.h @@ -18,7 +18,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #undef NOPTHREAD -class flext_sndobj: +class FLEXT_SHARE flext_sndobj: public flext_dsp { FLEXT_HEADER(flext_sndobj,flext_dsp) diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h index adf28b0d..44252c3f 100644 --- a/externals/grill/flext/source/flstdc.h +++ b/externals/grill/flext/source/flstdc.h @@ -162,8 +162,14 @@ typedef void t_binbuf; /* Set the right calling convention (and exporting) for the OS */ #ifdef _MSC_VER + #ifdef FLEXT_SHARED + #define FLEXT_SHARE __declspec(dllexport) + #else + #define FLEXT_SHARE + #endif #define FLEXT_EXT __declspec(dllexport) #else // other OS's + #define FLEXT_SHARE #define FLEXT_EXT #endif diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp index cd57dfd8..827896e3 100644 --- a/externals/grill/flext/source/flsupport.cpp +++ b/externals/grill/flext/source/flsupport.cpp @@ -48,6 +48,48 @@ void flext::Setup() #endif } + +///////////////////////////////////////////////////////// +// overloaded new/delete memory allocation methods +// +///////////////////////////////////////////////////////// + +void *flext::operator new(size_t bytes) +{ + bytes += sizeof(size_t); + char *blk = (char *)getbytes(bytes); + *(size_t *)blk = bytes; + return blk+sizeof(size_t); +} + +void flext::operator delete(void *blk) +{ + char *ori = (char *)blk-sizeof(size_t); + size_t bytes = *(size_t *)ori; + freebytes(ori,bytes); +} + +void *flext::NewAligned(size_t bytes,int bitalign) +{ + const size_t ovh = sizeof(size_t)+sizeof(char *); + const unsigned long alignovh = bitalign/8-1; + bytes += ovh+alignovh; + char *blk = (char *)getbytes(bytes); + char *ablk = reinterpret_cast<char *>((reinterpret_cast<unsigned long>(blk)+ovh+alignovh) & ~alignovh); + *(char **)(ablk-sizeof(size_t)-sizeof(char *)) = blk; + *(size_t *)(ablk-sizeof(size_t)) = bytes; + return ablk; +} + +void flext::FreeAligned(void *blk) +{ + char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *)); + size_t bytes = *(size_t *)((char *)blk-sizeof(size_t)); + freebytes(ori,bytes); +} + +// ------------------------------------------ + void flext::GetAString(const t_atom &a,char *buf,int szbuf) { #if FLEXT_SYS == FLEXT_SYS_PD diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index 6eef5bd5..470b73ca 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -17,14 +17,47 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flstdc.h" -class FLEXT_EXT flext_base; - -class FLEXT_EXT flext { +class FLEXT_SHARE flext_base; + +/*! \brief Flext support class + A number of methods (most are static functions) are defined here for convenience. + This class doesn't define any data members, hence it can be inherited to all + classes (not only PD objects) to profit from the cross-platform functionality. + Examples are the overloaded memory allocation, atom and atom list functions, + thread functions and classes, the sample buffer class and others. +*/ +class FLEXT_SHARE flext { /*! \defgroup FLEXT_SUPPORT Flext support class @{ */ public: + +// --- memory ------------------------------------------------------- + + /*! \defgroup FLEXT_S_MEMORY Memory allocation functions + @{ + */ + + /*! Overloaded new memory allocation method + \warning Max/MSP (or MacOS) allows only 16K in overdrive mode! + */ + void *operator new(size_t bytes); + //! Overloaded delete method + void operator delete(void *blk); + + #ifndef __MRC__ // doesn't allow new[] overloading?! + void *operator new[](size_t bytes) { return operator new(bytes); } + void operator delete[](void *blk) { operator delete(blk); } + #endif + + //! Get an aligned memory block + static void *NewAligned(size_t bytes,int bitalign = 128); + //! Free an aligned memory block + static void FreeAligned(void *blk); + + //! @} FLEXT_S_MEMORY + // --- buffer/array stuff ----------------------------------------- /*! \defgroup FLEXT_S_BUFFER Buffer handling @@ -32,7 +65,7 @@ public: */ //! Class for platform independent buffer handling - class buffer + class FLEXT_SHARE buffer { public: /*! \brief Construct buffer. @@ -122,7 +155,7 @@ public: //! Zero a memory region static void ZeroMem(void *dst,int bytes); //! Sleep for an amount of time - static void Sleep(float s); + static void Sleep(double s); //! @} FLEXT_S_UTIL @@ -277,7 +310,7 @@ public: // --- atom list stuff ------------------------------------------- //! Class representing a list of atoms - class AtomList + class FLEXT_SHARE AtomList { public: //! Construct list @@ -337,7 +370,7 @@ public: //! Class representing an "anything" - class AtomAnything: + class FLEXT_SHARE AtomAnything: public AtomList { public: @@ -551,7 +584,7 @@ public: /*! \brief Thread mutex \sa pthreads documentation */ - class FLEXT_EXT ThrMutex + class FLEXT_SHARE ThrMutex #if FLEXT_THREADS == FLEXT_THR_POSIX { public: @@ -605,7 +638,7 @@ public: /*! \brief Thread conditional \sa pthreads documentation */ - class FLEXT_EXT ThrCond + class FLEXT_SHARE ThrCond #if FLEXT_THREADS == FLEXT_THR_POSIX :public ThrMutex { diff --git a/externals/grill/flext/source/flutil.cpp b/externals/grill/flext/source/flutil.cpp index 2a65aaf6..ea11b458 100644 --- a/externals/grill/flext/source/flutil.cpp +++ b/externals/grill/flext/source/flutil.cpp @@ -34,13 +34,14 @@ void flext::ZeroMem(void *dst,int bytes) memset(dst,0,bytes); } -void flext::Sleep(float s) +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 || defined(__GNUC__) - usleep((long)(s*1000000)); + usleep((long)(s*1000000.)); #elif FLEXT_OS == FLEXT_OS_MACOS + // that's just for OS9! 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; diff --git a/externals/grill/flext/source/flxlet.cpp b/externals/grill/flext/source/flxlet.cpp index 2804bae3..e47a92e3 100755 --- a/externals/grill/flext/source/flxlet.cpp +++ b/externals/grill/flext/source/flxlet.cpp @@ -23,8 +23,9 @@ flext_base::xlet::xlet(type t,const char *d): { if(d) { int ln = strlen(d); - desc = new char[ln]; - strncpy(desc,d,ln); + desc = new char[ln+1]; + memcpy(desc,d,ln); + desc[ln] = 0; } else desc = NULL; } @@ -45,9 +46,18 @@ void flext_base::AddXlet(xlet::type tp,int mult,const char *desc,xlet *&root) } } -void flext_base::DescXlet(int ix,const char *desc,xlet *&root) +void flext_base::DescXlet(int ix,const char *d,xlet *&root) { - post("%s - sorry, not implemented",thisName()); + 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,...) diff --git a/externals/grill/flext/tutorial/adv2/adv2.cw b/externals/grill/flext/tutorial/adv2/adv2.cw Binary files differnew file mode 100755 index 00000000..a0a68e0f --- /dev/null +++ b/externals/grill/flext/tutorial/adv2/adv2.cw diff --git a/externals/grill/flext/tutorial/adv2/adv2.dsp b/externals/grill/flext/tutorial/adv2/adv2.dsp new file mode 100644 index 00000000..7c36c7c5 --- /dev/null +++ b/externals/grill/flext/tutorial/adv2/adv2.dsp @@ -0,0 +1,95 @@ +# Microsoft Developer Studio Project File - Name="adv2" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=adv2 - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "adv2.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "adv2.mak" CFG="adv2 - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "adv2 - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "adv2 - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "adv2" +# PROP Scc_LocalPath "." +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "adv2 - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "msvc" +# PROP Intermediate_Dir "msvc" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c +# ADD CPP /nologo /W3 /O2 /I "..\..\source" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib /nologo /dll /machine:I386 /out:"../pd-msvc/adv2.dll" /libpath:"..\..\pd-msvc" + +!ELSEIF "$(CFG)" == "adv2 - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "msvc-debug" +# PROP Intermediate_Dir "msvc-debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /ZI /Od /I "..\..\source" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "_DEBUG" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib pd.lib flext_d-pdwin.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\pd-msvc" + +!ENDIF + +# Begin Target + +# Name "adv2 - Win32 Release" +# Name "adv2 - Win32 Debug" +# Begin Source File + +SOURCE=.\main.cpp +# End Source File +# End Target +# End Project diff --git a/externals/grill/flext/tutorial/adv2/main.cpp b/externals/grill/flext/tutorial/adv2/main.cpp new file mode 100644 index 00000000..32adaf85 --- /dev/null +++ b/externals/grill/flext/tutorial/adv2/main.cpp @@ -0,0 +1,97 @@ +/* +flext tutorial - advanced 2 + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +------------------------------------------------------------------------- + +This is an optimized version of the example "simple 3" + +It has the exact same functionality but methods are registered at class setup opposed to +object setup (in the constructor) in "simple 3" + +The advantage of this lies in the fact that the message database needs only be constructed +once for all objects, namely on creation of the first object of this class. +All objects [adv2] will share the same database, saving memory. + +*/ + +// include flext header +#include <flext.h> + +// check for appropriate flext version +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error You need at least flext version 0.4.1 +#endif + +class adv2: + public flext_base +{ + // flext header with a setup function called "setup" + FLEXT_HEADER_S(adv2,flext_base,setup) + +public: + adv2(); + +protected: + void m_tag(); + void m_tag_and_int(int i); + void m_sym(t_symbol *s); + + virtual void m_help(); + +private: + // define the _static_ class setup function + static void setup(t_class *c); + + FLEXT_CALLBACK(m_tag); + FLEXT_CALLBACK_I(m_tag_and_int); + FLEXT_CALLBACK_S(m_sym); +}; + +// instantiate the class (constructor has a variable argument list) +FLEXT_NEW("adv2",adv2) + + +adv2::adv2() +{ + // define inlets + AddInAnything(); // add inlet of type anything (index 0) +} + +void adv2::setup(t_class *c) +{ + // register methods: + // notice the naming FLEXT_CADD_METHOD* instead of FLEXT_ADD_METHOD* + // there is also an additional parameter c pointing to the class definition + FLEXT_CADDMETHOD_(c,0,"born",m_tag); + FLEXT_CADDMETHOD_(c,0,"to",m_tag); + FLEXT_CADDMETHOD_(c,0,"hula",m_tag); + FLEXT_CADDMETHOD_I(c,0,"hula",m_tag_and_int); + + FLEXT_CADDMETHOD(c,0,m_sym); +} + +void adv2::m_tag() +{ + post("tag recognized"); +} + +void adv2::m_tag_and_int(int i) +{ + post("tag recognized (has int arg: %i)",i); +} + +void adv2::m_sym(t_symbol *s) +{ + post("symbol: %s",GetString(s)); +} + +void adv2::m_help() +{ + post("%s - example for tagged messages",thisName()); +} + + diff --git a/externals/grill/flext/tutorial/adv3/adv3.cw b/externals/grill/flext/tutorial/adv3/adv3.cw Binary files differnew file mode 100755 index 00000000..dd30edd4 --- /dev/null +++ b/externals/grill/flext/tutorial/adv3/adv3.cw diff --git a/externals/grill/flext/tutorial/adv3/adv3.dsp b/externals/grill/flext/tutorial/adv3/adv3.dsp new file mode 100644 index 00000000..87f026af --- /dev/null +++ b/externals/grill/flext/tutorial/adv3/adv3.dsp @@ -0,0 +1,95 @@ +# Microsoft Developer Studio Project File - Name="adv3" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=adv3 - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "adv3.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "adv3.mak" CFG="adv3 - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "adv3 - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "adv3 - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "adv3" +# PROP Scc_LocalPath "." +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "adv3 - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "msvc" +# PROP Intermediate_Dir "msvc" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c +# ADD CPP /nologo /W3 /O2 /I "..\..\source" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib /nologo /dll /machine:I386 /out:"../pd-msvc/adv3.dll" /libpath:"..\..\pd-msvc" + +!ELSEIF "$(CFG)" == "adv3 - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "msvc-debug" +# PROP Intermediate_Dir "msvc-debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /ZI /Od /I "..\..\source" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "_DEBUG" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib pd.lib flext_d-pdwin.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\pd-msvc" + +!ENDIF + +# Begin Target + +# Name "adv3 - Win32 Release" +# Name "adv3 - Win32 Debug" +# Begin Source File + +SOURCE=.\main.cpp +# End Source File +# End Target +# End Project diff --git a/externals/grill/flext/tutorial/adv3/main.cpp b/externals/grill/flext/tutorial/adv3/main.cpp new file mode 100644 index 00000000..0306e68f --- /dev/null +++ b/externals/grill/flext/tutorial/adv3/main.cpp @@ -0,0 +1,152 @@ +/* +flext tutorial - advanced 3 + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +------------------------------------------------------------------------- + +This is a port of Iohannes Zmölnigs "counter" example to the flext paradigm. +Find the original at http://iem.kug.ac.at/pd/externals-HOWTO/node5.html + +The functionality is exactly the same, with one exception: +flext doesn't support default arguments, hence a message "bound 1" will translate into +"bound 1 0" in the original example, but won't be recognized with flext. +This can be easily circumvented by using a method digesting a variable argument list, but +was omitted for the sake of clearness. + +Apart from that you'll notice several differences: +- with flext, callbacks have to be declared for all registered methods +- Flext allows the full usage of integer types +- there are no real "passive" methods with flext. + These can be emulated by methods, or more flexibly, attributes (see example "attr3") +- Help symbols can't be defined that freely. This is because in Max/MSP help files always + have the name of the object with a suffix .help appended. + However with flext, a path to the respective help file may be specified + +*/ + +// include flext header +#include <flext.h> + +// check for appropriate flext version +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error You need at least flext version 0.4.1 +#endif + +class adv3: + public flext_base +{ + FLEXT_HEADER_S(adv3,flext_base,setup) + +public: + // constructor with no arguments + adv3(int argc,t_atom *argv): + i_step(1) + { + // --- initialize bounds and step size --- + int f1 = 0,f2 = 0; + switch(argc) { + default: + case 3: + i_step = GetInt(argv[2]); + case 2: + f2 = GetInt(argv[1]); + case 1: + f1 = GetInt(argv[0]); + case 0: + ; + } + if(argc < 2) f2 = f1; + + m_bound(f1,f2); + + i_count = i_down; + + // --- define inlets and outlets --- + AddInAnything(); // default inlet + AddInList(); // inlet for bounds + AddInInt(); // inlet for step size + + AddOutInt(); // outlet for integer count + AddOutBang(); // outlet for bang + } + +protected: + void m_reset() + { + i_count = i_down; + } + + void m_set(int argc,t_atom *argv) + { + i_count = argc?GetAInt(argv[0]):0; + } + + void m_bang() + { + int f = i_count; + i_count += i_step; + if(i_down != i_up) { + if((i_step > 0) && (i_count > i_up)) { + i_count = i_down; + ToOutBang(1); + } + else if(i_count < i_down) { + i_count = i_up; + ToOutBang(1); + } + } + ToOutInt(0,f); + } + + void m_bound(int f1,int f2) + { + i_down = f1 < f2?f1:f2; + i_up = f1 > f2?f1:f2; + } + + void m_step(int s) + { + i_step = s; + } + + int i_count,i_down,i_up,i_step; + +private: + static void setup(t_class *c) + { + // --- set up methods (class scope) --- + + // register a bang method to the default inlet (0) + FLEXT_CADDBANG(c,0,m_bang); + + // set up tagged methods for the default inlet (0) + // the underscore _ after CADDMETHOD indicates that a message tag is used + // no, variable list or anything and all single arguments are recognized automatically, ... + FLEXT_CADDMETHOD_(c,0,"reset",m_reset); + FLEXT_CADDMETHOD_(c,0,"set",m_set); + // ..., more complex types (combinations of types) have to be specified + FLEXT_CADDMETHOD_II(c,0,"bound",m_bound); // two int arguments + + // set up methods for inlets 1 and 2 + // no message tag used + FLEXT_CADDMETHOD(c,1,m_bound); // variable arg type recognized automatically + FLEXT_CADDMETHOD(c,2,m_step); // single int arg also recognized automatically + } + + // for every registered method a callback has to be declared + FLEXT_CALLBACK(m_bang) + FLEXT_CALLBACK(m_reset) + FLEXT_CALLBACK_V(m_set) + FLEXT_CALLBACK_II(m_bound) + FLEXT_CALLBACK_I(m_step) +}; + +// instantiate the class (constructor has a variable argument list) +// let "counter" be an alternative name +// before the colon define the name of the path to the help file +FLEXT_NEW_V("help, adv3 counter",adv3) + + diff --git a/externals/grill/flext/tutorial/attr1/main.cpp b/externals/grill/flext/tutorial/attr1/main.cpp index 4945fe8f..2659a9ac 100644 --- a/externals/grill/flext/tutorial/attr1/main.cpp +++ b/externals/grill/flext/tutorial/attr1/main.cpp @@ -44,10 +44,10 @@ protected: private: // callback for method "m_trigger" (with one float argument) - FLEXT_CALLBACK_F(m_trigger); + FLEXT_CALLBACK_F(m_trigger) // define attribute callbacks for variable "arg" (with GET and SET properties) - FLEXT_ATTRVAR_F(arg); + FLEXT_ATTRVAR_F(arg) }; // instantiate the class diff --git a/externals/grill/flext/tutorial/attr2/main.cpp b/externals/grill/flext/tutorial/attr2/main.cpp index b1536117..d6df4e78 100644 --- a/externals/grill/flext/tutorial/attr2/main.cpp +++ b/externals/grill/flext/tutorial/attr2/main.cpp @@ -7,7 +7,11 @@ WARRANTIES, see the file, "license.txt," in this distribution. ------------------------------------------------------------------------- -This is an example of an object doing various float operations +This is an example of an object doing various float operations. + +Methods and attributes are registered at class level (opposed to object level in example "attr1"). +For details, see also example "adv2" + */ @@ -58,26 +62,27 @@ private: static void setup(t_class *); // callback for method "m_trigger" (with one float argument) - FLEXT_CALLBACK_F(m_trigger); + FLEXT_CALLBACK_F(m_trigger) // define attribute callbacks for variable "arg" ("ATTRVAR" means GET and SET) - FLEXT_ATTRVAR_F(arg); + FLEXT_ATTRVAR_F(arg) // define attribute callbacks for variable "res" (GET only) - FLEXT_ATTRGET_F(res); + FLEXT_ATTRGET_F(res) // methods for getting/setting the operation mode void opget(const t_symbol *&s) const; void opset(const t_symbol *&s); // define attribute callbacks for variable "res" (GET only) - FLEXT_CALLGET_S(opget); - FLEXT_CALLSET_S(opset); + FLEXT_CALLGET_S(opget) + FLEXT_CALLSET_S(opset) }; // instantiate the class FLEXT_NEW("attr2",attr2) + // instantiate static variables const t_symbol *attr2::sym_set, @@ -85,7 +90,7 @@ const t_symbol *attr2::sym_div,*attr2::sym_mul, *attr2::sym_pow; -void attr2::setup(t_class *) +void attr2::setup(t_class *c) { // Upon class creation setup some symbols // This is done only upon creation of of the first "attr2" object @@ -95,6 +100,21 @@ void attr2::setup(t_class *) sym_mul = MakeSymbol("*"); sym_div = MakeSymbol("/"); sym_pow = MakeSymbol("**"); + + + // setup methods and attributes at class scope + + // register method (for floats) "m_trigger" for inlet 0 + FLEXT_CADDMETHOD(c,0,m_trigger); + + // register attribute "arg" with the variable "arg" + FLEXT_CADDATTR_VAR1(c,"arg",arg); + + // register attribute "result" with variable "res" + FLEXT_CADDATTR_GET(c,"result",res); + + // register attribute "op" with methods "opget" and "opset" + FLEXT_CADDATTR_VAR(c,"op",opget,opset); } @@ -107,18 +127,6 @@ attr2::attr2(): // define outlets AddOutFloat(); // one float outlet (has index 0) - - // register method (for floats) "m_trigger" for inlet 0 - FLEXT_ADDMETHOD(0,m_trigger); - - // register attribute "arg" with the variable "arg" - FLEXT_ADDATTR_VAR1("arg",arg); - - // register attribute "result" with variable "res" - FLEXT_ADDATTR_GET("result",res); - - // register attribute "op" with methods "opget" and "opset" - FLEXT_ADDATTR_VAR("op",opget,opset); } // receive an operand, do the math operation and trigger the output diff --git a/externals/grill/flext/tutorial/attr3/attr3.cw b/externals/grill/flext/tutorial/attr3/attr3.cw Binary files differnew file mode 100755 index 00000000..fb08c819 --- /dev/null +++ b/externals/grill/flext/tutorial/attr3/attr3.cw diff --git a/externals/grill/flext/tutorial/attr3/attr3.dsp b/externals/grill/flext/tutorial/attr3/attr3.dsp new file mode 100644 index 00000000..6d22106d --- /dev/null +++ b/externals/grill/flext/tutorial/attr3/attr3.dsp @@ -0,0 +1,95 @@ +# Microsoft Developer Studio Project File - Name="attr3" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=attr3 - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "attr3.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "attr3.mak" CFG="attr3 - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "attr3 - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "attr3 - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "attr3" +# PROP Scc_LocalPath "." +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "attr3 - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "msvc" +# PROP Intermediate_Dir "msvc" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c +# ADD CPP /nologo /W3 /O2 /I "..\..\source" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib /nologo /dll /machine:I386 /out:"../pd-msvc/attr3.dll" /libpath:"..\..\pd-msvc" + +!ELSEIF "$(CFG)" == "attr3 - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "msvc-debug" +# PROP Intermediate_Dir "msvc-debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /ZI /Od /I "..\..\source" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "_DEBUG" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib pd.lib flext_d-pdwin.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\pd-msvc" + +!ENDIF + +# Begin Target + +# Name "attr3 - Win32 Release" +# Name "attr3 - Win32 Debug" +# Begin Source File + +SOURCE=.\main.cpp +# End Source File +# End Target +# End Project diff --git a/externals/grill/flext/tutorial/attr3/main.cpp b/externals/grill/flext/tutorial/attr3/main.cpp new file mode 100644 index 00000000..835c2881 --- /dev/null +++ b/externals/grill/flext/tutorial/attr3/main.cpp @@ -0,0 +1,163 @@ +/* +flext tutorial - attributes 3 + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +------------------------------------------------------------------------- + +This is tutorial example "advanced 3" with the usage of attributes. + +*/ + +// IMPORTANT: enable attribute processing (specify before inclusion of flext headers!) +// For clarity, this is done here, but you'd better specify it as a compiler definition +// FLEXT_ATTRIBUTES must be 0 or 1, +#define FLEXT_ATTRIBUTES 1 + +// include flext header +#include <flext.h> + +// check for appropriate flext version +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error You need at least flext version 0.4.1 +#endif + +class attr3: + public flext_base +{ + FLEXT_HEADER_S(attr3,flext_base,setup) + +public: + // constructor with no arguments + attr3(int argc,t_atom *argv): + i_step(1) + { + // --- initialize bounds and step size --- + int f1 = 0,f2 = 0; + switch(argc) { + default: + case 3: + i_step = GetInt(argv[2]); + case 2: + f2 = GetInt(argv[1]); + case 1: + f1 = GetInt(argv[0]); + case 0: + ; + } + if(argc < 2) f2 = f1; + + m_bound(f1,f2); + + i_count = i_down; + + // --- define inlets and outlets --- + AddInAnything(); // default inlet + AddInList(); // inlet for bounds + AddInInt(); // inlet for step size + + AddOutInt(); // outlet for integer count + AddOutBang(); // outlet for bang + } + +protected: + + void m_reset() { i_count = i_down; } + + void m_set(int argc,t_atom *argv) + { + i_count = argc?GetAInt(argv[0]):0; + } + + void m_bang() + { + int f = i_count; + i_count += i_step; + if(i_down != i_up) { + if((i_step > 0) && (i_count > i_up)) { + i_count = i_down; + ToOutBang(1); + } + else if(i_count < i_down) { + i_count = i_up; + ToOutBang(1); + } + } + ToOutInt(0,f); + } + + void m_bound(int f1,int f2) + { + i_down = f1 < f2?f1:f2; + i_up = f1 > f2?f1:f2; + } + + void m_step(int s) { i_step = s; } + + int i_count,i_down,i_up,i_step; + + // setter method of bounds variables + void ms_bound(const AtomList &l) + { + if(l.Count() == 2 && CanbeInt(l[0]) && CanbeInt(l[1])) + // if it is a two element integer list use m_bound method + m_bound(GetAInt(l[0]),GetAInt(l[1])); + else + // else post a warning + post("%s - bound needs to integer parameters",thisName()); + } + + // getter method of bounds variables + void mg_bound(AtomList &l) const + { + l(2); // initialize two element list + SetInt(l[0],i_down); // set first element + SetInt(l[1],i_up); // set second element + } + +private: + + static void setup(t_class *c) + { + // --- set up methods (class scope) --- + + // register a bang method to the default inlet (0) + FLEXT_CADDBANG(c,0,m_bang); + + // set up tagged methods for the default inlet (0) + FLEXT_CADDMETHOD_(c,0,"reset",m_reset); + FLEXT_CADDMETHOD_(c,0,"set",m_set); + + // set up methods for inlets 1 and 2 + // no message tag used + FLEXT_CADDMETHOD(c,1,m_bound); // variable arg type recognized automatically + FLEXT_CADDMETHOD(c,2,m_step); // single int arg also recognized automatically + + // --- set up attributes (class scope) --- + + FLEXT_CADDATTR_VAR1(c,"count",i_count); + FLEXT_CADDATTR_VAR1(c,"step",i_step); + + FLEXT_CADDATTR_VAR(c,"bound",mg_bound,ms_bound); + } + + // normal method callbacks for bang and reset + FLEXT_CALLBACK(m_bang) + FLEXT_CALLBACK(m_reset) + + FLEXT_CALLBACK_V(m_set) // normal method wrapper for m_set + FLEXT_ATTRVAR_I(i_count) // wrapper function for integer variable i_count + + FLEXT_CALLBACK_II(m_bound) // normal method wrapper for m_bound + FLEXT_CALLVAR_V(mg_bound,ms_bound) // getter and setter method of bounds + + FLEXT_CALLBACK_I(m_step) // normal method wrapper for m_step + FLEXT_ATTRVAR_I(i_step) // wrapper function for integer variable i_step +}; + +// instantiate the class (constructor has a variable argument list) +FLEXT_NEW_V("attr3",attr3) + + diff --git a/externals/grill/flext/tutorial/build-pd-bcc.bat b/externals/grill/flext/tutorial/build-pd-bcc.bat index 90ed411b..45961f13 100644 --- a/externals/grill/flext/tutorial/build-pd-bcc.bat +++ b/externals/grill/flext/tutorial/build-pd-bcc.bat @@ -16,6 +16,14 @@ @make -f ..\makefile.pd-bcc NAME=adv1 SETUPFUNCTION=adv1_setup @cd .. +@cd adv2 +@make -f ..\makefile.pd-bcc NAME=adv2 SETUPFUNCTION=adv2_setup +@cd .. + +@cd adv3 +@make -f ..\makefile.pd-bcc NAME=adv3 SETUPFUNCTION=adv3_setup +@cd .. + @cd attr1 @make -f ..\makefile.pd-bcc NAME=attr1 SETUPFUNCTION=attr1_setup @cd .. @@ -24,6 +32,10 @@ @make -f ..\makefile.pd-bcc NAME=attr2 SETUPFUNCTION=attr2_setup @cd .. +@cd attr3 +@make -f ..\makefile.pd-bcc NAME=attr3 SETUPFUNCTION=attr3_setup +@cd .. + @cd signal1 @make -f ..\makefile.pd-bcc NAME=signal1~ SETUPFUNCTION=signal1_tilde_setup @cd .. diff --git a/externals/grill/flext/tutorial/build-pd-msvc.bat b/externals/grill/flext/tutorial/build-pd-msvc.bat index 2c63951b..a01bee53 100644 --- a/externals/grill/flext/tutorial/build-pd-msvc.bat +++ b/externals/grill/flext/tutorial/build-pd-msvc.bat @@ -4,8 +4,11 @@ nmake /f makefile.pd-msvc NAME=simple1 DIR=simple1 nmake /f makefile.pd-msvc NAME=simple2 DIR=simple2 nmake /f makefile.pd-msvc NAME=simple3 DIR=simple3 nmake /f makefile.pd-msvc NAME=adv1 DIR=adv1 +nmake /f makefile.pd-msvc NAME=adv2 DIR=adv2 +nmake /f makefile.pd-msvc NAME=adv3 DIR=adv3 nmake /f makefile.pd-msvc NAME=attr1 DIR=attr1 nmake /f makefile.pd-msvc NAME=attr2 DIR=attr2 +nmake /f makefile.pd-msvc NAME=attr3 DIR=attr3 nmake /f makefile.pd-msvc NAME=signal1~ DIR=signal1 nmake /f makefile.pd-msvc NAME=signal2~ DIR=signal2 nmake /f makefile.pd-msvc NAME=sndobj1~ DIR=sndobj1 diff --git a/externals/grill/flext/tutorial/lib1/main.cpp b/externals/grill/flext/tutorial/lib1/main.cpp index 485bdf09..1f0a3120 100644 --- a/externals/grill/flext/tutorial/lib1/main.cpp +++ b/externals/grill/flext/tutorial/lib1/main.cpp @@ -49,8 +49,8 @@ protected: float arg; // argument variable private: - FLEXT_CALLBACK_F(m_trigger); // callback for method "m_trigger" (with one float argument) - FLEXT_ATTRVAR_F(arg); + FLEXT_CALLBACK_F(m_trigger) // callback for method "m_trigger" (with one float argument) + FLEXT_ATTRVAR_F(arg) }; libbase::libbase(): diff --git a/externals/grill/flext/tutorial/makefile.pd-cygwin b/externals/grill/flext/tutorial/makefile.pd-cygwin index fae2014d..6568273a 100644 --- a/externals/grill/flext/tutorial/makefile.pd-cygwin +++ b/externals/grill/flext/tutorial/makefile.pd-cygwin @@ -26,7 +26,7 @@ LIBS=m pd # all the source files from the package -EXAMPLES=simple1 simple2 simple3 adv1 attr1 attr2 signal1~ signal2~ sndobj1~ lib1 # thread1 thread2 +EXAMPLES=simple1 simple2 simple3 adv1 adv2 adv3 attr1 attr2 attr3 signal1~ signal2~ sndobj1~ lib1 # thread1 thread2 TARGETS=$(patsubst %,$(OUTPATH)/%.dll,$(EXAMPLES)) diff --git a/externals/grill/flext/tutorial/makefile.pd-darwin b/externals/grill/flext/tutorial/makefile.pd-darwin index 20f4a298..8a2ae255 100644 --- a/externals/grill/flext/tutorial/makefile.pd-darwin +++ b/externals/grill/flext/tutorial/makefile.pd-darwin @@ -24,7 +24,7 @@ LDFLAGS=-bundle -bundle_loader $(PD) # all the source files from the package -EXAMPLES=simple1 simple2 simple3 adv1 attr1 attr2 signal1~ signal2~ sndobj1~ lib1 thread1 thread2 +EXAMPLES=simple1 simple2 simple3 adv1 adv2 adv3 attr1 attr2 attr3 signal1~ signal2~ sndobj1~ lib1 thread1 thread2 TARGETS=$(patsubst %,$(OUTPATH)/%.pd_darwin,$(EXAMPLES)) diff --git a/externals/grill/flext/tutorial/makefile.pd-linux b/externals/grill/flext/tutorial/makefile.pd-linux index 6bbb4a06..58fee63d 100644 --- a/externals/grill/flext/tutorial/makefile.pd-linux +++ b/externals/grill/flext/tutorial/makefile.pd-linux @@ -24,7 +24,7 @@ LIBS=m # all the source files from the package -EXAMPLES=simple1 simple2 simple3 adv1 attr1 attr2 sndobj1~ signal1~ signal2~ lib1 thread1 thread2 +EXAMPLES=simple1 simple2 simple3 adv1 adv2 adv3 attr1 attr2 attr3 sndobj1~ signal1~ signal2~ lib1 thread1 thread2 TARGETS=$(patsubst %,$(OUTPATH)/%.pd_linux,$(EXAMPLES)) diff --git a/externals/grill/flext/tutorial/pd/ex-adv2.pd b/externals/grill/flext/tutorial/pd/ex-adv2.pd new file mode 100644 index 00000000..af534de2 --- /dev/null +++ b/externals/grill/flext/tutorial/pd/ex-adv2.pd @@ -0,0 +1,23 @@ +#N canvas 329 97 587 348 12;
+#X msg 26 97 help;
+#X msg 123 146 born;
+#X msg 172 147 to;
+#X msg 214 149 hula;
+#X msg 228 230 yeah;
+#X msg 228 192 hula 1;
+#X text 280 231 other symbol;
+#X text 261 150 tag without argument;
+#X text 297 190 tag and argument;
+#X text 72 97 print a help message;
+#X obj 16 7 cnv 15 550 40 empty empty adv2 10 22 0 24 -260818 -1 0
+;
+#X text 174 8 flext tutorial \, (C)2002 Thomas Grill;
+#X text 174 28 http://www.parasitaere-kapazitaeten.net;
+#X obj 148 293 adv2;
+#X text 21 49 this is identical to the simple3 example;
+#X connect 0 0 13 0;
+#X connect 1 0 13 0;
+#X connect 2 0 13 0;
+#X connect 3 0 13 0;
+#X connect 4 0 13 0;
+#X connect 5 0 13 0;
diff --git a/externals/grill/flext/tutorial/pd/ex-adv3.pd b/externals/grill/flext/tutorial/pd/ex-adv3.pd new file mode 100644 index 00000000..d58567f3 --- /dev/null +++ b/externals/grill/flext/tutorial/pd/ex-adv3.pd @@ -0,0 +1,40 @@ +#N canvas 175 139 597 355 12;
+#X obj 16 7 cnv 15 550 40 empty empty adv3 10 22 0 24 -260818 -1 0
+;
+#X text 174 8 flext tutorial \, (C)2002 Thomas Grill;
+#X text 174 28 http://www.parasitaere-kapazitaeten.net;
+#X obj 229 266 adv3 2 5 1;
+#X obj 305 303 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 223 300 nbx 5 18 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+12 -228992 -1 -1 0 256;
+#X msg 269 120 1 10;
+#X msg 389 118 1;
+#X msg 424 118 -1;
+#X msg 460 118 2;
+#X obj 88 119 bng 25 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X msg 313 119 7 2;
+#X text 325 300 end has been reached;
+#X obj 157 117 nbx 5 18 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+12 -228992 -1 -1 0 256;
+#X msg 158 140 set \$1;
+#X text 72 98 trigger;
+#X text 147 98 set counter;
+#X text 264 99 set bounds;
+#X text 390 96 set step size;
+#X msg 80 186 reset;
+#X text 83 166 reset;
+#X text 21 49 this is a port of IOhannes Zmoelnings "counter" example
+;
+#X connect 3 0 5 0;
+#X connect 3 1 4 0;
+#X connect 6 0 3 1;
+#X connect 7 0 3 2;
+#X connect 8 0 3 2;
+#X connect 9 0 3 2;
+#X connect 10 0 3 0;
+#X connect 11 0 3 1;
+#X connect 13 0 14 0;
+#X connect 14 0 3 0;
+#X connect 19 0 3 0;
diff --git a/externals/grill/flext/tutorial/pd/ex-attr3.pd b/externals/grill/flext/tutorial/pd/ex-attr3.pd new file mode 100644 index 00000000..de7d6bf2 --- /dev/null +++ b/externals/grill/flext/tutorial/pd/ex-attr3.pd @@ -0,0 +1,60 @@ +#N canvas 175 139 603 453 12;
+#X obj 16 7 cnv 15 550 40 empty empty attr3 10 22 0 24 -260818 -1 0
+;
+#X text 174 8 flext tutorial \, (C)2002 Thomas Grill;
+#X text 174 28 http://www.parasitaere-kapazitaeten.net;
+#X obj 293 364 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 196 361 nbx 5 18 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+12 -228992 -1 -1 8 256;
+#X msg 264 129 1 10;
+#X msg 384 127 1;
+#X msg 419 127 -1;
+#X msg 455 127 2;
+#X obj 36 128 bng 25 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+-1;
+#X msg 308 128 7 2;
+#X obj 159 123 nbx 5 18 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+12 -228992 -1 -1 0 256;
+#X msg 160 146 set \$1;
+#X text 20 107 trigger;
+#X text 149 104 set counter;
+#X text 259 108 set bounds;
+#X text 385 105 set step size;
+#X msg 87 135 reset;
+#X text 90 115 reset;
+#X text 23 63 with attributes;
+#X obj 197 327 attr3 @bounds 2 5 @step 1;
+#X msg 32 195 getattributes;
+#X obj 392 363 print;
+#X text 440 362 attributes;
+#X msg 32 237 getcount;
+#X msg 258 234 getbounds;
+#X msg 388 232 getstep;
+#X text 149 193 list all attributes;
+#X msg 32 266 count 3;
+#X text 109 238 get count;
+#X text 104 266 set count;
+#X msg 257 261 bounds 5 15;
+#X msg 387 259 step 3;
+#X text 21 49 this is a port of IOhannes Zmoelnings "counter" example
+;
+#X connect 5 0 20 1;
+#X connect 6 0 20 2;
+#X connect 7 0 20 2;
+#X connect 8 0 20 2;
+#X connect 9 0 20 0;
+#X connect 10 0 20 1;
+#X connect 11 0 12 0;
+#X connect 12 0 20 0;
+#X connect 17 0 20 0;
+#X connect 20 0 4 0;
+#X connect 20 1 3 0;
+#X connect 20 2 22 0;
+#X connect 21 0 20 0;
+#X connect 24 0 20 0;
+#X connect 25 0 20 0;
+#X connect 26 0 20 0;
+#X connect 28 0 20 0;
+#X connect 31 0 20 0;
+#X connect 32 0 20 0;
diff --git a/externals/grill/flext/tutorial/pd/ex-sndobj1.pd b/externals/grill/flext/tutorial/pd/ex-sndobj1.pd new file mode 100644 index 00000000..c343558e --- /dev/null +++ b/externals/grill/flext/tutorial/pd/ex-sndobj1.pd @@ -0,0 +1,34 @@ +#N canvas 405 36 584 392 12;
+#X obj 56 348 dac~;
+#X obj 15 8 cnv 15 550 40 empty empty sndobj1 10 22 0 24 -260818 -1
+0;
+#X text 175 8 flext tutorial \, (C)2002 Thomas Grill;
+#X text 175 28 http://www.parasitaere-kapazitaeten.net;
+#X text 170 285 adjust the volume;
+#X text 35 97 source;
+#X obj 171 268 hsl 128 15 0.01 1 1 0 empty empty empty -2 -6 0 8 -261681
+-1 -1 7200 1;
+#X msg 160 148 shL \$1;
+#X msg 218 148 shR \$1;
+#X obj 244 84 hsl 128 15 0.5 2 1 0 empty empty empty -2 -6 0 8 -261681
+-1 -1 1800 1;
+#X obj 244 104 hsl 128 15 0.5 2 1 0 empty empty empty -2 -6 0 8 -261681
+-1 -1 5100 1;
+#X text 149 82 pitch left;
+#X text 149 102 pitch right;
+#X obj 31 119 osc~ 442;
+#X obj 32 226 sndobj1~ @shL 0.7 @shR 1.2;
+#X obj 32 304 *~ 0.3;
+#X obj 91 304 *~ 0.3;
+#X connect 6 0 15 1;
+#X connect 6 0 16 1;
+#X connect 7 0 14 0;
+#X connect 8 0 14 0;
+#X connect 9 0 7 0;
+#X connect 10 0 8 0;
+#X connect 13 0 14 0;
+#X connect 13 0 14 1;
+#X connect 14 0 15 0;
+#X connect 14 1 16 0;
+#X connect 15 0 0 0;
+#X connect 16 0 0 1;
diff --git a/externals/grill/flext/tutorial/signal1/main.cpp b/externals/grill/flext/tutorial/signal1/main.cpp index f745be3b..3714e1f6 100644 --- a/externals/grill/flext/tutorial/signal1/main.cpp +++ b/externals/grill/flext/tutorial/signal1/main.cpp @@ -6,8 +6,8 @@ #include <flext.h> -#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400) -#error You need at least flext version 0.4.0 +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error You need at least flext version 0.4.1 #endif @@ -34,10 +34,14 @@ class signal1: // The constructor of your class is responsible for // setting up inlets and outlets and for registering // inlet-methods: - - AddInSignal(2); // 2 audio ins - AddInFloat(); // 1 float in - AddOutSignal(); // 1 audio out [ == AddOutSignal(1) ] + // The descriptions of the inlets and outlets are output + // via the Max/MSP assist method (when mousing over them in edit mode). + // PD will hopefully provide such a feature as well soon + + AddInSignal("left audio in"); // left audio in + AddInSignal("right audio in"); // right audio in + AddInFloat("panning parameter"); // 1 float in + AddOutSignal("audio out"); // 1 audio out // Now we need to bind the handler function to our // panning inlet, which is inlet 2 (counting all inlets @@ -87,7 +91,7 @@ class signal1: // that be for? Registering is made easy with the FLEXT_NEW_* macros defined // in flext.h. For tilde objects without arguments call: -FLEXT_NEW_DSP("signal1~ signal1~", signal1) +FLEXT_NEW_DSP("signal1~ pan~", signal1) // T.Grill: there are two names for the object: signal1~ as main name and pan~ as its alias // Now we define our DSP function. It gets this arguments: diff --git a/externals/grill/flext/tutorial/signal2/main.cpp b/externals/grill/flext/tutorial/signal2/main.cpp index 661625b2..76a2ca7b 100644 --- a/externals/grill/flext/tutorial/signal2/main.cpp +++ b/externals/grill/flext/tutorial/signal2/main.cpp @@ -37,7 +37,7 @@ protected: void m_bang(); // method for bang private: - FLEXT_CALLBACK(m_bang); // callback for method "m_bang" + FLEXT_CALLBACK(m_bang) // callback for method "m_bang" }; // instantiate the class diff --git a/externals/grill/flext/tutorial/simple1/main.cpp b/externals/grill/flext/tutorial/simple1/main.cpp index 5406cc8a..599e97f6 100755 --- a/externals/grill/flext/tutorial/simple1/main.cpp +++ b/externals/grill/flext/tutorial/simple1/main.cpp @@ -38,7 +38,7 @@ protected: void m_float(float f); // method for float values private: - FLEXT_CALLBACK_1(m_float,float); // callback for method "m_float" (with one float argument) + FLEXT_CALLBACK_1(m_float,float) // callback for method "m_float" (with one float argument) }; // instantiate the class diff --git a/externals/grill/flext/tutorial/simple2/main.cpp b/externals/grill/flext/tutorial/simple2/main.cpp index f23e1745..49b05351 100755 --- a/externals/grill/flext/tutorial/simple2/main.cpp +++ b/externals/grill/flext/tutorial/simple2/main.cpp @@ -37,8 +37,8 @@ protected: private: // FLEXT_CALLBACK_F(...) is a shortcut for FLEXT_CALLBACK_1(...,float) - FLEXT_CALLBACK_F(m_float1); // callback for method "m_float1" (with one float argument) - FLEXT_CALLBACK_F(m_float2); // callback for method "m_float2" (with one float argument) + FLEXT_CALLBACK_F(m_float1) // callback for method "m_float1" (with one float argument) + FLEXT_CALLBACK_F(m_float2) // callback for method "m_float2" (with one float argument) }; // instantiate the class (constructor has one float argument) diff --git a/externals/grill/flext/tutorial/simple3/main.cpp b/externals/grill/flext/tutorial/simple3/main.cpp index b09893ab..d13ce42d 100644 --- a/externals/grill/flext/tutorial/simple3/main.cpp +++ b/externals/grill/flext/tutorial/simple3/main.cpp @@ -25,7 +25,7 @@ class simple3: FLEXT_HEADER(simple3,flext_base) public: - // constructor with variable argument list + // constructor with no arguments simple3(); protected: @@ -38,12 +38,12 @@ protected: private: - FLEXT_CALLBACK(m_tag); // callback for method "m_tag" (no arguments) - FLEXT_CALLBACK_I(m_tag_and_int); // callback for method "m_tag" (int arguments) - FLEXT_CALLBACK_S(m_sym); // callback for method "m_sym" (with one symbol argument) + FLEXT_CALLBACK(m_tag) // callback for method "m_tag" (no arguments) + FLEXT_CALLBACK_I(m_tag_and_int) // callback for method "m_tag_and_int" (int arguments) + FLEXT_CALLBACK_S(m_sym) // callback for method "m_sym" (with one symbol argument) }; -// instantiate the class (constructor has a variable argument list) +// instantiate the class (constructor takes no arguments) FLEXT_NEW("simple3",simple3) diff --git a/externals/grill/flext/tutorial/thread1/main.cpp b/externals/grill/flext/tutorial/thread1/main.cpp index f5e2a651..c0d172e6 100644 --- a/externals/grill/flext/tutorial/thread1/main.cpp +++ b/externals/grill/flext/tutorial/thread1/main.cpp @@ -39,7 +39,7 @@ protected: private: // define threaded callback for method m_start // the same syntax as with FLEXT_CALLBACK is used here - FLEXT_THREAD(m_start); + FLEXT_THREAD(m_start) }; FLEXT_NEW("thread1",thread1) diff --git a/externals/grill/flext/tutorial/thread2/main.cpp b/externals/grill/flext/tutorial/thread2/main.cpp index 2cdc37c3..0abb5962 100644 --- a/externals/grill/flext/tutorial/thread2/main.cpp +++ b/externals/grill/flext/tutorial/thread2/main.cpp @@ -41,11 +41,11 @@ protected: void m_textout(); private: - FLEXT_THREAD_I(m_start); // define threaded callback for method m_start - FLEXT_CALLBACK(m_stop); // normal callback for m_stop - FLEXT_CALLBACK(m_text); // turn on console output + FLEXT_THREAD_I(m_start) // define threaded callback for method m_start + FLEXT_CALLBACK(m_stop) // normal callback for m_stop + FLEXT_CALLBACK(m_text) // turn on console output - FLEXT_THREAD(m_textout); // text output + FLEXT_THREAD(m_textout) // text output float delay; volatile int count; diff --git a/externals/grill/flext/tutorial/tutorial.dsw b/externals/grill/flext/tutorial/tutorial.dsw index 8a9d9707..e7338c60 100644 --- a/externals/grill/flext/tutorial/tutorial.dsw +++ b/externals/grill/flext/tutorial/tutorial.dsw @@ -19,6 +19,38 @@ Package=<4> ############################################################################### +Project: "adv2"=.\adv2\adv2.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + adv2 + .\adv2 + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "adv3"=.\adv3\adv3.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + adv3 + .\adv3 + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "attr1"=.\attr1\attr1.dsp - Package Owner=<4> Package=<5> @@ -51,6 +83,22 @@ Package=<4> ############################################################################### +Project: "attr3"=.\attr3\attr3.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + attr3 + .\attr3 + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "flext"=..\flext.dsp - Package Owner=<4> Package=<5> |