File: vsum.c

package info (click to toggle)
pd-smlib 0.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 828 kB
  • ctags: 642
  • sloc: ansic: 2,982; makefile: 345
file content (40 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (2)
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);
}