1 #include "../src/m_pd.h"
2 #include <../src/m_fixed.h>
20 t_class
*sighip_class
;
21 static void sighip_ft1(t_sighip
*x
, t_floatarg f
);
23 static void *sighip_new(t_floatarg f
)
25 t_sighip
*x
= (t_sighip
*)pd_new(sighip_class
);
26 inlet_new(&x
->x_obj
, &x
->x_obj
.ob_pd
, gensym("float"), gensym("ft1"));
27 outlet_new(&x
->x_obj
, gensym("signal"));
29 x
->x_ctl
= &x
->x_cspace
;
36 static void sighip_ft1(t_sighip
*x
, t_floatarg f
)
39 if (f
< 0.001) f
= 10;
41 coeff
= 1 - f
* (2 * 3.14159) / x
->x_sr
;
42 if (coeff
< 0) coeff
= 0;
43 x
->x_ctl
->c_coef
= ftofix(coeff
);
46 static t_int
*sighip_perform(t_int
*w
)
48 t_sample
*in
= (t_sample
*)(w
[1]);
49 t_sample
*out
= (t_sample
*)(w
[2]);
50 t_hipctl
*c
= (t_hipctl
*)(w
[3]);
51 int n
= (t_int
)(w
[4]);
53 t_sample last
= c
->c_x
;
54 t_sample coef
= c
->c_coef
;
55 for (i
= 0; i
< n
; i
++)
57 t_sample
new = *in
++ + mult(coef
,last
);
61 if (PD_BADFLOAT(last
))
67 static void sighip_dsp(t_sighip
*x
, t_signal
**sp
)
69 x
->x_sr
= sp
[0]->s_sr
;
70 sighip_ft1(x
, x
->x_hz
);
71 dsp_add(sighip_perform
, 4,
72 sp
[0]->s_vec
, sp
[1]->s_vec
,
73 x
->x_ctl
, sp
[0]->s_n
);
77 static void sighip_clear(t_sighip
*x
, t_floatarg q
)
85 void hip_tilde_setup(void)
87 sighip_class
= class_new(gensym("hip~"), (t_newmethod
)sighip_new
, 0,
88 sizeof(t_sighip
), 0, A_DEFFLOAT
, 0);
89 CLASS_MAINSIGNALIN(sighip_class
, t_sighip
, x_f
);
90 class_addmethod(sighip_class
, (t_method
)sighip_dsp
, gensym("dsp"), 0);
91 class_addmethod(sighip_class
, (t_method
)sighip_ft1
,
92 gensym("ft1"), A_FLOAT
, 0);
93 class_addmethod(sighip_class
, (t_method
)sighip_clear
, gensym("clear"), 0);
94 class_sethelpsymbol(sighip_class
, gensym("lop~-help.pd"));