~ubuntu-branches/ubuntu/wily/pd-smlib/wily

« back to all changes in this revision

Viewing changes to vsum.c

  • Committer: Bazaar Package Importer
  • Author(s): Hans-Christoph Steiner
  • Date: 2010-11-10 15:17:58 UTC
  • Revision ID: james.westby@ubuntu.com-20101110151758-3acjf69kiudo3gh4
Tags: upstream-0.12.1
ImportĀ upstreamĀ versionĀ 0.12.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "defines.h"
 
2
 
 
3
/*--------------- vsum ---------------*/
 
4
 
 
5
static t_class *vsum_class;
 
6
 
 
7
typedef struct _vsum
 
8
{
 
9
    t_object x_obj;
 
10
} t_vsum;
 
11
 
 
12
 
 
13
static void vsum_perform(t_vsum *x, t_symbol *s, int argc, t_atom *argv)
 
14
{
 
15
        float sum=0.f;
 
16
        int i;
 
17
        for (i = 0; i < argc; i++)
 
18
        {
 
19
                sum+= atom_getfloat(&argv[i]);
 
20
        }
 
21
    outlet_float(x->x_obj.ob_outlet, sum);
 
22
}
 
23
 
 
24
static void *vsum_new()
 
25
{
 
26
        t_vsum *x=(t_vsum *)pd_new(vsum_class);
 
27
        outlet_new(&x->x_obj, gensym("float"));
 
28
        return (void *)x;
 
29
}
 
30
 
 
31
void vsum_setup(void)
 
32
{
 
33
    vsum_class = class_new(gensym("vsum"),
 
34
        (t_newmethod)vsum_new, 0,
 
35
                sizeof(t_vsum), 
 
36
                CLASS_DEFAULT,
 
37
            0);
 
38
    class_addlist(vsum_class, (t_method)vsum_perform);
 
39
}
 
40