3
/*--------------- lmax ---------------*/
5
static t_class *lmax_class;
16
static void lmax_perform(t_lmax *x, t_float in)
18
x->m_max=(in > x->m_max) ? in : x->m_max * x->m_c_leak + in * x->m_leak;
19
outlet_float(x->x_obj.ob_outlet, x->m_max);
22
static void lmax_setHalfDecay(t_lmax *x, t_float halfDecayTime)
24
x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime));
25
x->m_leak=1.0f-x->m_c_leak;
28
static void lmax_clear(t_lmax *x)
33
static void *lmax_new( t_float halfDecayTime)
35
t_lmax *x=(t_lmax *)pd_new(lmax_class);
36
outlet_new(&x->x_obj, gensym("float"));
38
lmax_setHalfDecay(x, halfDecayTime);
46
lmax_class = class_new(gensym("lmax"),
47
(t_newmethod)lmax_new, 0,
51
class_addfloat(lmax_class, (t_method)lmax_perform);
52
class_addmethod(lmax_class, (t_method)lmax_clear,
53
gensym("clear"), A_GIMME, NULL);
54
class_addmethod(lmax_class, (t_method)lmax_setHalfDecay,
55
gensym("decay"), A_DEFFLOAT, NULL);