Update of /cvsroot/pure-data/externals/grill/dynext/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2904/src
Modified Files: main.cpp Log Message: some more documentation (proxy objects) better memory usage with modified proxies optimized DSP processing (less data copying, no more block delay) fixed send method so that any messages work now
Index: main.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/dynext/src/main.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** main.cpp 1 Jul 2006 13:53:20 -0000 1.12 --- main.cpp 1 Jul 2006 16:59:37 -0000 1.13 *************** *** 122,126 **** virtual bool CbMethodResort(int n,const t_symbol *s,int argc,const t_atom *argv); virtual bool CbDsp(); - virtual void CbSignal();
--- 122,125 ---- *************** *** 131,143 **** t_object obj; dyn *th; - int n; - t_sample *buf; - t_sample defsig;
void init(dyn *t) { th = t; ! n = 0,buf = NULL; defsig = 0; } }; --- 130,160 ---- t_object obj; dyn *th;
void init(dyn *t) { th = t; ! } ! }; ! ! // proxy object ! class sigproxy ! : public proxy ! { ! public: ! t_sample defsig; ! int n; ! t_sample *vec; ! ! void init(dyn *t) ! { ! proxy::init(t); defsig = 0; + n = 0,vec = NULL; + } + + void set(int n,t_sample *vec) + { + this->n = n; + this->vec = vec; } }; *************** *** 148,166 **** { public: ! t_outlet *outlet;
void Message(const t_symbol *s,int argc,const t_atom *argv) { ! typedmess((t_pd *)&obj,(t_symbol *)s,argc,(t_atom *)argv); }
- void init(dyn *t,bool s); - static void px_method(proxyin *obj,const t_symbol *s,int argc,const t_atom *argv) { ! outlet_anything(obj->outlet,(t_symbol *)s,argc,(t_atom *)argv); }
! static void dsp(proxyin *x, t_signal **sp); };
--- 165,197 ---- { public: ! void init(dyn *t) ! { ! proxy::init(t); ! outlet_new(&obj,&s_anything); ! }
void Message(const t_symbol *s,int argc,const t_atom *argv) { ! outlet_anything(obj.te_outlet,(t_symbol *)s,argc,(t_atom *)argv); }
static void px_method(proxyin *obj,const t_symbol *s,int argc,const t_atom *argv) { ! obj->Message(s,argc,argv); } + };
! // proxy for inbound signals ! class sigproxyin: ! public sigproxy ! { ! public: ! void init(dyn *t) ! { ! sigproxy::init(t); ! outlet_new(&obj,&s_signal); ! } ! ! static void dsp(sigproxyin *x, t_signal **sp); };
*************** *** 171,177 **** { public: ! int outlet; ! ! void init(dyn *t,int o,bool s);
static void px_method(proxyout *obj,const t_symbol *s,int argc,const t_atom *argv) --- 202,210 ---- { public: ! void init(dyn *t,int o) ! { ! proxy::init(t); ! outlet = o; ! }
static void px_method(proxyout *obj,const t_symbol *s,int argc,const t_atom *argv) *************** *** 180,184 **** }
! static void dsp(proxyout *x, t_signal **sp); };
--- 213,232 ---- }
! protected: ! int outlet; ! }; ! ! // proxy for outbound messages ! class sigproxyout: ! public sigproxy ! { ! public: ! void init(dyn *t) ! { ! sigproxy::init(t); ! outlet_new(&obj,&s_signal); ! } ! ! static void dsp(sigproxyout *x, t_signal **sp); };
*************** *** 186,191 **** static t_class *pxins_class,*pxouts_class;
! proxyin **pxin; ! proxyout **pxout;
static t_object *pxin_new() { return (t_object *)pd_new(pxin_class); } --- 234,242 ---- static t_class *pxins_class,*pxouts_class;
! int s_inlets,m_inlets,s_outlets,m_outlets; ! sigproxyin **pxsin; ! proxyin **pxmin; ! sigproxyout **pxsout; ! proxyout **pxmout;
static t_object *pxin_new() { return (t_object *)pd_new(pxin_class); } *************** *** 194,198 **** static t_object *pxouts_new() { return (t_object *)pd_new(pxouts_class); }
- int m_inlets,s_inlets,m_outlets,s_outlets; t_canvas *canvas; bool stripext,canvasmsg,symreuse; --- 245,248 ---- *************** *** 262,268 ****
// set up proxy class for inbound signals ! pxins_class = class_new(const_cast<t_symbol *>(sym_dynsin),(t_newmethod)pxins_new,NULL,sizeof(proxyin),0, A_NULL); ! add_dsp(pxins_class,proxyin::dsp); ! CLASS_MAINSIGNALIN(pxins_class, proxyin, defsig);
// set up proxy class for outbound messages --- 312,318 ----
// set up proxy class for inbound signals ! pxins_class = class_new(const_cast<t_symbol *>(sym_dynsin),(t_newmethod)pxins_new,NULL,sizeof(sigproxyin),0, A_NULL); ! add_dsp(pxins_class,sigproxyin::dsp); ! CLASS_MAINSIGNALIN(pxins_class, sigproxyin, defsig);
// set up proxy class for outbound messages *************** *** 271,277 ****
// set up proxy class for outbound signals ! pxouts_class = class_new(const_cast<t_symbol *>(sym_dynsout),(t_newmethod)pxouts_new,NULL,sizeof(proxyout),0, A_NULL); ! add_dsp(pxouts_class,proxyout::dsp); ! CLASS_MAINSIGNALIN(pxouts_class, proxyout, defsig);
// set up dyn~ --- 321,327 ----
// set up proxy class for outbound signals ! pxouts_class = class_new(const_cast<t_symbol *>(sym_dynsout),(t_newmethod)pxouts_new,NULL,sizeof(sigproxyout),0, A_NULL); ! add_dsp(pxouts_class,sigproxyout::dsp); ! CLASS_MAINSIGNALIN(pxouts_class, sigproxyout, defsig);
// set up dyn~ *************** *** 336,340 **** dyn::dyn(int argc,const t_atom *argv): canvas(NULL), ! pxin(NULL),pxout(NULL), stripext(false),symreuse(true),canvasmsg(false) { --- 386,390 ---- dyn::dyn(int argc,const t_atom *argv): canvas(NULL), ! pxsin(NULL),pxmin(NULL),pxsout(NULL),pxmout(NULL), stripext(false),symreuse(true),canvasmsg(false) { *************** *** 404,411 **** // --- create inlet proxies ------ int i; ! pxin = new proxyin *[s_inlets+m_inlets]; for(i = 0; i < s_inlets+m_inlets; ++i) { - bool sig = i < s_inlets; - t_atom lst[5]; SetInt(lst[0],i*100); --- 454,460 ---- // --- create inlet proxies ------ int i; ! if(s_inlets) pxsin = new sigproxyin *[s_inlets]; ! if(m_inlets) pxmin = new proxyin *[m_inlets]; for(i = 0; i < s_inlets+m_inlets; ++i) { t_atom lst[5]; SetInt(lst[0],i*100); *************** *** 413,421 **** SetSymbol(lst[2],sym_dot); SetSymbol(lst[3],sym__); - SetSymbol(lst[4],sig?sym_dynsin:sym_dynin);
try { ! pxin[i] = (proxyin *)New(k_obj,5,lst,false); ! if(pxin[i]) pxin[i]->init(this,sig); } catch(...) { --- 462,478 ---- SetSymbol(lst[2],sym_dot); SetSymbol(lst[3],sym__);
try { ! if(i < s_inlets) { ! SetSymbol(lst[4],sym_dynsin); ! pxsin[i] = (sigproxyin *)New(k_obj,5,lst,false); ! if(pxsin[i]) pxsin[i]->init(this); ! } ! else { ! int j = i-s_inlets; ! SetSymbol(lst[4],sym_dynin); ! pxmin[j] = (proxyin *)New(k_obj,5,lst,false); ! if(pxmin[j]) pxmin[j]->init(this); ! } } catch(...) { *************** *** 426,433 **** // --- create outlet proxies ------
! pxout = new proxyout *[s_outlets+m_outlets]; for(i = 0; i < s_outlets+m_outlets; ++i) { - bool sig = i < s_outlets; - t_atom lst[5]; SetInt(lst[0],i*100); --- 483,489 ---- // --- create outlet proxies ------
! if(s_outlets) pxsout = new sigproxyout *[s_outlets]; ! if(m_outlets) pxmout = new proxyout *[m_outlets]; for(i = 0; i < s_outlets+m_outlets; ++i) { t_atom lst[5]; SetInt(lst[0],i*100); *************** *** 435,443 **** SetSymbol(lst[2],sym_dot); SetSymbol(lst[3],sym__); - SetSymbol(lst[4],sig?sym_dynsout:sym_dynout);
try { ! pxout[i] = (proxyout *)New(k_obj,5,lst,false); ! if(pxout[i]) pxout[i]->init(this,i,sig); } catch(...) { --- 491,507 ---- SetSymbol(lst[2],sym_dot); SetSymbol(lst[3],sym__);
try { ! if(i < s_outlets) { ! SetSymbol(lst[4],sym_dynsout); ! pxsout[i] = (sigproxyout *)New(k_obj,5,lst,false); ! if(pxsout[i]) pxsout[i]->init(this); ! } ! else { ! int j = i-s_outlets; ! SetSymbol(lst[4],sym_dynout); ! pxmout[j] = (proxyout *)New(k_obj,5,lst,false); ! if(pxmout[j]) pxmout[j]->init(this,i); ! } } catch(...) { *************** *** 450,460 **** { int i; ! if(pxin) { ! for(i = 0; i < s_inlets+m_inlets; ++i) glist_delete(canvas,(t_gobj *)pxin[i]); ! delete[] pxin; } ! if(pxout) { ! for(i = 0; i < s_outlets+m_outlets; ++i) glist_delete(canvas,(t_gobj *)pxout[i]); ! delete[] pxout; } } --- 514,532 ---- { int i; ! if(pxsin) { ! for(i = 0; i < s_inlets; ++i) glist_delete(canvas,(t_gobj *)pxsin[i]); ! delete[] pxsin; pxsin = NULL; } ! if(pxmin) { ! for(i = 0; i < m_inlets; ++i) glist_delete(canvas,(t_gobj *)pxmin[i]); ! delete[] pxmin; pxmin = NULL; ! } ! if(pxsout) { ! for(i = 0; i < s_outlets; ++i) glist_delete(canvas,(t_gobj *)pxsout[i]); ! delete[] pxsout; pxsout = NULL; ! } ! if(pxmout) { ! for(i = 0; i < m_outlets; ++i) glist_delete(canvas,(t_gobj *)pxmout[i]); ! delete[] pxmout; pxmout = NULL; } } *************** *** 731,735 **** } else if(argc == 2 && CanbeInt(argv[0]) && CanbeInt(argv[1])) { ! // direct connection from proxy-in to proxy-out (for testing above all....) s_n = NULL; s_x = GetAInt(argv[0]); --- 803,807 ---- } else if(argc == 2 && CanbeInt(argv[0]) && CanbeInt(argv[1])) { ! // direct connection from proxy-in to proxy-out s_n = NULL; s_x = GetAInt(argv[0]); *************** *** 738,742 **** } else { ! post("%s - connect: [src] srcslot [dst] dstslot",thisName()); return; } --- 810,814 ---- } else { ! post("%s - connect: [src-name] src-slot [dst-name] dst-slot",thisName()); return; } *************** *** 758,762 **** } else { ! s_obj = &pxin[s_x]->obj; s_cnv = canvas; s_x = 0; // always 0 for proxy --- 830,834 ---- } else { ! s_obj = s_x < s_inlets?&pxsin[s_x]->obj:&pxmin[s_x-s_inlets]->obj; s_cnv = canvas; s_x = 0; // always 0 for proxy *************** *** 777,781 **** } else { ! d_obj = &pxout[d_x]->obj; d_cnv = canvas; d_x = 0; // always 0 for proxy --- 849,853 ---- } else { ! d_obj = d_x < s_outlets?&pxsout[d_x]->obj:&pxmout[d_x-s_outlets]->obj; d_cnv = canvas; d_x = 0; // always 0 for proxy *************** *** 819,823 **** else { // all other messages are forwarded to proxies (and connected objects) ! pxin[n-1]->Message(s,argc,argv); return true; } --- 891,898 ---- else { // all other messages are forwarded to proxies (and connected objects) ! if(n >= s_inlets) ! pxmin[n-s_inlets-1]->Message(s,argc,argv); ! else ! post("%s - message to signal inlet",thisName()); return true; } *************** *** 844,850 **** }
! void dyn::proxyin::dsp(proxyin *x,t_signal **sp) { ! FLEXT_ASSERT(x->buf && x->n); int n = sp[0]->s_n; if(n != x->n) { --- 919,925 ---- }
! void dyn::sigproxyin::dsp(sigproxyin *x,t_signal **sp) { ! FLEXT_ASSERT(x->vec && x->n); int n = sp[0]->s_n; if(n != x->n) { *************** *** 852,870 **** } else ! dsp_add_copy(x->buf,sp[0]->s_vec,n); ! } ! ! void dyn::proxyin::init(dyn *t,bool s) ! { ! proxy::init(t); ! outlet = outlet_new(&obj,s?&s_signal:&s_anything); }
! ! ! ! void dyn::proxyout::dsp(proxyout *x,t_signal **sp) { ! FLEXT_ASSERT(x->buf && x->n); int n = sp[0]->s_n; if(n != x->n) { --- 927,936 ---- } else ! dsp_add_copy(x->vec,sp[0]->s_vec,n); }
! void dyn::sigproxyout::dsp(sigproxyout *x,t_signal **sp) { ! FLEXT_ASSERT(x->vec && x->n); int n = sp[0]->s_n; if(n != x->n) { *************** *** 872,886 **** } else ! dsp_add_copy(sp[0]->s_vec,x->buf,n); ! } ! ! void dyn::proxyout::init(dyn *t,int o,bool s) ! { ! proxy::init(t); ! outlet = o; ! if(s) outlet_new(&obj,&s_signal); }
- bool dyn::CbDsp() { --- 938,944 ---- } else ! dsp_add_copy(sp[0]->s_vec,x->vec,n); }
bool dyn::CbDsp() { *************** *** 888,898 **** t_sample *const *in = InSig(),*const *out = OutSig(); int i; ! for(i = 0; i < s_inlets; ++i) pxin[i]->buf = in[i+1],pxin[i]->n = n; ! for(i = 0; i < s_outlets; ++i) pxout[i]->buf = out[i],pxout[i]->n = n;
// add sub canvas to dsp list (no signal vector to borrow from .. set it to NULL) mess1((t_pd *)canvas,const_cast<t_symbol *>(sym_dsp),NULL); ! return true; } - - void dyn::CbSignal() {} --- 946,954 ---- t_sample *const *in = InSig(),*const *out = OutSig(); int i; ! for(i = 0; i < s_inlets; ++i) pxsin[i]->set(n,in[i+1]); ! for(i = 0; i < s_outlets; ++i) pxsout[i]->set(n,out[i]);
// add sub canvas to dsp list (no signal vector to borrow from .. set it to NULL) mess1((t_pd *)canvas,const_cast<t_symbol *>(sym_dsp),NULL); ! return false; }