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/vcog.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 source/vcog.c (limited to 'source/vcog.c') diff --git a/source/vcog.c b/source/vcog.c new file mode 100644 index 0000000..1dd68a4 --- /dev/null +++ b/source/vcog.c @@ -0,0 +1,43 @@ +#include "defines.h" + +/*--------------- vcog ---------------*/ + +static t_class *vcog_class; + +typedef struct _vcog +{ + t_object x_obj; +} t_vcog; + + +static void vcog_perform(t_vcog *x, t_symbol *s, int argc, t_atom *argv) +{ + float sum=0.f; + float wsum=0.0f; + int i; + for (i = 0; i < argc; i++) + { + float tmp=atom_getfloat(&argv[i]); + sum+= tmp; + wsum+= tmp*i; + } + if (sum!=0.0f) outlet_float(x->x_obj.ob_outlet, 1.0f+(wsum/sum)); +} + +static void *vcog_new( t_float halfDecayTime) +{ + t_vcog *x=(t_vcog *)pd_new(vcog_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vcog_setup(void) +{ + vcog_class = class_new(gensym("vcog"), + (t_newmethod)vcog_new, 0, + sizeof(t_vcog), + CLASS_DEFAULT, + 0); + class_addlist(vcog_class, (t_method)vcog_perform); +} + -- cgit v1.2.1