~ubuntu-branches/ubuntu/saucy/pd-smlib/saucy

« back to all changes in this revision

Viewing changes to vabs.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
/*--------------- vabs ----------------*/
 
4
/* absolute values of a list of floats */
 
5
 
 
6
 
 
7
static t_class *vabs_class;
 
8
 
 
9
typedef struct _vabs
 
10
{
 
11
    t_object x_obj;
 
12
} t_vabs;
 
13
 
 
14
 
 
15
static void vabs_perform(t_vabs *x, t_symbol *s, int argc, t_atom *argv)
 
16
{
 
17
        int i;
 
18
        t_atom *ap,*app;
 
19
    ap = (t_atom *)getbytes(sizeof(t_atom)*argc);
 
20
        app=ap;
 
21
 
 
22
        for (i = 0; i < argc; i++)
 
23
        {
 
24
                float f=atom_getfloat(argv++);
 
25
                SETFLOAT(app, f>0?f:-f);
 
26
                app++;
 
27
        }
 
28
        outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap);
 
29
        freebytes(ap,argc);
 
30
}
 
31
 
 
32
static void *vabs_new()
 
33
{
 
34
        t_vabs *x=(t_vabs *)pd_new(vabs_class);
 
35
        outlet_new(&x->x_obj, gensym("list"));
 
36
        return (void *)x;
 
37
}
 
38
 
 
39
void vabs_setup(void)
 
40
{
 
41
    vabs_class = class_new(gensym("vabs"),
 
42
        (t_newmethod)vabs_new, 0,
 
43
                sizeof(t_vabs), 
 
44
                CLASS_DEFAULT,
 
45
            0);
 
46
    class_addlist(vabs_class, (t_method)vabs_perform);
 
47
}
 
48