Update of /cvsroot/pure-data/externals/grill/flext/source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13386/source
Modified Files:
flbase.cpp flbase.h flclass.h fldsp.cpp fldsp.h flext.cpp
flout.cpp flproxy.cpp
Log Message:
- better handling of click callback
bugfixes and optimizations, especially for DSP under Max/MSP
- more compatible handling of attributes in patcher (hiding is now an option - define FLEXT_ATTRHIDE)
Index: flout.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flout.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** flout.cpp 23 May 2005 16:52:45 -0000 1.22
--- flout.cpp 26 Sep 2005 13:59:34 -0000 1.23
***************
*** 192,213 ****
ok = false;
break;
! case xlet_float:
! inlets[ix] = NULL;
! if(ix >= 10) {
! post("%s: Only 9 float inlets possible",thisName());
! ok = false;
! }
! else
! floatin(x_obj,ix);
! break;
! case xlet_int:
! inlets[ix] = NULL;
! if(ix >= 10) {
! post("%s: Only 9 int inlets possible",thisName());
! ok = false;
! }
! else
! intin(x_obj,ix);
! break;
case xlet_any: // non-leftmost
case xlet_sym:
--- 192,214 ----
ok = false;
break;
! case xlet_float: {
! if(ix < 10) {
! inlets[ix] = NULL;
! floatin(x_obj,ix);
! break;
! }
! else
! goto makeproxy;
! }
! case xlet_int: {
! if(ix < 10) {
! inlets[ix] = NULL;
! intin(x_obj,ix);
! break;
! }
! else
! goto makeproxy;
! }
! makeproxy:
case xlet_any: // non-leftmost
case xlet_sym:
***************
*** 222,231 ****
}
}
!
! // incnt = cnt;
!
! if(insigs)
! dsp_setup(thisHdr(),insigs); // signal inlets
! }
#else
#error
--- 223,229 ----
}
}
!
! while(ix >= 0) inlets[ix--] = NULL;
! }
#else
#error
Index: flext.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flext.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** flext.cpp 12 Sep 2005 10:27:40 -0000 1.39
--- flext.cpp 26 Sep 2005 13:59:34 -0000 1.40
***************
*** 49,53 ****
}
! flext_base::~FLEXT_CLASSDEF(flext_base)()
{
#if FLEXT_SYS == FLEXT_SYS_PD && !defined(FLEXT_NOATTREDIT)
--- 49,82 ----
}
! /*! 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.
! */
! bool flext_base::Init()
! {
! bool ok = flext_obj::Init();
!
! if(ok) ok = InitInlets() && InitOutlets();
!
! if(ok) {
! if(HasAttributes() && m_holdaargc && m_holdaargv) {
! // initialize creation attributes
! ok = InitAttrib(m_holdaargc,m_holdaargv);
! }
! }
!
! return ok;
! }
!
!
! /*! This virtual function is called before the destructor.
! We do this because here we can still call virtual methods.
! */
! void flext_base::Exit()
{
#if FLEXT_SYS == FLEXT_SYS_PD && !defined(FLEXT_NOATTREDIT)
***************
*** 56,65 ****
#endif
- #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());
- #endif
-
#ifdef FLEXT_THREADS
StopThreads();
--- 85,88 ----
***************
*** 102,132 ****
}
#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.
! */
! bool flext_base::Init()
! {
! bool ok = flext_obj::Init();
!
! if(ok) ok = InitInlets() && InitOutlets();
!
! if(ok) {
! if(HasAttributes() && m_holdaargc && m_holdaargv) {
! // initialize creation attributes
! ok = InitAttrib(m_holdaargc,m_holdaargv);
! }
! }
!
! return ok;
}
/*! Set up proxy classes and basic methods at class creation time
This ensures that they are processed before the registered flext messages
--- 125,133 ----
}
#endif
! flext_obj::Exit();
}
+
/*! Set up proxy classes and basic methods at class creation time
This ensures that they are processed before the registered flext messages
Index: flproxy.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flproxy.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** flproxy.cpp 19 Jul 2005 13:17:50 -0000 1.10
--- flproxy.cpp 26 Sep 2005 13:59:34 -0000 1.11
***************
*** 43,47 ****
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)
int ci = ((flext_hdr *)c)->curinlet;
thisObject(c)->CbMethodHandler(ci,s,argc,argv);
--- 43,46 ----
***************
*** 50,54 ****
void flext_base::cb_px_int(t_class *c,long v)
{
- // check if inlet allows int type
t_atom atom; SetInt(atom,v);
int ci = ((flext_hdr *)c)->curinlet;
--- 49,52 ----
***************
*** 58,62 ****
void flext_base::cb_px_float(t_class *c,double v)
{
- // check if inlet allows float type
t_atom atom; SetFloat(atom,v);
int ci = ((flext_hdr *)c)->curinlet;
--- 56,59 ----
***************
*** 66,70 ****
void flext_base::cb_px_bang(t_class *c)
{
- // check if inlet allows bang
int ci = ((flext_hdr *)c)->curinlet;
thisObject(c)->CbMethodHandler(ci,sym_bang,0,NULL);
--- 63,66 ----
***************
*** 106,110 ****
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
--- 102,106 ----
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
***************
*** 123,137 ****
ADD_IN_FT(9);
}
-
- #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)
- {
- thisObject(c)->CbMethodHandler(winlet,s,argc,argv);
- }
-
- void flext_base::SetProxies(t_class *c)
- {
- fts_class_set_default_handler(c, jmax_proxy);
- }
-
#endif
--- 119,121 ----
Index: flbase.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flbase.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** flbase.h 30 Jul 2005 12:21:41 -0000 1.33
--- flbase.h 26 Sep 2005 13:59:34 -0000 1.34
***************
*** 211,215 ****
//! Creation callback
! static void __setup__(t_classid) { flext::Setup(); }
/*! \brief This is a temporary holder
--- 211,215 ----
//! Creation callback
! static void __setup__(t_classid);
/*! \brief This is a temporary holder
Index: fldsp.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/fldsp.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** fldsp.h 12 Sep 2005 10:27:40 -0000 1.16
--- fldsp.h 26 Sep 2005 13:59:34 -0000 1.17
***************
*** 53,73 ****
//! returns array of input vectors (CntInSig() vectors)
! t_sample *const *InSig() const { return invecs; }
//! returns input vector
! t_sample *InSig(int i) const { return invecs[i]; }
//! returns array of output vectors (CntOutSig() vectors)
! t_sample *const *OutSig() const { return outvecs; }
//! returns output vector
! t_sample *OutSig(int i) const { return outvecs[i]; }
//! typedef describing a signal vector
- #if FLEXT_SYS == FLEXT_SYS_JMAX
- typedef fts_symbol_t t_signalvec;
- #else
typedef t_sample *t_signalvec;
- #endif
//! @}
--- 53,69 ----
//! returns array of input vectors (CntInSig() vectors)
! t_sample *const *InSig() const { return vecs; }
//! returns input vector
! t_sample *InSig(int i) const { return vecs[i]; }
//! returns array of output vectors (CntOutSig() vectors)
! t_sample *const *OutSig() const { return vecs+CntInSig(); }
//! returns output vector
! t_sample *OutSig(int i) const { return vecs[CntInSig()+i]; }
//! typedef describing a signal vector
typedef t_sample *t_signalvec;
//! @}
***************
*** 146,150 ****
FLEXT_CLASSDEF(flext_dsp)();
! virtual ~FLEXT_CLASSDEF(flext_dsp)();
private:
--- 142,151 ----
FLEXT_CLASSDEF(flext_dsp)();
!
! #if FLEXT_SYS == FLEXT_SYS_MAX
! virtual bool Init();
! #endif
!
! virtual void Exit();
private:
***************
*** 153,157 ****
float srate;
int blksz;
! int chnsin,chnsout;
// setup function
--- 154,158 ----
float srate;
int blksz;
! t_signalvec *vecs;
// setup function
***************
*** 159,191 ****
// callback functions
!
! #if FLEXT_SYS == FLEXT_SYS_JMAX
! static void cb_dsp(fts_object_t *o, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at);
! // static void cb_dsp_init(fts_object_t *o, int winlet, fts_symbol_t *s, int ac, const fts_atom_t *at);
! // static void cb_dsp_delete(fts_object_t *o, int winlet, fts_symbol_t *s, int ac, const fts_atom_t *at);
! #elif FLEXT_SYS == FLEXT_SYS_MAX
static void cb_dsp(t_class *c,t_signal **s,short *count);
#else
static void cb_dsp(t_class *c,t_signal **s);
- #endif
-
- #if FLEXT_SYS != FLEXT_SYS_MAX
- #if FLEXT_SYS == FLEXT_SYS_JMAX
- static void cb_enable(fts_object_t *o, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at);
- #else
static void cb_enable(t_class *c,t_float on);
- #endif
bool dspon;
#endif
// dsp stuff
-
- #if FLEXT_SYS == FLEXT_SYS_JMAX
- static void dspmeth(fts_word_t *);
- static const t_symbol *dspsym;
- #else
static t_int *dspmeth(t_int *w);
- #endif
- t_signalvec *invecs,*outvecs;
};
--- 160,173 ----
// callback functions
! #if FLEXT_SYS == FLEXT_SYS_MAX
static void cb_dsp(t_class *c,t_signal **s,short *count);
#else
static void cb_dsp(t_class *c,t_signal **s);
static void cb_enable(t_class *c,t_float on);
bool dspon;
#endif
// dsp stuff
static t_int *dspmeth(t_int *w);
};
Index: flbase.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flbase.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** flbase.cpp 12 Sep 2005 10:27:40 -0000 1.25
--- flbase.cpp 26 Sep 2005 13:59:34 -0000 1.26
***************
*** 53,56 ****
--- 53,60 ----
void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; }
+ #if FLEXT_SYS == FLEXT_SYS_MAX
+ static const t_symbol *sym__shP = NULL;
+ #endif
+
/////////////////////////////////////////////////////////
// Constructor
***************
*** 65,69 ****
m_canvas = canvas_getcurrent();
#elif FLEXT_SYS == FLEXT_SYS_MAX
! m_canvas = (t_patcher *)gensym("#P")->s_thing;
x_obj->curinlet = 0;
#endif
--- 69,73 ----
m_canvas = canvas_getcurrent();
#elif FLEXT_SYS == FLEXT_SYS_MAX
! m_canvas = (t_patcher *)sym__shP->s_thing;
x_obj->curinlet = 0;
#endif
***************
*** 79,82 ****
--- 83,93 ----
}
+ void flext_obj::__setup__(t_classid)
+ {
+ #if FLEXT_SYS == FLEXT_SYS_MAX
+ sym__shP = MakeSymbol("#P");
+ #endif
+ flext::Setup();
+ }
bool flext_obj::Init() { return true; }
Index: fldsp.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/fldsp.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** fldsp.cpp 23 May 2005 16:52:44 -0000 1.28
--- fldsp.cpp 26 Sep 2005 13:59:34 -0000 1.29
***************
*** 19,26 ****
// === flext_dsp ==============================================
- #if FLEXT_SYS == FLEXT_SYS_JMAX
- const t_symbol *flext_dsp::dspsym = MakeSymbol("__flext_dspfun__");
- #endif
-
void flext_dsp::Setup(t_classid id)
{
--- 19,22 ----
***************
*** 34,83 ****
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);
#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()),
! #else
! srate(sys_getsr()),blksz(sys_getblksize()),
! #endif
! chnsin(0),chnsout(0),
#if FLEXT_SYS != FLEXT_SYS_MAX
! dspon(true),
#endif
! invecs(NULL),outvecs(NULL)
{
! #if FLEXT_SYS == FLEXT_SYS_JMAX
! fts_dsp_object_init(thisHdr());
! #endif
! }
! flext_dsp::~FLEXT_CLASSDEF(flext_dsp)()
{
- #if FLEXT_SYS == FLEXT_SYS_JMAX
- fts_dsp_object_delete(thisHdr());
- #endif
-
#if FLEXT_SYS == FLEXT_SYS_MAX
! // switch off dsp as the dsp function might get called afterwards (different thread)
! thisHdr()->z_disabled = true;
#endif
! if(invecs) delete[] invecs;
! if(outvecs) delete[] outvecs;
}
! #if FLEXT_SYS == FLEXT_SYS_JMAX
! void flext_dsp::dspmeth(fts_word_t *w)
! {
! }
! #else
t_int *flext_dsp::dspmeth(t_int *w)
{
--- 30,72 ----
add_dsp(c,cb_dsp);
add_method1(c,cb_enable,"enable",A_FLOAT);
! #else
! #error Platform not supported!
#endif
}
! flext_dsp::FLEXT_CLASSDEF(flext_dsp)()
! : srate(sys_getsr()),blksz(sys_getblksize())
! , vecs(NULL)
#if FLEXT_SYS != FLEXT_SYS_MAX
! , dspon(true)
#endif
! {}
!
! #if FLEXT_SYS == FLEXT_SYS_MAX
! bool flext_dsp::Init()
{
! if(!flext_base::Init())
! return false;
+ // according to the Max/MSP SDK this should be prior to any inlet creation, BUT
+ // that doesn't seem to be true... multiple signal ins and additional inlets don't seem to work then
+ dsp_setup(thisHdr(),CntInSig()); // signal inlets
+ return true;
+ }
+ #endif
! void flext_dsp::Exit()
{
#if FLEXT_SYS == FLEXT_SYS_MAX
! // according to David Z. one should do that first...
! dsp_free(thisHdr());
#endif
! flext_base::Exit();
!
! if(vecs) delete[] vecs;
}
!
t_int *flext_dsp::dspmeth(t_int *w)
{
***************
*** 96,104 ****
return w+2;
}
- #endif
! #if FLEXT_SYS == FLEXT_SYS_JMAX
! void flext_dsp::cb_dsp(fts_object_t *c, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at)
! #elif FLEXT_SYS == FLEXT_SYS_MAX
void flext_dsp::cb_dsp(t_class *c,t_signal **sp,short *count)
#else
--- 85,90 ----
return w+2;
}
! #if FLEXT_SYS == FLEXT_SYS_MAX
void flext_dsp::cb_dsp(t_class *c,t_signal **sp,short *count)
#else
***************
*** 114,185 ****
// min. 1 input channel! (CLASS_MAININLET in pd...)
if(!in) in = 1;
- #else
- if(in+out == 0) return;
#endif
// 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() ?
- #else
obj->srate = sp[0]->s_sr;
obj->blksz = sp[0]->s_n; // is this guaranteed to be the same as sys_getblksize() ?
- #endif
// store in and out signal vectors
! if(in != obj->chnsin) {
! if(obj->invecs) delete[] obj->invecs;
! obj->invecs = in?new t_signalvec[in]:NULL;
! obj->chnsin = in;
! }
! for(i = 0; i < in; ++i)
! obj->invecs[i] =
! #if FLEXT_SYS == FLEXT_SYS_JMAX
! fts_dsp_get_input_name(dsp,i);
! #else
! sp[i]->s_vec;
! #endif
! if(out != obj->chnsout) {
! if(obj->outvecs) delete[] obj->outvecs;
! obj->outvecs = out?new t_signalvec[out]:NULL;
! obj->chnsout = out;
! }
for(i = 0; i < out; ++i)
! obj->outvecs[i] =
! #if FLEXT_SYS == FLEXT_SYS_JMAX
! fts_dsp_get_output_name(dsp,i);
! #else
! sp[in+i]->s_vec;
! #endif
// with the following call derived classes can do their eventual DSP setup
if(obj->CbDsp()) {
// 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);
- #else
dsp_add((t_dspmethod)dspmeth,1,obj);
- #endif
}
}
- /*
- #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);
- }
-
- 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);
- }
- #endif
- */
void flext_dsp::m_dsp(int /*n*/,t_signalvec const * /*insigs*/,t_signalvec const * /*outsigs*/) {}
--- 100,126 ----
// min. 1 input channel! (CLASS_MAININLET in pd...)
if(!in) in = 1;
#endif
// store current dsp parameters
obj->srate = sp[0]->s_sr;
obj->blksz = sp[0]->s_n; // is this guaranteed to be the same as sys_getblksize() ?
// store in and out signal vectors
! if((in+out) && !obj->vecs)
! obj->vecs = new t_signalvec[in+out];
! for(i = 0; i < in; ++i)
! obj->vecs[i] = sp[i]->s_vec;
for(i = 0; i < out; ++i)
! obj->vecs[in+i] = sp[in+i]->s_vec;
// with the following call derived classes can do their eventual DSP setup
if(obj->CbDsp()) {
// set the DSP function
dsp_add((t_dspmethod)dspmeth,1,obj);
}
}
void flext_dsp::m_dsp(int /*n*/,t_signalvec const * /*insigs*/,t_signalvec const * /*outsigs*/) {}
***************
*** 187,194 ****
bool flext_dsp::CbDsp()
{
! m_dsp(Blocksize(),invecs,outvecs);
return true;
}
void flext_dsp::m_signal(int n,t_sample *const * /*insigs*/,t_sample *const *outs)
{
--- 128,137 ----
bool flext_dsp::CbDsp()
{
! // invoke legacy method
! m_dsp(Blocksize(),InSig(),OutSig());
return true;
}
+ // this function will be overridden anyway - the probably useless default is clearing all outputs
void flext_dsp::m_signal(int n,t_sample *const * /*insigs*/,t_sample *const *outs)
{
***************
*** 196,206 ****
}
! void flext_dsp::CbSignal() { m_signal(Blocksize(),invecs,outvecs); }
#if FLEXT_SYS == FLEXT_SYS_PD
void flext_dsp::cb_enable(t_class *c,t_float on) { thisObject(c)->dspon = on != 0; }
- #elif FLEXT_SYS == FLEXT_SYS_JMAX
- void flext_dsp::cb_enable(fts_object_t *c, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at)
- { thisObject(c)->dspon = fts_get_int(at+0) != 0; }
#endif
--- 139,150 ----
}
! void flext_dsp::CbSignal()
! {
! // invoke legacy method
! m_signal(Blocksize(),InSig(),OutSig());
! }
#if FLEXT_SYS == FLEXT_SYS_PD
void flext_dsp::cb_enable(t_class *c,t_float on) { thisObject(c)->dspon = on != 0; }
#endif
Index: flclass.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flclass.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -C2 -d -r1.63 -r1.64
*** flclass.h 30 Jul 2005 21:59:31 -0000 1.63
--- flclass.h 26 Sep 2005 13:59:34 -0000 1.64
***************
*** 519,523 ****
FLEXT_CLASSDEF(flext_base)();
- virtual ~FLEXT_CLASSDEF(flext_base)();
/*! \brief Set up inlets and outlets, method and attribute lists
--- 519,522 ----
***************
*** 525,528 ****
--- 524,531 ----
virtual bool Init();
+ /*! \brief Deallocate all kinds of stuff
+ */
+ virtual void Exit();
+
/*! \defgroup FLEXT_C_ATTR Attribute handling methods (object scope)