2
/******************************************************
4
* zexy - implementation file
6
* copyleft (c) IOhannes m zm�lnig
8
* 1999:forum::f�r::uml�ute:2004
10
* institute of electronic music and acoustics (iem)
12
******************************************************
14
* license: GNU General Public License v.2
16
******************************************************/
19
/* hack : 2108:forum::f�r::uml�ute:1999 @ iem */
24
/* =================== tabdump ====================== */
26
static t_class *tabdump_class;
28
typedef struct _tabdump
31
t_symbol *x_arrayname;
32
t_int startindex, stopindex;
35
static void tabdump_bang(t_tabdump *x)
41
if (!(A = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
42
error("%s: no such array", x->x_arrayname->s_name);
43
else if (!zarray_getarray(A, &npoints, &vec))
44
error("%s: bad template for tabdump", x->x_arrayname->s_name);
50
int start=x->startindex;
51
int stop =x->stopindex;
52
if(start<0||start>stop)start=0;
53
if(stop<start||stop>npoints)stop=npoints;
56
atombuf = (t_atom *)getbytes(sizeof(t_atom)*npoints);
57
for (n = 0; n < npoints; n++) SETFLOAT(&atombuf[n], zarray_getfloat(vec, start+n));
58
outlet_list(x->x_obj.ob_outlet, &s_list, npoints, atombuf);
59
freebytes(atombuf,sizeof(t_atom)*npoints);
63
static void tabdump_list(t_tabdump *x, t_symbol*s,int argc, t_atom*argv)
70
b=atom_getint(argv+1);
71
x->startindex=(a<b)?a:b;
72
x->stopindex =(a>b)?a:b;
76
error("tabdump: list must be 2 floats (is %d atoms)", argc);
80
static void tabdump_set(t_tabdump *x, t_symbol *s)
85
static void *tabdump_new(t_symbol *s)
87
t_tabdump *x = (t_tabdump *)pd_new(tabdump_class);
91
outlet_new(&x->x_obj, &s_list);
96
static void tabdump_helper(void)
98
post("\n%c tabdump - object : dumps a table as a package of floats", HEARTSYMBOL);
99
post("'set <table>'\t: read out another table\n"
100
"'bang'\t\t: dump the table\n"
101
"outlet\t\t: table-data as package of floats");
102
post("creation\t: \"tabdump <table>\"");
106
void tabdump_setup(void)
108
tabdump_class = class_new(gensym("tabdump"), (t_newmethod)tabdump_new,
109
0, sizeof(t_tabdump), 0, A_DEFSYM, 0);
110
class_addbang(tabdump_class, (t_method)tabdump_bang);
111
class_addlist(tabdump_class, (t_method)tabdump_list);
113
class_addmethod(tabdump_class, (t_method)tabdump_set, gensym("set"),
116
class_addmethod(tabdump_class, (t_method)tabdump_helper, gensym("help"), 0);
117
zexy_register("tabdump");