summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/d_dac.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/src/d_dac.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/src/d_dac.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/d_dac.c184
1 files changed, 0 insertions, 184 deletions
diff --git a/apps/plugins/pdbox/PDa/src/d_dac.c b/apps/plugins/pdbox/PDa/src/d_dac.c
index ce7c7127f0..1606b3a1f2 100644
--- a/apps/plugins/pdbox/PDa/src/d_dac.c
+++ b/apps/plugins/pdbox/PDa/src/d_dac.c
@@ -182,187 +182,3 @@ void d_dac_setup(void)
182 adc_setup(); 182 adc_setup();
183} 183}
184 184
185/* Copyright (c) 1997-1999 Miller Puckette.
186* For information on usage and redistribution, and for a DISCLAIMER OF ALL
187* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
188
189/* The dac~ and adc~ routines.
190*/
191
192#include "m_pd.h"
193#include "s_stuff.h"
194
195/* ----------------------------- dac~ --------------------------- */
196static t_class *dac_class;
197
198typedef struct _dac
199{
200 t_object x_obj;
201 t_int x_n;
202 t_int *x_vec;
203 float x_f;
204} t_dac;
205
206static void *dac_new(t_symbol *s, int argc, t_atom *argv)
207{
208 t_dac *x = (t_dac *)pd_new(dac_class);
209 t_atom defarg[2], *ap;
210 int i;
211 if (!argc)
212 {
213 argv = defarg;
214 argc = 2;
215 SETFLOAT(&defarg[0], 1);
216 SETFLOAT(&defarg[1], 2);
217 }
218 x->x_n = argc;
219 x->x_vec = (t_int *)getbytes(argc * sizeof(*x->x_vec));
220 for (i = 0; i < argc; i++)
221 x->x_vec[i] = atom_getintarg(i, argc, argv);
222 for (i = 1; i < argc; i++)
223 inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
224 x->x_f = 0;
225 return (x);
226}
227
228static void dac_dsp(t_dac *x, t_signal **sp)
229{
230 t_int i, *ip;
231 t_signal **sp2;
232 for (i = x->x_n, ip = x->x_vec, sp2 = sp; i--; ip++, sp2++)
233 {
234 int ch = *ip - 1;
235 if ((*sp2)->s_n != DEFDACBLKSIZE)
236 error("dac~: bad vector size");
237 else if (ch >= 0 && ch < sys_get_outchannels())
238 dsp_add(plus_perform, 4, sys_soundout + DEFDACBLKSIZE*ch,
239 (*sp2)->s_vec, sys_soundout + DEFDACBLKSIZE*ch, DEFDACBLKSIZE);
240 }
241}
242
243static void dac_free(t_dac *x)
244{
245 freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec));
246}
247
248static void dac_setup(void)
249{
250 dac_class = class_new(gensym("dac~"), (t_newmethod)dac_new,
251 (t_method)dac_free, sizeof(t_dac), 0, A_GIMME, 0);
252 CLASS_MAINSIGNALIN(dac_class, t_dac, x_f);
253 class_addmethod(dac_class, (t_method)dac_dsp, gensym("dsp"), A_CANT, 0);
254 class_sethelpsymbol(dac_class, gensym("adc~_dac~"));
255}
256
257/* ----------------------------- adc~ --------------------------- */
258static t_class *adc_class;
259
260typedef struct _adc
261{
262 t_object x_obj;
263 t_int x_n;
264 t_int *x_vec;
265} t_adc;
266
267static void *adc_new(t_symbol *s, int argc, t_atom *argv)
268{
269 t_adc *x = (t_adc *)pd_new(adc_class);
270 t_atom defarg[2], *ap;
271 int i;
272 if (!argc)
273 {
274 argv = defarg;
275 argc = 2;
276 SETFLOAT(&defarg[0], 1);
277 SETFLOAT(&defarg[1], 2);
278 }
279 x->x_n = argc;
280 x->x_vec = (t_int *)getbytes(argc * sizeof(*x->x_vec));
281 for (i = 0; i < argc; i++)
282 x->x_vec[i] = atom_getintarg(i, argc, argv);
283 for (i = 0; i < argc; i++)
284 outlet_new(&x->x_obj, &s_signal);
285 return (x);
286}
287
288t_int *copy_perform(t_int *w)
289{
290 t_float *in1 = (t_float *)(w[1]);
291 t_float *out = (t_float *)(w[2]);
292 int n = (int)(w[3]);
293 while (n--) *out++ = *in1++;
294 return (w+4);
295}
296
297t_int *copy_perf8(t_int *w)
298{
299 t_float *in1 = (t_float *)(w[1]);
300 t_float *out = (t_float *)(w[2]);
301 int n = (int)(w[3]);
302
303 for (; n; n -= 8, in1 += 8, out += 8)
304 {
305 float f0 = in1[0];
306 float f1 = in1[1];
307 float f2 = in1[2];
308 float f3 = in1[3];
309 float f4 = in1[4];
310 float f5 = in1[5];
311 float f6 = in1[6];
312 float f7 = in1[7];
313
314 out[0] = f0;
315 out[1] = f1;
316 out[2] = f2;
317 out[3] = f3;
318 out[4] = f4;
319 out[5] = f5;
320 out[6] = f6;
321 out[7] = f7;
322 }
323 return (w+4);
324}
325
326void dsp_add_copy(t_sample *in, t_sample *out, int n)
327{
328 if (n&7)
329 dsp_add(copy_perform, 3, in, out, n);
330 else
331 dsp_add(copy_perf8, 3, in, out, n);
332}
333
334static void adc_dsp(t_adc *x, t_signal **sp)
335{
336 t_int i, *ip;
337 t_signal **sp2;
338 for (i = x->x_n, ip = x->x_vec, sp2 = sp; i--; ip++, sp2++)
339 {
340 int ch = *ip - 1;
341 if ((*sp2)->s_n != DEFDACBLKSIZE)
342 error("adc~: bad vector size");
343 else if (ch >= 0 && ch < sys_get_inchannels())
344 dsp_add_copy(sys_soundin + DEFDACBLKSIZE*ch,
345 (*sp2)->s_vec, DEFDACBLKSIZE);
346 else dsp_add_zero((*sp2)->s_vec, DEFDACBLKSIZE);
347 }
348}
349
350static void adc_free(t_adc *x)
351{
352 freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec));
353}
354
355static void adc_setup(void)
356{
357 adc_class = class_new(gensym("adc~"), (t_newmethod)adc_new,
358 (t_method)adc_free, sizeof(t_adc), 0, A_GIMME, 0);
359 class_addmethod(adc_class, (t_method)adc_dsp, gensym("dsp"), A_CANT, 0);
360 class_sethelpsymbol(adc_class, gensym("adc~_dac~"));
361}
362
363void d_dac_setup(void)
364{
365 dac_setup();
366 adc_setup();
367}
368