diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/tabread~.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/intern/tabread~.c | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/tabread~.c b/apps/plugins/pdbox/PDa/intern/tabread~.c index f1f4fd4729..5a7ea5d57f 100644 --- a/apps/plugins/pdbox/PDa/intern/tabread~.c +++ b/apps/plugins/pdbox/PDa/intern/tabread~.c | |||
@@ -95,100 +95,4 @@ void tabread_tilde_setup(void) | |||
95 | class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_set, | 95 | class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_set, |
96 | gensym("set"), A_SYMBOL, 0); | 96 | gensym("set"), A_SYMBOL, 0); |
97 | } | 97 | } |
98 | #define FIXEDPOINT | ||
99 | #include <m_pd.h> | ||
100 | #include <m_fixed.h> | ||
101 | |||
102 | static t_class *tabread_tilde_class; | ||
103 | |||
104 | typedef struct _tabread_tilde | ||
105 | { | ||
106 | t_object x_obj; | ||
107 | int x_npoints; | ||
108 | t_sample *x_vec; | ||
109 | t_symbol *x_arrayname; | ||
110 | float x_f; | ||
111 | } t_tabread_tilde; | ||
112 | |||
113 | static void *tabread_tilde_new(t_symbol *s) | ||
114 | { | ||
115 | t_tabread_tilde *x = (t_tabread_tilde *)pd_new(tabread_tilde_class); | ||
116 | x->x_arrayname = s; | ||
117 | x->x_vec = 0; | ||
118 | outlet_new(&x->x_obj, gensym("signal")); | ||
119 | x->x_f = 0; | ||
120 | return (x); | ||
121 | } | ||
122 | |||
123 | static t_int *tabread_tilde_perform(t_int *w) | ||
124 | { | ||
125 | t_tabread_tilde *x = (t_tabread_tilde *)(w[1]); | ||
126 | t_sample *in = (t_sample *)(w[2]); | ||
127 | t_sample *out = (t_sample *)(w[3]); | ||
128 | int n = (int)(w[4]); | ||
129 | int maxindex; | ||
130 | t_sample *buf = x->x_vec, *fp; | ||
131 | int i; | ||
132 | |||
133 | maxindex = x->x_npoints - 1; | ||
134 | if (!buf) goto zero; | ||
135 | |||
136 | for (i = 0; i < n; i++) | ||
137 | { | ||
138 | int index = ((long long) mult((*in++),ftofix(44.1)) >> fix1); | ||
139 | if (index < 0) | ||
140 | index = 0; | ||
141 | else if (index > maxindex) | ||
142 | index = maxindex; | ||
143 | *out++ = buf[index]; | ||
144 | } | ||
145 | return (w+5); | ||
146 | zero: | ||
147 | while (n--) *out++ = 0; | ||
148 | |||
149 | return (w+5); | ||
150 | } | ||
151 | |||
152 | void tabread_tilde_set(t_tabread_tilde *x, t_symbol *s) | ||
153 | { | ||
154 | t_garray *a; | ||
155 | |||
156 | x->x_arrayname = s; | ||
157 | if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) | ||
158 | { | ||
159 | if (*s->s_name) | ||
160 | error("tabread~: %s: no such array", x->x_arrayname->s_name); | ||
161 | x->x_vec = 0; | ||
162 | } | ||
163 | else if (!garray_getfloatarray(a, &x->x_npoints, &x->x_vec)) | ||
164 | { | ||
165 | error("%s: bad template for tabread~", x->x_arrayname->s_name); | ||
166 | x->x_vec = 0; | ||
167 | } | ||
168 | else garray_usedindsp(a); | ||
169 | } | ||
170 | 98 | ||
171 | static void tabread_tilde_dsp(t_tabread_tilde *x, t_signal **sp) | ||
172 | { | ||
173 | tabread_tilde_set(x, x->x_arrayname); | ||
174 | |||
175 | dsp_add(tabread_tilde_perform, 4, x, | ||
176 | sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); | ||
177 | |||
178 | } | ||
179 | |||
180 | static void tabread_tilde_free(t_tabread_tilde *x) | ||
181 | { | ||
182 | } | ||
183 | |||
184 | void tabread_tilde_setup(void) | ||
185 | { | ||
186 | tabread_tilde_class = class_new(gensym("tabread~"), | ||
187 | (t_newmethod)tabread_tilde_new, (t_method)tabread_tilde_free, | ||
188 | sizeof(t_tabread_tilde), 0, A_DEFSYM, 0); | ||
189 | CLASS_MAINSIGNALIN(tabread_tilde_class, t_tabread_tilde, x_f); | ||
190 | class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_dsp, | ||
191 | gensym("dsp"), 0); | ||
192 | class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_set, | ||
193 | gensym("set"), A_SYMBOL, 0); | ||
194 | } | ||