1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/******************************************************
*
* zexy - implementation file
*
* copyleft (c) IOhannes m zmölnig
*
* 1999:forum::für::umläute:2004
*
* institute of electronic music and acoustics (iem)
*
******************************************************
*
* license: GNU General Public License v.2
*
******************************************************/
/* hack : 2108:forum::für::umläute:1999 @ iem */
#include "zexy.h"
/* =================== tabset ====================== */
static t_class *tabset_class;
typedef struct _tabset
{
t_object x_obj;
t_symbol *x_arrayname;
} t_tabset;
static void tabset_float(t_tabset *x, t_floatarg f)
{
t_garray *A;
int npoints;
t_float *vec;
if (!(A = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
error("%s: no such array", x->x_arrayname->s_name);
else if (!garray_getfloatarray(A, &npoints, &vec))
error("%s: bad template for tabset", x->x_arrayname->s_name);
else {
while(npoints--)*vec++=f;
garray_redraw(A);
}
}
static void tabset_list(t_tabset *x, t_symbol *s, int argc, t_atom* argv)
{
t_garray *A;
int npoints;
t_float *vec;
ZEXY_USEVAR(s);
if (!(A = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
error("%s: no such array", x->x_arrayname->s_name);
else if (!garray_getfloatarray(A, &npoints, &vec))
error("%s: bad template for tabset", x->x_arrayname->s_name);
else {
if (argc>=npoints)
while(npoints--)*vec++=atom_getfloat(argv++);
else {
npoints-=argc;
while (argc--)*vec++=atom_getfloat(argv++);
while (npoints--)*vec++=0;
}
garray_redraw(A);
}
}
static void tabset_set(t_tabset *x, t_symbol *s)
{
x->x_arrayname = s;
}
static void *tabset_new(t_symbol *s)
{
t_tabset *x = (t_tabset *)pd_new(tabset_class);
x->x_arrayname = s;
return (x);
}
static void tabset_helper(void)
{
post("\n%c tabset - object : set a table with a package of floats", HEARTSYMBOL);
post("'set <table>'\t: set another table\n"
"<list>\t\t: set the table"
"<float>\t\t: set the table to constant float\n");
post("creation\t: \"tabset <table>\"");
}
void tabset_setup(void)
{
tabset_class = class_new(gensym("tabset"), (t_newmethod)tabset_new,
0, sizeof(t_tabset), 0, A_DEFSYM, 0);
class_addfloat(tabset_class, (t_method)tabset_float);
class_addlist (tabset_class, (t_method)tabset_list);
class_addmethod(tabset_class, (t_method)tabset_set, gensym("set"),
A_SYMBOL, 0);
class_addmethod(tabset_class, (t_method)tabset_helper, gensym("help"), 0);
class_sethelpsymbol(tabset_class, gensym("zexy/tabset"));
zexy_register("tabset");
}
|