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 --- vrms.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 vrms.c (limited to 'vrms.c') diff --git a/vrms.c b/vrms.c new file mode 100644 index 0000000..52b8d6d --- /dev/null +++ b/vrms.c @@ -0,0 +1,41 @@ +#include "defines.h" + +/*--------------- vrms ---------------*/ + +static t_class *vrms_class; + +typedef struct _vrms +{ + t_object x_obj; +} t_vrms; + + +static void vrms_perform(t_vrms *x, t_symbol *s, int argc, t_atom *argv) +{ + float sum=0.f; + int i; + for (i = 0; i < argc; i++) + { + float tmp=atom_getfloat(&argv[i]); + sum+= tmp*tmp; + } + outlet_float(x->x_obj.ob_outlet, (float)sqrtf(sum/argc)); +} + +static void *vrms_new( t_float halfDecayTime) +{ + t_vrms *x=(t_vrms *)pd_new(vrms_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vrms_setup(void) +{ + vrms_class = class_new(gensym("vrms"), + (t_newmethod)vrms_new, 0, + sizeof(t_vrms), + CLASS_DEFAULT, + 0); + class_addlist(vrms_class, (t_method)vrms_perform); +} + -- cgit v1.2.1