Fix pdbox makefile to actually take part in dependency generation
[kugel-rb.git] / apps / plugins / pdbox / PDa / intern / tabreceive~.c
blobaa84188325e5a52b42e70b87b9a17e50aa4cb81c
1 #include "../src/m_pd.h"
2 #include <../src/m_fixed.h>
4 static t_class *tabreceive_class;
6 typedef struct _tabreceive
8 t_object x_obj;
9 t_sample *x_vec;
10 t_symbol *x_arrayname;
11 } t_tabreceive;
13 static t_int *tabreceive_perform(t_int *w)
15 t_tabreceive *x = (t_tabreceive *)(w[1]);
16 t_sample *out = (t_sample *)(w[2]);
17 int n = w[3];
18 t_sample *from = x->x_vec;
19 if (from) while (n--) *out++ = *from++;
20 else while (n--) *out++ = 0;
21 return (w+4);
24 static void tabreceive_dsp(t_tabreceive *x, t_signal **sp)
26 t_garray *a;
27 int vecsize;
29 if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
31 if (*x->x_arrayname->s_name)
32 error("tabsend~: %s: no such array", x->x_arrayname->s_name);
34 else if (!garray_getfloatarray(a, &vecsize, &x->x_vec))
35 error("%s: bad template for tabreceive~", x->x_arrayname->s_name);
36 else
38 int n = sp[0]->s_n;
39 if (n < vecsize) vecsize = n;
40 garray_usedindsp(a);
41 dsp_add(tabreceive_perform, 3, x, sp[0]->s_vec, vecsize);
45 static void *tabreceive_new(t_symbol *s)
47 t_tabreceive *x = (t_tabreceive *)pd_new(tabreceive_class);
48 x->x_arrayname = s;
49 outlet_new(&x->x_obj, &s_signal);
50 return (x);
53 void tabreceive_tilde_setup(void)
55 tabreceive_class = class_new(gensym("tabreceive~"),
56 (t_newmethod)tabreceive_new, 0,
57 sizeof(t_tabreceive), 0, A_DEFSYM, 0);
58 class_addmethod(tabreceive_class, (t_method)tabreceive_dsp,
59 gensym("dsp"), 0);