aboutsummaryrefslogtreecommitdiff
path: root/vsum.c
blob: d32db9a54ee340121da7870915a1b8dbce55a019 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "defines.h"

/*--------------- vsum ---------------*/

static t_class *vsum_class;

typedef struct _vsum
{
    t_object x_obj;
} t_vsum;


static void vsum_perform(t_vsum *x, t_symbol *s, int argc, t_atom *argv)
{
	t_float sum=0.;
	int i;
	for (i = 0; i < argc; i++)
	{
		sum+= atom_getfloat(&argv[i]);
	}
    outlet_float(x->x_obj.ob_outlet, sum);
}

static void *vsum_new()
{
	t_vsum *x=(t_vsum *)pd_new(vsum_class);
	outlet_new(&x->x_obj, gensym("float"));
	return (void *)x;
}

void vsum_setup(void)
{
    vsum_class = class_new(gensym("vsum"),
    	(t_newmethod)vsum_new, 0,
		sizeof(t_vsum), 
		CLASS_DEFAULT,
	    0);
    class_addlist(vsum_class, (t_method)vsum_perform);
}