aboutsummaryrefslogtreecommitdiff
path: root/vmin.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 /vmin.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 'vmin.c')
-rw-r--r--vmin.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/vmin.c b/vmin.c
new file mode 100644
index 0000000..a0b578e
--- /dev/null
+++ b/vmin.c
@@ -0,0 +1,52 @@
+#include "defines.h"
+
+/*--------------- vmin ---------------*/
+/* maximum value in a list of float
+ and its location (index)
+*/
+
+static t_class *vmin_class;
+
+typedef struct _vmin
+{
+ t_object x_obj;
+ t_outlet *m_out_maxi;
+} t_vmin;
+
+
+static void vmin_perform(t_vmin *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i;
+ int mini;
+ float min=MAXFLOAT;
+ for (i = 0; i < argc; i++)
+ {
+ float f=atom_getfloat(&argv[i]);
+ if (f<min)
+ {
+ min=f;
+ mini=i;
+ }
+ }
+ outlet_float(x->x_obj.ob_outlet, min);
+ outlet_float(x->m_out_maxi, (float)(mini+1));
+}
+
+static void *vmin_new( t_float halfDecayTime)
+{
+ t_vmin *x=(t_vmin *)pd_new(vmin_class);
+ outlet_new(&x->x_obj, gensym("float"));
+ x->m_out_maxi=outlet_new(&x->x_obj, gensym("float"));
+ return (void *)x;
+}
+
+void vmin_setup(void)
+{
+ vmin_class = class_new(gensym("vmin"),
+ (t_newmethod)vmin_new, 0,
+ sizeof(t_vmin),
+ CLASS_DEFAULT,
+ 0);
+ class_addlist(vmin_class, (t_method)vmin_perform);
+}
+