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

« back to all changes in this revision

Viewing changes to vdbtorms.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
/*--------------- vdbtorms ----------------*/
 
4
 
 
5
static t_class *vdbtorms_class;
 
6
 
 
7
typedef struct _vdbtorms
 
8
{
 
9
    t_object x_obj;
 
10
} t_vdbtorms;
 
11
 
 
12
float dbtorms(float f)
 
13
{
 
14
    if (f <= 0)
 
15
        return(0);
 
16
    else
 
17
    {
 
18
        if (f > 485)
 
19
            f = 485;
 
20
    }
 
21
    return (float)(exp((LOGTEN * 0.05) * (f-100.)));
 
22
}
 
23
 
 
24
static void vdbtorms_perform(t_vdbtorms *x, t_symbol *s, int argc, t_atom *argv)
 
25
{
 
26
        int i;
 
27
        t_atom *ap,*app;
 
28
    ap = (t_atom *)getbytes(sizeof(t_atom)*argc);
 
29
        app=ap;
 
30
 
 
31
        for (i = 0; i < argc; i++)
 
32
        {
 
33
                SETFLOAT(app, dbtorms(atom_getfloat(argv++)));
 
34
                app++;
 
35
        }
 
36
        outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap);
 
37
    freebytes(ap,argc);
 
38
}
 
39
 
 
40
static void *vdbtorms_new()
 
41
{
 
42
        t_vdbtorms *x=(t_vdbtorms *)pd_new(vdbtorms_class);
 
43
        outlet_new(&x->x_obj, gensym("list"));
 
44
        return (void *)x;
 
45
}
 
46
 
 
47
void vdbtorms_setup(void)
 
48
{
 
49
    vdbtorms_class = class_new(gensym("vdbtorms"),
 
50
        (t_newmethod)vdbtorms_new, 0,
 
51
                sizeof(t_vdbtorms), 
 
52
                CLASS_DEFAULT,
 
53
            0);
 
54
    class_addlist(vdbtorms_class, (t_method)vdbtorms_perform);
 
55
}
 
56