Skip to content
Snippets Groups Projects
Commit f732f3ca authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

rewrote set component of preset_node to allow for empty [set< message,...

rewrote set component of preset_node to allow for empty [set< message, adjusted and expanded documentation
parent 67cb498b
No related branches found
No related tags found
No related merge requests found
#N canvas 138 24 555 517 10;
#X obj 109 282 cnv 15 60 39 empty empty empty 20 12 0 14 -261234 -66577
#N canvas 138 24 555 616 10;
#X obj 109 282 cnv 15 60 37 empty empty empty 20 12 0 14 -261234 -66577
0;
#X obj 183 294 cnv 15 44 27 empty empty empty 20 12 0 14 -204280 -66577
0;
......@@ -45,7 +45,7 @@ to conform to the PDDP template for Pd version 0.42.;
0 %node% 2 54 0 %node% 1 21 %preset% 1 99 %preset% 2 23 %preset% 3
1001 %preset% 0 3 %node% 2 31 1 %preset% 1 problems %preset% 2 skidoo
%preset% 3 nights %preset% 0 stooges %node% 1 33 %node% 2 39 0 %node%
1 65;
1 64;
#X msg 80 125 store \$1;
#X msg 80 74 recall \$1;
#X msg 30 73 purge;
......@@ -134,9 +134,7 @@ same canvas as the abstraction:;
#X text 168 418 - reset all preset node data;
#X text 98 356 clear;
#X text 168 356 - clears preset n for all nodes;
#X text 171 515 - OPTIONAL context for this preset (defaults to "default")
;
#X obj 479 3 preset_hub %hidden% %hidden%;
#X obj 479 3 preset_hub %hidden% %node% 2 10 1;
#X obj 189 271 preset_node test;
#X floatatom 189 299 5 0 0 0 - - -;
#X msg 198 211 purge;
......@@ -146,6 +144,8 @@ same canvas as the abstraction:;
#X obj 233 300 print middle_node;
#X msg 232 244 set another;
#X msg 311 244 set test;
#X text 171 515 - OPTIONAL scope for this preset (defaults to null
or "");
#X connect 14 0 20 0;
#X connect 15 0 14 0;
#X connect 16 0 14 0;
......@@ -172,12 +172,12 @@ same canvas as the abstraction:;
#X connect 50 0 15 0;
#X connect 51 0 19 0;
#X connect 52 0 23 0;
#X connect 65 0 66 0;
#X connect 65 0 71 0;
#X connect 66 0 65 0;
#X connect 67 0 65 0;
#X connect 68 0 65 0;
#X connect 69 0 65 0;
#X connect 70 0 69 0;
#X connect 72 0 65 0;
#X connect 73 0 65 0;
#X connect 64 0 65 0;
#X connect 64 0 70 0;
#X connect 65 0 64 0;
#X connect 66 0 64 0;
#X connect 67 0 64 0;
#X connect 68 0 64 0;
#X connect 69 0 68 0;
#X connect 71 0 64 0;
#X connect 72 0 64 0;
#N canvas 438 24 555 517 10;
#N canvas 438 24 555 677 10;
#X obj 180 291 cnv 15 44 27 empty empty empty 20 12 0 14 -204280 -66577
0;
#X obj 107 279 cnv 15 60 39 empty empty empty 20 12 0 14 -261234 -66577
#X obj 107 279 cnv 15 60 37 empty empty empty 20 12 0 14 -261234 -66577
0;
#X obj 0 655 cnv 15 552 21 empty \$0-pddp.cnv.footer empty 20 12 0
14 -228856 -66577 0;
......@@ -25,7 +25,7 @@ to conform to the PDDP template for Pd version 0.42.;
0 13 -228856 -1 0;
#X obj 0 598 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 8 12
0 13 -228856 -1 0;
#X obj 78 347 cnv 3 3 140 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856
#X obj 78 347 cnv 17 3 140 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856
-162280 0;
#N canvas 102 481 428 108 Related_objects 0;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 3 12 0
......@@ -108,7 +108,14 @@ of message the connected object can output.;
#X text 98 605 Scope- [preset_hub foo] is local to its patch and all
of that patch's children (i.e. \, subpatches and abstractions).;
#X obj 98 633 pddp/pddplink preset_hub-help.pd;
#N canvas 186 308 428 292 More_info 0;
#N canvas 411 177 428 483 More_info 0;
#X obj 271 378 cnv 15 39 23 empty empty empty 20 12 0 14 -261234 -66577
0;
#X obj 275 382 hradio 15 1 0 2 empty empty empty 0 -8 0 10 -262144
-1 -1 0;
#X obj 52 378 cnv 15 36 25 empty empty empty 20 12 0 14 -261234 -66577
0;
#X msg 58 382 set;
#X obj 30 165 cnv 15 349 98 empty \$0-pddp.cnv.subheading empty 3 12
0 14 -191407 -1 0;
#X obj 31 166 cnv 15 347 96 empty \$0-pddp.cnv.subheading empty 3 12
......@@ -128,6 +135,31 @@ same canvas as the abstraction:;
#X text 168 205 inside it.;
#X text 40 171 [preset_hub foo] <-- this won't apply to [bar] because
;
#X obj 52 430 cnv 15 44 27 empty empty empty 20 12 0 14 -204280 -66577
0;
#X msg 213 406 store \$1;
#X obj 213 382 hradio 15 1 0 2 empty empty empty 0 -8 0 10 -262144
-1 -1 1;
#X msg 275 406 recall \$1;
#X msg 92 382 set some_scope;
#X obj 58 407 preset_node some_scope;
#X obj 213 433 preset_hub %hidden% %node% 2 60 17 %preset% 0 50 %preset%
1 100 %node% 2 60 19 %preset% 0 50 %preset% 1 100;
#X floatatom 58 435 5 0 0 0 - - -;
#X text 19 275 Setting node scope via "set" message allows for dynamic
scope switching. If you wish to set it to the default (also known as
null or "") scope \, you should use empty "set" message. Notice in
the example below how hub recall does not work until you click on the
"set" message which sets scope node to null as is the case with the
hub.;
#X connect 1 0 17 0;
#X connect 3 0 19 0;
#X connect 15 0 20 0;
#X connect 16 0 15 0;
#X connect 17 0 20 0;
#X connect 18 0 19 0;
#X connect 19 0 21 0;
#X connect 21 0 19 0;
#X restore 459 610 pd More_info;
#X text 168 386 - purge all orphaned/unused nodes (forwarded to hub)
;
......@@ -144,8 +176,6 @@ hub);
#X text 98 346 clear;
#X text 168 346 - clear this node data at preset n (forwarded to hub)
;
#X text 171 565 - OPTIONAL context for this preset (defaults to "default")
;
#X text 98 447 set;
#X text 168 447 - change context (hub) node is paired with;
#X msg 229 242 set another;
......@@ -153,6 +183,8 @@ hub);
#X obj 380 293 cnv 15 44 27 empty empty empty 20 12 0 14 -204280 -66577
0;
#X floatatom 386 298 5 0 0 0 - - -;
#X text 171 565 - OPTIONAL scope for this preset (defaults to null
or "");
#X connect 16 0 25 0;
#X connect 17 0 16 0;
#X connect 18 0 16 0;
......@@ -178,13 +210,13 @@ hub);
#X connect 39 0 41 0;
#X connect 40 0 39 0;
#X connect 41 0 42 0;
#X connect 44 0 77 0;
#X connect 44 0 76 0;
#X connect 46 0 47 0;
#X connect 47 0 46 0;
#X connect 47 0 50 0;
#X connect 48 0 47 0;
#X connect 49 0 47 0;
#X connect 51 0 47 0;
#X connect 73 0 26 0;
#X connect 74 0 26 0;
#X connect 75 0 26 0;
#X connect 77 0 44 0;
#X connect 76 0 44 0;
......@@ -543,14 +543,14 @@ void preset_node_purge(t_preset_node *x) {
//==================== end functions are for interaction with the hub =====================//
static void preset_node_set(t_preset_node *x, t_symbol *s)
static void preset_node_set(t_preset_node *x, t_symbol *s, int argc, t_atom *argv)
{
if(PH_DEBUG) fprintf(stderr,"preset_node_set %s\n", s->s_name);
if(PH_DEBUG) fprintf(stderr,"preset_node_set %d\n", argc);
if (!strcmp(s->s_name, "default"))
x->pn_hub_name = &s_;
if (argc == 0)
x->pn_hub_name = &s_;
else
x->pn_hub_name = s;
x->pn_hub_name = (t_symbol *)atom_getsymbol(&argv[0]);
if (x->pn_hub) {
preset_hub_delete_a_node(x->pn_hub, x);
......@@ -561,11 +561,6 @@ static void preset_node_set(t_preset_node *x, t_symbol *s)
preset_node_seek_hub(x);
}
static void preset_node_set_null(t_preset_node *x)
{
preset_node_set(x, &s_);
}
static void *preset_node_new(t_symbol *s, int argc, t_atom *argv)
{
if(PH_DEBUG) fprintf(stderr,"===preset_node_new===\n");
......@@ -574,7 +569,7 @@ static void *preset_node_new(t_symbol *s, int argc, t_atom *argv)
t_preset_node *x = (t_preset_node *)pd_new(preset_node_class);
// read creation arguments and substitute "default" for objects without optional arguments
// read creation arguments and substitute default for objects without optional arguments
if (!(argc > 0 && argv[0].a_type == A_SYMBOL))
x->pn_hub_name = &s_;
else
......@@ -641,7 +636,7 @@ void preset_node_setup(void)
class_addmethod(preset_node_class, (t_method)preset_node_request_hub_store,
gensym("store"), A_DEFFLOAT, 0);
class_addmethod(preset_node_class, (t_method)preset_node_set,
gensym("set"), A_SYMBOL, 0);
gensym("set"), A_GIMME, 0);
class_addmethod(preset_node_class, (t_method)preset_node_clear,
gensym("clear"), A_DEFFLOAT, 0);
......@@ -1166,11 +1161,15 @@ static void *preset_hub_new(t_symbol *s, int argc, t_atom *argv)
loc_pos = 0;
pos = 0; // position within argc
// read creation arguments and substitute "default" for objects without optional arguments
if (!(argc > 0 && argv[0].a_type == A_SYMBOL))
// read creation arguments and substitute default for objects without optional arguments
if (!(argc > 0 && argv[0].a_type == A_SYMBOL) ||
(argc > 0 && argv[0].a_type == A_SYMBOL && !strcmp(atom_getsymbol(&argv[0])->s_name, "%hidden%"))) {
pos--; // we subtract one position as we are essentially missing one argument
name = &s_;
else
}
else {
name = (t_symbol *)atom_getsymbol(&argv[0]);
}
// now check if there is already another hub on the same canvas with the same name and fail if so
check = canvas->gl_phub;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment