summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/intern/tabread4~.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
commit526b5580dabbfed7cfe5439dc3a90ec727f563c2 (patch)
tree22b1af92348785daad16714ee5e2b633017e0e48 /apps/plugins/pdbox/PDa/intern/tabread4~.c
parent4f2dfcc01b260d946044ef2b6af5fe36cb772c8d (diff)
downloadrockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.tar.gz
rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.zip
Cut the files in half and it might work better (note to self: check your tree is really clean before patching)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21070 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/tabread4~.c')
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabread4~.c104
1 files changed, 0 insertions, 104 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/tabread4~.c b/apps/plugins/pdbox/PDa/intern/tabread4~.c
index e530a9fce8..47a6fc3ddf 100644
--- a/apps/plugins/pdbox/PDa/intern/tabread4~.c
+++ b/apps/plugins/pdbox/PDa/intern/tabread4~.c
@@ -104,107 +104,3 @@ void tabread4_tilde_setup(void)
104 gensym("set"), A_SYMBOL, 0); 104 gensym("set"), A_SYMBOL, 0);
105} 105}
106 106
107#include <m_pd.h>
108#include <m_fixed.h>
109
110
111static t_class *tabread4_tilde_class;
112
113typedef struct _tabread4_tilde
114{
115 t_object x_obj;
116 int x_npoints;
117 t_sample *x_vec;
118 t_symbol *x_arrayname;
119 float x_f;
120} t_tabread4_tilde;
121
122static void *tabread4_tilde_new(t_symbol *s)
123{
124 t_tabread4_tilde *x = (t_tabread4_tilde *)pd_new(tabread4_tilde_class);
125 x->x_arrayname = s;
126 x->x_vec = 0;
127 outlet_new(&x->x_obj, gensym("signal"));
128 x->x_f = 0;
129 return (x);
130}
131
132static t_int *tabread4_tilde_perform(t_int *w)
133{
134 t_tabread4_tilde *x = (t_tabread4_tilde *)(w[1]);
135 t_sample *in = (t_sample *)(w[2]);
136 t_sample *out = (t_sample *)(w[3]);
137 int n = (int)(w[4]);
138 int maxindex;
139 t_sample *buf = x->x_vec, *fp;
140 int i;
141
142 maxindex = x->x_npoints - 3;
143
144 if (!buf) goto zero;
145
146 for (i = 0; i < n; i++)
147 {
148 t_time findex = ((long long) mult((*in++),ftofix(44.1)));
149 int index = fixtoi(findex);
150 t_sample frac;
151 // post("%d: index %d f %lld",index,findex,*in);
152
153 if (index < 1)
154 index = 1, frac = 0;
155 else if (index > maxindex)
156 index = maxindex, frac = 1;
157 else frac = findex - itofix(index);
158 fp = buf + index;
159 *out++ = fp[0] + mult(frac,fp[1]-fp[0]);
160 }
161 return (w+5);
162 zero:
163 while (n--) *out++ = 0;
164
165 return (w+5);
166}
167
168void tabread4_tilde_set(t_tabread4_tilde *x, t_symbol *s)
169{
170 t_garray *a;
171
172 x->x_arrayname = s;
173 if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
174 {
175 if (*s->s_name)
176 error("tabread4~: %s: no such array", x->x_arrayname->s_name);
177 x->x_vec = 0;
178 }
179 else if (!garray_getfloatarray(a, &x->x_npoints, &x->x_vec))
180 {
181 error("%s: bad template for tabread4~", x->x_arrayname->s_name);
182 x->x_vec = 0;
183 }
184 else garray_usedindsp(a);
185}
186
187static void tabread4_tilde_dsp(t_tabread4_tilde *x, t_signal **sp)
188{
189 tabread4_tilde_set(x, x->x_arrayname);
190
191 dsp_add(tabread4_tilde_perform, 4, x,
192 sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
193
194}
195
196static void tabread4_tilde_free(t_tabread4_tilde *x)
197{
198}
199
200void tabread4_tilde_setup(void)
201{
202 tabread4_tilde_class = class_new(gensym("tabread4~"),
203 (t_newmethod)tabread4_tilde_new, (t_method)tabread4_tilde_free,
204 sizeof(t_tabread4_tilde), 0, A_DEFSYM, 0);
205 CLASS_MAINSIGNALIN(tabread4_tilde_class, t_tabread4_tilde, x_f);
206 class_addmethod(tabread4_tilde_class, (t_method)tabread4_tilde_dsp,
207 gensym("dsp"), 0);
208 class_addmethod(tabread4_tilde_class, (t_method)tabread4_tilde_set,
209 gensym("set"), A_SYMBOL, 0);
210}