From 086e6b358ad45bda0e6a948cfb7ea2d33ab7da5a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 10 Feb 2010 00:34:05 +0000 Subject: re-arranged into libdir and setup with the template Makefile+debian stuff. renabled vv+ and vv- as vvplus and vvminus svn path=/trunk/externals/smlib/; revision=13158 --- vftom.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 vftom.c (limited to 'vftom.c') diff --git a/vftom.c b/vftom.c new file mode 100644 index 0000000..6355006 --- /dev/null +++ b/vftom.c @@ -0,0 +1,49 @@ +#include "defines.h" + +/*--------------- vftom ----------------*/ + +static t_class *vftom_class; + +typedef struct _vftom +{ + t_object x_obj; +} t_vftom; + +float ftom(float f) +{ + return (float)(f > 0 ? 17.3123405046 * log(.12231220585 * f) : -1500); +} + +static void vftom_perform(t_vftom *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + SETFLOAT(app, ftom(atom_getfloat(argv++))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vftom_new() +{ + t_vftom *x=(t_vftom *)pd_new(vftom_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vftom_setup(void) +{ + vftom_class = class_new(gensym("vftom"), + (t_newmethod)vftom_new, 0, + sizeof(t_vftom), + CLASS_DEFAULT, + 0); + class_addlist(vftom_class, (t_method)vftom_perform); +} + -- cgit v1.2.1