aboutsummaryrefslogtreecommitdiff
path: root/vstd.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-02-10 00:34:05 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-02-10 00:34:05 +0000
commit086e6b358ad45bda0e6a948cfb7ea2d33ab7da5a (patch)
treeb87b0adfbfd8f9b9439d8bf528b63b64f23dce03 /vstd.c
parent98e3e1214cf71a62b2de938c9c7e07f6bdd0090c (diff)
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
Diffstat (limited to 'vstd.c')
-rw-r--r--vstd.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/vstd.c b/vstd.c
new file mode 100644
index 0000000..538cb94
--- /dev/null
+++ b/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);
+}
+