Fix pdbox makefile to actually take part in dependency generation
[kugel-rb.git] / apps / plugins / pdbox / PDa / extra / zerox~.c
blob4b928bcad60499ebb9fe36e01c99382b5b6e13f0
1 #include "../src/m_pd.h"
3 static t_class *zerox_class;
5 typedef struct _zerox
7 t_object x_obj;
8 t_sample x_f;
9 t_int x_zeros;
10 } t_zerox;
13 static t_int *zerox_perform(t_int *w)
15 t_zerox* x = (t_zerox*)w[1];
16 t_sample *in = (t_sample *)(w[2]);
17 int n = (int)(w[3]) ;
19 if (*in * x->x_f < 0) x->x_zeros++;
20 n--;
21 while (n--)
23 float f = *(in++);
24 x->x_zeros += f * *in < 0;
26 return (w+4);
29 static void zerox_dsp(t_zerox *x, t_signal **sp)
31 dsp_add(zerox_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
35 static void zerox_bang(t_zerox* x)
37 outlet_float(x->x_obj.ob_outlet,x->x_zeros);
38 x->x_zeros=0;
41 static void *zerox_new(void)
43 t_zerox *x = (t_zerox *)pd_new(zerox_class);
44 outlet_new(&x->x_obj, gensym("float"));
45 x->x_f = 0;
46 x->x_zeros=0;
47 return (x);
50 void zerox_tilde_setup(void)
52 zerox_class = class_new(gensym("zerox~"), (t_newmethod)zerox_new, 0,
53 sizeof(t_zerox), 0, A_DEFFLOAT, 0);
54 CLASS_MAINSIGNALIN(zerox_class, t_zerox, x_f);
55 class_addmethod(zerox_class, (t_method)zerox_dsp, gensym("dsp"), 0);
56 class_addbang(zerox_class, (t_method)zerox_bang);