1 #include "../src/m_pd.h"
2 #include <../src/m_fixed.h>
4 static t_class
*tabreceive_class
;
6 typedef struct _tabreceive
10 t_symbol
*x_arrayname
;
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]);
18 t_sample
*from
= x
->x_vec
;
19 if (from
) while (n
--) *out
++ = *from
++;
20 else while (n
--) *out
++ = 0;
24 static void tabreceive_dsp(t_tabreceive
*x
, t_signal
**sp
)
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
);
39 if (n
< vecsize
) vecsize
= n
;
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
);
49 outlet_new(&x
->x_obj
, &s_signal
);
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
,