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/vstd.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 source/vstd.c (limited to 'source/vstd.c') diff --git a/source/vstd.c b/source/vstd.c new file mode 100644 index 0000000..538cb94 --- /dev/null +++ b/source/vstd.c @@ -0,0 +1,45 @@ +#include "defines.h" + +/*--------------- vstd ---------------*/ + +static t_class *vstd_class; + +typedef struct _vstd +{ + t_object x_obj; +} t_vstd; + + +static void vstd_perform(t_vstd *x, t_symbol *s, int argc, t_atom *argv) +{ + float sumsq=0.0f; + float sum=0.0f; + int i; + for (i = 0; i < argc; i++) + { + float tmp=atom_getfloat(&argv[i]); + sumsq+= tmp*tmp; + sum+=tmp; + } + sumsq/=argc; + sum/=argc; + outlet_float(x->x_obj.ob_outlet, (float)sqrtf(sumsq-sum*sum)); +} + +static void *vstd_new( t_float halfDecayTime) +{ + t_vstd *x=(t_vstd *)pd_new(vstd_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vstd_setup(void) +{ + vstd_class = class_new(gensym("vstd"), + (t_newmethod)vstd_new, 0, + sizeof(t_vstd), + CLASS_DEFAULT, + 0); + class_addlist(vstd_class, (t_method)vstd_perform); +} + -- cgit v1.2.1