From da1f0065d07250b86b9a761b012987e4825f491f Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 28 Nov 2005 16:53:25 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r4068, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/smlib/; revision=4069 --- source/vmtof.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 source/vmtof.c (limited to 'source/vmtof.c') diff --git a/source/vmtof.c b/source/vmtof.c new file mode 100644 index 0000000..828dcb6 --- /dev/null +++ b/source/vmtof.c @@ -0,0 +1,51 @@ +#include "defines.h" + +/*--------------- vmtof ----------------*/ + +static t_class *vmtof_class; + +typedef struct _vmtof +{ + t_object x_obj; +} t_vmtof; + +float mtof(float f) +{ + if (f <= -1500) return(0); + else if (f > 1499) return(mtof(1499)); + else return (float)(8.17579891564 * exp(.0577622650 * f)); +} + +static void vmtof_perform(t_vmtof *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, mtof(atom_getfloat(argv++))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vmtof_new() +{ + t_vmtof *x=(t_vmtof *)pd_new(vmtof_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vmtof_setup(void) +{ + vmtof_class = class_new(gensym("vmtof"), + (t_newmethod)vmtof_new, 0, + sizeof(t_vmtof), + CLASS_DEFAULT, + 0); + class_addlist(vmtof_class, (t_method)vmtof_perform); +} + -- cgit v1.2.1