summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/intern/tabwrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/tabwrite.c')
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabwrite.c83
1 files changed, 0 insertions, 83 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/tabwrite.c b/apps/plugins/pdbox/PDa/intern/tabwrite.c
index 8d6a6c0da8..ff4e40d042 100644
--- a/apps/plugins/pdbox/PDa/intern/tabwrite.c
+++ b/apps/plugins/pdbox/PDa/intern/tabwrite.c
@@ -82,87 +82,4 @@ void tabwrite_setup(void)
82 class_addfloat(tabwrite_class, (t_method)tabwrite_float); 82 class_addfloat(tabwrite_class, (t_method)tabwrite_float);
83 class_addmethod(tabwrite_class, (t_method)tabwrite_set, gensym("set"), A_SYMBOL, 0); 83 class_addmethod(tabwrite_class, (t_method)tabwrite_set, gensym("set"), A_SYMBOL, 0);
84} 84}
85#include <m_pd.h>
86/* ------------------ tabwrite: control ------------------------ */
87
88static t_class *tabwrite_class;
89
90typedef struct _tabwrite
91{
92 t_object x_obj;
93 t_symbol *x_arrayname;
94 t_clock *x_clock;
95 float x_ft1;
96 double x_updtime;
97 int x_set;
98} t_tabwrite;
99
100static void tabwrite_tick(t_tabwrite *x)
101{
102 t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class);
103 if (!a) bug("tabwrite_tick");
104 else garray_redraw(a);
105 x->x_set = 0;
106 x->x_updtime = clock_getsystime();
107}
108 85
109static void tabwrite_float(t_tabwrite *x, t_float f)
110{
111 int i, vecsize;
112 t_garray *a;
113 t_sample *vec;
114
115 if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
116 pd_error(x, "%s: no such array", x->x_arrayname->s_name);
117 else if (!garray_getfloatarray(a, &vecsize, &vec))
118 pd_error(x, "%s: bad template for tabwrite", x->x_arrayname->s_name);
119 else
120 {
121 int n = x->x_ft1;
122 double timesince = clock_gettimesince(x->x_updtime);
123 if (n < 0) n = 0;
124 else if (n >= vecsize) n = vecsize-1;
125 vec[n] = ftofix(f);
126 if (timesince > 1000)
127 {
128 tabwrite_tick(x);
129 }
130 else
131 {
132 if (x->x_set == 0)
133 {
134 clock_delay(x->x_clock, 1000 - timesince);
135 x->x_set = 1;
136 }
137 }
138 }
139}
140
141static void tabwrite_set(t_tabwrite *x, t_symbol *s)
142{
143 x->x_arrayname = s;
144}
145
146static void tabwrite_free(t_tabwrite *x)
147{
148 clock_free(x->x_clock);
149}
150
151static void *tabwrite_new(t_symbol *s)
152{
153 t_tabwrite *x = (t_tabwrite *)pd_new(tabwrite_class);
154 x->x_ft1 = 0;
155 x->x_arrayname = s;
156 x->x_updtime = clock_getsystime();
157 x->x_clock = clock_new(x, (t_method)tabwrite_tick);
158 floatinlet_new(&x->x_obj, &x->x_ft1);
159 return (x);
160}
161
162void tabwrite_setup(void)
163{
164 tabwrite_class = class_new(gensym("tabwrite"), (t_newmethod)tabwrite_new,
165 (t_method)tabwrite_free, sizeof(t_tabwrite), 0, A_DEFSYM, 0);
166 class_addfloat(tabwrite_class, (t_method)tabwrite_float);
167 class_addmethod(tabwrite_class, (t_method)tabwrite_set, gensym("set"), A_SYMBOL, 0);
168}