aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--help/param-help.pd126
-rw-r--r--src/param.c60
-rw-r--r--src/tof.h43
3 files changed, 131 insertions, 98 deletions
diff --git a/help/param-help.pd b/help/param-help.pd
index bdf0714..7337060 100644
--- a/help/param-help.pd
+++ b/help/param-help.pd
@@ -1,5 +1,5 @@
#N canvas 1024 24 1018 688 10;
-#X floatatom 477 321 5 0 0 0 - - -;
+#X floatatom 504 237 5 0 0 0 - - -;
#X obj -23 2 cnv 15 400 100 empty empty empty 20 12 0 14 -249661 -66577
0;
#X text -18 54 author: mrtoftrash@gmail.com;
@@ -7,15 +7,13 @@
system.;
#X text -19 75 version: 2009-09-19 (localized release);
#X text -19 33 tags: state routing param;
-#X text 3 389 /id keyword:;
#X text 179 122 argument 1: param name (must start with a slash);
-#X text 179 139 argument 2...: param value (can be a list);
-#X text 585 115 nbx: creates a numberbox;
-#X text 584 134 slider min max: creates a slider with the indicated
+#X text 612 141 nbx: creates a numberbox;
+#X text 611 160 slider min max: creates a slider with the indicated
minimum and maximum;
-#X text 584 163 bng: creates a bang;
-#X text 584 181 tgl: creates a toggle;
-#X text 586 199 symbolatom: creates a symbol box;
+#X text 611 189 bng: creates a bang;
+#X text 611 207 tgl: creates a toggle;
+#X text 613 225 symbolatom: creates a symbol box;
#X text 68 355 (\$0)/abstraction's name/.../param's name;
#X text 5 210 If the param object is created directly in the root patch
(as the my_name example above) \, its path is as follows:;
@@ -26,74 +24,72 @@ data can be accessed through a unique symbolic path.;
contained inside another abstraction an so forth) \, the path starts
at the root and follows every child patch (abstraction) until it reaches
the param object \, at which point the param's name is appended:;
-#X text 128 592 Sends values to params using a relative path.;
#X text 40 414 If an abstraction's arguments contains the "/id" keyword
\, the symbol following the "/id" keyword \, instead of the abstraction's
name \, will be used to build the path. See an example to the right.
;
-#X obj 557 599 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
--1 -1;
-#X obj 33 519 bng 15 250 50 0 empty empty save 17 7 0 10 -262144 -1
--1;
-#X obj 99 518 bng 15 250 50 0 empty empty load 17 7 0 10 -262144 -1
--1;
-#X floatatom 529 84 5 0 0 0 - - -;
-#X obj 555 519 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
--1 -1;
-#X obj 555 569 print DUMP;
-#X text 268 490 --------------------- SEE ALSO -----------------------
+#X floatatom 556 110 5 0 0 0 - - -;
+#X text 53 585 --------------------- SEE ALSO -----------------------
;
-#X obj 472 448 dac~;
-#X obj 690 364 hsl 100 15 0 1 0 0 \$0/FM_MOD/volume \$0/FM_MOD/volume_
-/FM_MOD/volume 105 7 0 10 -262144 -1 -1 2884 1;
-#X obj 690 384 hsl 100 15 200 2000 0 0 \$0/FM_MOD/carrier \$0/FM_MOD/carrier_
+#X obj 496 359 dac~;
+#X obj 717 280 hsl 100 15 0 1 0 0 \$0/FM_MOD/volume \$0/FM_MOD/volume_
+/FM_MOD/volume 105 7 0 10 -262144 -1 -1 0 1;
+#X obj 717 300 hsl 100 15 200 2000 0 0 \$0/FM_MOD/carrier \$0/FM_MOD/carrier_
/FM_MOD/carrier 105 7 0 10 -262144 -1 -1 2200 1;
-#X obj 688 423 nbx 5 14 -1e+37 1e+37 0 0 \$0/FM_MOD/modulation/index
+#X obj 715 339 nbx 5 14 -1e+37 1e+37 0 0 \$0/FM_MOD/modulation/index
\$0/FM_MOD/modulation/index_ /FM_MOD/modulation/index 57 7 0 10 -262144
--1 -1 10 256;
-#X obj 688 404 nbx 5 14 -1e+37 1e+37 0 0 \$0/FM_MOD/modulation/freq
+-1 -1 20 256;
+#X obj 715 320 nbx 5 14 -1e+37 1e+37 0 0 \$0/FM_MOD/modulation/freq
\$0/FM_MOD/modulation/freq_ /FM_MOD/modulation/freq 57 7 0 10 -262144
-1 -1 3 256;
-#X obj 517 367 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144
--1 -1 3700 1;
-#X text 650 542 Outputs all children params of the root patch.;
-#X text 121 539 Saves and restores all chilren params of the root patch
-to/from a file with optionnal presets.;
-#X text 636 617 Build a PD gui for all children params that have values
-for the "/gui" keyword.;
-#X text 124 617 Routes OSC messages to matching children params;
-#X obj 529 58 tof/param /number 30 /g nbx;
-#X obj 33 546 tof/paramFile;
-#X obj 32 592 tof/paramRoute;
-#X obj 30 619 tof/OSCToParam;
-#X obj 555 541 tof/paramDump;
-#X obj 557 620 tof/paramGui;
+#X obj 544 283 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144
+-1 -1 0 1;
+#X obj 556 84 tof/param /number 30 /g nbx;
+#X obj 22 613 tof/paramFile;
+#X obj 118 613 tof/paramRoute;
+#X obj 217 613 tof/OSCToParam;
+#X obj 322 613 tof/paramDump;
+#X obj 25 637 tof/paramGui;
#X obj -10 149 print loadbang;
#X obj -10 125 tof/param /my_name my_value;
-#X text 526 100 /g options:;
-#X text 529 13 When you create a param \, you can optinally use the
+#X text 553 126 /g options:;
+#X text 556 44 When you create a param \, you can optinally use the
"/g" keyword to flag the param with gui options.;
-#X text 484 1 /g keyword:;
-#X text 500 224 /nlb keyword:;
-#X obj 477 414 param-abs /id FM_MOD /carrier 600;
-#X floatatom 644 312 5 0 0 0 - - -;
-#X obj 644 289 tof/param /test 50 /nlb;
-#X text 531 246 A param automatically ouputs its value when it is created.
+#X obj 504 330 param-abs /id FM_MOD /carrier 600;
+#X floatatom 613 531 5 0 0 0 - - -;
+#X obj 613 508 tof/param /test 50 /nlb;
+#X text 500 465 A param automatically ouputs its value when it is created.
You can disable this behavior with the "/nlb" (no loadbang) keyword.
;
-#X msg 477 343 /modulation/index \$1;
-#X msg 514 389 /volume \$1;
-#X connect 0 0 54 0;
-#X connect 21 0 43 0;
-#X connect 22 0 39 0;
-#X connect 23 0 39 1;
-#X connect 25 0 42 0;
-#X connect 33 0 55 0;
-#X connect 38 0 24 0;
-#X connect 42 0 26 0;
-#X connect 45 0 44 0;
-#X connect 50 0 28 0;
-#X connect 50 0 28 1;
-#X connect 52 0 51 0;
-#X connect 54 0 50 0;
-#X connect 55 0 50 0;
+#X msg 504 259 /modulation/index \$1;
+#X msg 541 305 /volume \$1;
+#X text 179 139 argument 2...: param value (can be anything;
+#X text 3 389 Abstraction /id:;
+#X text 498 27 /g keyword: GUI options;
+#X text 466 393 /ns keyword: No save;
+#X text 469 443 /nlb keyword: No loadbang;
+#X text 497 415 This param will never be saved.;
+#X text 179 155 argument ...: special keywords;
+#X text 544 8 ----------------- SPECIAL KEYWORDS -------------------
+;
+#X text 475 557 /wfb keyword: Wait for bang;
+#X text 507 579 This param will only output its contents on a bang.
+;
+#X obj 614 393 tof/param /nope 50 /ns;
+#X obj 500 629 tof/param /waiting 50 /wfb;
+#X floatatom 500 602 5 0 0 0 - - -;
+#X floatatom 500 652 5 0 0 0 - - -;
+#X obj 544 605 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
+-1 -1;
+#X connect 0 0 40 0;
+#X connect 25 0 41 0;
+#X connect 26 0 18 0;
+#X connect 33 0 32 0;
+#X connect 36 0 20 0;
+#X connect 36 0 20 1;
+#X connect 38 0 37 0;
+#X connect 40 0 36 0;
+#X connect 41 0 36 0;
+#X connect 53 0 55 0;
+#X connect 54 0 53 0;
+#X connect 56 0 53 0;
diff --git a/src/param.c b/src/param.c
index 2aab6aa..0d29ac3 100644
--- a/src/param.c
+++ b/src/param.c
@@ -44,6 +44,7 @@ typedef struct _paramClass {
t_symbol* receive;
t_symbol* send;
t_symbol* set_s;
+ int nowaitforbang;
} t_paramClass;
typedef struct _paramClass_inlet2
@@ -87,7 +88,7 @@ static void paramClass_anything(t_paramClass *x, t_symbol *s, int ac, t_atom *av
tof_copy_atoms(av, x->av, ac);
}
- paramClass_bang(x);
+ if (x->nowaitforbang) paramClass_bang(x);
}
@@ -165,11 +166,40 @@ static void* paramClass_new(t_symbol *s, int ac, t_atom *av)
t_symbol* path = param_get_path(canvas,name);
t_symbol* root = tof_get_dollarzero(tof_get_root_canvas(canvas));
- x->param = param_register(x,root,path,\
- (t_paramGetMethod) paramClass_get,\
- (t_paramSaveMethod) paramClass_save,\
- (t_paramGUIMethod) paramClass_GUI);
+ //FIND THE GUI OPTIONS: /g
+ int ac_temp = 0;
+ t_atom* av_temp = NULL;
+
+ tof_find_tagged_argument('/',gensym("/g"), ac-1, av+1,&ac_temp,&av_temp);
+ x->gac = ac_temp;
+ x->gav = getbytes(x->gac * sizeof(*(x->gav)));
+ tof_copy_atoms(av_temp,x->gav,x->gac);
+
+ // FIND THE NO LOADBANG TAG: /nlb
+ x->noloadbang = tof_find_tag('/',gensym("/nlb"), ac-1, av+1);
+ //post("nlb: %i",x->noloadbang);
+
+ // FIND THE NO SAVE TAG: /ns
+ int nosave = tof_find_tag('/',gensym("/ns"), ac-1, av+1);
+ //post("ns: %i",nosave);
+
+ // FIND THE WAIT FOR BANG TAG: /wfb
+ x->nowaitforbang = !(tof_find_tag('/',gensym("/wfb"), ac-1, av+1));
+
+
+ // REGISTER PARAM
+ t_paramSaveMethod paramSaveMethod = NULL;
+ t_paramGUIMethod paramGUIMethod = NULL;
+
+ if ( x->gac > 0 ) paramGUIMethod = (t_paramGUIMethod) paramClass_GUI;
+ if ( nosave = 0 ) paramSaveMethod = (t_paramSaveMethod) paramClass_save;
+
+ x->param = param_register(x,root,path, \
+ (t_paramGetMethod) paramClass_get, \
+ paramSaveMethod, \
+ paramGUIMethod);
+
if (!x->param) return NULL;
// FIND PARAM VALUE
@@ -203,27 +233,11 @@ static void* paramClass_new(t_symbol *s, int ac, t_atom *av)
- // FIND THE NO LOADBANG TAG: /nlb
- int i;
- x->noloadbang = 0;
-
- for ( i =0; i < ac; i++) {
- if ( IS_A_SYMBOL(av,i) && (strcmp("/nlb",atom_getsymbol(av+i)->s_name) == 0)) {
- x->noloadbang = 1;
- break;
- }
- }
+
- //FIND THE GUI OPTIONS: /g
- int ac_g = 0;
- t_atom* av_g = NULL;
- // There could be a problem if the the name is also /g
- tof_find_tagged_argument('/',gensym("/g"), ac, av,&ac_g,&av_g);
- x->gac = ac_g;
- x->gav = getbytes(x->gac * sizeof(*(x->gav)));
- tof_copy_atoms(av_g,x->gav,x->gac);
+
diff --git a/src/tof.h b/src/tof.h
index 3698b52..ae4e1ac 100644
--- a/src/tof.h
+++ b/src/tof.h
@@ -197,22 +197,42 @@ static int tof_next_tagged_argument(char tag, int ac, t_atom *av, int* ac_a, t_a
return (*ac_a);
}
-static void tof_find_tagged_argument(char tag,t_symbol *name, int ac, t_atom *av, int *ac_r,t_atom** av_r) {
+
+
+static int tof_find_tag(char tag, t_symbol* name, int ac, t_atom* av) {
+ int i;
+ for (i=0; i<ac;i++) {
+ if ( IS_A_SYMBOL(av,i) && name == atom_getsymbol(av+i) ) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+
+
+// Returns 1 if the tag was found
+// Fills the given int* and t_atom** with the arguments of the tag
+static int tof_find_tagged_argument(char tag,t_symbol *name, int ac, t_atom *av, int *ac_r,t_atom** av_r) {
int i;
+ int match = 0;
int j = 0;
for (i=0;i<ac;i++) {
- //if ( IS_A_SYMBOL(av,i)) post("analyzing %s",atom_getsymbol(av+i)->s_name);
- if ( IS_A_SYMBOL(av,i) && name == atom_getsymbol(av+i) && (i+1)<ac ) {
- //post("matches");
- i=i+1;
- for (j=i;j<ac;j++) {
- if ( IS_A_SYMBOL(av,j) && (atom_getsymbol(av+j))->s_name[0] == tag ) {
- //j = j-1;
- break;
+ if ( IS_A_SYMBOL(av,i) && name == atom_getsymbol(av+i) ) {
+ // FOUND MATCH
+ match = 1;
+ if ( (i+1)<ac ) { // IS THERE SPACE FOR AT LEAST ONE ARGUMENT?
+ i=i+1;
+ for (j=i;j<ac;j++) { //FIND ITS END
+ if ( IS_A_SYMBOL(av,j) && (atom_getsymbol(av+j))->s_name[0] == tag ) {
+ //j = j-1;
+ break;
+ }
}
+ break;
}
- break;
}
}
j = j-i;
@@ -226,6 +246,9 @@ static void tof_find_tagged_argument(char tag,t_symbol *name, int ac, t_atom *av
*ac_r = 0;
*av_r = NULL;
}
+
+ return match;
+
}