diff options
-rw-r--r-- | average.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -41,9 +41,15 @@ void average_float(t_average *x, t_floatarg n) average_bang(x); } -void average_total(t_average *x, t_floatarg n) +void average_total(t_average *x, t_float f) { - x->a_total = (int)n; + if (f) x->a_total = (int)f; + else x->a_total = 10; + if (x->a_total > MAX_NUMBERS) { + logpost(x, 2, "[average]: argument set max numbers greater than %i, setting to %i", + MAX_NUMBERS, MAX_NUMBERS); + x->a_total = MAX_NUMBERS; + } } void average_reset(t_average *x, t_floatarg newVal) @@ -64,13 +70,7 @@ void *average_new(t_floatarg f) /* init vals in struc */ x->t_out1 = outlet_new(&x->x_obj, 0); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl1")); average_clear(x); - if (f) x->a_total = (int)f; - else x->a_total = 10; - if (x->a_total > MAX_NUMBERS) { - logpost(x, 2, "[average]: argument set max numbers greater than %i, setting to %i", - MAX_NUMBERS, MAX_NUMBERS); - x->a_total = MAX_NUMBERS; - } + average_total(x, f); x->a_whichNum = 0; return (x); } |