1 #include "../src/m_pd.h"
3 static t_class
*zerox_class
;
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]);
19 if (*in
* x
->x_f
< 0) x
->x_zeros
++;
24 x
->x_zeros
+= f
* *in
< 0;
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
);
41 static void *zerox_new(void)
43 t_zerox
*x
= (t_zerox
*)pd_new(zerox_class
);
44 outlet_new(&x
->x_obj
, gensym("float"));
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
);