aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/dyn/dyn_proxy.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2004-10-27 18:19:51 +0000
committerThomas Grill <xovo@users.sourceforge.net>2004-10-27 18:19:51 +0000
commit1471f1a6b3cf6169c6aae49f2cef643bc3c3c872 (patch)
tree50ae6f3e94d60b611cfd9f6cdad98b7eed180645 /externals/grill/dyn/dyn_proxy.cpp
parent89ca5ec0c49ae8923a206668ef9284257c56a104 (diff)
fixes for dsp and abstraction inlets
a few fixes dyn documentation more functionality only one dyn_id type for clarity better interface for listeners dyn_Finish instead of dyn_Flush all the major things are working in dyn! OSX checkin name changes for svn repository small fixes doesn't really work, but should compile dyn python module checkin now able to have real root patchers initial coding a few more things deleted test/mar patches (moved to /doc branch) dyn SWIG module dyn additions a _few_ changes in UIUI, establishing node groups made API headers monolithic first working dyn! updated todo list svn path=/trunk/; revision=2173
Diffstat (limited to 'externals/grill/dyn/dyn_proxy.cpp')
-rw-r--r--externals/grill/dyn/dyn_proxy.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/externals/grill/dyn/dyn_proxy.cpp b/externals/grill/dyn/dyn_proxy.cpp
new file mode 100644
index 00000000..f2b85a91
--- /dev/null
+++ b/externals/grill/dyn/dyn_proxy.cpp
@@ -0,0 +1,96 @@
+/*
+dyn - dynamical object management
+
+Copyright (c)2003-2004 Thomas Grill (gr@grrrr.org)
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+*/
+
+#include "dyn_proto.h"
+
+// proxy
+
+void proxy::px_exit(proxy *px)
+{
+ if(px->buf) FreeAligned(px->buf);
+}
+
+
+// proxyin
+
+void proxyin::init(dyn_patchable *obj,bool s)
+{
+ proxy::init(obj);
+ outlet = outlet_new(&pdobj,s?&s_signal:&s_anything);
+}
+
+void proxyin::px_method(proxyin *th,const t_symbol *s,int argc,const t_atom *argv)
+{
+ // send to connected object
+ outlet_anything(th->outlet,(t_symbol *)s,argc,(t_atom *)argv);
+}
+
+void proxyin::dsp(proxyin *x, t_signal **sp)
+{
+ int n = sp[0]->s_n;
+ if(n != x->n) {
+ // if vector size has changed make new buffer
+ if(x->buf) FreeAligned(x->buf);
+ x->buf = (t_sample *)NewAligned(sizeof(t_sample)*(x->n = n));
+ }
+ dsp_add_copy(x->buf,sp[0]->s_vec,n);
+}
+
+
+// proxyout
+
+void proxyout::init(dyn_patchable *obj,int o,bool s)
+{
+ proxy::init(obj);
+ listeners = new Listeners;
+ outlet = o;
+ if(s) outlet_new(&pdobj,&s_signal);
+}
+
+void proxyout::exit()
+{
+ // invalidate all listeners
+ for(Listeners::const_iterator it = listeners->begin(); it != listeners->end(); ++it)
+ Destroy(*it);
+ // delete container
+ delete listeners;
+}
+
+void proxyout::Rmv(proxyout *px,dyn_listen *l)
+{
+ px->listeners->erase(l);
+
+ // if there are no more listeners we can delete the object!
+ if(px->listeners->empty()) {
+ dyn_patcher *p = px->object->owner;
+
+ // remove reference
+ px->object->RmvProxyOut(px->outlet);
+
+ // delete PD object
+ glist_delete(p->glist(),(t_gobj *)px);
+ }
+}
+
+void proxyout::px_method(proxyout *th,const t_symbol *s,int argc,const t_atom *argv)
+{
+ // call attached responders
+ for(Listeners::const_iterator it = th->listeners->begin(); it != th->listeners->end(); ++it)
+ (*it)->Callback(th->outlet,s,argc,argv);
+}
+
+void proxyout::dsp(proxyout *x, t_signal **sp)
+{
+ int n = sp[0]->s_n;
+ if(n != x->n) {
+ // if vector size has changed make new buffer
+ if(x->buf) FreeAligned(x->buf);
+ x->buf = (t_sample *)NewAligned(sizeof(t_sample)*(x->n = n));
+ }
+ dsp_add_copy(sp[0]->s_vec,x->buf,n);
+}