aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tracker/makefile36
-rw-r--r--tracker/tracker.c120
-rw-r--r--tracker/tracker.h2
-rw-r--r--tracker/tracker.tk32
4 files changed, 131 insertions, 59 deletions
diff --git a/tracker/makefile b/tracker/makefile
index 1014845..64512a8 100644
--- a/tracker/makefile
+++ b/tracker/makefile
@@ -1,19 +1,37 @@
-all: tracker.pd_linux
-tracker.pd_linux: tracker.c tracker.h tracker.tk2c
+all: pd_linux
+
+SUFFIX=pd_linux
+#SUFFIX=pd_darwin
+
+$(SUFFIX): tracker.$(SUFFIX)
+tracker.$(SUFFIX): tracker.c tracker.h tracker.tk2c
+
+pd_darwin: tracker.pd_darwin
+tracker.pd_: tracker.c tracker.h tracker.tk2c
STRIP = strip
-CFLAGS = -DPD -DUNIX -O2 -funroll-loops -fomit-frame-pointer \
+CFLAGS = -DPD -O2 \
-Wall -W -Wno-shadow -Wstrict-prototypes \
- -Wno-unused -Wno-parentheses -Wno-switch \
- -I/usr/include -I../pd/src
+ -Wno-unused -Wno-parentheses -Wno-switch
+INCLUDE = -I/usr/include -I../pd/src
+LDFLAGS =
+
+ifeq ($(SUFFIX),pd_linux)
+ CFLAGS += -DUNIX -funroll-loops -fomit-frame-pointer
+ LDFLAGS += -export_dynamic -shared -lc -lm
+endif
+ifeq ($(SUFFIX),pd_darwin)
+ LDFLAGS += -bundle -undefined suppress -flat_namespace
+ STRIP = false
+endif
-.SUFFIXES: .pd_linux .tk .tk2c
+.SUFFIXES: .$(SUFFIX) .tk .tk2c
.tk.tk2c:
./tk2c.bash < $*.tk > $*.tk2c
-.c.pd_linux:
- $(CC) $(CFLAGS) -o $*.o -c $*.c
- $(LD) -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm
+.c.$(SUFFIX):
+ $(CC) $(CFLAGS) $(INCLUDE) -o $*.o -c $*.c
+ $(LD) $(LDFLAGS) -o $*.pd_linux $*.o
$(STRIP) --strip-unneeded $*.pd_linux
clean:
$(RM) -f *.o *.pd_* so_locations *.tk2c
diff --git a/tracker/tracker.c b/tracker/tracker.c
index 9477246..429f6d2 100644
--- a/tracker/tracker.c
+++ b/tracker/tracker.c
@@ -176,6 +176,11 @@ static void tracker_save(t_gobj* z, t_binbuf* b) {
);
}
+ if(*x->s_send->s_name)
+ binbuf_addv(b, "ss", gensym("-send"), x->s_send);
+
+ if(*x->s_recv->s_name)
+ binbuf_addv(b, "ss", gensym("-recv"), x->s_recv);
binbuf_addv(b, ";");
}
@@ -184,38 +189,15 @@ static void tracker_properties(t_gobj* z, t_glist* owner) {
char buf[800];
t_tracker* x = (t_tracker*)z;
- sprintf(buf, "pdtk_tracker_dialog %%s %d %d %d\n",
+ sprintf(buf, "pdtk_tracker_dialog %%s %d %d %d {%s} {%s}\n",
(int)x->x_columns, (int)x->x_rows,
- (int)x->b_save_data
+ (int)x->b_save_data,
+ x->s_send->s_name, x->s_recv->s_name
);
//post("buf=%s", buf);
gfxstub_new(&x->x_obj.ob_pd, x, buf);
}
-/*static void tracker_dialog(t_tracker* x, t_symbol* s, int argc, t_atom* argv) {
- t_canvas* canvas = glist_getcanvas(x->x_glist);
- int ei;
- if(!x) {
- post("tracker: error: trying to set properties on an unexisting object");
- return;
- }
- if(argc != 2) {
- post("tracker: error in number of arguments (%d)", argc);
- return;
- }
- if(argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT) {
- post("tracker: error in format of arguments");
- return;
- }
-
- tracker_draw_erase(x, x->x_glist);
-
- tracker_resize(x, (int)argv[1].a_w.w_float, (int)argv[0].a_w.w_float);
-
- tracker_draw_new(x, x->x_glist);
- canvas_fixlinesfor(canvas, (t_text*)x);
-}*/
-
static void tracker_select(t_gobj* z, t_glist* glist, int selected) {
t_tracker* x = (t_tracker*)z;
@@ -419,7 +401,23 @@ static void tracker_free(t_tracker* x) {
freebytes(x->x_data[ei], x->x_columns*sizeof(t_float));
}
freebytes(x->x_data, x->x_rows*sizeof(t_float));
- //pd_unbind(&x->x_obj.ob_pd, keyname_sym);
+}
+
+static void tracker_set_saveflag(t_tracker* x, t_floatarg b) {
+ x->b_save_data = (int)(b == 0 ? 0 : 1);
+}
+
+static void tracker_set_send(t_tracker* x, t_symbol *s) {
+ x->s_send = s;
+}
+
+static void tracker_set_recv(t_tracker* x, t_symbol *s) {
+ if(x->s_recv != gensym(""))
+ pd_unbind(&x->x_obj.ob_pd, x->s_recv);
+
+ x->s_recv = s;
+
+ pd_bind(&x->x_obj.ob_pd, s);
}
static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
@@ -446,6 +444,9 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
x->b_cursor = 0;
x->b_save_data = 0;
+ x->s_send = gensym("");
+ x->s_recv = gensym("");
+
int cols = 0, rows = 0;
int got_data = 0;
if(argc == 0) {
@@ -455,10 +456,6 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
tracker_resize(x, rows, cols);
x->b_save_data = 1;
} else {
- //if(argc <= 2) {
- // post("tracker: error: wrong # of arguments (<2)");
- // return NULL;
- //}
#define ARG_CHECK_LOOP_BEGIN while(ei < argc) { if(0) {}
#define ARG_CHECK_LOOP_END }
#define MATCH_ARG(sz) else if(argv[ei].a_type == A_SYMBOL && \
@@ -485,6 +482,16 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
MATCH_ARG_T("-sl", A_SYMBOL) { ei++; ei++; }
MATCH_ARG_T("-bd", A_FLOAT) { ei++; ei++; }
MATCH_ARG_T("-bd", A_SYMBOL) { ei++; ei++; }
+ MATCH_ARG_T("-send", A_SYMBOL){
+ ei++;
+ //x->s_send = argv[ei++].a_w.w_symbol;
+ tracker_set_send(x, argv[ei++].a_w.w_symbol);
+ }
+ MATCH_ARG_T("-recv", A_SYMBOL){
+ ei++;
+ //x->s_recv = argv[ei++].a_w.w_symbol;
+ tracker_set_recv(x, argv[ei++].a_w.w_symbol);
+ }
MATCH_ARG("-data") {
ei++;
if((argc - ei) < 2) {
@@ -506,7 +513,8 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
x->x_data[j / cols][j % cols] = argv[ei++].a_w.w_float;
}
got_data = 1;
- x->b_save_data = 1;
+ //x->b_save_data = 1;
+ tracker_set_saveflag(x, 1);
}
MATCH_FAILED {
post("tracker: argument error: w_float=%f, w_symbol=%s",
@@ -595,7 +603,11 @@ static void tracker_getrow(t_tracker* x, t_floatarg row) {
for(ei = 0; ei < x->x_columns; ei++) {
SETFLOAT(&atombuf[ei], x->x_data[introw][ei]);
}
+
outlet_list(x->outlet0, &s_list, x->x_columns, atombuf);
+ if(x->s_send != gensym(""))
+ pd_list(x->s_send->s_thing, &s_list, x->x_columns, atombuf);
+
freebytes(atombuf, sizeof(t_atom)*x->x_columns);
if(x->b_cursor) {
@@ -605,10 +617,6 @@ static void tracker_getrow(t_tracker* x, t_floatarg row) {
}
}
-static void tracker_set_saveflag(t_tracker* x, t_floatarg b) {
- x->b_save_data = (int)(b == 0 ? 0 : 1);
-}
-
static void tracker_toggle_cursor(t_tracker* x, t_floatarg b) {
x->b_cursor = (int)(b == 0 ? 0 : 1);
tracker_draw_update_cursor_pos(x);
@@ -653,6 +661,8 @@ static void tracker_getitem(t_tracker* x, t_float row, t_float col) {
SETFLOAT(&a, x->x_data[introw][intcol]);
outlet_list(x->outlet0, &s_list, 1, &a);
+ if(x->s_send != gensym(""))
+ pd_list(x->s_send->s_thing, &s_list, 1, &a);
}
static void tracker_setitem(t_tracker* x, t_float row, t_float col, t_float val) {
@@ -689,23 +699,35 @@ keyname_sym = gensym("#keyname");
0
);
class_addlist(tracker_class, tracker_list);
- class_addmethod(tracker_class, (t_method)tracker_toggle_cursor, gensym("trackrow"), A_FLOAT, 0);
- class_addmethod(tracker_class, (t_method)tracker_update, gensym("update"), A_GIMME, 0);
- //class_addmethod(tracker_class, (t_method)tracker_dialog, gensym("dialog"), A_GIMME, 0);
- class_addmethod(tracker_class, (t_method)tracker_setrow, gensym("setrow"), A_GIMME, 0);
- class_addmethod(tracker_class, (t_method)tracker_getrow, gensym("getrow"), A_FLOAT, 0);
- class_addmethod(tracker_class, (t_method)tracker_setitem, gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(tracker_class, (t_method)tracker_getitem, gensym("get"), A_FLOAT, A_FLOAT, 0);
- class_addmethod(tracker_class, (t_method)tracker_gresize, gensym("resize"), A_FLOAT, A_FLOAT, 0);
- class_addmethod(tracker_class, (t_method)tracker_set_saveflag, gensym("set_saveflag"), A_FLOAT, 0);
- class_addmethod(tracker_class, (t_method)tracker_file_load, gensym("load"), A_SYMBOL, 0);
- class_addmethod(tracker_class, (t_method)tracker_file_save, gensym("save"), A_SYMBOL, 0);
+ class_addmethod(tracker_class, (t_method)tracker_toggle_cursor,
+ gensym("trackrow"), A_FLOAT, 0);
+ class_addmethod(tracker_class, (t_method)tracker_update,
+ gensym("update"), A_GIMME, 0);
+ class_addmethod(tracker_class, (t_method)tracker_setrow,
+ gensym("setrow"), A_GIMME, 0);
+ class_addmethod(tracker_class, (t_method)tracker_getrow,
+ gensym("getrow"), A_FLOAT, 0);
+ class_addmethod(tracker_class, (t_method)tracker_setitem,
+ gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(tracker_class, (t_method)tracker_getitem,
+ gensym("get"), A_FLOAT, A_FLOAT, 0);
+ class_addmethod(tracker_class, (t_method)tracker_gresize,
+ gensym("resize"), A_FLOAT, A_FLOAT, 0);
+ class_addmethod(tracker_class, (t_method)tracker_set_saveflag,
+ gensym("set_saveflag"), A_FLOAT, 0);
+ class_addmethod(tracker_class, (t_method)tracker_set_send,
+ gensym("set_send"), A_SYMBOL, 0);
+ class_addmethod(tracker_class, (t_method)tracker_set_recv,
+ gensym("set_recv"), A_SYMBOL, 0);
+ class_addmethod(tracker_class, (t_method)tracker_file_load,
+ gensym("load"), A_SYMBOL, 0);
+ class_addmethod(tracker_class, (t_method)tracker_file_save,
+ gensym("save"), A_SYMBOL, 0);
tracker_widgetbehavior.w_getrectfn = tracker_getrect;
tracker_widgetbehavior.w_displacefn = tracker_displace;
tracker_widgetbehavior.w_selectfn = tracker_select;
- //tracker_widgetbehavior.w_activatefn = NULL;
- tracker_widgetbehavior.w_activatefn = tracker_activate;
+ tracker_widgetbehavior.w_activatefn = NULL;
tracker_widgetbehavior.w_deletefn = tracker_delete;
tracker_widgetbehavior.w_visfn = tracker_vis;
tracker_widgetbehavior.w_clickfn = tracker_click;
diff --git a/tracker/tracker.h b/tracker/tracker.h
index 36f9ba6..f32603d 100644
--- a/tracker/tracker.h
+++ b/tracker/tracker.h
@@ -34,6 +34,8 @@ typedef struct _tracker
t_int x_cell_height; // cell height in pixels (auto computed)
t_float** x_data; // data (2d matrix)
t_outlet* outlet0; // outlet
+ t_symbol* s_send;
+ t_symbol* s_recv;
} t_tracker;
static void tracker_draw_new(t_tracker* x, t_glist* glist);
diff --git a/tracker/tracker.tk b/tracker/tracker.tk
index cd21b9f..fcd226b 100644
--- a/tracker/tracker.tk
+++ b/tracker/tracker.tk
@@ -8,6 +8,10 @@ proc tracker_apply {id} {
global $var_graph_height
set var_saveflag [concat saveflag_$vid]
global $var_saveflag
+ set var_sym_send [concat sym_send_$vid]
+ global $var_sym_send
+ set var_sym_recv [concat sym_recv_$vid]
+ global $var_sym_recv
set cmd [concat $id resize \
[eval concat $$var_graph_height] \
@@ -19,6 +23,12 @@ proc tracker_apply {id} {
[eval concat $$var_saveflag] \
\;]
pd $cmd
+
+ set ss [string trim [set $var_sym_send]]
+ if {$ss != {}} {pd [concat $id set_send $ss \;]}
+
+ set rs [string trim [set $var_sym_recv]]
+ if {$rs != {}} {pd [concat $id set_recv $rs \;]}
}
proc tracker_cancel {id} {
@@ -32,7 +42,7 @@ proc tracker_ok {id} {
tracker_cancel $id
}
-proc pdtk_tracker_dialog {id width height saveflag} {
+proc pdtk_tracker_dialog {id width height saveflag ss rs} {
set vid [string trimleft $id .]
set var_graph_width [concat graph_width_$vid]
@@ -41,10 +51,16 @@ proc pdtk_tracker_dialog {id width height saveflag} {
global $var_graph_height
set var_saveflag [concat saveflag_$vid]
global $var_saveflag
+ set var_sym_send [concat sym_send_$vid]
+ global $var_sym_send
+ set var_sym_recv [concat sym_recv_$vid]
+ global $var_sym_recv
set $var_graph_width $width
set $var_graph_height $height
set $var_saveflag $saveflag
+ set $var_sym_recv $rs
+ set $var_sym_send $ss
toplevel $id
wm title $id {tracker}
@@ -85,7 +101,21 @@ proc pdtk_tracker_dialog {id width height saveflag} {
checkbutton $id.3rangef.saveflag -variable $var_saveflag -text "save contents"
pack $id.3rangef.lsaveflag $id.3rangef.saveflag -side left
+ frame $id.4rangef
+ pack $id.4rangef -side top
+ label $id.4rangef.lwidth -text "Send symbol :"
+ entry $id.4rangef.ss -textvar $var_sym_send -width 10
+ pack $id.4rangef.lwidth $id.4rangef.ss -side left
+
+ frame $id.5rangef
+ pack $id.5rangef -side top
+ label $id.5rangef.lwidth -text "Receive symbol :"
+ entry $id.5rangef.rs -textvar $var_sym_recv -width 10
+ pack $id.5rangef.lwidth $id.5rangef.rs -side left
+
bind $id.1rangef.width <KeyPress-Return> [concat tracker_ok $id]
bind $id.2rangef.height <KeyPress-Return> [concat tracker_ok $id]
+ bind $id.4rangef.ss <KeyPress-Return> [concat tracker_ok $id]
+ bind $id.5rangef.rs <KeyPress-Return> [concat tracker_ok $id]
focus $id.1rangef.width
}