aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2006-07-01 16:59:37 +0000
committerThomas Grill <xovo@users.sourceforge.net>2006-07-01 16:59:37 +0000
commitc901bd3e5672b4c8494beb6b337474b850883549 (patch)
treee39ba5b0f7d6bc412e36d0e31cee4f929444371b
parent685365ef51b6d6e26c6c2e89ae544d3919efa69c (diff)
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 svn path=/trunk/; revision=5331
-rw-r--r--externals/grill/dynext/pd/dyn~-help.pd70
-rwxr-xr-xexternals/grill/dynext/readme.txt2
-rw-r--r--externals/grill/dynext/src/main.cpp208
3 files changed, 167 insertions, 113 deletions
diff --git a/externals/grill/dynext/pd/dyn~-help.pd b/externals/grill/dynext/pd/dyn~-help.pd
index 86fca988..078cbeca 100644
--- a/externals/grill/dynext/pd/dyn~-help.pd
+++ b/externals/grill/dynext/pd/dyn~-help.pd
@@ -1,5 +1,5 @@
-#N canvas 36 61 829 548 12;
-#N canvas 71 10 558 565 examples 0;
+#N canvas 50 60 833 552 12;
+#N canvas 71 10 562 569 examples 0;
#X floatatom 148 239 5 0 0 0 - - -;
#X floatatom 105 304 5 0 0 0 - - -;
#X floatatom 113 501 5 0 0 0 - - -;
@@ -71,42 +71,40 @@ conn a 0 0;
#X text 187 98 reload all objects (keep connections);
#X msg 127 98 reload;
#X text 218 432 (connections are not drawn at the moment!);
-#N canvas 178 192 582 438 dsp-ex 0;
-#X obj 73 380 dac~;
-#X obj 183 257 hsl 128 15 0 1000 0 0 empty empty empty -2 -6 0 8 -261681
--1 -1 0 1;
-#X obj 194 282 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
-10 -262144 -1 -1 0 256;
-#X msg 66 78 reset;
-#X obj 467 323 loadbang;
-#X msg 466 347 \; pd dsp 1;
-#X text 65 56 clear all;
-#X obj 47 278 dyn~ 0 1 2 0;
-#X text 70 107 make an oscillator (left);
-#X text 66 167 add an oscillator (double frq \, right);
-#X text 24 17 signals passing through dyn~ are delayed by one block
-;
-#X text 74 239 select frequency;
-#X obj 57 341 *~ 0.2;
-#X obj 141 340 *~ 0.2;
-#X obj 179 313 hsl 128 15 0.001 1 1 0 empty empty empty -2 -6 0 8 -262131
--1 -1 0 1;
-#X text 316 309 gain;
-#X msg 64 129 newobj . o1 osc~ 220 \, conn 0 o1 0 \, conn o1 0 0;
-#X msg 67 187 newobj . m * 1.5 \, newobj . o2 osc~ 330 \, conn 0 m
+#N canvas 178 192 594 450 dsp-ex 0;
+#X obj 63 357 dac~;
+#X obj 173 234 hsl 128 15 0 1000 0 0 empty empty empty -2 -6 0 8 -261681
+-1 -1 2800 1;
+#X obj 184 259 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+10 -262144 -1 -1 220.472 256;
+#X msg 56 55 reset;
+#X obj 457 300 loadbang;
+#X msg 456 324 \; pd dsp 1;
+#X text 55 33 clear all;
+#X obj 37 255 dyn~ 0 1 2 0;
+#X text 60 84 make an oscillator (left);
+#X text 56 144 add an oscillator (double frq \, right);
+#X text 64 216 select frequency;
+#X obj 47 318 *~ 0.2;
+#X obj 131 317 *~ 0.2;
+#X obj 169 290 hsl 128 15 0.001 1 1 0 empty empty empty -2 -6 0 8 -262131
+-1 -1 3300 1;
+#X text 306 286 gain;
+#X msg 54 106 newobj . o1 osc~ 220 \, conn 0 o1 0 \, conn o1 0 0;
+#X msg 57 164 newobj . m * 1.5 \, newobj . o2 osc~ 330 \, conn 0 m
0 \, conn m 0 o2 0 \, conn o2 0 1;
#X connect 1 0 2 0;
#X connect 1 0 7 1;
#X connect 3 0 7 0;
#X connect 4 0 5 0;
-#X connect 7 0 12 0;
-#X connect 7 1 13 0;
-#X connect 12 0 0 0;
-#X connect 13 0 0 1;
-#X connect 14 0 12 1;
-#X connect 14 0 13 1;
+#X connect 7 0 11 0;
+#X connect 7 1 12 0;
+#X connect 11 0 0 0;
+#X connect 12 0 0 1;
+#X connect 13 0 11 1;
+#X connect 13 0 12 1;
+#X connect 15 0 7 0;
#X connect 16 0 7 0;
-#X connect 17 0 7 0;
#X restore 514 487 pd dsp-ex;
#X msg 129 156 newmsg . b Hello;
#X msg 128 124 newobj . a + 1;
@@ -118,10 +116,8 @@ patcher;
#X text 273 200 make sub patcher;
#X msg 432 198 newobj c d bang;
#X text 561 198 make object in sub patcher;
-#X text 133 12 dynamic object management \, (C)2003-2005 Thomas Grill
-;
#X text 133 30 http://grrrr.org/ext;
-#N canvas 132 483 562 540 proxies 0;
+#N canvas 132 483 566 544 proxies 0;
#X text 25 78 Instead you have to create a "real" object that;
#X text 24 94 gets the message and passes it along to the abstraction.
;
@@ -155,6 +151,8 @@ in it;
#X connect 16 0 6 0;
#X restore 626 469 pd proxies;
#X msg 128 387 send a message 1;
+#X text 133 12 dynamic object management \, (C)2003-2006 Thomas Grill
+;
#X connect 1 0 13 0;
#X connect 3 0 13 0;
#X connect 5 0 13 0;
@@ -168,4 +166,4 @@ in it;
#X connect 25 0 13 0;
#X connect 28 0 13 0;
#X connect 30 0 13 0;
-#X connect 35 0 13 0;
+#X connect 34 0 13 0;
diff --git a/externals/grill/dynext/readme.txt b/externals/grill/dynext/readme.txt
index e779840a..c3270f4f 100755
--- a/externals/grill/dynext/readme.txt
+++ b/externals/grill/dynext/readme.txt
@@ -30,6 +30,7 @@ CHANGES:
0.1.2:
- optimized DSP path (less copying, no block delay)
+- separate message and signal proxy objects to save memory
0.1.1:
- using aligned memory
@@ -69,5 +70,4 @@ CHANGES:
TODO:
--------
- add mute attribute
-- separate message and signal proxy objects to save memory
diff --git a/externals/grill/dynext/src/main.cpp b/externals/grill/dynext/src/main.cpp
index 56c55694..1baf6902 100644
--- a/externals/grill/dynext/src/main.cpp
+++ b/externals/grill/dynext/src/main.cpp
@@ -121,7 +121,6 @@ protected:
virtual bool CbMethodResort(int n,const t_symbol *s,int argc,const t_atom *argv);
virtual bool CbDsp();
- virtual void CbSignal();
// proxy object
@@ -130,15 +129,33 @@ protected:
public:
t_object obj;
dyn *th;
- int n;
- t_sample *buf;
- t_sample defsig;
void init(dyn *t)
{
th = t;
- n = 0,buf = NULL;
+ }
+ };
+
+ // 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;
}
};
@@ -147,21 +164,35 @@ protected:
public proxy
{
public:
- t_outlet *outlet;
+ void init(dyn *t)
+ {
+ proxy::init(t);
+ outlet_new(&obj,&s_anything);
+ }
void Message(const t_symbol *s,int argc,const t_atom *argv)
{
- typedmess((t_pd *)&obj,(t_symbol *)s,argc,(t_atom *)argv);
+ outlet_anything(obj.te_outlet,(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);
+ obj->Message(s,argc,argv);
}
+ };
- static void dsp(proxyin *x, t_signal **sp);
+ // 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);
};
@@ -170,30 +201,49 @@ protected:
public proxy
{
public:
- int outlet;
-
- void init(dyn *t,int o,bool s);
+ 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)
{
obj->th->ToOutAnything(obj->outlet,s,argc,argv);
}
- static void dsp(proxyout *x, t_signal **sp);
+ 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);
};
static t_class *pxin_class,*pxout_class;
static t_class *pxins_class,*pxouts_class;
- proxyin **pxin;
- proxyout **pxout;
+ 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); }
static t_object *pxins_new() { return (t_object *)pd_new(pxins_class); }
static t_object *pxout_new() { return (t_object *)pd_new(pxout_class); }
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;
@@ -261,18 +311,18 @@ void dyn::setup(t_classid c)
add_anything(pxin_class,proxyin::px_method);
// 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);
+ 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
pxout_class = class_new(const_cast<t_symbol *>(sym_dynout),(t_newmethod)pxout_new,NULL,sizeof(proxyout),0, A_NULL);
add_anything(pxout_class,proxyout::px_method);
// 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);
+ 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~
FLEXT_CADDMETHOD_(c,0,"reset",m_reset);
@@ -335,7 +385,7 @@ In all cases the 1)s have been chosen as the cleaner solution
dyn::dyn(int argc,const t_atom *argv):
canvas(NULL),
- pxin(NULL),pxout(NULL),
+ pxsin(NULL),pxmin(NULL),pxsout(NULL),pxmout(NULL),
stripext(false),symreuse(true),canvasmsg(false)
{
if(argc < 4) {
@@ -403,20 +453,27 @@ void dyn::NewProxies()
{
// --- create inlet proxies ------
int i;
- pxin = new proxyin *[s_inlets+m_inlets];
+ 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) {
- bool sig = i < s_inlets;
-
t_atom lst[5];
SetInt(lst[0],i*100);
SetInt(lst[1],10);
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);
+ 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(...) {
error("%s - Error creating inlet proxy",thisName());
@@ -425,20 +482,27 @@ void dyn::NewProxies()
// --- create outlet proxies ------
- pxout = new proxyout *[s_outlets+m_outlets];
+ 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) {
- bool sig = i < s_outlets;
-
t_atom lst[5];
SetInt(lst[0],i*100);
SetInt(lst[1],500);
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);
+ 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(...) {
error("%s - Error creating outlet proxy",thisName());
@@ -449,13 +513,21 @@ void dyn::NewProxies()
void dyn::DelProxies()
{
int i;
- if(pxin) {
- for(i = 0; i < s_inlets+m_inlets; ++i) glist_delete(canvas,(t_gobj *)pxin[i]);
- delete[] pxin;
+ 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(pxout) {
- for(i = 0; i < s_outlets+m_outlets; ++i) glist_delete(canvas,(t_gobj *)pxout[i]);
- delete[] pxout;
+ 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;
}
}
@@ -730,14 +802,14 @@ void dyn::ConnDis(bool conn,int argc,const t_atom *argv)
d_x = GetAInt(argv[2]);
}
else if(argc == 2 && CanbeInt(argv[0]) && CanbeInt(argv[1])) {
- // direct connection from proxy-in to proxy-out (for testing above all....)
+ // direct connection from proxy-in to proxy-out
s_n = NULL;
s_x = GetAInt(argv[0]);
d_n = NULL;
d_x = GetAInt(argv[1]);
}
else {
- post("%s - connect: [src] srcslot [dst] dstslot",thisName());
+ post("%s - connect: [src-name] src-slot [dst-name] dst-slot",thisName());
return;
}
@@ -757,7 +829,7 @@ void dyn::ConnDis(bool conn,int argc,const t_atom *argv)
return;
}
else {
- s_obj = &pxin[s_x]->obj;
+ 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
}
@@ -776,7 +848,7 @@ void dyn::ConnDis(bool conn,int argc,const t_atom *argv)
return;
}
else {
- d_obj = &pxout[d_x]->obj;
+ 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
}
@@ -818,7 +890,10 @@ bool dyn::CbMethodResort(int n,const t_symbol *s,int argc,const t_atom *argv)
return flext_base::m_method_(n,s,argc,argv);
else {
// all other messages are forwarded to proxies (and connected objects)
- pxin[n-1]->Message(s,argc,argv);
+ if(n >= s_inlets)
+ pxmin[n-s_inlets-1]->Message(s,argc,argv);
+ else
+ post("%s - message to signal inlet",thisName());
return true;
}
}
@@ -843,56 +918,37 @@ void dyn::m_send(int argc,const t_atom *argv)
}
}
-void dyn::proxyin::dsp(proxyin *x,t_signal **sp)
+void dyn::sigproxyin::dsp(sigproxyin *x,t_signal **sp)
{
- FLEXT_ASSERT(x->buf && x->n);
+ FLEXT_ASSERT(x->vec && x->n);
int n = sp[0]->s_n;
if(n != x->n) {
post("dyn~ proxyin - blocksize doesn't match!");
}
else
- dsp_add_copy(x->buf,sp[0]->s_vec,n);
+ dsp_add_copy(x->vec,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)
+void dyn::sigproxyout::dsp(sigproxyout *x,t_signal **sp)
{
- FLEXT_ASSERT(x->buf && x->n);
+ FLEXT_ASSERT(x->vec && x->n);
int n = sp[0]->s_n;
if(n != x->n) {
post("dyn~ proxyout - blocksize doesn't match!");
}
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);
+ dsp_add_copy(sp[0]->s_vec,x->vec,n);
}
-
bool dyn::CbDsp()
{
int n = Blocksize();
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;
+ 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 true;
+ return false;
}
-
-void dyn::CbSignal() {}