aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas O Fredericks <mrtof@users.sourceforge.net>2009-10-26 21:11:49 +0000
committerThomas O Fredericks <mrtof@users.sourceforge.net>2009-10-26 21:11:49 +0000
commit71bb1c90837f8114a6fc962b1afcf074e2e17e63 (patch)
tree136de37d07aae76f16823982652e4a86dafb45c8
parent7541b9f1ba232dce4aceb41115c17292bd7298f4 (diff)
Added ifdefs to change the method of sending parameters
svn path=/trunk/externals/tof/; revision=12681
-rw-r--r--help/param-help.pd15
-rw-r--r--src/param.c7
-rw-r--r--src/paramCustom.h55
-rw-r--r--src/paramFile.h54
-rw-r--r--src/paramRoute.h21
5 files changed, 90 insertions, 62 deletions
diff --git a/help/param-help.pd b/help/param-help.pd
index 4624ca8..abcf5ab 100644
--- a/help/param-help.pd
+++ b/help/param-help.pd
@@ -11,7 +11,7 @@ system.;
#X floatatom 144 229 5 0 0 0 - - -;
#X obj 136 351 dac~;
#X obj 184 275 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144
--1 -1 9400 1;
+-1 -1 0 1;
#X msg 144 251 /modulation/index \$1;
#X msg 181 297 /volume \$1;
#N canvas 237 177 542 366 [param 0;
@@ -182,16 +182,21 @@ name \, will be used to build the path.;
#X obj 404 243 cnv 15 200 20 empty empty /FM_MOD/ 2 12 0 8 -258401
-262144 0;
#X obj 404 266 nbx 5 14 -1e+37 1e+37 0 0 /FM_MOD/modulation/freq /FM_MOD/modulation/freq_
-modulation/freq 50 8 0 8 -262144 -1 -1 0 256;
+modulation/freq 50 8 0 8 -262144 -1 -1 29 256;
#X obj 404 284 nbx 5 14 -1e+37 1e+37 0 0 /FM_MOD/modulation/index /FM_MOD/modulation/index_
-modulation/index 50 8 0 8 -262144 -1 -1 0 256;
+modulation/index 50 8 0 8 -262144 -1 -1 20 256;
#X obj 404 302 hsl 100 15 0 1 0 0 /FM_MOD/volume /FM_MOD/volume_ volume
-105 7 0 8 -262144 -1 -1 7328 1;
+105 7 0 8 -262144 -1 -1 0 1;
#X obj 404 320 hsl 100 15 200 2000 0 0 /FM_MOD/carrier /FM_MOD/carrier_
-carrier 105 7 0 8 -262144 -1 -1 6200 1;
+carrier 105 7 0 8 -262144 -1 -1 2200 1;
+#X obj 441 129 tof/param route;
+#X msg 440 91 /FM_MOD/modulation/freq \$1;
+#X floatatom 444 44 5 0 0 0 - - -;
#X connect 6 0 9 0;
#X connect 8 0 10 0;
#X connect 9 0 20 0;
#X connect 10 0 20 0;
#X connect 20 0 7 0;
#X connect 20 0 7 1;
+#X connect 27 0 26 0;
+#X connect 28 0 27 0;
diff --git a/src/param.c b/src/param.c
index fc2daf0..9464a40 100644
--- a/src/param.c
+++ b/src/param.c
@@ -19,9 +19,16 @@
* MA 02110-1301, USA.
*/
+// Post a lot of debug messages
//#define PARAMDEBUG
+
+// Adds the root's $0 to the start of the paths
//#define LOCAL
+// Uses the symbol's s_thing to target the proper param
+// This is faster but can potentially target two params
+#define USEBINDINGS
+
#include "param.h"
#include "paramCustom.h"
#include "paramDump.h"
diff --git a/src/paramCustom.h b/src/paramCustom.h
index db1e66e..df3eba1 100644
--- a/src/paramCustom.h
+++ b/src/paramCustom.h
@@ -10,7 +10,9 @@ typedef struct _paramCustom {
t_outlet* outlet;
t_outlet* outlet2;
t_binbuf* bb;
- //t_symbol* receive;
+ #ifdef USEBINDINGS
+ t_symbol* receive;
+ #endif
struct _paramCustom_receive* r;
int nopresets;
} t_paramCustom;
@@ -23,22 +25,6 @@ typedef struct _paramCustom_receive
-static void paramCustom_bang(t_paramCustom *x)
-{
- /*
- outlet_anything(x->outlet, x->selector, x->ac, x->av);
-
- if(x->selector != &s_bang ) tof_send_anything_prepend(x->send,x->selector,x->ac,x->av,x->set_s );
- */
-}
-/*
-
-static void paramClass_loadbang(t_paramClass *x)
-{
- if (!sys_noloadbang && !x->noloadbang)
- paramClass_bang(x);
-}
-*/
static void paramCustom_anything(t_paramCustom *x, t_symbol *selector, int argc, t_atom *argv)
{
@@ -65,9 +51,10 @@ static void paramCustom_anything(t_paramCustom *x, t_symbol *selector, int argc,
static void paramCustom_free(t_paramCustom *x)
{
+ #ifdef USEBINDINGS
+ if (x->receive) pd_unbind(&x->r->x_obj.ob_pd, x->receive);
+ #endif
- //if (x->receive) pd_unbind(&x->r->x_obj.ob_pd, x->receive);
-
if (x->param) param_unregister(x->param);
@@ -140,23 +127,31 @@ static void* paramCustom_new(t_symbol *s, int ac, t_atom *av)
x->r = r;
r->owner = x;
- // BIND RECEIVER
- //pd_bind(&r->x_obj.ob_pd, x->receive );
x->param = param_register(r,root,path, NULL,\
(t_paramSaveMethod) paramCustom_save,NULL);
if (!x->param) return NULL;
-
- int l = strlen(path->s_name) + strlen(root->s_name) + 2;
- char* receiver = getbytes( l * sizeof(*receiver));
- strcat(receiver,root->s_name);
- strcat(receiver,path->s_name);
- //x->receive = gensym(receiver);
-
- freebytes(receiver, l * sizeof(*receiver));
+ #ifdef USEBINDINGS
+
+ #ifdef LOCAL
+ int l = strlen(path->s_name) + strlen(root->s_name) + 2;
+ char* receiver = getbytes( l * sizeof(*receiver));
+ receiver[0] = '\0';
+ strcat(receiver,root->s_name);
+ strcat(receiver,path->s_name);
+ x->receive = gensym(receiver);
+ freebytes(receiver, l * sizeof(*receiver));
+ #else
+ x->receive = path;
+ #endif
+
+ pd_bind(&r->x_obj.ob_pd, x->receive );
+ #endif
+
+
#ifdef PARAMDEBUG
post("receive:%s",x->receive->s_name);
@@ -188,7 +183,7 @@ void paramCustom_setup(void)
class_addanything(paramCustom_class, paramCustom_anything);
- class_addbang(paramCustom_class, paramCustom_bang);
+ //class_addbang(paramCustom_class, paramCustom_bang);
//class_addmethod(param_class, (t_method)paramClass_loadbang, gensym("loadbang"), 0);
diff --git a/src/paramFile.h b/src/paramFile.h
index 66d016c..fad3ea6 100644
--- a/src/paramFile.h
+++ b/src/paramFile.h
@@ -103,11 +103,12 @@ static void paramFile_do_load(t_paramFile* x, t_float f) {
t_symbol* root = x->root;
-
+ #ifndef USEBINDINGS
t_param* pp = get_param_list(root);
t_param* p;
if (pp) {
+ #endif
int r_error;
t_binbuf *bbuf = binbuf_new();
@@ -123,22 +124,28 @@ static void paramFile_do_load(t_paramFile* x, t_float f) {
while (bb_ac--) {
if (bb_av->a_type == A_SEMI) {
if ( IS_A_SYMBOL(av,0) && ac > 1) {
- /*
- #ifdef LOCAL
- t_symbol* path = atom_getsymbol(av);
- strcpy(param_buf_temp_a,root->s_name);
- strcat(param_buf_temp_a,path->s_name);
- t_symbol* s = gensym(param_buf_temp_a);
+ #ifdef USEBINDINGS
+ #ifdef LOCAL
+ t_symbol* path = atom_getsymbol(av);
+ strcpy(param_buf_temp_a,root->s_name);
+ strcat(param_buf_temp_a,path->s_name);
+ s = gensym(param_buf_temp_a);
+ #else
+ s = atom_getsymbol(av);
+ #endif
#else
- t_symbol* s = atom_getsymbol(av);
- #endif
- */
- s = atom_getsymbol(av);
- p = pp;
- while(p && p->path != s) p=p->next;
-
+ s = atom_getsymbol(av);
+ p = pp;
+ while(p && p->path != s) p=p->next;
+ #endif
- if (p) {
+
+ #ifdef USEBINDINGS
+ if (s->s_thing) {
+ #else
+ if (p) {
+ #endif
+
if ( ac > 3 && IS_A_SYMBOL(av,1) && atom_getsymbol(av+1) == &s_symbol) {
// STUPID MANAGEMENT OF SYMBOLS WITH SPACES
// This whole block is simply to convert symbols saved with spaces to complete symbols
@@ -157,11 +164,21 @@ static void paramFile_do_load(t_paramFile* x, t_float f) {
binbuf_free(bbuf_stupid);
t_atom* stupid_atom = getbytes(sizeof(*stupid_atom));
SETSYMBOL(stupid_atom, stupid_symbol);
- pd_typedmess(p->x, &s_symbol, 1, stupid_atom);
+
+ #ifdef USEBINDINGS
+ pd_typedmess(s->s_thing, &s_symbol, 1, stupid_atom);
+ #else
+ pd_typedmess(p->x, &s_symbol, 1, stupid_atom);
+ #endif
freebytes(stupid_atom, sizeof(*stupid_atom));
} else {
- pd_forwardmess(p->x, ac-1, av+1);
+ #ifdef USEBINDINGS
+ pd_forwardmess(s->s_thing, ac-1, av+1);
+ #else
+ pd_forwardmess(p->x, ac-1, av+1);
+ #endif
+
}
}
}
@@ -178,8 +195,9 @@ static void paramFile_do_load(t_paramFile* x, t_float f) {
binbuf_free(bbuf);
if ( r_error) pd_error(x, "%s: read failed", filename->s_name);
+ #ifndef USEBINDINGS
}
-
+ #endif
x->working = 0;
diff --git a/src/paramRoute.h b/src/paramRoute.h
index c336367..5d94e30 100644
--- a/src/paramRoute.h
+++ b/src/paramRoute.h
@@ -18,16 +18,15 @@ typedef struct _paramRoute
static void paramRoute_anything(t_paramRoute *x, t_symbol *s, int ac, t_atom *av) {
-
+
+ #ifndef USEBINDINGS
t_param* p = get_param_list(x->root);
-
+ #endif
if (ac) {
- if ( p != NULL && s->s_name[0] == '/' && strlen(s->s_name) > 1) {
-
-
-
-
+
+ if ( s->s_name[0] == '/' && strlen(s->s_name) > 1) {
+
if (x->previousSymbol != s) {
param_buf_temp_a[0] = '\0';
#ifdef LOCAL
@@ -43,15 +42,19 @@ static void paramRoute_anything(t_paramRoute *x, t_symbol *s, int ac, t_atom *av
#endif
x->previousSymbol = s;
}
-
+ #ifdef USEBINDINGS
+ if (x->target->s_thing) {
+ pd_forwardmess(x->target->s_thing, ac, av);
+ #else
while (p && p->path != x->target) p=p->next;
if (p) {
pd_forwardmess(p->x, ac, av);
+ #endif
} else {
outlet_anything(x->x_outlet,s,ac,av);
}
-
+
} else {
outlet_anything(x->x_outlet,s,ac,av);