summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/intern/tabread.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/tabread.c')
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabread.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/tabread.c b/apps/plugins/pdbox/PDa/intern/tabread.c
index 5cd51b3036..16beb5977a 100644
--- a/apps/plugins/pdbox/PDa/intern/tabread.c
+++ b/apps/plugins/pdbox/PDa/intern/tabread.c
@@ -50,55 +50,4 @@ void tabread_setup(void)
50 class_addmethod(tabread_class, (t_method)tabread_set, gensym("set"), 50 class_addmethod(tabread_class, (t_method)tabread_set, gensym("set"),
51 A_SYMBOL, 0); 51 A_SYMBOL, 0);
52} 52}
53#include <m_pd.h>
54
55/* ---------- tabread: control, non-interpolating ------------------------ */
56
57static t_class *tabread_class;
58
59typedef struct _tabread
60{
61 t_object x_obj;
62 t_symbol *x_arrayname;
63} t_tabread;
64
65static void tabread_float(t_tabread *x, t_float f)
66{
67 t_garray *a;
68 int npoints;
69 t_sample *vec;
70 53
71 if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
72 pd_error(x, "%s: no such array", x->x_arrayname->s_name);
73 else if (!garray_getfloatarray(a, &npoints, &vec))
74 pd_error(x, "%s: bad template for tabread", x->x_arrayname->s_name);
75 else
76 {
77 int n = f;
78 if (n < 0) n = 0;
79 else if (n >= npoints) n = npoints - 1;
80 outlet_float(x->x_obj.ob_outlet, (npoints ? fixtof(vec[n]) : 0));
81 }
82}
83
84static void tabread_set(t_tabread *x, t_symbol *s)
85{
86 x->x_arrayname = s;
87}
88
89static void *tabread_new(t_symbol *s)
90{
91 t_tabread *x = (t_tabread *)pd_new(tabread_class);
92 x->x_arrayname = s;
93 outlet_new(&x->x_obj, &s_float);
94 return (x);
95}
96
97void tabread_setup(void)
98{
99 tabread_class = class_new(gensym("tabread"), (t_newmethod)tabread_new,
100 0, sizeof(t_tabread), 0, A_DEFSYM, 0);
101 class_addfloat(tabread_class, (t_method)tabread_float);
102 class_addmethod(tabread_class, (t_method)tabread_set, gensym("set"),
103 A_SYMBOL, 0);
104}