static void *minmax_new(void) { t_minmax *x = (t_minmax *)pd_new(minmax_class); outlet_new((t_object *)x, &s_signal); outlet_new((t_object *)x, &s_signal); x->x_minout = outlet_new((t_object *)x, &s_float); x->x_maxout = outlet_new((t_object *)x, &s_float); minmax_reset(x); return (x); }
static void *minmax_new(void) { t_minmax *x = (t_minmax *)pd_new(minmax_class); inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); outlet_new((t_object *)x, &s_signal); outlet_new((t_object *)x, &s_signal); x->x_glist = canvas_getcurrent(); x->x_signalscalar = obj_findsignalscalar((t_object *)x, 1); x->x_minout = outlet_new((t_object *)x, &s_float); x->x_maxout = outlet_new((t_object *)x, &s_float); minmax_reset(x); return (x); }
/* Check if new measurement updates the 1st, 2nd or 3rd choice min. */ u32 minmax_running_min(struct minmax *m, u32 win, u32 t, u32 meas) { struct minmax_sample val = { .t = t, .v = meas }; if (unlikely(val.v <= m->s[0].v) || /* found new min? */ unlikely(val.t - m->s[2].t > win)) /* nothing left in window? */ return minmax_reset(m, t, meas); /* forget earlier samples */ if (unlikely(val.v <= m->s[1].v)) m->s[2] = m->s[1] = val; else if (unlikely(val.v <= m->s[2].v)) m->s[2] = val; return minmax_subwin_update(m, win, &val); }