aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/dyn
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/dyn')
-rw-r--r--externals/grill/dyn/pd/help-dyn~.pd (renamed from externals/grill/dyn/pd/dyn~.pd)275
-rw-r--r--externals/grill/dyn/readme.txt1
-rw-r--r--externals/grill/dyn/src/main.cpp87
3 files changed, 198 insertions, 165 deletions
diff --git a/externals/grill/dyn/pd/dyn~.pd b/externals/grill/dyn/pd/help-dyn~.pd
index 8ec75d9c..61d9e572 100644
--- a/externals/grill/dyn/pd/dyn~.pd
+++ b/externals/grill/dyn/pd/help-dyn~.pd
@@ -1,137 +1,138 @@
-#N canvas 351 22 757 583 12;
-#N canvas 41 57 576 675 examples 0;
-#X floatatom 153 276 5 0 0 0 - - -;
-#X floatatom 110 353 5 0 0 0 - - -;
-#X floatatom 111 576 5 0 0 0 - - -;
-#X obj 256 315 +;
-#X floatatom 257 350 5 0 0 0 - - -;
-#X floatatom 153 498 5 0 0 0 - - -;
-#X floatatom 242 499 5 0 0 0 - - -;
-#X floatatom 304 497 5 0 0 0 - - -;
-#X obj 259 543 * 2;
-#X obj 301 544 + 1;
-#X floatatom 268 574 5 0 0 0 - - -;
-#X floatatom 261 275 5 0 0 0 - - -;
-#X floatatom 224 72 5 0 0 0 - - -;
-#X floatatom 100 155 5 0 0 0 - - -;
-#X floatatom 239 152 5 0 0 0 - - -;
-#X obj 238 117 f;
-#X obj 101 117 dyn~ 0 1 0 1;
-#X obj 111 315 dyn~ 0 2 0 1;
-#X obj 111 543 dyn~ 0 3 0 1;
-#X msg 36 34 reset \, newobj . a f \, conn 0 a 0 \, conn a 0 0;
-#X msg 42 234 reset \, newobj . a + \, conn 0 a 0 \, conn 1 a 1 \,
-conn a 0 0;
-#X msg 35 443 reset \, newobj . a * 2 \, newobj . b + 1 \, conn 0 a
-0 \, conn 1 a 1 \, conn a 0 b 0 \, conn 2 b 1 \, conn b 0 0;
-#X connect 0 0 3 0;
-#X connect 0 0 17 1;
-#X connect 3 0 4 0;
-#X connect 5 0 8 0;
-#X connect 5 0 18 1;
-#X connect 6 0 8 1;
-#X connect 6 0 18 2;
-#X connect 7 0 9 1;
-#X connect 7 0 18 3;
-#X connect 8 0 9 0;
-#X connect 9 0 10 0;
-#X connect 11 0 3 1;
-#X connect 11 0 17 2;
-#X connect 12 0 15 0;
-#X connect 12 0 16 1;
-#X connect 15 0 14 0;
-#X connect 16 0 13 0;
-#X connect 17 0 1 0;
-#X connect 18 0 2 0;
-#X connect 19 0 16 0;
-#X connect 20 0 17 0;
-#X connect 21 0 18 0;
-#X restore 514 459 pd examples;
-#X msg 127 70 reset;
-#X text 184 70 clear all objects and connections;
-#X msg 129 231 conn 0 a 0;
-#X text 224 230 connect dyn-inlet 0 to a-inlet 0;
-#X msg 129 260 conn a 0 0;
-#X text 224 259 connect a-outlet 0 to dyn-outlet 0;
-#X msg 129 293 conn x 2 y 3;
-#X text 234 292 connect x-outlet 2 to y-inlet 3;
-#X msg 129 356 del a;
-#X text 181 358 delete object "a";
-#X obj 11 10 cnv 15 600 40 empty empty dyn~ 10 22 0 24 -260818 -1 0
-;
-#X text 133 32 http://www.parasitaere-kapazitaeten.net;
-#X text 133 12 dynamic object management \, (C)2003 Thomas Grill;
-#X msg 128 387 send a message 1;
-#X text 270 387 send "message 1" to a-inlet 0;
-#X obj 54 468 dyn~ 0 1 0 2;
-#X text 156 467 dyn sig/msg inlets sig/msg outlets;
-#X msg 165 421 vis \$1;
-#X obj 129 421 tgl 20 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
-1;
-#X text 222 417 make patch visible/invisible;
-#X msg 129 323 dis x 2 y 3;
-#X text 234 324 disconnect x-outlet 2 to y-inlet 3;
-#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 574 430 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 5200 1;
-#X obj 194 282 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -6 0 10
--262144 -1 -1 409.449 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 8800 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
-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 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;
-#X text 247 124 make new object [+ 1] with name "a" in root patcher
-(".");
-#X text 269 156 make new message object [Hello( with name "b" in root
-patcher;
-#X msg 128 200 newobj . c pd sub;
-#X text 273 200 make sub patcher;
-#X msg 425 198 newobj c d bang;
-#X text 561 198 make object in sub patcher;
-#X connect 1 0 16 0;
-#X connect 3 0 16 0;
-#X connect 5 0 16 0;
-#X connect 7 0 16 0;
-#X connect 9 0 16 0;
-#X connect 14 0 16 0;
-#X connect 18 0 16 0;
-#X connect 19 0 18 0;
-#X connect 21 0 16 0;
-#X connect 24 0 16 0;
-#X connect 27 0 16 0;
-#X connect 28 0 16 0;
-#X connect 31 0 16 0;
-#X connect 33 0 16 0;
+#N canvas 81 25 813 532 12;
+#N canvas 71 10 550 557 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 - - -;
+#X obj 251 273 +;
+#X floatatom 252 301 5 0 0 0 - - -;
+#X floatatom 155 423 5 0 0 0 - - -;
+#X floatatom 244 424 5 0 0 0 - - -;
+#X floatatom 306 422 5 0 0 0 - - -;
+#X obj 261 468 * 2;
+#X obj 303 469 + 1;
+#X floatatom 270 499 5 0 0 0 - - -;
+#X floatatom 256 238 5 0 0 0 - - -;
+#X floatatom 224 72 5 0 0 0 - - -;
+#X floatatom 98 136 5 0 0 0 - - -;
+#X floatatom 237 133 5 0 0 0 - - -;
+#X obj 236 107 f;
+#X obj 99 107 dyn~ 0 1 0 1;
+#X obj 106 273 dyn~ 0 2 0 1;
+#X obj 113 468 dyn~ 0 3 0 1;
+#X msg 37 36 reset \, newobj . a f \, conn 0 a 0 \, conn a 0 0;
+#X msg 37 197 reset \, newobj . a + \, conn 0 a 0 \, conn 1 a 1 \,
+conn a 0 0;
+#X msg 37 368 reset \, newobj . a * 2 \, newobj . b + 1 \, conn 0 a
+0 \, conn 1 a 1 \, conn a 0 b 0 \, conn 2 b 1 \, conn b 0 0;
+#X connect 0 0 3 0;
+#X connect 0 0 17 1;
+#X connect 3 0 4 0;
+#X connect 5 0 8 0;
+#X connect 5 0 18 1;
+#X connect 6 0 8 1;
+#X connect 6 0 18 2;
+#X connect 7 0 9 1;
+#X connect 7 0 18 3;
+#X connect 8 0 9 0;
+#X connect 9 0 10 0;
+#X connect 11 0 3 1;
+#X connect 11 0 17 2;
+#X connect 12 0 15 0;
+#X connect 12 0 16 1;
+#X connect 15 0 14 0;
+#X connect 16 0 13 0;
+#X connect 17 0 1 0;
+#X connect 18 0 2 0;
+#X connect 19 0 16 0;
+#X connect 20 0 17 0;
+#X connect 21 0 18 0;
+#X restore 514 459 pd examples;
+#X msg 127 70 reset;
+#X text 184 70 clear all objects and connections;
+#X msg 129 231 conn 0 a 0;
+#X text 224 230 connect dyn-inlet 0 to a-inlet 0;
+#X msg 129 260 conn a 0 0;
+#X text 224 259 connect a-outlet 0 to dyn-outlet 0;
+#X msg 129 293 conn x 2 y 3;
+#X text 234 292 connect x-outlet 2 to y-inlet 3;
+#X msg 129 356 del a;
+#X text 181 358 delete object "a";
+#X obj 11 10 cnv 15 700 40 empty empty dyn~ 10 22 0 24 -260818 -1 0
+;
+#X text 133 32 http://www.parasitaere-kapazitaeten.net;
+#X msg 128 387 send a message 1;
+#X text 270 387 send "message 1" to a-inlet 0;
+#X obj 54 468 dyn~ 0 1 0 2;
+#X text 156 467 dyn sig/msg inlets sig/msg outlets;
+#X msg 165 421 vis \$1;
+#X obj 129 421 tgl 20 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X text 222 417 make patch visible/invisible;
+#X msg 129 323 dis x 2 y 3;
+#X text 234 324 disconnect x-outlet 2 to y-inlet 3;
+#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 578 434 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
+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 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;
+#X text 247 124 make new object [+ 1] with name "a" in root patcher
+(".");
+#X text 269 156 make new message object [Hello( with name "b" in root
+patcher;
+#X msg 128 200 newobj . c pd sub;
+#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-2004 Thomas Grill
+;
+#X connect 1 0 15 0;
+#X connect 3 0 15 0;
+#X connect 5 0 15 0;
+#X connect 7 0 15 0;
+#X connect 9 0 15 0;
+#X connect 13 0 15 0;
+#X connect 17 0 15 0;
+#X connect 18 0 17 0;
+#X connect 20 0 15 0;
+#X connect 23 0 15 0;
+#X connect 26 0 15 0;
+#X connect 27 0 15 0;
+#X connect 30 0 15 0;
+#X connect 32 0 15 0;
diff --git a/externals/grill/dyn/readme.txt b/externals/grill/dyn/readme.txt
index 116e27d3..2942d4e6 100644
--- a/externals/grill/dyn/readme.txt
+++ b/externals/grill/dyn/readme.txt
@@ -41,6 +41,7 @@ CHANGES:
0.1.1:
- using aligned memory
+- cached several symbols
0.1.0:
- first release: PD 0.37 supports all necessary functionality
diff --git a/externals/grill/dyn/src/main.cpp b/externals/grill/dyn/src/main.cpp
index 4447d7a4..34b2f7bf 100644
--- a/externals/grill/dyn/src/main.cpp
+++ b/externals/grill/dyn/src/main.cpp
@@ -166,6 +166,9 @@ private:
FLEXT_CALLBACK_V(m_disconnect)
FLEXT_CALLBACK_V(m_send)
FLEXT_CALLBACK_B(m_vis)
+
+ static const t_symbol *sym_dot,*sym_dynsin,*sym_dynsout,*sym_dynin,*sym_dynout,*sym_dyncanvas;
+ static const t_symbol *sym_vis,*sym_loadbang,*sym_dsp;
};
FLEXT_NEW_DSP_V("dyn~",dyn)
@@ -178,28 +181,47 @@ const t_symbol *dyn::k_obj = NULL;
const t_symbol *dyn::k_msg = NULL;
const t_symbol *dyn::k_text = NULL;
+const t_symbol *dyn::sym_dot = NULL;
+const t_symbol *dyn::sym_dynsin = NULL;
+const t_symbol *dyn::sym_dynsout = NULL;
+const t_symbol *dyn::sym_dynin = NULL;
+const t_symbol *dyn::sym_dynout = NULL;
+const t_symbol *dyn::sym_dyncanvas = NULL;
+
+const t_symbol *dyn::sym_vis = NULL;
+const t_symbol *dyn::sym_loadbang = NULL;
+const t_symbol *dyn::sym_dsp = NULL;
+
void dyn::setup(t_classid c)
{
post("");
- post("dyn~ %s - dynamic object management, (C)2003 Thomas Grill",DYN_VERSION);
+ post("dyn~ %s - dynamic object management, (C)2003-2004 Thomas Grill",DYN_VERSION);
post("");
+ sym_dynsin = MakeSymbol("dyn_in~");
+ sym_dynsout = MakeSymbol("dyn_out~");
+ sym_dynin = MakeSymbol("dyn_in");
+ sym_dynout = MakeSymbol("dyn_out");
+
+ sym_dot = MakeSymbol(".");
+ sym_dyncanvas = MakeSymbol(" dyn~-canvas ");
+
// set up proxy class for inbound messages
- pxin_class = class_new(gensym("dyn_in"),(t_newmethod)pxin_new,(t_method)proxy::px_exit,sizeof(proxyin),0, A_NULL);
+ pxin_class = class_new(const_cast<t_symbol *>(sym_dynin),(t_newmethod)pxin_new,(t_method)proxy::px_exit,sizeof(proxyin),0, A_NULL);
add_anything(pxin_class,proxyin::px_method);
// set up proxy class for inbound signals
- pxins_class = class_new(gensym("dyn_in~"),(t_newmethod)pxins_new,(t_method)proxy::px_exit,sizeof(proxyin),0, A_NULL);
+ pxins_class = class_new(const_cast<t_symbol *>(sym_dynsin),(t_newmethod)pxins_new,(t_method)proxy::px_exit,sizeof(proxyin),0, A_NULL);
add_dsp(pxins_class,proxyin::dsp);
CLASS_MAINSIGNALIN(pxins_class, proxyin, defsig);
// set up proxy class for outbound messages
- pxout_class = class_new(gensym("dyn_out"),(t_newmethod)pxout_new,(t_method)proxy::px_exit,sizeof(proxyout),0, A_NULL);
+ pxout_class = class_new(const_cast<t_symbol *>(sym_dynout),(t_newmethod)pxout_new,(t_method)proxy::px_exit,sizeof(proxyout),0, A_NULL);
add_anything(pxout_class,proxyout::px_method);
// set up proxy class for outbound signals
- pxouts_class = class_new(gensym("dyn_out~"),(t_newmethod)pxouts_new,(t_method)proxy::px_exit,sizeof(proxyout),0, A_NULL);
+ pxouts_class = class_new(const_cast<t_symbol *>(sym_dynsout),(t_newmethod)pxouts_new,(t_method)proxy::px_exit,sizeof(proxyout),0, A_NULL);
add_dsp(pxouts_class,proxyout::dsp);
CLASS_MAINSIGNALIN(pxouts_class, proxyout, defsig);
@@ -219,6 +241,10 @@ void dyn::setup(t_classid c)
k_obj = MakeSymbol("obj");
k_msg = MakeSymbol("msg");
k_text = MakeSymbol("text");
+
+ sym_vis = MakeSymbol("vis");
+ sym_loadbang = MakeSymbol("loadbang");
+ sym_dsp = MakeSymbol("dsp");
}
@@ -279,7 +305,7 @@ dyn::dyn(int argc,const t_atom *argv):
SetInt(arg[1],0); // ypos
SetInt(arg[2],700); // xwidth
SetInt(arg[3],520); // xwidth
- SetString(arg[4]," dyn~-canvas "); // canvas name
+ SetSymbol(arg[4],sym_dyncanvas); // canvas name
SetInt(arg[5],0); // visible
canvas = canvas_new(NULL, NULL, 6, arg);
@@ -295,9 +321,9 @@ dyn::dyn(int argc,const t_atom *argv):
t_atom lst[5];
SetInt(lst[0],i*100);
SetInt(lst[1],10);
- SetString(lst[2],".");
- SetString(lst[3],"");
- SetString(lst[4],sig?"dyn_in~":"dyn_in");
+ 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);
@@ -317,9 +343,9 @@ dyn::dyn(int argc,const t_atom *argv):
t_atom lst[5];
SetInt(lst[0],i*100);
SetInt(lst[1],500);
- SetString(lst[2],".");
- SetString(lst[3],"");
- SetString(lst[4],sig?"dyn_out~":"dyn_out");
+ 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);
@@ -360,7 +386,7 @@ dyn::obj *dyn::Find(const t_symbol *n)
t_glist *dyn::FindCanvas(const t_symbol *n)
{
- if(n == MakeSymbol("."))
+ if(n == sym_dot)
return canvas;
else {
obj *o = Find(n);
@@ -385,8 +411,10 @@ void dyn::Delete(t_gobj *o)
static t_gobj *GetLast(t_glist *gl)
{
- t_gobj *go;
- for (go = gl->gl_list; go->g_next; go = go->g_next);
+ t_gobj *go = gl->gl_list;
+ if(go)
+ while(go->g_next)
+ go = go->g_next;
return go;
}
@@ -422,7 +450,7 @@ t_gobj *dyn::New(const t_symbol *kind,int _argc_,const t_atom *_argv_,bool add)
}
if(argv) {
- if(add && (!name || name == MakeSymbol(".") || Find(name)))
+ if(add && (!name || name == sym_dot || Find(name)))
err = "Object name is already present";
else if(!canv || !(glist = FindCanvas(canv)))
err = "Canvas could not be found";
@@ -430,24 +458,27 @@ t_gobj *dyn::New(const t_symbol *kind,int _argc_,const t_atom *_argv_,bool add)
// set selected canvas as current
canvas_setcurrent(glist);
- pd_typedmess((t_pd *)glist,(t_symbol *)kind,argc,(t_atom *)argv);
+ t_gobj *last = GetLast(glist);
+ pd_typedmess((t_pd *)glist,(t_symbol *)kind,argc,argv);
+ newest = GetLast(glist);
if(kind == k_obj) {
t_object *o = (t_object *)pd_newest();
- newest = o?&o->te_g:NULL;
- if(!newest) {
+ if(!o) {
// PD creates a text object when the intended object could not be created
t_gobj *trash = GetLast(glist);
- // TODO: Test for it....
-
- // Delete it!
- Delete(trash);
+ // Test for newly created object....
+ if(trash && last != trash) {
+ // Delete it!
+ glist_delete(glist,trash);
+ }
+ newest = NULL;
}
+ else
+ newest = &o->te_g;
}
- else
- newest = GetLast(glist);
// look for latest created object
if(newest) {
@@ -457,10 +488,10 @@ t_gobj *dyn::New(const t_symbol *kind,int _argc_,const t_atom *_argv_,bool add)
// send loadbang (if it is an abstraction)
if(pd_class(&newest->g_pd) == canvas_class) {
// hide the sub-canvas
- pd_vmess((t_pd *)newest,gensym("vis"),"i",0);
+ pd_vmess((t_pd *)newest,const_cast<t_symbol *>(sym_vis),"i",0);
// loadbang the abstraction
- pd_vmess((t_pd *)newest,gensym("loadbang"),"");
+ pd_vmess((t_pd *)newest,const_cast<t_symbol *>(sym_loadbang),"");
}
// restart dsp - that's necessary because ToCanvas is called manually
@@ -727,7 +758,7 @@ void dyn::proxyout::init(dyn *t,int o,bool s)
void dyn::m_dsp(int n,t_signalvec const *insigs,t_signalvec const *outsigs)
{
// add sub canvas to dsp list (no signal vector to borrow from .. set it to NULL)
- mess1((t_pd *)canvas, gensym("dsp"),NULL);
+ mess1((t_pd *)canvas,const_cast<t_symbol *>(sym_dsp),NULL);
flext_dsp::m_dsp(n,insigs,outsigs);
}